Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Issue 2732093003: bindings: Add support for the record<K,V> WebIDL type. (Closed)

Created:
3 years, 9 months ago by Raphael Kubo da Costa (rakuco)
Modified:
3 years, 9 months ago
Reviewers:
haraken, bashi, Yuki
CC:
chromium-reviews, blink-reviews, blink-reviews-bindings_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

bindings: Add support for the record<K,V> WebIDL type. Records (https://heycam.github.io/webidl/#idl-record) are ordered associative arrays mapping instances of K to instances of V, where K must be a ByteString, a DOMString or an USVString. In C++, we represent records as Vector<std::pair<k,v>> (or HeapVector), which are converted from V8 objects via NativeValueTraits<IDLRecord<K, V>>::nativeValue() To convert the C++ Vectors back to V8 objects, we piggyback on already existing ToV8() overloads for Vector<std::pair<>> and HeapVector. The majority of the required work to support this new IDL type has already landed and concerned making it possible to convert JS values to arbitrary C++ types without knowing much about them (there is a single JS->C++ conversion function that needs to work for pretty much any JS data type). This CL mainly makes the Python bindings code aware of this new type and allows it to generate the appropriate JS->C++ and C++->V8 calls, and adds the IDLRecord NativeValueTraits template specialization mentioned above. All the rest is new tests and updates to existing expectations. It is also important to note that the JS->C++ conversion code relies on a NativeValueTraits specialization existing for the record value types, and they are always used regardless of whether they are the fastest way to convert data or not -- for example, it always creates and uses an ExceptionState even if the actual conversion functions do not use it (as is the case for toDOMWindow() or ScriptValue()). Finally, while here rename IDLSequence::MaybeWrappedCppType to IDLSequence::MaybeMemberCppType to avoid confusion (and do the same for IDLRecord), as "wrapper" in a bindings context tends to refer to the V8 wrapper for DOM objects, which is not the case here. BUG=685754 R=bashi@chromium.org,haraken@chromium.org,yukishiino@chromium.org Review-Url: https://codereview.chromium.org/2732093003 Cr-Commit-Position: refs/heads/master@{#456048} Committed: https://chromium.googlesource.com/chromium/src/+/90659e8a6bbc7e40ea3145c19af3138f484beb52

Patch Set 1 #

Patch Set 2 : Small build fix #

Patch Set 3 : Blind attempt at fixing Windows component builds #

Patch Set 4 : Remove static from isPropertyEnumerable #

Patch Set 5 : It turns out static was indeed necessary #

Total comments: 11

Patch Set 6 : Address most review comments #

Total comments: 24

Patch Set 7 : Address most review comments #

Patch Set 8 : Make isPropertyEnumerable rethrow exceptions in Get(), add more tests #

Total comments: 8

Patch Set 9 : s/oilpanRecordMember/garbageCollectedRecordMember/ #

Patch Set 10 : Remove isPropertyEnumerable and simplify the checks #

Total comments: 1

Patch Set 11 : s/isolate->GetCurrentContext()/context/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1229 lines, -25 lines) Patch
A third_party/WebKit/LayoutTests/bindings/record-type.html View 1 2 3 4 5 6 1 chunk +142 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/bindings/bindings.gni View 1 chunk +1 line, -0 lines 0 comments Download
M third_party/WebKit/Source/bindings/core/v8/BUILD.gn View 1 2 3 4 5 6 2 chunks +4 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/bindings/core/v8/IDLTypes.h View 1 2 3 4 5 2 chunks +33 lines, -3 lines 0 comments Download
M third_party/WebKit/Source/bindings/core/v8/IDLTypesTest.cpp View 1 chunk +22 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h View 1 2 3 4 5 6 7 8 9 10 1 chunk +125 lines, -0 lines 0 comments Download
A third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImplTest.cpp View 1 2 3 4 5 6 7 1 chunk +245 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/bindings/core/v8/ToV8.h View 1 2 3 4 5 6 1 chunk +2 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/bindings/scripts/v8_interface.py View 1 2 3 4 5 6 1 chunk +2 lines, -1 line 0 comments Download
M third_party/WebKit/Source/bindings/scripts/v8_types.py View 1 2 3 4 5 6 11 chunks +54 lines, -9 lines 0 comments Download
M third_party/WebKit/Source/bindings/scripts/v8_union.py View 4 chunks +13 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/bindings/templates/union_container.cpp.tmpl View 9 chunks +19 lines, -10 lines 0 comments Download
M third_party/WebKit/Source/bindings/tests/idls/core/TestDictionary.idl View 1 2 3 4 5 6 7 8 1 chunk +2 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/bindings/tests/idls/core/TestTypedefs.idl View 2 chunks +8 lines, -0 lines 0 comments Download
A third_party/WebKit/Source/bindings/tests/results/core/ByteStringSequenceSequenceOrByteStringByteStringRecord.h View 1 chunk +96 lines, -0 lines 0 comments Download
A third_party/WebKit/Source/bindings/tests/results/core/ByteStringSequenceSequenceOrByteStringByteStringRecord.cpp View 1 chunk +109 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/bindings/tests/results/core/TestDictionary.h View 1 2 3 4 5 6 7 8 4 chunks +12 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/bindings/tests/results/core/TestDictionary.cpp View 1 2 3 4 5 6 7 8 3 chunks +23 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/bindings/tests/results/core/V8TestDictionary.cpp View 1 2 3 4 5 6 7 8 4 chunks +38 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/bindings/tests/results/core/V8TestTypedefs.h View 2 chunks +5 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/bindings/tests/results/core/V8TestTypedefs.cpp View 5 chunks +82 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/BUILD.gn View 1 2 3 4 5 6 1 chunk +2 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/core_idl_files.gni View 1 2 3 4 5 6 1 chunk +1 line, -0 lines 0 comments Download
M third_party/WebKit/Source/core/testing/Internals.h View 2 chunks +2 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/testing/Internals.cpp View 1 2 3 4 5 6 2 chunks +5 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/testing/Internals.idl View 1 chunk +1 line, -0 lines 0 comments Download
A third_party/WebKit/Source/core/testing/RecordTest.h View 1 1 chunk +69 lines, -0 lines 0 comments Download
A third_party/WebKit/Source/core/testing/RecordTest.cpp View 1 chunk +83 lines, -0 lines 0 comments Download
A third_party/WebKit/Source/core/testing/RecordTest.idl View 1 chunk +29 lines, -0 lines 0 comments Download

