Changeset 158984 in webkit
- Timestamp:
- Nov 8, 2013 5:51:11 PM (11 years ago)
- Location:
- trunk/Source
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r158982 r158984 1 2013-11-08 Anders Carlsson <andersca@apple.com> 2 3 Implement encoding of arrays of objects 4 https://bugs.webkit.org/show_bug.cgi?id=124091 5 6 Reviewed by Beth Dakin. 7 8 * history/HistoryItem.cpp: 9 (WebCore::HistoryItem::encodeBackForwardTreeNode): 10 Encode the rest of the members. 11 12 * platform/KeyedCoding.h: 13 (WebCore::KeyedEncoder::encodeObjects): 14 Call beginArray, then beginArrayElement/endArrayElement for every element and lastly endArray. 15 1 16 2013-11-08 Tim Horton <timothy_horton@apple.com> 2 17 -
trunk/Source/WebCore/history/HistoryItem.cpp
r158980 r158984 738 738 void HistoryItem::encodeBackForwardTreeNode(KeyedEncoder& encoder) const 739 739 { 740 // FIXME: Implement. 740 encoder.encodeObjects("children", m_children.begin(), m_children.end(), [](KeyedEncoder& encoder, const RefPtr<HistoryItem>& child) { 741 encoder.encodeString("originalURLString", child->m_originalURLString); 742 encoder.encodeString("urlString", child->m_urlString); 743 744 child->encodeBackForwardTreeNode(encoder); 745 }); 746 747 encoder.encodeInt64("documentSequenceNumber", m_documentSequenceNumber); 748 749 encoder.encodeObjects("documentState", m_documentState.begin(), m_documentState.end(), [](KeyedEncoder& encoder, const String& string) { 750 encoder.encodeString("string", string); 751 }); 741 752 742 753 encoder.encodeString("formContentType", m_formContentType); … … 745 756 // FIXME: Implement. 746 757 }); 758 759 encoder.encodeInt64("itemSequenceNumber", m_itemSequenceNumber); 747 760 748 761 encoder.encodeString("referrer", m_referrer); -
trunk/Source/WebCore/platform/KeyedCoding.h
r158980 r158984 39 39 virtual void encodeUInt32(const String& key, uint32_t) = 0; 40 40 virtual void encodeInt32(const String& key, int32_t) = 0; 41 virtual void encodeInt64(const String& key, int64_t) = 0; 41 42 virtual void encodeFloat(const String& key, float) = 0; 42 43 virtual void encodeString(const String& key, const String&) = 0; 43 44 44 45 template<typename T, typename F> 45 void encodeObject(const String& key, const T& object, F function)46 void encodeObject(const String& key, const T& object, F&& function) 46 47 { 47 this->beginObject(key);48 beginObject(key); 48 49 function(*this, object); 49 this->endObject();50 endObject(); 50 51 } 51 52 … … 59 60 } 60 61 62 template<typename T, typename F> 63 void encodeObjects(const String& key, T begin, T end, F&& function) 64 { 65 if (begin == end) 66 return; 67 68 beginArray(key); 69 for (T it = begin; it != end; ++it) { 70 beginArrayElement(); 71 function(*this, *it); 72 endArrayElement(); 73 } 74 endArray(); 75 } 76 61 77 private: 62 78 virtual void beginObject(const String& key) = 0; 63 79 virtual void endObject() = 0; 80 81 virtual void beginArray(const String& key) = 0; 82 virtual void beginArrayElement() = 0; 83 virtual void endArrayElement() = 0; 84 virtual void endArray() = 0; 64 85 }; 65 86 -
trunk/Source/WebKit2/ChangeLog
r158982 r158984 1 2013-11-08 Anders Carlsson <andersca@apple.com> 2 3 Implement encoding of arrays of objects 4 https://bugs.webkit.org/show_bug.cgi?id=124091 5 6 Reviewed by Beth Dakin. 7 8 Add a new array stack and push and pop from it accordingly. 9 10 * Shared/cf/KeyedEncoder.cpp: 11 (WebKit::KeyedEncoder::~KeyedEncoder): 12 (WebKit::KeyedEncoder::encodeBytes): 13 (WebKit::KeyedEncoder::encodeUInt32): 14 (WebKit::KeyedEncoder::encodeInt32): 15 (WebKit::KeyedEncoder::encodeInt64): 16 (WebKit::KeyedEncoder::encodeFloat): 17 (WebKit::KeyedEncoder::beginArray): 18 (WebKit::KeyedEncoder::beginArrayElement): 19 (WebKit::KeyedEncoder::endArrayElement): 20 (WebKit::KeyedEncoder::endArray): 21 * Shared/cf/KeyedEncoder.h: 22 1 23 2013-11-08 Tim Horton <timothy_horton@apple.com> 2 24 -
trunk/Source/WebKit2/Shared/cf/KeyedEncoder.cpp
r158980 r158984 47 47 ASSERT(m_dictionaryStack.size() == 1); 48 48 ASSERT(m_dictionaryStack.last() == m_rootDictionary); 49 ASSERT(m_arrayStack.isEmpty()); 49 50 } 50 51 51 52 void KeyedEncoder::encodeBytes(const String& key, const uint8_t* bytes, size_t size) 52 53 { 53 RetainPtr<CFDataRef>data = adoptCF(CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, bytes, size, kCFAllocatorNull));54 auto data = adoptCF(CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, bytes, size, kCFAllocatorNull)); 54 55 CFDictionarySetValue(m_dictionaryStack.last(), key.createCFString().get(), data.get()); 55 56 } … … 57 58 void KeyedEncoder::encodeUInt32(const String& key, uint32_t value) 58 59 { 59 RetainPtr<CFNumberRef>number = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &value));60 auto number = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &value)); 60 61 CFDictionarySetValue(m_dictionaryStack.last(), key.createCFString().get(), number.get()); 61 62 } … … 63 64 void KeyedEncoder::encodeInt32(const String& key, int32_t value) 64 65 { 65 RetainPtr<CFNumberRef> number = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &value)); 66 auto number = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &value)); 67 CFDictionarySetValue(m_dictionaryStack.last(), key.createCFString().get(), number.get()); 68 } 69 70 void KeyedEncoder::encodeInt64(const String& key, int64_t value) 71 { 72 auto number = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt64Type, &value)); 66 73 CFDictionarySetValue(m_dictionaryStack.last(), key.createCFString().get(), number.get()); 67 74 } … … 69 76 void KeyedEncoder::encodeFloat(const String& key, float value) 70 77 { 71 RetainPtr<CFNumberRef>number = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberFloatType, &value));78 auto number = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberFloatType, &value)); 72 79 CFDictionarySetValue(m_dictionaryStack.last(), key.createCFString().get(), number.get()); 73 80 } … … 91 98 } 92 99 100 void KeyedEncoder::beginArray(const String& key) 101 { 102 auto array = adoptCF(CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks)); 103 CFDictionarySetValue(m_dictionaryStack.last(), key.createCFString().get(), array.get()); 104 105 m_arrayStack.append(array.get()); 106 } 107 108 void KeyedEncoder::beginArrayElement() 109 { 110 auto dictionary = createDictionary(); 111 CFArrayAppendValue(m_arrayStack.last(), dictionary.get()); 112 113 m_dictionaryStack.append(dictionary.get()); 114 } 115 116 void KeyedEncoder::endArrayElement() 117 { 118 m_dictionaryStack.removeLast(); 119 } 120 121 void KeyedEncoder::endArray() 122 { 123 m_arrayStack.removeLast(); 124 } 125 93 126 } // namespace WebKit -
trunk/Source/WebKit2/Shared/cf/KeyedEncoder.h
r158980 r158984 43 43 virtual void encodeUInt32(const String& key, uint32_t) OVERRIDE; 44 44 virtual void encodeInt32(const String& key, int32_t) OVERRIDE; 45 virtual void encodeInt64(const String& key, int64_t) OVERRIDE; 45 46 virtual void encodeFloat(const String& key, float) OVERRIDE; 46 47 virtual void encodeString(const String& key, const String&) OVERRIDE; … … 49 50 virtual void endObject() OVERRIDE; 50 51 52 virtual void beginArray(const String& key) OVERRIDE; 53 virtual void beginArrayElement() OVERRIDE; 54 virtual void endArrayElement() OVERRIDE; 55 virtual void endArray() OVERRIDE; 56 51 57 RetainPtr<CFMutableDictionaryRef> m_rootDictionary; 58 52 59 Vector<CFMutableDictionaryRef, 16> m_dictionaryStack; 60 Vector<CFMutableArrayRef, 16> m_arrayStack; 53 61 }; 54 62 -
trunk/Source/WebKit2/WebProcess/WebPage/WebBackForwardListProxy.cpp
r158971 r158984 85 85 static void updateBackForwardItem(uint64_t itemID, HistoryItem* item) 86 86 { 87 KeyedEncoder keyedEncoder;88 item->encodeBackForwardTree(keyedEncoder);89 90 87 EncoderAdapter encoder; 91 88 item->encodeBackForwardTree(encoder);
Note: See TracChangeset
for help on using the changeset viewer.