| 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 20 matching lines...) Expand all Loading... |
| 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/StyleChangeReason.h" | 34 #include "core/dom/StyleChangeReason.h" |
| 35 #include "core/dom/TreeScope.h" | 35 #include "core/dom/TreeScope.h" |
| 36 #include "core/dom/shadow/ShadowRoot.h" | 36 #include "core/dom/shadow/ShadowRoot.h" |
| 37 #include "core/html/HTMLStyleElement.h" | 37 #include "core/html/HTMLStyleElement.h" |
| 38 | 38 |
| 39 namespace blink { | 39 namespace blink { |
| 40 | 40 |
| 41 StyleSheetInvalidationAnalysis::StyleSheetInvalidationAnalysis(const TreeScope&
treeScope, const WillBeHeapVector<RawPtrWillBeMember<StyleSheetContents>>& sheet
s) | 41 StyleSheetInvalidationAnalysis::StyleSheetInvalidationAnalysis(const TreeScope&
treeScope, const HeapVector<Member<StyleSheetContents>>& sheets) |
| 42 : m_treeScope(&treeScope) | 42 : m_treeScope(&treeScope) |
| 43 { | 43 { |
| 44 for (unsigned i = 0; i < sheets.size() && !m_dirtiesAllStyle; ++i) | 44 for (unsigned i = 0; i < sheets.size() && !m_dirtiesAllStyle; ++i) |
| 45 analyzeStyleSheet(sheets[i]); | 45 analyzeStyleSheet(sheets[i]); |
| 46 } | 46 } |
| 47 | 47 |
| 48 static bool determineSelectorScopes(const CSSSelectorList& selectorList, HashSet
<StringImpl*>& idScopes, HashSet<StringImpl*>& classScopes) | 48 static bool determineSelectorScopes(const CSSSelectorList& selectorList, HashSet
<StringImpl*>& idScopes, HashSet<StringImpl*>& classScopes) |
| 49 { | 49 { |
| 50 for (const CSSSelector* selector = selectorList.first(); selector; selector
= CSSSelectorList::next(*selector)) { | 50 for (const CSSSelector* selector = selectorList.first(); selector; selector
= CSSSelectorList::next(*selector)) { |
| 51 const CSSSelector* scopeSelector = 0; | 51 const CSSSelector* scopeSelector = 0; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 void StyleSheetInvalidationAnalysis::analyzeStyleSheet(StyleSheetContents* style
SheetContents) | 105 void StyleSheetInvalidationAnalysis::analyzeStyleSheet(StyleSheetContents* style
SheetContents) |
| 106 { | 106 { |
| 107 // Updating the style on the shadow DOM for image fallback content can bring
us here when imports | 107 // Updating the style on the shadow DOM for image fallback content can bring
us here when imports |
| 108 // are still getting loaded in the main document. Just need to exit early as
we will return here | 108 // are still getting loaded in the main document. Just need to exit early as
we will return here |
| 109 // when the imports finish loading. | 109 // when the imports finish loading. |
| 110 if (styleSheetContents->isLoading()) | 110 if (styleSheetContents->isLoading()) |
| 111 return; | 111 return; |
| 112 | 112 |
| 113 // See if all rules on the sheet are scoped to some specific ids or classes. | 113 // See if all rules on the sheet are scoped to some specific ids or classes. |
| 114 // Then test if we actually have any of those in the tree at the moment. | 114 // Then test if we actually have any of those in the tree at the moment. |
| 115 const WillBeHeapVector<RefPtrWillBeMember<StyleRuleImport>>& importRules = s
tyleSheetContents->importRules(); | 115 const HeapVector<Member<StyleRuleImport>>& importRules = styleSheetContents-
>importRules(); |
| 116 for (unsigned i = 0; i < importRules.size(); ++i) { | 116 for (unsigned i = 0; i < importRules.size(); ++i) { |
| 117 if (!importRules[i]->styleSheet()) | 117 if (!importRules[i]->styleSheet()) |
| 118 continue; | 118 continue; |
| 119 analyzeStyleSheet(importRules[i]->styleSheet()); | 119 analyzeStyleSheet(importRules[i]->styleSheet()); |
| 120 if (m_dirtiesAllStyle) | 120 if (m_dirtiesAllStyle) |
| 121 return; | 121 return; |
| 122 } | 122 } |
| 123 | 123 |
| 124 if (m_treeScope->rootNode().isShadowRoot()) | 124 if (m_treeScope->rootNode().isShadowRoot()) |
| 125 return; | 125 return; |
| 126 | 126 |
| 127 const WillBeHeapVector<RefPtrWillBeMember<StyleRuleBase>>& rules = styleShee
tContents->childRules(); | 127 const HeapVector<Member<StyleRuleBase>>& rules = styleSheetContents->childRu
les(); |
| 128 for (unsigned i = 0; i < rules.size(); i++) { | 128 for (unsigned i = 0; i < rules.size(); i++) { |
| 129 StyleRuleBase* rule = rules[i].get(); | 129 StyleRuleBase* rule = rules[i].get(); |
| 130 if (!rule->isStyleRule()) { | 130 if (!rule->isStyleRule()) { |
| 131 if (ruleAdditionMightRequireDocumentStyleRecalc(rule)) { | 131 if (ruleAdditionMightRequireDocumentStyleRecalc(rule)) { |
| 132 m_dirtiesAllStyle = true; | 132 m_dirtiesAllStyle = true; |
| 133 return; | 133 return; |
| 134 } | 134 } |
| 135 continue; | 135 continue; |
| 136 } | 136 } |
| 137 StyleRule* styleRule = toStyleRule(rule); | 137 StyleRule* styleRule = toStyleRule(rule); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 element->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonFo
rTracing::create(StyleChangeReason::StyleSheetChange)); | 174 element->setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonFo
rTracing::create(StyleChangeReason::StyleSheetChange)); |
| 175 // The whole subtree is now invalidated, we can skip to the next sib
ling. | 175 // The whole subtree is now invalidated, we can skip to the next sib
ling. |
| 176 element = ElementTraversal::nextSkippingChildren(*element); | 176 element = ElementTraversal::nextSkippingChildren(*element); |
| 177 continue; | 177 continue; |
| 178 } | 178 } |
| 179 element = ElementTraversal::next(*element); | 179 element = ElementTraversal::next(*element); |
| 180 } | 180 } |
| 181 } | 181 } |
| 182 | 182 |
| 183 } // namespace blink | 183 } // namespace blink |
| OLD | NEW |