Diff
Modified: trunk/Source/WebCore/ChangeLog (206310 => 206311)
--- trunk/Source/WebCore/ChangeLog 2016-09-23 16:29:43 UTC (rev 206310)
+++ trunk/Source/WebCore/ChangeLog 2016-09-23 16:35:04 UTC (rev 206311)
@@ -1,3 +1,93 @@
+2016-09-23 Antti Koivisto <[email protected]>
+
+ Move stylesheet change logic from Document to AuthorStyleSheets
+ https://bugs.webkit.org/show_bug.cgi?id=162488
+
+ Reviewed by Andreas Kling.
+
+ That's where it belongs.
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * css/CSSStyleSheet.cpp:
+ (WebCore::CSSStyleSheet::didMutateRules):
+ (WebCore::CSSStyleSheet::didMutate):
+ (WebCore::CSSStyleSheet::clearOwnerNode):
+ * dom/AuthorStyleSheets.cpp:
+ (WebCore::AuthorStyleSheets::AuthorStyleSheets):
+ (WebCore::AuthorStyleSheets::flushPendingUpdates):
+ (WebCore::AuthorStyleSheets::scheduleOptimizedUpdate):
+ (WebCore::AuthorStyleSheets::didChange):
+ (WebCore::AuthorStyleSheets::optimizedUpdateTimerFired):
+ * dom/AuthorStyleSheets.h:
+ (WebCore::AuthorStyleSheets::hasPendingUpdate):
+ (WebCore::AuthorStyleSheets::pendingUpdateType): Deleted.
+ (WebCore::AuthorStyleSheets::setPendingUpdateType): Deleted.
+ (WebCore::AuthorStyleSheets::flushPendingUpdates): Deleted.
+ * dom/Document.cpp:
+ (WebCore::Document::Document):
+ (WebCore::Document::setContentLanguage):
+ (WebCore::Document::needsStyleRecalc):
+ (WebCore::Document::updateStyleIfNeeded):
+ (WebCore::Document::updateLayoutIgnorePendingStylesheets):
+ (WebCore::Document::didRemoveAllPendingStylesheet):
+ (WebCore::Document::processHttpEquiv):
+ (WebCore::Document::setSelectedStylesheetSet):
+ (WebCore::Document::updateHoverActiveState):
+ (WebCore::Document::optimizedStyleSheetUpdateTimerFired): Deleted.
+ (WebCore::Document::scheduleOptimizedStyleSheetUpdate): Deleted.
+ (WebCore::Document::styleResolverChanged): Deleted.
+ * dom/Document.h:
+ (WebCore::Document::needsStyleRecalc): Deleted.
+ * dom/ExtensionStyleSheets.cpp:
+ (WebCore::ExtensionStyleSheets::clearPageUserSheet):
+ (WebCore::ExtensionStyleSheets::updatePageUserSheet):
+ (WebCore::ExtensionStyleSheets::invalidateInjectedStyleSheetCache):
+ (WebCore::ExtensionStyleSheets::addUserStyleSheet):
+ (WebCore::ExtensionStyleSheets::addAuthorStyleSheetForTesting):
+ (WebCore::ExtensionStyleSheets::styleResolverChangedTimerFired):
+ * dom/InlineStyleSheetOwner.cpp:
+ (WebCore::InlineStyleSheetOwner::removedFromDocument):
+ * dom/ProcessingInstruction.cpp:
+ (WebCore::ProcessingInstruction::removedFrom):
+
+ Also fix a bug that prevented document from rendering if a loading processing instruction was removed from the tree.
+ This is tested by fast/dom/StyleSheet/detached-style-pi-2.xhtml (after other changes in this patch).
+
+ * dom/ShadowRoot.cpp:
+ (WebCore::ShadowRoot::updateStyle):
+ * html/HTMLLinkElement.cpp:
+ (WebCore::HTMLLinkElement::setDisabledState):
+ (WebCore::HTMLLinkElement::parseAttribute):
+ (WebCore::HTMLLinkElement::process):
+ (WebCore::HTMLLinkElement::removedFrom):
+ (WebCore::HTMLLinkElement::removePendingSheet):
+ * html/HTMLStyleElement.cpp:
+ (WebCore::HTMLStyleElement::parseAttribute):
+ * inspector/InspectorCSSAgent.cpp:
+ (WebCore::InspectorCSSAgent::forcePseudoState):
+ (WebCore::InspectorCSSAgent::resetPseudoStates):
+ * inspector/InspectorPageAgent.cpp:
+ (WebCore::InspectorPageAgent::setEmulatedMedia):
+ * page/Frame.cpp:
+ (WebCore::Frame::setPrinting):
+ * page/FrameView.cpp:
+ (WebCore::FrameView::layout):
+ (WebCore::FrameView::setPagination):
+ (WebCore::FrameView::setViewportSizeForCSSViewportUnits):
+ * page/Page.cpp:
+ (WebCore::Page::setViewMode):
+ (WebCore::Page::setNeedsRecalcStyleInAllFrames):
+ (WebCore::Page::invalidateInjectedStyleSheetCacheInAllFrames):
+ * svg/SVGFontFaceElement.cpp:
+ (WebCore::SVGFontFaceElement::rebuildFontFace):
+ (WebCore::SVGFontFaceElement::removedFrom):
+ * xml/XMLTreeViewer.cpp:
+ (WebCore::XMLTreeViewer::transformDocumentToTreeView):
+ * xml/parser/XMLDocumentParser.cpp:
+ (WebCore::XMLDocumentParser::end):
+ * xml/parser/XMLDocumentParserLibxml2.cpp:
+ (WebCore::XMLDocumentParser::doEnd):
+
2016-09-22 Sergio Villar Senin <[email protected]>
[css-grid] ASSERT when sizing tracks with percentages inside calc
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (206310 => 206311)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-09-23 16:29:43 UTC (rev 206310)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-09-23 16:35:04 UTC (rev 206311)
@@ -6197,7 +6197,7 @@
E461802D1C8DD2900026C02C /* StyleRelations.h in Headers */ = {isa = PBXBuildFile; fileRef = E461802C1C8DD2900026C02C /* StyleRelations.h */; };
E461802F1C8DD4D20026C02C /* StyleRelations.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E461802E1C8DD4D20026C02C /* StyleRelations.cpp */; };
E461D65D1BB0C7F000CB5645 /* AuthorStyleSheets.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E461D65C1BB0C7F000CB5645 /* AuthorStyleSheets.cpp */; };
- E461D65F1BB0C80D00CB5645 /* AuthorStyleSheets.h in Headers */ = {isa = PBXBuildFile; fileRef = E461D65E1BB0C80D00CB5645 /* AuthorStyleSheets.h */; };
+ E461D65F1BB0C80D00CB5645 /* AuthorStyleSheets.h in Headers */ = {isa = PBXBuildFile; fileRef = E461D65E1BB0C80D00CB5645 /* AuthorStyleSheets.h */; settings = {ATTRIBUTES = (Private, ); }; };
E462A4A1113E71BE004A4220 /* IntPointHash.h in Headers */ = {isa = PBXBuildFile; fileRef = E462A4A0113E71BE004A4220 /* IntPointHash.h */; settings = {ATTRIBUTES = (Private, ); }; };
E46A2B1C17CA65B9000DBCD8 /* TypedElementDescendantIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = E46A2B1B17CA65B9000DBCD8 /* TypedElementDescendantIterator.h */; settings = {ATTRIBUTES = (Private, ); }; };
E46A2B1E17CA76B1000DBCD8 /* ElementChildIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = E46A2B1D17CA76B1000DBCD8 /* ElementChildIterator.h */; settings = {ATTRIBUTES = (Private, ); }; };
Modified: trunk/Source/WebCore/css/CSSStyleSheet.cpp (206310 => 206311)
--- trunk/Source/WebCore/css/CSSStyleSheet.cpp 2016-09-23 16:29:43 UTC (rev 206310)
+++ trunk/Source/WebCore/css/CSSStyleSheet.cpp 2016-09-23 16:35:04 UTC (rev 206311)
@@ -179,11 +179,11 @@
resolver->addKeyframeStyle(*insertedKeyframesRule);
return;
}
- owner->scheduleOptimizedStyleSheetUpdate();
+ owner->authorStyleSheets().scheduleOptimizedUpdate();
return;
}
- owner->styleResolverChanged(DeferRecalcStyle);
+ owner->authorStyleSheets().didChange(DeferRecalcStyle);
m_mutatedRules = true;
}
@@ -193,7 +193,7 @@
Document* owner = ownerDocument();
if (!owner)
return;
- owner->styleResolverChanged(DeferRecalcStyle);
+ owner->authorStyleSheets().didChange(DeferRecalcStyle);
}
void CSSStyleSheet::clearOwnerNode()
@@ -202,7 +202,7 @@
m_ownerNode = 0;
if (!owner)
return;
- owner->styleResolverChanged(DeferRecalcStyleIfNeeded);
+ owner->authorStyleSheets().didChange(DeferRecalcStyleIfNeeded);
}
void CSSStyleSheet::reattachChildRuleCSSOMWrappers()
Modified: trunk/Source/WebCore/dom/AuthorStyleSheets.cpp (206310 => 206311)
--- trunk/Source/WebCore/dom/AuthorStyleSheets.cpp 2016-09-23 16:29:43 UTC (rev 206310)
+++ trunk/Source/WebCore/dom/AuthorStyleSheets.cpp 2016-09-23 16:35:04 UTC (rev 206311)
@@ -57,6 +57,7 @@
AuthorStyleSheets::AuthorStyleSheets(Document& document)
: m_document(document)
+ , m_optimizedUpdateTimer(*this, &AuthorStyleSheets::optimizedUpdateTimerFired)
{
}
@@ -63,6 +64,7 @@
AuthorStyleSheets::AuthorStyleSheets(ShadowRoot& shadowRoot)
: m_document(shadowRoot.documentScope())
, m_shadowRoot(&shadowRoot)
+ , m_optimizedUpdateTimer(*this, &AuthorStyleSheets::optimizedUpdateTimerFired)
{
}
@@ -384,4 +386,64 @@
return m_weakCopyOfActiveStyleSheetListForFastLookup->contains(sheet);
}
+void AuthorStyleSheets::flushPendingUpdates()
+{
+ if (m_pendingUpdateType == NoUpdate)
+ return;
+ updateActiveStyleSheets(m_pendingUpdateType);
}
+
+void AuthorStyleSheets::scheduleOptimizedUpdate()
+{
+ if (m_optimizedUpdateTimer.isActive())
+ return;
+ if (m_pendingUpdateType == NoUpdate)
+ m_pendingUpdateType = OptimizedUpdate;
+ m_optimizedUpdateTimer.startOneShot(0);
+}
+
+void AuthorStyleSheets::didChange(StyleResolverUpdateFlag updateFlag)
+{
+ m_optimizedUpdateTimer.stop();
+
+ // Don't bother updating, since we haven't loaded all our style info yet
+ // and haven't calculated the style resolver for the first time.
+ if (!m_document.hasLivingRenderTree() || (!m_shadowRoot && !m_didCalculateStyleResolver && m_pendingStyleSheetCount)) {
+ m_document.clearStyleResolver();
+ return;
+ }
+ m_didCalculateStyleResolver = true;
+
+ auto styleSheetUpdate = (updateFlag == RecalcStyleIfNeeded || updateFlag == DeferRecalcStyleIfNeeded)
+ ? AuthorStyleSheets::OptimizedUpdate
+ : AuthorStyleSheets::FullUpdate;
+ bool stylesheetChangeRequiresStyleRecalc = updateActiveStyleSheets(styleSheetUpdate);
+
+ auto scheduleStyleRecalc = [&] {
+ if (m_shadowRoot)
+ m_shadowRoot->setNeedsStyleRecalc();
+ else
+ m_document.scheduleForcedStyleRecalc();
+ };
+
+ if (updateFlag == DeferRecalcStyle) {
+ scheduleStyleRecalc();
+ return;
+ }
+
+ if (updateFlag == DeferRecalcStyleIfNeeded) {
+ if (stylesheetChangeRequiresStyleRecalc)
+ scheduleStyleRecalc();
+ return;
+ }
+
+ if (stylesheetChangeRequiresStyleRecalc)
+ m_document.recalcStyle(Style::Force);
+}
+
+void AuthorStyleSheets::optimizedUpdateTimerFired()
+{
+ didChange(RecalcStyleIfNeeded);
+}
+
+}
Modified: trunk/Source/WebCore/dom/AuthorStyleSheets.h (206310 => 206311)
--- trunk/Source/WebCore/dom/AuthorStyleSheets.h 2016-09-23 16:29:43 UTC (rev 206310)
+++ trunk/Source/WebCore/dom/AuthorStyleSheets.h 2016-09-23 16:35:04 UTC (rev 206311)
@@ -48,6 +48,13 @@
class ShadowRoot;
class TreeScope;
+enum StyleResolverUpdateFlag {
+ RecalcStyleImmediately,
+ DeferRecalcStyle,
+ RecalcStyleIfNeeded,
+ DeferRecalcStyleIfNeeded
+};
+
class AuthorStyleSheets {
WTF_MAKE_FAST_ALLOCATED;
public:
@@ -62,23 +69,8 @@
void addStyleSheetCandidateNode(Node&, bool createdByParser);
void removeStyleSheetCandidateNode(Node&);
- enum UpdateFlag { NoUpdate = 0, OptimizedUpdate, FullUpdate };
+ WEBCORE_EXPORT void didChange(StyleResolverUpdateFlag);
- UpdateFlag pendingUpdateType() const { return m_pendingUpdateType; }
- void setPendingUpdateType(UpdateFlag updateType)
- {
- if (updateType > m_pendingUpdateType)
- m_pendingUpdateType = updateType;
- }
-
- void flushPendingUpdates()
- {
- if (m_pendingUpdateType != NoUpdate)
- updateActiveStyleSheets(m_pendingUpdateType);
- }
-
- bool updateActiveStyleSheets(UpdateFlag);
-
String preferredStylesheetSetName() const { return m_preferredStylesheetSetName; }
String selectedStylesheetSetName() const { return m_selectedStylesheetSetName; }
void setPreferredStylesheetSetName(const String& name) { m_preferredStylesheetSetName = name; }
@@ -99,8 +91,16 @@
bool activeStyleSheetsContains(const CSSStyleSheet*) const;
+ void scheduleOptimizedUpdate();
+ bool hasPendingUpdate() const { return m_optimizedUpdateTimer.isActive(); }
+ void flushPendingUpdates();
+
private:
+ enum UpdateFlag { NoUpdate = 0, OptimizedUpdate, FullUpdate };
+ bool updateActiveStyleSheets(UpdateFlag);
+
void collectActiveStyleSheets(Vector<RefPtr<StyleSheet>>&);
+
enum StyleResolverUpdateType {
Reconstruct,
Reset,
@@ -109,6 +109,8 @@
StyleResolverUpdateType analyzeStyleSheetChange(UpdateFlag, const Vector<RefPtr<CSSStyleSheet>>& newStylesheets, bool& requiresFullStyleRecalc);
void updateStyleResolver(Vector<RefPtr<CSSStyleSheet>>&, StyleResolverUpdateType);
+ void optimizedUpdateTimerFired();
+
Document& m_document;
ShadowRoot* m_shadowRoot { nullptr };
@@ -115,6 +117,8 @@
Vector<RefPtr<StyleSheet>> m_styleSheetsForStyleSheetList;
Vector<RefPtr<CSSStyleSheet>> m_activeStyleSheets;
+ Timer m_optimizedUpdateTimer;
+
// This is a mirror of m_activeAuthorStyleSheets that gets populated on demand for activeStyleSheetsContains().
mutable std::unique_ptr<HashSet<const CSSStyleSheet*>> m_weakCopyOfActiveStyleSheetListForFastLookup;
@@ -123,6 +127,7 @@
// We use this count of pending sheets to detect when we can begin attaching
// elements and when it is safe to execute scripts.
int m_pendingStyleSheetCount { 0 };
+ bool m_didCalculateStyleResolver { false };
UpdateFlag m_pendingUpdateType { NoUpdate };
Modified: trunk/Source/WebCore/dom/Document.cpp (206310 => 206311)
--- trunk/Source/WebCore/dom/Document.cpp 2016-09-23 16:29:43 UTC (rev 206310)
+++ trunk/Source/WebCore/dom/Document.cpp 2016-09-23 16:35:04 UTC (rev 206311)
@@ -435,7 +435,6 @@
, m_touchEventsChangedTimer(*this, &Document::touchEventsChangedTimerFired)
#endif
, m_referencingNodeCount(0)
- , m_didCalculateStyleResolver(false)
, m_hasNodesWithPlaceholderStyle(false)
, m_needsNotifyRemoveAllPendingStylesheet(false)
, m_ignorePendingStylesheets(false)
@@ -458,7 +457,6 @@
, m_visuallyOrdered(false)
, m_readyState(Complete)
, m_bParsing(false)
- , m_optimizedStyleSheetUpdateTimer(*this, &Document::optimizedStyleSheetUpdateTimerFired)
, m_styleRecalcTimer(*this, &Document::updateStyleIfNeeded)
, m_pendingStyleRecalcShouldForce(false)
, m_inStyleRecalc(false)
@@ -1357,7 +1355,7 @@
m_contentLanguage = language;
// Recalculate style so language is used when selecting the initial font.
- styleResolverChanged(DeferRecalcStyle);
+ m_authorStyleSheets->didChange(DeferRecalcStyle);
}
void Document::setXMLVersion(const String& version, ExceptionCode& ec)
@@ -1945,6 +1943,14 @@
frameView.frame().mainFrame().eventHandler().dispatchFakeMouseMoveEventSoon();
}
+bool Document::needsStyleRecalc() const
+{
+ if (pageCacheState() != NotInPageCache)
+ return false;
+
+ return m_pendingStyleRecalcShouldForce || childNeedsStyleRecalc() || authorStyleSheets().hasPendingUpdate();
+}
+
void Document::updateStyleIfNeeded()
{
ASSERT(isMainThread());
@@ -1953,8 +1959,8 @@
if (!view() || view()->isInRenderTreeLayout())
return;
- if (m_optimizedStyleSheetUpdateTimer.isActive())
- styleResolverChanged(RecalcStyleIfNeeded);
+ if (authorStyleSheets().hasPendingUpdate())
+ authorStyleSheets().didChange(RecalcStyleIfNeeded);
if (!needsStyleRecalc())
return;
@@ -2008,7 +2014,7 @@
HTMLElement* bodyElement = bodyOrFrameset();
if (bodyElement && !bodyElement->renderer() && m_pendingSheetLayout == NoLayoutWithPendingSheets) {
m_pendingSheetLayout = DidLayoutWithPendingSheets;
- styleResolverChanged(RecalcStyleImmediately);
+ authorStyleSheets().didChange(RecalcStyleImmediately);
} else if (m_hasNodesWithPlaceholderStyle)
// If new nodes have been added or style recalc has been done with style sheets still pending, some nodes
// may not have had their real style calculated yet. Normally this gets cleaned when style sheets arrive
@@ -3145,7 +3151,7 @@
{
m_needsNotifyRemoveAllPendingStylesheet = false;
- styleResolverChanged(DeferRecalcStyleIfNeeded);
+ authorStyleSheets().didChange(DeferRecalcStyleIfNeeded);
if (m_pendingSheetLayout == DidLayoutWithPendingSheets) {
m_pendingSheetLayout = IgnoreLayoutWithPendingSheets;
@@ -3220,7 +3226,7 @@
// -dwh
authorStyleSheets().setSelectedStylesheetSetName(content);
authorStyleSheets().setPreferredStylesheetSetName(content);
- styleResolverChanged(DeferRecalcStyle);
+ authorStyleSheets().didChange(DeferRecalcStyle);
break;
case HTTPHeaderName::Refresh: {
@@ -3524,7 +3530,7 @@
void Document::setSelectedStylesheetSet(const String& aString)
{
authorStyleSheets().setSelectedStylesheetSetName(aString);
- styleResolverChanged(DeferRecalcStyle);
+ authorStyleSheets().didChange(DeferRecalcStyle);
}
void Document::evaluateMediaQueryList()
@@ -3547,19 +3553,6 @@
picture->sourcesChanged();
}
-void Document::optimizedStyleSheetUpdateTimerFired()
-{
- styleResolverChanged(RecalcStyleIfNeeded);
-}
-
-void Document::scheduleOptimizedStyleSheetUpdate()
-{
- if (m_optimizedStyleSheetUpdateTimer.isActive())
- return;
- authorStyleSheets().setPendingUpdateType(AuthorStyleSheets::OptimizedUpdate);
- m_optimizedStyleSheetUpdateTimer.startOneShot(0);
-}
-
void Document::updateViewportUnitsOnResize()
{
if (!hasStyleWithViewportUnits())
@@ -3624,39 +3617,6 @@
audioProducer->pageMutedStateDidChange();
}
-void Document::styleResolverChanged(StyleResolverUpdateFlag updateFlag)
-{
- if (m_optimizedStyleSheetUpdateTimer.isActive())
- m_optimizedStyleSheetUpdateTimer.stop();
-
- // Don't bother updating, since we haven't loaded all our style info yet
- // and haven't calculated the style selector for the first time.
- if (!hasLivingRenderTree() || (!m_didCalculateStyleResolver && !haveStylesheetsLoaded())) {
- m_styleResolver = nullptr;
- return;
- }
- m_didCalculateStyleResolver = true;
-
- auto styleSheetUpdate = (updateFlag == RecalcStyleIfNeeded || updateFlag == DeferRecalcStyleIfNeeded)
- ? AuthorStyleSheets::OptimizedUpdate
- : AuthorStyleSheets::FullUpdate;
- bool stylesheetChangeRequiresStyleRecalc = authorStyleSheets().updateActiveStyleSheets(styleSheetUpdate);
-
- if (updateFlag == DeferRecalcStyle) {
- scheduleForcedStyleRecalc();
- return;
- }
-
- if (updateFlag == DeferRecalcStyleIfNeeded) {
- if (stylesheetChangeRequiresStyleRecalc)
- scheduleForcedStyleRecalc();
- return;
- }
-
- if (stylesheetChangeRequiresStyleRecalc)
- recalcStyle(Style::Force);
-}
-
static bool isNodeInSubtree(Node* node, Node* container, bool amongChildrenOnly)
{
bool nodeInSubtree = false;
@@ -6645,7 +6605,7 @@
return nullptr;
}
-void Document::updateHoverActiveState(const HitTestRequest& request, Element* innerElement, StyleResolverUpdateFlag updateFlag)
+void Document::updateHoverActiveState(const HitTestRequest& request, Element* innerElement)
{
ASSERT(!request.readOnly());
@@ -6762,9 +6722,7 @@
}
}
- ASSERT(updateFlag == RecalcStyleIfNeeded || updateFlag == DeferRecalcStyleIfNeeded);
- if (updateFlag == RecalcStyleIfNeeded)
- updateStyleIfNeeded();
+ updateStyleIfNeeded();
}
bool Document::haveStylesheetsLoaded() const
Modified: trunk/Source/WebCore/dom/Document.h (206310 => 206311)
--- trunk/Source/WebCore/dom/Document.h 2016-09-23 16:29:43 UTC (rev 206310)
+++ trunk/Source/WebCore/dom/Document.h 2016-09-23 16:35:04 UTC (rev 206311)
@@ -231,8 +231,6 @@
PageshowEventPersisted = 1
};
-enum StyleResolverUpdateFlag { RecalcStyleImmediately, DeferRecalcStyle, RecalcStyleIfNeeded, DeferRecalcStyleIfNeeded };
-
enum NodeListInvalidationType {
DoNotInvalidateOnAttributeChanges = 0,
InvalidateOnClassAttrChange,
@@ -517,19 +515,6 @@
bool gotoAnchorNeededAfterStylesheetsLoad() { return m_gotoAnchorNeededAfterStylesheetsLoad; }
void setGotoAnchorNeededAfterStylesheetsLoad(bool b) { m_gotoAnchorNeededAfterStylesheetsLoad = b; }
- /**
- * Called when one or more stylesheets in the document may have been added, removed or changed.
- *
- * Creates a new style resolver and assign it to this document. This is done by iterating through all nodes in
- * document (or those before <BODY> in a HTML document), searching for stylesheets. Stylesheets can be contained in
- * <LINK>, <STYLE> or <BODY> elements, as well as processing instructions (XML documents only). A list is
- * constructed from these which is used to create the a new style selector which collates all of the stylesheets
- * found and is used to calculate the derived styles for all rendering objects.
- */
- WEBCORE_EXPORT void styleResolverChanged(StyleResolverUpdateFlag);
-
- void scheduleOptimizedStyleSheetUpdate();
-
void evaluateMediaQueryList();
FormController& formController();
@@ -557,7 +542,7 @@
void recalcStyle(Style::Change = Style::NoChange);
WEBCORE_EXPORT void updateStyleIfNeeded();
- bool needsStyleRecalc() const { return pageCacheState() == NotInPageCache && (m_pendingStyleRecalcShouldForce || childNeedsStyleRecalc() || m_optimizedStyleSheetUpdateTimer.isActive()); }
+ bool needsStyleRecalc() const;
WEBCORE_EXPORT void updateLayout();
@@ -736,7 +721,7 @@
void hoveredElementDidDetach(Element*);
void elementInActiveChainDidDetach(Element*);
- void updateHoverActiveState(const HitTestRequest&, Element*, StyleResolverUpdateFlag = RecalcStyleIfNeeded);
+ void updateHoverActiveState(const HitTestRequest&, Element*);
// Updates for :target (CSS3 selector).
void setCSSTarget(Element*);
@@ -748,7 +733,6 @@
void unscheduleStyleRecalc();
bool hasPendingStyleRecalc() const;
bool hasPendingForcedStyleRecalc() const;
- void optimizedStyleSheetUpdateTimerFired();
void registerNodeListForInvalidation(LiveNodeList&);
void unregisterNodeListForInvalidation(LiveNodeList&);
@@ -1414,7 +1398,6 @@
std::unique_ptr<StyleResolver> m_styleResolver;
std::unique_ptr<StyleResolver> m_userAgentShadowTreeStyleResolver;
- bool m_didCalculateStyleResolver;
bool m_hasNodesWithPlaceholderStyle;
bool m_needsNotifyRemoveAllPendingStylesheet;
// But sometimes you need to ignore pending stylesheet count to
@@ -1502,7 +1485,6 @@
ReadyState m_readyState;
bool m_bParsing;
- Timer m_optimizedStyleSheetUpdateTimer;
Timer m_styleRecalcTimer;
bool m_pendingStyleRecalcShouldForce;
bool m_inStyleRecalc;
Modified: trunk/Source/WebCore/dom/ExtensionStyleSheets.cpp (206310 => 206311)
--- trunk/Source/WebCore/dom/ExtensionStyleSheets.cpp 2016-09-23 16:29:43 UTC (rev 206310)
+++ trunk/Source/WebCore/dom/ExtensionStyleSheets.cpp 2016-09-23 16:35:04 UTC (rev 206311)
@@ -28,6 +28,7 @@
#include "config.h"
#include "ExtensionStyleSheets.h"
+#include "AuthorStyleSheets.h"
#include "CSSStyleSheet.h"
#include "Element.h"
#include "HTMLIFrameElement.h"
@@ -82,7 +83,7 @@
{
if (m_pageUserSheet) {
m_pageUserSheet = nullptr;
- m_document.styleResolverChanged(DeferRecalcStyle);
+ m_document.authorStyleSheets().didChange(DeferRecalcStyle);
}
}
@@ -90,7 +91,7 @@
{
clearPageUserSheet();
if (pageUserSheet())
- m_document.styleResolverChanged(RecalcStyleImmediately);
+ m_document.authorStyleSheets().didChange(RecalcStyleImmediately);
}
const Vector<RefPtr<CSSStyleSheet>>& ExtensionStyleSheets::injectedUserStyleSheets() const
@@ -154,7 +155,7 @@
m_injectedStyleSheetCacheValid = false;
if (m_injectedUserStyleSheets.isEmpty() && m_injectedAuthorStyleSheets.isEmpty())
return;
- m_document.styleResolverChanged(DeferRecalcStyle);
+ m_document.authorStyleSheets().didChange(DeferRecalcStyle);
}
void ExtensionStyleSheets::addUserStyleSheet(Ref<StyleSheetContents>&& userSheet)
@@ -161,7 +162,7 @@
{
ASSERT(userSheet.get().isUserStyleSheet());
m_userStyleSheets.append(CSSStyleSheet::create(WTFMove(userSheet), m_document));
- m_document.styleResolverChanged(RecalcStyleImmediately);
+ m_document.authorStyleSheets().didChange(RecalcStyleImmediately);
}
void ExtensionStyleSheets::addAuthorStyleSheetForTesting(Ref<StyleSheetContents>&& authorSheet)
@@ -168,7 +169,7 @@
{
ASSERT(!authorSheet.get().isUserStyleSheet());
m_authorStyleSheetsForTesting.append(CSSStyleSheet::create(WTFMove(authorSheet), m_document));
- m_document.styleResolverChanged(RecalcStyleImmediately);
+ m_document.authorStyleSheets().didChange(RecalcStyleImmediately);
}
#if ENABLE(CONTENT_EXTENSIONS)
@@ -200,7 +201,7 @@
void ExtensionStyleSheets::styleResolverChangedTimerFired()
{
- m_document.styleResolverChanged(RecalcStyleImmediately);
+ m_document.authorStyleSheets().didChange(RecalcStyleImmediately);
}
void ExtensionStyleSheets::detachFromDocument()
Modified: trunk/Source/WebCore/dom/InlineStyleSheetOwner.cpp (206310 => 206311)
--- trunk/Source/WebCore/dom/InlineStyleSheetOwner.cpp 2016-09-23 16:29:43 UTC (rev 206310)
+++ trunk/Source/WebCore/dom/InlineStyleSheetOwner.cpp 2016-09-23 16:35:04 UTC (rev 206311)
@@ -73,7 +73,7 @@
// If we're in document teardown, then we don't need to do any notification of our sheet's removal.
if (document.hasLivingRenderTree())
- document.styleResolverChanged(DeferRecalcStyle);
+ document.authorStyleSheets().didChange(DeferRecalcStyle);
}
void InlineStyleSheetOwner::clearDocumentData(Document&, Element& element)
Modified: trunk/Source/WebCore/dom/ProcessingInstruction.cpp (206310 => 206311)
--- trunk/Source/WebCore/dom/ProcessingInstruction.cpp 2016-09-23 16:29:43 UTC (rev 206310)
+++ trunk/Source/WebCore/dom/ProcessingInstruction.cpp 2016-09-23 16:35:04 UTC (rev 206311)
@@ -268,11 +268,17 @@
ASSERT(m_sheet->ownerNode() == this);
m_sheet->clearOwnerNode();
m_sheet = nullptr;
+
}
+ if (m_loading) {
+ m_loading = false;
+ document().authorStyleSheets().removePendingSheet();
+ }
+
// If we're in document teardown, then we don't need to do any notification of our sheet's removal.
if (document().hasLivingRenderTree())
- document().styleResolverChanged(DeferRecalcStyle);
+ document().authorStyleSheets().didChange(DeferRecalcStyle);
}
void ProcessingInstruction::finishParsingChildren()
Modified: trunk/Source/WebCore/dom/ShadowRoot.cpp (206310 => 206311)
--- trunk/Source/WebCore/dom/ShadowRoot.cpp 2016-09-23 16:29:43 UTC (rev 206310)
+++ trunk/Source/WebCore/dom/ShadowRoot.cpp 2016-09-23 16:35:04 UTC (rev 206311)
@@ -108,15 +108,10 @@
void ShadowRoot::updateStyle()
{
- bool shouldRecalcStyle = false;
-
- if (m_authorStyleSheets) {
- // FIXME: Make optimized updated work.
- shouldRecalcStyle = m_authorStyleSheets->updateActiveStyleSheets(AuthorStyleSheets::FullUpdate);
- }
-
- if (shouldRecalcStyle)
- setNeedsStyleRecalc();
+ if (!m_authorStyleSheets)
+ return;
+ // FIXME: Make optimized updated work.
+ m_authorStyleSheets->didChange(DeferRecalcStyle);
}
String ShadowRoot::innerHTML() const
Modified: trunk/Source/WebCore/html/HTMLLinkElement.cpp (206310 => 206311)
--- trunk/Source/WebCore/html/HTMLLinkElement.cpp 2016-09-23 16:29:43 UTC (rev 206310)
+++ trunk/Source/WebCore/html/HTMLLinkElement.cpp 2016-09-23 16:35:04 UTC (rev 206311)
@@ -140,7 +140,7 @@
if (!m_sheet && m_disabledState == EnabledViaScript)
process();
else
- document().styleResolverChanged(DeferRecalcStyle); // Update the style selector.
+ document().authorStyleSheets().didChange(DeferRecalcStyle);
}
}
@@ -176,7 +176,7 @@
m_media = value.string().convertToASCIILowercase();
process();
if (m_sheet && !isDisabled())
- document().styleResolverChanged(DeferRecalcStyle);
+ document().authorStyleSheets().didChange(DeferRecalcStyle);
return;
}
if (name == disabledAttr) {
@@ -283,7 +283,7 @@
} else if (m_sheet) {
// we no longer contain a stylesheet, e.g. perhaps rel or type was changed
clearSheet();
- document().styleResolverChanged(DeferRecalcStyle);
+ document().authorStyleSheets().didChange(DeferRecalcStyle);
}
}
@@ -330,7 +330,7 @@
removePendingSheet(RemovePendingSheetNotifyLater);
if (document().hasLivingRenderTree())
- document().styleResolverChanged(DeferRecalcStyleIfNeeded);
+ document().authorStyleSheets().didChange(DeferRecalcStyleIfNeeded);
}
void HTMLLinkElement::finishParsingChildren()
@@ -555,7 +555,7 @@
if (type == InactiveSheet) {
// Document just needs to know about the sheet for exposure through document.styleSheets
- document().authorStyleSheets().updateActiveStyleSheets(AuthorStyleSheets::OptimizedUpdate);
+ document().authorStyleSheets().didChange(DeferRecalcStyleIfNeeded);
return;
}
Modified: trunk/Source/WebCore/html/HTMLStyleElement.cpp (206310 => 206311)
--- trunk/Source/WebCore/html/HTMLStyleElement.cpp 2016-09-23 16:29:43 UTC (rev 206310)
+++ trunk/Source/WebCore/html/HTMLStyleElement.cpp 2016-09-23 16:35:04 UTC (rev 206311)
@@ -24,6 +24,7 @@
#include "config.h"
#include "HTMLStyleElement.h"
+#include "AuthorStyleSheets.h"
#include "Document.h"
#include "Event.h"
#include "EventNames.h"
@@ -77,7 +78,7 @@
if (sheet()) {
sheet()->setMediaQueries(MediaQuerySet::createAllowingDescriptionSyntax(value));
if (inDocument() && document().hasLivingRenderTree())
- document().styleResolverChanged(RecalcStyleImmediately);
+ document().authorStyleSheets().didChange(RecalcStyleImmediately);
}
} else if (name == typeAttr)
m_styleSheetOwner.setContentType(value);
Modified: trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp (206310 => 206311)
--- trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp 2016-09-23 16:29:43 UTC (rev 206310)
+++ trunk/Source/WebCore/inspector/InspectorCSSAgent.cpp 2016-09-23 16:35:04 UTC (rev 206311)
@@ -889,7 +889,7 @@
m_nodeIdToForcedPseudoState.set(nodeId, forcedPseudoState);
else
m_nodeIdToForcedPseudoState.remove(nodeId);
- element->document().styleResolverChanged(RecalcStyleImmediately);
+ element->document().authorStyleSheets().didChange(RecalcStyleImmediately);
}
void InspectorCSSAgent::getNamedFlowCollection(ErrorString& errorString, int documentNodeId, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::CSS::NamedFlow>>& result)
@@ -1189,7 +1189,7 @@
m_nodeIdToForcedPseudoState.clear();
for (auto& document : documentsToChange)
- document->styleResolverChanged(RecalcStyleImmediately);
+ document->authorStyleSheets().didChange(RecalcStyleImmediately);
}
} // namespace WebCore
Modified: trunk/Source/WebCore/inspector/InspectorPageAgent.cpp (206310 => 206311)
--- trunk/Source/WebCore/inspector/InspectorPageAgent.cpp 2016-09-23 16:29:43 UTC (rev 206310)
+++ trunk/Source/WebCore/inspector/InspectorPageAgent.cpp 2016-09-23 16:35:04 UTC (rev 206311)
@@ -32,6 +32,7 @@
#include "config.h"
#include "InspectorPageAgent.h"
+#include "AuthorStyleSheets.h"
#include "CachedCSSStyleSheet.h"
#include "CachedFont.h"
#include "CachedImage.h"
@@ -1001,7 +1002,7 @@
m_emulatedMedia = media;
Document* document = m_page.mainFrame().document();
if (document) {
- document->styleResolverChanged(RecalcStyleImmediately);
+ document->authorStyleSheets().didChange(RecalcStyleImmediately);
document->updateLayout();
}
}
Modified: trunk/Source/WebCore/page/Frame.cpp (206310 => 206311)
--- trunk/Source/WebCore/page/Frame.cpp 2016-09-23 16:29:43 UTC (rev 206310)
+++ trunk/Source/WebCore/page/Frame.cpp 2016-09-23 16:35:04 UTC (rev 206311)
@@ -32,6 +32,7 @@
#include "AnimationController.h"
#include "ApplyStyleCommand.h"
+#include "AuthorStyleSheets.h"
#include "BackForwardController.h"
#include "CSSComputedStyleDeclaration.h"
#include "CSSPropertyNames.h"
@@ -643,7 +644,7 @@
m_doc->setPrinting(printing);
view()->adjustMediaTypeForPrinting(printing);
- m_doc->styleResolverChanged(RecalcStyleImmediately);
+ m_doc->authorStyleSheets().didChange(RecalcStyleImmediately);
if (shouldUsePrintingLayout()) {
view()->forceLayoutForPagination(pageSize, originalPageSize, maximumShrinkRatio, shouldAdjustViewSize);
} else {
Modified: trunk/Source/WebCore/page/FrameView.cpp (206310 => 206311)
--- trunk/Source/WebCore/page/FrameView.cpp 2016-09-23 16:29:43 UTC (rev 206310)
+++ trunk/Source/WebCore/page/FrameView.cpp 2016-09-23 16:35:04 UTC (rev 206311)
@@ -29,6 +29,7 @@
#include "AXObjectCache.h"
#include "AnimationController.h"
+#include "AuthorStyleSheets.h"
#include "BackForwardController.h"
#include "CachedImage.h"
#include "CachedResourceLoader.h"
@@ -1300,7 +1301,7 @@
StyleResolver* styleResolver = document.styleResolverIfExists();
if (!styleResolver || styleResolver->hasMediaQueriesAffectedByViewportChange()) {
LOG(Layout, " hasMediaQueriesAffectedByViewportChange, enqueueing style recalc");
- document.styleResolverChanged(DeferRecalcStyle);
+ document.authorStyleSheets().didChange(DeferRecalcStyle);
// FIXME: This instrumentation event is not strictly accurate since cached media query results do not persist across StyleResolver rebuilds.
InspectorInstrumentation::mediaQueryResultChanged(document);
} else
@@ -3495,7 +3496,7 @@
m_pagination = pagination;
- frame().document()->styleResolverChanged(DeferRecalcStyle);
+ frame().document()->authorStyleSheets().didChange(DeferRecalcStyle);
}
IntRect FrameView::windowClipRect() const
@@ -4964,7 +4965,7 @@
if (Document* document = frame().document()) {
// FIXME: this should probably be updateViewportUnitsOnResize(), but synchronously
// dirtying style here causes assertions on iOS (rdar://problem/19998166).
- document->styleResolverChanged(DeferRecalcStyle);
+ document->authorStyleSheets().didChange(DeferRecalcStyle);
}
}
Modified: trunk/Source/WebCore/page/Page.cpp (206310 => 206311)
--- trunk/Source/WebCore/page/Page.cpp 2016-09-23 16:29:43 UTC (rev 206310)
+++ trunk/Source/WebCore/page/Page.cpp 2016-09-23 16:35:04 UTC (rev 206311)
@@ -23,6 +23,7 @@
#include "AlternativeTextClient.h"
#include "AnimationController.h"
#include "ApplicationCacheStorage.h"
+#include "AuthorStyleSheets.h"
#include "BackForwardClient.h"
#include "BackForwardController.h"
#include "Chrome.h"
@@ -422,7 +423,7 @@
m_mainFrame->view()->forceLayout();
if (m_mainFrame->document())
- m_mainFrame->document()->styleResolverChanged(RecalcStyleImmediately);
+ m_mainFrame->document()->authorStyleSheets().didChange(RecalcStyleImmediately);
}
#endif // ENABLE(VIEW_MODE_CSS_MEDIA)
@@ -500,7 +501,7 @@
{
for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
if (Document* document = frame->document())
- document->styleResolverChanged(DeferRecalcStyle);
+ document->authorStyleSheets().didChange(DeferRecalcStyle);
}
}
@@ -1161,7 +1162,7 @@
if (!document)
continue;
document->extensionStyleSheets().invalidateInjectedStyleSheetCache();
- document->styleResolverChanged(DeferRecalcStyle);
+ document->authorStyleSheets().didChange(DeferRecalcStyle);
}
}
Modified: trunk/Source/WebCore/svg/SVGFontFaceElement.cpp (206310 => 206311)
--- trunk/Source/WebCore/svg/SVGFontFaceElement.cpp 2016-09-23 16:29:43 UTC (rev 206310)
+++ trunk/Source/WebCore/svg/SVGFontFaceElement.cpp 2016-09-23 16:35:04 UTC (rev 206311)
@@ -24,6 +24,7 @@
#if ENABLE(SVG_FONTS)
#include "SVGFontFaceElement.h"
+#include "AuthorStyleSheets.h"
#include "CSSFontFaceSrcValue.h"
#include "CSSParser.h"
#include "CSSPropertyNames.h"
@@ -266,7 +267,7 @@
}
}
- document().styleResolverChanged(DeferRecalcStyle);
+ document().authorStyleSheets().didChange(DeferRecalcStyle);
}
Node::InsertionNotificationRequest SVGFontFaceElement::insertedInto(ContainerNode& rootParent)
@@ -291,7 +292,7 @@
document().accessSVGExtensions().unregisterSVGFontFaceElement(this);
m_fontFaceRule->mutableProperties().clear();
- document().styleResolverChanged(DeferRecalcStyle);
+ document().authorStyleSheets().didChange(DeferRecalcStyle);
} else
ASSERT(!m_fontElement);
}
Modified: trunk/Source/WebCore/xml/XMLTreeViewer.cpp (206310 => 206311)
--- trunk/Source/WebCore/xml/XMLTreeViewer.cpp 2016-09-23 16:29:43 UTC (rev 206310)
+++ trunk/Source/WebCore/xml/XMLTreeViewer.cpp 2016-09-23 16:35:04 UTC (rev 206311)
@@ -32,6 +32,7 @@
#if ENABLE(XSLT)
+#include "AuthorStyleSheets.h"
#include "Document.h"
#include "Element.h"
#include "ExceptionCodePlaceholder.h"
@@ -63,7 +64,7 @@
String cssString = StringImpl::createWithoutCopying(XMLViewer_css, sizeof(XMLViewer_css));
auto text = m_document.createTextNode(cssString);
m_document.getElementById(String(ASCIILiteral("xml-viewer-style")))->appendChild(text, IGNORE_EXCEPTION);
- m_document.styleResolverChanged(RecalcStyleImmediately);
+ m_document.authorStyleSheets().didChange(RecalcStyleImmediately);
}
} // namespace WebCore
Modified: trunk/Source/WebCore/xml/parser/XMLDocumentParser.cpp (206310 => 206311)
--- trunk/Source/WebCore/xml/parser/XMLDocumentParser.cpp 2016-09-23 16:29:43 UTC (rev 206310)
+++ trunk/Source/WebCore/xml/parser/XMLDocumentParser.cpp 2016-09-23 16:35:04 UTC (rev 206311)
@@ -26,6 +26,7 @@
#include "config.h"
#include "XMLDocumentParser.h"
+#include "AuthorStyleSheets.h"
#include "CDATASection.h"
#include "CachedScript.h"
#include "Comment.h"
@@ -199,7 +200,7 @@
insertErrorMessageBlock();
else {
updateLeafTextNode();
- document()->styleResolverChanged(RecalcStyleImmediately);
+ document()->authorStyleSheets().didChange(RecalcStyleImmediately);
}
if (isParsing())
Modified: trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp (206310 => 206311)
--- trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp 2016-09-23 16:29:43 UTC (rev 206310)
+++ trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp 2016-09-23 16:35:04 UTC (rev 206311)
@@ -28,6 +28,7 @@
#include "config.h"
#include "XMLDocumentParser.h"
+#include "AuthorStyleSheets.h"
#include "CDATASection.h"
#include "CachedScript.h"
#include "Comment.h"
@@ -1386,7 +1387,7 @@
document()->setTransformSource(std::make_unique<TransformSource>(doc));
document()->setParsing(false); // Make the document think it's done, so it will apply XSL stylesheets.
- document()->styleResolverChanged(RecalcStyleImmediately);
+ document()->authorStyleSheets().didChange(RecalcStyleImmediately);
// styleResolverChanged() call can detach the parser and null out its document.
// In that case, we just bail out.
Modified: trunk/Source/WebKit/mac/WebView/WebHTMLView.mm (206310 => 206311)
--- trunk/Source/WebKit/mac/WebView/WebHTMLView.mm 2016-09-23 16:29:43 UTC (rev 206310)
+++ trunk/Source/WebKit/mac/WebView/WebHTMLView.mm 2016-09-23 16:35:04 UTC (rev 206311)
@@ -72,6 +72,7 @@
#import "WebTypesInternal.h"
#import "WebUIDelegatePrivate.h"
#import "WebViewInternal.h"
+#import <WebCore/AuthorStyleSheets.h>
#import <WebCore/CSSStyleDeclaration.h>
#import <WebCore/CachedImage.h>
#import <WebCore/CachedResourceClient.h>
@@ -3611,7 +3612,7 @@
#endif
if (Frame* coreFrame = core([self _frame]))
- coreFrame->document()->styleResolverChanged(RecalcStyleImmediately);
+ coreFrame->document()->authorStyleSheets().didChange(RecalcStyleImmediately);
#ifdef LOG_TIMES
double thisTime = CFAbsoluteTimeGetCurrent() - start;
@@ -5004,7 +5005,7 @@
document->setPaginatedForScreen(_private->paginateScreenContent);
document->setPrinting(_private->printing);
- document->styleResolverChanged(RecalcStyleImmediately);
+ document->authorStyleSheets().didChange(RecalcStyleImmediately);
}
}