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

Side by Side Diff: Source/core/svg/SVGAnimatedColor.cpp

Issue 678163002: Oilpan: move SVG property hierarchy to the heap. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased upto r185213 Created 6 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/svg/SVGAnimatedColor.h ('k') | Source/core/svg/SVGAnimatedEnumeration.h » ('j') | 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) Research In Motion Limited 2011. All rights reserved. 2 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 14 matching lines...) Expand all
25 #include "core/svg/ColorDistance.h" 25 #include "core/svg/ColorDistance.h"
26 #include "core/svg/SVGAnimateElement.h" 26 #include "core/svg/SVGAnimateElement.h"
27 27
28 namespace blink { 28 namespace blink {
29 29
30 String SVGColorProperty::valueAsString() const 30 String SVGColorProperty::valueAsString() const
31 { 31 {
32 return m_styleColor.isCurrentColor() ? "currentColor" : m_styleColor.color() .serializedAsCSSComponentValue(); 32 return m_styleColor.isCurrentColor() ? "currentColor" : m_styleColor.color() .serializedAsCSSComponentValue();
33 } 33 }
34 34
35 PassRefPtr<SVGPropertyBase> SVGColorProperty::cloneForAnimation(const String&) c onst 35 PassRefPtrWillBeRawPtr<SVGPropertyBase> SVGColorProperty::cloneForAnimation(cons t String&) const
36 { 36 {
37 // SVGAnimatedColor is deprecated. So No SVG DOM animation. 37 // SVGAnimatedColor is deprecated. So No SVG DOM animation.
38 ASSERT_NOT_REACHED(); 38 ASSERT_NOT_REACHED();
39 return nullptr; 39 return nullptr;
40 } 40 }
41 41
42 static inline Color fallbackColorForCurrentColor(SVGElement* targetElement) 42 static inline Color fallbackColorForCurrentColor(SVGElement* targetElement)
43 { 43 {
44 ASSERT(targetElement); 44 ASSERT(targetElement);
45 if (RenderObject* targetRenderer = targetElement->renderer()) 45 if (RenderObject* targetRenderer = targetElement->renderer())
46 return targetRenderer->style()->visitedDependentColor(CSSPropertyColor); 46 return targetRenderer->style()->visitedDependentColor(CSSPropertyColor);
47 else 47 else
48 return Color::transparent; 48 return Color::transparent;
49 } 49 }
50 50
51 void SVGColorProperty::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGEle ment* contextElement) 51 void SVGColorProperty::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGEle ment* contextElement)
52 { 52 {
53 ASSERT(contextElement); 53 ASSERT(contextElement);
54 54
55 Color fallbackColor = fallbackColorForCurrentColor(contextElement); 55 Color fallbackColor = fallbackColorForCurrentColor(contextElement);
56 Color fromColor = toSVGColorProperty(other)->m_styleColor.resolve(fallbackCo lor); 56 Color fromColor = toSVGColorProperty(other)->m_styleColor.resolve(fallbackCo lor);
57 Color toColor = m_styleColor.resolve(fallbackColor); 57 Color toColor = m_styleColor.resolve(fallbackColor);
58 m_styleColor = StyleColor(ColorDistance::addColors(fromColor, toColor)); 58 m_styleColor = StyleColor(ColorDistance::addColors(fromColor, toColor));
59 } 59 }
60 60
61 void SVGColorProperty::calculateAnimatedValue(SVGAnimationElement* animationElem ent, float percentage, unsigned repeatCount, PassRefPtr<SVGPropertyBase> fromVal ue, PassRefPtr<SVGPropertyBase> toValue, PassRefPtr<SVGPropertyBase> toAtEndOfDu rationValue, SVGElement* contextElement) 61 void SVGColorProperty::calculateAnimatedValue(SVGAnimationElement* animationElem ent, float percentage, unsigned repeatCount, PassRefPtrWillBeRawPtr<SVGPropertyB ase> fromValue, PassRefPtrWillBeRawPtr<SVGPropertyBase> toValue, PassRefPtrWillB eRawPtr<SVGPropertyBase> toAtEndOfDurationValue, SVGElement* contextElement)
62 { 62 {
63 StyleColor fromStyleColor = toSVGColorProperty(fromValue)->m_styleColor; 63 StyleColor fromStyleColor = toSVGColorProperty(fromValue)->m_styleColor;
64 StyleColor toStyleColor = toSVGColorProperty(toValue)->m_styleColor; 64 StyleColor toStyleColor = toSVGColorProperty(toValue)->m_styleColor;
65 StyleColor toAtEndOfDurationStyleColor = toSVGColorProperty(toAtEndOfDuratio nValue)->m_styleColor; 65 StyleColor toAtEndOfDurationStyleColor = toSVGColorProperty(toAtEndOfDuratio nValue)->m_styleColor;
66 66
67 // Apply currentColor rules. 67 // Apply currentColor rules.
68 ASSERT(contextElement); 68 ASSERT(contextElement);
69 Color fallbackColor = fallbackColorForCurrentColor(contextElement); 69 Color fallbackColor = fallbackColorForCurrentColor(contextElement);
70 Color fromColor = fromStyleColor.resolve(fallbackColor); 70 Color fromColor = fromStyleColor.resolve(fallbackColor);
71 Color toColor = toStyleColor.resolve(fallbackColor); 71 Color toColor = toStyleColor.resolve(fallbackColor);
72 Color toAtEndOfDurationColor = toAtEndOfDurationStyleColor.resolve(fallbackC olor); 72 Color toAtEndOfDurationColor = toAtEndOfDurationStyleColor.resolve(fallbackC olor);
73 Color animatedColor = m_styleColor.resolve(fallbackColor); 73 Color animatedColor = m_styleColor.resolve(fallbackColor);
74 74
75 ASSERT(animationElement); 75 ASSERT(animationElement);
76 float animatedRed = animatedColor.red(); 76 float animatedRed = animatedColor.red();
77 animationElement->animateAdditiveNumber(percentage, repeatCount, fromColor.r ed(), toColor.red(), toAtEndOfDurationColor.red(), animatedRed); 77 animationElement->animateAdditiveNumber(percentage, repeatCount, fromColor.r ed(), toColor.red(), toAtEndOfDurationColor.red(), animatedRed);
78 78
79 float animatedGreen = animatedColor.green(); 79 float animatedGreen = animatedColor.green();
80 animationElement->animateAdditiveNumber(percentage, repeatCount, fromColor.g reen(), toColor.green(), toAtEndOfDurationColor.green(), animatedGreen); 80 animationElement->animateAdditiveNumber(percentage, repeatCount, fromColor.g reen(), toColor.green(), toAtEndOfDurationColor.green(), animatedGreen);
81 81
82 float animatedBlue = animatedColor.blue(); 82 float animatedBlue = animatedColor.blue();
83 animationElement->animateAdditiveNumber(percentage, repeatCount, fromColor.b lue(), toColor.blue(), toAtEndOfDurationColor.blue(), animatedBlue); 83 animationElement->animateAdditiveNumber(percentage, repeatCount, fromColor.b lue(), toColor.blue(), toAtEndOfDurationColor.blue(), animatedBlue);
84 84
85 float animatedAlpha = animatedColor.alpha(); 85 float animatedAlpha = animatedColor.alpha();
86 animationElement->animateAdditiveNumber(percentage, repeatCount, fromColor.a lpha(), toColor.alpha(), toAtEndOfDurationColor.alpha(), animatedAlpha); 86 animationElement->animateAdditiveNumber(percentage, repeatCount, fromColor.a lpha(), toColor.alpha(), toAtEndOfDurationColor.alpha(), animatedAlpha);
87 87
88 m_styleColor = StyleColor(makeRGBA(roundf(animatedRed), roundf(animatedGreen ), roundf(animatedBlue), roundf(animatedAlpha))); 88 m_styleColor = StyleColor(makeRGBA(roundf(animatedRed), roundf(animatedGreen ), roundf(animatedBlue), roundf(animatedAlpha)));
89 } 89 }
90 90
91 float SVGColorProperty::calculateDistance(PassRefPtr<SVGPropertyBase> toValue, S VGElement* contextElement) 91 float SVGColorProperty::calculateDistance(PassRefPtrWillBeRawPtr<SVGPropertyBase > toValue, SVGElement* contextElement)
92 { 92 {
93 ASSERT(contextElement); 93 ASSERT(contextElement);
94 Color fallbackColor = fallbackColorForCurrentColor(contextElement); 94 Color fallbackColor = fallbackColorForCurrentColor(contextElement);
95 95
96 Color fromColor = m_styleColor.resolve(fallbackColor); 96 Color fromColor = m_styleColor.resolve(fallbackColor);
97 Color toColor = toSVGColorProperty(toValue)->m_styleColor.resolve(fallbackCo lor); 97 Color toColor = toSVGColorProperty(toValue)->m_styleColor.resolve(fallbackCo lor);
98 return ColorDistance::distance(fromColor, toColor); 98 return ColorDistance::distance(fromColor, toColor);
99 } 99 }
100 100
101 } 101 }
OLDNEW
« no previous file with comments | « Source/core/svg/SVGAnimatedColor.h ('k') | Source/core/svg/SVGAnimatedEnumeration.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698