Title: [210918] trunk
Revision
210918
Author
achristen...@apple.com
Date
2017-01-19 00:21:37 -0800 (Thu, 19 Jan 2017)

Log Message

[WebIDL] Records should preserve _javascript_ object order
https://bugs.webkit.org/show_bug.cgi?id=167189

Patch by Sam Weinig <s...@webkit.org> on 2017-01-18
Reviewed by Alex Christensen.

Source/WebCore:

Instead of modeling IDL records as HashMaps, use a Vector
of KeyValuePairs, to all preserving the iteration order.

* Modules/webdatabase/SQLResultSetRowList.cpp:
(WebCore::SQLResultSetRowList::item):
* Modules/webdatabase/SQLResultSetRowList.h:
Return a Vector rather than a HashMap.

* bindings/IDLTypes.h:
Change underlying type to be a Vector<KeyValuePair<K, V>>.

* bindings/js/JSDOMConvert.h:
Update conversion for new implementation type. For conversion
to JSValue, allow any type that can has an iterator of keyValuePairs.
 
* testing/TypeConversions.h:
(WebCore::TypeConversions::testLongRecord):
(WebCore::TypeConversions::setTestLongRecord):
(WebCore::TypeConversions::testNodeRecord):
(WebCore::TypeConversions::setTestNodeRecord):
(WebCore::TypeConversions::testSequenceRecord):
(WebCore::TypeConversions::setTestSequenceRecord):
* testing/TypeConversions.idl:
Update test IDL to use functions, since the spec mandates that
records can't be used with attributes.

LayoutTests:

* js/dom/webidl-type-mapping-expected.txt:
* js/dom/webidl-type-mapping.html:
Update test to reflect changes to TypeConversions.idl

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (210917 => 210918)


--- trunk/LayoutTests/ChangeLog	2017-01-19 08:08:38 UTC (rev 210917)
+++ trunk/LayoutTests/ChangeLog	2017-01-19 08:21:37 UTC (rev 210918)
@@ -1,3 +1,14 @@
+2017-01-18  Sam Weinig  <s...@webkit.org>
+
+        [WebIDL] Records should preserve _javascript_ object order
+        https://bugs.webkit.org/show_bug.cgi?id=167189
+
+        Reviewed by Alex Christensen.
+
+        * js/dom/webidl-type-mapping-expected.txt:
+        * js/dom/webidl-type-mapping.html:
+        Update test to reflect changes to TypeConversions.idl
+
 2017-01-18  Yoav Weiss  <y...@yoav.ws>
 
         Add Link header support for preload.

Modified: trunk/LayoutTests/js/dom/webidl-type-mapping-expected.txt (210917 => 210918)


--- trunk/LayoutTests/js/dom/webidl-type-mapping-expected.txt	2017-01-19 08:08:38 UTC (rev 210917)
+++ trunk/LayoutTests/js/dom/webidl-type-mapping-expected.txt	2017-01-19 08:21:37 UTC (rev 210918)
@@ -1127,69 +1127,69 @@
 PASS converter.typeConversionsDictionaryUnionType is 'dictionary'
 
 Testing record conversion
