[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.22-985-g3c00f00

darin at chromium.org darin at chromium.org
Wed Mar 17 18:32:23 UTC 2010


The following commit has been merged in the webkit-1.1 branch:
commit 83853ec7af2cf0f4937a743fe99371b6592017b1
Author: darin at chromium.org <darin at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Mar 11 00:59:11 2010 +0000

    2010-03-10  Darin Fisher  <darin at chromium.org>
    
            Reviewed by Jeremy Orlow.
    
            Add API wrapper for WebCore::SerializedScriptValue
            https://bugs.webkit.org/show_bug.cgi?id=35988
    
            WebSerializedScriptValue is a wrapper around SerializedScriptValue.
    
            WebPrivatePtr is used to simplify wrapping reference counted WebCore
            types.  This class is used to cleanup WebHistoryItem, and will be used
            to clean up other classes in the WebKit API in a follow-up patch.
    
            * WebKit.gyp:
            * public/WebHistoryItem.h:
            * public/WebPrivatePtr.h: Added.
            * public/WebSerializedScriptValue.h: Added.
            * src/WebHistoryItem.cpp:
            * src/WebSerializedScriptValue.cpp: Added.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@55820 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/chromium/ChangeLog b/WebKit/chromium/ChangeLog
index 0a0c65d..44a93ee 100644
--- a/WebKit/chromium/ChangeLog
+++ b/WebKit/chromium/ChangeLog
@@ -1,3 +1,23 @@
+2010-03-10  Darin Fisher  <darin at chromium.org>
+
+        Reviewed by Jeremy Orlow.
+
+        Add API wrapper for WebCore::SerializedScriptValue
+        https://bugs.webkit.org/show_bug.cgi?id=35988
+
+        WebSerializedScriptValue is a wrapper around SerializedScriptValue.
+
+        WebPrivatePtr is used to simplify wrapping reference counted WebCore
+        types.  This class is used to cleanup WebHistoryItem, and will be used
+        to clean up other classes in the WebKit API in a follow-up patch.
+
+        * WebKit.gyp:
+        * public/WebHistoryItem.h:
+        * public/WebPrivatePtr.h: Added.
+        * public/WebSerializedScriptValue.h: Added.
+        * src/WebHistoryItem.cpp:
+        * src/WebSerializedScriptValue.cpp: Added.
+
 2010-03-10  Sanjeev Radhakrishnan  <sanjeevr at chromium.org>
 
         Reviewed by Darin Fisher.
diff --git a/WebKit/chromium/WebKit.gyp b/WebKit/chromium/WebKit.gyp
index 3f3b9fb..d23d205 100644
--- a/WebKit/chromium/WebKit.gyp
+++ b/WebKit/chromium/WebKit.gyp
@@ -159,6 +159,7 @@
                 'public/WebPoint.h',
                 'public/WebPopupMenu.h',
                 'public/WebPopupMenuInfo.h',
+                'public/WebPrivatePtr.h',
                 'public/WebRange.h',
                 'public/WebRect.h',
                 'public/WebRegularExpression.h',
@@ -169,6 +170,7 @@
                 'public/WebSearchableFormData.h',
                 'public/WebSecurityOrigin.h',
                 'public/WebSecurityPolicy.h',
+                'public/WebSerializedScriptValue.h',
                 'public/WebSettings.h',
                 'public/WebSharedWorker.h',
                 'public/WebSharedWorkerRepository.h',
@@ -349,6 +351,7 @@
                 'src/WebSearchableFormData.cpp',
                 'src/WebSecurityOrigin.cpp',
                 'src/WebSecurityPolicy.cpp',
+                'src/WebSerializedScriptValue.cpp',
                 'src/WebSettingsImpl.cpp',
                 'src/WebSettingsImpl.h',
                 'src/WebSharedWorkerImpl.cpp',
diff --git a/WebKit/chromium/public/WebHistoryItem.h b/WebKit/chromium/public/WebHistoryItem.h
index e248a61..015f5d7 100644
--- a/WebKit/chromium/public/WebHistoryItem.h
+++ b/WebKit/chromium/public/WebHistoryItem.h
@@ -32,17 +32,14 @@
 #define WebHistoryItem_h
 
 #include "WebCommon.h"
+#include "WebPrivatePtr.h"
 
-#if WEBKIT_IMPLEMENTATION
 namespace WebCore { class HistoryItem; }
-namespace WTF { template <typename T> class PassRefPtr; }
-#endif
 
 namespace WebKit {
-
-class WebHistoryItemPrivate;
 class WebHTTPBody;
 class WebString;
+class WebSerializedScriptValue;
 struct WebPoint;
 template <typename T> class WebVector;
 
@@ -55,8 +52,8 @@ class WebHistoryItem {
 public:
     ~WebHistoryItem() { reset(); }
 
-    WebHistoryItem() : m_private(0) { }
-    WebHistoryItem(const WebHistoryItem& h) : m_private(0) { assign(h); }
+    WebHistoryItem() { }
+    WebHistoryItem(const WebHistoryItem& h) { assign(h); }
     WebHistoryItem& operator=(const WebHistoryItem& h)
     {
         assign(h);
@@ -67,7 +64,7 @@ public:
     WEBKIT_API void reset();
     WEBKIT_API void assign(const WebHistoryItem&);
 
-    bool isNull() const { return !m_private; }
+    bool isNull() const { return m_private.isNull(); }
 
     WEBKIT_API WebString urlString() const;
     WEBKIT_API void setURLString(const WebString&);
@@ -108,6 +105,9 @@ public:
     WEBKIT_API long long documentSequenceNumber() const;
     WEBKIT_API void setDocumentSequenceNumber(long long);
 
+    WEBKIT_API WebSerializedScriptValue stateObject() const;
+    WEBKIT_API void setStateObject(const WebSerializedScriptValue&);
+
     WEBKIT_API WebString httpContentType() const;
     WEBKIT_API void setHTTPContentType(const WebString&);
 
@@ -125,9 +125,8 @@ public:
 #endif
 
 private:
-    void assign(WebHistoryItemPrivate*);
     void ensureMutable();
-    WebHistoryItemPrivate* m_private;
+    WebPrivatePtr<WebCore::HistoryItem> m_private;
 };
 
 } // namespace WebKit
diff --git a/WebKit/chromium/public/WebPrivatePtr.h b/WebKit/chromium/public/WebPrivatePtr.h
new file mode 100644
index 0000000..48b469e
--- /dev/null
+++ b/WebKit/chromium/public/WebPrivatePtr.h
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebPrivatePtr_h
+#define WebPrivatePtr_h
+
+#if WEBKIT_IMPLEMENTATION
+#include <wtf/PassRefPtr.h>
+#endif
+
+namespace WebKit {
+
+// This class is an implementation detail of the WebKit API.  It exists
+// to help simplify the implementation of WebKit interfaces that merely
+// wrap a reference counted WebCore class.
+template <typename T>
+class WebPrivatePtr {
+public:
+    WebPrivatePtr() : m_ptr(0) { }
+
+    bool isNull() const { return !m_ptr; }
+
+#if WEBKIT_IMPLEMENTATION
+    WebPrivatePtr(const PassRefPtr<T>& prp)
+        : m_ptr(prp.releaseRef())
+    {
+    }
+
+    void reset()
+    {
+        assign(0);
+    }
+
+    void assign(T* p)
+    {
+        // p is already ref'd for us by the caller
+        if (m_ptr)
+            m_ptr->deref();
+        m_ptr = p;
+    }
+
+    WebPrivatePtr<T>& operator=(const WebPrivatePtr<T>& other)
+    {
+        T* p = other.m_ptr;
+        if (p)
+            p->ref();
+        assign(p);
+        return *this;
+    }
+
+    WebPrivatePtr<T>& operator=(const PassRefPtr<T>& prp)
+    {
+        assign(prp.releaseRef());
+        return *this;
+    }
+
+    T* get() const
+    {
+        return m_ptr;
+    }
+
+    T* operator->() const
+    {
+        ASSERT(m_ptr);
+        return m_ptr;
+    }
+#endif
+
+private:
+    T* m_ptr;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/WebKit/chromium/public/WebSerializedScriptValue.h b/WebKit/chromium/public/WebSerializedScriptValue.h
new file mode 100644
index 0000000..dbcb92a
--- /dev/null
+++ b/WebKit/chromium/public/WebSerializedScriptValue.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef WebSerializedScriptValue_h
+#define WebSerializedScriptValue_h
+
+#include "WebCommon.h"
+#include "WebPrivatePtr.h"
+
+namespace WebCore { class SerializedScriptValue; }
+
+namespace WebKit {
+class WebString;
+
+class WebSerializedScriptValue {
+public:
+    ~WebSerializedScriptValue() { reset(); }
+
+    WebSerializedScriptValue() { }
+    WebSerializedScriptValue(const WebSerializedScriptValue& d) { assign(d); }
+    WebSerializedScriptValue& operator=(const WebSerializedScriptValue& d)
+    {
+        assign(d);
+        return *this;
+    }
+
+    WEBKIT_API static WebSerializedScriptValue fromString(const WebString&);
+
+    WEBKIT_API void reset();
+    WEBKIT_API void assign(const WebSerializedScriptValue&);
+
+    bool isNull() const { return m_private.isNull(); }
+
+    // Returns a string representation of the WebSerializedScriptValue.
+    WEBKIT_API WebString toString() const;
+
+#if WEBKIT_IMPLEMENTATION
+    WebSerializedScriptValue(const WTF::PassRefPtr<WebCore::SerializedScriptValue>&);
+    WebSerializedScriptValue& operator=(const WTF::PassRefPtr<WebCore::SerializedScriptValue>&);
+    operator WTF::PassRefPtr<WebCore::SerializedScriptValue>() const;
+#endif
+
+private:
+    WebPrivatePtr<WebCore::SerializedScriptValue> m_private;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/WebKit/chromium/src/WebHistoryItem.cpp b/WebKit/chromium/src/WebHistoryItem.cpp
index 4ca8cc7..45e4472 100644
--- a/WebKit/chromium/src/WebHistoryItem.cpp
+++ b/WebKit/chromium/src/WebHistoryItem.cpp
@@ -37,6 +37,7 @@
 
 #include "WebHTTPBody.h"
 #include "WebPoint.h"
+#include "WebSerializedScriptValue.h"
 #include "WebString.h"
 #include "WebVector.h"
 
@@ -44,30 +45,23 @@ using namespace WebCore;
 
 namespace WebKit {
 
-class WebHistoryItemPrivate : public HistoryItem {
-};
-
 void WebHistoryItem::initialize()
 {
-    assign(static_cast<WebHistoryItemPrivate*>(HistoryItem::create().releaseRef()));
+    m_private = HistoryItem::create();
 }
 
 void WebHistoryItem::reset()
 {
-    assign(0);
+    m_private.reset();
 }
 
 void WebHistoryItem::assign(const WebHistoryItem& other)
 {
-    WebHistoryItemPrivate* p = const_cast<WebHistoryItemPrivate*>(other.m_private);
-    if (p)
-        p->ref();
-    assign(p);
+    m_private = other.m_private;
 }
 
 WebString WebHistoryItem::urlString() const
 {
-    ASSERT(!isNull());
     return m_private->urlString();
 }
 
@@ -79,7 +73,6 @@ void WebHistoryItem::setURLString(const WebString& url)
 
 WebString WebHistoryItem::originalURLString() const
 {
-    ASSERT(!isNull());
     return m_private->originalURLString();
 }
 
@@ -91,7 +84,6 @@ void WebHistoryItem::setOriginalURLString(const WebString& originalURLString)
 
 WebString WebHistoryItem::referrer() const
 {
-    ASSERT(!isNull());
     return m_private->referrer();
 }
 
@@ -103,7 +95,6 @@ void WebHistoryItem::setReferrer(const WebString& referrer)
 
 WebString WebHistoryItem::target() const
 {
-    ASSERT(!isNull());
     return m_private->target();
 }
 
@@ -115,7 +106,6 @@ void WebHistoryItem::setTarget(const WebString& target)
 
 WebString WebHistoryItem::parent() const
 {
-    ASSERT(!isNull());
     return m_private->parent();
 }
 
@@ -127,7 +117,6 @@ void WebHistoryItem::setParent(const WebString& parent)
 
 WebString WebHistoryItem::title() const
 {
-    ASSERT(!isNull());
     return m_private->title();
 }
 
@@ -139,7 +128,6 @@ void WebHistoryItem::setTitle(const WebString& title)
 
 WebString WebHistoryItem::alternateTitle() const
 {
-    ASSERT(!isNull());
     return m_private->alternateTitle();
 }
 
@@ -151,7 +139,6 @@ void WebHistoryItem::setAlternateTitle(const WebString& alternateTitle)
 
 double WebHistoryItem::lastVisitedTime() const
 {
-    ASSERT(!isNull());
     return m_private->lastVisitedTime();
 }
 
@@ -168,7 +155,6 @@ void WebHistoryItem::setLastVisitedTime(double lastVisitedTime)
 
 WebPoint WebHistoryItem::scrollOffset() const
 {
-    ASSERT(!isNull());
     return m_private->scrollPoint();
 }
 
@@ -180,7 +166,6 @@ void WebHistoryItem::setScrollOffset(const WebPoint& scrollOffset)
 
 bool WebHistoryItem::isTargetItem() const
 {
-    ASSERT(!isNull());
     return m_private->isTargetItem();
 }
 
@@ -192,7 +177,6 @@ void WebHistoryItem::setIsTargetItem(bool isTargetItem)
 
 int WebHistoryItem::visitCount() const
 {
-    ASSERT(!isNull());
     return m_private->visitCount();
 }
 
@@ -204,7 +188,6 @@ void WebHistoryItem::setVisitCount(int count)
 
 WebVector<WebString> WebHistoryItem::documentState() const
 {
-    ASSERT(!isNull());
     return m_private->documentState();
 }
 
@@ -220,7 +203,6 @@ void WebHistoryItem::setDocumentState(const WebVector<WebString>& state)
 
 long long WebHistoryItem::documentSequenceNumber() const
 {
-    ASSERT(!isNull());
     return m_private->documentSequenceNumber();
 }
 
@@ -230,9 +212,19 @@ void WebHistoryItem::setDocumentSequenceNumber(long long documentSequenceNumber)
     m_private->setDocumentSequenceNumber(documentSequenceNumber);
 }
 
+WebSerializedScriptValue WebHistoryItem::stateObject() const
+{
+    return WebSerializedScriptValue(m_private->stateObject());
+}
+
+void WebHistoryItem::setStateObject(const WebSerializedScriptValue& object)
+{
+    ensureMutable();
+    m_private->setStateObject(object);
+}
+
 WebString WebHistoryItem::httpContentType() const
 {
-    ASSERT(!isNull());
     return m_private->formContentType();
 }
 
@@ -244,7 +236,6 @@ void WebHistoryItem::setHTTPContentType(const WebString& httpContentType)
 
 WebHTTPBody WebHistoryItem::httpBody() const
 {
-    ASSERT(!isNull());
     return WebHTTPBody(m_private->formData());
 }
 
@@ -256,7 +247,6 @@ void WebHistoryItem::setHTTPBody(const WebHTTPBody& httpBody)
 
 WebVector<WebHistoryItem> WebHistoryItem::children() const
 {
-    ASSERT(!isNull());
     return m_private->children();
 }
 
@@ -275,34 +265,25 @@ void WebHistoryItem::appendToChildren(const WebHistoryItem& item)
 }
 
 WebHistoryItem::WebHistoryItem(const PassRefPtr<HistoryItem>& item)
-    : m_private(static_cast<WebHistoryItemPrivate*>(item.releaseRef()))
+    : m_private(item)
 {
 }
 
 WebHistoryItem& WebHistoryItem::operator=(const PassRefPtr<HistoryItem>& item)
 {
-    assign(static_cast<WebHistoryItemPrivate*>(item.releaseRef()));
+    m_private = item;
     return *this;
 }
 
 WebHistoryItem::operator PassRefPtr<HistoryItem>() const
 {
-    return m_private;
-}
-
-void WebHistoryItem::assign(WebHistoryItemPrivate* p)
-{
-    // p is already ref'd for us by the caller
-    if (m_private)
-        m_private->deref();
-    m_private = p;
+    return m_private.get();
 }
 
 void WebHistoryItem::ensureMutable()
 {
-    ASSERT(!isNull());
     if (!m_private->hasOneRef())
-        assign(static_cast<WebHistoryItemPrivate*>(m_private->copy().releaseRef()));
+        m_private = m_private->copy();
 }
 
 } // namespace WebKit
diff --git a/WebKit/chromium/src/WebSerializedScriptValue.cpp b/WebKit/chromium/src/WebSerializedScriptValue.cpp
new file mode 100644
index 0000000..ee73e00
--- /dev/null
+++ b/WebKit/chromium/src/WebSerializedScriptValue.cpp
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebSerializedScriptValue.h"
+
+#include "SerializedScriptValue.h"
+#include "WebString.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void WebSerializedScriptValue::reset()
+{
+    m_private.reset();
+}
+
+void WebSerializedScriptValue::assign(const WebSerializedScriptValue& other)
+{
+    m_private = other.m_private;
+}
+
+WebString WebSerializedScriptValue::toString() const
+{
+    return m_private->toWireString();
+}
+
+WebSerializedScriptValue::WebSerializedScriptValue(const PassRefPtr<SerializedScriptValue>& value)
+    : m_private(value)
+{
+}
+
+WebSerializedScriptValue& WebSerializedScriptValue::operator=(const PassRefPtr<SerializedScriptValue>& value)
+{
+    m_private = value;
+    return *this;
+}
+
+WebSerializedScriptValue::operator PassRefPtr<SerializedScriptValue>() const
+{
+    return m_private.get();
+}
+
+} // namespace WebKit

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list