| OLD | NEW | 
|---|
| 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 706 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 717     // FIXME: Shouldn't this be on RenderBody::styleDidChange? | 717     // FIXME: Shouldn't this be on RenderBody::styleDidChange? | 
| 718     if (element->hasTagName(bodyTag)) | 718     if (element->hasTagName(bodyTag)) | 
| 719         document().textLinkColors().setTextColor(state.style()->visitedDependent
      Color(CSSPropertyColor)); | 719         document().textLinkColors().setTextColor(state.style()->visitedDependent
      Color(CSSPropertyColor)); | 
| 720 | 720 | 
| 721     setAnimationUpdateIfNeeded(state, *element); | 721     setAnimationUpdateIfNeeded(state, *element); | 
| 722 | 722 | 
| 723     // Now return the style. | 723     // Now return the style. | 
| 724     return state.takeStyle(); | 724     return state.takeStyle(); | 
| 725 } | 725 } | 
| 726 | 726 | 
| 727 PassRefPtr<RenderStyle> StyleResolver::styleForKeyframe(Element* e, const Render
      Style* elementStyle, const StyleKeyframe* keyframe) | 727 PassRefPtr<RenderStyle> StyleResolver::styleForKeyframe(Element* e, const Render
      Style& elementStyle, const StyleKeyframe* keyframe) | 
