| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) | 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) |
| 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) | 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) |
| 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc.
All rights reserved. | 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc.
All rights reserved. |
| 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
| 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> | 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> |
| 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
| 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. | 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. |
| 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 } | 115 } |
| 116 | 116 |
| 117 static StylePropertySet* rightToLeftDeclaration() | 117 static StylePropertySet* rightToLeftDeclaration() |
| 118 { | 118 { |
| 119 DEFINE_STATIC_REF_WILL_BE_PERSISTENT(MutableStylePropertySet, rightToLeftDec
l, (MutableStylePropertySet::create())); | 119 DEFINE_STATIC_REF_WILL_BE_PERSISTENT(MutableStylePropertySet, rightToLeftDec
l, (MutableStylePropertySet::create())); |
| 120 if (rightToLeftDecl->isEmpty()) | 120 if (rightToLeftDecl->isEmpty()) |
| 121 rightToLeftDecl->setProperty(CSSPropertyDirection, CSSValueRtl); | 121 rightToLeftDecl->setProperty(CSSPropertyDirection, CSSValueRtl); |
| 122 return rightToLeftDecl; | 122 return rightToLeftDecl; |
| 123 } | 123 } |
| 124 | 124 |
| 125 static void addFontFaceRule(Document* document, CSSFontSelector* cssFontSelector
, const StyleRuleFontFace* fontFaceRule) | |
| 126 { | |
| 127 RefPtrWillBeRawPtr<FontFace> fontFace = FontFace::create(document, fontFaceR
ule); | |
| 128 if (fontFace) | |
| 129 cssFontSelector->fontFaceCache()->add(cssFontSelector, fontFaceRule, fon
tFace); | |
| 130 } | |
| 131 | |
| 132 static void collectScopedResolversForHostedShadowTrees(const Element* element, W
illBeHeapVector<RawPtrWillBeMember<ScopedStyleResolver>, 8>& resolvers) | 125 static void collectScopedResolversForHostedShadowTrees(const Element* element, W
illBeHeapVector<RawPtrWillBeMember<ScopedStyleResolver>, 8>& resolvers) |
| 133 { | 126 { |
| 134 ElementShadow* shadow = element->shadow(); | 127 ElementShadow* shadow = element->shadow(); |
| 135 if (!shadow) | 128 if (!shadow) |
| 136 return; | 129 return; |
| 137 | 130 |
| 138 // Adding scoped resolver for active shadow roots for shadow host styling. | 131 // Adding scoped resolver for active shadow roots for shadow host styling. |
| 139 for (ShadowRoot* shadowRoot = shadow->youngestShadowRoot(); shadowRoot; shad
owRoot = shadowRoot->olderShadowRoot()) { | 132 for (ShadowRoot* shadowRoot = shadow->youngestShadowRoot(); shadowRoot; shad
owRoot = shadowRoot->olderShadowRoot()) { |
| 140 if (shadowRoot->numberOfStyles() > 0) { | 133 if (shadowRoot->numberOfStyles() > 0) { |
| 141 if (ScopedStyleResolver* resolver = shadowRoot->scopedStyleResolver(
)) | 134 if (ScopedStyleResolver* resolver = shadowRoot->scopedStyleResolver(
)) |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 void StyleResolver::appendCSSStyleSheet(CSSStyleSheet& cssSheet) | 183 void StyleResolver::appendCSSStyleSheet(CSSStyleSheet& cssSheet) |
| 191 { | 184 { |
| 192 ASSERT(!cssSheet.disabled()); | 185 ASSERT(!cssSheet.disabled()); |
| 193 if (cssSheet.mediaQueries() && !m_medium->eval(cssSheet.mediaQueries(), &m_v
iewportDependentMediaQueryResults)) | 186 if (cssSheet.mediaQueries() && !m_medium->eval(cssSheet.mediaQueries(), &m_v
iewportDependentMediaQueryResults)) |
| 194 return; | 187 return; |
| 195 | 188 |
| 196 TreeScope* treeScope = ScopedStyleResolver::treeScopeFor(document(), &cssShe
et); | 189 TreeScope* treeScope = ScopedStyleResolver::treeScopeFor(document(), &cssShe
et); |
| 197 if (!treeScope) | 190 if (!treeScope) |
| 198 return; | 191 return; |
| 199 | 192 |
| 200 unsigned index = treeScope->ensureScopedStyleResolver().appendCSSStyleSheet(
&cssSheet); | 193 treeScope->ensureScopedStyleResolver().appendCSSStyleSheet(cssSheet, *m_medi
um); |
| 201 addRulesFromSheet(cssSheet, treeScope, index); | |
| 202 } | |
| 203 | |
| 204 void StyleResolver::addRulesFromSheet(CSSStyleSheet& cssSheet, TreeScope* treeSc
ope, unsigned index) | |
| 205 { | |
| 206 StyleSheetContents* sheet = cssSheet.contents(); | |
| 207 AddRuleFlags addRuleFlags = document().securityOrigin()->canRequest(sheet->b
aseURL()) ? RuleHasDocumentSecurityOrigin : RuleHasNoSpecialState; | |
| 208 const RuleSet& ruleSet = sheet->ensureRuleSet(*m_medium, addRuleFlags); | |
| 209 | |
| 210 addMediaQueryResults(ruleSet.viewportDependentMediaQueryResults()); | |
| 211 processScopedRules(ruleSet, &cssSheet, index, treeScope->rootNode()); | |
| 212 } | 194 } |
| 213 | 195 |
| 214 void StyleResolver::appendPendingAuthorStyleSheets() | 196 void StyleResolver::appendPendingAuthorStyleSheets() |
| 215 { | 197 { |
| 216 for (const auto& styleSheet : m_pendingStyleSheets) | 198 for (const auto& styleSheet : m_pendingStyleSheets) |
| 217 appendCSSStyleSheet(*styleSheet); | 199 appendCSSStyleSheet(*styleSheet); |
| 218 | 200 |
| 219 m_pendingStyleSheets.clear(); | 201 m_pendingStyleSheets.clear(); |
| 220 finishAppendAuthorStyleSheets(); | 202 finishAppendAuthorStyleSheets(); |
| 221 } | 203 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 242 | 224 |
| 243 void StyleResolver::resetRuleFeatures() | 225 void StyleResolver::resetRuleFeatures() |
| 244 { | 226 { |
| 245 // Need to recreate RuleFeatureSet. | 227 // Need to recreate RuleFeatureSet. |
| 246 m_features.clear(); | 228 m_features.clear(); |
| 247 m_siblingRuleSet.clear(); | 229 m_siblingRuleSet.clear(); |
| 248 m_uncommonAttributeRuleSet.clear(); | 230 m_uncommonAttributeRuleSet.clear(); |
| 249 m_needCollectFeatures = true; | 231 m_needCollectFeatures = true; |
| 250 } | 232 } |
| 251 | 233 |
| 252 void StyleResolver::processScopedRules(const RuleSet& authorRules, CSSStyleSheet
* parentStyleSheet, unsigned parentIndex, ContainerNode& scope) | 234 void StyleResolver::addTreeBoundaryCrossingScope(ContainerNode& scope) |
| 253 { | 235 { |
| 254 const WillBeHeapVector<RawPtrWillBeMember<StyleRuleKeyframes> > keyframesRul
es = authorRules.keyframesRules(); | 236 m_treeBoundaryCrossingRules.addScope(scope); |
| 255 ScopedStyleResolver& resolver = scope.treeScope().ensureScopedStyleResolver(
); | |
| 256 for (unsigned i = 0; i < keyframesRules.size(); ++i) | |
| 257 resolver.addKeyframeStyle(keyframesRules[i]); | |
| 258 | |
| 259 m_treeBoundaryCrossingRules.addTreeBoundaryCrossingRules(authorRules, parent
StyleSheet, parentIndex, scope); | |
| 260 | |
| 261 // FIXME(BUG 72461): We don't add @font-face rules of scoped style sheets fo
r the moment. | |
| 262 if (scope.isDocumentNode()) { | |
| 263 const WillBeHeapVector<RawPtrWillBeMember<StyleRuleFontFace> > fontFaceR
ules = authorRules.fontFaceRules(); | |
| 264 for (unsigned i = 0; i < fontFaceRules.size(); ++i) | |
| 265 addFontFaceRule(m_document, document().styleEngine()->fontSelector()
, fontFaceRules[i]); | |
| 266 if (fontFaceRules.size()) | |
| 267 invalidateMatchedPropertiesCache(); | |
| 268 } | |
| 269 } | 237 } |
| 270 | 238 |
| 271 void StyleResolver::resetAuthorStyle(TreeScope& treeScope) | 239 void StyleResolver::resetAuthorStyle(TreeScope& treeScope) |
| 272 { | 240 { |
| 273 m_treeBoundaryCrossingRules.reset(&treeScope.rootNode()); | 241 m_treeBoundaryCrossingRules.removeScope(treeScope.rootNode()); |
| 274 resetRuleFeatures(); | 242 resetRuleFeatures(); |
| 275 | 243 |
| 276 ScopedStyleResolver* resolver = treeScope.scopedStyleResolver(); | 244 ScopedStyleResolver* resolver = treeScope.scopedStyleResolver(); |
| 277 if (!resolver) | 245 if (!resolver) |
| 278 return; | 246 return; |
| 279 | 247 |
| 280 resolver->resetAuthorStyle(); | 248 resolver->resetAuthorStyle(); |
| 281 if (treeScope.rootNode().isDocumentNode()) | 249 if (treeScope.rootNode().isDocumentNode()) |
| 282 return; | 250 return; |
| 283 | 251 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 308 | 276 |
| 309 if (document().isViewSource()) | 277 if (document().isViewSource()) |
| 310 m_features.add(defaultStyleSheets.defaultViewSourceStyle()->features()); | 278 m_features.add(defaultStyleSheets.defaultViewSourceStyle()->features()); |
| 311 | 279 |
| 312 if (document().isTransitionDocument()) | 280 if (document().isTransitionDocument()) |
| 313 m_features.add(defaultStyleSheets.defaultTransitionStyle()->features()); | 281 m_features.add(defaultStyleSheets.defaultTransitionStyle()->features()); |
| 314 | 282 |
| 315 if (m_watchedSelectorsRules) | 283 if (m_watchedSelectorsRules) |
| 316 m_features.add(m_watchedSelectorsRules->features()); | 284 m_features.add(m_watchedSelectorsRules->features()); |
| 317 | 285 |
| 318 m_treeBoundaryCrossingRules.collectFeaturesTo(m_features); | |
| 319 | |
| 320 document().styleEngine()->collectScopedStyleFeaturesTo(m_features); | 286 document().styleEngine()->collectScopedStyleFeaturesTo(m_features); |
| 321 | 287 |
| 322 m_siblingRuleSet = makeRuleSet(m_features.siblingRules); | 288 m_siblingRuleSet = makeRuleSet(m_features.siblingRules); |
| 323 m_uncommonAttributeRuleSet = makeRuleSet(m_features.uncommonAttributeRules); | 289 m_uncommonAttributeRuleSet = makeRuleSet(m_features.uncommonAttributeRules); |
| 324 m_needCollectFeatures = false; | 290 m_needCollectFeatures = false; |
| 325 } | 291 } |
| 326 | 292 |
| 327 bool StyleResolver::hasRulesForId(const AtomicString& id) const | 293 bool StyleResolver::hasRulesForId(const AtomicString& id) const |
| 328 { | 294 { |
| 329 return m_features.hasSelectorForId(id); | 295 return m_features.hasSelectorForId(id); |
| (...skipping 1195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1525 visitor->trace(m_uncommonAttributeRuleSet); | 1491 visitor->trace(m_uncommonAttributeRuleSet); |
| 1526 visitor->trace(m_watchedSelectorsRules); | 1492 visitor->trace(m_watchedSelectorsRules); |
| 1527 visitor->trace(m_treeBoundaryCrossingRules); | 1493 visitor->trace(m_treeBoundaryCrossingRules); |
| 1528 visitor->trace(m_styleSharingLists); | 1494 visitor->trace(m_styleSharingLists); |
| 1529 visitor->trace(m_pendingStyleSheets); | 1495 visitor->trace(m_pendingStyleSheets); |
| 1530 visitor->trace(m_document); | 1496 visitor->trace(m_document); |
| 1531 #endif | 1497 #endif |
| 1532 } | 1498 } |
| 1533 | 1499 |
| 1534 } // namespace blink | 1500 } // namespace blink |
| OLD | NEW |