WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
patch
slotted-6.patch (text/plain), 20.68 KB, created by
Antti Koivisto
on 2016-02-25 13:21:58 PST
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Antti Koivisto
Created:
2016-02-25 13:21:58 PST
Size:
20.68 KB
patch
obsolete
>Index: Source/WebCore/ChangeLog >=================================================================== >--- Source/WebCore/ChangeLog (revision 197127) >+++ Source/WebCore/ChangeLog (working copy) >@@ -1,3 +1,63 @@ >+2016-02-25 Antti Koivisto <antti@apple.com> >+ >+ Implement ::slotted pseudo element >+ https://bugs.webkit.org/show_bug.cgi?id=149441 >+ <rdar://problem/22731987> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * css/CSSGrammar.y.in: >+ >+ Parse ::slotted. >+ >+ * css/CSSParser.cpp: >+ (WebCore::CSSParser::detectFunctionTypeToken): >+ * css/CSSParserValues.cpp: >+ (WebCore::CSSParserSelector::parsePseudoElementCueFunctionSelector): >+ (WebCore::CSSParserSelector::parsePseudoElementSlottedFunctionSelector): >+ >+ Tokenize ::slotted. >+ >+ (WebCore::CSSParserSelector::parsePseudoClassAndCompatibilityElementSelector): >+ * css/CSSParserValues.h: >+ * css/CSSSelector.cpp: >+ (WebCore::CSSSelector::pseudoId): >+ * css/CSSSelector.h: >+ * css/ElementRuleCollector.cpp: >+ (WebCore::ElementRuleCollector::matchAuthorRules): >+ (WebCore::ElementRuleCollector::matchHostPseudoClassRules): >+ (WebCore::ElementRuleCollector::matchSlottedPseudoElementRules): >+ >+ Match ::slotted selector. >+ >+ (WebCore::ElementRuleCollector::collectSlottedPseudoElementRulesForSlot): >+ >+ Collect ::slotted rules that may apply to an element in a slot. >+ >+ (WebCore::ElementRuleCollector::matchUserRules): >+ (WebCore::ElementRuleCollector::matchUARules): >+ (WebCore::findSlottedPseudoElementSelector): >+ (WebCore::ElementRuleCollector::ruleMatches): >+ * css/ElementRuleCollector.h: >+ * css/RuleSet.cpp: >+ (WebCore::RuleSet::addRule): >+ >+ Collect ::slotted rules. >+ >+ (WebCore::RuleSet::shrinkToFit): >+ * css/RuleSet.h: >+ (WebCore::RuleSet::hostPseudoClassRules): >+ (WebCore::RuleSet::slottedPseudoElementRules): >+ (WebCore::RuleSet::focusPseudoClassRules): >+ (WebCore::RuleSet::universalRules): >+ * css/SelectorChecker.cpp: >+ (WebCore::SelectorChecker::checkOne): >+ * style/StyleSharingResolver.cpp: >+ (WebCore::Style::SharingResolver::resolve): >+ >+ Disable style sharing for children of shadow host. They may be affected by the shadow tree style >+ which is not considered in style sharing checks. >+ > 2016-02-25 Said Abou-Hallawa <sabouhallawa@apple.com> > > REGRESSION (r196268): Many assertion failures and crashes on SVG path animation tests when JS garbage collection happens quickly >Index: Source/WebCore/css/CSSGrammar.y.in >=================================================================== >--- Source/WebCore/css/CSSGrammar.y.in (revision 197027) >+++ Source/WebCore/css/CSSGrammar.y.in (working copy) >@@ -365,6 +365,12 @@ static bool selectorListDoesNotMatchAnyP > > #endif > >+#if ENABLE_SHADOW_DOM >+ >+%token <string> SLOTTEDFUNCTION >+ >+#endif >+ > %% > > stylesheet: >@@ -1357,6 +1363,11 @@ pseudo: > $$ = CSSParserSelector::parsePseudoElementCueFunctionSelector($3, $5); > } > #endif >+#if ENABLE_SHADOW_DOM >+ | ':' ':' SLOTTEDFUNCTION maybe_space simple_selector_list maybe_space ')' { >+ $$ = CSSParserSelector::parsePseudoElementSlottedFunctionSelector($3, $5); >+ } >+#endif > // use by :-webkit-any. > // FIXME: should we support generic selectors here or just simple_selectors? > // Use simple_selector_list for now to match -moz-any. >Index: Source/WebCore/css/CSSParser.cpp >=================================================================== >--- Source/WebCore/css/CSSParser.cpp (revision 197027) >+++ Source/WebCore/css/CSSParser.cpp (working copy) >@@ -11894,8 +11894,13 @@ inline bool CSSParser::detectFunctionTyp > m_token = MATCHESFUNCTION; > return true; > } >+#if ENABLE(SHADOW_DOM) >+ if (isEqualToCSSIdentifier(name, "slotted")) { >+ m_token = SLOTTEDFUNCTION; >+ return true; >+ } >+#endif > return false; >- > case 9: > if (isEqualToCSSIdentifier(name, "nth-child")) { > m_token = NTHCHILDFUNCTIONS; >Index: Source/WebCore/css/CSSParserValues.cpp >=================================================================== >--- Source/WebCore/css/CSSParserValues.cpp (revision 197027) >+++ Source/WebCore/css/CSSParserValues.cpp (working copy) >@@ -231,6 +231,24 @@ CSSParserSelector* CSSParserSelector::pa > } > #endif > >+#if ENABLE(SHADOW_DOM) >+CSSParserSelector* CSSParserSelector::parsePseudoElementSlottedFunctionSelector(const CSSParserString& functionIdentifier, Vector<std::unique_ptr<CSSParserSelector>>* parsedSelectorVector) >+{ >+ ASSERT_UNUSED(functionIdentifier, String(functionIdentifier) == "slotted("); >+ >+ std::unique_ptr<Vector<std::unique_ptr<CSSParserSelector>>> selectorVector(parsedSelectorVector); >+ >+ if (!selectorVector) >+ return nullptr; >+ >+ auto selector = std::make_unique<CSSParserSelector>(); >+ selector->m_selector->setMatch(CSSSelector::PseudoElement); >+ selector->m_selector->setPseudoElementType(CSSSelector::PseudoElementSlotted); >+ selector->adoptSelectorVector(*selectorVector); >+ return selector.release(); >+} >+#endif >+ > CSSParserSelector* CSSParserSelector::parsePseudoClassAndCompatibilityElementSelector(CSSParserString& pseudoTypeString) > { > if (pseudoTypeString.length() && pseudoTypeString[pseudoTypeString.length() - 1] == '(') >Index: Source/WebCore/css/CSSParserValues.h >=================================================================== >--- Source/WebCore/css/CSSParserValues.h (revision 197027) >+++ Source/WebCore/css/CSSParserValues.h (working copy) >@@ -203,7 +203,10 @@ class CSSParserSelector { > public: > static CSSParserSelector* parsePagePseudoSelector(const CSSParserString& pseudoTypeString); > static CSSParserSelector* parsePseudoElementSelector(CSSParserString& pseudoTypeString); >- static CSSParserSelector* parsePseudoElementCueFunctionSelector(const CSSParserString& functionIdentifier, Vector<std::unique_ptr<CSSParserSelector>>* selectorVector); >+ static CSSParserSelector* parsePseudoElementCueFunctionSelector(const CSSParserString& functionIdentifier, Vector<std::unique_ptr<CSSParserSelector>>*); >+#if ENABLE(SHADOW_DOM) >+ static CSSParserSelector* parsePseudoElementSlottedFunctionSelector(const CSSParserString& functionIdentifier, Vector<std::unique_ptr<CSSParserSelector>>*); >+#endif > static CSSParserSelector* parsePseudoClassAndCompatibilityElementSelector(CSSParserString& pseudoTypeString); > > CSSParserSelector(); >Index: Source/WebCore/css/CSSSelector.cpp >=================================================================== >--- Source/WebCore/css/CSSSelector.cpp (revision 197027) >+++ Source/WebCore/css/CSSSelector.cpp (working copy) >@@ -299,6 +299,9 @@ PseudoId CSSSelector::pseudoId(PseudoEle > #if ENABLE(VIDEO_TRACK) > case PseudoElementCue: > #endif >+#if ENABLE(SHADOW_DOM) >+ case PseudoElementSlotted: >+#endif > case PseudoElementUnknown: > case PseudoElementUserAgentCustom: > case PseudoElementWebKitCustom: >Index: Source/WebCore/css/CSSSelector.h >=================================================================== >--- Source/WebCore/css/CSSSelector.h (revision 197027) >+++ Source/WebCore/css/CSSSelector.h (working copy) >@@ -181,6 +181,9 @@ namespace WebCore { > PseudoElementScrollbarTrack, > PseudoElementScrollbarTrackPiece, > PseudoElementSelection, >+#if ENABLE(SHADOW_DOM) >+ PseudoElementSlotted, >+#endif > PseudoElementUserAgentCustom, > PseudoElementWebKitCustom, > }; >Index: Source/WebCore/css/ElementRuleCollector.cpp >=================================================================== >--- Source/WebCore/css/ElementRuleCollector.cpp (revision 197027) >+++ Source/WebCore/css/ElementRuleCollector.cpp (working copy) >@@ -36,6 +36,7 @@ > #include "CSSSelectorList.h" > #include "CSSValueKeywords.h" > #include "HTMLElement.h" >+#include "HTMLSlotElement.h" > #include "InspectorInstrumentation.h" > #include "NodeRenderStyle.h" > #include "RenderRegion.h" >@@ -206,6 +207,10 @@ void ElementRuleCollector::matchAuthorRu > #if ENABLE(SHADOW_DOM) > if (m_element.shadowRoot()) > matchHostPseudoClassRules(includeEmptyRules); >+ >+ auto* parent = m_element.parentNode(); >+ if (parent && parent->shadowRoot()) >+ matchSlottedPseudoElementRules(includeEmptyRules); > #endif > > clearMatchedRules(); >@@ -241,6 +246,59 @@ void ElementRuleCollector::matchHostPseu > // FIXME: Match the spec when it is finalized. > sortAndTransferMatchedRules(); > } >+ >+void ElementRuleCollector::matchSlottedPseudoElementRules(bool includeEmptyRules) >+{ >+ auto* hostShadowRoot = m_element.parentNode()->shadowRoot(); >+ ASSERT(hostShadowRoot); >+ auto* slot = hostShadowRoot->findAssignedSlot(m_element); >+ if (!slot) >+ return; >+ auto* shadowAuthorStyle = hostShadowRoot->styleResolver().ruleSets().authorStyle(); >+ if (!shadowAuthorStyle) >+ return; >+ // Find out if there are any ::slotted rules in the shadow tree matching the current slot. >+ // FIXME: This is really part of the slot style and could be cached when resolving it. >+ ElementRuleCollector collector(*slot, *shadowAuthorStyle, nullptr); >+ auto slottedPseudoElementRules = collector.collectSlottedPseudoElementRulesForSlot(includeEmptyRules); >+ if (slottedPseudoElementRules.isEmpty()) >+ return; >+ >+ TemporaryChange<bool> change(m_isMatchindSlottedPseudoElement, true); >+ >+ clearMatchedRules(); >+ m_result.ranges.lastAuthorRule = m_result.matchedProperties().size() - 1; >+ auto ruleRange = m_result.ranges.authorRuleRange(); >+ >+ // Match in the current scope. >+ MatchRequest matchRequest(nullptr, includeEmptyRules); >+ collectMatchingRulesForList(&slottedPseudoElementRules, matchRequest, ruleRange); >+ >+ // FIXME: What is the correct order? >+ sortAndTransferMatchedRules(); >+} >+ >+RuleSet::RuleDataVector ElementRuleCollector::collectSlottedPseudoElementRulesForSlot(bool includeEmptyRules) >+{ >+ ASSERT(is<HTMLSlotElement>(m_element)); >+ >+ clearMatchedRules(); >+ >+ m_mode = SelectorChecker::Mode::CollectingRules; >+ >+ // Match global author rules. >+ MatchRequest matchRequest(&m_authorStyle, includeEmptyRules); >+ StyleResolver::RuleRange ruleRange = m_result.ranges.authorRuleRange(); >+ collectMatchingRulesForList(&m_authorStyle.slottedPseudoElementRules(), matchRequest, ruleRange); >+ >+ if (m_matchedRules.isEmpty()) >+ return { }; >+ >+ RuleSet::RuleDataVector ruleDataVector; >+ for (auto& matchedRule : m_matchedRules) >+ ruleDataVector.append(*matchedRule.ruleData); >+ return ruleDataVector; >+} > #endif > > void ElementRuleCollector::matchUserRules(bool includeEmptyRules) >@@ -284,6 +342,20 @@ void ElementRuleCollector::matchUARules( > sortAndTransferMatchedRules(); > } > >+#if ENABLE(SHADOW_DOM) >+static const CSSSelector* findSlottedPseudoElementSelector(const CSSSelector* selector) >+{ >+ for (; selector; selector = selector->tagHistory()) { >+ if (selector->match() == CSSSelector::PseudoElement && selector->pseudoElementType() == CSSSelector::PseudoElementSlotted) { >+ if (auto* list = selector->selectorList()) >+ return list->first(); >+ break; >+ } >+ }; >+ return nullptr; >+} >+#endif >+ > inline bool ElementRuleCollector::ruleMatches(const RuleData& ruleData, unsigned& specificity) > { > // We know a sufficiently simple single part selector matches simply because we found it from the rule hash when filtering the RuleSet. >@@ -356,9 +428,18 @@ inline bool ElementRuleCollector::ruleMa > } else > #endif // ENABLE(CSS_SELECTOR_JIT) > { >+ auto* selector = ruleData.selector(); >+#if ENABLE(SHADOW_DOM) >+ if (m_isMatchindSlottedPseudoElement) { >+ selector = findSlottedPseudoElementSelector(ruleData.selector()); >+ if (!selector) >+ return false; >+ } >+ >+#endif > // Slow path. > SelectorChecker selectorChecker(m_element.document()); >- selectorMatches = selectorChecker.match(*ruleData.selector(), m_element, context, specificity); >+ selectorMatches = selectorChecker.match(*selector, m_element, context, specificity); > } > > commitStyleRelations(context.styleRelations); >Index: Source/WebCore/css/ElementRuleCollector.h >=================================================================== >--- Source/WebCore/css/ElementRuleCollector.h (revision 197027) >+++ Source/WebCore/css/ElementRuleCollector.h (working copy) >@@ -73,6 +73,8 @@ private: > void matchUARules(RuleSet*); > #if ENABLE(SHADOW_DOM) > void matchHostPseudoClassRules(bool includeEmptyRules); >+ void matchSlottedPseudoElementRules(bool includeEmptyRules); >+ RuleSet::RuleDataVector collectSlottedPseudoElementRulesForSlot(bool includeEmptyRules); > #endif > > void collectMatchingRules(const MatchRequest&, StyleResolver::RuleRange&); >@@ -98,6 +100,9 @@ private: > PseudoStyleRequest m_pseudoStyleRequest { NOPSEUDO }; > bool m_sameOriginOnly { false }; > SelectorChecker::Mode m_mode { SelectorChecker::Mode::ResolvingStyle }; >+#if ENABLE(SHADOW_DOM) >+ bool m_isMatchindSlottedPseudoElement { false }; >+#endif > > Vector<MatchedRule, 64> m_matchedRules; > >Index: Source/WebCore/css/RuleSet.cpp >=================================================================== >--- Source/WebCore/css/RuleSet.cpp (revision 197027) >+++ Source/WebCore/css/RuleSet.cpp (working copy) >@@ -266,6 +266,12 @@ void RuleSet::addRule(StyleRule* rule, u > m_hostPseudoClassRules.append(ruleData); > return; > } >+ if (selector->match() == CSSSelector::PseudoElement && selector->pseudoElementType() == CSSSelector::PseudoElementSlotted) { >+ // ::slotted pseudo elements work accross shadow boundary making filtering difficult. >+ ruleData.disableSelectorFiltering(); >+ m_slottedPseudoElementRules.append(ruleData); >+ return; >+ } > #endif > if (selector->relation() != CSSSelector::SubSelector) > break; >@@ -422,6 +428,10 @@ void RuleSet::shrinkToFit() > #if ENABLE(VIDEO_TRACK) > m_cuePseudoRules.shrinkToFit(); > #endif >+#if ENABLE(SHADOW_DOM) >+ m_hostPseudoClassRules.shrinkToFit(); >+ m_slottedPseudoElementRules.shrinkToFit(); >+#endif > m_focusPseudoClassRules.shrinkToFit(); > m_universalRules.shrinkToFit(); > m_pageRules.shrinkToFit(); >Index: Source/WebCore/css/RuleSet.h >=================================================================== >--- Source/WebCore/css/RuleSet.h (revision 197027) >+++ Source/WebCore/css/RuleSet.h (working copy) >@@ -184,6 +184,7 @@ public: > #endif > #if ENABLE(SHADOW_DOM) > const RuleDataVector& hostPseudoClassRules() const { return m_hostPseudoClassRules; } >+ const RuleDataVector& slottedPseudoElementRules() const { return m_slottedPseudoElementRules; } > #endif > const RuleDataVector* focusPseudoClassRules() const { return &m_focusPseudoClassRules; } > const RuleDataVector* universalRules() const { return &m_universalRules; } >@@ -210,6 +211,7 @@ private: > #endif > #if ENABLE(SHADOW_DOM) > RuleDataVector m_hostPseudoClassRules; >+ RuleDataVector m_slottedPseudoElementRules; > #endif > RuleDataVector m_focusPseudoClassRules; > RuleDataVector m_universalRules; >Index: Source/WebCore/css/SelectorChecker.cpp >=================================================================== >--- Source/WebCore/css/SelectorChecker.cpp (revision 197027) >+++ Source/WebCore/css/SelectorChecker.cpp (working copy) >@@ -44,6 +44,7 @@ > #include "HTMLOptionElement.h" > #include "HTMLParserIdioms.h" > #include "HTMLProgressElement.h" >+#include "HTMLSlotElement.h" > #include "HTMLStyleElement.h" > #include "InspectorInstrumentation.h" > #include "Page.h" >@@ -1038,7 +1039,13 @@ bool SelectorChecker::checkOne(CheckingC > return false; > } > #endif >- // ### add the rest of the checks... >+#if ENABLE(SHADOW_DOM) >+ if (selector.match() == CSSSelector::PseudoElement && selector.pseudoElementType() == CSSSelector::PseudoElementSlotted) { >+ // We see ::slotted() pseudo elements when collecting slotted rules from the slot shadow tree only. >+ ASSERT(checkingContext.resolvingMode == Mode::CollectingRules); >+ return is<HTMLSlotElement>(element); >+ } >+#endif > return true; > } > >Index: Source/WebCore/style/StyleSharingResolver.cpp >=================================================================== >--- Source/WebCore/style/StyleSharingResolver.cpp (revision 197027) >+++ Source/WebCore/style/StyleSharingResolver.cpp (working copy) >@@ -76,6 +76,8 @@ const Element* SharingResolver::resolve( > if (!element.parentElement()) > return nullptr; > auto& parentElement = *element.parentElement(); >+ if (parentElement.shadowRoot()) >+ return nullptr; > if (!parentElement.renderStyle()) > return nullptr; > // If the element has inline style it is probably unique. >Index: LayoutTests/ChangeLog >=================================================================== >--- LayoutTests/ChangeLog (revision 197027) >+++ LayoutTests/ChangeLog (working copy) >@@ -1,3 +1,16 @@ >+2016-02-25 Antti Koivisto <antti@apple.com> >+ >+ Implement ::slotted pseudo element >+ https://bugs.webkit.org/show_bug.cgi?id=149441 >+ <rdar://problem/22731987> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Enable the test, fix it and update it to the current spec. >+ >+ * fast/shadow-dom/css-scoping-shadow-slotted-rule.html: >+ * platform/mac/TestExpectations: >+ > 2016-02-24 Carlos Garcia Campos <cgarcia@igalia.com> > > REGRESSION(r195949): [GTK] Test /webkit2/WebKitWebView/insert/link is failing since r195949 >Index: LayoutTests/fast/shadow-dom/css-scoping-shadow-slotted-rule.html >=================================================================== >--- LayoutTests/fast/shadow-dom/css-scoping-shadow-slotted-rule.html (revision 197027) >+++ LayoutTests/fast/shadow-dom/css-scoping-shadow-slotted-rule.html (working copy) >@@ -1,7 +1,7 @@ > <!DOCTYPE html> > <html> > <head> >- <title>CSS Scoping - :slotted pesudo element must allow selecting elements assigned to a slot element</title> >+ <title>CSS Scoping - :slotted pseudo element must allow selecting elements assigned to a slot element</title> > <link rel="author" title="Ryosuke Niwa" href="mailto:rniwa@webkit.org"/> > <link rel="help" href="http://www.w3.org/TR/css-scoping-1/#selectors-data-model"> > <link rel="match" href="reference/green-box.html"/> >@@ -12,7 +12,8 @@ > display: block; > width: 100px; > height: 100px; >- background: red; >+ color: red; >+ background: green; > } > my-host > div, nested-host { > display: block; >@@ -23,7 +24,7 @@ > <p>Test passes if you see a single 100px by 100px green box below.</p> > <my-host> > <div class="green">FAIL1</div> >- <div><span>FAIL2</span></div> >+ <myelem><span>FAIL2</span></myelem> > <nested-host> > <span>FAIL3</span> > </nested-host> >@@ -36,15 +37,15 @@ > try { > var shadowHost = document.querySelector('my-host'); > shadowRoot = shadowHost.attachShadow({mode: 'open'}); >- shadowRoot.innerHTML = '<slot></slot><style> ::slotted > .green, ::slotted span { color:green; } </style>'; >+ shadowRoot.innerHTML = '<slot></slot><style> ::slotted(.green), ::slotted(myelem) { color:green; } </style>'; > > shadowHost = document.querySelector('nested-host'); > shadowRoot = shadowHost.attachShadow({mode: 'open'}); >- shadowRoot.innerHTML = '<slot></slot>'; >+ shadowRoot.innerHTML = '<style> .mydiv ::slotted(*) { color:green; } </style><div class=mydiv><slot></slot></div>'; > > shadowHost = document.querySelector('another-host'); > shadowRoot = shadowHost.attachShadow({mode: 'open'}); >- shadowRoot.innerHTML = '<style> ::slotted { color:green; } </style><slot></slot>'; >+ shadowRoot.innerHTML = '<style> ::slotted(*) { color:green; } </style><slot></slot>'; > } catch (exception) { > document.body.appendChild(document.createTextNode(exception)); > } >Index: LayoutTests/platform/mac/TestExpectations >=================================================================== >--- LayoutTests/platform/mac/TestExpectations (revision 197027) >+++ LayoutTests/platform/mac/TestExpectations (working copy) >@@ -1250,7 +1250,6 @@ webkit.org/b/149128 fast/text/control-ch > > webkit.org/b/148695 fast/shadow-dom [ Pass ] > webkit.org/b/149440 fast/shadow-dom/css-scoping-shadow-host-functional-rule.html [ ImageOnlyFailure ] >-webkit.org/b/149441 fast/shadow-dom/css-scoping-shadow-slotted-rule.html [ ImageOnlyFailure ] > webkit.org/b/149441 fast/shadow-dom/css-scoping-shadow-slot-display-override.html [ ImageOnlyFailure ] > > # Touch events is not enabled on Mac
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 149441
:
272203
|
272226
|
272230
|
272231
|
272310
|
272318
|
272319