-converter.testLongRecord = { key: 1, key2: 2 }
-PASS converter.testLongRecord is an instance of Object
-PASS converter.testLongRecord.hasOwnProperty('key') is true
-PASS 'key' in converter.testLongRecord is true
-PASS converter.testLongRecord['key'] is 1
-PASS converter.testLongRecord.hasOwnProperty('key2') is true
-PASS 'key2' in converter.testLongRecord is true
-PASS converter.testLongRecord['key2'] is 2
-converter.testLongRecord = undefined
-PASS converter.testLongRecord is an instance of Object
-converter.testLongRecord = null
-PASS converter.testLongRecord is an instance of Object
-PASS converter.testLongRecord = 1 threw exception TypeError: Type error.
-PASS converter.testLongRecord = { key: { valueOf:function() { throw new Error(); } } } threw exception Error.
-var o = { otherKey: 2 }; Object.defineProperty(o, 'key', { enumerable: false, value: 1 }); converter.testLongRecord = o;
-PASS converter.testLongRecord.hasOwnProperty('key') is false
-PASS converter.testLongRecord.hasOwnProperty('otherKey') is true
-PASS converter.testLongRecord['otherKey'] is 2
-var o = { otherKey: 2 }; Object.defineProperty(o, 'key', { get: function() { return 1; }, enumerable: true }); converter.testLongRecord = o;
-PASS converter.testLongRecord.hasOwnProperty('key') is true
-PASS converter.testLongRecord['key'] is 1
-PASS converter.testLongRecord.hasOwnProperty('otherKey') is true
-PASS converter.testLongRecord['otherKey'] is 2
-PASS var o = { otherKey: 2 }; Object.defineProperty(o, 'key', { get: function() { throw new Error();; }, enumerable: true }); converter.testLongRecord = o; threw exception Error.
-converter.testNodeRecord = { key: document, key2: document.documentElement }
-PASS converter.testNodeRecord.hasOwnProperty('key') is true
-PASS 'key' in converter.testNodeRecord is true
-PASS converter.testNodeRecord['key'] is document
-PASS converter.testNodeRecord.hasOwnProperty('key2') is true
-PASS 'key2' in converter.testNodeRecord is true
-PASS converter.testNodeRecord['key2'] is document.documentElement
-PASS converter.testNodeRecord = { key: 'hello' } threw exception TypeError: Type error.
-converter.testLongRecord = {'í €': 1 }
-PASS converter.testLongRecord['í €'] is 1
-converter.testNodeRecord = {'í €': document }
-PASS converter.testNodeRecord['�'] is document
-converter.testLongRecord = {'í°€': 1 }
-PASS converter.testLongRecord['í°€'] is 1
-converter.testNodeRecord = {'í°€': document }
-PASS converter.testNodeRecord['�'] is document
-converter.testLongRecord = {'í €': 1 }
-PASS converter.testLongRecord['í €\0'] is 1
-converter.testNodeRecord = {'í €': document }
-PASS converter.testNodeRecord['�\0'] is document
-converter.testLongRecord = {'í°€': 1 }
-PASS converter.testLongRecord['í°€\0'] is 1
-converter.testNodeRecord = {'í°€': document }
-PASS converter.testNodeRecord['�\0'] is document
-converter.testLongRecord = {'í°€í €': 1 }
-PASS converter.testLongRecord['í°€í €'] is 1
-converter.testNodeRecord = {'í°€í €': document }
-PASS converter.testNodeRecord['��'] is document
-converter.testLongRecord = {'𝄞': 1 }
-PASS converter.testLongRecord['𝄞'] is 1
-converter.testNodeRecord = {'𝄞': document }
-PASS converter.testNodeRecord['𝄞'] is document
-converter.testSequenceRecord = { key: ['value', 'other value'] }
-PASS converter.testSequenceRecord.hasOwnProperty('key') is true
-PASS 'key' in converter.testSequenceRecord is true
-PASS converter.testSequenceRecord['key'] is ['value', 'other value']
-PASS converter.testSequenceRecord = { 'Ā': ['value'] } threw exception TypeError: Type error.
-converter.testSequenceRecord = { 'ÿ': ['value'] }
-PASS converter.testSequenceRecord['ÿ'] is ['value']
+converter.setTestLongRecord({ key: 1, key2: 2 })
+PASS converter.testLongRecord() is an instance of Object
+PASS converter.testLongRecord().hasOwnProperty('key') is true
+PASS 'key' in converter.testLongRecord() is true
+PASS converter.testLongRecord()['key'] is 1
+PASS converter.testLongRecord().hasOwnProperty('key2') is true
+PASS 'key2' in converter.testLongRecord() is true
+PASS converter.testLongRecord()['key2'] is 2
+converter.setTestLongRecord(undefined)
+PASS converter.testLongRecord() is an instance of Object
+converter.setTestLongRecord(null)
+PASS converter.testLongRecord() is an instance of Object
+PASS converter.setTestLongRecord(1) threw exception TypeError: Type error.
+PASS converter.setTestLongRecord({ key: { valueOf:function() { throw new Error(); } } }) threw exception Error.
+var o = { otherKey: 2 }; Object.defineProperty(o, 'key', { enumerable: false, value: 1 }); converter.setTestLongRecord(o);
+PASS converter.testLongRecord().hasOwnProperty('key') is false
+PASS converter.testLongRecord().hasOwnProperty('otherKey') is true
+PASS converter.testLongRecord()['otherKey'] is 2
+var o = { otherKey: 2 }; Object.defineProperty(o, 'key', { get: function() { return 1; }, enumerable: true }); converter.setTestLongRecord(o);
+PASS converter.testLongRecord().hasOwnProperty('key') is true
+PASS converter.testLongRecord()['key'] is 1
+PASS converter.testLongRecord().hasOwnProperty('otherKey') is true
+PASS converter.testLongRecord()['otherKey'] is 2
+PASS var o = { otherKey: 2 }; Object.defineProperty(o, 'key', { get: function() { throw new Error(); }, enumerable: true }); converter.setTestLongRecord(o); threw exception Error.
+converter.setTestNodeRecord({ key: document, key2: document.documentElement })
+PASS converter.testNodeRecord().hasOwnProperty('key') is true
+PASS 'key' in converter.testNodeRecord() is true
+PASS converter.testNodeRecord()['key'] is document
+PASS converter.testNodeRecord().hasOwnProperty('key2') is true
+PASS 'key2' in converter.testNodeRecord() is true
+PASS converter.testNodeRecord()['key2'] is document.documentElement
+PASS converter.setTestNodeRecord({ key: 'hello' }) threw exception TypeError: Type error.
+converter.setTestLongRecord({'í €': 1 })
+PASS converter.testLongRecord()['í €'] is 1
+converter.setTestNodeRecord({'í €': document })
+PASS converter.testNodeRecord()['�'] is document
+converter.setTestLongRecord({'í°€': 1 })
+PASS converter.testLongRecord()['í°€'] is 1
+converter.setTestNodeRecord({'í°€': document })
+PASS converter.testNodeRecord()['�'] is document
+converter.setTestLongRecord({'í €': 1 })
+PASS converter.testLongRecord()['í €\0'] is 1
+converter.setTestNodeRecord({'í €': document })
+PASS converter.testNodeRecord()['�\0'] is document
+converter.setTestLongRecord({'í°€': 1 })
+PASS converter.testLongRecord()['í°€\0'] is 1
+converter.setTestNodeRecord({'í°€': document })
+PASS converter.testNodeRecord()['�\0'] is document
+converter.setTestLongRecord({'í°€í €': 1 })
+PASS converter.testLongRecord()['í°€í €'] is 1
+converter.setTestNodeRecord({'í°€í €': document })
+PASS converter.testNodeRecord()['��'] is document
+converter.setTestLongRecord({'𝄞': 1 })
+PASS converter.testLongRecord()['𝄞'] is 1
+converter.setTestNodeRecord({'𝄞': document })
+PASS converter.testNodeRecord()['𝄞'] is document
+converter.setTestSequenceRecord({ key: ['value', 'other value'] })
+PASS converter.testSequenceRecord().hasOwnProperty('key') is true
+PASS 'key' in converter.testSequenceRecord() is true
+PASS converter.testSequenceRecord()['key'] is ['value', 'other value']
+PASS converter.setTestSequenceRecord({ 'Ā': ['value'] }) threw exception TypeError: Type error.
+converter.setTestSequenceRecord({ 'ÿ': ['value'] })
+PASS converter.testSequenceRecord()['ÿ'] is ['value']
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/js/dom/webidl-type-mapping.html (210917 => 210918)


