RESOLVED FIXED Bug 192671
CSS Typed OM should expose attributeStyleMap
https://bugs.webkit.org/show_bug.cgi?id=192671
Summary CSS Typed OM should expose attributeStyleMap
Justin Michaud
Reported 2018-12-13 11:45:56 PST
CSS Typed OM should expose attributeStyleMap
Attachments
Patch (36.17 KB, patch)
2018-12-13 11:52 PST, Justin Michaud
no flags
Patch (35.37 KB, patch)
2018-12-13 11:56 PST, Justin Michaud
no flags
Patch (38.88 KB, patch)
2018-12-13 17:00 PST, Justin Michaud
no flags
Archive of layout-test-results from ews103 for mac-sierra (2.80 MB, application/zip)
2018-12-13 18:07 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews106 for mac-sierra-wk2 (3.52 MB, application/zip)
2018-12-13 18:41 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews116 for mac-sierra (2.00 MB, application/zip)
2018-12-13 19:02 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews126 for ios-simulator-wk2 (2.41 MB, application/zip)
2018-12-13 19:03 PST, EWS Watchlist
no flags
Patch (52.60 KB, patch)
2018-12-13 19:37 PST, Justin Michaud
no flags
Archive of layout-test-results from ews103 for mac-sierra (2.51 MB, application/zip)
2018-12-13 20:51 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews112 for mac-sierra (2.24 MB, application/zip)
2018-12-13 21:32 PST, EWS Watchlist
no flags
Patch (74.46 KB, patch)
2018-12-14 14:18 PST, Justin Michaud
no flags
Patch (73.79 KB, patch)
2018-12-14 15:10 PST, Justin Michaud
no flags
Patch (73.86 KB, patch)
2018-12-14 15:16 PST, Justin Michaud
no flags
Archive of layout-test-results from ews206 for win-future (12.83 MB, application/zip)
2018-12-14 18:11 PST, EWS Watchlist
no flags
Patch (67.69 KB, patch)
2018-12-17 22:41 PST, Justin Michaud
no flags
Patch (68.48 KB, patch)
2018-12-17 22:49 PST, Justin Michaud
no flags
Patch (68.47 KB, patch)
2018-12-18 10:01 PST, Justin Michaud
no flags
Justin Michaud
Comment 1 2018-12-13 11:52:03 PST
Justin Michaud
Comment 2 2018-12-13 11:56:19 PST
Ryosuke Niwa
Comment 3 2018-12-13 13:28:47 PST
Comment on attachment 357243 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=357243&action=review > Source/WebCore/ChangeLog:7 > + You should add a description as to what you're implementing. > Source/WebCore/css/ElementCSSInlineStyle.idl:32 > + [SameObject, EnabledAtRuntime=CSSTypedOM, Conditional=CSS_TYPED_OM] readonly attribute StylePropertyMap attributeStyleMap; SameObject isn't supported hence the FIXME right above. So that the same thing here. > Source/WebCore/css/typedom/StylePropertyMap.idl:32 > +] interface StylePropertyMap : StylePropertyMapReadOnly { You need GenerateIsReachable=ImplOwnerNodeRoot and make StylePropertyMapReadOnly reachable from GC when the element is alive to get the same effect as SameObject.
Ryosuke Niwa
Comment 4 2018-12-13 13:30:29 PST
Right now, your code has a bug that if you call element.attributeStyleMap, let GC run, and then access element.attributeStyleMap again, then we'd create a new JS wrapper. That is, if you had inserted element.attributeStyleMap into a WeakMap/WeakSet and/or you added a property onto it, then we'd lose that entry / property when GC runs.
Ryosuke Niwa
Comment 5 2018-12-13 13:34:00 PST
Comment on attachment 357243 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=357243&action=review > Source/WebCore/css/typedom/StylePropertyMapReadOnly.h:46 > + struct StylePropertyMapImpl { > + virtual ~StylePropertyMapImpl() = default; > + virtual RefPtr<TypedOMCSSStyleValue> get(const String& property) const = 0; > + }; Why do we need a separate object for this? Why can't StylePropertyMapReadOnly simply provide some overridable virtual functions instead? Is the intent that multiple StylePropertyMapReadOnly would share a simple implementation? When would that happen? > Source/WebCore/dom/StyledElement.cpp:124 > + if (!ensureElementRareData().attributeStyleMap()) > + elementRareData()->setAttributeStyleMap(StylePropertyMap::create(makeUniqueRef<StyledElementInlineStylePropertyMapImpl>(*this))); > + return *elementRareData()->attributeStyleMap(); Calling ensureElementRareData() three times is efficient. Store a reference to it the first time you call it.
Ryosuke Niwa
Comment 6 2018-12-13 13:34:27 PST
Comment on attachment 357243 [details] Patch r- because of the above issues and build failures.
Justin Michaud
Comment 7 2018-12-13 17:00:37 PST
EWS Watchlist
Comment 8 2018-12-13 18:07:18 PST Comment hidden (obsolete)
EWS Watchlist
Comment 9 2018-12-13 18:07:19 PST Comment hidden (obsolete)
EWS Watchlist
Comment 10 2018-12-13 18:41:53 PST Comment hidden (obsolete)
EWS Watchlist
Comment 11 2018-12-13 18:41:55 PST Comment hidden (obsolete)
EWS Watchlist
Comment 12 2018-12-13 19:02:50 PST Comment hidden (obsolete)
EWS Watchlist
Comment 13 2018-12-13 19:02:52 PST Comment hidden (obsolete)
EWS Watchlist
Comment 14 2018-12-13 19:03:26 PST Comment hidden (obsolete)
EWS Watchlist
Comment 15 2018-12-13 19:03:28 PST Comment hidden (obsolete)
Justin Michaud
Comment 16 2018-12-13 19:22:11 PST
(In reply to Ryosuke Niwa from comment #5) > > Why do we need a separate object for this? Why can't > StylePropertyMapReadOnly simply provide some overridable virtual functions > instead? > Is the intent that multiple StylePropertyMapReadOnly would share a simple > implementation? > When would that happen? This is more for bindings. StylePropertyMap inherits from StylePropertyMapReadOnly, and I didn't want to have to disable bindings hardening or write my own toJS function. I think (?) that I would need to do at least one of those things if I tried to pass a subclass of StylePropertyMap to toJS.
Justin Michaud
Comment 17 2018-12-13 19:37:43 PST
Ryosuke Niwa
Comment 18 2018-12-13 19:41:44 PST
(In reply to Justin Michaud from comment #16) > (In reply to Ryosuke Niwa from comment #5) > > > > Why do we need a separate object for this? Why can't > > StylePropertyMapReadOnly simply provide some overridable virtual functions > > instead? > > Is the intent that multiple StylePropertyMapReadOnly would share a simple > > implementation? > > When would that happen? > > This is more for bindings. StylePropertyMap inherits from > StylePropertyMapReadOnly, and I didn't want to have to disable bindings > hardening or write my own toJS function. I think (?) that I would need to do > at least one of those things if I tried to pass a subclass of > StylePropertyMap to toJS. Just remove ImplementationLacksVTable from IDL then you should be able to use inheritance. There is no need to avoid using virtual function table for this.
EWS Watchlist
Comment 19 2018-12-13 20:51:09 PST Comment hidden (obsolete)
EWS Watchlist
Comment 20 2018-12-13 20:51:11 PST Comment hidden (obsolete)
EWS Watchlist
Comment 21 2018-12-13 21:32:06 PST Comment hidden (obsolete)
EWS Watchlist
Comment 22 2018-12-13 21:32:08 PST Comment hidden (obsolete)
Justin Michaud
Comment 23 2018-12-14 13:32:12 PST
(In reply to Ryosuke Niwa from comment #18) > (In reply to Justin Michaud from comment #16) > > (In reply to Ryosuke Niwa from comment #5) > > > > > > Why do we need a separate object for this? Why can't > > > StylePropertyMapReadOnly simply provide some overridable virtual functions > > > instead? > > > Is the intent that multiple StylePropertyMapReadOnly would share a simple > > > implementation? > > > When would that happen? > > > > This is more for bindings. StylePropertyMap inherits from > > StylePropertyMapReadOnly, and I didn't want to have to disable bindings > > hardening or write my own toJS function. I think (?) that I would need to do > > at least one of those things if I tried to pass a subclass of > > StylePropertyMap to toJS. > > Just remove ImplementationLacksVTable from IDL then you should be able to > use inheritance. There is no need to avoid using virtual function table for > this. I did need to disable binding hardening, although since there are no IDL subclasses, thankfully I don't need a custom toJS function like in TypedOMCSSStyleValue.
Justin Michaud
Comment 24 2018-12-14 14:18:41 PST
Justin Michaud
Comment 25 2018-12-14 14:21:00 PST
Once the bots pass, I am going to roll the bindings generator changes into a separate patch.
Justin Michaud
Comment 26 2018-12-14 15:10:46 PST
Justin Michaud
Comment 27 2018-12-14 15:16:01 PST
EWS Watchlist
Comment 28 2018-12-14 18:11:34 PST Comment hidden (obsolete)
EWS Watchlist
Comment 29 2018-12-14 18:11:45 PST Comment hidden (obsolete)
Ryosuke Niwa
Comment 30 2018-12-17 13:04:10 PST
Huh, css-typedom/attributeStyleMap.html is failing on Windows. Do we know why what's happening here?
Justin Michaud
Comment 31 2018-12-17 14:44:44 PST
(In reply to Ryosuke Niwa from comment #30) > Huh, css-typedom/attributeStyleMap.html is failing on Windows. Do we know > why what's happening here? The feature flag only works with WK2, but I forgot to change the windows test expectations.
Ryosuke Niwa
Comment 32 2018-12-17 14:54:25 PST
Comment on attachment 357347 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=357347&action=review > Source/WebCore/ChangeLog:18 > + * css/ElementCSSInlineStyle.idl: You're missing an entry for CodeGeneratorJS.pm. Please add it with a description as to what you're changing. > Source/WebCore/css/typedom/StylePropertyMap.h:38 > +public: I don't think we need to have this access specifier. > Source/WebCore/dom/StyledElement.cpp:89 > + auto* registered = element.document().getCSSRegisteredCustomPropertySet().get(name); Nit: we should probably address this in a separate patch but our coding guideline mandates that this function, which doesn't have an out argument, to not have "get" prefix: https://webkit.org/code-style-guidelines/#names-out-argument > Source/WebCore/platform/graphics/CustomPaintImage.cpp:62 > +static RefPtr<TypedOMCSSStyleValue> extractComputedProperty(const String& name, Element& element) Can we share this code with the one in StyledElement.cpp e.g. using a template? It's not great to duplicate this much code in two places.
Justin Michaud
Comment 33 2018-12-17 22:41:07 PST
Justin Michaud
Comment 34 2018-12-17 22:49:08 PST
Justin Michaud
Comment 35 2018-12-18 10:01:30 PST
WebKit Commit Bot
Comment 36 2018-12-18 10:51:14 PST
Comment on attachment 357574 [details] Patch Clearing flags on attachment: 357574 Committed r239341: <https://trac.webkit.org/changeset/239341>
WebKit Commit Bot
Comment 37 2018-12-18 10:51:16 PST
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 38 2018-12-18 10:52:47 PST
Note You need to log in before you can comment on or make changes to this bug.