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

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

Issue 19266007: Web Animations: Introduce ActiveAnimations and AnimationStack (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Removed maps. Store ActiveAnimations in ElementRareData. Created 7 years, 5 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 19 matching lines...) Expand all
30 #include "core/css/resolver/StyleResolver.h" 30 #include "core/css/resolver/StyleResolver.h"
31 31
32 // FIXME: This include list is way more than we need! 32 // FIXME: This include list is way more than we need!
33 #include "CSSPropertyNames.h" 33 #include "CSSPropertyNames.h"
34 #include "HTMLNames.h" 34 #include "HTMLNames.h"
35 #include "RuntimeEnabledFeatures.h" 35 #include "RuntimeEnabledFeatures.h"
36 #include "SVGNames.h" 36 #include "SVGNames.h"
37 #include "XMLNames.h" 37 #include "XMLNames.h"
38 #include "core/animation/AnimatableValue.h" 38 #include "core/animation/AnimatableValue.h"
39 #include "core/animation/Animation.h" 39 #include "core/animation/Animation.h"
40 #include "core/animation/DocumentTimeline.h"
40 #include "core/css/CSSCalculationValue.h" 41 #include "core/css/CSSCalculationValue.h"
41 #include "core/css/CSSCursorImageValue.h" 42 #include "core/css/CSSCursorImageValue.h"
42 #include "core/css/CSSDefaultStyleSheets.h" 43 #include "core/css/CSSDefaultStyleSheets.h"
43 #include "core/css/CSSFontSelector.h" 44 #include "core/css/CSSFontSelector.h"
44 #include "core/css/CSSImageSetValue.h" 45 #include "core/css/CSSImageSetValue.h"
45 #include "core/css/CSSKeyframeRule.h" 46 #include "core/css/CSSKeyframeRule.h"
46 #include "core/css/CSSKeyframesRule.h" 47 #include "core/css/CSSKeyframesRule.h"
47 #include "core/css/CSSLineBoxContainValue.h" 48 #include "core/css/CSSLineBoxContainValue.h"
48 #include "core/css/CSSParser.h" 49 #include "core/css/CSSParser.h"
49 #include "core/css/CSSPrimitiveValueMappings.h" 50 #include "core/css/CSSPrimitiveValueMappings.h"
(...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after
1049 matchAuthorRules(collector, rulesToInclude & EmptyCSSRules); 1050 matchAuthorRules(collector, rulesToInclude & EmptyCSSRules);
1050 } 1051 }
1051 1052
1052 return collector.matchedRuleList(); 1053 return collector.matchedRuleList();
1053 } 1054 }
1054 1055
1055 // ----------------------------------------------------------------------------- -------- 1056 // ----------------------------------------------------------------------------- --------
1056 // this is mostly boring stuff on how to apply a certain rule to the renderstyle ... 1057 // this is mostly boring stuff on how to apply a certain rule to the renderstyle ...
1057 1058
1058 template <StyleResolver::StyleApplicationPass pass> 1059 template <StyleResolver::StyleApplicationPass pass>
1059 void StyleResolver::applyAnimatedProperties(const Element* target) 1060 void StyleResolver::applyAnimatedProperties(const Element* target, const Documen tTimeline* timeline)
1060 { 1061 {
1061 ASSERT(pass != VariableDefinitions); 1062 ASSERT(pass != VariableDefinitions);
1062 ASSERT(pass != AnimationProperties); 1063 ASSERT(pass != AnimationProperties);
1063 if (!target->hasActiveAnimations()) 1064 AnimationStack* animationStack = timeline->animationStack(target);
1065 if (!animationStack)
1064 return; 1066 return;
1067 const Vector<Animation*>& animations = animationStack->activeAnimations(targ et);
1065 1068
1066 Vector<Animation*>* animations = target->activeAnimations(); 1069 for (size_t i = 0; i < animations.size(); ++i) {
1067 1070 RefPtr<Animation> animation = animations.at(i);
1068 for (size_t i = 0; i < animations->size(); ++i) {
1069 RefPtr<Animation> animation = animations->at(i);
1070 const AnimationEffect::CompositableValueMap* compositableValues = animat ion->compositableValues(); 1071 const AnimationEffect::CompositableValueMap* compositableValues = animat ion->compositableValues();
1071 for (AnimationEffect::CompositableValueMap::const_iterator iter = compos itableValues->begin(); iter != compositableValues->end(); ++iter) { 1072 for (AnimationEffect::CompositableValueMap::const_iterator iter = compos itableValues->begin(); iter != compositableValues->end(); ++iter) {
1072 CSSPropertyID property = iter->key; 1073 CSSPropertyID property = iter->key;
1073 if (!isPropertyForPass<pass>(property)) 1074 if (!isPropertyForPass<pass>(property))
1074 continue; 1075 continue;
1075 RefPtr<CSSValue> value = iter->value->compositeOnto(AnimatableValue: :neutralValue())->toCSSValue(); 1076 RefPtr<CSSValue> value = iter->value->compositeOnto(AnimatableValue: :neutralValue())->toCSSValue();
1076 if (pass == HighPriorityProperties && property == CSSPropertyLineHei ght) 1077 if (pass == HighPriorityProperties && property == CSSPropertyLineHei ght)
1077 m_state.setLineHeightValue(value.get()); 1078 m_state.setLineHeightValue(value.get());
1078 else 1079 else
1079 applyProperty(property, value.get()); 1080 applyProperty(property, value.get());
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
1299 // FIXME: animations should be triggered here 1300 // FIXME: animations should be triggered here
1300 1301
1301 // Now we have all of the matched rules in the appropriate order. Walk the r ules and apply 1302 // Now we have all of the matched rules in the appropriate order. Walk the r ules and apply
1302 // high-priority properties first, i.e., those properties that other propert ies depend on. 1303 // high-priority properties first, i.e., those properties that other propert ies depend on.
1303 // The order is (1) high-priority not important, (2) high-priority important , (3) normal not important 1304 // The order is (1) high-priority not important, (2) high-priority important , (3) normal not important
1304 // and (4) normal important. 1305 // and (4) normal important.
1305 state.setLineHeightValue(0); 1306 state.setLineHeightValue(0);
1306 applyMatchedProperties<HighPriorityProperties>(matchResult, false, 0, matchR esult.matchedProperties.size() - 1, applyInheritedOnly); 1307 applyMatchedProperties<HighPriorityProperties>(matchResult, false, 0, matchR esult.matchedProperties.size() - 1, applyInheritedOnly);
1307 // Animation contributions are processed here because CSS Animations are ove rridable by user !important rules. 1308 // Animation contributions are processed here because CSS Animations are ove rridable by user !important rules.
1308 if (RuntimeEnabledFeatures::webAnimationsEnabled()) 1309 if (RuntimeEnabledFeatures::webAnimationsEnabled())
1309 applyAnimatedProperties<HighPriorityProperties>(element); 1310 applyAnimatedProperties<HighPriorityProperties>(element, element->docume nt()->timeline());
1310 applyMatchedProperties<HighPriorityProperties>(matchResult, true, matchResul t.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly) ; 1311 applyMatchedProperties<HighPriorityProperties>(matchResult, true, matchResul t.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly) ;
1311 applyMatchedProperties<HighPriorityProperties>(matchResult, true, matchResul t.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly); 1312 applyMatchedProperties<HighPriorityProperties>(matchResult, true, matchResul t.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly);
1312 applyMatchedProperties<HighPriorityProperties>(matchResult, true, matchResul t.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); 1313 applyMatchedProperties<HighPriorityProperties>(matchResult, true, matchResul t.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly);
1313 1314
1314 if (cachedMatchedProperties && cachedMatchedProperties->renderStyle->effecti veZoom() != state.style()->effectiveZoom()) { 1315 if (cachedMatchedProperties && cachedMatchedProperties->renderStyle->effecti veZoom() != state.style()->effectiveZoom()) {
1315 state.fontBuilder().setFontDirty(true); 1316 state.fontBuilder().setFontDirty(true);
1316 applyInheritedOnly = false; 1317 applyInheritedOnly = false;
1317 } 1318 }
1318 1319
1319 // If our font got dirtied, go ahead and update it now. 1320 // If our font got dirtied, go ahead and update it now.
1320 updateFont(); 1321 updateFont();
1321 1322
1322 // Line-height is set when we are sure we decided on the font-size. 1323 // Line-height is set when we are sure we decided on the font-size.
1323 if (state.lineHeightValue()) 1324 if (state.lineHeightValue())
1324 applyProperty(CSSPropertyLineHeight, state.lineHeightValue()); 1325 applyProperty(CSSPropertyLineHeight, state.lineHeightValue());
1325 1326
1326 // Many properties depend on the font. If it changes we just apply all prope rties. 1327 // Many properties depend on the font. If it changes we just apply all prope rties.
1327 if (cachedMatchedProperties && cachedMatchedProperties->renderStyle->fontDes cription() != state.style()->fontDescription()) 1328 if (cachedMatchedProperties && cachedMatchedProperties->renderStyle->fontDes cription() != state.style()->fontDescription())
1328 applyInheritedOnly = false; 1329 applyInheritedOnly = false;
1329 1330
1330 // Now do the normal priority UA properties. 1331 // Now do the normal priority UA properties.
1331 applyMatchedProperties<LowPriorityProperties>(matchResult, false, matchResul t.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); 1332 applyMatchedProperties<LowPriorityProperties>(matchResult, false, matchResul t.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly);
1332 1333
1333 // Cache the UA properties to pass them to RenderTheme in adjustRenderStyle. 1334 // Cache the UA properties to pass them to RenderTheme in adjustRenderStyle.
1334 state.cacheUserAgentBorderAndBackground(); 1335 state.cacheUserAgentBorderAndBackground();
1335 1336
1336 // Now do the author and user normal priority properties and all the !import ant properties. 1337 // Now do the author and user normal priority properties and all the !import ant properties.
1337 applyMatchedProperties<LowPriorityProperties>(matchResult, false, matchResul t.ranges.lastUARule + 1, matchResult.matchedProperties.size() - 1, applyInherite dOnly); 1338 applyMatchedProperties<LowPriorityProperties>(matchResult, false, matchResul t.ranges.lastUARule + 1, matchResult.matchedProperties.size() - 1, applyInherite dOnly);
1338 if (RuntimeEnabledFeatures::webAnimationsEnabled()) 1339 if (RuntimeEnabledFeatures::webAnimationsEnabled())
1339 applyAnimatedProperties<LowPriorityProperties>(element); 1340 applyAnimatedProperties<LowPriorityProperties>(element, element->documen t()->timeline());
1340 applyMatchedProperties<LowPriorityProperties>(matchResult, true, matchResult .ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly); 1341 applyMatchedProperties<LowPriorityProperties>(matchResult, true, matchResult .ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly);
1341 applyMatchedProperties<LowPriorityProperties>(matchResult, true, matchResult .ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly); 1342 applyMatchedProperties<LowPriorityProperties>(matchResult, true, matchResult .ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly);
1342 applyMatchedProperties<LowPriorityProperties>(matchResult, true, matchResult .ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); 1343 applyMatchedProperties<LowPriorityProperties>(matchResult, true, matchResult .ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly);
1343 1344
1344 // Start loading resources referenced by this style. 1345 // Start loading resources referenced by this style.
1345 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle Resources()); 1346 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle Resources());
1346 1347
1347 ASSERT(!state.fontBuilder().fontDirty()); 1348 ASSERT(!state.fontBuilder().fontDirty());
1348 1349
1349 if (cachedMatchedProperties || !cacheHash) 1350 if (cachedMatchedProperties || !cacheHash)
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1510 info.addMember(m_state, "state"); 1511 info.addMember(m_state, "state");
1511 1512
1512 // FIXME: move this to a place where it would be called only once? 1513 // FIXME: move this to a place where it would be called only once?
1513 info.addMember(CSSDefaultStyleSheets::defaultStyle, "defaultStyle"); 1514 info.addMember(CSSDefaultStyleSheets::defaultStyle, "defaultStyle");
1514 info.addMember(CSSDefaultStyleSheets::defaultQuirksStyle, "defaultQuirksStyl e"); 1515 info.addMember(CSSDefaultStyleSheets::defaultQuirksStyle, "defaultQuirksStyl e");
1515 info.addMember(CSSDefaultStyleSheets::defaultPrintStyle, "defaultPrintStyle" ); 1516 info.addMember(CSSDefaultStyleSheets::defaultPrintStyle, "defaultPrintStyle" );
1516 info.addMember(CSSDefaultStyleSheets::defaultViewSourceStyle, "defaultViewSo urceStyle"); 1517 info.addMember(CSSDefaultStyleSheets::defaultViewSourceStyle, "defaultViewSo urceStyle");
1517 } 1518 }
1518 1519
1519 } // namespace WebCore 1520 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698