--- trunk/LayoutTests/js/dom/webidl-type-mapping.html	2017-01-19 08:08:38 UTC (rev 210917)
+++ trunk/LayoutTests/js/dom/webidl-type-mapping.html	2017-01-19 08:21:37 UTC (rev 210918)
@@ -659,39 +659,39 @@
 // testNodeRecord is a record<USVString, Node> attribute
 // testSequenceRecord is a record<ByteString, sequence<DOMString>> attribute
 
-evalAndLog("converter.testLongRecord = { key: 1, key2: 2 }");
-shouldBeType("converter.testLongRecord", "Object");
-shouldBeTrue("converter.testLongRecord.hasOwnProperty('key')");
-shouldBeTrue("'key' in converter.testLongRecord");
-shouldBe("converter.testLongRecord['key']", "1");
-shouldBeTrue("converter.testLongRecord.hasOwnProperty('key2')");
-shouldBeTrue("'key2' in converter.testLongRecord");
-shouldBe("converter.testLongRecord['key2']", "2");
-evalAndLog("converter.testLongRecord = undefined");
-shouldBeType("converter.testLongRecord", "Object");
-evalAndLog("converter.testLongRecord = null");
-shouldBeType("converter.testLongRecord", "Object");
-shouldThrow("converter.testLongRecord = 1");
-shouldThrow("converter.testLongRecord = { key: { valueOf:function() { throw new Error(); } } }");
-evalAndLog("var o = { otherKey: 2 }; Object.defineProperty(o, 'key', { enumerable: false, value: 1 }); converter.testLongRecord = o;");
-shouldBeFalse("converter.testLongRecord.hasOwnProperty('key')");
-shouldBeTrue("converter.testLongRecord.hasOwnProperty('otherKey')");
-shouldBe("converter.testLongRecord['otherKey']", "2");
-evalAndLog("var o = { otherKey: 2 }; Object.defineProperty(o, 'key', { get: function() { return 1; }, enumerable: true }); converter.testLongRecord = o;");
-shouldBeTrue("converter.testLongRecord.hasOwnProperty('key')");
-shouldBe("converter.testLongRecord['key']", "1");
-shouldBeTrue("converter.testLongRecord.hasOwnProperty('otherKey')");
-shouldBe("converter.testLongRecord['otherKey']", "2");
-shouldThrow("var o = { otherKey: 2 }; Object.defineProperty(o, 'key', { get: function() { throw new Error();; }, enumerable: true }); converter.testLongRecord = o;");
+evalAndLog("converter.setTestLongRecord({ key: 1, key2: 2 })");
+shouldBeType("converter.testLongRecord()", "Object");
+shouldBeTrue("converter.testLongRecord().hasOwnProperty('key')");
+shouldBeTrue("'key' in converter.testLongRecord()");
+shouldBe("converter.testLongRecord()['key']", "1");
+shouldBeTrue("converter.testLongRecord().hasOwnProperty('key2')");
+shouldBeTrue("'key2' in converter.testLongRecord()");
+shouldBe("converter.testLongRecord()['key2']", "2");
+evalAndLog("converter.setTestLongRecord(undefined)");
+shouldBeType("converter.testLongRecord()", "Object");
+evalAndLog("converter.setTestLongRecord(null)");
+shouldBeType("converter.testLongRecord()", "Object");
+shouldThrow("converter.setTestLongRecord(1)");
+shouldThrow("converter.setTestLongRecord({ key: { valueOf:function() { throw new Error(); } } })");
+evalAndLog("var o = { otherKey: 2 }; Object.defineProperty(o, 'key', { enumerable: false, value: 1 }); converter.setTestLongRecord(o);");
+shouldBeFalse("converter.testLongRecord().hasOwnProperty('key')");
+shouldBeTrue("converter.testLongRecord().hasOwnProperty('otherKey')");
+shouldBe("converter.testLongRecord()['otherKey']", "2");
+evalAndLog("var o = { otherKey: 2 }; Object.defineProperty(o, 'key', { get: function() { return 1; }, enumerable: true }); converter.setTestLongRecord(o);");
+shouldBeTrue("converter.testLongRecord().hasOwnProperty('key')");
+shouldBe("converter.testLongRecord()['key']", "1");
+shouldBeTrue("converter.testLongRecord().hasOwnProperty('otherKey')");
+shouldBe("converter.testLongRecord()['otherKey']", "2");
+shouldThrow("var o = { otherKey: 2 }; Object.defineProperty(o, 'key', { get: function() { throw new Error(); }, enumerable: true }); converter.setTestLongRecord(o);");
 
