- Revision
- 207077
- Author
- an...@apple.com
- Date
- 2016-10-11 03:24:07 -0700 (Tue, 11 Oct 2016)
Log Message
Stop copying author shadow pseudo rules into shadow tree style resolver
https://bugs.webkit.org/show_bug.cgi?id=163232
Reviewed by Darin Adler.
* css/ElementRuleCollector.cpp:
(WebCore::ElementRuleCollector::collectMatchingRules):
(WebCore::ElementRuleCollector::matchAuthorRules):
(WebCore::ElementRuleCollector::matchAuthorShadowPseudoElementRules):
If we are resolving a user agent shadow tree also look up pseudo element rules from the host scope author sheet.
This is needed to keep web exposed ::-webkit-foo pseudo elements working.
(WebCore::ElementRuleCollector::collectMatchingShadowPseudoElementRules):
Factor to a function.
* css/ElementRuleCollector.h:
* css/RuleSet.cpp:
(WebCore::RuleSet::copyShadowPseudoElementRulesFrom): Deleted.
* css/RuleSet.h:
* dom/Document.cpp:
(WebCore::Document::userAgentShadowTreeStyleResolver):
* style/StyleScope.cpp:
(WebCore::Style::Scope::updateStyleResolver):
No need to awkwardly copy these rules anymore.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (207076 => 207077)
--- trunk/Source/WebCore/ChangeLog 2016-10-11 10:22:44 UTC (rev 207076)
+++ trunk/Source/WebCore/ChangeLog 2016-10-11 10:24:07 UTC (rev 207077)
@@ -1,3 +1,33 @@
+2016-10-10 Antti Koivisto <an...@apple.com>
+
+ Stop copying author shadow pseudo rules into shadow tree style resolver
+ https://bugs.webkit.org/show_bug.cgi?id=163232
+
+ Reviewed by Darin Adler.
+
+ * css/ElementRuleCollector.cpp:
+ (WebCore::ElementRuleCollector::collectMatchingRules):
+ (WebCore::ElementRuleCollector::matchAuthorRules):
+ (WebCore::ElementRuleCollector::matchAuthorShadowPseudoElementRules):
+
+ If we are resolving a user agent shadow tree also look up pseudo element rules from the host scope author sheet.
+ This is needed to keep web exposed ::-webkit-foo pseudo elements working.
+
+ (WebCore::ElementRuleCollector::collectMatchingShadowPseudoElementRules):
+
+ Factor to a function.
+
+ * css/ElementRuleCollector.h:
+ * css/RuleSet.cpp:
+ (WebCore::RuleSet::copyShadowPseudoElementRulesFrom): Deleted.
+ * css/RuleSet.h:
+ * dom/Document.cpp:
+ (WebCore::Document::userAgentShadowTreeStyleResolver):
+ * style/StyleScope.cpp:
+ (WebCore::Style::Scope::updateStyleResolver):
+
+ No need to awkwardly copy these rules anymore.
+
2016-10-11 Chris Dumez <cdu...@apple.com>
Update IDBVersionChangeEvent to stop using legacy [ConstructorTemplate=Event]
Modified: trunk/Source/WebCore/css/ElementRuleCollector.cpp (207076 => 207077)
--- trunk/Source/WebCore/css/ElementRuleCollector.cpp 2016-10-11 10:22:44 UTC (rev 207076)
+++ trunk/Source/WebCore/css/ElementRuleCollector.cpp 2016-10-11 10:24:07 UTC (rev 207077)
@@ -143,17 +143,9 @@
ASSERT(matchRequest.ruleSet);
ASSERT_WITH_MESSAGE(!(m_mode == SelectorChecker::Mode::CollectingRulesIgnoringVirtualPseudoElements && m_pseudoStyleRequest.pseudoId != NOPSEUDO), "When in StyleInvalidation or SharingRules, SelectorChecker does not try to match the pseudo ID. While ElementRuleCollector supports matching a particular pseudoId in this case, this would indicate a error at the call site since matching a particular element should be unnecessary.");
-#if ENABLE(VIDEO_TRACK)
- if (m_element.isWebVTTElement())
- collectMatchingRulesForList(matchRequest.ruleSet->cuePseudoRules(), matchRequest, ruleRange);
-#endif
-
auto* shadowRoot = m_element.containingShadowRoot();
- if (shadowRoot && shadowRoot->mode() == ShadowRoot::Mode::UserAgent) {
- const AtomicString& pseudoId = m_element.shadowPseudoId();
- if (!pseudoId.isEmpty())
- collectMatchingRulesForList(matchRequest.ruleSet->shadowPseudoElementRules(pseudoId.impl()), matchRequest, ruleRange);
- }
+ if (shadowRoot && shadowRoot->mode() == ShadowRoot::Mode::UserAgent)
+ collectMatchingShadowPseudoElementRules(matchRequest, ruleRange);
// We need to collect the rules for id, class, tag, and everything else into a buffer and
// then sort the buffer.
@@ -226,9 +218,24 @@
if (m_element.shadowRoot())
matchHostPseudoClassRules(matchRequest, ruleRange);
+ if (m_element.isInShadowTree())
+ matchAuthorShadowPseudoElementRules(matchRequest, ruleRange);
+
sortAndTransferMatchedRules();
}
+void ElementRuleCollector::matchAuthorShadowPseudoElementRules(const MatchRequest& matchRequest, StyleResolver::RuleRange& ruleRange)
+{
+ ASSERT(m_element.isInShadowTree());
+ auto& shadowRoot = *m_element.containingShadowRoot();
+ if (shadowRoot.mode() != ShadowRoot::Mode::UserAgent)
+ return;
+ // Look up shadow pseudo elements also from the host scope author style as they are web-exposed.
+ auto& hostAuthorRules = Style::Scope::forNode(*shadowRoot.host()).resolver().ruleSets().authorStyle();
+ MatchRequest hostAuthorRequest { &hostAuthorRules, matchRequest.includeEmptyRules };
+ collectMatchingShadowPseudoElementRules(hostAuthorRequest, ruleRange);
+}
+
void ElementRuleCollector::matchHostPseudoClassRules(MatchRequest& matchRequest, StyleResolver::RuleRange& ruleRange)
{
ASSERT(m_element.shadowRoot());
@@ -284,6 +291,22 @@
}
}
+void ElementRuleCollector::collectMatchingShadowPseudoElementRules(const MatchRequest& matchRequest, StyleResolver::RuleRange& ruleRange)
+{
+ ASSERT(matchRequest.ruleSet);
+ ASSERT(m_element.containingShadowRoot()->mode() == ShadowRoot::Mode::UserAgent);
+
+ auto& rules = *matchRequest.ruleSet;
+#if ENABLE(VIDEO_TRACK)
+ // FXIME: WebVTT should not be done by styling UA shadow trees like this.
+ if (m_element.isWebVTTElement())
+ collectMatchingRulesForList(rules.cuePseudoRules(), matchRequest, ruleRange);
+#endif
+ auto& pseudoId = m_element.shadowPseudoId();
+ if (!pseudoId.isEmpty())
+ collectMatchingRulesForList(rules.shadowPseudoElementRules(pseudoId.impl()), matchRequest, ruleRange);
+}
+
std::unique_ptr<RuleSet::RuleDataVector> ElementRuleCollector::collectSlottedPseudoElementRulesForSlot(bool includeEmptyRules)
{
ASSERT(is<HTMLSlotElement>(m_element));
Modified: trunk/Source/WebCore/css/ElementRuleCollector.h (207076 => 207077)
--- trunk/Source/WebCore/css/ElementRuleCollector.h 2016-10-11 10:22:44 UTC (rev 207076)
+++ trunk/Source/WebCore/css/ElementRuleCollector.h 2016-10-11 10:24:07 UTC (rev 207077)
@@ -76,8 +76,11 @@
void addElementStyleProperties(const StyleProperties*, bool isCacheable = true);
void matchUARules(RuleSet*);
+ void matchAuthorShadowPseudoElementRules(const MatchRequest&, StyleResolver::RuleRange&);
void matchHostPseudoClassRules(MatchRequest&, StyleResolver::RuleRange&);
void matchSlottedPseudoElementRules(MatchRequest&, StyleResolver::RuleRange&);
+
+ void collectMatchingShadowPseudoElementRules(const MatchRequest&, StyleResolver::RuleRange&);
std::unique_ptr<RuleSet::RuleDataVector> collectSlottedPseudoElementRulesForSlot(bool includeEmptyRules);
void collectMatchingRules(const MatchRequest&, StyleResolver::RuleRange&);
Modified: trunk/Source/WebCore/css/RuleSet.cpp (207076 => 207077)
--- trunk/Source/WebCore/css/RuleSet.cpp 2016-10-11 10:22:44 UTC (rev 207076)
+++ trunk/Source/WebCore/css/RuleSet.cpp 2016-10-11 10:24:07 UTC (rev 207077)
@@ -394,18 +394,6 @@
return false;
}
-void RuleSet::copyShadowPseudoElementRulesFrom(const RuleSet& other)
-{
- for (auto& keyValuePair : other.m_shadowPseudoElementRules)
- m_shadowPseudoElementRules.add(keyValuePair.key, std::make_unique<RuleDataVector>(*keyValuePair.value));
-
-#if ENABLE(VIDEO_TRACK)
- // FIXME: We probably shouldn't treat WebVTT as author stylable user agent shadow tree.
- for (auto& cue : other.m_cuePseudoRules)
- m_cuePseudoRules.append(cue);
-#endif
-}
-
static inline void shrinkMapVectorsToFit(RuleSet::AtomRuleMap& map)
{
for (auto& vector : map.values())
Modified: trunk/Source/WebCore/css/RuleSet.h (207076 => 207077)
--- trunk/Source/WebCore/css/RuleSet.h 2016-10-11 10:22:44 UTC (rev 207076)
+++ trunk/Source/WebCore/css/RuleSet.h 2016-10-11 10:24:07 UTC (rev 207077)
@@ -192,7 +192,6 @@
unsigned ruleCount() const { return m_ruleCount; }
bool hasShadowPseudoElementRules() const;
- void copyShadowPseudoElementRulesFrom(const RuleSet&);
private:
void addChildRules(const Vector<RefPtr<StyleRuleBase>>&, const MediaQueryEvaluator& medium, StyleResolver*, bool hasDocumentSecurityOrigin, bool isInitiatingElementInUserAgentShadowTree, AddRuleFlags);
Modified: trunk/Source/WebCore/dom/Document.cpp (207076 => 207077)
--- trunk/Source/WebCore/dom/Document.cpp 2016-10-11 10:22:44 UTC (rev 207076)
+++ trunk/Source/WebCore/dom/Document.cpp 2016-10-11 10:24:07 UTC (rev 207077)
@@ -2144,15 +2144,8 @@
StyleResolver& Document::userAgentShadowTreeStyleResolver()
{
- if (!m_userAgentShadowTreeStyleResolver) {
+ if (!m_userAgentShadowTreeStyleResolver)
m_userAgentShadowTreeStyleResolver = std::make_unique<StyleResolver>(*this);
-
- // FIXME: Filter out shadow pseudo elements we don't want to expose to authors.
- auto& documentAuthorStyle = styleScope().resolver().ruleSets().authorStyle();
- if (documentAuthorStyle.hasShadowPseudoElementRules())
- m_userAgentShadowTreeStyleResolver->ruleSets().authorStyle().copyShadowPseudoElementRulesFrom(documentAuthorStyle);
- }
-
return *m_userAgentShadowTreeStyleResolver;
}
Modified: trunk/Source/WebCore/style/StyleScope.cpp (207076 => 207077)
--- trunk/Source/WebCore/style/StyleScope.cpp 2016-10-11 10:22:44 UTC (rev 207076)
+++ trunk/Source/WebCore/style/StyleScope.cpp 2016-10-11 10:24:07 UTC (rev 207077)
@@ -404,14 +404,6 @@
newStyleSheets.appendRange(activeStyleSheets.begin() + firstNewIndex, activeStyleSheets.end());
styleResolver.appendAuthorStyleSheets(newStyleSheets);
}
-
- if (!m_shadowRoot) {
- auto& userAgentShadowTreeStyleResolver = m_document.userAgentShadowTreeStyleResolver();
- userAgentShadowTreeStyleResolver.ruleSets().resetAuthorStyle();
- auto& authorRuleSet = styleResolver.ruleSets().authorStyle();
- if (authorRuleSet.hasShadowPseudoElementRules())
- userAgentShadowTreeStyleResolver.ruleSets().authorStyle().copyShadowPseudoElementRulesFrom(authorRuleSet);
- }
}
const Vector<RefPtr<CSSStyleSheet>> Scope::activeStyleSheetsForInspector() const