Changeset 158980 in webkit


Ignore:
Timestamp:
Nov 8, 2013 5:16:26 PM (10 years ago)
Author:
andersca@apple.com
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:
Location:
trunk/Source
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r158979 r158980  
     12013-11-08  Anders Carlsson  <andersca@apple.com>
     2
     3        Implement more KeyedEncoder functionality
     4        https://bugs.webkit.org/show_bug.cgi?id=124089
     5
     6        Reviewed by Beth Dakin.
     7
     8        * bindings/js/SerializedScriptValue.h:
     9        * history/HistoryItem.cpp:
     10        (WebCore::HistoryItem::encodeBackForwardTreeNode):
     11        * platform/KeyedCoding.h:
     12        (WebCore::KeyedEncoder::encodeConditionalObject):
     13
    1142013-11-08  Eric Carlson  <eric.carlson@apple.com>
    215
  • trunk/Source/WebCore/bindings/js/SerializedScriptValue.h

    r155736 r158980  
    9696#endif
    9797
    98     const Vector<uint8_t>& data() { return m_data; }
     98    const Vector<uint8_t>& data() const { return m_data; }
    9999    const Vector<String>& blobURLs() const { return m_blobURLs; }
    100100
  • trunk/Source/WebCore/history/HistoryItem.cpp

    r158978 r158980  
    740740    // FIXME: Implement.
    741741
     742    encoder.encodeString("formContentType", m_formContentType);
     743
     744    encoder.encodeConditionalObject("formData", m_formData.get(), [](KeyedEncoder&, const FormData&) {
     745        // FIXME: Implement.
     746    });
     747
     748    encoder.encodeString("referrer", m_referrer);
     749
     750    encoder.encodeObject("scrollPoint", m_scrollPoint, [](KeyedEncoder& encoder, const IntPoint& scrollPoint) {
     751        encoder.encodeInt32("x", scrollPoint.x());
     752        encoder.encodeInt32("y", scrollPoint.y());
     753    });
     754
     755    encoder.encodeFloat("pageScaleFactor", m_pageScaleFactor);
     756
     757    encoder.encodeConditionalObject("stateObject", m_stateObject.get(), [](KeyedEncoder& encoder, const SerializedScriptValue& stateObject) {
     758        encoder.encodeBytes("data", stateObject.data().data(), stateObject.data().size());
     759    });
     760
    742761    encoder.encodeString("target", m_target);
    743762}
  • trunk/Source/WebCore/platform/KeyedCoding.h

    r158978 r158980  
    3636
    3737public:
     38    virtual void encodeBytes(const String& key, const uint8_t*, size_t) = 0;
    3839    virtual void encodeUInt32(const String& key, uint32_t) = 0;
    39 
     40    virtual void encodeInt32(const String& key, int32_t) = 0;
     41    virtual void encodeFloat(const String& key, float) = 0;
    4042    virtual void encodeString(const String& key, const String&) = 0;
    4143
     
    4850    }
    4951
     52    template<typename T, typename F>
     53    void encodeConditionalObject(const String& key, const T* object, F&& function)
     54    {
     55        if (!object)
     56            return;
     57
     58        encodeObject(key, *object, std::forward<F>(function));
     59    }
     60
    5061private:
    5162    virtual void beginObject(const String& key) = 0;
  • trunk/Source/WebKit2/ChangeLog

    r158978 r158980  
     12013-11-08  Anders Carlsson  <andersca@apple.com>
     2
     3        Implement more KeyedEncoder functionality
     4        https://bugs.webkit.org/show_bug.cgi?id=124089
     5
     6        Reviewed by Beth Dakin.
     7
     8        * Shared/cf/KeyedEncoder.cpp:
     9        (WebKit::KeyedEncoder::encodeBytes):
     10        (WebKit::KeyedEncoder::encodeInt32):
     11        (WebKit::KeyedEncoder::encodeFloat):
     12        * Shared/cf/KeyedEncoder.h:
     13
    1142013-11-08  Anders Carlsson  <andersca@apple.com>
    215
  • trunk/Source/WebKit2/Shared/cf/KeyedEncoder.cpp

    r158978 r158980  
    4949}
    5050
     51void KeyedEncoder::encodeBytes(const String& key, const uint8_t* bytes, size_t size)
     52{
     53    RetainPtr<CFDataRef> data = adoptCF(CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, bytes, size, kCFAllocatorNull));
     54    CFDictionarySetValue(m_dictionaryStack.last(), key.createCFString().get(), data.get());
     55}
     56
    5157void KeyedEncoder::encodeUInt32(const String& key, uint32_t value)
    5258{
    5359    RetainPtr<CFNumberRef> number = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &value));
     60    CFDictionarySetValue(m_dictionaryStack.last(), key.createCFString().get(), number.get());
     61}
     62
     63void KeyedEncoder::encodeInt32(const String& key, int32_t value)
     64{
     65    RetainPtr<CFNumberRef> number = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &value));
     66    CFDictionarySetValue(m_dictionaryStack.last(), key.createCFString().get(), number.get());
     67}
     68
     69void KeyedEncoder::encodeFloat(const String& key, float value)
     70{
     71    RetainPtr<CFNumberRef> number = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberFloatType, &value));
    5472    CFDictionarySetValue(m_dictionaryStack.last(), key.createCFString().get(), number.get());
    5573}
  • trunk/Source/WebKit2/Shared/cf/KeyedEncoder.h

    r158978 r158980  
    3939
    4040private:
     41    virtual void encodeBytes(const String& key, const uint8_t*, size_t) OVERRIDE;
     42
    4143    virtual void encodeUInt32(const String& key, uint32_t) OVERRIDE;
     44    virtual void encodeInt32(const String& key, int32_t) OVERRIDE;
     45    virtual void encodeFloat(const String& key, float) OVERRIDE;
    4246    virtual void encodeString(const String& key, const String&) OVERRIDE;
    4347
Note: See TracChangeset for help on using the changeset viewer.