Changeset 158978 in webkit
- Timestamp:
- Nov 8, 2013 4:51:54 PM (10 years ago)
- Location:
- trunk/Source
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r158972 r158978 1 2013-11-08 Anders Carlsson <andersca@apple.com> 2 3 KeyedEncoder should be able to encoder objects 4 https://bugs.webkit.org/show_bug.cgi?id=124085 5 6 Reviewed by Sam Weinig. 7 8 * history/HistoryItem.cpp: 9 (WebCore::HistoryItem::encodeBackForwardTree): 10 Encode the root object. 11 12 (WebCore::HistoryItem::encodeBackForwardTreeNode): 13 Encode the target. 14 15 * history/HistoryItem.h: 16 Add new members. 17 18 * platform/KeyedCoding.h: 19 (WebCore::KeyedEncoder::encodeObject): 20 Call beginObject, call the functor and then call endObject(). 21 1 22 2013-11-08 Sam Weinig <sam@webkit.org> 2 23 -
trunk/Source/WebCore/history/HistoryItem.cpp
r158971 r158978 688 688 encoder.encodeUInt32("version", backForwardTreeEncodingVersion); 689 689 690 // FIXME: Encode the tree. 690 encoder.encodeObject("root", *this, [](KeyedEncoder& encoder, const HistoryItem& item) { 691 item.encodeBackForwardTreeNode(encoder); 692 }); 691 693 } 692 694 … … 732 734 733 735 encoder.encodeString(m_target); 736 } 737 738 void HistoryItem::encodeBackForwardTreeNode(KeyedEncoder& encoder) const 739 { 740 // FIXME: Implement. 741 742 encoder.encodeString("target", m_target); 734 743 } 735 744 -
trunk/Source/WebCore/history/HistoryItem.h
r158971 r158978 224 224 225 225 void encodeBackForwardTreeNode(Encoder&) const; 226 227 /* When adding new member variables to this class, please notify the Qt team. 228 * qt/HistoryItemQt.cpp contains code to serialize history items. 229 */ 226 void encodeBackForwardTreeNode(KeyedEncoder&) const; 230 227 231 228 String m_urlString; -
trunk/Source/WebCore/platform/KeyedCoding.h
r158971 r158978 37 37 public: 38 38 virtual void encodeUInt32(const String& key, uint32_t) = 0; 39 40 virtual void encodeString(const String& key, const String&) = 0; 41 42 template<typename T, typename F> 43 void encodeObject(const String& key, const T& object, F function) 44 { 45 this->beginObject(key); 46 function(*this, object); 47 this->endObject(); 48 } 49 50 private: 51 virtual void beginObject(const String& key) = 0; 52 virtual void endObject() = 0; 39 53 }; 40 54 -
trunk/Source/WebKit2/ChangeLog
r158976 r158978 1 2013-11-08 Anders Carlsson <andersca@apple.com> 2 3 KeyedEncoder should be able to encoder objects 4 https://bugs.webkit.org/show_bug.cgi?id=124085 5 6 Reviewed by Sam Weinig. 7 8 Add a dictionary stack to KeyedEncoder that's pushed and popped by 9 beginObject/endObject. 10 11 * Shared/cf/KeyedEncoder.cpp: 12 (WebKit::KeyedEncoder::KeyedEncoder): 13 (WebKit::KeyedEncoder::~KeyedEncoder): 14 (WebKit::KeyedEncoder::encodeUInt32): 15 (WebKit::KeyedEncoder::encodeString): 16 (WebKit::KeyedEncoder::beginObject): 17 (WebKit::KeyedEncoder::endObject): 18 * Shared/cf/KeyedEncoder.h: 19 1 20 2013-11-08 Alexandru Chiculita <achicu@adobe.com> 2 21 -
trunk/Source/WebKit2/Shared/cf/KeyedEncoder.cpp
r158971 r158978 40 40 : m_rootDictionary(createDictionary()) 41 41 { 42 m_dictionaryStack.append(m_rootDictionary.get()); 42 43 } 43 44 44 45 KeyedEncoder::~KeyedEncoder() 45 46 { 47 ASSERT(m_dictionaryStack.size() == 1); 48 ASSERT(m_dictionaryStack.last() == m_rootDictionary); 46 49 } 47 50 … … 49 52 { 50 53 RetainPtr<CFNumberRef> number = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &value)); 51 CFDictionarySetValue(m_rootDictionary.get(), key.createCFString().get(), number.get()); 54 CFDictionarySetValue(m_dictionaryStack.last(), key.createCFString().get(), number.get()); 55 } 56 57 void KeyedEncoder::encodeString(const String& key, const String& value) 58 { 59 CFDictionarySetValue(m_dictionaryStack.last(), key.createCFString().get(), value.createCFString().get()); 60 } 61 62 void KeyedEncoder::beginObject(const String& key) 63 { 64 auto dictionary = createDictionary(); 65 CFDictionarySetValue(m_dictionaryStack.last(), key.createCFString().get(), dictionary.get()); 66 67 m_dictionaryStack.append(dictionary.get()); 68 } 69 70 void KeyedEncoder::endObject() 71 { 72 m_dictionaryStack.removeLast(); 52 73 } 53 74 -
trunk/Source/WebKit2/Shared/cf/KeyedEncoder.h
r158971 r158978 29 29 #include <WebCore/KeyedCoding.h> 30 30 #include <wtf/RetainPtr.h> 31 #include <wtf/Vector.h> 31 32 32 33 namespace WebKit { … … 39 40 private: 40 41 virtual void encodeUInt32(const String& key, uint32_t) OVERRIDE; 42 virtual void encodeString(const String& key, const String&) OVERRIDE; 43 44 virtual void beginObject(const String& key) OVERRIDE; 45 virtual void endObject() OVERRIDE; 41 46 42 47 RetainPtr<CFMutableDictionaryRef> m_rootDictionary; 48 Vector<CFMutableDictionaryRef, 16> m_dictionaryStack; 43 49 }; 44 50
Note: See TracChangeset
for help on using the changeset viewer.