-evalAndLog("converter.testNodeRecord = { key: document, key2: document.documentElement }");
-shouldBeTrue("converter.testNodeRecord.hasOwnProperty('key')");
-shouldBeTrue("'key' in converter.testNodeRecord");
-shouldBe("converter.testNodeRecord['key']", "document");
-shouldBeTrue("converter.testNodeRecord.hasOwnProperty('key2')");
-shouldBeTrue("'key2' in converter.testNodeRecord");
-shouldBe("converter.testNodeRecord['key2']", "document.documentElement");
-shouldThrow("converter.testNodeRecord = { key: 'hello' }");
+evalAndLog("converter.setTestNodeRecord({ key: document, key2: document.documentElement })");
+shouldBeTrue("converter.testNodeRecord().hasOwnProperty('key')");
+shouldBeTrue("'key' in converter.testNodeRecord()");
+shouldBe("converter.testNodeRecord()['key']", "document");
+shouldBeTrue("converter.testNodeRecord().hasOwnProperty('key2')");
+shouldBeTrue("'key2' in converter.testNodeRecord()");
+shouldBe("converter.testNodeRecord()['key2']", "document.documentElement");
+shouldThrow("converter.setTestNodeRecord({ key: 'hello' })");
 
 [{input: "\uD800", expected: "\uFFFD"},
  {input: "\uDC00", expected: "\uFFFD"},
@@ -700,19 +700,19 @@
  {input: "\uDC00\uD800", expected: "\uFFFD\uFFFD"},
  {input: "\uD834\uDD1E", expected: "\uD834\uDD1E"},
 ].forEach(function(test) {
-    evalAndLog("converter.testLongRecord = {'" + test.input + "': 1 }");
-    shouldBe("converter.testLongRecord['" + test.input + "']", "1");
-    evalAndLog("converter.testNodeRecord = {'" + test.input + "': document }");
-    shouldBe("converter.testNodeRecord['" + test.expected + "']", "document");
+    evalAndLog("converter.setTestLongRecord({'" + test.input + "': 1 })");
+    shouldBe("converter.testLongRecord()['" + test.input + "']", "1");
+    evalAndLog("converter.setTestNodeRecord({'" + test.input + "': document })");
+    shouldBe("converter.testNodeRecord()['" + test.expected + "']", "document");
 });
 
