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

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

Issue 26382004: Web Animations CSS: Implement CSS Transitions backed on Web Animations model (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: fix logic for elapsedTime in event Created 7 years, 2 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
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 1230 matching lines...) Expand 10 before | Expand all | Expand 10 after
1241 const Element* element = state.element(); 1241 const Element* element = state.element();
1242 const CSSAnimationUpdate* update = state.animationUpdate(); 1242 const CSSAnimationUpdate* update = state.animationUpdate();
1243 AnimationStack* animationStack = timeline->animationStack(element); 1243 AnimationStack* animationStack = timeline->animationStack(element);
1244 if (!animationStack) 1244 if (!animationStack)
1245 return false; 1245 return false;
1246 bool didApply = false; 1246 bool didApply = false;
1247 1247
1248 const Vector<Animation*>& animations = animationStack->activeAnimations(elem ent); 1248 const Vector<Animation*>& animations = animationStack->activeAnimations(elem ent);
1249 for (size_t i = 0; i < animations.size(); ++i) { 1249 for (size_t i = 0; i < animations.size(); ++i) {
1250 RefPtr<Animation> animation = animations.at(i); 1250 RefPtr<Animation> animation = animations.at(i);
1251 if (update && update->isCancelled(animation->player())) 1251 if (update && update->isCancelledAnimation(animation->player()))
1252 continue; 1252 continue;
1253 const AnimationEffect::CompositableValueMap* compositableValues = animat ion->compositableValues(); 1253 const AnimationEffect::CompositableValueMap* compositableValues = animat ion->compositableValues();
1254 for (AnimationEffect::CompositableValueMap::const_iterator iter = compos itableValues->begin(); iter != compositableValues->end(); ++iter) { 1254 for (AnimationEffect::CompositableValueMap::const_iterator iter = compos itableValues->begin(); iter != compositableValues->end(); ++iter) {
1255 CSSPropertyID property = iter->key; 1255 CSSPropertyID property = iter->key;
1256 if (!isPropertyForPass<pass>(property)) 1256 if (!isPropertyForPass<pass>(property))
1257 continue; 1257 continue;
1258 RELEASE_ASSERT_WITH_MESSAGE(!iter->value->dependsOnUnderlyingValue() , "Not yet implemented: An interface for compositing onto the underlying value." ); 1258 RELEASE_ASSERT_WITH_MESSAGE(!iter->value->dependsOnUnderlyingValue() , "Not yet implemented: An interface for compositing onto the underlying value." );
1259 RefPtr<AnimatableValue> animatableValue = iter->value->compositeOnto (0); 1259 RefPtr<AnimatableValue> animatableValue = iter->value->compositeOnto (0);
1260 if (pass == HighPriorityProperties && property == CSSPropertyLineHei ght) 1260 if (pass == HighPriorityProperties && property == CSSPropertyLineHei ght)
1261 state.setLineHeightValue(toAnimatableLength(animatableValue.get( ))->toCSSValue().get()); 1261 state.setLineHeightValue(toAnimatableLength(animatableValue.get( ))->toCSSValue().get());
(...skipping 26 matching lines...) Expand all
1288 state.setLineHeightValue(toAnimatableLength(animatableValue. get())->toCSSValue().get()); 1288 state.setLineHeightValue(toAnimatableLength(animatableValue. get())->toCSSValue().get());
1289 else 1289 else
1290 AnimatedStyleBuilder::applyProperty(property, state, animata bleValue.get()); 1290 AnimatedStyleBuilder::applyProperty(property, state, animata bleValue.get());
1291 didApply = true; 1291 didApply = true;
1292 } 1292 }
1293 } 1293 }
1294 } 1294 }
1295 return didApply; 1295 return didApply;
1296 } 1296 }
1297 1297
1298 void StyleResolver::applyTransitionedProperties(StyleResolverState& state)
1299 {
1300 ASSERT(RuntimeEnabledFeatures::webAnimationsCSSEnabled());
1301 const CSSAnimationUpdate* update = state.animationUpdate();
1302 ActiveAnimations* activeAnimations = state.element()->activeAnimations();
1303 const CSSAnimations* cssAnimations = activeAnimations ? activeAnimations->cs sAnimations() : 0;
1304
1305 const AnimationEffect::CompositableValueMap& compositableValues = CSSAnimati ons::compositableValuesForTransitions(cssAnimations, update);
1306
1307 for (AnimationEffect::CompositableValueMap::const_iterator iter = compositab leValues.begin(); iter != compositableValues.end(); ++iter) {
1308 CSSPropertyID id = iter->key;
1309 AnimatedStyleBuilder::applyProperty(iter->key, state, iter->value->compo siteOnto(AnimatableValue::neutralValue()).get());
1310 }
1311 }
1312
1298 // http://dev.w3.org/csswg/css3-regions/#the-at-region-style-rule 1313 // http://dev.w3.org/csswg/css3-regions/#the-at-region-style-rule
1299 // FIXME: add incremental support for other region styling properties. 1314 // FIXME: add incremental support for other region styling properties.
1300 static inline bool isValidRegionStyleProperty(CSSPropertyID id) 1315 static inline bool isValidRegionStyleProperty(CSSPropertyID id)
1301 { 1316 {
1302 switch (id) { 1317 switch (id) {
1303 case CSSPropertyBackgroundColor: 1318 case CSSPropertyBackgroundColor:
1304 case CSSPropertyColor: 1319 case CSSPropertyColor:
1305 return true; 1320 return true;
1306 default: 1321 default:
1307 break; 1322 break;
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1446 static unsigned computeMatchedPropertiesHash(const MatchedProperties* properties , unsigned size) 1461 static unsigned computeMatchedPropertiesHash(const MatchedProperties* properties , unsigned size)
1447 { 1462 {
1448 return StringHasher::hashMemory(properties, sizeof(MatchedProperties) * size ); 1463 return StringHasher::hashMemory(properties, sizeof(MatchedProperties) * size );
1449 } 1464 }
1450 1465
1451 void StyleResolver::invalidateMatchedPropertiesCache() 1466 void StyleResolver::invalidateMatchedPropertiesCache()
1452 { 1467 {
1453 m_matchedPropertiesCache.clear(); 1468 m_matchedPropertiesCache.clear();
1454 } 1469 }
1455 1470
1456 void StyleResolver::calculateCSSAnimationUpdate(StyleResolverState& state)
1457 {
1458 if (!RuntimeEnabledFeatures::webAnimationsCSSEnabled())
1459 return;
1460
1461 Element* element = state.element();
1462 ASSERT(element);
1463
1464 if (!CSSAnimations::needsUpdate(element, state.style()))
1465 return;
1466
1467 ActiveAnimations* activeAnimations = element->activeAnimations();
1468 const CSSAnimationDataList* animations = state.style()->animations();
1469 const CSSAnimations* cssAnimations = activeAnimations ? activeAnimations->cs sAnimations() : 0;
1470 state.setAnimationUpdate(CSSAnimations::calculateUpdate(element, state.style (), cssAnimations, animations, this));
1471 }
1472
1473 void StyleResolver::applyMatchedProperties(StyleResolverState& state, const Matc hResult& matchResult) 1471 void StyleResolver::applyMatchedProperties(StyleResolverState& state, const Matc hResult& matchResult)
1474 { 1472 {
1475 const Element* element = state.element(); 1473 const Element* element = state.element();
1476 ASSERT(element); 1474 ASSERT(element);
1477 STYLE_STATS_ADD_MATCHED_PROPERTIES_SEARCH(); 1475 STYLE_STATS_ADD_MATCHED_PROPERTIES_SEARCH();
1478 1476
1479 unsigned cacheHash = matchResult.isCacheable ? computeMatchedPropertiesHash( matchResult.matchedProperties.data(), matchResult.matchedProperties.size()) : 0; 1477 unsigned cacheHash = matchResult.isCacheable ? computeMatchedPropertiesHash( matchResult.matchedProperties.data(), matchResult.matchedProperties.size()) : 0;
1480 bool applyInheritedOnly = false; 1478 bool applyInheritedOnly = false;
1481 const CachedMatchedProperties* cachedMatchedProperties = 0; 1479 const CachedMatchedProperties* cachedMatchedProperties = 0;
1482 1480
(...skipping 24 matching lines...) Expand all
1507 applyMatchedProperties<VariableDefinitions>(state, matchResult, true, matchR esult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedO nly); 1505 applyMatchedProperties<VariableDefinitions>(state, matchResult, true, matchR esult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedO nly);
1508 applyMatchedProperties<VariableDefinitions>(state, matchResult, true, matchR esult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly) ; 1506 applyMatchedProperties<VariableDefinitions>(state, matchResult, true, matchR esult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly) ;
1509 applyMatchedProperties<VariableDefinitions>(state, matchResult, true, matchR esult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); 1507 applyMatchedProperties<VariableDefinitions>(state, matchResult, true, matchR esult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly);
1510 1508
1511 // Apply animation properties in order to apply animation results and trigge r transitions below. 1509 // Apply animation properties in order to apply animation results and trigge r transitions below.
1512 applyMatchedProperties<AnimationProperties>(state, matchResult, false, 0, ma tchResult.matchedProperties.size() - 1, applyInheritedOnly); 1510 applyMatchedProperties<AnimationProperties>(state, matchResult, false, 0, ma tchResult.matchedProperties.size() - 1, applyInheritedOnly);
1513 applyMatchedProperties<AnimationProperties>(state, matchResult, true, matchR esult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedO nly); 1511 applyMatchedProperties<AnimationProperties>(state, matchResult, true, matchR esult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedO nly);
1514 applyMatchedProperties<AnimationProperties>(state, matchResult, true, matchR esult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly) ; 1512 applyMatchedProperties<AnimationProperties>(state, matchResult, true, matchR esult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly) ;
1515 applyMatchedProperties<AnimationProperties>(state, matchResult, true, matchR esult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); 1513 applyMatchedProperties<AnimationProperties>(state, matchResult, true, matchR esult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly);
1516 1514
1515 // Match transition-property / animation-name length by trimming and
1516 // lengthening other transition / animation property lists
1517 // FIXME: This is wrong because we shouldn't affect the computed values
1518 state.style()->adjustAnimations();
dstockwell 2013/10/08 21:02:59 should be guarded by if enable web-animations-css
Timothy Loh 2013/10/09 01:33:07 same as above; moving this should be fine for the
1519 state.style()->adjustTransitions();
1520
1517 // Now we have all of the matched rules in the appropriate order. Walk the r ules and apply 1521 // Now we have all of the matched rules in the appropriate order. Walk the r ules and apply
1518 // high-priority properties first, i.e., those properties that other propert ies depend on. 1522 // high-priority properties first, i.e., those properties that other propert ies depend on.
1519 // The order is (1) high-priority not important, (2) high-priority important , (3) normal not important 1523 // The order is (1) high-priority not important, (2) high-priority important , (3) normal not important
1520 // and (4) normal important. 1524 // and (4) normal important.
1521 state.setLineHeightValue(0); 1525 state.setLineHeightValue(0);
1522 applyMatchedProperties<HighPriorityProperties>(state, matchResult, false, 0, matchResult.matchedProperties.size() - 1, applyInheritedOnly); 1526 applyMatchedProperties<HighPriorityProperties>(state, matchResult, false, 0, matchResult.matchedProperties.size() - 1, applyInheritedOnly);
1523 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat chResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInherit edOnly); 1527 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat chResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInherit edOnly);
1524 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat chResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOn ly); 1528 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat chResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOn ly);
1525 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat chResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); 1529 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat chResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly);
1526 1530
(...skipping 19 matching lines...) Expand all
1546 // Cache the UA properties to pass them to RenderTheme in adjustRenderStyle. 1550 // Cache the UA properties to pass them to RenderTheme in adjustRenderStyle.
1547 state.cacheUserAgentBorderAndBackground(); 1551 state.cacheUserAgentBorderAndBackground();
1548 1552
1549 // Now do the author and user normal priority properties and all the !import ant properties. 1553 // Now do the author and user normal priority properties and all the !import ant properties.
1550 applyMatchedProperties<LowPriorityProperties>(state, matchResult, false, mat chResult.ranges.lastUARule + 1, matchResult.matchedProperties.size() - 1, applyI nheritedOnly); 1554 applyMatchedProperties<LowPriorityProperties>(state, matchResult, false, mat chResult.ranges.lastUARule + 1, matchResult.matchedProperties.size() - 1, applyI nheritedOnly);
1551 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc hResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInherite dOnly); 1555 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc hResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInherite dOnly);
1552 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc hResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnl y); 1556 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc hResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnl y);
1553 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc hResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); 1557 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc hResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly);
1554 1558
1555 if (RuntimeEnabledFeatures::webAnimationsEnabled() && !applyInheritedOnly) { 1559 if (RuntimeEnabledFeatures::webAnimationsEnabled() && !applyInheritedOnly) {
1556 calculateCSSAnimationUpdate(state); 1560 state.setAnimationUpdate(CSSAnimations::calculateUpdate(state.element(), state.style(), this));
1557 // Apply animated properties, then reapply any rules marked important. 1561 // Apply animated properties, then reapply any rules marked important.
1558 if (applyAnimatedProperties<HighPriorityProperties>(state, element->docu ment().timeline())) { 1562 if (applyAnimatedProperties<HighPriorityProperties>(state, element->docu ment().timeline())) {
1559 bool important = true; 1563 bool important = true;
1560 applyMatchedProperties<HighPriorityProperties>(state, matchResult, i mportant, matchResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly); 1564 applyMatchedProperties<HighPriorityProperties>(state, matchResult, i mportant, matchResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly);
1561 applyMatchedProperties<HighPriorityProperties>(state, matchResult, i mportant, matchResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, app lyInheritedOnly); 1565 applyMatchedProperties<HighPriorityProperties>(state, matchResult, i mportant, matchResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, app lyInheritedOnly);
1562 applyMatchedProperties<HighPriorityProperties>(state, matchResult, i mportant, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyIn heritedOnly); 1566 applyMatchedProperties<HighPriorityProperties>(state, matchResult, i mportant, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyIn heritedOnly);
1563 } 1567 }
1564 if (applyAnimatedProperties<LowPriorityProperties>(state, element->docum ent().timeline())) { 1568 if (applyAnimatedProperties<LowPriorityProperties>(state, element->docum ent().timeline())) {
1565 bool important = true; 1569 bool important = true;
1566 applyMatchedProperties<LowPriorityProperties>(state, matchResult, im portant, matchResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly); 1570 applyMatchedProperties<LowPriorityProperties>(state, matchResult, im portant, matchResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly);
1567 applyMatchedProperties<LowPriorityProperties>(state, matchResult, im portant, matchResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, appl yInheritedOnly); 1571 applyMatchedProperties<LowPriorityProperties>(state, matchResult, im portant, matchResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, appl yInheritedOnly);
1568 applyMatchedProperties<LowPriorityProperties>(state, matchResult, im portant, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInh eritedOnly); 1572 applyMatchedProperties<LowPriorityProperties>(state, matchResult, im portant, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInh eritedOnly);
1569 } 1573 }
1574
1575 applyTransitionedProperties(state);
1570 } 1576 }
1571 1577
1572 // Start loading resources referenced by this style. 1578 // Start loading resources referenced by this style.
1573 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle Resources()); 1579 m_styleResourceLoader.loadPendingResources(state.style(), state.elementStyle Resources());
1574 1580
1575 ASSERT(!state.fontBuilder().fontDirty()); 1581 ASSERT(!state.fontBuilder().fontDirty());
1576 1582
1577 #ifdef STYLE_STATS 1583 #ifdef STYLE_STATS
1578 if (!cachedMatchedProperties) 1584 if (!cachedMatchedProperties)
1579 STYLE_STATS_ADD_MATCHED_PROPERTIES_TO_CACHE(); 1585 STYLE_STATS_ADD_MATCHED_PROPERTIES_TO_CACHE();
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
1655 m_matchedPropertiesSearches, m_matchedPropertiesHit, m_matchedProperties SharedInheritedHit, m_matchedPropertiesToCache, m_matchedPropertiesEnteredIntoCa che); 1661 m_matchedPropertiesSearches, m_matchedPropertiesHit, m_matchedProperties SharedInheritedHit, m_matchedPropertiesToCache, m_matchedPropertiesEnteredIntoCa che);
1656 1662
1657 fprintf(stderr, "Total:\n"); 1663 fprintf(stderr, "Total:\n");
1658 printStyleStats(m_totalSearches, m_totalElementsEligibleForSharing, m_totalS tylesShared, m_totalSearchFoundSiblingForSharing, m_totalSearchesMissedSharing, 1664 printStyleStats(m_totalSearches, m_totalElementsEligibleForSharing, m_totalS tylesShared, m_totalSearchFoundSiblingForSharing, m_totalSearchesMissedSharing,
1659 m_totalMatchedPropertiesSearches, m_totalMatchedPropertiesHit, m_totalMa tchedPropertiesSharedInheritedHit, m_totalMatchedPropertiesToCache, m_totalMatch edPropertiesEnteredIntoCache); 1665 m_totalMatchedPropertiesSearches, m_totalMatchedPropertiesHit, m_totalMa tchedPropertiesSharedInheritedHit, m_totalMatchedPropertiesToCache, m_totalMatch edPropertiesEnteredIntoCache);
1660 fprintf(stderr, "----------------------------------------------------------- ---------------------\n"); 1666 fprintf(stderr, "----------------------------------------------------------- ---------------------\n");
1661 } 1667 }
1662 #endif 1668 #endif
1663 1669
1664 } // namespace WebCore 1670 } // namespace WebCore
OLDNEW
« Source/core/css/resolver/StyleAdjuster.cpp ('K') | « Source/core/css/resolver/StyleResolver.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698