| 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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 // needs to be reconstructed. To handle insertions too the rule order number
s would need to be updated. | 208 // needs to be reconstructed. To handle insertions too the rule order number
s would need to be updated. |
| 209 for (const auto& styleSheet : styleSheets) | 209 for (const auto& styleSheet : styleSheets) |
| 210 appendCSSStyleSheet(*styleSheet); | 210 appendCSSStyleSheet(*styleSheet); |
| 211 } | 211 } |
| 212 | 212 |
| 213 void StyleResolver::finishAppendAuthorStyleSheets() | 213 void StyleResolver::finishAppendAuthorStyleSheets() |
| 214 { | 214 { |
| 215 collectFeatures(); | 215 collectFeatures(); |
| 216 | 216 |
| 217 if (document().layoutView() && document().layoutView()->style()) | 217 if (document().layoutView() && document().layoutView()->style()) |
| 218 document().layoutView()->style()->font().update(document().styleEngine()
->fontSelector()); | 218 document().layoutView()->style()->font().update(document().styleEngine()
.fontSelector()); |
| 219 | 219 |
| 220 collectViewportRules(); | 220 collectViewportRules(); |
| 221 | 221 |
| 222 document().styleEngine()->resetCSSFeatureFlags(m_features); | 222 document().styleEngine().resetCSSFeatureFlags(m_features); |
| 223 } | 223 } |
| 224 | 224 |
| 225 void StyleResolver::resetRuleFeatures() | 225 void StyleResolver::resetRuleFeatures() |
| 226 { | 226 { |
| 227 // Need to recreate RuleFeatureSet. | 227 // Need to recreate RuleFeatureSet. |
| 228 m_features.clear(); | 228 m_features.clear(); |
| 229 m_siblingRuleSet.clear(); | 229 m_siblingRuleSet.clear(); |
| 230 m_uncommonAttributeRuleSet.clear(); | 230 m_uncommonAttributeRuleSet.clear(); |
| 231 m_needCollectFeatures = true; | 231 m_needCollectFeatures = true; |
| 232 } | 232 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 | 276 |
| 277 if (document().isViewSource()) | 277 if (document().isViewSource()) |
| 278 m_features.add(defaultStyleSheets.defaultViewSourceStyle()->features()); | 278 m_features.add(defaultStyleSheets.defaultViewSourceStyle()->features()); |
| 279 | 279 |
| 280 if (document().isTransitionDocument()) | 280 if (document().isTransitionDocument()) |
| 281 m_features.add(defaultStyleSheets.defaultTransitionStyle()->features()); | 281 m_features.add(defaultStyleSheets.defaultTransitionStyle()->features()); |
| 282 | 282 |
| 283 if (m_watchedSelectorsRules) | 283 if (m_watchedSelectorsRules) |
| 284 m_features.add(m_watchedSelectorsRules->features()); | 284 m_features.add(m_watchedSelectorsRules->features()); |
| 285 | 285 |
| 286 document().styleEngine()->collectScopedStyleFeaturesTo(m_features); | 286 document().styleEngine().collectScopedStyleFeaturesTo(m_features); |
| 287 | 287 |
| 288 m_siblingRuleSet = makeRuleSet(m_features.siblingRules); | 288 m_siblingRuleSet = makeRuleSet(m_features.siblingRules); |
| 289 m_uncommonAttributeRuleSet = makeRuleSet(m_features.uncommonAttributeRules); | 289 m_uncommonAttributeRuleSet = makeRuleSet(m_features.uncommonAttributeRules); |
| 290 m_needCollectFeatures = false; | 290 m_needCollectFeatures = false; |
| 291 } | 291 } |
| 292 | 292 |
| 293 bool StyleResolver::hasRulesForId(const AtomicString& id) const | 293 bool StyleResolver::hasRulesForId(const AtomicString& id) const |
| 294 { | 294 { |
| 295 return m_features.hasSelectorForId(id); | 295 return m_features.hasSelectorForId(id); |
| 296 } | 296 } |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 void StyleResolver::adjustLayoutStyle(StyleResolverState& state, Element* elemen
t) | 517 void StyleResolver::adjustLayoutStyle(StyleResolverState& state, Element* elemen
t) |
| 518 { | 518 { |
| 519 StyleAdjuster adjuster(document().inQuirksMode()); | 519 StyleAdjuster adjuster(document().inQuirksMode()); |
| 520 adjuster.adjustLayoutStyle(state.mutableStyleRef(), *state.parentStyle(), el
ement, authorStyleInfo(state)); | 520 adjuster.adjustLayoutStyle(state.mutableStyleRef(), *state.parentStyle(), el
ement, authorStyleInfo(state)); |
| 521 } | 521 } |
| 522 | 522 |
| 523 // Start loading resources referenced by this style. | 523 // Start loading resources referenced by this style. |
| 524 void StyleResolver::loadPendingResources(StyleResolverState& state) | 524 void StyleResolver::loadPendingResources(StyleResolverState& state) |
| 525 { | 525 { |
| 526 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle
Resources()); | 526 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle
Resources()); |
| 527 document().styleEngine()->fontSelector()->fontLoader()->loadPendingFonts(); | 527 document().styleEngine().fontSelector()->fontLoader()->loadPendingFonts(); |
| 528 } | 528 } |
| 529 | 529 |
| 530 PassRefPtr<LayoutStyle> StyleResolver::styleForElement(Element* element, LayoutS
tyle* defaultParent, StyleSharingBehavior sharingBehavior, | 530 PassRefPtr<LayoutStyle> StyleResolver::styleForElement(Element* element, LayoutS
tyle* defaultParent, StyleSharingBehavior sharingBehavior, |
| 531 RuleMatchingBehavior matchingBehavior) | 531 RuleMatchingBehavior matchingBehavior) |
| 532 { | 532 { |
| 533 ASSERT(document().frame()); | 533 ASSERT(document().frame()); |
| 534 ASSERT(document().settings()); | 534 ASSERT(document().settings()); |
| 535 ASSERT(!hasPendingAuthorStyleSheets()); | 535 ASSERT(!hasPendingAuthorStyleSheets()); |
| 536 ASSERT(!m_needCollectFeatures); | 536 ASSERT(!m_needCollectFeatures); |
| 537 | 537 |
| 538 // Once an element has a renderer, we don't try to destroy it, since otherwi
se the renderer | 538 // Once an element has a renderer, we don't try to destroy it, since otherwi
se the renderer |
| 539 // will vanish if a style recalc happens during loading. | 539 // will vanish if a style recalc happens during loading. |
| 540 if (sharingBehavior == AllowStyleSharing && !document().isRenderingReady() &
& !element->renderer()) { | 540 if (sharingBehavior == AllowStyleSharing && !document().isRenderingReady() &
& !element->renderer()) { |
| 541 if (!s_styleNotYetAvailable) { | 541 if (!s_styleNotYetAvailable) { |
| 542 s_styleNotYetAvailable = LayoutStyle::create().leakRef(); | 542 s_styleNotYetAvailable = LayoutStyle::create().leakRef(); |
| 543 s_styleNotYetAvailable->setDisplay(NONE); | 543 s_styleNotYetAvailable->setDisplay(NONE); |
| 544 s_styleNotYetAvailable->font().update(document().styleEngine()->font
Selector()); | 544 s_styleNotYetAvailable->font().update(document().styleEngine().fontS
elector()); |
| 545 } | 545 } |
| 546 | 546 |
| 547 document().setHasNodesWithPlaceholderStyle(); | 547 document().setHasNodesWithPlaceholderStyle(); |
| 548 return s_styleNotYetAvailable; | 548 return s_styleNotYetAvailable; |
| 549 } | 549 } |
| 550 | 550 |
| 551 didAccess(); | 551 didAccess(); |
| 552 | 552 |
| 553 StyleResolverParentScope::ensureParentStackIsPushed(); | 553 StyleResolverParentScope::ensureParentStackIsPushed(); |
| 554 | 554 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 696 style = LayoutStyle::create(); | 696 style = LayoutStyle::create(); |
| 697 StyleResolverState state(element.document(), &element); | 697 StyleResolverState state(element.document(), &element); |
| 698 state.setStyle(style); | 698 state.setStyle(style); |
| 699 return createAnimatableValueSnapshot(state, property, value); | 699 return createAnimatableValueSnapshot(state, property, value); |
| 700 } | 700 } |
| 701 | 701 |
| 702 PassRefPtrWillBeRawPtr<AnimatableValue> StyleResolver::createAnimatableValueSnap
shot(StyleResolverState& state, CSSPropertyID property, CSSValue* value) | 702 PassRefPtrWillBeRawPtr<AnimatableValue> StyleResolver::createAnimatableValueSnap
shot(StyleResolverState& state, CSSPropertyID property, CSSValue* value) |
| 703 { | 703 { |
| 704 if (value) { | 704 if (value) { |
| 705 StyleBuilder::applyProperty(property, state, value); | 705 StyleBuilder::applyProperty(property, state, value); |
| 706 state.fontBuilder().createFont(state.document().styleEngine()->fontSelec
tor(), state.mutableStyleRef()); | 706 state.fontBuilder().createFont(state.document().styleEngine().fontSelect
or(), state.mutableStyleRef()); |
| 707 } | 707 } |
| 708 return CSSAnimatableValueFactory::create(property, *state.style()); | 708 return CSSAnimatableValueFactory::create(property, *state.style()); |
| 709 } | 709 } |
| 710 | 710 |
| 711 PassRefPtrWillBeRawPtr<PseudoElement> StyleResolver::createPseudoElement(Element
* parent, PseudoId pseudoId) | 711 PassRefPtrWillBeRawPtr<PseudoElement> StyleResolver::createPseudoElement(Element
* parent, PseudoId pseudoId) |
| 712 { | 712 { |
| 713 if (pseudoId == FIRST_LETTER) | 713 if (pseudoId == FIRST_LETTER) |
| 714 return FirstLetterPseudoElement::create(parent); | 714 return FirstLetterPseudoElement::create(parent); |
| 715 return PseudoElement::create(parent, pseudoId); | 715 return PseudoElement::create(parent, pseudoId); |
| 716 } | 716 } |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 900 scopedResolver->collectViewportRulesTo(this); | 900 scopedResolver->collectViewportRulesTo(this); |
| 901 | 901 |
| 902 viewportStyleResolver()->resolve(); | 902 viewportStyleResolver()->resolve(); |
| 903 } | 903 } |
| 904 | 904 |
| 905 PassRefPtr<LayoutStyle> StyleResolver::defaultStyleForElement() | 905 PassRefPtr<LayoutStyle> StyleResolver::defaultStyleForElement() |
| 906 { | 906 { |
| 907 RefPtr<LayoutStyle> style = LayoutStyle::create(); | 907 RefPtr<LayoutStyle> style = LayoutStyle::create(); |
| 908 FontBuilder fontBuilder(document()); | 908 FontBuilder fontBuilder(document()); |
| 909 fontBuilder.setInitial(style->effectiveZoom()); | 909 fontBuilder.setInitial(style->effectiveZoom()); |
| 910 fontBuilder.createFont(document().styleEngine()->fontSelector(), *style); | 910 fontBuilder.createFont(document().styleEngine().fontSelector(), *style); |
| 911 return style.release(); | 911 return style.release(); |
| 912 } | 912 } |
| 913 | 913 |
| 914 PassRefPtr<LayoutStyle> StyleResolver::styleForText(Text* textNode) | 914 PassRefPtr<LayoutStyle> StyleResolver::styleForText(Text* textNode) |
| 915 { | 915 { |
| 916 ASSERT(textNode); | 916 ASSERT(textNode); |
| 917 | 917 |
| 918 Node* parentNode = NodeRenderingTraversal::parent(*textNode); | 918 Node* parentNode = NodeRenderingTraversal::parent(*textNode); |
| 919 if (!parentNode || !parentNode->layoutStyle()) | 919 if (!parentNode || !parentNode->layoutStyle()) |
| 920 return defaultStyleForElement(); | 920 return defaultStyleForElement(); |
| 921 return parentNode->layoutStyle(); | 921 return parentNode->layoutStyle(); |
| 922 } | 922 } |
| 923 | 923 |
| 924 void StyleResolver::updateFont(StyleResolverState& state) | 924 void StyleResolver::updateFont(StyleResolverState& state) |
| 925 { | 925 { |
| 926 state.fontBuilder().createFont(document().styleEngine()->fontSelector(), sta
te.mutableStyleRef()); | 926 state.fontBuilder().createFont(document().styleEngine().fontSelector(), stat
e.mutableStyleRef()); |
| 927 state.setConversionFontSizes(CSSToLengthConversionData::FontSizes(state.styl
e(), state.rootElementStyle())); | 927 state.setConversionFontSizes(CSSToLengthConversionData::FontSizes(state.styl
e(), state.rootElementStyle())); |
| 928 state.setConversionZoom(state.style()->effectiveZoom()); | 928 state.setConversionZoom(state.style()->effectiveZoom()); |
| 929 } | 929 } |
| 930 | 930 |
| 931 PassRefPtrWillBeRawPtr<StyleRuleList> StyleResolver::styleRulesForElement(Elemen
t* element, unsigned rulesToInclude) | 931 PassRefPtrWillBeRawPtr<StyleRuleList> StyleResolver::styleRulesForElement(Elemen
t* element, unsigned rulesToInclude) |
| 932 { | 932 { |
| 933 ASSERT(element); | 933 ASSERT(element); |
| 934 StyleResolverState state(document(), element); | 934 StyleResolverState state(document(), element); |
| 935 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, sta
te.style()); | 935 ElementRuleCollector collector(state.elementContext(), m_selectorFilter, sta
te.style()); |
| 936 collector.setMode(SelectorChecker::CollectingStyleRules); | 936 collector.setMode(SelectorChecker::CollectingStyleRules); |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1515 visitor->trace(m_uncommonAttributeRuleSet); | 1515 visitor->trace(m_uncommonAttributeRuleSet); |
| 1516 visitor->trace(m_watchedSelectorsRules); | 1516 visitor->trace(m_watchedSelectorsRules); |
| 1517 visitor->trace(m_treeBoundaryCrossingRules); | 1517 visitor->trace(m_treeBoundaryCrossingRules); |
| 1518 visitor->trace(m_styleSharingLists); | 1518 visitor->trace(m_styleSharingLists); |
| 1519 visitor->trace(m_pendingStyleSheets); | 1519 visitor->trace(m_pendingStyleSheets); |
| 1520 visitor->trace(m_document); | 1520 visitor->trace(m_document); |
| 1521 #endif | 1521 #endif |
| 1522 } | 1522 } |
| 1523 | 1523 |
| 1524 } // namespace blink | 1524 } // namespace blink |
| OLD | NEW |