Messages

Total messages: 53 (27 generated)
Raphael Kubo da Costa (rakuco)
PTAL. This is the last part of the record code that needs to make it ...
3 years, 9 months ago (2017-03-07 17:08:21 UTC) #9
Yuki
I think you need to use one of CORE_TEMPLATE_CLASS_EXPORT CORE_EXTERN_TEMPLATE_EXPORT CORE_TEMPALTE_EXPORT for templates. Of course, ...
3 years, 9 months ago (2017-03-08 13:37:52 UTC) #10
Raphael Kubo da Costa (rakuco)
Thanks for the review! I've addressed the items in my local checkout, and will upload ...
3 years, 9 months ago (2017-03-08 18:13:19 UTC) #11
Raphael Kubo da Costa (rakuco)
Patch v6 is up. The only thing that I didn't change was |originalValue| -> |value|, ...
3 years, 9 months ago (2017-03-08 19:33:16 UTC) #12
Yuki
https://codereview.chromium.org/2732093003/diff/80001/third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h File third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h (right): https://codereview.chromium.org/2732093003/diff/80001/third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h#newcode340 third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h:340: v8::Local<v8::Value> originalValue, On 2017/03/08 18:13:19, Raphael Kubo da Costa ...
3 years, 9 months ago (2017-03-09 08:32:55 UTC) #13
Yuki
LGTM with minor comments. https://codereview.chromium.org/2732093003/diff/100001/third_party/WebKit/LayoutTests/bindings/record-type.html File third_party/WebKit/LayoutTests/bindings/record-type.html (right): https://codereview.chromium.org/2732093003/diff/100001/third_party/WebKit/LayoutTests/bindings/record-type.html#newcode8 third_party/WebKit/LayoutTests/bindings/record-type.html:8: function assert_record_equals(obj, expected, description) { ...
3 years, 9 months ago (2017-03-09 10:10:08 UTC) #14
haraken
LGTM https://codereview.chromium.org/2732093003/diff/100001/third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h File third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h (right): https://codereview.chromium.org/2732093003/diff/100001/third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h#newcode340 third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h:340: ->GetOwnPropertyNames(context, Can this API fail? If it fails ...
3 years, 9 months ago (2017-03-09 12:52:56 UTC) #15
Yuki
https://codereview.chromium.org/2732093003/diff/100001/third_party/WebKit/Source/bindings/scripts/v8_types.py File third_party/WebKit/Source/bindings/scripts/v8_types.py (right): https://codereview.chromium.org/2732093003/diff/100001/third_party/WebKit/Source/bindings/scripts/v8_types.py#newcode923 third_party/WebKit/Source/bindings/scripts/v8_types.py:923: 'Date': 'v8DateOrNaN({isolate}, {cpp_value})', On 2017/03/09 12:52:55, haraken wrote: > ...
3 years, 9 months ago (2017-03-09 13:00:57 UTC) #16
Raphael Kubo da Costa (rakuco)
https://codereview.chromium.org/2732093003/diff/100001/third_party/WebKit/LayoutTests/bindings/record-type.html File third_party/WebKit/LayoutTests/bindings/record-type.html (right): https://codereview.chromium.org/2732093003/diff/100001/third_party/WebKit/LayoutTests/bindings/record-type.html#newcode8 third_party/WebKit/LayoutTests/bindings/record-type.html:8: function assert_record_equals(obj, expected, description) { On 2017/03/09 10:10:08, Yuki ...
3 years, 9 months ago (2017-03-09 16:08:34 UTC) #17
haraken
https://codereview.chromium.org/2732093003/diff/100001/third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h File third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h (right): https://codereview.chromium.org/2732093003/diff/100001/third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h#newcode437 third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h:437: return false; On 2017/03/09 16:08:34, Raphael Kubo da Costa ...
3 years, 9 months ago (2017-03-09 16:11:20 UTC) #18
Raphael Kubo da Costa (rakuco)
https://codereview.chromium.org/2732093003/diff/100001/third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h File third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h (right): https://codereview.chromium.org/2732093003/diff/100001/third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h#newcode437 third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h:437: return false; On 2017/03/09 16:11:20, haraken wrote: > On ...
3 years, 9 months ago (2017-03-09 16:16:31 UTC) #20
haraken
https://codereview.chromium.org/2732093003/diff/100001/third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h File third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h (right): https://codereview.chromium.org/2732093003/diff/100001/third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h#newcode437 third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h:437: return false; On 2017/03/09 16:16:30, Raphael Kubo da Costa ...
3 years, 9 months ago (2017-03-09 16:18:11 UTC) #21
Raphael Kubo da Costa (rakuco)
https://codereview.chromium.org/2732093003/diff/100001/third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h File third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h (right): https://codereview.chromium.org/2732093003/diff/100001/third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h#newcode437 third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h:437: return false; On 2017/03/09 16:18:11, haraken wrote: > On ...
3 years, 9 months ago (2017-03-09 16:36:06 UTC) #22
haraken
On 2017/03/09 16:36:06, Raphael Kubo da Costa (rakuco) wrote: > https://codereview.chromium.org/2732093003/diff/100001/third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h > File third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h (right): ...
3 years, 9 months ago (2017-03-09 17:49:36 UTC) #23
Raphael Kubo da Costa (rakuco)
On 2017/03/09 17:49:36, haraken wrote: > BTW, looking up "enumerable" is a right way to ...
3 years, 9 months ago (2017-03-09 22:54:57 UTC) #26
Raphael Kubo da Costa (rakuco)
Patch 8 is up: I've made isPropertyEnumerable() rethrow an exception in all cases, and added ...
3 years, 9 months ago (2017-03-09 22:57:38 UTC) #27
bashi
lgtm on my side (haraken@ and yukishiino@ may want to have another look) https://codereview.chromium.org/2732093003/diff/140001/third_party/WebKit/Source/bindings/tests/idls/core/TestDictionary.idl File ...
3 years, 9 months ago (2017-03-10 00:23:17 UTC) #28
Yuki
LGTM. https://codereview.chromium.org/2732093003/diff/140001/third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h File third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h (right): https://codereview.chromium.org/2732093003/diff/140001/third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h#newcode437 third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h:437: .ToLocal(&enumerable)) { You can safely use ToLocalChecked() here ...
3 years, 9 months ago (2017-03-10 06:54:32 UTC) #31
Raphael Kubo da Costa (rakuco)
https://codereview.chromium.org/2732093003/diff/140001/third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h File third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h (right): https://codereview.chromium.org/2732093003/diff/140001/third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h#newcode437 third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h:437: .ToLocal(&enumerable)) { On 2017/03/10 06:54:32, Yuki wrote: > You ...
3 years, 9 months ago (2017-03-10 08:19:09 UTC) #32
haraken
LGTM
3 years, 9 months ago (2017-03-10 09:22:38 UTC) #35
Yuki
https://codereview.chromium.org/2732093003/diff/140001/third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h File third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h (right): https://codereview.chromium.org/2732093003/diff/140001/third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h#newcode437 third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h:437: .ToLocal(&enumerable)) { On 2017/03/10 08:19:09, Raphael Kubo da Costa ...
3 years, 9 months ago (2017-03-10 09:52:22 UTC) #36
Raphael Kubo da Costa (rakuco)
https://codereview.chromium.org/2732093003/diff/140001/third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h File third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h (right): https://codereview.chromium.org/2732093003/diff/140001/third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h#newcode441 third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h:441: return toBoolean(isolate, enumerable, exceptionState); On 2017/03/10 09:52:21, Yuki wrote: ...
3 years, 9 months ago (2017-03-10 10:42:37 UTC) #39
Raphael Kubo da Costa (rakuco)
Patch v10 is up: isPropertyEnumerable() is gone since there's no need to handle ExceptionState in ...
3 years, 9 months ago (2017-03-10 10:52:04 UTC) #40
Yuki
LGTM. https://codereview.chromium.org/2732093003/diff/180001/third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h File third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h (right): https://codereview.chromium.org/2732093003/diff/180001/third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h#newcode389 third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImpl.h:389: ->Get(isolate->GetCurrentContext(), nit: s/isolate->GetCurrentContext()/context/ Maybe, desc.As<v8::Object>() is shorter? I ...
3 years, 9 months ago (2017-03-10 11:06:07 UTC) #43
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2732093003/200001
3 years, 9 months ago (2017-03-10 13:05:02 UTC) #50
commit-bot: I haz the power
3 years, 9 months ago (2017-03-10 13:10:15 UTC) #53
Message was sent while issue was closed.
Committed patchset #11 (id:200001) as
https://chromium.googlesource.com/chromium/src/+/90659e8a6bbc7e40ea3145c19af3...

Powered by Google App Engine
This is Rietveld 408576698