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

Issue 534133002: [WIP] bindings: Introduce PropertyBag (Closed)

Created:
6 years, 3 months ago by bashi
Modified:
6 years ago
CC:
blink-reviews, blink-reviews-bindings_chromium.org, arv+blink, Inactive, abarth-chromium
Base URL:
https://chromium.googlesource.com/chromium/blink.git@master
Project:
blink
Visibility:
Public.

Description

bindings: Add PropertyBag This is a work-in-progress CL and not intended to land. (This CL doesn't pass all layout tests now) To implement IDL dictionaries, we need a helper class that converts a V8 object's properties to native values. Currently DictionaryHelper does the job, but it's very complicated and difficult to extend. Using DictionaryHelper to implement IDL dictionaries will add further mess and I'd like to avoid that. However, it's somewhat difficult to clean up DictionaryHelper at this point. So I'd like to add a new class called PropertyBag for IDL dictionaries implementation. This class does a similar job to DictionaryHelper, but makes use of the CG and template specialization to reduce manually-written code. The idea is: - The GC generates T -> V8T conversion traits (PropertyBagTraits). - Add template functions which convert a V8 value to a native value in V8Binding.h (called nativeValueMayFail). These functions are used by PropertyBag::getInternal(). - PropertyBag has one get() method and some getInternal() methods. getInternal() will be defined for container types and types which require special handling. - We no longer need to add template specialization manually. Once we implement IDL dictionaries, we should be able to remove DictionaryHelper. However, DictionaryHelper is also used to initialize EventInits so we need to replace it with PropertyBag. In this CL, I added EventInitInitializer class to show how we can use PropertyBag to initialize EventInits. This CL removed DictionaryHelper, but I don't think we can do it now. My current plan is: - Add the minimum PropertyBag implementation for IDL dictionaries. (at this point, we will have some code duplication) - Implement all IDL dictionaries we need. - Use PropertyBag to initialize EventInits. - Remove Dictionary(Helper) from blink side. WDYT? If this approach sounds reasonable, I'll create CLs for actual review.

Patch Set 1 : #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1130 lines, -1410 lines) Patch
M LayoutTests/fast/dom/idl-dictionary-unittest.html View 1 chunk +58 lines, -23 lines 0 comments Download
M LayoutTests/fast/dom/idl-dictionary-unittest-expected.txt View 1 chunk +37 lines, -10 lines 0 comments Download
M LayoutTests/fast/events/constructors/message-event-constructor-expected.txt View 1 chunk +12 lines, -12 lines 0 comments Download
M Source/bindings/core/v8/CustomElementConstructorBuilder.cpp View 2 chunks +2 lines, -2 lines 0 comments Download
M Source/bindings/core/v8/Dictionary.h View 2 chunks +78 lines, -99 lines 0 comments Download
M Source/bindings/core/v8/Dictionary.cpp View 3 chunks +2 lines, -225 lines 0 comments Download
D Source/bindings/core/v8/DictionaryHelperForBindings.h View 1 chunk +0 lines, -70 lines 0 comments Download
D Source/bindings/core/v8/DictionaryHelperForCore.cpp View 1 chunk +0 lines, -655 lines 0 comments Download
A Source/bindings/core/v8/PropertyBag.h View 1 chunk +266 lines, -0 lines 0 comments Download
A Source/bindings/core/v8/PropertyBag.cpp View 1 chunk +87 lines, -0 lines 0 comments Download
A + Source/bindings/core/v8/PropertyBagTraits.h View 1 chunk +4 lines, -7 lines 0 comments Download
M Source/bindings/core/v8/V8Binding.h View 11 chunks +121 lines, -16 lines 0 comments Download
M Source/bindings/core/v8/V8Binding.cpp View 1 chunk +11 lines, -0 lines 0 comments Download
M Source/bindings/core/v8/custom/V8BlobCustomHelpers.cpp View 3 chunks +3 lines, -3 lines 0 comments Download
M Source/bindings/core/v8/custom/V8MessageEventCustom.cpp View 1 chunk +4 lines, -3 lines 0 comments Download
M Source/bindings/core/v8/v8.gypi View 2 chunks +3 lines, -2 lines 0 comments Download
A Source/bindings/modules/v8/DictionaryForModules.h View 1 chunk +13 lines, -0 lines 0 comments Download
D Source/bindings/modules/v8/DictionaryHelperForModules.cpp View 1 chunk +0 lines, -82 lines 0 comments Download
M Source/bindings/modules/v8/v8.gypi View 1 chunk +1 line, -1 line 0 comments Download
M Source/bindings/scripts/idl_types.py View 1 chunk +1 line, -0 lines 0 comments Download
M Source/bindings/scripts/v8_dictionary.py View 1 chunk +2 lines, -2 lines 0 comments Download
M Source/bindings/scripts/v8_interface.py View 2 chunks +2 lines, -1 line 0 comments Download
M Source/bindings/scripts/v8_types.py View 2 chunks +3 lines, -2 lines 0 comments Download
M Source/bindings/templates/dictionary_v8.h View 1 chunk +3 lines, -1 line 0 comments Download
M Source/bindings/templates/dictionary_v8.cpp View 1 chunk +6 lines, -5 lines 0 comments Download
M Source/bindings/templates/interface.h View 2 chunks +7 lines, -2 lines 0 comments Download
M Source/bindings/templates/interface.cpp View 2 chunks +13 lines, -12 lines 0 comments Download
M Source/bindings/tests/results/V8SVGTestInterface.h View 2 chunks +6 lines, -0 lines 0 comments Download
M Source/bindings/tests/results/V8TestDictionary.h View 1 chunk +3 lines, -1 line 0 comments Download
M Source/bindings/tests/results/V8TestDictionary.cpp View 1 chunk +20 lines, -18 lines 0 comments Download
M Source/bindings/tests/results/V8TestException.h View 2 chunks +6 lines, -0 lines 0 comments Download
M Source/bindings/tests/results/V8TestInterface.h View 2 chunks +6 lines, -0 lines 0 comments Download
M Source/bindings/tests/results/V8TestInterface2.h View 2 chunks +6 lines, -0 lines 0 comments Download
M Source/bindings/tests/results/V8TestInterface3.h View 2 chunks +6 lines, -0 lines 0 comments Download
M Source/bindings/tests/results/V8TestInterfaceCheckSecurity.h View 2 chunks +6 lines, -0 lines 0 comments Download
M Source/bindings/tests/results/V8TestInterfaceConstructor.h View 2 chunks +6 lines, -0 lines 0 comments Download
M Source/bindings/tests/results/V8TestInterfaceConstructor2.h View 2 chunks +6 lines, -0 lines 0 comments Download
M Source/bindings/tests/results/V8TestInterfaceConstructor3.h View 2 chunks +6 lines, -0 lines 0 comments Download
M Source/bindings/tests/results/V8TestInterfaceConstructor4.h View 2 chunks +6 lines, -0 lines 0 comments Download
M Source/bindings/tests/results/V8TestInterfaceCustomConstructor.h View 2 chunks +6 lines, -0 lines 0 comments Download
M Source/bindings/tests/results/V8TestInterfaceDocument.h View 2 chunks +6 lines, -0 lines 0 comments Download
M Source/bindings/tests/results/V8TestInterfaceEmpty.h View 2 chunks +6 lines, -0 lines 0 comments Download
M Source/bindings/tests/results/V8TestInterfaceEventConstructor.h View 3 chunks +8 lines, -2 lines 0 comments Download
M Source/bindings/tests/results/V8TestInterfaceEventConstructor.cpp View 3 chunks +22 lines, -21 lines 0 comments Download
M Source/bindings/tests/results/V8TestInterfaceEventTarget.h View 2 chunks +6 lines, -0 lines 0 comments Download
M Source/bindings/tests/results/V8TestInterfaceGarbageCollected.h View 2 chunks +6 lines, -0 lines 0 comments Download
M Source/bindings/tests/results/V8TestInterfaceNamedConstructor.h View 2 chunks +6 lines, -0 lines 0 comments Download
M Source/bindings/tests/results/V8TestInterfaceNamedConstructor2.h View 2 chunks +6 lines, -0 lines 0 comments Download
M Source/bindings/tests/results/V8TestInterfaceNode.h View 2 chunks +6 lines, -0 lines 0 comments Download
M Source/bindings/tests/results/V8TestInterfaceNotScriptWrappable.h View 2 chunks +6 lines, -0 lines 0 comments Download
M Source/bindings/tests/results/V8TestInterfaceWillBeGarbageCollected.h View 2 chunks +6 lines, -0 lines 0 comments Download
M Source/bindings/tests/results/V8TestNode.h View 2 chunks +6 lines, -0 lines 0 comments Download
M Source/bindings/tests/results/V8TestObject.h View 2 chunks +6 lines, -0 lines 0 comments Download
M Source/bindings/tests/results/V8TestObject.cpp View 1 chunk +2 lines, -1 line 0 comments Download
M Source/bindings/tests/results/V8TestSpecialOperations.h View 2 chunks +6 lines, -0 lines 0 comments Download
M Source/bindings/tests/results/V8TestSpecialOperationsNotEnumerable.h View 2 chunks +6 lines, -0 lines 0 comments Download
M Source/bindings/tests/results/V8TestTypedefs.h View 2 chunks +6 lines, -0 lines 0 comments Download
M Source/core/animation/AnimationTest.cpp View 1 chunk +2 lines, -2 lines 0 comments Download
M Source/core/animation/EffectInput.cpp View 3 chunks +5 lines, -5 lines 0 comments Download
M Source/core/animation/TimingInput.cpp View 1 chunk +9 lines, -9 lines 0 comments Download
M Source/core/css/FontFace.cpp View 1 chunk +6 lines, -6 lines 0 comments Download
M Source/core/dom/DOMPoint.cpp View 1 chunk +4 lines, -4 lines 0 comments Download
M Source/core/dom/Element.cpp View 4 chunks +4 lines, -4 lines 0 comments Download
M Source/core/dom/MutationObserver.cpp View 1 chunk +7 lines, -7 lines 0 comments Download
M Source/core/frame/LocalDOMWindow.cpp View 1 chunk +1 line, -1 line 0 comments Download
M Source/core/page/EventSource.cpp View 1 chunk +1 line, -1 line 0 comments Download
M Source/core/testing/DictionaryTest.h View 2 chunks +15 lines, -5 lines 0 comments Download
M Source/core/testing/DictionaryTest.cpp View 2 chunks +44 lines, -11 lines 0 comments Download
M Source/core/testing/InternalDictionary.idl View 1 chunk +10 lines, -3 lines 0 comments Download
M Source/modules/crypto/CryptoResultImpl.cpp View 1 chunk +4 lines, -0 lines 0 comments Download
M Source/modules/crypto/NormalizeAlgorithm.cpp View 6 chunks +6 lines, -6 lines 0 comments Download
M Source/modules/crypto/SubtleCrypto.cpp View 3 chunks +3 lines, -3 lines 0 comments Download
M Source/modules/encoding/TextDecoder.cpp View 2 chunks +3 lines, -3 lines 0 comments Download
M Source/modules/filesystem/FileSystemFlags.h View 1 chunk +2 lines, -2 lines 0 comments Download
M Source/modules/geofencing/CircularRegion.cpp View 1 chunk +4 lines, -4 lines 0 comments Download
M Source/modules/geolocation/PositionOptions.cpp View 2 chunks +3 lines, -3 lines 0 comments Download
M Source/modules/indexeddb/IDBDatabase.cpp View 1 chunk +2 lines, -2 lines 0 comments Download
M Source/modules/indexeddb/IDBObjectStore.cpp View 1 chunk +2 lines, -2 lines 0 comments Download
M Source/modules/mediastream/MediaConstraintsImpl.cpp View 2 chunks +2 lines, -2 lines 0 comments Download
M Source/modules/mediastream/RTCIceCandidate.cpp View 1 chunk +3 lines, -3 lines 0 comments Download
M Source/modules/mediastream/RTCPeerConnection.cpp View 7 chunks +17 lines, -17 lines 0 comments Download
M Source/modules/mediastream/RTCSessionDescription.cpp View 1 chunk +2 lines, -2 lines 0 comments Download
M Source/modules/mediastream/UserMediaRequest.cpp View 1 chunk +1 line, -1 line 0 comments Download
M Source/modules/notifications/Notification.cpp View 1 chunk +5 lines, -5 lines 0 comments Download
M Source/modules/serviceworkers/Headers.cpp View 3 chunks +3 lines, -3 lines 0 comments Download
M Source/modules/serviceworkers/RegistrationOptionList.h View 1 chunk +1 line, -1 line 0 comments Download
M Source/modules/serviceworkers/RequestInit.cpp View 2 chunks +7 lines, -7 lines 0 comments Download
M Source/modules/serviceworkers/Response.h View 1 chunk +1 line, -1 line 0 comments Download
M Source/modules/serviceworkers/ResponseInit.h View 2 chunks +5 lines, -5 lines 0 comments Download
M Source/modules/serviceworkers/ServiceWorkerClients.cpp View 1 chunk +1 line, -1 line 0 comments Download
M Source/modules/webmidi/MIDIOptions.h View 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 10 (5 generated)
bashi
Forgot to publish... Could you glance at this CL? The key changes are in Dictionary ...
6 years, 3 months ago (2014-09-09 00:27:39 UTC) #6
haraken
Overall the approach looks good. This CL definitely decreases the mess of the Dictionary implementation. ...
6 years, 3 months ago (2014-09-09 03:56:59 UTC) #7
bashi
On 2014/09/09 03:56:59, haraken wrote: > Overall the approach looks good. This CL definitely decreases ...
6 years, 3 months ago (2014-09-09 04:14:15 UTC) #8
haraken
On 2014/09/09 04:14:15, bashi1 wrote: > On 2014/09/09 03:56:59, haraken wrote: > > Overall the ...
6 years, 3 months ago (2014-09-09 04:17:36 UTC) #9
bashi
6 years, 3 months ago (2014-09-09 04:22:39 UTC) #10
On 2014/09/09 04:17:36, haraken wrote:
> On 2014/09/09 04:14:15, bashi1 wrote:
> > On 2014/09/09 03:56:59, haraken wrote:
> > > Overall the approach looks good. This CL definitely decreases the mess of
> the
> > > Dictionary implementation.
> > > 
> > > The only thing I don't fully understand is why we need nativeValueMayFail
> > > templates in V8Binding.h. Would there be any way to avoid adding the
> > templates?
> > 
> > We can generate V8T -> T conversion automatically, but for primitive types
and
> > container types, we need to write them manually (nativeValueMayFail and
> > getInternal in this CL). Maybe there is a way to avoid templates, but I
can't
> > come up with a neat solution. Another thoughts:
> > - For container types, we can move getInternal() to nativeValueMayFail()
> > - We may want to integrate nativeValue and nativeValueMayFail by adding
> > ExceptionState* to nativeValue as an argument
> > 
> > Anyway, we can defer this refactoring. Once we implement IDL dictionaries,
> this
> > work should be much easier.
> 
> OK, let's get back to the issue later. What I'm concerned about is we have a
lot
> of value conversion methods. In my ideal world, we want to have only two
> templates: one template for the V8 value => C++ value conversion and the other
> template for the C++ value => the V8 value conversion.

Yeah, we should have one pair of V8 value <=> C++ value conversion templates for
each T in an ideal world. V8Binding.h has too many conversions...

Powered by Google App Engine
This is Rietveld 408576698