Diff
Modified: trunk/LayoutTests/ChangeLog (206879 => 206880)
--- trunk/LayoutTests/ChangeLog 2016-10-06 20:47:44 UTC (rev 206879)
+++ trunk/LayoutTests/ChangeLog 2016-10-06 20:53:08 UTC (rev 206880)
@@ -1,3 +1,14 @@
+2016-10-06 Antti Koivisto <an...@apple.com>
+
+ Mutating styleSheet in shadow tree doesn't update the style
+ https://bugs.webkit.org/show_bug.cgi?id=162744
+ <rdar://problem/28550588>
+
+ Reviewed by Ryosuke Niwa.
+
+ * fast/shadow-dom/mutating-stylesheet-in-shadow-tree-expected.html: Added.
+ * fast/shadow-dom/mutating-stylesheet-in-shadow-tree.html: Added.
+
2016-10-06 Adam Bergkvist <adam.bergkv...@ericsson.com>
WebRTC: Add support for the iceconnectionstatechange event in MediaEndpointPeerConnection
Added: trunk/LayoutTests/fast/shadow-dom/mutating-stylesheet-in-shadow-tree-expected.html (0 => 206880)
--- trunk/LayoutTests/fast/shadow-dom/mutating-stylesheet-in-shadow-tree-expected.html (rev 0)
+++ trunk/LayoutTests/fast/shadow-dom/mutating-stylesheet-in-shadow-tree-expected.html 2016-10-06 20:53:08 UTC (rev 206880)
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<html>
+<body>
+ <p>Test passes if you see a single 100px by 100px green box below.</p>
+ <div style="width: 100px; height: 100px; background: green;"></div>
+</body>
+</html>
Added: trunk/LayoutTests/fast/shadow-dom/mutating-stylesheet-in-shadow-tree.html (0 => 206880)
--- trunk/LayoutTests/fast/shadow-dom/mutating-stylesheet-in-shadow-tree.html (rev 0)
+++ trunk/LayoutTests/fast/shadow-dom/mutating-stylesheet-in-shadow-tree.html 2016-10-06 20:53:08 UTC (rev 206880)
@@ -0,0 +1,57 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>Test passes if you see a single 100px by 100px green box below.</p>
+<style>
+
+div {
+ width: 100px;
+ height: 25px;
+ background: red;
+}
+
+</style>
+<script>
+
+function appendShadowHost(container, template, callback) {
+ var host = document.createElement('div');
+ container.appendChild(host);
+ var shadow = host.attachShadow({mode: 'closed'});
+ shadow.innerHTML = template;
+ callback(shadow);
+ return host;
+}
+
+appendShadowHost(document.body, `
+ <style></style>
+ <div>FAIL</div>
+`, function (shadow) {
+ var style = shadow.querySelector('style');
+ style.sheet.insertRule('div { width: 100%; height: 100%; background: green; color: green; }', 0);
+});
+appendShadowHost(document.body, `
+ <style media="aural"> div { width: 100%; height: 100%; color: green; background: green; } </style>
+ <div>FAIL</div>
+`, function (shadow) {
+ var style = shadow.querySelector('style');
+ style.removeAttribute('media');
+});
+appendShadowHost(document.body, `
+ <style> div { width: 100%; height: 100%; color: green; background: green; } </style>
+ <style> div { color: black; background: red; } </style>
+ <div>FAIL</div>
+`, function (shadow) {
+ var style = shadow.querySelectorAll('style')[1];
+ style.disabled = true;
+});
+appendShadowHost(document.body, `
+ <style> div { width: 100%; height: 100%; color: green; background: green; } </style>
+ <style> div { color: black; background: red; } </style>
+ <div>FAIL</div>
+`, function (shadow) {
+ shadow.querySelectorAll('style')[1].remove();
+});
+
+</script>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (206879 => 206880)
--- trunk/Source/WebCore/ChangeLog 2016-10-06 20:47:44 UTC (rev 206879)
+++ trunk/Source/WebCore/ChangeLog 2016-10-06 20:53:08 UTC (rev 206880)
@@ -1,3 +1,82 @@
+2016-10-06 Antti Koivisto <an...@apple.com>
+
+ Mutating styleSheet in shadow tree doesn't update the style
+ https://bugs.webkit.org/show_bug.cgi?id=162744
+ <rdar://problem/28550588>
+
+ Reviewed by Ryosuke Niwa.
+
+ We weren't always invalidating the right AuthorStyleSheets (to be renamed) instance
+ for the scope after mutations.
+
+ Test: fast/shadow-dom/mutating-stylesheet-in-shadow-tree.html
+
+ * css/CSSStyleSheet.cpp:
+ (WebCore::CSSStyleSheet::didMutateRules):
+ (WebCore::CSSStyleSheet::didMutate):
+ (WebCore::CSSStyleSheet::clearOwnerNode):
+ (WebCore::CSSStyleSheet::rootStyleSheet):
+ (WebCore::CSSStyleSheet::ownerDocument):
+ (WebCore::CSSStyleSheet::styleSheetScope):
+
+ Invalidate the right scope after stylesheet mutations.
+
+ * css/CSSStyleSheet.h:
+ * dom/AuthorStyleSheets.cpp:
+ (WebCore::AuthorStyleSheets::styleResolver):
+ (WebCore::AuthorStyleSheets::styleResolverIfExists):
+
+ Take care to update the right style resolver.
+
+ (WebCore::AuthorStyleSheets::forNode):
+ (WebCore::AuthorStyleSheets::removeStyleSheetCandidateNode):
+
+ Start the update timer so clients don't need to request update separately.
+
+ (WebCore::AuthorStyleSheets::analyzeStyleSheetChange):
+ (WebCore::AuthorStyleSheets::updateActiveStyleSheets):
+ (WebCore::AuthorStyleSheets::updateStyleResolver):
+ * dom/AuthorStyleSheets.h:
+ * dom/InlineStyleSheetOwner.cpp:
+ (WebCore::InlineStyleSheetOwner::insertedIntoDocument):
+
+ Save the scope we were inserted into so removals can be done reliably.
+
+ (WebCore::InlineStyleSheetOwner::removedFromDocument):
+
+ Use and clear the saved scope.
+ Remove didChangeCandidatesForActiveSet() as it is now done by removeStyleSheetCandidateNode() call.
+
+ (WebCore::InlineStyleSheetOwner::clearDocumentData):
+ (WebCore::InlineStyleSheetOwner::createSheet):
+ (WebCore::InlineStyleSheetOwner::sheetLoaded):
+ (WebCore::InlineStyleSheetOwner::startLoadingDynamicSheet):
+ (WebCore::authorStyleSheetsForElement): Deleted.
+ * dom/InlineStyleSheetOwner.h:
+ (WebCore::InlineStyleSheetOwner::styleSheetScope):
+ * dom/ShadowRoot.cpp:
+ (WebCore::ShadowRoot::styleResolverIfExists):
+ * dom/ShadowRoot.h:
+ * html/HTMLLinkElement.cpp:
+ (WebCore::HTMLLinkElement::removedFrom):
+
+ Remove didChangeCandidatesForActiveSet() as it is now done by removeStyleSheetCandidateNode() call.
+
+ * html/HTMLStyleElement.cpp:
+ (WebCore::HTMLStyleElement::~HTMLStyleElement):
+ (WebCore::HTMLStyleElement::parseAttribute):
+
+ Fix a bug where we wouldn't create stylesheet if a style element was activated by removing a media attribute.
+
+ (WebCore::HTMLStyleElement::insertedInto):
+ (WebCore::HTMLStyleElement::removedFrom):
+ * page/DOMWindow.cpp:
+ (WebCore::DOMWindow::getMatchedCSSRules):
+ * svg/SVGStyleElement.cpp:
+ (WebCore::SVGStyleElement::~SVGStyleElement):
+ (WebCore::SVGStyleElement::insertedInto):
+ (WebCore::SVGStyleElement::removedFrom):
+
2016-10-06 Alex Christensen <achristen...@webkit.org>
Skip tabs and newlines between end of query and beginning of fragment in non-UTF-8-encoded URLs
Modified: trunk/Source/WebCore/css/CSSStyleSheet.cpp (206879 => 206880)
--- trunk/Source/WebCore/css/CSSStyleSheet.cpp 2016-10-06 20:47:44 UTC (rev 206879)
+++ trunk/Source/WebCore/css/CSSStyleSheet.cpp 2016-10-06 20:53:08 UTC (rev 206880)
@@ -41,6 +41,7 @@
#include "SVGNames.h"
#include "SVGStyleElement.h"
#include "SecurityOrigin.h"
+#include "ShadowRoot.h"
#include "StyleResolver.h"
#include "StyleRule.h"
#include "StyleSheetContents.h"
@@ -169,21 +170,21 @@
ASSERT(m_contents->isMutable());
ASSERT(m_contents->hasOneClient());
- Document* owner = ownerDocument();
- if (!owner)
+ auto* scope = styleSheetScope();
+ if (!scope)
return;
- if (mutationType == RuleInsertion && !contentsWereClonedForMutation && !owner->authorStyleSheets().activeStyleSheetsContains(this)) {
+ if (mutationType == RuleInsertion && !contentsWereClonedForMutation && !scope->activeStyleSheetsContains(this)) {
if (insertedKeyframesRule) {
- if (StyleResolver* resolver = owner->styleResolverIfExists())
+ if (auto* resolver = scope->styleResolverIfExists())
resolver->addKeyframeStyle(*insertedKeyframesRule);
return;
}
- owner->authorStyleSheets().scheduleActiveSetUpdate();
+ scope->scheduleActiveSetUpdate();
return;
}
- owner->authorStyleSheets().didChangeContentsOrInterpretation();
+ scope->didChangeContentsOrInterpretation();
m_mutatedRules = true;
}
@@ -190,19 +191,15 @@
void CSSStyleSheet::didMutate()
{
- Document* owner = ownerDocument();
- if (!owner)
+ auto* scope = styleSheetScope();
+ if (!scope)
return;
- owner->authorStyleSheets().didChangeContentsOrInterpretation();
+ scope->didChangeContentsOrInterpretation();
}
void CSSStyleSheet::clearOwnerNode()
{
- Document* owner = ownerDocument();
- m_ownerNode = 0;
- if (!owner)
- return;
- owner->authorStyleSheets().didChangeCandidatesForActiveSet();
+ m_ownerNode = nullptr;
}
void CSSStyleSheet::reattachChildRuleCSSOMWrappers()
@@ -399,14 +396,33 @@
return m_ownerRule ? m_ownerRule->parentStyleSheet() : nullptr;
}
-Document* CSSStyleSheet::ownerDocument() const
+CSSStyleSheet& CSSStyleSheet::rootStyleSheet()
{
- const CSSStyleSheet* root = this;
+ auto* root = this;
while (root->parentStyleSheet())
root = root->parentStyleSheet();
- return root->ownerNode() ? &root->ownerNode()->document() : nullptr;
+ return *root;
}
+const CSSStyleSheet& CSSStyleSheet::rootStyleSheet() const
+{
+ return const_cast<CSSStyleSheet&>(*this).rootStyleSheet();
+}
+
+Document* CSSStyleSheet::ownerDocument() const
+{
+ auto& root = rootStyleSheet();
+ return root.ownerNode() ? &root.ownerNode()->document() : nullptr;
+}
+
+AuthorStyleSheets* CSSStyleSheet::styleSheetScope()
+{
+ auto* ownerNode = rootStyleSheet().ownerNode();
+ if (!ownerNode)
+ return nullptr;
+ return &AuthorStyleSheets::forNode(*ownerNode);
+}
+
void CSSStyleSheet::clearChildRuleCSSOMWrappers()
{
m_childRuleCSSOMWrappers.clear();
Modified: trunk/Source/WebCore/css/CSSStyleSheet.h (206879 => 206880)
--- trunk/Source/WebCore/css/CSSStyleSheet.h 2016-10-06 20:47:44 UTC (rev 206879)
+++ trunk/Source/WebCore/css/CSSStyleSheet.h 2016-10-06 20:53:08 UTC (rev 206880)
@@ -31,6 +31,7 @@
namespace WebCore {
+class AuthorStyleSheets;
class CSSCharsetRule;
class CSSImportRule;
class CSSParser;
@@ -82,7 +83,12 @@
bool isLoading() const final;
void clearOwnerRule() { m_ownerRule = 0; }
+
Document* ownerDocument() const;
+ CSSStyleSheet& rootStyleSheet();
+ const CSSStyleSheet& rootStyleSheet() const;
+ AuthorStyleSheets* styleSheetScope();
+
MediaQuerySet* mediaQueries() const { return m_mediaQueries.get(); }
void setMediaQueries(Ref<MediaQuerySet>&&);
void setTitle(const String& title) { m_title = title; }
Modified: trunk/Source/WebCore/dom/AuthorStyleSheets.cpp (206879 => 206880)
--- trunk/Source/WebCore/dom/AuthorStyleSheets.cpp 2016-10-06 20:47:44 UTC (rev 206879)
+++ trunk/Source/WebCore/dom/AuthorStyleSheets.cpp 2016-10-06 20:53:08 UTC (rev 206880)
@@ -69,6 +69,31 @@
{
}
+StyleResolver& AuthorStyleSheets::styleResolver()
+{
+ if (m_shadowRoot)
+ return m_shadowRoot->styleResolver();
+
+ return m_document.ensureStyleResolver();
+}
+
+StyleResolver* AuthorStyleSheets::styleResolverIfExists()
+{
+ if (m_shadowRoot)
+ return m_shadowRoot->styleResolverIfExists();
+
+ return m_document.styleResolverIfExists();
+}
+
+AuthorStyleSheets& AuthorStyleSheets::forNode(Node& node)
+{
+ ASSERT(node.inDocument());
+ auto* shadowRoot = node.containingShadowRoot();
+ if (shadowRoot)
+ return shadowRoot->authorStyleSheets();
+ return node.document().authorStyleSheets();
+}
+
// This method is called whenever a top-level stylesheet has finished loading.
void AuthorStyleSheets::removePendingSheet(RemovePendingSheetNotificationType notification)
{
@@ -133,7 +158,8 @@
void AuthorStyleSheets::removeStyleSheetCandidateNode(Node& node)
{
- m_styleSheetCandidateNodes.remove(&node);
+ if (m_styleSheetCandidateNodes.remove(&node))
+ scheduleActiveSetUpdate();
}
void AuthorStyleSheets::collectActiveStyleSheets(Vector<RefPtr<StyleSheet>>& sheets)
@@ -220,10 +246,10 @@
unsigned newStylesheetCount = newStylesheets.size();
- if (!m_document.styleResolverIfExists())
+ if (!styleResolverIfExists())
return Reconstruct;
- StyleResolver& styleResolver = *m_document.styleResolverIfExists();
+ StyleResolver& styleResolver = *styleResolverIfExists();
// Find out which stylesheets are new.
unsigned oldStylesheetCount = m_activeStyleSheets.size();
@@ -306,6 +332,10 @@
return;
}
+ // FIXME: Support optimized invalidation in shadow trees.
+ if (m_shadowRoot)
+ updateType = UpdateType::ContentsOrInterpretation;
+
m_didUpdateActiveStyleSheets = true;
Vector<RefPtr<StyleSheet>> activeStyleSheets;
@@ -352,8 +382,7 @@
m_document.clearStyleResolver();
return;
}
- auto& styleResolver = m_document.ensureStyleResolver();
- auto& userAgentShadowTreeStyleResolver = m_document.userAgentShadowTreeStyleResolver();
+ auto& styleResolver = this->styleResolver();
if (updateType == Reset) {
styleResolver.ruleSets().resetAuthorStyle();
@@ -366,10 +395,13 @@
styleResolver.appendAuthorStyleSheets(newStyleSheets);
}
- userAgentShadowTreeStyleResolver.ruleSets().resetAuthorStyle();
- auto& authorRuleSet = styleResolver.ruleSets().authorStyle();
- if (authorRuleSet.hasShadowPseudoElementRules())
- userAgentShadowTreeStyleResolver.ruleSets().authorStyle().copyShadowPseudoElementRulesFrom(authorRuleSet);
+ 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>> AuthorStyleSheets::activeStyleSheetsForInspector() const
@@ -422,6 +454,11 @@
void AuthorStyleSheets::scheduleActiveSetUpdate()
{
+ if (m_shadowRoot) {
+ // FIXME: We need to flush updates recursively to support asynchronous updates in shadow trees.
+ didChangeCandidatesForActiveSet();
+ return;
+ }
if (m_pendingUpdateTimer.isActive())
return;
if (!m_pendingUpdateType)
Modified: trunk/Source/WebCore/dom/AuthorStyleSheets.h (206879 => 206880)
--- trunk/Source/WebCore/dom/AuthorStyleSheets.h 2016-10-06 20:47:44 UTC (rev 206879)
+++ trunk/Source/WebCore/dom/AuthorStyleSheets.h 2016-10-06 20:53:08 UTC (rev 206880)
@@ -42,6 +42,7 @@
class CSSStyleSheet;
class Document;
class Node;
+class StyleResolver;
class StyleSheet;
class StyleSheetContents;
class StyleSheetList;
@@ -87,6 +88,11 @@
bool hasPendingUpdate() const { return !!m_pendingUpdateType; }
void flushPendingUpdate();
+ StyleResolver& styleResolver();
+ StyleResolver* styleResolverIfExists();
+
+ static AuthorStyleSheets& forNode(Node&);
+
private:
enum class UpdateType { ActiveSet, ContentsOrInterpretation };
void updateActiveStyleSheets(UpdateType);
Modified: trunk/Source/WebCore/dom/InlineStyleSheetOwner.cpp (206879 => 206880)
--- trunk/Source/WebCore/dom/InlineStyleSheetOwner.cpp 2016-10-06 20:47:44 UTC (rev 206879)
+++ trunk/Source/WebCore/dom/InlineStyleSheetOwner.cpp 2016-10-06 20:53:08 UTC (rev 206880)
@@ -49,41 +49,35 @@
clearSheet();
}
-static AuthorStyleSheets& authorStyleSheetsForElement(Element& element)
+void InlineStyleSheetOwner::insertedIntoDocument(Element& element)
{
- auto* shadowRoot = element.containingShadowRoot();
- return shadowRoot ? shadowRoot->authorStyleSheets() : element.document().authorStyleSheets();
-}
+ m_styleSheetScope = &AuthorStyleSheets::forNode(element);
+ m_styleSheetScope->addStyleSheetCandidateNode(element, m_isParsingChildren);
-void InlineStyleSheetOwner::insertedIntoDocument(Document&, Element& element)
-{
- authorStyleSheetsForElement(element).addStyleSheetCandidateNode(element, m_isParsingChildren);
-
if (m_isParsingChildren)
return;
createSheetFromTextContents(element);
}
-void InlineStyleSheetOwner::removedFromDocument(Document& document, Element& element)
+void InlineStyleSheetOwner::removedFromDocument(Element& element)
{
- authorStyleSheetsForElement(element).removeStyleSheetCandidateNode(element);
-
+ if (m_styleSheetScope) {
+ m_styleSheetScope->removeStyleSheetCandidateNode(element);
+ m_styleSheetScope = nullptr;
+ }
if (m_sheet)
clearSheet();
-
- // If we're in document teardown, then we don't need to do any notification of our sheet's removal.
- if (document.hasLivingRenderTree())
- document.authorStyleSheets().didChangeContentsOrInterpretation();
}
-void InlineStyleSheetOwner::clearDocumentData(Document&, Element& element)
+void InlineStyleSheetOwner::clearDocumentData(Element& element)
{
if (m_sheet)
m_sheet->clearOwnerNode();
- if (!element.inDocument())
- return;
- authorStyleSheetsForElement(element).removeStyleSheetCandidateNode(element);
+ if (m_styleSheetScope) {
+ m_styleSheetScope->removeStyleSheetCandidateNode(element);
+ m_styleSheetScope = nullptr;
+ }
}
void InlineStyleSheetOwner::childrenChanged(Element& element)
@@ -130,8 +124,8 @@
ASSERT(element.inDocument());
Document& document = element.document();
if (m_sheet) {
- if (m_sheet->isLoading())
- document.authorStyleSheets().removePendingSheet();
+ if (m_sheet->isLoading() && m_styleSheetScope)
+ m_styleSheetScope->removePendingSheet();
clearSheet();
}
@@ -155,7 +149,8 @@
if (!screenEval.evaluate(*mediaQueries) && !printEval.evaluate(*mediaQueries))
return;
- authorStyleSheetsForElement(element).addPendingSheet();
+ if (m_styleSheetScope)
+ m_styleSheetScope->addPendingSheet();
m_loading = true;
@@ -177,18 +172,21 @@
return m_sheet && m_sheet->isLoading();
}
-bool InlineStyleSheetOwner::sheetLoaded(Element& element)
+bool InlineStyleSheetOwner::sheetLoaded(Element&)
{
if (isLoading())
return false;
- authorStyleSheetsForElement(element).removePendingSheet();
+ if (m_styleSheetScope)
+ m_styleSheetScope->removePendingSheet();
+
return true;
}
-void InlineStyleSheetOwner::startLoadingDynamicSheet(Element& element)
+void InlineStyleSheetOwner::startLoadingDynamicSheet(Element&)
{
- authorStyleSheetsForElement(element).addPendingSheet();
+ if (m_styleSheetScope)
+ m_styleSheetScope->addPendingSheet();
}
}
Modified: trunk/Source/WebCore/dom/InlineStyleSheetOwner.h (206879 => 206880)
--- trunk/Source/WebCore/dom/InlineStyleSheetOwner.h 2016-10-06 20:47:44 UTC (rev 206879)
+++ trunk/Source/WebCore/dom/InlineStyleSheetOwner.h 2016-10-06 20:53:08 UTC (rev 206880)
@@ -44,12 +44,14 @@
bool sheetLoaded(Element&);
void startLoadingDynamicSheet(Element&);
- void insertedIntoDocument(Document&, Element&);
- void removedFromDocument(Document&, Element&);
- void clearDocumentData(Document&, Element&);
+ void insertedIntoDocument(Element&);
+ void removedFromDocument(Element&);
+ void clearDocumentData(Element&);
void childrenChanged(Element&);
void finishParsingChildren(Element&);
+ AuthorStyleSheets* styleSheetScope() { return m_styleSheetScope; }
+
private:
void createSheet(Element&, const String& text);
void createSheetFromTextContents(Element&);
@@ -61,6 +63,7 @@
AtomicString m_contentType;
AtomicString m_media;
RefPtr<CSSStyleSheet> m_sheet;
+ AuthorStyleSheets* m_styleSheetScope { nullptr };
};
}
Modified: trunk/Source/WebCore/dom/ShadowRoot.cpp (206879 => 206880)
--- trunk/Source/WebCore/dom/ShadowRoot.cpp 2016-10-06 20:47:44 UTC (rev 206879)
+++ trunk/Source/WebCore/dom/ShadowRoot.cpp 2016-10-06 20:53:08 UTC (rev 206880)
@@ -94,6 +94,14 @@
return *m_styleResolver;
}
+StyleResolver* ShadowRoot::styleResolverIfExists()
+{
+ if (m_type == Mode::UserAgent)
+ return &document().userAgentShadowTreeStyleResolver();
+
+ return m_styleResolver.get();
+}
+
void ShadowRoot::resetStyleResolver()
{
m_styleResolver = nullptr;
Modified: trunk/Source/WebCore/dom/ShadowRoot.h (206879 => 206880)
--- trunk/Source/WebCore/dom/ShadowRoot.h 2016-10-06 20:47:44 UTC (rev 206879)
+++ trunk/Source/WebCore/dom/ShadowRoot.h 2016-10-06 20:53:08 UTC (rev 206880)
@@ -63,8 +63,9 @@
using TreeScope::rootNode;
StyleResolver& styleResolver();
+ StyleResolver* styleResolverIfExists();
AuthorStyleSheets& authorStyleSheets();
-
+
void updateStyle();
void resetStyleResolver();
Modified: trunk/Source/WebCore/html/HTMLLinkElement.cpp (206879 => 206880)
--- trunk/Source/WebCore/html/HTMLLinkElement.cpp 2016-10-06 20:47:44 UTC (rev 206879)
+++ trunk/Source/WebCore/html/HTMLLinkElement.cpp 2016-10-06 20:53:08 UTC (rev 206880)
@@ -328,9 +328,6 @@
if (styleSheetIsLoading())
removePendingSheet(RemovePendingSheetNotifyLater);
-
- if (document().hasLivingRenderTree())
- document().authorStyleSheets().didChangeCandidatesForActiveSet();
}
void HTMLLinkElement::finishParsingChildren()
Modified: trunk/Source/WebCore/html/HTMLStyleElement.cpp (206879 => 206880)
--- trunk/Source/WebCore/html/HTMLStyleElement.cpp 2016-10-06 20:47:44 UTC (rev 206879)
+++ trunk/Source/WebCore/html/HTMLStyleElement.cpp 2016-10-06 20:53:08 UTC (rev 206880)
@@ -58,9 +58,7 @@
HTMLStyleElement::~HTMLStyleElement()
{
- // During tear-down, willRemove isn't called, so m_scopedStyleRegistrationState may still be RegisteredAsScoped or RegisteredInShadowRoot here.
- // Therefore we can't ASSERT(m_scopedStyleRegistrationState == NotRegistered).
- m_styleSheetOwner.clearDocumentData(document(), *this);
+ m_styleSheetOwner.clearDocumentData(*this);
styleLoadEventSender().cancelEvent(*this);
}
@@ -78,9 +76,10 @@
m_styleSheetOwner.setMedia(value);
if (sheet()) {
sheet()->setMediaQueries(MediaQuerySet::createAllowingDescriptionSyntax(value));
- if (inDocument() && document().hasLivingRenderTree())
- document().authorStyleSheets().didChangeContentsOrInterpretation();
- }
+ if (auto* scope = m_styleSheetOwner.styleSheetScope())
+ scope->didChangeContentsOrInterpretation();
+ } else
+ m_styleSheetOwner.childrenChanged(*this);
} else if (name == typeAttr)
m_styleSheetOwner.setContentType(value);
else
@@ -97,7 +96,7 @@
{
HTMLElement::insertedInto(insertionPoint);
if (insertionPoint.inDocument())
- m_styleSheetOwner.insertedIntoDocument(document(), *this);
+ m_styleSheetOwner.insertedIntoDocument(*this);
return InsertionDone;
}
@@ -107,7 +106,7 @@
HTMLElement::removedFrom(insertionPoint);
if (insertionPoint.inDocument())
- m_styleSheetOwner.removedFromDocument(document(), *this);
+ m_styleSheetOwner.removedFromDocument(*this);
}
void HTMLStyleElement::childrenChanged(const ChildChange& change)
Modified: trunk/Source/WebCore/page/DOMWindow.cpp (206879 => 206880)
--- trunk/Source/WebCore/page/DOMWindow.cpp 2016-10-06 20:47:44 UTC (rev 206879)
+++ trunk/Source/WebCore/page/DOMWindow.cpp 2016-10-06 20:53:08 UTC (rev 206880)
@@ -27,6 +27,7 @@
#include "config.h"
#include "DOMWindow.h"
+#include "AuthorStyleSheets.h"
#include "BackForwardController.h"
#include "BarProp.h"
#include "BeforeUnloadEvent.h"
@@ -1431,6 +1432,8 @@
if (pseudoType == CSSSelector::PseudoElementUnknown && !pseudoElement.isEmpty())
return nullptr;
+ m_frame->document()->authorStyleSheets().flushPendingUpdate();
+
unsigned rulesToInclude = StyleResolver::AuthorCSSRules;
if (!authorOnly)
rulesToInclude |= StyleResolver::UAAndUserCSSRules;
Modified: trunk/Source/WebCore/svg/SVGStyleElement.cpp (206879 => 206880)
--- trunk/Source/WebCore/svg/SVGStyleElement.cpp 2016-10-06 20:47:44 UTC (rev 206879)
+++ trunk/Source/WebCore/svg/SVGStyleElement.cpp 2016-10-06 20:53:08 UTC (rev 206880)
@@ -41,7 +41,7 @@
SVGStyleElement::~SVGStyleElement()
{
- m_styleSheetOwner.clearDocumentData(document(), *this);
+ m_styleSheetOwner.clearDocumentData(*this);
}
Ref<SVGStyleElement> SVGStyleElement::create(const QualifiedName& tagName, Document& document, bool createdByParser)
@@ -123,7 +123,7 @@
{
SVGElement::insertedInto(rootParent);
if (rootParent.inDocument())
- m_styleSheetOwner.insertedIntoDocument(document(), *this);
+ m_styleSheetOwner.insertedIntoDocument(*this);
return InsertionDone;
}
@@ -131,7 +131,7 @@
{
SVGElement::removedFrom(rootParent);
if (rootParent.inDocument())
- m_styleSheetOwner.removedFromDocument(document(), *this);
+ m_styleSheetOwner.removedFromDocument(*this);
}
void SVGStyleElement::childrenChanged(const ChildChange& change)