-evalAndLog("converter.testSequenceRecord = { key: ['value', 'other value'] }");
-shouldBeTrue("converter.testSequenceRecord.hasOwnProperty('key')");
-shouldBeTrue("'key' in converter.testSequenceRecord");
-shouldBe("converter.testSequenceRecord['key']", "['value', 'other value']");
-shouldThrow("converter.testSequenceRecord = { '\u0100': ['value'] }");
-evalAndLog("converter.testSequenceRecord = { '\u00FF': ['value'] }");
-shouldBe("converter.testSequenceRecord['\u00FF']", "['value']");
+evalAndLog("converter.setTestSequenceRecord({ key: ['value', 'other value'] })");
+shouldBeTrue("converter.testSequenceRecord().hasOwnProperty('key')");
+shouldBeTrue("'key' in converter.testSequenceRecord()");
+shouldBe("converter.testSequenceRecord()['key']", "['value', 'other value']");
+shouldThrow("converter.setTestSequenceRecord({ '\u0100': ['value'] })");
+evalAndLog("converter.setTestSequenceRecord({ '\u00FF': ['value'] })");
+shouldBe("converter.testSequenceRecord()['\u00FF']", "['value']");
 
 </script>
 <script src=""

Modified: trunk/Source/WebCore/ChangeLog (210917 => 210918)


--- trunk/Source/WebCore/ChangeLog	2017-01-19 08:08:38 UTC (rev 210917)
+++ trunk/Source/WebCore/ChangeLog	2017-01-19 08:21:37 UTC (rev 210918)
@@ -1,3 +1,36 @@
+2017-01-18  Sam Weinig  <s...@webkit.org>
+
+        [WebIDL] Records should preserve _javascript_ object order
+        https://bugs.webkit.org/show_bug.cgi?id=167189
+
+        Reviewed by Alex Christensen.
+
+        Instead of modeling IDL records as HashMaps, use a Vector
+        of KeyValuePairs, to all preserving the iteration order.
+
+        * Modules/webdatabase/SQLResultSetRowList.cpp:
+        (WebCore::SQLResultSetRowList::item):
+        * Modules/webdatabase/SQLResultSetRowList.h:
+        Return a Vector rather than a HashMap.
+
+        * bindings/IDLTypes.h:
+        Change underlying type to be a Vector<KeyValuePair<K, V>>.
+
+        * bindings/js/JSDOMConvert.h:
+        Update conversion for new implementation type. For conversion
+        to JSValue, allow any type that can has an iterator of keyValuePairs.
+ 
+        * testing/TypeConversions.h:
+        (WebCore::TypeConversions::testLongRecord):
+        (WebCore::TypeConversions::setTestLongRecord):
+        (WebCore::TypeConversions::testNodeRecord):
+        (WebCore::TypeConversions::setTestNodeRecord):
+        (WebCore::TypeConversions::testSequenceRecord):
+        (WebCore::TypeConversions::setTestSequenceRecord):
+        * testing/TypeConversions.idl:
+        Update test IDL to use functions, since the spec mandates that
+        records can't be used with attributes.
+
 2017-01-18  Alex Christensen  <achristen...@webkit.org>
 
         Implement URLSearchParams's sort()