| 728 { | 728 { | 
| 729     ASSERT(document().frame()); | 729     ASSERT(document().frame()); | 
| 730     ASSERT(documentSettings()); | 730     ASSERT(documentSettings()); | 
| 731 | 731 | 
| 732     if (e == document().documentElement()) | 732     if (e == document().documentElement()) | 
| 733         resetDirectionAndWritingModeOnDocument(document()); | 733         resetDirectionAndWritingModeOnDocument(document()); | 
| 734     StyleResolverState state(document(), e); | 734     StyleResolverState state(document(), e); | 
| 735 | 735 | 
| 736     MatchResult result; | 736     MatchResult result; | 
| 737     if (keyframe->properties()) | 737     if (keyframe->properties()) | 
| 738         result.addMatchedProperties(keyframe->properties()); | 738         result.addMatchedProperties(keyframe->properties()); | 
| 739 | 739 | 
| 740     ASSERT(!state.style()); | 740     ASSERT(!state.style()); | 
| 741 | 741 | 
| 742     // Create the style | 742     // Create the style | 
| 743     state.setStyle(RenderStyle::clone(elementStyle)); | 743     state.setStyle(RenderStyle::clone(&elementStyle)); | 
| 744     state.setLineHeightValue(0); | 744     state.setLineHeightValue(0); | 
| 745 | 745 | 
| 746     state.fontBuilder().initForStyleResolve(state.document(), state.style(), sta
      te.useSVGZoomRules()); | 746     state.fontBuilder().initForStyleResolve(state.document(), state.style(), sta
      te.useSVGZoomRules()); | 
| 747 | 747 | 
| 748     // We don't need to bother with !important. Since there is only ever one | 748     // We don't need to bother with !important. Since there is only ever one | 
| 749     // decl, there's nothing to override. So just add the first properties. | 749     // decl, there's nothing to override. So just add the first properties. | 
| 750     bool inheritedOnly = false; | 750     bool inheritedOnly = false; | 
| 751     if (keyframe->properties()) { | 751     if (keyframe->properties()) { | 
| 752         // FIXME: Can't keyframes contain variables? | 752         // FIXME: Can't keyframes contain variables? | 
| 753         applyMatchedProperties<AnimationProperties>(state, result, false, 0, res
      ult.matchedProperties.size() - 1, inheritedOnly); | 753         applyMatchedProperties<AnimationProperties>(state, result, false, 0, res
      ult.matchedProperties.size() - 1, inheritedOnly); | 
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 787     if (stack.isEmpty()) | 787     if (stack.isEmpty()) | 
| 788         return 0; | 788         return 0; | 
| 789 | 789 | 
| 790     for (size_t i = 0; i < stack.size(); ++i) { | 790     for (size_t i = 0; i < stack.size(); ++i) { | 
| 791         if (const StyleRuleKeyframes* keyframesRule = stack.at(i)->keyframeStyle
      sForAnimation(animationName)) | 791         if (const StyleRuleKeyframes* keyframesRule = stack.at(i)->keyframeStyle
      sForAnimation(animationName)) | 
| 792             return keyframesRule; | 792             return keyframesRule; | 
| 793     } | 793     } | 
| 794     return 0; | 794     return 0; | 
| 795 } | 795 } | 
| 796 | 796 | 
| 797 void StyleResolver::keyframeStylesForAnimation(Element* e, const RenderStyle* el
      ementStyle, KeyframeList& list) | 797 void StyleResolver::keyframeStylesForAnimation(Element* e, const RenderStyle& el
      ementStyle, KeyframeList& list) | 
| 798 { | 798 { | 
| 799     ASSERT(!RuntimeEnabledFeatures::webAnimationsCSSEnabled()); | 799     ASSERT(!RuntimeEnabledFeatures::webAnimationsCSSEnabled()); | 
| 800     list.clear(); | 800     list.clear(); | 
| 801 | 801 | 
| 802     // Get the keyframesRule for this name | 802     // Get the keyframesRule for this name | 
| 803     if (!e || list.animationName().isEmpty()) | 803     if (!e || list.animationName().isEmpty()) | 
| 804         return; | 804         return; | 
| 805 | 805 | 
| 806     const StyleRuleKeyframes* keyframesRule = matchScopedKeyframesRule(e, list.a
      nimationName().impl()); | 806     const StyleRuleKeyframes* keyframesRule = matchScopedKeyframesRule(e, list.a
      nimationName().impl()); | 
| 807     if (!keyframesRule) | 807     if (!keyframesRule) | 
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 846             hundredPercentKeyframe = StyleKeyframe::create().leakRef(); | 846             hundredPercentKeyframe = StyleKeyframe::create().leakRef(); | 
| 847             hundredPercentKeyframe->setKeyText("100%"); | 847             hundredPercentKeyframe->setKeyText("100%"); | 
| 848         } | 848         } | 
| 849         KeyframeValue keyframeValue(1, 0); | 849         KeyframeValue keyframeValue(1, 0); | 
| 850         keyframeValue.setStyle(styleForKeyframe(e, elementStyle, hundredPercentK
      eyframe)); | 850         keyframeValue.setStyle(styleForKeyframe(e, elementStyle, hundredPercentK
      eyframe)); | 
| 851         keyframeValue.addProperties(hundredPercentKeyframe->properties()); | 851         keyframeValue.addProperties(hundredPercentKeyframe->properties()); | 
| 852         list.insert(keyframeValue); | 852         list.insert(keyframeValue); | 
| 853     } | 853     } | 
| 854 } | 854 } | 
| 855 | 855 | 
| 856 void StyleResolver::resolveKeyframes(Element* element, const RenderStyle* style,
       const AtomicString& name, TimingFunction* defaultTimingFunction, Vector<std::pa
      ir<KeyframeAnimationEffect::KeyframeVector, RefPtr<TimingFunction> > >& keyframe
      sAndTimingFunctions) | 856 void StyleResolver::resolveKeyframes(Element* element, const RenderStyle& style,
       const AtomicString& name, TimingFunction* defaultTimingFunction, Vector<std::pa
      ir<KeyframeAnimationEffect::KeyframeVector, RefPtr<TimingFunction> > >& keyframe
      sAndTimingFunctions) | 
