| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. | 3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. |
| 4 * Copyright (C) 2012 Google Inc. All rights reserved. | 4 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 { | 49 { |
| 50 for (TreeScope* scope = treeScope().parentTreeScope(); scope; scope = scope-
>parentTreeScope()) { | 50 for (TreeScope* scope = treeScope().parentTreeScope(); scope; scope = scope-
>parentTreeScope()) { |
| 51 if (ScopedStyleResolver* resolver = scope->scopedStyleResolver()) | 51 if (ScopedStyleResolver* resolver = scope->scopedStyleResolver()) |
| 52 return resolver; | 52 return resolver; |
| 53 } | 53 } |
| 54 return nullptr; | 54 return nullptr; |
| 55 } | 55 } |
| 56 | 56 |
| 57 void ScopedStyleResolver::addKeyframeRules(const RuleSet& ruleSet) | 57 void ScopedStyleResolver::addKeyframeRules(const RuleSet& ruleSet) |
| 58 { | 58 { |
| 59 const WillBeHeapVector<RawPtrWillBeMember<StyleRuleKeyframes>> keyframesRule
s = ruleSet.keyframesRules(); | 59 const HeapVector<Member<StyleRuleKeyframes>> keyframesRules = ruleSet.keyfra
mesRules(); |
| 60 for (unsigned i = 0; i < keyframesRules.size(); ++i) | 60 for (unsigned i = 0; i < keyframesRules.size(); ++i) |
| 61 addKeyframeStyle(keyframesRules[i]); | 61 addKeyframeStyle(keyframesRules[i]); |
| 62 } | 62 } |
| 63 | 63 |
| 64 void ScopedStyleResolver::addFontFaceRules(const RuleSet& ruleSet) | 64 void ScopedStyleResolver::addFontFaceRules(const RuleSet& ruleSet) |
| 65 { | 65 { |
| 66 // FIXME(BUG 72461): We don't add @font-face rules of scoped style sheets fo
r the moment. | 66 // FIXME(BUG 72461): We don't add @font-face rules of scoped style sheets fo
r the moment. |
| 67 if (!treeScope().rootNode().isDocumentNode()) | 67 if (!treeScope().rootNode().isDocumentNode()) |
| 68 return; | 68 return; |
| 69 | 69 |
| 70 Document& document = treeScope().document(); | 70 Document& document = treeScope().document(); |
| 71 CSSFontSelector* cssFontSelector = document.styleEngine().fontSelector(); | 71 CSSFontSelector* cssFontSelector = document.styleEngine().fontSelector(); |
| 72 const WillBeHeapVector<RawPtrWillBeMember<StyleRuleFontFace>> fontFaceRules
= ruleSet.fontFaceRules(); | 72 const HeapVector<Member<StyleRuleFontFace>> fontFaceRules = ruleSet.fontFace
Rules(); |
| 73 for (auto& fontFaceRule : fontFaceRules) { | 73 for (auto& fontFaceRule : fontFaceRules) { |
| 74 if (RefPtrWillBeRawPtr<FontFace> fontFace = FontFace::create(&document,
fontFaceRule)) | 74 if (RawPtr<FontFace> fontFace = FontFace::create(&document, fontFaceRule
)) |
| 75 cssFontSelector->fontFaceCache()->add(cssFontSelector, fontFaceRule,
fontFace); | 75 cssFontSelector->fontFaceCache()->add(cssFontSelector, fontFaceRule,
fontFace); |
| 76 } | 76 } |
| 77 if (fontFaceRules.size()) | 77 if (fontFaceRules.size()) |
| 78 document.styleResolver()->invalidateMatchedPropertiesCache(); | 78 document.styleResolver()->invalidateMatchedPropertiesCache(); |
| 79 } | 79 } |
| 80 | 80 |
| 81 void ScopedStyleResolver::appendCSSStyleSheet(CSSStyleSheet& cssSheet, const Med
iaQueryEvaluator& medium) | 81 void ScopedStyleResolver::appendCSSStyleSheet(CSSStyleSheet& cssSheet, const Med
iaQueryEvaluator& medium) |
| 82 { | 82 { |
| 83 unsigned index = m_authorStyleSheets.size(); | 83 unsigned index = m_authorStyleSheets.size(); |
| 84 m_authorStyleSheets.append(&cssSheet); | 84 m_authorStyleSheets.append(&cssSheet); |
| 85 StyleSheetContents* sheet = cssSheet.contents(); | 85 StyleSheetContents* sheet = cssSheet.contents(); |
| 86 AddRuleFlags addRuleFlags = treeScope().document().getSecurityOrigin()->canR
equest(sheet->baseURL()) ? RuleHasDocumentSecurityOrigin : RuleHasNoSpecialState
; | 86 AddRuleFlags addRuleFlags = treeScope().document().getSecurityOrigin()->canR
equest(sheet->baseURL()) ? RuleHasDocumentSecurityOrigin : RuleHasNoSpecialState
; |
| 87 const RuleSet& ruleSet = sheet->ensureRuleSet(medium, addRuleFlags); | 87 const RuleSet& ruleSet = sheet->ensureRuleSet(medium, addRuleFlags); |
| 88 | 88 |
| 89 addKeyframeRules(ruleSet); | 89 addKeyframeRules(ruleSet); |
| 90 addFontFaceRules(ruleSet); | 90 addFontFaceRules(ruleSet); |
| 91 addTreeBoundaryCrossingRules(ruleSet, &cssSheet, index); | 91 addTreeBoundaryCrossingRules(ruleSet, &cssSheet, index); |
| 92 treeScope().document().styleResolver()->addViewportDependentMediaQueries(rul
eSet.viewportDependentMediaQueryResults()); | 92 treeScope().document().styleResolver()->addViewportDependentMediaQueries(rul
eSet.viewportDependentMediaQueryResults()); |
| 93 treeScope().document().styleResolver()->addDeviceDependentMediaQueries(ruleS
et.deviceDependentMediaQueryResults()); | 93 treeScope().document().styleResolver()->addDeviceDependentMediaQueries(ruleS
et.deviceDependentMediaQueryResults()); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void ScopedStyleResolver::collectFeaturesTo(RuleFeatureSet& features, WillBeHeap
HashSet<RawPtrWillBeMember<const StyleSheetContents>>& visitedSharedStyleSheetCo
ntents) const | 96 void ScopedStyleResolver::collectFeaturesTo(RuleFeatureSet& features, HeapHashSe
t<Member<const StyleSheetContents>>& visitedSharedStyleSheetContents) const |
| 97 { | 97 { |
| 98 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) { | 98 for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) { |
| 99 ASSERT(m_authorStyleSheets[i]->ownerNode()); | 99 ASSERT(m_authorStyleSheets[i]->ownerNode()); |
| 100 StyleSheetContents* contents = m_authorStyleSheets[i]->contents(); | 100 StyleSheetContents* contents = m_authorStyleSheets[i]->contents(); |
| 101 if (contents->hasOneClient() || visitedSharedStyleSheetContents.add(cont
ents).isNewEntry) | 101 if (contents->hasOneClient() || visitedSharedStyleSheetContents.add(cont
ents).isNewEntry) |
| 102 features.add(contents->ruleSet().features()); | 102 features.add(contents->ruleSet().features()); |
| 103 } | 103 } |
| 104 | 104 |
| 105 if (!m_treeBoundaryCrossingRuleSet) | 105 if (!m_treeBoundaryCrossingRuleSet) |
| 106 return; | 106 return; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 122 if (m_keyframesRuleMap.isEmpty()) | 122 if (m_keyframesRuleMap.isEmpty()) |
| 123 return nullptr; | 123 return nullptr; |
| 124 | 124 |
| 125 KeyframesRuleMap::iterator it = m_keyframesRuleMap.find(animationName); | 125 KeyframesRuleMap::iterator it = m_keyframesRuleMap.find(animationName); |
| 126 if (it == m_keyframesRuleMap.end()) | 126 if (it == m_keyframesRuleMap.end()) |
| 127 return nullptr; | 127 return nullptr; |
| 128 | 128 |
| 129 return it->value.get(); | 129 return it->value.get(); |
| 130 } | 130 } |
| 131 | 131 |
| 132 void ScopedStyleResolver::addKeyframeStyle(PassRefPtrWillBeRawPtr<StyleRuleKeyfr
ames> rule) | 132 void ScopedStyleResolver::addKeyframeStyle(RawPtr<StyleRuleKeyframes> rule) |
| 133 { | 133 { |
| 134 AtomicString s(rule->name()); | 134 AtomicString s(rule->name()); |
| 135 | 135 |
| 136 if (rule->isVendorPrefixed()) { | 136 if (rule->isVendorPrefixed()) { |
| 137 KeyframesRuleMap::iterator it = m_keyframesRuleMap.find(s.impl()); | 137 KeyframesRuleMap::iterator it = m_keyframesRuleMap.find(s.impl()); |
| 138 if (it == m_keyframesRuleMap.end()) | 138 if (it == m_keyframesRuleMap.end()) |
| 139 m_keyframesRuleMap.set(s.impl(), rule); | 139 m_keyframesRuleMap.set(s.impl(), rule); |
| 140 else if (it->value->isVendorPrefixed()) | 140 else if (it->value->isVendorPrefixed()) |
| 141 m_keyframesRuleMap.set(s.impl(), rule); | 141 m_keyframesRuleMap.set(s.impl(), rule); |
| 142 } else { | 142 } else { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 DEFINE_TRACE(ScopedStyleResolver) | 192 DEFINE_TRACE(ScopedStyleResolver) |
| 193 { | 193 { |
| 194 #if ENABLE(OILPAN) | 194 #if ENABLE(OILPAN) |
| 195 visitor->trace(m_scope); | 195 visitor->trace(m_scope); |
| 196 visitor->trace(m_authorStyleSheets); | 196 visitor->trace(m_authorStyleSheets); |
| 197 visitor->trace(m_keyframesRuleMap); | 197 visitor->trace(m_keyframesRuleMap); |
| 198 visitor->trace(m_treeBoundaryCrossingRuleSet); | 198 visitor->trace(m_treeBoundaryCrossingRuleSet); |
| 199 #endif | 199 #endif |
| 200 } | 200 } |
| 201 | 201 |
| 202 static void addRules(RuleSet* ruleSet, const WillBeHeapVector<MinimalRuleData>&
rules) | 202 static void addRules(RuleSet* ruleSet, const HeapVector<MinimalRuleData>& rules) |
| 203 { | 203 { |
| 204 for (unsigned i = 0; i < rules.size(); ++i) { | 204 for (unsigned i = 0; i < rules.size(); ++i) { |
| 205 const MinimalRuleData& info = rules[i]; | 205 const MinimalRuleData& info = rules[i]; |
| 206 ruleSet->addRule(info.m_rule, info.m_selectorIndex, info.m_flags); | 206 ruleSet->addRule(info.m_rule, info.m_selectorIndex, info.m_flags); |
| 207 } | 207 } |
| 208 } | 208 } |
| 209 | 209 |
| 210 void ScopedStyleResolver::addTreeBoundaryCrossingRules(const RuleSet& authorRule
s, CSSStyleSheet* parentStyleSheet, unsigned sheetIndex) | 210 void ScopedStyleResolver::addTreeBoundaryCrossingRules(const RuleSet& authorRule
s, CSSStyleSheet* parentStyleSheet, unsigned sheetIndex) |
| 211 { | 211 { |
| 212 bool isDocumentScope = treeScope().rootNode().isDocumentNode(); | 212 bool isDocumentScope = treeScope().rootNode().isDocumentNode(); |
| 213 if (authorRules.deepCombinatorOrShadowPseudoRules().isEmpty() | 213 if (authorRules.deepCombinatorOrShadowPseudoRules().isEmpty() |
| 214 && (isDocumentScope || (authorRules.contentPseudoElementRules().isEmpty(
) && authorRules.slottedPseudoElementRules().isEmpty()))) | 214 && (isDocumentScope || (authorRules.contentPseudoElementRules().isEmpty(
) && authorRules.slottedPseudoElementRules().isEmpty()))) |
| 215 return; | 215 return; |
| 216 | 216 |
| 217 if (!authorRules.deepCombinatorOrShadowPseudoRules().isEmpty()) | 217 if (!authorRules.deepCombinatorOrShadowPseudoRules().isEmpty()) |
| 218 m_hasDeepOrShadowSelector = true; | 218 m_hasDeepOrShadowSelector = true; |
| 219 | 219 |
| 220 OwnPtrWillBeRawPtr<RuleSet> ruleSetForScope = RuleSet::create(); | 220 RawPtr<RuleSet> ruleSetForScope = RuleSet::create(); |
| 221 addRules(ruleSetForScope.get(), authorRules.deepCombinatorOrShadowPseudoRule
s()); | 221 addRules(ruleSetForScope.get(), authorRules.deepCombinatorOrShadowPseudoRule
s()); |
| 222 | 222 |
| 223 if (!isDocumentScope) { | 223 if (!isDocumentScope) { |
| 224 addRules(ruleSetForScope.get(), authorRules.contentPseudoElementRules())
; | 224 addRules(ruleSetForScope.get(), authorRules.contentPseudoElementRules())
; |
| 225 addRules(ruleSetForScope.get(), authorRules.slottedPseudoElementRules())
; | 225 addRules(ruleSetForScope.get(), authorRules.slottedPseudoElementRules())
; |
| 226 } | 226 } |
| 227 | 227 |
| 228 if (!m_treeBoundaryCrossingRuleSet) { | 228 if (!m_treeBoundaryCrossingRuleSet) { |
| 229 m_treeBoundaryCrossingRuleSet = adoptPtrWillBeNoop(new CSSStyleSheetRule
SubSet()); | 229 m_treeBoundaryCrossingRuleSet = new CSSStyleSheetRuleSubSet(); |
| 230 treeScope().document().styleResolver()->addTreeBoundaryCrossingScope(tre
eScope().rootNode()); | 230 treeScope().document().styleResolver()->addTreeBoundaryCrossingScope(tre
eScope().rootNode()); |
| 231 } | 231 } |
| 232 | 232 |
| 233 m_treeBoundaryCrossingRuleSet->append(RuleSubSet::create(parentStyleSheet, s
heetIndex, ruleSetForScope.release())); | 233 m_treeBoundaryCrossingRuleSet->append(RuleSubSet::create(parentStyleSheet, s
heetIndex, ruleSetForScope.release())); |
| 234 } | 234 } |
| 235 | 235 |
| 236 DEFINE_TRACE(ScopedStyleResolver::RuleSubSet) | 236 DEFINE_TRACE(ScopedStyleResolver::RuleSubSet) |
| 237 { | 237 { |
| 238 visitor->trace(m_parentStyleSheet); | 238 visitor->trace(m_parentStyleSheet); |
| 239 visitor->trace(m_ruleSet); | 239 visitor->trace(m_ruleSet); |
| 240 } | 240 } |
| 241 | 241 |
| 242 } // namespace blink | 242 } // namespace blink |
| OLD | NEW |