Diff
Modified: trunk/LayoutTests/ChangeLog (206989 => 206990)
--- trunk/LayoutTests/ChangeLog 2016-10-10 08:13:56 UTC (rev 206989)
+++ trunk/LayoutTests/ChangeLog 2016-10-10 08:19:03 UTC (rev 206990)
@@ -1,3 +1,13 @@
+2016-10-09 Antti Koivisto <an...@apple.com>
+
+ Enable optimized stylesheet updates in shadow trees
+ https://bugs.webkit.org/show_bug.cgi?id=163180
+
+ Reviewed by Darin Adler.
+
+ * fast/shadow-dom/scoped-style-invalidation-expected.txt: Added.
+ * fast/shadow-dom/scoped-style-invalidation.html: Added.
+
2016-10-09 Gyuyoung Kim <gyuyoung....@navercorp.com>
Unreviewed, EFL Gardening on Oct. 10th - 2
Added: trunk/LayoutTests/fast/shadow-dom/scoped-style-invalidation-expected.txt (0 => 206990)
--- trunk/LayoutTests/fast/shadow-dom/scoped-style-invalidation-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/shadow-dom/scoped-style-invalidation-expected.txt 2016-10-10 08:19:03 UTC (rev 206990)
@@ -0,0 +1,6 @@
+
+PASS Test that adding stylesheet with matching selector invalidates in document scope
+PASS Test that adding stylesheet without matching selector does not invalidate in document scope
+PASS Test that adding stylesheet with matching selector invalidates in shadow scope
+PASS Test that adding stylesheet without matching selector does not invalidate in shadow scope
+
Added: trunk/LayoutTests/fast/shadow-dom/scoped-style-invalidation.html (0 => 206990)
--- trunk/LayoutTests/fast/shadow-dom/scoped-style-invalidation.html (rev 0)
+++ trunk/LayoutTests/fast/shadow-dom/scoped-style-invalidation.html 2016-10-10 08:19:03 UTC (rev 206990)
@@ -0,0 +1,43 @@
+<script src=""
+<script src=""
+
+<div></div>
+<div class=styled><div></div></div>
+<div><div class=styled></div></div>
+
+<div id=host></div>
+
+<script>
+var host = document.getElementById('host');
+var shadow = host.attachShadow({mode: 'closed'});
+shadow.innerHTML = `
+ <div></div>
+ <div class=styled><div></div></div>
+ <div><div class=styled></div></div>
+`;
+
+function testInvalidation(scope, cssText, shouldInvalidate, name)
+{
+ test(() => {
+ internals.updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks();
+
+ var style = document.createElement("style");
+ style.textContent = cssText;
+ scope.appendChild(style);
+
+ var styledDiv = scope.querySelectorAll("div.styled");
+ for (var div of styledDiv)
+ assert_equals(internals.styleChangeType(div), shouldInvalidate ? "InlineStyleChange" : "NoStyleChange");
+
+ var notStyledDiv = scope.querySelectorAll("div:not(.styled)");
+ for (var div of notStyledDiv)
+ assert_equals(internals.styleChangeType(div), "NoStyleChange");
+ }, name);
+}
+
+testInvalidation(document.body, ".styled { color: red }", true, "Test that adding stylesheet with matching selector invalidates in document scope");
+testInvalidation(document.body, ".nothere { color: red }", false, "Test that adding stylesheet without matching selector does not invalidate in document scope");
+testInvalidation(shadow, ".styled { color: red }", true, "Test that adding stylesheet with matching selector invalidates in shadow scope");
+testInvalidation(shadow, ".nothere { color: red }", false, "Test that adding stylesheet without matching selector does not invalidate in shadow scope");
+
+</script>
Modified: trunk/Source/WebCore/ChangeLog (206989 => 206990)
--- trunk/Source/WebCore/ChangeLog 2016-10-10 08:13:56 UTC (rev 206989)
+++ trunk/Source/WebCore/ChangeLog 2016-10-10 08:19:03 UTC (rev 206990)
@@ -1,3 +1,26 @@
+2016-10-09 Antti Koivisto <an...@apple.com>
+
+ Enable optimized stylesheet updates in shadow trees
+ https://bugs.webkit.org/show_bug.cgi?id=163180
+
+ Reviewed by Darin Adler.
+
+ When we get a new stylesheet (for example when load completes) we invalidate only
+ those elements in DOM that are affected by the new sheet. This patch makes the
+ optimization also work in shadow trees.
+
+ Test: fast/shadow-dom/scoped-style-invalidation.html
+
+ * css/StyleInvalidationAnalysis.cpp:
+ (WebCore::StyleInvalidationAnalysis::invalidateStyle):
+ * css/StyleInvalidationAnalysis.h:
+ * dom/Document.cpp:
+ (WebCore::Document::didRemoveAllPendingStylesheet):
+ * style/StyleScope.cpp:
+ (WebCore::Style::Scope::removePendingSheet):
+ (WebCore::Style::Scope::analyzeStyleSheetChange):
+ (WebCore::Style::Scope::updateActiveStyleSheets):
+
2016-10-10 Youenn Fablet <you...@apple.com>
Refactor binding generated casted-this checks for attribute setters
Modified: trunk/Source/WebCore/css/StyleInvalidationAnalysis.cpp (206989 => 206990)
--- trunk/Source/WebCore/css/StyleInvalidationAnalysis.cpp 2016-10-10 08:13:56 UTC (rev 206989)
+++ trunk/Source/WebCore/css/StyleInvalidationAnalysis.cpp 2016-10-10 08:19:03 UTC (rev 206990)
@@ -169,6 +169,16 @@
invalidateStyleForTree(*documentElement, &filter);
}
+void StyleInvalidationAnalysis::invalidateStyle(ShadowRoot& shadowRoot)
+{
+ ASSERT(!m_dirtiesAllStyle);
+
+ for (auto& child : childrenOfType<Element>(shadowRoot)) {
+ SelectorFilter filter;
+ invalidateStyleForTree(child, &filter);
+ }
+}
+
void StyleInvalidationAnalysis::invalidateStyle(Element& element)
{
ASSERT(!m_dirtiesAllStyle);
Modified: trunk/Source/WebCore/css/StyleInvalidationAnalysis.h (206989 => 206990)
--- trunk/Source/WebCore/css/StyleInvalidationAnalysis.h 2016-10-10 08:13:56 UTC (rev 206989)
+++ trunk/Source/WebCore/css/StyleInvalidationAnalysis.h 2016-10-10 08:19:03 UTC (rev 206990)
@@ -35,6 +35,7 @@
class MediaQueryEvaluator;
class RuleSet;
class SelectorFilter;
+class ShadowRoot;
class StyleSheetContents;
class StyleInvalidationAnalysis {
@@ -45,6 +46,7 @@
bool dirtiesAllStyle() const { return m_dirtiesAllStyle; }
bool hasShadowPseudoElementRulesInAuthorSheet() const { return m_hasShadowPseudoElementRulesInAuthorSheet; }
void invalidateStyle(Document&);
+ void invalidateStyle(ShadowRoot&);
void invalidateStyle(Element&);
private:
Modified: trunk/Source/WebCore/dom/Document.cpp (206989 => 206990)
--- trunk/Source/WebCore/dom/Document.cpp 2016-10-10 08:13:56 UTC (rev 206989)
+++ trunk/Source/WebCore/dom/Document.cpp 2016-10-10 08:19:03 UTC (rev 206990)
@@ -3083,8 +3083,6 @@
{
m_needsNotifyRemoveAllPendingStylesheet = false;
- styleScope().didChangeCandidatesForActiveSet();
-
if (m_pendingSheetLayout == DidLayoutWithPendingSheets) {
m_pendingSheetLayout = IgnoreLayoutWithPendingSheets;
if (renderView())
Modified: trunk/Source/WebCore/style/StyleScope.cpp (206989 => 206990)
--- trunk/Source/WebCore/style/StyleScope.cpp 2016-10-10 08:13:56 UTC (rev 206989)
+++ trunk/Source/WebCore/style/StyleScope.cpp 2016-10-10 08:19:03 UTC (rev 206990)
@@ -129,13 +129,10 @@
return;
}
- if (m_shadowRoot) {
- // FIXME: Make optimized updates work.
- didChangeContentsOrInterpretation();
- return;
- }
+ didChangeCandidatesForActiveSet();
- m_document.didRemoveAllPendingStylesheet();
+ if (!m_shadowRoot)
+ m_document.didRemoveAllPendingStylesheet();
}
void Scope::addStyleSheetCandidateNode(Node& node, bool createdByParser)
@@ -300,7 +297,12 @@
StyleInvalidationAnalysis invalidationAnalysis(addedSheets, styleResolver.mediaQueryEvaluator());
if (invalidationAnalysis.dirtiesAllStyle())
return styleResolverUpdateType;
- invalidationAnalysis.invalidateStyle(m_document);
+
+ if (m_shadowRoot)
+ invalidationAnalysis.invalidateStyle(*m_shadowRoot);
+ else
+ invalidationAnalysis.invalidateStyle(m_document);
+
requiresFullStyleRecalc = false;
return styleResolverUpdateType;
@@ -347,10 +349,6 @@
return;
}
- // FIXME: Support optimized invalidation in shadow trees.
- if (m_shadowRoot)
- updateType = UpdateType::ContentsOrInterpretation;
-
m_didUpdateActiveStyleSheets = true;
Vector<RefPtr<StyleSheet>> activeStyleSheets;