| 857 { | 857 { | 
| 858     ASSERT(RuntimeEnabledFeatures::webAnimationsCSSEnabled()); | 858     ASSERT(RuntimeEnabledFeatures::webAnimationsCSSEnabled()); | 
| 859     const StyleRuleKeyframes* keyframesRule = matchScopedKeyframesRule(element, 
      name.impl()); | 859     const StyleRuleKeyframes* keyframesRule = matchScopedKeyframesRule(element, 
      name.impl()); | 
| 860     if (!keyframesRule) | 860     if (!keyframesRule) | 
| 861         return; | 861         return; | 
| 862 | 862 | 
| 863     const Vector<RefPtr<StyleKeyframe> >& styleKeyframes = keyframesRule->keyfra
      mes(); | 863     const Vector<RefPtr<StyleKeyframe> >& styleKeyframes = keyframesRule->keyfra
      mes(); | 
| 864     if (styleKeyframes.isEmpty()) | 864     if (styleKeyframes.isEmpty()) | 
| 865         return; | 865         return; | 
| 866 | 866 | 
| 867     // Construct and populate the style for each keyframe | 867     // Construct and populate the style for each keyframe | 
| 868     KeyframeAnimationEffect::KeyframeVector keyframes; | 868     KeyframeAnimationEffect::KeyframeVector keyframes; | 
| 869     HashMap<double, RefPtr<TimingFunction> > perKeyframeTimingFunctions; | 869     HashMap<double, RefPtr<TimingFunction> > perKeyframeTimingFunctions; | 
| 870     for (size_t i = 0; i < styleKeyframes.size(); ++i) { | 870     for (size_t i = 0; i < styleKeyframes.size(); ++i) { | 
| 871         const StyleKeyframe* styleKeyframe = styleKeyframes[i].get(); | 871         const StyleKeyframe* styleKeyframe = styleKeyframes[i].get(); | 
| 872         RefPtr<RenderStyle> keyframeStyle = styleForKeyframe(element, style, sty
      leKeyframe); | 872         RefPtr<RenderStyle> keyframeStyle = styleForKeyframe(element, style, sty
      leKeyframe); | 
| 873         RefPtr<Keyframe> keyframe = Keyframe::create(); | 873         RefPtr<Keyframe> keyframe = Keyframe::create(); | 
| 874         const Vector<double>& offsets = styleKeyframe->keys(); | 874         const Vector<double>& offsets = styleKeyframe->keys(); | 
| 875         ASSERT(!offsets.isEmpty()); | 875         ASSERT(!offsets.isEmpty()); | 
| 876         keyframe->setOffset(offsets[0]); | 876         keyframe->setOffset(offsets[0]); | 
| 877         TimingFunction* timingFunction = defaultTimingFunction; | 877         TimingFunction* timingFunction = defaultTimingFunction; | 
| 878         const StylePropertySet* properties = styleKeyframe->properties(); | 878         const StylePropertySet* properties = styleKeyframe->properties(); | 
| 879         for (unsigned j = 0; j < properties->propertyCount(); j++) { | 879         for (unsigned j = 0; j < properties->propertyCount(); j++) { | 
| 880             CSSPropertyID property = properties->propertyAt(j).id(); | 880             CSSPropertyID property = properties->propertyAt(j).id(); | 
| 881             if (property == CSSPropertyWebkitAnimationTimingFunction || property
       == CSSPropertyAnimationTimingFunction) { | 881             if (property == CSSPropertyWebkitAnimationTimingFunction || property
       == CSSPropertyAnimationTimingFunction) { | 
| 882                 // FIXME: This sometimes gets the wrong timing function. See crb
      ug.com/288540. | 882                 // FIXME: This sometimes gets the wrong timing function. See crb
      ug.com/288540. | 
| 883                 timingFunction = KeyframeValue::timingFunction(keyframeStyle.get
      (), name); | 883                 timingFunction = KeyframeValue::timingFunction(keyframeStyle.get
      (), name); | 
| 884             } else if (CSSAnimations::isAnimatableProperty(property)) { | 884             } else if (CSSAnimations::isAnimatableProperty(property)) { | 
| 885                 keyframe->setPropertyValue(property, CSSAnimatableValueFactory::
      create(property, keyframeStyle.get()).get()); | 885                 keyframe->setPropertyValue(property, CSSAnimatableValueFactory::
      create(property, *keyframeStyle).get()); | 
| 886             } | 886             } | 
| 887         } | 887         } | 
| 888         keyframes.append(keyframe); | 888         keyframes.append(keyframe); | 
| 889         // The last keyframe specified at a given offset is used. | 889         // The last keyframe specified at a given offset is used. | 
| 890         perKeyframeTimingFunctions.set(offsets[0], timingFunction); | 890         perKeyframeTimingFunctions.set(offsets[0], timingFunction); | 
| 891         for (size_t j = 1; j < offsets.size(); ++j) { | 891         for (size_t j = 1; j < offsets.size(); ++j) { | 
| 892             keyframes.append(keyframe->cloneWithOffset(offsets[j])); | 892             keyframes.append(keyframe->cloneWithOffset(offsets[j])); | 
| 893             perKeyframeTimingFunctions.set(offsets[j], timingFunction); | 893             perKeyframeTimingFunctions.set(offsets[j], timingFunction); | 
| 894         } | 894         } | 
| 895     } | 895     } | 
| (...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1496 | 1496 | 
| 1497     // Now do the author and user normal priority properties and all the !import
      ant properties. | 1497     // Now do the author and user normal priority properties and all the !import
      ant properties. | 
| 1498     applyMatchedProperties<LowPriorityProperties>(state, matchResult, false, mat
      chResult.ranges.lastUARule + 1, matchResult.matchedProperties.size() - 1, applyI
      nheritedOnly); | 1498     applyMatchedProperties<LowPriorityProperties>(state, matchResult, false, mat
      chResult.ranges.lastUARule + 1, matchResult.matchedProperties.size() - 1, applyI
      nheritedOnly); | 
| 1499     applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc
      hResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInherite
      dOnly); | 1499     applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc
      hResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorRule, applyInherite
      dOnly); | 
| 1500     applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc
      hResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnl
      y); | 1500     applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc
      hResult.ranges.firstUserRule, matchResult.ranges.lastUserRule, applyInheritedOnl
      y); | 