Modified: trunk/Source/WebCore/Modules/webdatabase/SQLResultSetRowList.cpp (210917 => 210918)


--- trunk/Source/WebCore/Modules/webdatabase/SQLResultSetRowList.cpp	2017-01-19 08:08:38 UTC (rev 210917)
+++ trunk/Source/WebCore/Modules/webdatabase/SQLResultSetRowList.cpp	2017-01-19 08:21:37 UTC (rev 210918)
@@ -43,17 +43,17 @@
     return m_result.size() / m_columns.size();
 }
 
-ExceptionOr<HashMap<String, SQLValue>> SQLResultSetRowList::item(unsigned index) const
+ExceptionOr<Vector<WTF::KeyValuePair<String, SQLValue>>> SQLResultSetRowList::item(unsigned index) const
 {
     if (index >= length())
         return Exception { INDEX_SIZE_ERR };
 
-    HashMap<String, SQLValue> result;
+    Vector<WTF::KeyValuePair<String, SQLValue>> result;
 
     unsigned numberOfColumns = m_columns.size();
     unsigned valuesIndex = index * numberOfColumns;
     for (unsigned i = 0; i < numberOfColumns; i++)
-        result.set(m_columns[i], m_result[valuesIndex + i]);
+        result.append({ m_columns[i], m_result[valuesIndex + i] });
 
     return WTFMove(result);
 }

Modified: trunk/Source/WebCore/Modules/webdatabase/SQLResultSetRowList.h (210917 => 210918)


--- trunk/Source/WebCore/Modules/webdatabase/SQLResultSetRowList.h	2017-01-19 08:08:38 UTC (rev 210917)
+++ trunk/Source/WebCore/Modules/webdatabase/SQLResultSetRowList.h	2017-01-19 08:21:37 UTC (rev 210918)
@@ -30,8 +30,7 @@
 
 #include "ExceptionOr.h"
 #include "SQLValue.h"
-#include <wtf/HashMap.h>
-#include <wtf/text/StringHash.h>
+#include <wtf/HashTraits.h>
 
 namespace WebCore {
 
@@ -46,7 +45,7 @@
     void addResult(const SQLValue& result) { m_result.append(result); }
 
     unsigned length() const;
-    ExceptionOr<HashMap<String, SQLValue>> item(unsigned index) const;
+    ExceptionOr<Vector<WTF::KeyValuePair<String, SQLValue>>> item(unsigned index) const;
 
 private:
     SQLResultSetRowList() { }

Modified: trunk/Source/WebCore/bindings/IDLTypes.h (210917 => 210918)


--- trunk/Source/WebCore/bindings/IDLTypes.h	2017-01-19 08:08:38 UTC (rev 210917)
+++ trunk/Source/WebCore/bindings/IDLTypes.h	2017-01-19 08:21:37 UTC (rev 210918)
@@ -156,11 +156,11 @@
     using ParameterType = const Vector<typename T::ImplementationType>&;
 };
 
