Chromium Code Reviews| 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 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 622 document.setDirectionSetOnDocumentElement(false); | 622 document.setDirectionSetOnDocumentElement(false); |
| 623 document.setWritingModeSetOnDocumentElement(false); | 623 document.setWritingModeSetOnDocumentElement(false); |
| 624 } | 624 } |
| 625 | 625 |
| 626 static void addContentAttrValuesToFeatures(const Vector<AtomicString>& contentAt trValues, RuleFeatureSet& features) | 626 static void addContentAttrValuesToFeatures(const Vector<AtomicString>& contentAt trValues, RuleFeatureSet& features) |
| 627 { | 627 { |
| 628 for (size_t i = 0; i < contentAttrValues.size(); ++i) | 628 for (size_t i = 0; i < contentAttrValues.size(); ++i) |
| 629 features.addAttributeInASelector(contentAttrValues[i]); | 629 features.addAttributeInASelector(contentAttrValues[i]); |
| 630 } | 630 } |
| 631 | 631 |
| 632 // Start loading resources referenced by this style. | |
| 633 void StyleResolver::loadPendingResources(StyleResolverState& state) | |
| 634 { | |
| 635 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle Resources()); | |
| 636 document().styleEngine()->fontSelector()->loadPendingFonts(); | |
| 637 } | |
| 638 | |
| 632 PassRefPtr<RenderStyle> StyleResolver::styleForElement(Element* element, RenderS tyle* defaultParent, StyleSharingBehavior sharingBehavior, | 639 PassRefPtr<RenderStyle> StyleResolver::styleForElement(Element* element, RenderS tyle* defaultParent, StyleSharingBehavior sharingBehavior, |
| 633 RuleMatchingBehavior matchingBehavior) | 640 RuleMatchingBehavior matchingBehavior) |
| 634 { | 641 { |
| 635 ASSERT(document().frame()); | 642 ASSERT(document().frame()); |
| 636 ASSERT(documentSettings()); | 643 ASSERT(documentSettings()); |
| 637 ASSERT(!hasPendingAuthorStyleSheets()); | 644 ASSERT(!hasPendingAuthorStyleSheets()); |
| 638 ASSERT(!m_needCollectFeatures); | 645 ASSERT(!m_needCollectFeatures); |
| 639 | 646 |
| 640 // Once an element has a renderer, we don't try to destroy it, since otherwi se the renderer | 647 // Once an element has a renderer, we don't try to destroy it, since otherwi se the renderer |
| 641 // will vanish if a style recalc happens during loading. | 648 // will vanish if a style recalc happens during loading. |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 776 if (state.lineHeightValue()) | 783 if (state.lineHeightValue()) |
| 777 StyleBuilder::applyProperty(CSSPropertyLineHeight, state, state.lineHeig htValue()); | 784 StyleBuilder::applyProperty(CSSPropertyLineHeight, state, state.lineHeig htValue()); |
| 778 | 785 |
| 779 // Now do rest of the properties. | 786 // Now do rest of the properties. |
| 780 applyMatchedProperties<LowPriorityProperties>(state, result, false, 0, resul t.matchedProperties.size() - 1, inheritedOnly); | 787 applyMatchedProperties<LowPriorityProperties>(state, result, false, 0, resul t.matchedProperties.size() - 1, inheritedOnly); |
| 781 | 788 |
| 782 // If our font got dirtied by one of the non-essential font props, | 789 // If our font got dirtied by one of the non-essential font props, |
| 783 // go ahead and update it a second time. | 790 // go ahead and update it a second time. |
| 784 updateFont(state); | 791 updateFont(state); |
| 785 | 792 |
| 786 // Start loading resources referenced by this style. | 793 loadPendingResources(state); |
| 787 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle Resources()); | |
| 788 document().styleEngine()->fontSelector()->loadPendingFonts(); | |
| 789 | 794 |
| 790 didAccess(); | 795 didAccess(); |
| 791 | 796 |
| 792 return state.takeStyle(); | 797 return state.takeStyle(); |
| 793 } | 798 } |
| 794 | 799 |
| 795 // This function is used by the WebAnimations JavaScript API method animate(). | 800 // This function is used by the WebAnimations JavaScript API method animate(). |
| 796 // FIXME: Remove this when animate() switches away from resolution-dependent par sing. | 801 // FIXME: Remove this when animate() switches away from resolution-dependent par sing. |
| 797 PassRefPtrWillBeRawPtr<KeyframeEffectModel> StyleResolver::createKeyframeEffectM odel(Element& element, const Vector<RefPtr<MutableStylePropertySet> >& propertyS etVector, KeyframeEffectModel::KeyframeVector& keyframes) | 802 PassRefPtrWillBeRawPtr<KeyframeEffectModel> StyleResolver::createKeyframeEffectM odel(Element& element, const Vector<RefPtr<MutableStylePropertySet> >& propertyS etVector, KeyframeEffectModel::KeyframeVector& keyframes) |
| 798 { | 803 { |
| 799 ASSERT(propertySetVector.size() == keyframes.size()); | 804 ASSERT(propertySetVector.size() == keyframes.size()); |
| 800 | 805 |
| 801 StyleResolverState state(element.document(), &element); | 806 StyleResolverState state(element.document(), &element); |
| 802 state.setStyle(RenderStyle::create()); | 807 state.setStyle(RenderStyle::create()); |
| 803 | 808 |
| 804 for (unsigned i = 0; i < propertySetVector.size(); ++i) { | 809 for (unsigned i = 0; i < propertySetVector.size(); ++i) { |
| 805 for (unsigned j = 0; j < propertySetVector[i]->propertyCount(); ++j) { | 810 for (unsigned j = 0; j < propertySetVector[i]->propertyCount(); ++j) { |
| 806 CSSPropertyID id = propertySetVector[i]->propertyAt(j).id(); | 811 CSSPropertyID id = propertySetVector[i]->propertyAt(j).id(); |
| 807 StyleBuilder::applyProperty(id, state, propertySetVector[i]->getProp ertyCSSValue(id).get()); | 812 StyleBuilder::applyProperty(id, state, propertySetVector[i]->getProp ertyCSSValue(id).get()); |
| 808 keyframes[i]->setPropertyValue(id, CSSAnimatableValueFactory::create (id, *state.style()).get()); | 813 keyframes[i]->setPropertyValue(id, CSSAnimatableValueFactory::create (id, *state.style()).get()); |
| 809 } | 814 } |
| 810 } | 815 } |
| 816 | |
| 811 return KeyframeEffectModel::create(keyframes); | 817 return KeyframeEffectModel::create(keyframes); |
| 812 } | 818 } |
| 813 | 819 |
| 814 PassRefPtr<PseudoElement> StyleResolver::createPseudoElementIfNeeded(Element& pa rent, PseudoId pseudoId) | 820 PassRefPtr<PseudoElement> StyleResolver::createPseudoElementIfNeeded(Element& pa rent, PseudoId pseudoId) |
| 815 { | 821 { |
| 816 RenderObject* parentRenderer = parent.renderer(); | 822 RenderObject* parentRenderer = parent.renderer(); |
| 817 if (!parentRenderer) | 823 if (!parentRenderer) |
| 818 return nullptr; | 824 return nullptr; |
| 819 | 825 |
| 820 if (pseudoId < FIRST_INTERNAL_PSEUDOID && !parentRenderer->style()->hasPseud oStyle(pseudoId)) | 826 if (pseudoId < FIRST_INTERNAL_PSEUDOID && !parentRenderer->style()->hasPseud oStyle(pseudoId)) |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 948 updateFont(state); | 954 updateFont(state); |
| 949 | 955 |
| 950 // Line-height is set when we are sure we decided on the font-size. | 956 // Line-height is set when we are sure we decided on the font-size. |
| 951 if (state.lineHeightValue()) | 957 if (state.lineHeightValue()) |
| 952 StyleBuilder::applyProperty(CSSPropertyLineHeight, state, state.lineHeig htValue()); | 958 StyleBuilder::applyProperty(CSSPropertyLineHeight, state, state.lineHeig htValue()); |
| 953 | 959 |
| 954 applyMatchedProperties<LowPriorityProperties>(state, result, false, 0, resul t.matchedProperties.size() - 1, inheritedOnly); | 960 applyMatchedProperties<LowPriorityProperties>(state, result, false, 0, resul t.matchedProperties.size() - 1, inheritedOnly); |
| 955 | 961 |
| 956 addContentAttrValuesToFeatures(state.contentAttrValues(), m_features); | 962 addContentAttrValuesToFeatures(state.contentAttrValues(), m_features); |
| 957 | 963 |
| 958 // Start loading resources referenced by this style. | 964 loadPendingResources(state); |
| 959 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle Resources()); | |
| 960 document().styleEngine()->fontSelector()->loadPendingFonts(); | |
| 961 | 965 |
| 962 didAccess(); | 966 didAccess(); |
| 963 | 967 |
| 964 // Now return the style. | 968 // Now return the style. |
| 965 return state.takeStyle(); | 969 return state.takeStyle(); |
| 966 } | 970 } |
| 967 | 971 |
| 968 void StyleResolver::collectViewportRules() | 972 void StyleResolver::collectViewportRules() |
| 969 { | 973 { |
| 970 CSSDefaultStyleSheets& defaultStyleSheets = CSSDefaultStyleSheets::instance( ); | 974 CSSDefaultStyleSheets& defaultStyleSheets = CSSDefaultStyleSheets::instance( ); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1078 applyAnimatedProperties<HighPriorityProperties>(state, compositableValuesFor Transitions); | 1082 applyAnimatedProperties<HighPriorityProperties>(state, compositableValuesFor Transitions); |
| 1079 applyAnimatedProperties<LowPriorityProperties>(state, compositableValuesForA nimations); | 1083 applyAnimatedProperties<LowPriorityProperties>(state, compositableValuesForA nimations); |
| 1080 applyAnimatedProperties<LowPriorityProperties>(state, compositableValuesForT ransitions); | 1084 applyAnimatedProperties<LowPriorityProperties>(state, compositableValuesForT ransitions); |
| 1081 | 1085 |
| 1082 // If the animations/transitions change opacity or transform, we need to upd ate | 1086 // If the animations/transitions change opacity or transform, we need to upd ate |
| 1083 // the style to impose the stacking rules. Note that this is also | 1087 // the style to impose the stacking rules. Note that this is also |
| 1084 // done in StyleResolver::adjustRenderStyle(). | 1088 // done in StyleResolver::adjustRenderStyle(). |
| 1085 RenderStyle* style = state.style(); | 1089 RenderStyle* style = state.style(); |
| 1086 if (style->hasAutoZIndex() && (style->opacity() < 1.0f || style->hasTransfor m())) | 1090 if (style->hasAutoZIndex() && (style->opacity() < 1.0f || style->hasTransfor m())) |
| 1087 style->setZIndex(0); | 1091 style->setZIndex(0); |
| 1092 | |
| 1093 // Start loading resources used by animations. | |
| 1094 loadPendingResources(state); | |
|
esprehn
2014/03/18 02:58:56
The callers of this should do this? It seems like
alancutter (OOO until 2018)
2014/03/18 03:54:31
I put it inside applyAnimatedProperties() to match
| |
| 1088 } | 1095 } |
| 1089 | 1096 |
| 1090 template <StyleResolver::StyleApplicationPass pass> | 1097 template <StyleResolver::StyleApplicationPass pass> |
| 1091 void StyleResolver::applyAnimatedProperties(StyleResolverState& state, const Ani mationEffect::CompositableValueMap& compositableValues) | 1098 void StyleResolver::applyAnimatedProperties(StyleResolverState& state, const Ani mationEffect::CompositableValueMap& compositableValues) |
| 1092 { | 1099 { |
| 1093 ASSERT(pass != AnimationProperties); | 1100 ASSERT(pass != AnimationProperties); |
| 1094 | 1101 |
| 1095 for (AnimationEffect::CompositableValueMap::const_iterator iter = compositab leValues.begin(); iter != compositableValues.end(); ++iter) { | 1102 for (AnimationEffect::CompositableValueMap::const_iterator iter = compositab leValues.begin(); iter != compositableValues.end(); ++iter) { |
| 1096 CSSPropertyID property = iter->key; | 1103 CSSPropertyID property = iter->key; |
| 1097 if (!isPropertyForPass<pass>(property)) | 1104 if (!isPropertyForPass<pass>(property)) |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1322 | 1329 |
| 1323 // Cache the UA properties to pass them to RenderTheme in adjustRenderStyle. | 1330 // Cache the UA properties to pass them to RenderTheme in adjustRenderStyle. |
| 1324 state.cacheUserAgentBorderAndBackground(); | 1331 state.cacheUserAgentBorderAndBackground(); |
| 1325 | 1332 |
| 1326 // Now do the author and user normal priority properties and all the !import ant properties. | 1333 // Now do the author and user normal priority properties and all the !import ant properties. |
| 1327 applyMatchedProperties<LowPriorityProperties>(state, matchResult, false, mat chResult.ranges.lastUARule + 1, matchResult.matchedProperties.size() - 1, applyI nheritedOnly); | 1334 applyMatchedProperties<LowPriorityProperties>(state, matchResult, false, mat chResult.ranges.lastUARule + 1, matchResult.matchedProperties.size() - 1, applyI nheritedOnly); |
| 1328 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc hResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInherite dOnly); | 1335 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc hResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInherite dOnly); |
| 1329 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc hResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnl y); | 1336 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc hResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnl y); |
| 1330 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc hResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); | 1337 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc hResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); |
| 1331 | 1338 |
| 1332 // Start loading resources referenced by this style. | 1339 loadPendingResources(state); |
| 1333 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle Resources()); | |
| 1334 document().styleEngine()->fontSelector()->loadPendingFonts(); | |
| 1335 | 1340 |
| 1336 if (!cachedMatchedProperties && cacheHash && MatchedPropertiesCache::isCache able(element, state.style(), state.parentStyle())) { | 1341 if (!cachedMatchedProperties && cacheHash && MatchedPropertiesCache::isCache able(element, state.style(), state.parentStyle())) { |
| 1337 INCREMENT_STYLE_STATS_COUNTER(*this, matchedPropertyCacheAdded); | 1342 INCREMENT_STYLE_STATS_COUNTER(*this, matchedPropertyCacheAdded); |
| 1338 m_matchedPropertiesCache.add(state.style(), state.parentStyle(), cacheHa sh, matchResult); | 1343 m_matchedPropertiesCache.add(state.style(), state.parentStyle(), cacheHa sh, matchResult); |
| 1339 } | 1344 } |
| 1340 | 1345 |
| 1341 ASSERT(!state.fontBuilder().fontDirty()); | 1346 ASSERT(!state.fontBuilder().fontDirty()); |
| 1342 } | 1347 } |
| 1343 | 1348 |
| 1344 CSSPropertyValue::CSSPropertyValue(CSSPropertyID id, const StylePropertySet& pro pertySet) | 1349 CSSPropertyValue::CSSPropertyValue(CSSPropertyID id, const StylePropertySet& pro pertySet) |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1408 bool StyleResolver::mediaQueryAffectedByViewportChange() const | 1413 bool StyleResolver::mediaQueryAffectedByViewportChange() const |
| 1409 { | 1414 { |
| 1410 for (unsigned i = 0; i < m_viewportDependentMediaQueryResults.size(); ++i) { | 1415 for (unsigned i = 0; i < m_viewportDependentMediaQueryResults.size(); ++i) { |
| 1411 if (m_medium->eval(&m_viewportDependentMediaQueryResults[i]->m_expressio n) != m_viewportDependentMediaQueryResults[i]->m_result) | 1416 if (m_medium->eval(&m_viewportDependentMediaQueryResults[i]->m_expressio n) != m_viewportDependentMediaQueryResults[i]->m_result) |
| 1412 return true; | 1417 return true; |
| 1413 } | 1418 } |
| 1414 return false; | 1419 return false; |
| 1415 } | 1420 } |
| 1416 | 1421 |
| 1417 } // namespace WebCore | 1422 } // namespace WebCore |
| OLD | NEW |