RESOLVED FIXED Bug 88606
[Shadow DOM] Needs @host rule for ShadowDOM styling
https://bugs.webkit.org/show_bug.cgi?id=88606
Summary [Shadow DOM] Needs @host rule for ShadowDOM styling
Hajime Morrita
Reported 2012-06-07 19:09:30 PDT
http://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html#selecting-nodes-distributed-to-insertion-points > The :host pseudoclass represents the shadow host of a shadow DOM subtree. > If the contextual reference element set is empty or includes elements outside of a shadow DOM subtree, :host matches northing.
Attachments
WIP (47.82 KB, patch)
2012-07-30 04:16 PDT, Takashi Sakamoto
no flags
WIP (48.96 KB, patch)
2012-07-30 22:19 PDT, Takashi Sakamoto
no flags
WIP (43.03 KB, patch)
2012-07-31 02:45 PDT, Takashi Sakamoto
no flags
WIP (29.48 KB, patch)
2012-08-01 01:41 PDT, Takashi Sakamoto
no flags
WIP (32.62 KB, patch)
2012-08-01 01:52 PDT, Takashi Sakamoto
no flags
WIP (29.51 KB, patch)
2012-08-01 03:11 PDT, Takashi Sakamoto
no flags
WIP (32.84 KB, patch)
2012-08-07 03:19 PDT, Takashi Sakamoto
no flags
Patch (33.15 KB, patch)
2012-08-20 23:44 PDT, Takashi Sakamoto
no flags
Patch (36.48 KB, patch)
2012-09-02 23:08 PDT, Takashi Sakamoto
no flags
Patch (36.40 KB, patch)
2012-09-18 00:34 PDT, Takashi Sakamoto
no flags
Patch (38.79 KB, patch)
2012-09-20 21:54 PDT, Takashi Sakamoto
no flags
Patch (34.71 KB, patch)
2012-10-03 00:45 PDT, Takashi Sakamoto
no flags
Patch (39.69 KB, patch)
2012-10-09 02:25 PDT, Takashi Sakamoto
no flags
Patch (43.15 KB, patch)
2012-10-10 01:01 PDT, Takashi Sakamoto
no flags
Patch (43.19 KB, patch)
2012-10-11 00:50 PDT, Takashi Sakamoto
no flags
Patch (44.32 KB, patch)
2012-10-12 06:37 PDT, Takashi Sakamoto
no flags
Patch (44.30 KB, patch)
2012-10-17 00:56 PDT, Takashi Sakamoto
no flags
Patch (45.02 KB, patch)
2012-10-17 23:36 PDT, Takashi Sakamoto
no flags
Patch (41.78 KB, patch)
2012-10-19 03:48 PDT, Takashi Sakamoto
no flags
Patch (42.44 KB, patch)
2012-10-23 04:49 PDT, Takashi Sakamoto
no flags
Patch (42.52 KB, patch)
2012-10-23 19:09 PDT, Takashi Sakamoto
no flags
WIP (42.74 KB, patch)
2012-10-24 23:10 PDT, Takashi Sakamoto
no flags
Patch for landing (42.74 KB, patch)
2012-10-25 23:50 PDT, Takashi Sakamoto
no flags
Takashi Sakamoto
Comment 1 2012-07-30 04:16:35 PDT
Build Bot
Comment 2 2012-07-30 04:47:09 PDT
Build Bot
Comment 3 2012-07-30 05:42:32 PDT
Takashi Sakamoto
Comment 4 2012-07-30 22:19:38 PDT
Build Bot
Comment 5 2012-07-31 01:33:57 PDT
Build Bot
Comment 6 2012-07-31 02:34:07 PDT
Build Bot
Comment 7 2012-07-31 02:37:06 PDT
Takashi Sakamoto
Comment 8 2012-07-31 02:45:21 PDT
Dimitri Glazkov (Google)
Comment 9 2012-07-31 11:29:09 PDT
Comment on attachment 155477 [details] WIP View in context: https://bugs.webkit.org/attachment.cgi?id=155477&action=review There are several patches in here, to be landed separately. It's fine to work on this as one patch for now, however. ProTip: don't fill out the ChangeLog until you're ready to start landing. Otherwise, you'll end up rewriting it many times :) > Source/WebCore/html/HTMLStyleElement.cpp:155 > + if (hasHostRule()) > + if (ShadowRoot* sr = shadowRoot()) > + if (Element* host = sr->host()) { > + host->registerScopedHTMLStyleChild(); > + isHostRuleRegistered = true; > + } Wild to see this here. Why can't we do this when we're adding rules in StyleResolver, like all other machinery in CSS does? > Source/WebCore/html/HTMLStyleElement.cpp:185 > + if (m_scopedStyleRegistrationState == RegisteredInShadowRootWithHostRule || m_scopedStyleRegistrationState == RegisteredAsScopedWithHostRule) > + if (ShadowRoot* sr = shadowRoot()) > + if (Element* host = sr->host()) > + host->unregisterScopedHTMLStyleChild(); You won't need any of these when you move @host accounting in styleresolver. > Source/WebCore/html/HTMLStyleElement.cpp:200 > +bool HTMLStyleElement::hasHostRule() const > +{ > + if (CSSStyleSheet* styleSheet = const_cast<HTMLStyleElement*>(this)->sheet()) > + return styleSheet->contents()->hasHostRule(); > + return false; > +} Or these. > Source/WebCore/html/shadow/HTMLShadowElement.h:56 > + bool m_registeredWithShadowRoot; It seems we're building an extra set of machinery for something that already exists. We already _know_ which shadow trees are rendered or not by the time we've created the composed tree, which happens before style resolution. Please ask morrita@/hayato@ for guidance here.
Takashi Sakamoto
Comment 10 2012-08-01 01:41:50 PDT
Takashi Sakamoto
Comment 11 2012-08-01 01:52:58 PDT
Takashi Sakamoto
Comment 12 2012-08-01 03:11:30 PDT
Takashi Sakamoto
Comment 13 2012-08-01 03:21:36 PDT
Thank you for reviewing my WIP patch. (In reply to comment #9) > (From update of attachment 155477 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=155477&action=review > > There are several patches in here, to be landed separately. It's fine to work on this as one patch for now, however. > > ProTip: don't fill out the ChangeLog until you're ready to start landing. Otherwise, you'll end up rewriting it many times :) I see. I recreated ChangeLog and removed all details about my patch. > > Source/WebCore/html/HTMLStyleElement.cpp:155 > > + if (hasHostRule()) > > + if (ShadowRoot* sr = shadowRoot()) > > + if (Element* host = sr->host()) { > > + host->registerScopedHTMLStyleChild(); > > + isHostRuleRegistered = true; > > + } > > Wild to see this here. Why can't we do this when we're adding rules in StyleResolver, like all other machinery in CSS does? > > > Source/WebCore/html/HTMLStyleElement.cpp:185 > > + if (m_scopedStyleRegistrationState == RegisteredInShadowRootWithHostRule || m_scopedStyleRegistrationState == RegisteredAsScopedWithHostRule) > > + if (ShadowRoot* sr = shadowRoot()) > > + if (Element* host = sr->host()) > > + host->unregisterScopedHTMLStyleChild(); > > You won't need any of these when you move @host accounting in styleresolver. > > > Source/WebCore/html/HTMLStyleElement.cpp:200 > > +bool HTMLStyleElement::hasHostRule() const > > +{ > > + if (CSSStyleSheet* styleSheet = const_cast<HTMLStyleElement*>(this)->sheet()) > > + return styleSheet->contents()->hasHostRule(); > > + return false; > > +} > > Or these. I see. As I decided to create the own matchHostRules or collectMatchingRules, I don't need to use m_scopedAuthorStyles now. I removed these codes and modified StyleResolver, i.e. adding m_atHostRules to class StyleResolver, not class RuleSet. > > > Source/WebCore/html/shadow/HTMLShadowElement.h:56 > > + bool m_registeredWithShadowRoot; > > It seems we're building an extra set of machinery for something that already exists. We already _know_ which shadow trees are rendered or not by the time we've created the composed tree, which happens before style resolution. Please ask morrita@/hayato@ for guidance here. I asked hayato-san and he said that it is possible to find insertion points when distributed nodes are given. However, when shadow roots are given, there are no direct way to find whether there are any <shadow> in the shadow DOM subtrees. He said, m_nodeToInsertionPoint's values() are insertion points. So, by using the following way: (1) obtaining treescope of each m_nodeToInsertionPoint value and (2) comparing the treescope with the given shadow root. we can find active insertion points. Is it better to try hayato-san's way and to file a new bug: "improve performance of finding <shadow>"? Best regards, Takashi Sakamoto
Takashi Sakamoto
Comment 14 2012-08-07 03:19:15 PDT
Takashi Sakamoto
Comment 15 2012-08-20 23:44:41 PDT
Dimitri Glazkov (Google)
Comment 16 2012-08-22 15:06:44 PDT
Comment on attachment 159626 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=159626&action=review > Source/WebCore/css/StyleResolver.cpp:1046 > + for (ShadowRoot* shadowRoot = shadow->youngestShadowRoot(); shadowRoot; shadowRoot = shadowRoot->olderShadowRoot()) { > + if (atHostRuleSetForScope(shadowRoot)) > + return true; > + if (!shadowRoot->hasShadowInsertionPoint()) > + break; > + } Can we cache this value on ElementShadow? > Source/WebCore/css/StyleResolver.cpp:1069 > + Vector<RuleSet*, 16> matchedRules; > + for (ShadowRoot* shadowRoot = shadow->youngestShadowRoot(); shadowRoot; shadowRoot = shadowRoot->olderShadowRoot()) { > + if (RuleSet* ruleSet = atHostRuleSetForScope(shadowRoot)) > + matchedRules.append(ruleSet); > + if (!shadowRoot->hasShadowInsertionPoint()) > + break; > + } > + if (matchedRules.isEmpty()) > + return; Ah, this could be on ElementShadow, just as I suggested above. Basically, maintain a list of activeShadowRoots (the interesting bit is that you only need to store one value, the last visible shadow root from the stack). This should allow you to make the patch neatly splittable into the section where we first expose the ElementShadow::activeShadowRoots along with window.internals tests for it, and then a trivial patch of adding the support @host rules. WDYT?
Takashi Sakamoto
Comment 17 2012-08-28 03:29:41 PDT
Comment on attachment 159626 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=159626&action=review Thank you for reviewing. I have not updated the patch yet, however I would like to confirm whether we should implement activeShadowRoots or not. >> Source/WebCore/css/StyleResolver.cpp:1046 >> + } > > Can we cache this value on ElementShadow? I see. We hav e to cache the value. I will implement. >> Source/WebCore/css/StyleResolver.cpp:1069 >> + return; > > Ah, this could be on ElementShadow, just as I suggested above. Basically, maintain a list of activeShadowRoots (the interesting bit is that you only need to store one value, the last visible shadow root from the stack). This should allow you to make the patch neatly splittable into the section where we first expose the ElementShadow::activeShadowRoots along with window.internals tests for it, and then a trivial patch of adding the support @host rules. WDYT? I think, we can add (or remove from)<style> which has some @host @-rules to any shadow dom subtree after adding the shadow dom subtree. So we have to update activeShadowRoots when childrenChanged in class ShadowRoot is invoked. And I think, by using the activeShadowRoots, we can only remove "if (!shadowRoot->hasShadowInsertionPoint())". ( I guess, it will take almost the same time to traverse activeShadowRoots as just to traverse shadow roots from the youngest one.) So I'm not sure whether we should implement activeShadowRoots. Do we need the list?
Takashi Sakamoto
Comment 18 2012-08-29 00:16:47 PDT
(In reply to comment #17) > (From update of attachment 159626 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=159626&action=review > > Thank you for reviewing. > I have not updated the patch yet, however I would like to confirm whether we should implement activeShadowRoots or not. > > >> Source/WebCore/css/StyleResolver.cpp:1046 > >> + } > > > > Can we cache this value on ElementShadow? > > I see. We hav e to cache the value. I will implement. > > >> Source/WebCore/css/StyleResolver.cpp:1069 > >> + return; > > > > Ah, this could be on ElementShadow, just as I suggested above. Basically, maintain a list of activeShadowRoots (the interesting bit is that you only need to store one value, the last visible shadow root from the stack). This should allow you to make the patch neatly splittable into the section where we first expose the ElementShadow::activeShadowRoots along with window.internals tests for it, and then a trivial patch of adding the support @host rules. WDYT? > > I think, we can add (or remove from)<style> which has some @host @-rules to any shadow dom subtree after adding the shadow dom subtree. So we have to update activeShadowRoots when childrenChanged in class ShadowRoot is invoked. > And I think, by using the activeShadowRoots, we can only remove "if (!shadowRoot->hasShadowInsertionPoint())". ( I guess, it will take almost the same time to traverse activeShadowRoots as just to traverse shadow roots from the youngest one.) > So I'm not sure whether we should implement activeShadowRoots. Do we need the list? I'm sorry. Not <style>, I mean <shadow>. Since it is possible to add/remove <shadow>, probably we have to maintain an entire list of active shadow roots.
Takashi Sakamoto
Comment 19 2012-09-02 23:08:45 PDT
Takashi Sakamoto
Comment 20 2012-09-18 00:34:22 PDT
Dimitri Glazkov (Google)
Comment 21 2012-09-19 10:21:35 PDT
Comment on attachment 164506 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=164506&action=review Thank you for working on this! > Source/WebCore/css/StyleResolver.cpp:1112 > + transferMatchedRules(result); This is wrong. We should somehow change the specificity of the @host at-rules, so that it all works as sort-and-match. Hmmm.. This might be a spec bug. > Source/WebCore/css/StyleResolver.h:556 > + RuleSet* atHostRuleSetForScope(const ShadowRoot*); > + bool matchesHostRules(); please group functions with functions and data with data. > Source/WebCore/dom/ShadowRoot.h:94 > + void registerShadowElement() { ++m_numberOfShadowElementChildren; } > + void unregisterShadowElement() { --m_numberOfShadowElementChildren; } > + bool hasShadowInsertionPoint() const { return m_numberOfShadowElementChildren > 0; } This seems like a separate, smaller patch.
Takashi Sakamoto
Comment 22 2012-09-20 21:54:30 PDT
Takashi Sakamoto
Comment 23 2012-09-20 21:59:47 PDT
Comment on attachment 164506 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=164506&action=review Thank you for reviewing. I filed a new bug 97184, which blocks this bug 88606. After finishing bug 97184, I will request review again. Best regards, Takashi Sakamoto >> Source/WebCore/css/StyleResolver.cpp:1112 >> + transferMatchedRules(result); > > This is wrong. We should somehow change the specificity of the @host at-rules, so that it all works as sort-and-match. Hmmm.. This might be a spec bug. I see. I modified "RuleSet::addStyleRule" and "RuleSet::addRule" to modify RuleData's specificity when the given style rule comes from @host @-rules. >> Source/WebCore/css/StyleResolver.h:556 >> + bool matchesHostRules(); > > please group functions with functions and data with data. Done. >> Source/WebCore/dom/ShadowRoot.h:94 >> + bool hasShadowInsertionPoint() const { return m_numberOfShadowElementChildren > 0; } > > This seems like a separate, smaller patch. I filed a new bug for this, i.e. https://bugs.webkit.org/show_bug.cgi?id=97184. My patch still has these changes... to pass cq-bot check. I will remove these changes after a patch for bug 97184 is landed.
Takashi Sakamoto
Comment 24 2012-10-03 00:45:47 PDT
Hajime Morrita
Comment 25 2012-10-03 03:51:38 PDT
Comment on attachment 166821 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=166821&action=review > Source/WebCore/css/StyleResolver.cpp:271 > + void addStyleRule(StyleRule*, bool hasDocumentSecurityOrigin, bool canUseFastCheckSelector, bool isInRegionRule = false, bool isHostRule = false); Let's turn the multiple boolean into a enum as a bit mask. something like "true, false, true" on the call side is readability disaster.
Takashi Sakamoto
Comment 26 2012-10-09 02:25:33 PDT
Takashi Sakamoto
Comment 27 2012-10-09 02:27:24 PDT
Comment on attachment 166821 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=166821&action=review >> Source/WebCore/css/StyleResolver.cpp:271 >> + void addStyleRule(StyleRule*, bool hasDocumentSecurityOrigin, bool canUseFastCheckSelector, bool isInRegionRule = false, bool isHostRule = false); > > Let's turn the multiple boolean into a enum as a bit mask. something like "true, false, true" on the call side is readability disaster. I see. Done.
Takashi Sakamoto
Comment 28 2012-10-10 01:01:36 PDT
Gyuyoung Kim
Comment 29 2012-10-10 01:06:33 PDT
Early Warning System Bot
Comment 30 2012-10-10 01:08:12 PDT
Build Bot
Comment 31 2012-10-10 01:08:47 PDT
Early Warning System Bot
Comment 32 2012-10-10 01:18:10 PDT
Build Bot
Comment 33 2012-10-10 01:57:53 PDT
Takashi Sakamoto
Comment 34 2012-10-11 00:50:25 PDT
Hajime Morrita
Comment 35 2012-10-12 00:38:24 PDT
Comment on attachment 168155 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=168155&action=review > Source/WebCore/css/RuleSet.h:50 > + RuleData(StyleRule*, unsigned selectorIndex, unsigned position, unsigned addRuleState); Coud you use AddRuleState instead of unsigned? > Source/WebCore/css/StyleResolver.cpp:438 > +void StyleResolver::addHostRule(StyleRuleHost* hostRule, bool hasDocumentSecurityOrigin, const ContainerNode* scope) Can we move this implementation more to StyleScopeResolver? Ideally all @host related code should be owned by StyleScopeResolver. I know it's unfeasible for now. But I think we could be better here. > Source/WebCore/css/StyleResolver.cpp:440 > +#if ENABLE(STYLE_SCOPED) This isn't related STYLE_SCOPED. This should be part of SHAODW_ROOT. > Source/WebCore/css/StyleResolver.cpp:781 > +#if ENABLE(STYLE_SCOPED) Ditto. > Source/WebCore/css/StyleResolver.cpp:790 > +#if ENABLE(STYLE_SCOPED) Ditto.
Takashi Sakamoto
Comment 36 2012-10-12 06:37:19 PDT
Takashi Sakamoto
Comment 37 2012-10-12 06:41:04 PDT
Comment on attachment 168155 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=168155&action=review Thank you for reviewing. >> Source/WebCore/css/RuleSet.h:50 >> + RuleData(StyleRule*, unsigned selectorIndex, unsigned position, unsigned addRuleState); > > Coud you use AddRuleState instead of unsigned? I see. Done. >> Source/WebCore/css/StyleResolver.cpp:438 >> +void StyleResolver::addHostRule(StyleRuleHost* hostRule, bool hasDocumentSecurityOrigin, const ContainerNode* scope) > > Can we move this implementation more to StyleScopeResolver? > Ideally all @host related code should be owned by StyleScopeResolver. > I know it's unfeasible for now. But I think we could be better here. I see. I moved.... So I created a new method to ensure m_scopeResolver, i.e. ensureScopeResolver to create (if needed) and obtain m_scopeResolver. Is this ok...? >> Source/WebCore/css/StyleResolver.cpp:440 >> +#if ENABLE(STYLE_SCOPED) > > This isn't related STYLE_SCOPED. This should be part of SHAODW_ROOT. I see. I modified to use ENABLE(SHADOW_DOM). >> Source/WebCore/css/StyleResolver.cpp:781 >> +#if ENABLE(STYLE_SCOPED) > > Ditto. Done. >> Source/WebCore/css/StyleResolver.cpp:790 >> +#if ENABLE(STYLE_SCOPED) > > Ditto. Done.
Takashi Sakamoto
Comment 38 2012-10-17 00:56:25 PDT
Hajime Morrita
Comment 39 2012-10-17 19:16:43 PDT
Comment on attachment 169112 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=169112&action=review > Source/WebCore/css/RuleSet.cpp:360 > + resolver->ensureScopeResolver()->addHostRule(static_cast<StyleRuleHost*>(rule), hasDocumentSecurityOrigin, scope); If possible I'd keep StyleScopeResovler as a n implementation detail of StyleResolver. > Source/WebCore/css/StyleResolver.cpp:795 > + matchHostRules(result, includeEmptyRules); Could you move this call int to matchScopedAuthorRules()? Then we can assume that we have m_scopedResolver > Source/WebCore/css/StyleResolver.h:34 > +#include "StyleScopeResolver.h" Can we eliminate this? > Source/WebCore/css/StyleResolver.h:76 > +class ShadowRoot; It looks we don't need this? > Source/WebCore/css/StyleRule.cpp:393 > +StyleRuleHost::StyleRuleHost(Vector<RefPtr<StyleRuleBase> >& adoptRules) it's fine to inline these in the header. > Source/WebCore/css/StyleRule.cpp:398 > +StyleRuleHost::StyleRuleHost(const StyleRuleHost& o) ditto. > Source/WebCore/css/StyleScopeResolver.cpp:195 > +bool StyleScopeResolver::styleSharingCandidateMatchesHostRules(const Element* element) How about to have a flag just for indicating existence of @host rules regardless that matches or not? This hidden side effect is adding complexity which we might not need. We can assume that many host rule will match to the host in many cases. That's why the author put @host rule after all.
Takashi Sakamoto
Comment 40 2012-10-17 23:36:33 PDT
Takashi Sakamoto
Comment 41 2012-10-17 23:38:27 PDT
Comment on attachment 169112 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=169112&action=review Thank you for reviewing. I updated the patch except styleSharingCandidateMatchesHostRules. I would like to confirm the comment about styleSharingCandidateMatchesHostRules. Best regards, Takashi Sakamoto >> Source/WebCore/css/RuleSet.cpp:360 >> + resolver->ensureScopeResolver()->addHostRule(static_cast<StyleRuleHost*>(rule), hasDocumentSecurityOrigin, scope); > > If possible I'd keep StyleScopeResovler as a n implementation detail of StyleResolver. I added a wrapper method to StyleScopeResolver::addHostRule to StyleResolver. The wrapper method looks like just ... "{ ensureScopeResolver()->addHostRule(...);". Now ensureScopeResolver is a private method. >> Source/WebCore/css/StyleResolver.cpp:795 >> + matchHostRules(result, includeEmptyRules); > > Could you move this call int to matchScopedAuthorRules()? Then we can assume that we have m_scopedResolver Sure. Done. >> Source/WebCore/css/StyleResolver.h:34 >> +#include "StyleScopeResolver.h" > > Can we eliminate this? I need StyleScopeResolver.h because addHostRule() and ensureScopeResolver() defined in StyleResolver.h need information about StyleScopeResolver. i.e. adoptPtr(new StyleScopeResolver()) and ensureScopeResolver()->addHostRule(...). Is it better to move these implementation into StyleResolver.cpp? >> Source/WebCore/css/StyleRule.cpp:393 >> +StyleRuleHost::StyleRuleHost(Vector<RefPtr<StyleRuleBase> >& adoptRules) > > it's fine to inline these in the header. Done. >> Source/WebCore/css/StyleRule.cpp:398 >> +StyleRuleHost::StyleRuleHost(const StyleRuleHost& o) > > ditto. Done. >> Source/WebCore/css/StyleScopeResolver.cpp:195 >> +bool StyleScopeResolver::styleSharingCandidateMatchesHostRules(const Element* element) > > How about to have a flag just for indicating existence of @host rules regardless that matches or not? > This hidden side effect is adding complexity which we might not need. > We can assume that many host rule will match to the host in many cases. That's why the author put @host rule after all. I would like to confirm this. Currently, I added a flag to ElementShadow and the flag caches whether any @host @-rule is applied to shadow host or not. So would you mean adding a flag to class Element or class RenderStyle and caching existence of @host @-rules instead of ElementShadow's flag?
Build Bot
Comment 42 2012-10-17 23:42:27 PDT
Early Warning System Bot
Comment 43 2012-10-17 23:43:31 PDT
Early Warning System Bot
Comment 44 2012-10-17 23:43:33 PDT
Hajime Morrita
Comment 45 2012-10-17 23:53:01 PDT
Comment on attachment 169112 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=169112&action=review >>> Source/WebCore/css/StyleScopeResolver.cpp:195 >>> +bool StyleScopeResolver::styleSharingCandidateMatchesHostRules(const Element* element) >> >> How about to have a flag just for indicating existence of @host rules regardless that matches or not? >> This hidden side effect is adding complexity which we might not need. >> We can assume that many host rule will match to the host in many cases. That's why the author put @host rule after all. > > I would like to confirm this. > Currently, I added a flag to ElementShadow and the flag caches whether any @host @-rule is applied to shadow host or not. > So would you mean adding a flag to class Element or class RenderStyle and caching existence of @host @-rules instead of ElementShadow's flag? Having the flag on ElementShadow is fine. I though we could have a flag that just implies whether the styles in shadow have @host rule or not since we can set the flag in StyleScopeResolver::addHostRule(). If it's not so straightforward, we could keep current approach. I prefer a tri-state enum rather than two bool values with uninitialized one - uninitialized values better not be used if possible.
Takashi Sakamoto
Comment 46 2012-10-18 20:41:13 PDT
I see. Thank you, Morita-san. I agree with you. I will update addHostRule. And I will also fix cq-. Best regards, Takashi Sakamoto (In reply to comment #45) > (From update of attachment 169112 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=169112&action=review > > >>> Source/WebCore/css/StyleScopeResolver.cpp:195 > >>> +bool StyleScopeResolver::styleSharingCandidateMatchesHostRules(const Element* element) > >> > >> How about to have a flag just for indicating existence of @host rules regardless that matches or not? > >> This hidden side effect is adding complexity which we might not need. > >> We can assume that many host rule will match to the host in many cases. That's why the author put @host rule after all. > > > > I would like to confirm this. > > Currently, I added a flag to ElementShadow and the flag caches whether any @host @-rule is applied to shadow host or not. > > So would you mean adding a flag to class Element or class RenderStyle and caching existence of @host @-rules instead of ElementShadow's flag? > > Having the flag on ElementShadow is fine. I though we could have a flag that just implies whether the styles in shadow have @host rule or not > since we can set the flag in StyleScopeResolver::addHostRule(). If it's not so straightforward, we could keep current approach. > I prefer a tri-state enum rather than two bool values with uninitialized one - uninitialized values better not be used if possible.
Takashi Sakamoto
Comment 47 2012-10-19 03:48:01 PDT
Takashi Sakamoto
Comment 48 2012-10-19 04:08:13 PDT
(In reply to comment #45) > (From update of attachment 169112 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=169112&action=review > > >>> Source/WebCore/css/StyleScopeResolver.cpp:195 > >>> +bool StyleScopeResolver::styleSharingCandidateMatchesHostRules(const Element* element) > >> > >> How about to have a flag just for indicating existence of @host rules regardless that matches or not? > >> This hidden side effect is adding complexity which we might not need. > >> We can assume that many host rule will match to the host in many cases. That's why the author put @host rule after all. > > > > I would like to confirm this. > > Currently, I added a flag to ElementShadow and the flag caches whether any @host @-rule is applied to shadow host or not. > > So would you mean adding a flag to class Element or class RenderStyle and caching existence of @host @-rules instead of ElementShadow's flag? > > Having the flag on ElementShadow is fine. I though we could have a flag that just implies whether the styles in shadow have @host rule or not > since we can set the flag in StyleScopeResolver::addHostRule(). If it's not so straightforward, we could keep current approach. > I prefer a tri-state enum rather than two bool values with uninitialized one - uninitialized values better not be used if possible. I filed a new bug, https://bugs.webkit.org/show_bug.cgi?id=99827 to add some flag which has information about whether any @host @-rules is applied or not. Best regards, Takashi Sakamoto
Hajime Morrita
Comment 49 2012-10-21 18:06:48 PDT
> >> Source/WebCore/css/StyleResolver.h:34 > >> +#include "StyleScopeResolver.h" > > > > Can we eliminate this? > > I need StyleScopeResolver.h because addHostRule() and ensureScopeResolver() defined in StyleResolver.h need information about StyleScopeResolver. i.e. > adoptPtr(new StyleScopeResolver()) and ensureScopeResolver()->addHostRule(...). > Is it better to move these implementation into StyleResolver.cpp? I think so. addHostRule() is guarded by isHost() thus won't be hot.
Hajime Morrita
Comment 50 2012-10-21 18:06:49 PDT
> >> Source/WebCore/css/StyleResolver.h:34 > >> +#include "StyleScopeResolver.h" > > > > Can we eliminate this? > > I need StyleScopeResolver.h because addHostRule() and ensureScopeResolver() defined in StyleResolver.h need information about StyleScopeResolver. i.e. > adoptPtr(new StyleScopeResolver()) and ensureScopeResolver()->addHostRule(...). > Is it better to move these implementation into StyleResolver.cpp? I think so. addHostRule() is guarded by isHost() thus won't be hot.
Hajime Morrita
Comment 51 2012-10-21 18:12:23 PDT
Comment on attachment 169594 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=169594&action=review Almost looks good. Added some nits comment. > Source/WebCore/css/CSSGrammar.y.in:907 > +before_host_rule: We need to #ifdef these. > Source/WebCore/css/CSSParser.cpp:9188 > + case 'h': Ditto. > Source/WebCore/css/RuleSet.h:34 > +enum AddRuleState { Nit: This isn't actually a state. Maybe flags? > Source/WebCore/css/StyleResolver.h:178 > + { Could you assert RuntimeEnabledFeatures::shadowDOMEnabled() || styleScoepedEnabled() here to emphasize this is only enabled with these features being on? > Source/WebCore/css/StyleScopeResolver.cpp:203 > + // FIXME(99827): add a new flag to ElementShadow and cache whether any Could you type the url instead of bug number? > Source/WebCore/css/StyleScopeResolver.cpp:225 > + // FIXME(99827): add a new flag to ElementShadow and cache whether any Ditto.
Hajime Morrita
Comment 52 2012-10-21 18:46:42 PDT
Comment on attachment 169594 [details] Patch oops.
Takashi Sakamoto
Comment 53 2012-10-23 04:49:18 PDT
Takashi Sakamoto
Comment 54 2012-10-23 04:50:44 PDT
Comment on attachment 169594 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=169594&action=review >> Source/WebCore/css/CSSGrammar.y.in:907 >> +before_host_rule: > > We need to #ifdef these. I see. Done. >> Source/WebCore/css/CSSParser.cpp:9188 >> + case 'h': > > Ditto. Done. >> Source/WebCore/css/RuleSet.h:34 >> +enum AddRuleState { > > Nit: This isn't actually a state. Maybe flags? I see. Now AddRuleFlag. >> Source/WebCore/css/StyleResolver.h:178 >> + { > > Could you assert RuntimeEnabledFeatures::shadowDOMEnabled() || styleScoepedEnabled() here to emphasize this is only enabled with these features being on? Sure. And I also added #ifdef here. >> Source/WebCore/css/StyleScopeResolver.cpp:203 >> + // FIXME(99827): add a new flag to ElementShadow and cache whether any > > Could you type the url instead of bug number? I added the url. >> Source/WebCore/css/StyleScopeResolver.cpp:225 >> + // FIXME(99827): add a new flag to ElementShadow and cache whether any > > Ditto. Done.
Hajime Morrita
Comment 55 2012-10-23 17:59:14 PDT
Comment on attachment 170124 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=170124&action=review OK, let's land and see! > Source/WebCore/css/RuleSet.h:34 > +enum AddRuleFlag { s/Flag/Flags/
Takashi Sakamoto
Comment 56 2012-10-23 19:09:35 PDT
Takashi Sakamoto
Comment 57 2012-10-23 19:10:34 PDT
Comment on attachment 170124 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=170124&action=review >> Source/WebCore/css/RuleSet.h:34 >> +enum AddRuleFlag { > > s/Flag/Flags/ Sure. Done.
WebKit Review Bot
Comment 58 2012-10-23 21:37:36 PDT
Comment on attachment 170292 [details] Patch Clearing flags on attachment: 170292 Committed r132303: <http://trac.webkit.org/changeset/132303>
WebKit Review Bot
Comment 59 2012-10-23 21:37:45 PDT
All reviewed patches have been landed. Closing bug.
Dominik Röttsches (drott)
Comment 60 2012-10-24 07:08:29 PDT
This is causing failures on EFL, pls. cmp bug 100246.
WebKit Review Bot
Comment 61 2012-10-24 14:17:49 PDT
Re-opened since this is blocked by bug 100287
Takashi Sakamoto
Comment 62 2012-10-24 23:10:35 PDT
Takashi Sakamoto
Comment 63 2012-10-24 23:16:44 PDT
I fixed two shadow dom test failures reported by https://bugs.webkit.org/show_bug.cgi?id=100246 : - fast/dom/shadow/shadowdom-dynamic-styling.html & fast/dom/shadow/style-scoped-not-enabled.html The reason why these tests failed is that I used #if ENABLE(STYLE_SCOPED) in StyleResolver::appendAuthorStyleSheets. The code should be #if ENABLE(STYLE_SCOPED) || ENABLE(SHADOW_DOM). Because if only SHADOW_DOM is enabled, my old patch will register styles in shadow dom subtrees with document. This is a problem. I'm now trying to find why my patch causes https://bugs.webkit.org/show_bug.cgi?id=100287 and crashes @host @-rules test. Best regards, Takashi Sakamoto
Takashi Sakamoto
Comment 64 2012-10-25 23:50:58 PDT
Created attachment 170831 [details] Patch for landing
Takashi Sakamoto
Comment 65 2012-10-25 23:52:54 PDT
(In reply to comment #63) > I'm now trying to find why my patch causes https://bugs.webkit.org/show_bug.cgi?id=100287 and crashes @host @-rules test. I obtained the comment that my patch doesn't cause the crashing in many popular sites. So after finishing the bug https://bugs.webkit.org/show_bug.cgi?id=100455, I would like to request cq?. Best regards, Takashi Sakamoto
Hajime Morrita
Comment 66 2012-10-26 04:01:30 PDT
Comment on attachment 170831 [details] Patch for landing Let's try again.
WebKit Review Bot
Comment 67 2012-10-26 04:33:39 PDT
Comment on attachment 170831 [details] Patch for landing Clearing flags on attachment: 170831 Committed r132618: <http://trac.webkit.org/changeset/132618>
WebKit Review Bot
Comment 68 2012-10-26 04:33:47 PDT
All reviewed patches have been landed. Closing bug.
Antti Koivisto
Comment 69 2012-11-14 06:32:16 PST
Comment on attachment 170831 [details] Patch for landing View in context: https://bugs.webkit.org/attachment.cgi?id=170831&action=review > Source/WebCore/css/CSSPropertySourceData.h:98 > + REGION_RULE, > + HOST_RULE HOST_RULE should be behind #if ENABLE(SHADOW_DOM) here too (and as a result everywhere it is used).
Hajime Morrita
Comment 70 2012-11-14 19:52:06 PST
> HOST_RULE should be behind #if ENABLE(SHADOW_DOM) here too (and as a result everywhere it is used). Thanks for the catch! Filed Bug 102321.
Note You need to log in before you can comment on or make changes to this bug.