-template<typename K, typename V> struct IDLRecord : IDLType<HashMap<typename K::ImplementationType, typename V::ImplementationType>> {
+template<typename K, typename V> struct IDLRecord : IDLType<Vector<WTF::KeyValuePair<typename K::ImplementationType, typename V::ImplementationType>>> {
     using KeyType = K;
     using ValueType = V;
 
-    using ParameterType = const HashMap<typename K::ImplementationType, typename V::ImplementationType>&;
+    using ParameterType = const Vector<WTF::KeyValuePair<typename K::ImplementationType, typename V::ImplementationType>>&;
 };
 
 template<typename T> struct IDLPromise : IDLType<DOMPromise<T>> {

Modified: trunk/Source/WebCore/bindings/js/JSDOMConvert.h (210917 => 210918)


--- trunk/Source/WebCore/bindings/js/JSDOMConvert.h	2017-01-19 08:08:38 UTC (rev 210917)
+++ trunk/Source/WebCore/bindings/js/JSDOMConvert.h	2017-01-19 08:21:37 UTC (rev 210918)
@@ -1271,8 +1271,10 @@
                 
                 // 4. If typedKey is already a key in result, set its value to typedValue.
                 // Note: This can happen when O is a proxy object.
+                // FIXME: Handle this case.
+                
                 // 5. Otherwise, append to result a mapping (typedKey, typedValue).
-                result.set(typedKey, typedValue);
+                result.append({ typedKey, typedValue });
             }
         }
 
@@ -1285,8 +1287,8 @@
     static constexpr bool needsState = true;
     static constexpr bool needsGlobalObject = true;
 
-    template<typename ValueType>
-    static JSC::JSValue convert(JSC::ExecState& state, JSDOMGlobalObject& globalObject, const HashMap<String, ValueType>& map)
+    template<typename MapType>
+    static JSC::JSValue convert(JSC::ExecState& state, JSDOMGlobalObject& globalObject, const MapType& map)
     {
         auto& vm = state.vm();
     

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (210917 => 210918)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2017-01-19 08:08:38 UTC (rev 210917)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2017-01-19 08:21:37 UTC (rev 210918)
@@ -297,7 +297,7 @@
     }
 
     if ($codeGenerator->IsRecordType($type)) {
-        AddToIncludes("<wtf/HashMap.h>", $includesRef, $conditional);
+        AddToIncludes("<wtf/Vector.h>", $includesRef, $conditional);
         AddToIncludesForIDLType(@{$type->subtypes}[0], $includesRef, $conditional);
         AddToIncludesForIDLType(@{$type->subtypes}[1], $includesRef, $conditional);
         return;
@@ -5327,7 +5327,7 @@
     return GetEnumerationClassName($type, $interface) if $codeGenerator->IsEnumType($type);
     return GetDictionaryClassName($type, $interface) if $codeGenerator->IsDictionaryType($type);
     return "Vector<" . GetNativeInnerType(@{$type->subtypes}[0], $interface) . ">" if $codeGenerator->IsSequenceOrFrozenArrayType($type);
-    return "HashMap<" . GetNativeInnerType(@{$type->subtypes}[0], $interface) . ", " . GetNativeInnerType(@{$type->subtypes}[1], $interface) . ">" if $codeGenerator->IsRecordType($type);
+    return "Vector<WTF::KeyValuePair<" . GetNativeInnerType(@{$type->subtypes}[0], $interface) . ", " . GetNativeInnerType(@{$type->subtypes}[1], $interface) . ">>" if $codeGenerator->IsRecordType($type);
 
     return "RefPtr<${typeName}>" if $codeGenerator->IsTypedArrayType($type) and $typeName ne "ArrayBuffer";
     return "${typeName}*";
@@ -5344,7 +5344,7 @@
     return GetEnumerationClassName($innerType, $interface) if $codeGenerator->IsEnumType($innerType);
     return GetDictionaryClassName($innerType, $interface) if $codeGenerator->IsDictionaryType($innerType);
     return "Vector<" . GetNativeInnerType(@{$innerType->subtypes}[0], $interface) . ">" if $codeGenerator->IsSequenceOrFrozenArrayType($innerType);
-    return "HashMap<" . GetNativeInnerType(@{$innerType->subtypes}[0], $interface) . ", " . GetNativeInnerType(@{$innerType->subtypes}[1], $interface) . ">" if $codeGenerator->IsRecordType($innerType);
+    return "Vector<WTF::KeyValuePair<" . GetNativeInnerType(@{$innerType->subtypes}[0], $interface) . ", " . GetNativeInnerType(@{$innerType->subtypes}[1], $interface) . ">>" if $codeGenerator->IsRecordType($innerType);
     return "RefPtr<$innerTypeName>";
 }
 

