Title: [158980] trunk/Source
Revision
158980
Author
[email protected]
Date
2013-11-08 17:16:26 -0800 (Fri, 08 Nov 2013)

Log Message

Implement more KeyedEncoder functionality
https://bugs.webkit.org/show_bug.cgi?id=124089

Reviewed by Beth Dakin.

Source/WebCore:

* bindings/js/SerializedScriptValue.h:
* history/HistoryItem.cpp:
(WebCore::HistoryItem::encodeBackForwardTreeNode):
* platform/KeyedCoding.h:
(WebCore::KeyedEncoder::encodeConditionalObject):

Source/WebKit2:

* Shared/cf/KeyedEncoder.cpp:
(WebKit::KeyedEncoder::encodeBytes):
(WebKit::KeyedEncoder::encodeInt32):
(WebKit::KeyedEncoder::encodeFloat):
* Shared/cf/KeyedEncoder.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (158979 => 158980)


--- trunk/Source/WebCore/ChangeLog	2013-11-09 01:13:29 UTC (rev 158979)
+++ trunk/Source/WebCore/ChangeLog	2013-11-09 01:16:26 UTC (rev 158980)
@@ -1,3 +1,16 @@
+2013-11-08  Anders Carlsson  <[email protected]>
+
+        Implement more KeyedEncoder functionality
+        https://bugs.webkit.org/show_bug.cgi?id=124089
+
+        Reviewed by Beth Dakin.
+
+        * bindings/js/SerializedScriptValue.h:
+        * history/HistoryItem.cpp:
+        (WebCore::HistoryItem::encodeBackForwardTreeNode):
+        * platform/KeyedCoding.h:
+        (WebCore::KeyedEncoder::encodeConditionalObject):
+
 2013-11-08  Eric Carlson  <[email protected]>
 
         getCueAsHTML() on an empty cue should return a document fragment

Modified: trunk/Source/WebCore/bindings/js/SerializedScriptValue.h (158979 => 158980)


--- trunk/Source/WebCore/bindings/js/SerializedScriptValue.h	2013-11-09 01:13:29 UTC (rev 158979)
+++ trunk/Source/WebCore/bindings/js/SerializedScriptValue.h	2013-11-09 01:16:26 UTC (rev 158980)
@@ -95,7 +95,7 @@
     ScriptValue deserializeForInspector(JSC::ExecState*);
 #endif
 
-    const Vector<uint8_t>& data() { return m_data; }
+    const Vector<uint8_t>& data() const { return m_data; }
     const Vector<String>& blobURLs() const { return m_blobURLs; }
 
 #if ENABLE(INDEXED_DATABASE)

Modified: trunk/Source/WebCore/history/HistoryItem.cpp (158979 => 158980)


--- trunk/Source/WebCore/history/HistoryItem.cpp	2013-11-09 01:13:29 UTC (rev 158979)
+++ trunk/Source/WebCore/history/HistoryItem.cpp	2013-11-09 01:16:26 UTC (rev 158980)
@@ -739,6 +739,25 @@
 {
     // FIXME: Implement.
 
+    encoder.encodeString("formContentType", m_formContentType);
+
+    encoder.encodeConditionalObject("formData", m_formData.get(), [](KeyedEncoder&, const FormData&) {
+        // FIXME: Implement.
+    });
+
+    encoder.encodeString("referrer", m_referrer);
+
+    encoder.encodeObject("scrollPoint", m_scrollPoint, [](KeyedEncoder& encoder, const IntPoint& scrollPoint) {
+        encoder.encodeInt32("x", scrollPoint.x());
+        encoder.encodeInt32("y", scrollPoint.y());
+    });
+
+    encoder.encodeFloat("pageScaleFactor", m_pageScaleFactor);
+
+    encoder.encodeConditionalObject("stateObject", m_stateObject.get(), [](KeyedEncoder& encoder, const SerializedScriptValue& stateObject) {
+        encoder.encodeBytes("data", stateObject.data().data(), stateObject.data().size());
+    });
+
     encoder.encodeString("target", m_target);
 }
 

Modified: trunk/Source/WebCore/platform/KeyedCoding.h (158979 => 158980)


--- trunk/Source/WebCore/platform/KeyedCoding.h	2013-11-09 01:13:29 UTC (rev 158979)
+++ trunk/Source/WebCore/platform/KeyedCoding.h	2013-11-09 01:16:26 UTC (rev 158980)
@@ -35,8 +35,10 @@
     virtual ~KeyedEncoder() { }
 
 public:
+    virtual void encodeBytes(const String& key, const uint8_t*, size_t) = 0;
     virtual void encodeUInt32(const String& key, uint32_t) = 0;