| 1501     applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc
      hResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); | 1501     applyMatchedProperties<LowPriorityProperties>(state, matchResult, true, matc
      hResult.ranges.firstUARule, matchResult.ranges.lastUARule, applyInheritedOnly); | 
| 1502 | 1502 | 
| 1503     // animatingElement may be null, for example if we're calculating the | 1503     // animatingElement may be null, for example if we're calculating the | 
| 1504     // style for a potential pseudo element that has yet to be created. | 1504     // style for a potential pseudo element that has yet to be created. | 
| 1505     if (RuntimeEnabledFeatures::webAnimationsEnabled() && animatingElement) { | 1505     if (RuntimeEnabledFeatures::webAnimationsEnabled() && animatingElement) { | 
| 1506         state.setAnimationUpdate(CSSAnimations::calculateUpdate(animatingElement
      , state.style(), this)); | 1506         state.setAnimationUpdate(CSSAnimations::calculateUpdate(animatingElement
      , *state.style(), this)); | 
| 1507         if (state.animationUpdate()) { | 1507         if (state.animationUpdate()) { | 
| 1508             ASSERT(!applyInheritedOnly); | 1508             ASSERT(!applyInheritedOnly); | 
| 1509             const AnimationEffect::CompositableValueMap& compositableValuesForAn
      imations = state.animationUpdate()->compositableValuesForAnimations(); | 1509             const AnimationEffect::CompositableValueMap& compositableValuesForAn
      imations = state.animationUpdate()->compositableValuesForAnimations(); | 
| 1510             const AnimationEffect::CompositableValueMap& compositableValuesForTr
      ansitions = state.animationUpdate()->compositableValuesForTransitions(); | 1510             const AnimationEffect::CompositableValueMap& compositableValuesForTr
      ansitions = state.animationUpdate()->compositableValuesForTransitions(); | 
| 1511             // Apply animated properties, then reapply any rules marked importan
      t. | 1511             // Apply animated properties, then reapply any rules marked importan
      t. | 
| 1512             if (applyAnimatedProperties<HighPriorityProperties>(state, composita
      bleValuesForAnimations)) { | 1512             if (applyAnimatedProperties<HighPriorityProperties>(state, composita
      bleValuesForAnimations)) { | 
| 1513                 bool important = true; | 1513                 bool important = true; | 
| 1514                 applyMatchedProperties<HighPriorityProperties>(state, matchResul
      t, important, matchResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorR
      ule, applyInheritedOnly); | 1514                 applyMatchedProperties<HighPriorityProperties>(state, matchResul
      t, important, matchResult.ranges.firstAuthorRule, matchResult.ranges.lastAuthorR
      ule, applyInheritedOnly); | 
| 1515                 applyMatchedProperties<HighPriorityProperties>(state, matchResul
      t, important, matchResult.ranges.firstUserRule, matchResult.ranges.lastUserRule,
       applyInheritedOnly); | 1515                 applyMatchedProperties<HighPriorityProperties>(state, matchResul
      t, important, matchResult.ranges.firstUserRule, matchResult.ranges.lastUserRule,
       applyInheritedOnly); | 
| 1516                 applyMatchedProperties<HighPriorityProperties>(state, matchResul
      t, important, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, app
      lyInheritedOnly); | 1516                 applyMatchedProperties<HighPriorityProperties>(state, matchResul
      t, important, matchResult.ranges.firstUARule, matchResult.ranges.lastUARule, app
      lyInheritedOnly); | 
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1612         m_matchedPropertiesSearches, m_matchedPropertiesHit, m_matchedProperties
      SharedInheritedHit, m_matchedPropertiesToCache, m_matchedPropertiesEnteredIntoCa
      che); | 1612         m_matchedPropertiesSearches, m_matchedPropertiesHit, m_matchedProperties
      SharedInheritedHit, m_matchedPropertiesToCache, m_matchedPropertiesEnteredIntoCa
      che); | 
| 1613 | 1613 | 
| 1614     fprintf(stderr, "Total:\n"); | 1614     fprintf(stderr, "Total:\n"); | 
| 1615     printStyleStats(m_totalSearches, m_totalElementsEligibleForSharing, m_totalS
      tylesShared, m_totalSearchFoundSiblingForSharing, m_totalSearchesMissedSharing, | 1615     printStyleStats(m_totalSearches, m_totalElementsEligibleForSharing, m_totalS
      tylesShared, m_totalSearchFoundSiblingForSharing, m_totalSearchesMissedSharing, | 
| 1616         m_totalMatchedPropertiesSearches, m_totalMatchedPropertiesHit, m_totalMa
      tchedPropertiesSharedInheritedHit, m_totalMatchedPropertiesToCache, m_totalMatch
      edPropertiesEnteredIntoCache); | 1616         m_totalMatchedPropertiesSearches, m_totalMatchedPropertiesHit, m_totalMa
      tchedPropertiesSharedInheritedHit, m_totalMatchedPropertiesToCache, m_totalMatch
      edPropertiesEnteredIntoCache); | 
| 1617     fprintf(stderr, "-----------------------------------------------------------
      ---------------------\n"); | 1617     fprintf(stderr, "-----------------------------------------------------------
      ---------------------\n"); | 
| 1618 } | 1618 } | 
| 1619 #endif | 1619 #endif | 
| 1620 | 1620 | 
| 1621 } // namespace WebCore | 1621 } // namespace WebCore | 
| OLD | NEW | 
|---|