Diff
Modified: trunk/Source/WebCore/ChangeLog (206950 => 206951)
--- trunk/Source/WebCore/ChangeLog 2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/ChangeLog 2016-10-08 08:42:03 UTC (rev 206951)
@@ -1,3 +1,79 @@
+2016-10-08 Antti Koivisto <[email protected]>
+
+ Move StyleResolver ownership from Document/ShadowRoot to Style::Scope
+ https://bugs.webkit.org/show_bug.cgi?id=163148
+
+ Reviewed by Andreas Kling.
+
+ Reduce duplication between Document and ShadowRoot.
+
+ * css/CSSComputedStyleDeclaration.cpp:
+ (WebCore::ComputedStyleExtractor::propertyValue):
+ * css/CSSStyleSheet.cpp:
+ (WebCore::CSSStyleSheet::didMutateRules):
+ * css/ElementRuleCollector.cpp:
+ (WebCore::ElementRuleCollector::matchHostPseudoClassRules):
+ (WebCore::ElementRuleCollector::matchSlottedPseudoElementRules):
+ * css/MediaQueryMatcher.cpp:
+ (WebCore::MediaQueryMatcher::documentElementUserAgentStyle):
+ * css/StyleMedia.cpp:
+ (WebCore::StyleMedia::matchMedium):
+ * css/parser/SizesAttributeParser.cpp:
+ (WebCore::SizesAttributeParser::mediaConditionMatches):
+ * dom/Document.cpp:
+ (WebCore::Document::~Document):
+ (WebCore::Document::childrenChanged):
+ (WebCore::Document::isPageBoxVisible):
+ (WebCore::Document::pageSizeAndMarginsInPixels):
+ (WebCore::Document::userAgentShadowTreeStyleResolver):
+ (WebCore::Document::fontsNeedUpdate):
+ (WebCore::Document::didClearStyleResolver):
+ (WebCore::Document::updateViewportUnitsOnResize):
+ (WebCore::Document::createStyleResolver): Deleted.
+ (WebCore::Document::clearStyleResolver): Deleted.
+ * dom/Document.h:
+ (WebCore::Document::styleResolverIfExists): Deleted.
+ (WebCore::Document::ensureStyleResolver): Deleted.
+ * dom/Element.cpp:
+ (WebCore::Element::styleResolver):
+ * dom/ShadowRoot.cpp:
+ (WebCore::ShadowRoot::styleResolver): Deleted.
+ (WebCore::ShadowRoot::styleResolverIfExists): Deleted.
+ (WebCore::ShadowRoot::resetStyleResolver): Deleted.
+ * dom/ShadowRoot.h:
+ * page/DOMWindow.cpp:
+ (WebCore::DOMWindow::getMatchedCSSRules):
+ * page/FrameView.cpp:
+ (WebCore::FrameView::layout):
+ * page/Page.cpp:
+ (WebCore::Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment):
+ * page/PrintContext.cpp:
+ (WebCore::PrintContext::pageProperty):
+ * platform/MemoryPressureHandler.cpp:
+ (WebCore::MemoryPressureHandler::releaseCriticalMemory):
+ * style/AttributeChangeInvalidation.cpp:
+ (WebCore::Style::mayBeAffectedByHostStyle):
+ * style/ClassChangeInvalidation.cpp:
+ (WebCore::Style::mayBeAffectedByHostStyle):
+ * style/IdChangeInvalidation.cpp:
+ (WebCore::Style::mayBeAffectedByHostStyle):
+ * style/StyleScope.cpp:
+ (WebCore::Style::Scope::resolver):
+ (WebCore::Style::Scope::resolverIfExists):
+ (WebCore::Style::Scope::clearResolver):
+ (WebCore::Style::Scope::analyzeStyleSheetChange):
+ (WebCore::Style::Scope::updateActiveStyleSheets):
+ (WebCore::Style::Scope::updateStyleResolver):
+ (WebCore::Style::Scope::styleResolver): Deleted.
+ (WebCore::Style::Scope::styleResolverIfExists): Deleted.
+ * style/StyleScope.h:
+ * style/StyleSharingResolver.cpp:
+ (WebCore::Style::SharingResolver::resolve):
+ (WebCore::Style::SharingResolver::canShareStyleWithElement):
+ * style/StyleTreeResolver.cpp:
+ (WebCore::Style::TreeResolver::Scope::Scope):
+ (WebCore::Style::TreeResolver::resolve):
+
2016-10-07 Chris Dumez <[email protected]>
window.navigator.language incorrectly returns all lowercase string
Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (206950 => 206951)
--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2016-10-08 08:42:03 UTC (rev 206951)
@@ -70,6 +70,7 @@
#include "StylePropertyShorthand.h"
#include "StylePropertyShorthandFunctions.h"
#include "StyleResolver.h"
+#include "StyleScope.h"
#include "WebKitCSSFilterValue.h"
#include "WebKitCSSTransformValue.h"
#include "WebKitFontFamilyNames.h"
@@ -2494,7 +2495,7 @@
// FIXME: Some of these cases could be narrowed down or optimized better.
forceFullLayout = isLayoutDependent(propertyID, style, renderer)
|| styledNode->isInShadowTree()
- || (document.styleResolverIfExists() && document.styleResolverIfExists()->hasViewportDependentMediaQueries() && document.ownerElement());
+ || (document.styleScope().resolverIfExists() && document.styleScope().resolverIfExists()->hasViewportDependentMediaQueries() && document.ownerElement());
if (forceFullLayout) {
document.updateLayoutIgnorePendingStylesheets();
Modified: trunk/Source/WebCore/css/CSSStyleSheet.cpp (206950 => 206951)
--- trunk/Source/WebCore/css/CSSStyleSheet.cpp 2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/css/CSSStyleSheet.cpp 2016-10-08 08:42:03 UTC (rev 206951)
@@ -177,7 +177,7 @@
if (mutationType == RuleInsertion && !contentsWereClonedForMutation && !scope->activeStyleSheetsContains(this)) {
if (insertedKeyframesRule) {
- if (auto* resolver = scope->styleResolverIfExists())
+ if (auto* resolver = scope->resolverIfExists())
resolver->addKeyframeStyle(*insertedKeyframesRule);
return;
}
Modified: trunk/Source/WebCore/css/ElementRuleCollector.cpp (206950 => 206951)
--- trunk/Source/WebCore/css/ElementRuleCollector.cpp 2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/css/ElementRuleCollector.cpp 2016-10-08 08:42:03 UTC (rev 206951)
@@ -45,6 +45,7 @@
#include "SelectorFilter.h"
#include "ShadowRoot.h"
#include "StyleProperties.h"
+#include "StyleScope.h"
#include "StyledElement.h"
#include <wtf/TemporaryChange.h>
@@ -234,7 +235,7 @@
matchRequest.treeContextOrdinal++;
- auto& shadowAuthorStyle = m_element.shadowRoot()->styleResolver().ruleSets().authorStyle();
+ auto& shadowAuthorStyle = m_element.shadowRoot()->styleScope().resolver().ruleSets().authorStyle();
auto& shadowHostRules = shadowAuthorStyle.hostPseudoClassRules();
if (shadowHostRules.isEmpty())
return;
@@ -265,11 +266,11 @@
// In nested case the slot may itself be assigned to a slot. Collect ::slotted rules from all the nested trees.
maybeSlotted = slot;
- if (!hostShadowRoot->styleResolver().ruleSets().isAuthorStyleDefined())
+ if (!hostShadowRoot->styleScope().resolver().ruleSets().isAuthorStyleDefined())
continue;
// 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, hostShadowRoot->styleResolver().ruleSets().authorStyle(), nullptr);
+ ElementRuleCollector collector(*slot, hostShadowRoot->styleScope().resolver().ruleSets().authorStyle(), nullptr);
auto slottedPseudoElementRules = collector.collectSlottedPseudoElementRulesForSlot(matchRequest.includeEmptyRules);
if (!slottedPseudoElementRules)
continue;
Modified: trunk/Source/WebCore/css/MediaQueryMatcher.cpp (206950 => 206951)
--- trunk/Source/WebCore/css/MediaQueryMatcher.cpp 2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/css/MediaQueryMatcher.cpp 2016-10-08 08:42:03 UTC (rev 206951)
@@ -30,6 +30,7 @@
#include "NodeRenderStyle.h"
#include "RenderElement.h"
#include "StyleResolver.h"
+#include "StyleScope.h"
namespace WebCore {
@@ -65,7 +66,7 @@
if (!documentElement)
return nullptr;
- return m_document->ensureStyleResolver().styleForElement(*documentElement, m_document->renderStyle(), MatchOnlyUserAgentRules).renderStyle;
+ return m_document->styleScope().resolver().styleForElement(*documentElement, m_document->renderStyle(), MatchOnlyUserAgentRules).renderStyle;
}
bool MediaQueryMatcher::evaluate(const MediaQuerySet& media)
Modified: trunk/Source/WebCore/css/StyleMedia.cpp (206950 => 206951)
--- trunk/Source/WebCore/css/StyleMedia.cpp 2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/css/StyleMedia.cpp 2016-10-08 08:42:03 UTC (rev 206951)
@@ -34,6 +34,7 @@
#include "NodeRenderStyle.h"
#include "RenderElement.h"
#include "StyleResolver.h"
+#include "StyleScope.h"
namespace WebCore {
@@ -62,7 +63,7 @@
if (!documentElement)
return false;
- auto rootStyle = document->ensureStyleResolver().styleForElement(*documentElement, document->renderStyle(), MatchOnlyUserAgentRules).renderStyle;
+ auto rootStyle = document->styleScope().resolver().styleForElement(*documentElement, document->renderStyle(), MatchOnlyUserAgentRules).renderStyle;
auto media = MediaQuerySet::create();
if (!media->parse(query))
Modified: trunk/Source/WebCore/css/parser/SizesAttributeParser.cpp (206950 => 206951)
--- trunk/Source/WebCore/css/parser/SizesAttributeParser.cpp 2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/css/parser/SizesAttributeParser.cpp 2016-10-08 08:42:03 UTC (rev 206951)
@@ -36,6 +36,7 @@
#include "MediaQueryEvaluator.h"
#include "RenderView.h"
#include "SizesCalcParser.h"
+#include "StyleScope.h"
namespace WebCore {
@@ -110,7 +111,7 @@
if (!renderer)
return false;
auto& style = renderer->style();
- return MediaQueryEvaluator { "screen", m_document, &style }.evaluate(mediaCondition, m_document.styleResolverIfExists());
+ return MediaQueryEvaluator { "screen", m_document, &style }.evaluate(mediaCondition, const_cast<Style::Scope&>(m_document.styleScope()).resolverIfExists());
}
bool SizesAttributeParser::parse(CSSParserTokenRange range)
Modified: trunk/Source/WebCore/dom/Document.cpp (206950 => 206951)
--- trunk/Source/WebCore/dom/Document.cpp 2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/dom/Document.cpp 2016-10-08 08:42:03 UTC (rev 206951)
@@ -631,7 +631,7 @@
extensionStyleSheets().detachFromDocument();
- clearStyleResolver(); // We need to destroy CSSFontSelector before destroying m_cachedResourceLoader.
+ styleScope().clearResolver(); // We need to destroy CSSFontSelector before destroying m_cachedResourceLoader.
m_fontSelector->clearDocument();
m_fontSelector->unregisterForInvalidationCallbacks(*this);
@@ -863,7 +863,7 @@
return;
m_documentElement = newDocumentElement;
// The root style used for media query matching depends on the document element.
- clearStyleResolver();
+ styleScope().clearResolver();
}
#if ENABLE(CUSTOM_ELEMENTS)
@@ -2097,13 +2097,13 @@
bool Document::isPageBoxVisible(int pageIndex)
{
- std::unique_ptr<RenderStyle> pageStyle(ensureStyleResolver().styleForPage(pageIndex));
+ std::unique_ptr<RenderStyle> pageStyle(styleScope().resolver().styleForPage(pageIndex));
return pageStyle->visibility() != HIDDEN; // display property doesn't apply to @page.
}
void Document::pageSizeAndMarginsInPixels(int pageIndex, IntSize& pageSize, int& marginTop, int& marginRight, int& marginBottom, int& marginLeft)
{
- std::unique_ptr<RenderStyle> style = ensureStyleResolver().styleForPage(pageIndex);
+ std::unique_ptr<RenderStyle> style = styleScope().resolver().styleForPage(pageIndex);
int width = pageSize.width();
int height = pageSize.height();
@@ -2139,12 +2139,6 @@
marginLeft = style->marginLeft().isAuto() ? marginLeft : intValueForLength(style->marginLeft(), width);
}
-void Document::createStyleResolver()
-{
- m_styleResolver = std::make_unique<StyleResolver>(*this);
- m_styleResolver->appendAuthorStyleSheets(styleScope().activeStyleSheets());
-}
-
StyleResolver& Document::userAgentShadowTreeStyleResolver()
{
if (!m_userAgentShadowTreeStyleResolver) {
@@ -2151,7 +2145,7 @@
m_userAgentShadowTreeStyleResolver = std::make_unique<StyleResolver>(*this);
// FIXME: Filter out shadow pseudo elements we don't want to expose to authors.
- auto& documentAuthorStyle = ensureStyleResolver().ruleSets().authorStyle();
+ auto& documentAuthorStyle = styleScope().resolver().ruleSets().authorStyle();
if (documentAuthorStyle.hasShadowPseudoElementRules())
m_userAgentShadowTreeStyleResolver->ruleSets().authorStyle().copyShadowPseudoElementRulesFrom(documentAuthorStyle);
}
@@ -2161,16 +2155,15 @@
void Document::fontsNeedUpdate(FontSelector&)
{
- if (m_styleResolver)
- m_styleResolver->invalidateMatchedPropertiesCache();
+ if (auto* resolver = styleScope().resolverIfExists())
+ resolver->invalidateMatchedPropertiesCache();
if (pageCacheState() != NotInPageCache || !renderView())
return;
scheduleForcedStyleRecalc();
}
-void Document::clearStyleResolver()
+void Document::didClearStyleResolver()
{
- m_styleResolver = nullptr;
m_userAgentShadowTreeStyleResolver = nullptr;
m_fontSelector->buildStarted();
@@ -3491,7 +3484,7 @@
if (!hasStyleWithViewportUnits())
return;
- ensureStyleResolver().clearCachedPropertiesAffectedByViewportUnits();
+ styleScope().resolver().clearCachedPropertiesAffectedByViewportUnits();
// FIXME: Ideally, we should save the list of elements that have viewport units and only iterate over those.
for (Element* element = ElementTraversal::firstWithin(rootNode()); element; element = ElementTraversal::nextIncludingPseudo(*element)) {
Modified: trunk/Source/WebCore/dom/Document.h (206950 => 206951)
--- trunk/Source/WebCore/dom/Document.h 2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/dom/Document.h 2016-10-08 08:42:03 UTC (rev 206951)
@@ -487,16 +487,8 @@
bool isSrcdocDocument() const { return m_isSrcdocDocument; }
- StyleResolver* styleResolverIfExists() const { return m_styleResolver.get(); }
-
bool sawElementsInKnownNamespaces() const { return m_sawElementsInKnownNamespaces; }
- StyleResolver& ensureStyleResolver()
- {
- if (!m_styleResolver)
- createStyleResolver();
- return *m_styleResolver;
- }
StyleResolver& userAgentShadowTreeStyleResolver();
CSSFontSelector& fontSelector() { return m_fontSelector; }
@@ -1230,7 +1222,7 @@
void didRemoveAllPendingStylesheet();
void setNeedsNotifyRemoveAllPendingStylesheet() { m_needsNotifyRemoveAllPendingStylesheet = true; }
- void clearStyleResolver();
+ void didClearStyleResolver();
bool inStyleRecalc() const { return m_inStyleRecalc; }
bool inRenderTreeUpdate() const { return m_inRenderTreeUpdate; }
@@ -1352,8 +1344,6 @@
void buildAccessKeyMap(TreeScope* root);
- void createStyleResolver();
-
void loadEventDelayTimerFired();
void pendingTasksTimerFired();
@@ -1397,7 +1387,6 @@
unsigned m_referencingNodeCount;
- std::unique_ptr<StyleResolver> m_styleResolver;
std::unique_ptr<StyleResolver> m_userAgentShadowTreeStyleResolver;
bool m_hasNodesWithPlaceholderStyle;
bool m_needsNotifyRemoveAllPendingStylesheet;
Modified: trunk/Source/WebCore/dom/Element.cpp (206950 => 206951)
--- trunk/Source/WebCore/dom/Element.cpp 2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/dom/Element.cpp 2016-10-08 08:42:03 UTC (rev 206951)
@@ -97,6 +97,7 @@
#include "SlotAssignment.h"
#include "StyleProperties.h"
#include "StyleResolver.h"
+#include "StyleScope.h"
#include "StyleTreeResolver.h"
#include "TextIterator.h"
#include "VoidCallback.h"
@@ -1429,9 +1430,9 @@
StyleResolver& Element::styleResolver()
{
if (auto* shadowRoot = containingShadowRoot())
- return shadowRoot->styleResolver();
+ return shadowRoot->styleScope().resolver();
- return document().ensureStyleResolver();
+ return document().styleScope().resolver();
}
ElementStyle Element::resolveStyle(const RenderStyle* parentStyle)
Modified: trunk/Source/WebCore/dom/ShadowRoot.cpp (206950 => 206951)
--- trunk/Source/WebCore/dom/ShadowRoot.cpp 2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/dom/ShadowRoot.cpp 2016-10-08 08:42:03 UTC (rev 206951)
@@ -41,7 +41,6 @@
struct SameSizeAsShadowRoot : public DocumentFragment, public TreeScope {
unsigned countersAndFlags[1];
- void* styleResolver;
void* styleScope;
void* host;
void* slotAssignment;
@@ -80,33 +79,6 @@
removeDetachedChildren();
}
-StyleResolver& ShadowRoot::styleResolver()
-{
- if (m_type == Mode::UserAgent)
- return document().userAgentShadowTreeStyleResolver();
-
- if (!m_styleResolver) {
- // FIXME: We could share style resolver with shadow roots that have identical style.
- m_styleResolver = std::make_unique<StyleResolver>(document());
- if (m_styleScope)
- m_styleResolver->appendAuthorStyleSheets(m_styleScope->activeStyleSheets());
- }
- return *m_styleResolver;
-}
-
-StyleResolver* ShadowRoot::styleResolverIfExists()
-{
- if (m_type == Mode::UserAgent)
- return &document().userAgentShadowTreeStyleResolver();
-
- return m_styleResolver.get();
-}
-
-void ShadowRoot::resetStyleResolver()
-{
- m_styleResolver = nullptr;
-}
-
Style::Scope& ShadowRoot::styleScope()
{
if (!m_styleScope)
@@ -114,14 +86,6 @@
return *m_styleScope;
}
-void ShadowRoot::updateStyle()
-{
- if (!m_styleScope)
- return;
- // FIXME: Make optimized updated work.
- m_styleScope->didChangeContentsOrInterpretation();
-}
-
String ShadowRoot::innerHTML() const
{
return createMarkup(*this, ChildrenOnly);
Modified: trunk/Source/WebCore/dom/ShadowRoot.h (206950 => 206951)
--- trunk/Source/WebCore/dom/ShadowRoot.h 2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/dom/ShadowRoot.h 2016-10-08 08:42:03 UTC (rev 206951)
@@ -61,13 +61,8 @@
using TreeScope::rootNode;
- StyleResolver& styleResolver();
- StyleResolver* styleResolverIfExists();
Style::Scope& styleScope();
- void updateStyle();
- void resetStyleResolver();
-
bool resetStyleInheritance() const { return m_resetStyleInheritance; }
void setResetStyleInheritance(bool);
@@ -114,7 +109,6 @@
Element* m_host { nullptr };
- std::unique_ptr<StyleResolver> m_styleResolver;
std::unique_ptr<Style::Scope> m_styleScope;
std::unique_ptr<SlotAssignment> m_slotAssignment;
Modified: trunk/Source/WebCore/page/DOMWindow.cpp (206950 => 206951)
--- trunk/Source/WebCore/page/DOMWindow.cpp 2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/page/DOMWindow.cpp 2016-10-08 08:42:03 UTC (rev 206951)
@@ -1442,7 +1442,7 @@
PseudoId pseudoId = CSSSelector::pseudoId(pseudoType);
- auto matchedRules = m_frame->document()->ensureStyleResolver().pseudoStyleRulesForElement(element, pseudoId, rulesToInclude);
+ auto matchedRules = m_frame->document()->styleScope().resolver().pseudoStyleRulesForElement(element, pseudoId, rulesToInclude);
if (matchedRules.isEmpty())
return nullptr;
Modified: trunk/Source/WebCore/page/FrameView.cpp (206950 => 206951)
--- trunk/Source/WebCore/page/FrameView.cpp 2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/page/FrameView.cpp 2016-10-08 08:42:03 UTC (rev 206951)
@@ -1332,7 +1332,7 @@
m_layoutPhase = InPreLayoutStyleUpdate;
// Viewport-dependent media queries may cause us to need completely different style information.
- StyleResolver* styleResolver = document.styleResolverIfExists();
+ auto* styleResolver = document.styleScope().resolverIfExists();
if (!styleResolver || styleResolver->hasMediaQueriesAffectedByViewportChange()) {
LOG(Layout, " hasMediaQueriesAffectedByViewportChange, enqueueing style recalc");
document.styleScope().didChangeContentsOrInterpretation();
Modified: trunk/Source/WebCore/page/Page.cpp (206950 => 206951)
--- trunk/Source/WebCore/page/Page.cpp 2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/page/Page.cpp 2016-10-08 08:42:03 UTC (rev 206951)
@@ -491,7 +491,7 @@
// the properties cache.
if (!frame->document())
continue;
- if (StyleResolver* styleResolver = frame->document()->styleResolverIfExists())
+ if (StyleResolver* styleResolver = frame->document()->styleScope().resolverIfExists())
styleResolver->invalidateMatchedPropertiesCache();
frame->document()->scheduleForcedStyleRecalc();
}
Modified: trunk/Source/WebCore/page/PrintContext.cpp (206950 => 206951)
--- trunk/Source/WebCore/page/PrintContext.cpp 2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/page/PrintContext.cpp 2016-10-08 08:42:03 UTC (rev 206951)
@@ -27,6 +27,7 @@
#include "RenderView.h"
#include "StyleInheritedData.h"
#include "StyleResolver.h"
+#include "StyleScope.h"
#include <wtf/text/WTFString.h>
namespace WebCore {
@@ -251,7 +252,7 @@
PrintContext printContext(frame);
printContext.begin(800); // Any width is OK here.
document->updateLayout();
- std::unique_ptr<RenderStyle> style = document->ensureStyleResolver().styleForPage(pageNumber);
+ std::unique_ptr<RenderStyle> style = document->styleScope().resolver().styleForPage(pageNumber);
// Implement formatters for properties we care about.
if (!strcmp(propertyName, "margin-left")) {
Modified: trunk/Source/WebCore/platform/MemoryPressureHandler.cpp (206950 => 206951)
--- trunk/Source/WebCore/platform/MemoryPressureHandler.cpp 2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/platform/MemoryPressureHandler.cpp 2016-10-08 08:42:03 UTC (rev 206951)
@@ -39,6 +39,7 @@
#include "Page.h"
#include "PageCache.h"
#include "ScrollingThread.h"
+#include "StyleScope.h"
#include "StyledElement.h"
#include "WorkerThread.h"
#include <_javascript_Core/IncrementalSweeper.h>
@@ -128,7 +129,7 @@
Vector<RefPtr<Document>> documents;
copyToVector(Document::allDocuments(), documents);
for (auto& document : documents)
- document->clearStyleResolver();
+ document->styleScope().clearResolver();
}
{
Modified: trunk/Source/WebCore/style/AttributeChangeInvalidation.cpp (206950 => 206951)
--- trunk/Source/WebCore/style/AttributeChangeInvalidation.cpp 2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/style/AttributeChangeInvalidation.cpp 2016-10-08 08:42:03 UTC (rev 206951)
@@ -31,6 +31,7 @@
#include "ShadowRoot.h"
#include "StyleInvalidationAnalysis.h"
#include "StyleResolver.h"
+#include "StyleScope.h"
namespace WebCore {
namespace Style {
@@ -37,7 +38,7 @@
static bool mayBeAffectedByHostStyle(ShadowRoot& shadowRoot, bool isHTML, const QualifiedName& attributeName)
{
- auto& shadowRuleSets = shadowRoot.styleResolver().ruleSets();
+ auto& shadowRuleSets = shadowRoot.styleScope().resolver().ruleSets();
if (shadowRuleSets.authorStyle().hostPseudoClassRules().isEmpty())
return false;
Modified: trunk/Source/WebCore/style/ClassChangeInvalidation.cpp (206950 => 206951)
--- trunk/Source/WebCore/style/ClassChangeInvalidation.cpp 2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/style/ClassChangeInvalidation.cpp 2016-10-08 08:42:03 UTC (rev 206951)
@@ -32,6 +32,7 @@
#include "SpaceSplitString.h"
#include "StyleInvalidationAnalysis.h"
#include "StyleResolver.h"
+#include "StyleScope.h"
#include <wtf/BitVector.h>
namespace WebCore {
@@ -87,7 +88,7 @@
static bool mayBeAffectedByHostStyle(ShadowRoot& shadowRoot, AtomicStringImpl* changedClass)
{
- auto& shadowRuleSets = shadowRoot.styleResolver().ruleSets();
+ auto& shadowRuleSets = shadowRoot.styleScope().resolver().ruleSets();
if (shadowRuleSets.authorStyle().hostPseudoClassRules().isEmpty())
return false;
return shadowRuleSets.features().classesInRules.contains(changedClass);
Modified: trunk/Source/WebCore/style/IdChangeInvalidation.cpp (206950 => 206951)
--- trunk/Source/WebCore/style/IdChangeInvalidation.cpp 2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/style/IdChangeInvalidation.cpp 2016-10-08 08:42:03 UTC (rev 206951)
@@ -30,6 +30,7 @@
#include "ElementChildIterator.h"
#include "ShadowRoot.h"
#include "StyleResolver.h"
+#include "StyleScope.h"
namespace WebCore {
namespace Style {
@@ -36,7 +37,7 @@
static bool mayBeAffectedByHostStyle(ShadowRoot& shadowRoot, const AtomicString& changedId)
{
- auto& shadowRuleSets = shadowRoot.styleResolver().ruleSets();
+ auto& shadowRuleSets = shadowRoot.styleScope().resolver().ruleSets();
if (shadowRuleSets.authorStyle().hostPseudoClassRules().isEmpty())
return false;
Modified: trunk/Source/WebCore/style/StyleScope.cpp (206950 => 206951)
--- trunk/Source/WebCore/style/StyleScope.cpp 2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/style/StyleScope.cpp 2016-10-08 08:42:03 UTC (rev 206951)
@@ -71,22 +71,34 @@
{
}
-StyleResolver& Scope::styleResolver()
+StyleResolver& Scope::resolver()
{
- if (m_shadowRoot)
- return m_shadowRoot->styleResolver();
+ if (m_shadowRoot && m_shadowRoot->mode() == ShadowRoot::Mode::UserAgent)
+ return m_document.userAgentShadowTreeStyleResolver();
- return m_document.ensureStyleResolver();
+ if (!m_resolver) {
+ m_resolver = std::make_unique<StyleResolver>(m_document);
+ m_resolver->appendAuthorStyleSheets(m_activeStyleSheets);
+ }
+ return *m_resolver;
}
-StyleResolver* Scope::styleResolverIfExists()
+StyleResolver* Scope::resolverIfExists()
{
- if (m_shadowRoot)
- return m_shadowRoot->styleResolverIfExists();
+ if (m_shadowRoot && m_shadowRoot->mode() == ShadowRoot::Mode::UserAgent)
+ return &m_document.userAgentShadowTreeStyleResolver();
- return m_document.styleResolverIfExists();
+ return m_resolver.get();
}
+void Scope::clearResolver()
+{
+ m_resolver = nullptr;
+
+ if (!m_shadowRoot)
+ m_document.didClearStyleResolver();
+}
+
Scope& Scope::forNode(Node& node)
{
ASSERT(node.inDocument());
@@ -118,7 +130,8 @@
}
if (m_shadowRoot) {
- m_shadowRoot->updateStyle();
+ // FIXME: Make optimized updates work.
+ didChangeContentsOrInterpretation();
return;
}
@@ -248,10 +261,10 @@
unsigned newStylesheetCount = newStylesheets.size();
- if (!styleResolverIfExists())
+ if (!resolverIfExists())
return Reconstruct;
- StyleResolver& styleResolver = *styleResolverIfExists();
+ auto& styleResolver = *resolverIfExists();
// Find out which stylesheets are new.
unsigned oldStylesheetCount = m_activeStyleSheets.size();
@@ -323,7 +336,7 @@
}
if (!m_document.hasLivingRenderTree()) {
- m_document.clearStyleResolver();
+ clearResolver();
return;
}
@@ -330,7 +343,7 @@
// 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_shadowRoot && !m_didUpdateActiveStyleSheets && m_pendingStyleSheetCount) {
- m_document.clearStyleResolver();
+ clearResolver();
return;
}
@@ -378,13 +391,10 @@
void Scope::updateStyleResolver(Vector<RefPtr<CSSStyleSheet>>& activeStyleSheets, StyleResolverUpdateType updateType)
{
if (updateType == Reconstruct) {
- if (m_shadowRoot)
- m_shadowRoot->resetStyleResolver();
- else
- m_document.clearStyleResolver();
+ clearResolver();
return;
}
- auto& styleResolver = this->styleResolver();
+ auto& styleResolver = resolver();
if (updateType == Reset) {
styleResolver.ruleSets().resetAuthorStyle();
Modified: trunk/Source/WebCore/style/StyleScope.h (206950 => 206951)
--- trunk/Source/WebCore/style/StyleScope.h 2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/style/StyleScope.h 2016-10-08 08:42:03 UTC (rev 206951)
@@ -89,8 +89,9 @@
bool hasPendingUpdate() const { return !!m_pendingUpdateType; }
void flushPendingUpdate();
- StyleResolver& styleResolver();
- StyleResolver* styleResolverIfExists();
+ StyleResolver& resolver();
+ StyleResolver* resolverIfExists();
+ void clearResolver();
static Scope& forNode(Node&);
@@ -114,6 +115,8 @@
Document& m_document;
ShadowRoot* m_shadowRoot { nullptr };
+ std::unique_ptr<StyleResolver> m_resolver;
+
Vector<RefPtr<StyleSheet>> m_styleSheetsForStyleSheetList;
Vector<RefPtr<CSSStyleSheet>> m_activeStyleSheets;
Modified: trunk/Source/WebCore/style/StyleSharingResolver.cpp (206950 => 206951)
--- trunk/Source/WebCore/style/StyleSharingResolver.cpp 2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/style/StyleSharingResolver.cpp 2016-10-08 08:42:03 UTC (rev 206951)
@@ -34,6 +34,7 @@
#include "RenderStyle.h"
#include "SVGElement.h"
#include "ShadowRoot.h"
+#include "StyleScope.h"
#include "StyleUpdate.h"
#include "StyledElement.h"
#include "VisitedLinkState.h"
@@ -97,7 +98,7 @@
return nullptr;
if (elementHasDirectionAuto(element))
return nullptr;
- if (element.shadowRoot() && !element.shadowRoot()->styleResolver().ruleSets().authorStyle().hostPseudoClassRules().isEmpty())
+ if (element.shadowRoot() && !element.shadowRoot()->styleScope().resolver().ruleSets().authorStyle().hostPseudoClassRules().isEmpty())
return nullptr;
Context context {
@@ -287,7 +288,7 @@
if (candidateElement.matchesDefaultPseudoClass() != element.matchesDefaultPseudoClass())
return false;
- if (element.shadowRoot() && !element.shadowRoot()->styleResolver().ruleSets().authorStyle().hostPseudoClassRules().isEmpty())
+ if (element.shadowRoot() && !element.shadowRoot()->styleScope().resolver().ruleSets().authorStyle().hostPseudoClassRules().isEmpty())
return false;
#if ENABLE(FULLSCREEN_API)
Modified: trunk/Source/WebCore/style/StyleTreeResolver.cpp (206950 => 206951)
--- trunk/Source/WebCore/style/StyleTreeResolver.cpp 2016-10-08 08:31:00 UTC (rev 206950)
+++ trunk/Source/WebCore/style/StyleTreeResolver.cpp 2016-10-08 08:42:03 UTC (rev 206951)
@@ -83,13 +83,13 @@
}
TreeResolver::Scope::Scope(Document& document)
- : styleResolver(document.ensureStyleResolver())
+ : styleResolver(document.styleScope().resolver())
, sharingResolver(document, styleResolver.ruleSets(), selectorFilter)
{
}
TreeResolver::Scope::Scope(ShadowRoot& shadowRoot, Scope& enclosingScope)
- : styleResolver(shadowRoot.styleResolver())
+ : styleResolver(shadowRoot.styleScope().resolver())
, sharingResolver(shadowRoot.documentScope(), styleResolver.ruleSets(), selectorFilter)
, shadowRoot(&shadowRoot)
, enclosingScope(&enclosingScope)
@@ -440,7 +440,7 @@
Element* documentElement = m_document.documentElement();
if (!documentElement) {
- m_document.ensureStyleResolver();
+ m_document.styleScope().resolver();
return nullptr;
}
if (change != Force && !documentElement->childNeedsStyleRecalc() && !documentElement->needsStyleRecalc())