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

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: update testexpectations and friends 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
« no previous file with comments | « Source/core/css/resolver/StyleResolver.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1239 ASSERT(pass != AnimationProperties); 1239 ASSERT(pass != AnimationProperties);
1240 const Element* element = state.element(); 1240 const Element* element = state.element();
1241 const CSSAnimationUpdate* update = state.animationUpdate(); 1241 const CSSAnimationUpdate* update = state.animationUpdate();
1242 AnimationStack* animationStack = timeline->animationStack(element); 1242 AnimationStack* animationStack = timeline->animationStack(element);
1243 bool didApply = false; 1243 bool didApply = false;
1244 1244
1245 if (animationStack) { 1245 if (animationStack) {
1246 const Vector<Animation*>& animations = animationStack->activeAnimations( element); 1246 const Vector<Animation*>& animations = animationStack->activeAnimations( element);
1247 for (size_t i = 0; i < animations.size(); ++i) { 1247 for (size_t i = 0; i < animations.size(); ++i) {
1248 RefPtr<Animation> animation = animations.at(i); 1248 RefPtr<Animation> animation = animations.at(i);
1249 if (update && update->isCancelled(animation->player())) 1249 if (update && update->isCancelledAnimation(animation->player()))
1250 continue; 1250 continue;
1251 const AnimationEffect::CompositableValueMap* compositableValues = an imation->compositableValues(); 1251 const AnimationEffect::CompositableValueMap* compositableValues = an imation->compositableValues();
1252 for (AnimationEffect::CompositableValueMap::const_iterator iter = co mpositableValues->begin(); iter != compositableValues->end(); ++iter) { 1252 for (AnimationEffect::CompositableValueMap::const_iterator iter = co mpositableValues->begin(); iter != compositableValues->end(); ++iter) {
1253 CSSPropertyID property = iter->key; 1253 CSSPropertyID property = iter->key;
1254 if (!isPropertyForPass<pass>(property)) 1254 if (!isPropertyForPass<pass>(property))
1255 continue; 1255 continue;
1256 RELEASE_ASSERT_WITH_MESSAGE(!iter->value->dependsOnUnderlyingVal ue(), "Web Animations not yet implemented: An interface for compositing onto the underlying value."); 1256 RELEASE_ASSERT_WITH_MESSAGE(!iter->value->dependsOnUnderlyingVal ue(), "Web Animations not yet implemented: An interface for compositing onto the underlying value.");
1257 RefPtr<AnimatableValue> animatableValue = iter->value->composite Onto(0); 1257 RefPtr<AnimatableValue> animatableValue = iter->value->composite Onto(0);
1258 if (pass == HighPriorityProperties && property == CSSPropertyLin eHeight) 1258 if (pass == HighPriorityProperties && property == CSSPropertyLin eHeight)
1259 state.setLineHeightValue(toAnimatableLength(animatableValue. get())->toCSSValue().get()); 1259 state.setLineHeightValue(toAnimatableLength(animatableValue. get())->toCSSValue().get());
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1445 static unsigned computeMatchedPropertiesHash(const MatchedProperties* properties , unsigned size) 1445 static unsigned computeMatchedPropertiesHash(const MatchedProperties* properties , unsigned size)
1446 { 1446 {
1447 return StringHasher::hashMemory(properties, sizeof(MatchedProperties) * size ); 1447 return StringHasher::hashMemory(properties, sizeof(MatchedProperties) * size );
1448 } 1448 }
1449 1449
1450 void StyleResolver::invalidateMatchedPropertiesCache() 1450 void StyleResolver::invalidateMatchedPropertiesCache()
1451 { 1451 {
1452 m_matchedPropertiesCache.clear(); 1452 m_matchedPropertiesCache.clear();
1453 } 1453 }
1454 1454
1455 void StyleResolver::calculateCSSAnimationUpdate(StyleResolverState& state)
1456 {
1457 if (!RuntimeEnabledFeatures::webAnimationsCSSEnabled())
1458 return;
1459
1460 Element* element = state.element();
1461 ASSERT(element);
1462
1463 if (!CSSAnimations::needsUpdate(element, state.style()))
1464 return;
1465
1466 ActiveAnimations* activeAnimations = element->activeAnimations();
1467 const CSSAnimationDataList* animations = state.style()->animations();
1468 const CSSAnimations* cssAnimations = activeAnimations ? activeAnimations->cs sAnimations() : 0;
1469 state.setAnimationUpdate(CSSAnimations::calculateUpdate(element, state.style (), cssAnimations, animations, this));
1470 }
1471
1472 void StyleResolver::applyMatchedProperties(StyleResolverState& state, const Matc hResult& matchResult) 1455 void StyleResolver::applyMatchedProperties(StyleResolverState& state, const Matc hResult& matchResult)
1473 { 1456 {
1474 const Element* element = state.element(); 1457 const Element* element = state.element();
1475 ASSERT(element); 1458 ASSERT(element);
1476 STYLE_STATS_ADD_MATCHED_PROPERTIES_SEARCH(); 1459 STYLE_STATS_ADD_MATCHED_PROPERTIES_SEARCH();
1477 1460
1478 unsigned cacheHash = matchResult.isCacheable ? computeMatchedPropertiesHash( matchResult.matchedProperties.data(), matchResult.matchedProperties.size()) : 0; 1461 unsigned cacheHash = matchResult.isCacheable ? computeMatchedPropertiesHash( matchResult.matchedProperties.data(), matchResult.matchedProperties.size()) : 0;
1479 bool applyInheritedOnly = false; 1462 bool applyInheritedOnly = false;
1480 const CachedMatchedProperties* cachedMatchedProperties = 0; 1463 const CachedMatchedProperties* cachedMatchedProperties = 0;
1481 1464
(...skipping 24 matching lines...) Expand all
1506 applyMatchedProperties<VariableDefinitions>(state, matchResult, true, matchR esult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedO nly); 1489 applyMatchedProperties<VariableDefinitions>(state, matchResult, true, matchR esult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedO nly);
1507 applyMatchedProperties<VariableDefinitions>(state, matchResult, true, matchR esult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly) ; 1490 applyMatchedProperties<VariableDefinitions>(state, matchResult, true, matchR esult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly) ;
1508 applyMatchedProperties<VariableDefinitions>(state, matchResult, true, matchR esult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); 1491 applyMatchedProperties<VariableDefinitions>(state, matchResult, true, matchR esult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly);
1509 1492
1510 // Apply animation properties in order to apply animation results and trigge r transitions below. 1493 // Apply animation properties in order to apply animation results and trigge r transitions below.
1511 applyMatchedProperties<AnimationProperties>(state, matchResult, false, 0, ma tchResult.matchedProperties.size() - 1, applyInheritedOnly); 1494 applyMatchedProperties<AnimationProperties>(state, matchResult, false, 0, ma tchResult.matchedProperties.size() - 1, applyInheritedOnly);
1512 applyMatchedProperties<AnimationProperties>(state, matchResult, true, matchR esult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedO nly); 1495 applyMatchedProperties<AnimationProperties>(state, matchResult, true, matchR esult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedO nly);
1513 applyMatchedProperties<AnimationProperties>(state, matchResult, true, matchR esult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly) ; 1496 applyMatchedProperties<AnimationProperties>(state, matchResult, true, matchR esult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnly) ;
1514 applyMatchedProperties<AnimationProperties>(state, matchResult, true, matchR esult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); 1497 applyMatchedProperties<AnimationProperties>(state, matchResult, true, matchR esult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly);
1515 1498
1499 // Match transition-property / animation-name length by trimming and
1500 // lengthening other transition / animation property lists
1501 // FIXME: This is wrong because we shouldn't affect the computed values
1502 state.style()->adjustAnimations();
1503 state.style()->adjustTransitions();
1504
1516 // Now we have all of the matched rules in the appropriate order. Walk the r ules and apply 1505 // Now we have all of the matched rules in the appropriate order. Walk the r ules and apply
1517 // high-priority properties first, i.e., those properties that other propert ies depend on. 1506 // high-priority properties first, i.e., those properties that other propert ies depend on.
1518 // The order is (1) high-priority not important, (2) high-priority important , (3) normal not important 1507 // The order is (1) high-priority not important, (2) high-priority important , (3) normal not important
1519 // and (4) normal important. 1508 // and (4) normal important.
1520 state.setLineHeightValue(0); 1509 state.setLineHeightValue(0);
1521 applyMatchedProperties<HighPriorityProperties>(state, matchResult, false, 0, matchResult.matchedProperties.size() - 1, applyInheritedOnly); 1510 applyMatchedProperties<HighPriorityProperties>(state, matchResult, false, 0, matchResult.matchedProperties.size() - 1, applyInheritedOnly);
1522 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat chResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInherit edOnly); 1511 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat chResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInherit edOnly);
1523 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat chResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOn ly); 1512 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat chResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOn ly);
1524 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat chResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); 1513 applyMatchedProperties<HighPriorityProperties>(state, matchResult, true, mat chResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly);
1525 1514
(...skipping 19 matching lines...) Expand all
1545 // Cache the UA properties to pass them to RenderTheme in adjustRenderStyle. 1534 // Cache the UA properties to pass them to RenderTheme in adjustRenderStyle.
1546 state.cacheUserAgentBorderAndBackground(); 1535 state.cacheUserAgentBorderAndBackground();
1547 1536
1548 // Now do the author and user normal priority properties and all the !import ant properties. 1537 // Now do the author and user normal priority properties and all the !import ant properties.
1549 applyMatchedProperties<LowPriorityProperties>(state, matchResult, false, mat chResult.ranges.lastUARule + 1, matchResult.matchedProperties.size() - 1, applyI nheritedOnly); 1538 applyMatchedProperties<LowPriorityProperties>(state, matchResult, false, mat chResult.ranges.lastUARule + 1, matchResult.matchedProperties.size() - 1, applyI nheritedOnly);
1550 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc hResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInherite dOnly); 1539 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc hResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInherite dOnly);
1551 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc hResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnl y); 1540 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc hResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnl y);
1552 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc hResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); 1541 applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc hResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly);
1553 1542
1554 if (RuntimeEnabledFeatures::webAnimationsEnabled() && !applyInheritedOnly) { 1543 if (RuntimeEnabledFeatures::webAnimationsEnabled() && !applyInheritedOnly) {
1555 calculateCSSAnimationUpdate(state); 1544 state.setAnimationUpdate(CSSAnimations::calculateUpdate(state.element(), state.style(), this));
1556 // Apply animated properties, then reapply any rules marked important. 1545 // Apply animated properties, then reapply any rules marked important.
1557 if (applyAnimatedProperties<HighPriorityProperties>(state, element->docu ment().timeline())) { 1546 if (applyAnimatedProperties<HighPriorityProperties>(state, element->docu ment().timeline())) {
1558 bool important = true; 1547 bool important = true;
1559 applyMatchedProperties<HighPriorityProperties>(state, matchResult, i mportant, matchResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly); 1548 applyMatchedProperties<HighPriorityProperties>(state, matchResult, i mportant, matchResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly);
1560 applyMatchedProperties<HighPriorityProperties>(state, matchResult, i mportant, matchResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, app lyInheritedOnly); 1549 applyMatchedProperties<HighPriorityProperties>(state, matchResult, i mportant, matchResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, app lyInheritedOnly);
1561 applyMatchedProperties<HighPriorityProperties>(state, matchResult, i mportant, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyIn heritedOnly); 1550 applyMatchedProperties<HighPriorityProperties>(state, matchResult, i mportant, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyIn heritedOnly);
1562 } 1551 }
1563 if (applyAnimatedProperties<LowPriorityProperties>(state, element->docum ent().timeline())) { 1552 if (applyAnimatedProperties<LowPriorityProperties>(state, element->docum ent().timeline())) {
1564 bool important = true; 1553 bool important = true;
1565 applyMatchedProperties<LowPriorityProperties>(state, matchResult, im portant, matchResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInheritedOnly); 1554 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
1654 m_matchedPropertiesSearches, m_matchedPropertiesHit, m_matchedProperties SharedInheritedHit, m_matchedPropertiesToCache, m_matchedPropertiesEnteredIntoCa che); 1643 m_matchedPropertiesSearches, m_matchedPropertiesHit, m_matchedProperties SharedInheritedHit, m_matchedPropertiesToCache, m_matchedPropertiesEnteredIntoCa che);
1655 1644
1656 fprintf(stderr, "Total:\n"); 1645 fprintf(stderr, "Total:\n");
1657 printStyleStats(m_totalSearches, m_totalElementsEligibleForSharing, m_totalS tylesShared, m_totalSearchFoundSiblingForSharing, m_totalSearchesMissedSharing, 1646 printStyleStats(m_totalSearches, m_totalElementsEligibleForSharing, m_totalS tylesShared, m_totalSearchFoundSiblingForSharing, m_totalSearchesMissedSharing,
1658 m_totalMatchedPropertiesSearches, m_totalMatchedPropertiesHit, m_totalMa tchedPropertiesSharedInheritedHit, m_totalMatchedPropertiesToCache, m_totalMatch edPropertiesEnteredIntoCache); 1647 m_totalMatchedPropertiesSearches, m_totalMatchedPropertiesHit, m_totalMa tchedPropertiesSharedInheritedHit, m_totalMatchedPropertiesToCache, m_totalMatch edPropertiesEnteredIntoCache);
1659 fprintf(stderr, "----------------------------------------------------------- ---------------------\n"); 1648 fprintf(stderr, "----------------------------------------------------------- ---------------------\n");
1660 } 1649 }
1661 #endif 1650 #endif
1662 1651
1663 } // namespace WebCore 1652 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/css/resolver/StyleResolver.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698