Modified: trunk/Source/WebCore/testing/TypeConversions.h (210917 => 210918)


--- trunk/Source/WebCore/testing/TypeConversions.h	2017-01-19 08:08:38 UTC (rev 210917)
+++ trunk/Source/WebCore/testing/TypeConversions.h	2017-01-19 08:21:37 UTC (rev 210918)
@@ -102,12 +102,12 @@
     const String& testByteString() const { return m_byteString; }
     void setTestByteString(const String& byteString) { m_byteString = byteString; }
 
-    const HashMap<String, int>& testLongRecord() const { return m_longRecord; }
-    void setTestLongRecord(const HashMap<String, int>& value) { m_longRecord = value; }
-    const HashMap<String, RefPtr<Node>>& testNodeRecord() const { return m_nodeRecord; }
-    void setTestNodeRecord(const HashMap<String, RefPtr<Node>>& value) { m_nodeRecord = value; }
-    const HashMap<String, Vector<String>>& testSequenceRecord() const { return m_sequenceRecord; }
-    void setTestSequenceRecord(const HashMap<String, Vector<String>>& value) { m_sequenceRecord = value; }
+    const Vector<WTF::KeyValuePair<String, int>>& testLongRecord() const { return m_longRecord; }
+    void setTestLongRecord(const Vector<WTF::KeyValuePair<String, int>>& value) { m_longRecord = value; }
+    const Vector<WTF::KeyValuePair<String, RefPtr<Node>>>& testNodeRecord() const { return m_nodeRecord; }
+    void setTestNodeRecord(const Vector<WTF::KeyValuePair<String, RefPtr<Node>>>& value) { m_nodeRecord = value; }
+    const Vector<WTF::KeyValuePair<String, Vector<String>>>& testSequenceRecord() const { return m_sequenceRecord; }
+    void setTestSequenceRecord(const Vector<WTF::KeyValuePair<String, Vector<String>>>& value) { m_sequenceRecord = value; }
 
     using TestUnion = Variant<String, int, bool, RefPtr<Node>, Vector<int>>;
     const TestUnion& testUnion() const { return m_union; }
@@ -150,9 +150,9 @@
     String m_string;
     String m_usvstring;
     String m_byteString;
-    HashMap<String, int> m_longRecord;
-    HashMap<String, RefPtr<Node>> m_nodeRecord;
-    HashMap<String, Vector<String>> m_sequenceRecord;
+    Vector<WTF::KeyValuePair<String, int>> m_longRecord;
+    Vector<WTF::KeyValuePair<String, RefPtr<Node>>> m_nodeRecord;
+    Vector<WTF::KeyValuePair<String, Vector<String>>> m_sequenceRecord;
     TestUnion m_union;
     
     int m_typeConversionsDictionaryLongValue { 0 };

Modified: trunk/Source/WebCore/testing/TypeConversions.idl (210917 => 210918)


--- trunk/Source/WebCore/testing/TypeConversions.idl	2017-01-19 08:08:38 UTC (rev 210917)
+++ trunk/Source/WebCore/testing/TypeConversions.idl	2017-01-19 08:21:37 UTC (rev 210918)
@@ -54,10 +54,15 @@
     attribute ByteString testByteString;
     attribute USVString testUSVString;
 
-    attribute record<DOMString, long> testLongRecord;
-    attribute record<USVString, Node> testNodeRecord;
-    attribute record<ByteString, sequence<DOMString>> testSequenceRecord;
+    void setTestLongRecord(record<DOMString, long> record);
+    record<DOMString, long> testLongRecord();
 
+    void setTestNodeRecord(record<USVString, Node> record);
+    record<USVString, Node> testNodeRecord();
+
+    void setTestSequenceRecord(record<ByteString, sequence<DOMString>> record);
+    record<ByteString, sequence<DOMString>> testSequenceRecord();
+
     attribute (DOMString or long or boolean or Node or sequence<long>) testUnion;
     
     void setTypeConversionsDictionary(TypeConversionsDictionary d);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to