-
+    virtual void encodeInt32(const String& key, int32_t) = 0;
+    virtual void encodeFloat(const String& key, float) = 0;
     virtual void encodeString(const String& key, const String&) = 0;
 
     template<typename T, typename F>
@@ -47,6 +49,15 @@
         this->endObject();
     }
 
+    template<typename T, typename F>
+    void encodeConditionalObject(const String& key, const T* object, F&& function)
+    {
+        if (!object)
+            return;
+
+        encodeObject(key, *object, std::forward<F>(function));
+    }
+
 private:
     virtual void beginObject(const String& key) = 0;
     virtual void endObject() = 0;

Modified: trunk/Source/WebKit2/ChangeLog (158979 => 158980)


--- trunk/Source/WebKit2/ChangeLog	2013-11-09 01:13:29 UTC (rev 158979)
+++ trunk/Source/WebKit2/ChangeLog	2013-11-09 01:16:26 UTC (rev 158980)
@@ -1,5 +1,18 @@
 2013-11-08  Anders Carlsson  <[email protected]>
 
+        Implement more KeyedEncoder functionality
+        https://bugs.webkit.org/show_bug.cgi?id=124089
+
+        Reviewed by Beth Dakin.
+
+        * Shared/cf/KeyedEncoder.cpp:
+        (WebKit::KeyedEncoder::encodeBytes):
+        (WebKit::KeyedEncoder::encodeInt32):
+        (WebKit::KeyedEncoder::encodeFloat):
+        * Shared/cf/KeyedEncoder.h:
+
+2013-11-08  Anders Carlsson  <[email protected]>
+
         KeyedEncoder should be able to encoder objects
         https://bugs.webkit.org/show_bug.cgi?id=124085
 

Modified: trunk/Source/WebKit2/Shared/cf/KeyedEncoder.cpp (158979 => 158980)


--- trunk/Source/WebKit2/Shared/cf/KeyedEncoder.cpp	2013-11-09 01:13:29 UTC (rev 158979)
+++ trunk/Source/WebKit2/Shared/cf/KeyedEncoder.cpp	2013-11-09 01:16:26 UTC (rev 158980)
@@ -48,12 +48,30 @@
     ASSERT(m_dictionaryStack.last() == m_rootDictionary);
 }
 
+void KeyedEncoder::encodeBytes(const String& key, const uint8_t* bytes, size_t size)
+{
+    RetainPtr<CFDataRef> data = "" bytes, size, kCFAllocatorNull));
+    CFDictionarySetValue(m_dictionaryStack.last(), key.createCFString().get(), data.get());
+}
+
 void KeyedEncoder::encodeUInt32(const String& key, uint32_t value)
 {
     RetainPtr<CFNumberRef> number = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &value));
     CFDictionarySetValue(m_dictionaryStack.last(), key.createCFString().get(), number.get());
 }
 
+void KeyedEncoder::encodeInt32(const String& key, int32_t value)
+{
+    RetainPtr<CFNumberRef> number = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &value));
+    CFDictionarySetValue(m_dictionaryStack.last(), key.createCFString().get(), number.get());
+}
+
+void KeyedEncoder::encodeFloat(const String& key, float value)
+{
+    RetainPtr<CFNumberRef> number = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberFloatType, &value));
+    CFDictionarySetValue(m_dictionaryStack.last(), key.createCFString().get(), number.get());
+}
+
 void KeyedEncoder::encodeString(const String& key, const String& value)
 {
     CFDictionarySetValue(m_dictionaryStack.last(), key.createCFString().get(), value.createCFString().get());

Modified: trunk/Source/WebKit2/Shared/cf/KeyedEncoder.h (158979 => 158980)


--- trunk/Source/WebKit2/Shared/cf/KeyedEncoder.h	2013-11-09 01:13:29 UTC (rev 158979)
+++ trunk/Source/WebKit2/Shared/cf/KeyedEncoder.h	2013-11-09 01:16:26 UTC (rev 158980)
@@ -38,7 +38,11 @@
     ~KeyedEncoder();
 
 private:
+    virtual void encodeBytes(const String& key, const uint8_t*, size_t) OVERRIDE;
+
     virtual void encodeUInt32(const String& key, uint32_t) OVERRIDE;
+    virtual void encodeInt32(const String& key, int32_t) OVERRIDE;
+    virtual void encodeFloat(const String& key, float) OVERRIDE;
     virtual void encodeString(const String& key, const String&) OVERRIDE;
 
     virtual void beginObject(const String& key) OVERRIDE;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to