| 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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 m_watchedSelectorsRules->addStyleRule(watchedSelectors[i].get(), RuleHas
NoSpecialState); | 182 m_watchedSelectorsRules->addStyleRule(watchedSelectors[i].get(), RuleHas
NoSpecialState); |
| 183 } | 183 } |
| 184 | 184 |
| 185 void StyleResolver::lazyAppendAuthorStyleSheets(unsigned firstNew, const Vector<
RefPtr<CSSStyleSheet> >& styleSheets) | 185 void StyleResolver::lazyAppendAuthorStyleSheets(unsigned firstNew, const Vector<
RefPtr<CSSStyleSheet> >& styleSheets) |
| 186 { | 186 { |
| 187 unsigned size = styleSheets.size(); | 187 unsigned size = styleSheets.size(); |
| 188 for (unsigned i = firstNew; i < size; ++i) | 188 for (unsigned i = firstNew; i < size; ++i) |
| 189 m_pendingStyleSheets.add(styleSheets[i].get()); | 189 m_pendingStyleSheets.add(styleSheets[i].get()); |
| 190 } | 190 } |
| 191 | 191 |
| 192 void StyleResolver::removePendingAuthorStyleSheets(const Vector<RefPtr<CSSStyleS
heet> >& styleSheets) | |
| 193 { | |
| 194 for (unsigned i = 0; i < styleSheets.size(); ++i) | |
| 195 m_pendingStyleSheets.remove(styleSheets[i].get()); | |
| 196 } | |
| 197 | |
| 198 void StyleResolver::appendCSSStyleSheet(CSSStyleSheet* cssSheet) | 192 void StyleResolver::appendCSSStyleSheet(CSSStyleSheet* cssSheet) |
| 199 { | 193 { |
| 200 ASSERT(cssSheet); | 194 ASSERT(cssSheet); |
| 201 ASSERT(!cssSheet->disabled()); | 195 ASSERT(!cssSheet->disabled()); |
| 202 if (cssSheet->mediaQueries() && !m_medium->eval(cssSheet->mediaQueries(), &m
_viewportDependentMediaQueryResults)) | 196 if (cssSheet->mediaQueries() && !m_medium->eval(cssSheet->mediaQueries(), &m
_viewportDependentMediaQueryResults)) |
| 203 return; | 197 return; |
| 204 | 198 |
| 205 StyleSheetContents* sheet = cssSheet->contents(); | 199 StyleSheetContents* sheet = cssSheet->contents(); |
| 206 ContainerNode* scopingNode = ScopedStyleResolver::scopingNodeFor(document(),
cssSheet); | 200 ContainerNode* scopingNode = ScopedStyleResolver::scopingNodeFor(document(),
cssSheet); |
| 207 if (!scopingNode) | 201 if (!scopingNode) |
| (...skipping 29 matching lines...) Expand all Loading... |
| 237 collectFeatures(); | 231 collectFeatures(); |
| 238 | 232 |
| 239 if (document().renderer() && document().renderer()->style()) | 233 if (document().renderer() && document().renderer()->style()) |
| 240 document().renderer()->style()->font().update(fontSelector()); | 234 document().renderer()->style()->font().update(fontSelector()); |
| 241 | 235 |
| 242 collectViewportRules(); | 236 collectViewportRules(); |
| 243 | 237 |
| 244 document().styleEngine()->resetCSSFeatureFlags(m_features); | 238 document().styleEngine()->resetCSSFeatureFlags(m_features); |
| 245 } | 239 } |
| 246 | 240 |
| 247 void StyleResolver::resetRuleFeatures() | |
| 248 { | |
| 249 // Need to recreate RuleFeatureSet. | |
| 250 m_features.clear(); | |
| 251 m_siblingRuleSet.clear(); | |
| 252 m_uncommonAttributeRuleSet.clear(); | |
| 253 m_needCollectFeatures = true; | |
| 254 } | |
| 255 | |
| 256 void StyleResolver::addTreeBoundaryCrossingRules(const Vector<MinimalRuleData>&
rules, ContainerNode* scope) | 241 void StyleResolver::addTreeBoundaryCrossingRules(const Vector<MinimalRuleData>&
rules, ContainerNode* scope) |
| 257 { | 242 { |
| 258 for (unsigned i = 0; i < rules.size(); ++i) { | 243 for (unsigned i = 0; i < rules.size(); ++i) { |
| 259 const MinimalRuleData& info = rules[i]; | 244 const MinimalRuleData& info = rules[i]; |
| 260 m_treeBoundaryCrossingRules.addRule(info.m_rule, info.m_selectorIndex, s
cope, info.m_flags); | 245 m_treeBoundaryCrossingRules.addRule(info.m_rule, info.m_selectorIndex, s
cope, info.m_flags); |
| 261 } | 246 } |
| 262 } | 247 } |
| 263 | 248 |
| 264 void StyleResolver::processScopedRules(const RuleSet& authorRules, const KURL& s
heetBaseURL, ContainerNode* scope) | 249 void StyleResolver::processScopedRules(const RuleSet& authorRules, const KURL& s
heetBaseURL, ContainerNode* scope) |
| 265 { | 250 { |
| 266 const Vector<StyleRuleKeyframes*> keyframesRules = authorRules.keyframesRule
s(); | 251 const Vector<StyleRuleKeyframes*> keyframesRules = authorRules.keyframesRule
s(); |
| 267 for (unsigned i = 0; i < keyframesRules.size(); ++i) | 252 for (unsigned i = 0; i < keyframesRules.size(); ++i) |
| 268 ensureScopedStyleResolver(scope)->addKeyframeStyle(keyframesRules[i]); | 253 ensureScopedStyleResolver(scope)->addKeyframeStyle(keyframesRules[i]); |
| 269 | 254 |
| 270 addTreeBoundaryCrossingRules(authorRules.treeBoundaryCrossingRules(), scope)
; | 255 addTreeBoundaryCrossingRules(authorRules.treeBoundaryCrossingRules(), scope)
; |
| 271 | 256 |
| 272 // FIXME(BUG 72461): We don't add @font-face rules of scoped style sheets fo
r the moment. | 257 // FIXME(BUG 72461): We don't add @font-face rules of scoped style sheets fo
r the moment. |
| 273 if (!scope || scope->isDocumentNode()) { | 258 if (!scope || scope->isDocumentNode()) { |
| 274 const Vector<StyleRuleFontFace*> fontFaceRules = authorRules.fontFaceRul
es(); | 259 const Vector<StyleRuleFontFace*> fontFaceRules = authorRules.fontFaceRul
es(); |
| 275 for (unsigned i = 0; i < fontFaceRules.size(); ++i) | 260 for (unsigned i = 0; i < fontFaceRules.size(); ++i) |
| 276 fontSelector()->addFontFaceRule(fontFaceRules[i]); | 261 fontSelector()->addFontFaceRule(fontFaceRules[i]); |
| 277 if (fontFaceRules.size()) | 262 if (fontFaceRules.size()) |
| 278 invalidateMatchedPropertiesCache(); | 263 invalidateMatchedPropertiesCache(); |
| 279 } else { | 264 } else { |
| 280 addTreeBoundaryCrossingRules(authorRules.shadowDistributedRules(), scope
); | 265 addTreeBoundaryCrossingRules(authorRules.shadowDistributedRules(), scope
); |
| 281 } | 266 } |
| 282 } | 267 } |
| 283 | 268 |
| 284 void StyleResolver::resetFontSelector() | |
| 285 { | |
| 286 ASSERT(m_fontSelector); | |
| 287 m_fontSelector->unregisterForInvalidationCallbacks(this); | |
| 288 m_fontSelector->clearDocument(); | |
| 289 invalidateMatchedPropertiesCache(); | |
| 290 | |
| 291 m_fontSelector = CSSFontSelector::create(&m_document); | |
| 292 m_fontSelector->registerForInvalidationCallbacks(this); | |
| 293 } | |
| 294 | |
| 295 void StyleResolver::resetAuthorStyle(const ContainerNode* scopingNode) | |
| 296 { | |
| 297 // FIXME: When chanking scoped attribute, scopingNode's hasScopedHTMLStyleCh
ild has been already modified. | |
| 298 // So we cannot use hasScopedHTMLStyleChild flag here. | |
| 299 ScopedStyleResolver* resolver = scopingNode ? m_styleTree.lookupScopedStyleR
esolverFor(scopingNode) : m_styleTree.scopedStyleResolverForDocument(); | |
| 300 if (!resolver) | |
| 301 return; | |
| 302 | |
| 303 treeBoundaryCrossingRules().reset(scopingNode); | |
| 304 | |
| 305 resolver->resetAuthorStyle(); | |
| 306 resetRuleFeatures(); | |
| 307 if (!scopingNode) | |
| 308 return; | |
| 309 | |
| 310 m_styleTree.remove(scopingNode); | |
| 311 } | |
| 312 | |
| 313 static PassOwnPtr<RuleSet> makeRuleSet(const Vector<RuleFeature>& rules) | 269 static PassOwnPtr<RuleSet> makeRuleSet(const Vector<RuleFeature>& rules) |
| 314 { | 270 { |
| 315 size_t size = rules.size(); | 271 size_t size = rules.size(); |
| 316 if (!size) | 272 if (!size) |
| 317 return nullptr; | 273 return nullptr; |
| 318 OwnPtr<RuleSet> ruleSet = RuleSet::create(); | 274 OwnPtr<RuleSet> ruleSet = RuleSet::create(); |
| 319 for (size_t i = 0; i < size; ++i) | 275 for (size_t i = 0; i < size; ++i) |
| 320 ruleSet->addRule(rules[i].rule, rules[i].selectorIndex, rules[i].hasDocu
mentSecurityOrigin ? RuleHasDocumentSecurityOrigin : RuleHasNoSpecialState); | 276 ruleSet->addRule(rules[i].rule, rules[i].selectorIndex, rules[i].hasDocu
mentSecurityOrigin ? RuleHasDocumentSecurityOrigin : RuleHasNoSpecialState); |
| 321 return ruleSet.release(); | 277 return ruleSet.release(); |
| 322 } | 278 } |
| (...skipping 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1423 bool StyleResolver::affectedByViewportChange() const | 1379 bool StyleResolver::affectedByViewportChange() const |
| 1424 { | 1380 { |
| 1425 for (unsigned i = 0; i < m_viewportDependentMediaQueryResults.size(); ++i) { | 1381 for (unsigned i = 0; i < m_viewportDependentMediaQueryResults.size(); ++i) { |
| 1426 if (m_medium->eval(&m_viewportDependentMediaQueryResults[i]->m_expressio
n) != m_viewportDependentMediaQueryResults[i]->m_result) | 1382 if (m_medium->eval(&m_viewportDependentMediaQueryResults[i]->m_expressio
n) != m_viewportDependentMediaQueryResults[i]->m_result) |
| 1427 return true; | 1383 return true; |
| 1428 } | 1384 } |
| 1429 return false; | 1385 return false; |
| 1430 } | 1386 } |
| 1431 | 1387 |
| 1432 } // namespace WebCore | 1388 } // namespace WebCore |
| OLD | NEW |