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

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: store animatablevalues explicitly 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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1446 static unsigned computeMatchedPropertiesHash(const MatchedProperties* properties , unsigned size) 1446 static unsigned computeMatchedPropertiesHash(const MatchedProperties* properties , unsigned size)
1447 { 1447 {
1448 return StringHasher::hashMemory(properties, sizeof(MatchedProperties) * size ); 1448 return StringHasher::hashMemory(properties, sizeof(MatchedProperties) * size );
1449 } 1449 }
1450 1450
1451 void StyleResolver::invalidateMatchedPropertiesCache() 1451 void StyleResolver::invalidateMatchedPropertiesCache()
1452 { 1452 {
1453 m_matchedPropertiesCache.clear(); 1453 m_matchedPropertiesCache.clear();
1454 } 1454 }
1455 1455
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) 1456 void StyleResolver::applyMatchedProperties(StyleResolverState& state, const Matc hResult& matchResult)
1474 { 1457 {
1475 const Element* element = state.element(); 1458 const Element* element = state.element();
1476 ASSERT(element); 1459 ASSERT(element);
1477 STYLE_STATS_ADD_MATCHED_PROPERTIES_SEARCH(); 1460 STYLE_STATS_ADD_MATCHED_PROPERTIES_SEARCH();
1478 1461
1479 unsigned cacheHash = matchResult.isCacheable ? computeMatchedPropertiesHash( matchResult.matchedProperties.data(), matchResult.matchedProperties.size()) : 0; 1462 unsigned cacheHash = matchResult.isCacheable ? computeMatchedPropertiesHash( matchResult.matchedProperties.data(), matchResult.matchedProperties.size()) : 0;
1480 bool applyInheritedOnly = false; 1463 bool applyInheritedOnly = false;
1481 const CachedMatchedProperties* cachedMatchedProperties = 0; 1464 const CachedMatchedProperties* cachedMatchedProperties = 0;
1482 1465
(...skipping 24 matching lines...) Expand all
1507 applyMatchedProperties<VariableDefinitions>(state, matchResult, true, matchR esult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedO nly); 1490 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) ; 1491 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); 1492 applyMatchedProperties<VariableDefinitions>(state, matchResult, true, matchR esult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly);
1510 1493
1511 // Apply animation properties in order to apply animation results and trigge r transitions below. 1494 // 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); 1495 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); 1496 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) ; 1497 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); 1498 applyMatchedProperties<AnimationProperties>(state, matchResult, true, matchR esult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly);
1516 1499
1500 // Match transition-property / animation-name length by trimming and
1501 // lengthening other transition / animation property lists
1502 // FIXME: This is wrong because we shouldn't affect the computed values
1503 state.style()->adjustAnimations();
1504 state.style()->adjustTransitions();
1505
1517 // Now we have all of the matched rules in the appropriate order. Walk the r ules and apply 1506 // 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. 1507 // 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 1508 // The order is (1) high-priority not important, (2) high-priority important , (3) normal not important
1520 // and (4) normal important. 1509 // and (4) normal important.
1521 state.setLineHeightValue(0); 1510 state.setLineHeightValue(0);
1522 applyMatchedProperties<HighPriorityProperties>(state, matchResult, false, 0, matchResult.matchedProperties.size() - 1, applyInheritedOnly); 1511 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); 1512 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); 1513 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); 1514 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat chResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly);
1526 1515
(...skipping 19 matching lines...) Expand all
1546 // Cache the UA properties to pass them to RenderTheme in adjustRenderStyle. 1535 // Cache the UA properties to pass them to RenderTheme in adjustRenderStyle.
1547 state.cacheUserAgentBorderAndBackground(); 1536 state.cacheUserAgentBorderAndBackground();
1548 1537
1549 // Now do the author and user normal priority properties and all the !import ant properties. 1538 // 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); 1539 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); 1540 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); 1541 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); 1542 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc hResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly);
1554 1543
1555 if (RuntimeEnabledFeatures::webAnimationsEnabled() && !applyInheritedOnly) { 1544 if (RuntimeEnabledFeatures::webAnimationsEnabled() && !applyInheritedOnly) {
1556 calculateCSSAnimationUpdate(state); 1545 state.setAnimationUpdate(CSSAnimations::calculateUpdate(state.element(), state.style(), this));
1557 // Apply animated properties, then reapply any rules marked important. 1546 // Apply animated properties, then reapply any rules marked important.
1558 if (applyAnimatedProperties<HighPriorityProperties>(state, element->docu ment().timeline())) { 1547 if (applyAnimatedProperties<HighPriorityProperties>(state, element->docu ment().timeline())) {
1559 bool important = true; 1548 bool important = true;
1560 applyMatchedProperties<HighPriorityProperties>(state, matchResult, i mportant, matchResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly); 1549 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); 1550 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); 1551 applyMatchedProperties<HighPriorityProperties>(state, matchResult, i mportant, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyIn heritedOnly);
1563 } 1552 }
1564 if (applyAnimatedProperties<LowPriorityProperties>(state, element->docum ent().timeline())) { 1553 if (applyAnimatedProperties<LowPriorityProperties>(state, element->docum ent().timeline())) {
1565 bool important = true; 1554 bool important = true;
1566 applyMatchedProperties<LowPriorityProperties>(state, matchResult, im portant, matchResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly); 1555 applyMatchedProperties<LowPriorityProperties>(state, matchResult, im portant, matchResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1655 m_matchedPropertiesSearches, m_matchedPropertiesHit, m_matchedProperties SharedInheritedHit, m_matchedPropertiesToCache, m_matchedPropertiesEnteredIntoCa che); 1644 m_matchedPropertiesSearches, m_matchedPropertiesHit, m_matchedProperties SharedInheritedHit, m_matchedPropertiesToCache, m_matchedPropertiesEnteredIntoCa che);
1656 1645
1657 fprintf(stderr, "Total:\n"); 1646 fprintf(stderr, "Total:\n");
1658 printStyleStats(m_totalSearches, m_totalElementsEligibleForSharing, m_totalS tylesShared, m_totalSearchFoundSiblingForSharing, m_totalSearchesMissedSharing, 1647 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); 1648 m_totalMatchedPropertiesSearches, m_totalMatchedPropertiesHit, m_totalMa tchedPropertiesSharedInheritedHit, m_totalMatchedPropertiesToCache, m_totalMatch edPropertiesEnteredIntoCache);
1660 fprintf(stderr, "----------------------------------------------------------- ---------------------\n"); 1649 fprintf(stderr, "----------------------------------------------------------- ---------------------\n");
1661 } 1650 }
1662 #endif 1651 #endif
1663 1652
1664 } // namespace WebCore 1653 } // namespace WebCore
OLDNEW
« Source/core/animation/css/CSSAnimations.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