| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2012 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 #include "core/css/StyleSheetContents.h" | 30 #include "core/css/StyleSheetContents.h" |
| 31 #include "core/dom/ContainerNode.h" | 31 #include "core/dom/ContainerNode.h" |
| 32 #include "core/dom/Document.h" | 32 #include "core/dom/Document.h" |
| 33 #include "core/dom/ElementTraversal.h" | 33 #include "core/dom/ElementTraversal.h" |
| 34 #include "core/dom/TreeScope.h" | 34 #include "core/dom/TreeScope.h" |
| 35 #include "core/dom/shadow/ShadowRoot.h" | 35 #include "core/dom/shadow/ShadowRoot.h" |
| 36 #include "core/html/HTMLStyleElement.h" | 36 #include "core/html/HTMLStyleElement.h" |
| 37 | 37 |
| 38 namespace blink { | 38 namespace blink { |
| 39 | 39 |
| 40 StyleSheetInvalidationAnalysis::StyleSheetInvalidationAnalysis(const TreeScope&
treeScope, const WillBeHeapVector<RawPtrWillBeMember<StyleSheetContents>>& sheet
s) | 40 StyleSheetInvalidationAnalysis::StyleSheetInvalidationAnalysis(const TreeScope&
treeScope, const HeapVector<Member<StyleSheetContents>>& sheets) |
| 41 : m_treeScope(&treeScope) | 41 : m_treeScope(&treeScope) |
| 42 { | 42 { |
| 43 for (unsigned i = 0; i < sheets.size() && !m_dirtiesAllStyle; ++i) | 43 for (unsigned i = 0; i < sheets.size() && !m_dirtiesAllStyle; ++i) |
| 44 analyzeStyleSheet(sheets[i]); | 44 analyzeStyleSheet(sheets[i]); |
| 45 } | 45 } |
| 46 | 46 |
| 47 static bool determineSelectorScopes(const CSSSelectorList& selectorList, HashSet
<StringImpl*>& idScopes, HashSet<StringImpl*>& classScopes) | 47 static bool determineSelectorScopes(const CSSSelectorList& selectorList, HashSet
<StringImpl*>& idScopes, HashSet<StringImpl*>& classScopes) |
| 48 { | 48 { |
| 49 for (const CSSSelector* selector = selectorList.first(); selector; selector
= CSSSelectorList::next(*selector)) { | 49 for (const CSSSelector* selector = selectorList.first(); selector; selector
= CSSSelectorList::next(*selector)) { |
| 50 const CSSSelector* scopeSelector = 0; | 50 const CSSSelector* scopeSelector = 0; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 void StyleSheetInvalidationAnalysis::analyzeStyleSheet(StyleSheetContents* style
SheetContents) | 104 void StyleSheetInvalidationAnalysis::analyzeStyleSheet(StyleSheetContents* style
SheetContents) |
| 105 { | 105 { |
| 106 // Updating the style on the shadow DOM for image fallback content can bring
us here when imports | 106 // Updating the style on the shadow DOM for image fallback content can bring
us here when imports |
| 107 // are still getting loaded in the main document. Just need to exit early as
we will return here | 107 // are still getting loaded in the main document. Just need to exit early as
we will return here |
| 108 // when the imports finish loading. | 108 // when the imports finish loading. |
| 109 if (styleSheetContents->isLoading()) | 109 if (styleSheetContents->isLoading()) |
| 110 return; | 110 return; |
| 111 | 111 |
| 112 // See if all rules on the sheet are scoped to some specific ids or classes. | 112 // See if all rules on the sheet are scoped to some specific ids or classes. |
| 113 // Then test if we actually have any of those in the tree at the moment. | 113 // Then test if we actually have any of those in the tree at the moment. |
| 114 const WillBeHeapVector<RefPtrWillBeMember<StyleRuleImport>>& importRules = s
tyleSheetContents->importRules(); | 114 const HeapVector<Member<StyleRuleImport>>& importRules = styleSheetContents-
>importRules(); |
| 115 for (unsigned i = 0; i < importRules.size(); ++i) { | 115 for (unsigned i = 0; i < importRules.size(); ++i) { |
| 116 if (!importRules[i]->styleSheet()) | 116 if (!importRules[i]->styleSheet()) |
| 117 continue; | 117 continue; |
| 118 analyzeStyleSheet(importRules[i]->styleSheet()); | 118 analyzeStyleSheet(importRules[i]->styleSheet()); |
| 119 if (m_dirtiesAllStyle) | 119 if (m_dirtiesAllStyle) |
| 120 return; | 120 return; |
| 121 } | 121 } |
| 122 | 122 |
| 123 if (m_treeScope->rootNode().isShadowRoot()) | 123 if (m_treeScope->rootNode().isShadowRoot()) |
| 124 return; | 124 return; |
| 125 | 125 |
| 126 const WillBeHeapVector<RefPtrWillBeMember<StyleRuleBase>>& rules = styleShee
tContents->childRules(); | 126 const HeapVector<Member<StyleRuleBase>>& rules = styleSheetContents->childRu
les(); |
| 127 for (unsigned i = 0; i < rules.size(); i++) { | 127 for (unsigned i = 0; i < rules.size(); i++) { |
| 128 StyleRuleBase* rule = rules[i].get(); | 128 StyleRuleBase* rule = rules[i].get(); |
| 129 if (!rule->isStyleRule()) { | 129 if (!rule->isStyleRule()) { |
| 130 if (ruleAdditionMightRequireDocumentStyleRecalc(rule)) { | 130 if (ruleAdditionMightRequireDocumentStyleRecalc(rule)) { |
| 131 m_dirtiesAllStyle = true; | 131 m_dirtiesAllStyle = true; |
| 132 return; | 132 return; |
| 133 } | 133 } |
| 134 continue; | 134 continue; |
| 135 } | 135 } |
| 136 StyleRule* styleRule = toStyleRule(rule); | 136 StyleRule* styleRule = toStyleRule(rule); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 element->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonFo
rTracing::create(StyleChangeReason::StyleSheetChange)); | 173 element->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonFo
rTracing::create(StyleChangeReason::StyleSheetChange)); |
| 174 // The whole subtree is now invalidated, we can skip to the next sib
ling. | 174 // The whole subtree is now invalidated, we can skip to the next sib
ling. |
| 175 element = ElementTraversal::nextSkippingChildren(*element); | 175 element = ElementTraversal::nextSkippingChildren(*element); |
| 176 continue; | 176 continue; |
| 177 } | 177 } |
| 178 element = ElementTraversal::next(*element); | 178 element = ElementTraversal::next(*element); |
| 179 } | 179 } |
| 180 } | 180 } |
| 181 | 181 |
| 182 } // namespace blink | 182 } // namespace blink |
| OLD | NEW |