| 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 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 775 // FIXME: Shouldn't this be on RenderBody::styleDidChange? | 775 // FIXME: Shouldn't this be on RenderBody::styleDidChange? |
| 776 if (element->hasTagName(bodyTag)) | 776 if (element->hasTagName(bodyTag)) |
| 777 document().textLinkColors().setTextColor(state.style()->visitedDependent
Color(CSSPropertyColor)); | 777 document().textLinkColors().setTextColor(state.style()->visitedDependent
Color(CSSPropertyColor)); |
| 778 | 778 |
| 779 setAnimationUpdateIfNeeded(state, *element); | 779 setAnimationUpdateIfNeeded(state, *element); |
| 780 | 780 |
| 781 // Now return the style. | 781 // Now return the style. |
| 782 return state.takeStyle(); | 782 return state.takeStyle(); |
| 783 } | 783 } |
| 784 | 784 |
| 785 PassRefPtr<RenderStyle> StyleResolver::styleForKeyframe(Element* e, const Render
Style& elementStyle, const StyleKeyframe* keyframe) | 785 PassRefPtr<RenderStyle> StyleResolver::styleForKeyframe(Element* e, const Render
Style& elementStyle, const StyleKeyframe* keyframe, const AtomicString& animatio
nName) |
| 786 { | 786 { |
| 787 ASSERT(document().frame()); | 787 ASSERT(document().frame()); |
| 788 ASSERT(documentSettings()); | 788 ASSERT(documentSettings()); |
| 789 ASSERT(!hasPendingAuthorStyleSheets()); | 789 ASSERT(!hasPendingAuthorStyleSheets()); |
| 790 | 790 |
| 791 if (e == document().documentElement()) | 791 if (e == document().documentElement()) |
| 792 resetDirectionAndWritingModeOnDocument(document()); | 792 resetDirectionAndWritingModeOnDocument(document()); |
| 793 StyleResolverState state(document(), e); | 793 StyleResolverState state(document(), e); |
| 794 | 794 |
| 795 MatchResult result; | 795 MatchResult result; |
| 796 if (keyframe->properties()) | 796 if (keyframe->properties()) |
| 797 result.addMatchedProperties(keyframe->properties()); | 797 result.addMatchedProperties(keyframe->properties()); |
| 798 | 798 |
| 799 ASSERT(!state.style()); | 799 ASSERT(!state.style()); |
| 800 | 800 |
| 801 // Create the style | 801 // Create the style |
| 802 state.setStyle(RenderStyle::clone(&elementStyle)); | 802 state.setStyle(RenderStyle::clone(&elementStyle)); |
| 803 state.setLineHeightValue(0); | 803 state.setLineHeightValue(0); |
| 804 | 804 |
| 805 // Make sure that the CSSAnimationData for the animation to which this |
| 806 // keyframe belongs is first in the list. This makes sure that if the |
| 807 // animation-timing-function property is set for this keyframe, it will be |
| 808 // applied to the correct CSSAnimationData object. Note that objects other |
| 809 // than the first in the list are ignored when reading the timing function |
| 810 // value. See KeyframeValue::timingFunction(). |
| 811 CSSAnimationDataList* animations = state.style()->accessAnimations(); |
| 812 ASSERT(animations && !animations->isEmpty()); |
| 813 while (animations->animation(0)->name() != animationName) |
| 814 animations->remove(0); |
| 815 ASSERT(!animations->isEmpty() && animations->animation(0)->name() == animati
onName); |
| 816 |
| 805 state.fontBuilder().initForStyleResolve(state.document(), state.style(), sta
te.useSVGZoomRules()); | 817 state.fontBuilder().initForStyleResolve(state.document(), state.style(), sta
te.useSVGZoomRules()); |
| 806 | 818 |
| 807 // We don't need to bother with !important. Since there is only ever one | 819 // We don't need to bother with !important. Since there is only ever one |
| 808 // decl, there's nothing to override. So just add the first properties. | 820 // decl, there's nothing to override. So just add the first properties. |
| 809 bool inheritedOnly = false; | 821 bool inheritedOnly = false; |
| 810 if (keyframe->properties()) { | 822 if (keyframe->properties()) { |
| 811 // FIXME: Can't keyframes contain variables? | 823 // FIXME: Can't keyframes contain variables? |
| 812 applyMatchedProperties<AnimationProperties>(state, result, false, 0, res
ult.matchedProperties.size() - 1, inheritedOnly); | 824 applyMatchedProperties<AnimationProperties>(state, result, false, 0, res
ult.matchedProperties.size() - 1, inheritedOnly); |
| 813 applyMatchedProperties<HighPriorityProperties>(state, result, false, 0,
result.matchedProperties.size() - 1, inheritedOnly); | 825 applyMatchedProperties<HighPriorityProperties>(state, result, false, 0,
result.matchedProperties.size() - 1, inheritedOnly); |
| 814 } | 826 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 845 // Get the keyframesRule for this name | 857 // Get the keyframesRule for this name |
| 846 if (!e || list.animationName().isEmpty()) | 858 if (!e || list.animationName().isEmpty()) |
| 847 return; | 859 return; |
| 848 | 860 |
| 849 ASSERT(!hasPendingAuthorStyleSheets()); | 861 ASSERT(!hasPendingAuthorStyleSheets()); |
| 850 const StyleRuleKeyframes* keyframesRule = CSSAnimations::matchScopedKeyframe
sRule(this, e, list.animationName().impl()); | 862 const StyleRuleKeyframes* keyframesRule = CSSAnimations::matchScopedKeyframe
sRule(this, e, list.animationName().impl()); |
| 851 if (!keyframesRule) | 863 if (!keyframesRule) |
| 852 return; | 864 return; |
| 853 | 865 |
| 854 // Construct and populate the style for each keyframe | 866 // Construct and populate the style for each keyframe |
| 867 const AtomicString& name = list.animationName(); |
| 855 const Vector<RefPtr<StyleKeyframe> >& keyframes = keyframesRule->keyframes()
; | 868 const Vector<RefPtr<StyleKeyframe> >& keyframes = keyframesRule->keyframes()
; |
| 856 for (unsigned i = 0; i < keyframes.size(); ++i) { | 869 for (unsigned i = 0; i < keyframes.size(); ++i) { |
| 857 // Apply the declaration to the style. This is a simplified version of t
he logic in styleForElement | 870 // Apply the declaration to the style. This is a simplified version of t
he logic in styleForElement |
| 858 const StyleKeyframe* keyframe = keyframes[i].get(); | 871 const StyleKeyframe* keyframe = keyframes[i].get(); |
| 859 | 872 |
| 860 KeyframeValue keyframeValue(0, 0); | 873 KeyframeValue keyframeValue(0, 0); |
| 861 keyframeValue.setStyle(styleForKeyframe(e, elementStyle, keyframe)); | 874 keyframeValue.setStyle(styleForKeyframe(e, elementStyle, keyframe, name)
); |
| 862 keyframeValue.addProperties(keyframe->properties()); | 875 keyframeValue.addProperties(keyframe->properties()); |
| 863 | 876 |
| 864 // Add this keyframe style to all the indicated key times | 877 // Add this keyframe style to all the indicated key times |
| 865 const Vector<double>& keys = keyframe->keys(); | 878 const Vector<double>& keys = keyframe->keys(); |
| 866 for (size_t keyIndex = 0; keyIndex < keys.size(); ++keyIndex) { | 879 for (size_t keyIndex = 0; keyIndex < keys.size(); ++keyIndex) { |
| 867 keyframeValue.setKey(keys[keyIndex]); | 880 keyframeValue.setKey(keys[keyIndex]); |
| 868 list.insert(keyframeValue); | 881 list.insert(keyframeValue); |
| 869 } | 882 } |
| 870 } | 883 } |
| 871 | 884 |
| 872 // If the 0% keyframe is missing, create it (but only if there is at least o
ne other keyframe) | 885 // If the 0% keyframe is missing, create it (but only if there is at least o
ne other keyframe) |
| 873 int initialListSize = list.size(); | 886 int initialListSize = list.size(); |
| 874 if (initialListSize > 0 && list[0].key()) { | 887 if (initialListSize > 0 && list[0].key()) { |
| 875 static StyleKeyframe* zeroPercentKeyframe; | 888 static StyleKeyframe* zeroPercentKeyframe; |
| 876 if (!zeroPercentKeyframe) { | 889 if (!zeroPercentKeyframe) { |
| 877 zeroPercentKeyframe = StyleKeyframe::create().leakRef(); | 890 zeroPercentKeyframe = StyleKeyframe::create().leakRef(); |
| 878 zeroPercentKeyframe->setKeyText("0%"); | 891 zeroPercentKeyframe->setKeyText("0%"); |
| 879 } | 892 } |
| 880 KeyframeValue keyframeValue(0, 0); | 893 KeyframeValue keyframeValue(0, 0); |
| 881 keyframeValue.setStyle(styleForKeyframe(e, elementStyle, zeroPercentKeyf
rame)); | 894 keyframeValue.setStyle(styleForKeyframe(e, elementStyle, zeroPercentKeyf
rame, name)); |
| 882 keyframeValue.addProperties(zeroPercentKeyframe->properties()); | 895 keyframeValue.addProperties(zeroPercentKeyframe->properties()); |
| 883 list.insert(keyframeValue); | 896 list.insert(keyframeValue); |
| 884 } | 897 } |
| 885 | 898 |
| 886 // If the 100% keyframe is missing, create it (but only if there is at least
one other keyframe) | 899 // If the 100% keyframe is missing, create it (but only if there is at least
one other keyframe) |
| 887 if (initialListSize > 0 && (list[list.size() - 1].key() != 1)) { | 900 if (initialListSize > 0 && (list[list.size() - 1].key() != 1)) { |
| 888 static StyleKeyframe* hundredPercentKeyframe; | 901 static StyleKeyframe* hundredPercentKeyframe; |
| 889 if (!hundredPercentKeyframe) { | 902 if (!hundredPercentKeyframe) { |
| 890 hundredPercentKeyframe = StyleKeyframe::create().leakRef(); | 903 hundredPercentKeyframe = StyleKeyframe::create().leakRef(); |
| 891 hundredPercentKeyframe->setKeyText("100%"); | 904 hundredPercentKeyframe->setKeyText("100%"); |
| 892 } | 905 } |
| 893 KeyframeValue keyframeValue(1, 0); | 906 KeyframeValue keyframeValue(1, 0); |
| 894 keyframeValue.setStyle(styleForKeyframe(e, elementStyle, hundredPercentK
eyframe)); | 907 keyframeValue.setStyle(styleForKeyframe(e, elementStyle, hundredPercentK
eyframe, name)); |
| 895 keyframeValue.addProperties(hundredPercentKeyframe->properties()); | 908 keyframeValue.addProperties(hundredPercentKeyframe->properties()); |
| 896 list.insert(keyframeValue); | 909 list.insert(keyframeValue); |
| 897 } | 910 } |
| 898 } | 911 } |
| 899 | 912 |
| 900 PassRefPtr<RenderStyle> StyleResolver::pseudoStyleForElement(Element* e, const P
seudoStyleRequest& pseudoStyleRequest, RenderStyle* parentStyle) | 913 PassRefPtr<RenderStyle> StyleResolver::pseudoStyleForElement(Element* e, const P
seudoStyleRequest& pseudoStyleRequest, RenderStyle* parentStyle) |
| 901 { | 914 { |
| 902 ASSERT(document().frame()); | 915 ASSERT(document().frame()); |
| 903 ASSERT(documentSettings()); | 916 ASSERT(documentSettings()); |
| 904 ASSERT(parentStyle); | 917 ASSERT(parentStyle); |
| (...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1462 bool StyleResolver::affectedByViewportChange() const | 1475 bool StyleResolver::affectedByViewportChange() const |
| 1463 { | 1476 { |
| 1464 for (unsigned i = 0; i < m_viewportDependentMediaQueryResults.size(); ++i) { | 1477 for (unsigned i = 0; i < m_viewportDependentMediaQueryResults.size(); ++i) { |
| 1465 if (m_medium->eval(&m_viewportDependentMediaQueryResults[i]->m_expressio
n) != m_viewportDependentMediaQueryResults[i]->m_result) | 1478 if (m_medium->eval(&m_viewportDependentMediaQueryResults[i]->m_expressio
n) != m_viewportDependentMediaQueryResults[i]->m_result) |
| 1466 return true; | 1479 return true; |
| 1467 } | 1480 } |
| 1468 return false; | 1481 return false; |
| 1469 } | 1482 } |
| 1470 | 1483 |
| 1471 } // namespace WebCore | 1484 } // namespace WebCore |
| OLD | NEW |