Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(482)

Side by Side Diff: Source/core/css/resolver/StyleResolver.cpp

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

Powered by Google App Engine
This is Rietveld 408576698