| Index: third_party/WebKit/Source/core/dom/StyleEngine.h
|
| diff --git a/third_party/WebKit/Source/core/dom/StyleEngine.h b/third_party/WebKit/Source/core/dom/StyleEngine.h
|
| index 24dfe5766b3abc3ed3cdee45b2b42a532e610fbf..441b17aa3f95cf5bd5bcd96bc0951f93f76b5f33 100644
|
| --- a/third_party/WebKit/Source/core/dom/StyleEngine.h
|
| +++ b/third_party/WebKit/Source/core/dom/StyleEngine.h
|
| @@ -30,6 +30,7 @@
|
|
|
| #include "core/CoreExport.h"
|
| #include "core/css/CSSFontSelectorClient.h"
|
| +#include "core/css/CSSGlobalRuleSet.h"
|
| #include "core/css/invalidation/StyleInvalidator.h"
|
| #include "core/css/resolver/StyleResolver.h"
|
| #include "core/css/resolver/StyleResolverStats.h"
|
| @@ -48,12 +49,14 @@ namespace blink {
|
|
|
| class CSSFontSelector;
|
| class CSSStyleSheet;
|
| +class MediaQueryEvaluator;
|
| class Node;
|
| class RuleFeatureSet;
|
| class ShadowTreeStyleSheetCollection;
|
| class StyleRuleFontFace;
|
| class StyleSheet;
|
| class StyleSheetContents;
|
| +class ViewportStyleResolver;
|
|
|
| class CORE_EXPORT StyleEngine final : public GarbageCollectedFinalized<StyleEngine>, public CSSFontSelectorClient {
|
| USING_GARBAGE_COLLECTED_MIXIN(StyleEngine);
|
| @@ -75,23 +78,24 @@ public:
|
| ~StyleEngine();
|
|
|
| const HeapVector<Member<StyleSheet>>& styleSheetsForStyleSheetList(TreeScope&);
|
| -
|
| const HeapVector<Member<CSSStyleSheet>>& injectedAuthorStyleSheets() const { return m_injectedAuthorStyleSheets; }
|
| + const ActiveStyleSheetVector activeStyleSheetsForInspector();
|
|
|
| - const HeapVector<Member<CSSStyleSheet>> activeStyleSheetsForInspector() const;
|
| + void setNeedsActiveStyleUpdate(TreeScope&);
|
| + void setNeedsGlobalRuleSetUpdate() { m_needsGlobalRuleSetUpdate = true; }
|
| + bool needsActiveStyleUpdate() const { return needsActiveStyleSheetUpdate() || m_needsGlobalRuleSetUpdate; }
|
| + void updateActiveStyle();
|
|
|
| - void setNeedsActiveStyleUpdate(StyleSheet*, StyleResolverUpdateMode);
|
| void addStyleSheetCandidateNode(Node*);
|
| void removeStyleSheetCandidateNode(Node*);
|
| void removeStyleSheetCandidateNode(Node*, TreeScope&);
|
| void modifiedStyleSheetCandidateNode(Node*);
|
| - void watchedSelectorsChanged();
|
|
|
| + void watchedSelectorsChanged();
|
| void injectAuthorSheet(StyleSheetContents* authorSheet);
|
|
|
| - void clearMediaQueryRuleSetStyleSheets();
|
| + void mediaQueryAffectingValueChanged();
|
| void updateStyleSheetsInImport(DocumentStyleSheetCollector& parentCollector);
|
| - void updateActiveStyleSheets(StyleResolverUpdateMode);
|
|
|
| String preferredStylesheetSetName() const { return m_preferredStylesheetSetName; }
|
| String selectedStylesheetSetName() const { return m_selectedStylesheetSetName; }
|
| @@ -102,25 +106,29 @@ public:
|
| void addPendingSheet(StyleEngineContext&);
|
| void removePendingSheet(Node* styleSheetCandidateNode, const StyleEngineContext&);
|
|
|
| - bool hasPendingScriptBlockingSheets() const { return m_pendingScriptBlockingStylesheets > 0; }
|
| - bool hasPendingRenderBlockingSheets() const { return m_pendingRenderBlockingStylesheets > 0; }
|
| + bool hasPendingScriptBlockingSheets() const { return m_pendingScriptBlockingStylesheets; }
|
| + bool hasPendingRenderBlockingSheets() const { return m_pendingRenderBlockingStylesheets; }
|
| bool haveScriptBlockingStylesheetsLoaded() const { return !hasPendingScriptBlockingSheets() || m_ignorePendingStylesheets; }
|
| bool haveRenderBlockingStylesheetsLoaded() const { return !hasPendingRenderBlockingSheets() || m_ignorePendingStylesheets; }
|
| bool ignoringPendingStylesheets() const { return m_ignorePendingStylesheets; }
|
|
|
| - unsigned maxDirectAdjacentSelectors() const { return m_maxDirectAdjacentSelectors; }
|
| - bool usesSiblingRules() const { return m_usesSiblingRules; }
|
| - bool usesFirstLineRules() const { return m_usesFirstLineRules; }
|
| - bool usesWindowInactiveSelector() const { return m_usesWindowInactiveSelector; }
|
| -
|
| bool usesRemUnits() const { return m_usesRemUnits; }
|
| void setUsesRemUnit(bool b) { m_usesRemUnits = b; }
|
|
|
| - void resetCSSFeatureFlags(const RuleFeatureSet&);
|
| + unsigned maxDirectAdjacentSelectors() const { return m_globalRuleSet.m_features.maxDirectAdjacentSelectors(); }
|
| + bool usesSiblingRules() const { return m_globalRuleSet.m_features.usesSiblingRules(); }
|
| + bool usesFirstLineRules() const { return m_globalRuleSet.m_features.usesFirstLineRules(); }
|
| + bool usesWindowInactiveSelector() const { return m_globalRuleSet.m_features.usesWindowInactiveSelector(); }
|
| + RuleSet* watchedSelectorsRuleSet() { return m_globalRuleSet.m_watchedSelectorsRuleSet; }
|
|
|
| void didRemoveShadowRoot(ShadowRoot*);
|
| void shadowRootRemovedFromDocument(ShadowRoot*);
|
| - void appendActiveAuthorStyleSheets();
|
| + void markAllTreeScopesDirty() { m_allTreeScopesDirty = true; }
|
| + void addTreeBoundaryCrossingScope(ContainerNode& scope);
|
| +
|
| + void collectScopedStyleFeaturesTo(RuleFeatureSet&) const;
|
| +
|
| + RuleSet& ensureRuleSetForSheet(CSSStyleSheet&);
|
|
|
| StyleResolver* resolver() const
|
| {
|
| @@ -129,45 +137,54 @@ public:
|
|
|
| StyleResolver& ensureResolver()
|
| {
|
| - if (!m_resolver) {
|
| + updateActiveStyle();
|
| + if (!m_resolver)
|
| createResolver();
|
| - } else if (m_resolver->hasPendingAuthorStyleSheets()) {
|
| - m_resolver->appendPendingAuthorStyleSheets();
|
| - }
|
| return *m_resolver.get();
|
| }
|
|
|
| bool hasResolver() const { return m_resolver.get(); }
|
| void clearResolver();
|
| - void clearMasterResolver();
|
|
|
| StyleInvalidator& styleInvalidator() { return m_styleInvalidator; }
|
| + MediaQueryEvaluator& ensureMediaQueryEvaluator();
|
| + bool mediaQueryAffectedByViewportChange();
|
| + bool mediaQueryAffectedByDeviceChange();
|
| + bool hasViewportDependentMediaQueries() const { return !m_globalRuleSet.m_features.viewportDependentMediaQueryResults.isEmpty(); }
|
|
|
| CSSFontSelector* fontSelector() { return m_fontSelector.get(); }
|
| void setFontSelector(CSSFontSelector*);
|
|
|
| void removeFontFaceRules(const HeapVector<Member<const StyleRuleFontFace>>&);
|
| + void removeFontFaceRules(const HeapVector<Member<StyleRuleFontFace>>&);
|
| void clearFontCache();
|
| // updateGenericFontFamilySettings is used from WebSettingsImpl.
|
| void updateGenericFontFamilySettings();
|
|
|
| + ViewportStyleResolver& ensureViewportStyleResolver();
|
| +
|
| void didDetach();
|
| bool shouldClearResolver() const;
|
| - void resolverChanged(StyleResolverUpdateMode);
|
|
|
| CSSStyleSheet* createSheet(Element*, const String& text, TextPosition startPosition, StyleEngineContext&);
|
| void removeSheet(StyleSheetContents*);
|
|
|
| - void collectScopedStyleFeaturesTo(RuleFeatureSet&) const;
|
| - void ensureFullscreenUAStyle();
|
| -
|
| void platformColorsChanged();
|
|
|
| + bool hasRulesForId(const AtomicString& id) const;
|
| void classChangedForElement(const SpaceSplitString& changedClasses, Element&);
|
| void classChangedForElement(const SpaceSplitString& oldClasses, const SpaceSplitString& newClasses, Element&);
|
| void attributeChangedForElement(const QualifiedName& attributeName, Element&);
|
| void idChangedForElement(const AtomicString& oldId, const AtomicString& newId, Element&);
|
| void pseudoStateChangedForElement(CSSSelector::PseudoType, Element&);
|
| + void scheduleInvalidationsForRuleSets(TreeScope&, const HeapVector<Member<RuleSet>>&);
|
| +
|
| + void ensureUAStyleForFullscreen();
|
| + void ensureUAStyleForElement(const Element&);
|
| +
|
| + PassRefPtr<ComputedStyle> findSharedStyle(const ElementResolveContext&);
|
| +
|
| + const DocumentOrderedList& treeBoundaryCrossingScopes() const { return m_treeBoundaryCrossingScopes; }
|
|
|
| unsigned styleForElementCount() const { return m_styleForElementCount; }
|
| void incStyleForElementCount() { m_styleForElementCount++; }
|
| @@ -186,10 +203,16 @@ private:
|
| private:
|
| StyleEngine(Document&);
|
|
|
| + void updateViewport();
|
| + void updateActiveStyleSheets();
|
| + void updateGlobalRuleSet();
|
| +
|
| + bool needsActiveStyleSheetUpdate() const { return m_allTreeScopesDirty || m_documentScopeDirty || m_dirtyTreeScopes.size(); }
|
| +
|
| TreeScopeStyleSheetCollection* ensureStyleSheetCollectionFor(TreeScope&);
|
| TreeScopeStyleSheetCollection* styleSheetCollectionFor(TreeScope&);
|
| - bool shouldUpdateDocumentStyleSheetCollection(StyleResolverUpdateMode) const;
|
| - bool shouldUpdateShadowTreeStyleSheetCollection(StyleResolverUpdateMode) const;
|
| + bool shouldUpdateDocumentStyleSheetCollection() const;
|
| + bool shouldUpdateShadowTreeStyleSheetCollection() const;
|
|
|
| void markDocumentDirty();
|
| void markTreeScopeDirty(TreeScope&);
|
| @@ -200,11 +223,12 @@ private:
|
|
|
| typedef HeapHashSet<Member<TreeScope>> UnorderedTreeScopeSet;
|
|
|
| - void clearMediaQueryRuleSetOnTreeScopeStyleSheets(UnorderedTreeScopeSet&);
|
| + void mediaQueryAffectingValueChanged(UnorderedTreeScopeSet&);
|
| + const RuleFeatureSet& ruleFeatureSet() const { return m_globalRuleSet.m_features; }
|
|
|
| void createResolver();
|
|
|
| - static CSSStyleSheet* parseSheet(Element*, const String& text, TextPosition startPosition);
|
| + CSSStyleSheet* parseSheet(Element*, const String& text, TextPosition startPosition);
|
|
|
| const DocumentStyleSheetCollection* documentStyleSheetCollection() const
|
| {
|
| @@ -216,9 +240,10 @@ private:
|
| return m_documentStyleSheetCollection.get();
|
| }
|
|
|
| - void updateActiveStyleSheetsInShadow(StyleResolverUpdateMode, TreeScope*, UnorderedTreeScopeSet& treeScopesRemoved);
|
| + void updateActiveStyleSheetsInShadow(TreeScope*, UnorderedTreeScopeSet& treeScopesRemoved);
|
|
|
| bool shouldSkipInvalidationFor(const Element&) const;
|
| + void scheduleRuleSetInvalidationsForElement(Element&, const HeapVector<Member<RuleSet>>&);
|
|
|
| Member<Document> m_document;
|
| bool m_isMaster;
|
| @@ -227,33 +252,35 @@ private:
|
| // Sheets loaded using the @import directive are not included in this count.
|
| // 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_pendingScriptBlockingStylesheets = 0;
|
| - int m_pendingRenderBlockingStylesheets = 0;
|
| + unsigned m_pendingScriptBlockingStylesheets = 0;
|
| + unsigned m_pendingRenderBlockingStylesheets = 0;
|
|
|
| HeapVector<Member<CSSStyleSheet>> m_injectedAuthorStyleSheets;
|
| -
|
| Member<DocumentStyleSheetCollection> m_documentStyleSheetCollection;
|
|
|
| - typedef HeapHashMap<WeakMember<TreeScope>, Member<ShadowTreeStyleSheetCollection>> StyleSheetCollectionMap;
|
| + using StyleSheetCollectionMap = HeapHashMap<WeakMember<TreeScope>, Member<ShadowTreeStyleSheetCollection>>;
|
| +
|
| StyleSheetCollectionMap m_styleSheetCollectionMap;
|
|
|
| bool m_documentScopeDirty = true;
|
| + bool m_allTreeScopesDirty = false;
|
| UnorderedTreeScopeSet m_dirtyTreeScopes;
|
| UnorderedTreeScopeSet m_activeTreeScopes;
|
| + DocumentOrderedList m_treeBoundaryCrossingScopes;
|
|
|
| String m_preferredStylesheetSetName;
|
| String m_selectedStylesheetSetName;
|
|
|
| - bool m_usesSiblingRules = false;
|
| - bool m_usesFirstLineRules = false;
|
| - bool m_usesWindowInactiveSelector = false;
|
| - bool m_usesRemUnits = false;
|
| - unsigned m_maxDirectAdjacentSelectors = 0;
|
| + CSSGlobalRuleSet m_globalRuleSet;
|
|
|
| + bool m_needsGlobalRuleSetUpdate = true;
|
| + bool m_usesRemUnits = false;
|
| bool m_ignorePendingStylesheets = false;
|
| bool m_didCalculateResolver = false;
|
|
|
| Member<StyleResolver> m_resolver;
|
| + Member<ViewportStyleResolver> m_viewportResolver;
|
| + Member<MediaQueryEvaluator> m_medium;
|
| StyleInvalidator m_styleInvalidator;
|
|
|
| Member<CSSFontSelector> m_fontSelector;
|
|
|