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

Side by Side Diff: third_party/WebKit/Source/core/animation/CSSColorInterpolationType.cpp

Issue 1713513002: Rename -webkit-text to -internal-quirk-inherit, limiting it to UA style (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase; add new (negative) test Created 4 years, 10 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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/animation/CSSColorInterpolationType.h" 5 #include "core/animation/CSSColorInterpolationType.h"
6 6
7 #include "core/animation/ColorPropertyFunctions.h" 7 #include "core/animation/ColorPropertyFunctions.h"
8 #include "core/css/parser/CSSPropertyParser.h" 8 #include "core/css/parser/CSSPropertyParser.h"
9 #include "core/css/resolver/StyleResolverState.h" 9 #include "core/css/resolver/StyleResolverState.h"
10 #include "core/layout/LayoutTheme.h" 10 #include "core/layout/LayoutTheme.h"
11 11
12 namespace blink { 12 namespace blink {
13 13
14 enum InterpolableColorIndex { 14 enum InterpolableColorIndex {
15 Red, 15 Red,
16 Green, 16 Green,
17 Blue, 17 Blue,
18 Alpha, 18 Alpha,
19 Currentcolor, 19 Currentcolor,
20 WebkitActivelink, 20 WebkitActivelink,
21 WebkitLink, 21 WebkitLink,
22 WebkitText, 22 QuirkInherit,
23 InterpolableColorIndexCount, 23 InterpolableColorIndexCount,
24 }; 24 };
25 25
26 static PassOwnPtr<InterpolableValue> createInterpolableColorForIndex(Interpolabl eColorIndex index) 26 static PassOwnPtr<InterpolableValue> createInterpolableColorForIndex(Interpolabl eColorIndex index)
27 { 27 {
28 ASSERT(index < InterpolableColorIndexCount); 28 ASSERT(index < InterpolableColorIndexCount);
29 OwnPtr<InterpolableList> list = InterpolableList::create(InterpolableColorIn dexCount); 29 OwnPtr<InterpolableList> list = InterpolableList::create(InterpolableColorIn dexCount);
30 for (int i = 0; i < InterpolableColorIndexCount; i++) 30 for (int i = 0; i < InterpolableColorIndexCount; i++)
31 list->set(i, InterpolableNumber::create(i == index)); 31 list->set(i, InterpolableNumber::create(i == index));
32 return list.release(); 32 return list.release();
33 } 33 }
34 34
35 PassOwnPtr<InterpolableValue> CSSColorInterpolationType::createInterpolableColor (const Color& color) 35 PassOwnPtr<InterpolableValue> CSSColorInterpolationType::createInterpolableColor (const Color& color)
36 { 36 {
37 OwnPtr<InterpolableList> list = InterpolableList::create(InterpolableColorIn dexCount); 37 OwnPtr<InterpolableList> list = InterpolableList::create(InterpolableColorIn dexCount);
38 list->set(Red, InterpolableNumber::create(color.red() * color.alpha())); 38 list->set(Red, InterpolableNumber::create(color.red() * color.alpha()));
39 list->set(Green, InterpolableNumber::create(color.green() * color.alpha())); 39 list->set(Green, InterpolableNumber::create(color.green() * color.alpha()));
40 list->set(Blue, InterpolableNumber::create(color.blue() * color.alpha())); 40 list->set(Blue, InterpolableNumber::create(color.blue() * color.alpha()));
41 list->set(Alpha, InterpolableNumber::create(color.alpha())); 41 list->set(Alpha, InterpolableNumber::create(color.alpha()));
42 list->set(Currentcolor, InterpolableNumber::create(0)); 42 list->set(Currentcolor, InterpolableNumber::create(0));
43 list->set(WebkitActivelink, InterpolableNumber::create(0)); 43 list->set(WebkitActivelink, InterpolableNumber::create(0));
44 list->set(WebkitLink, InterpolableNumber::create(0)); 44 list->set(WebkitLink, InterpolableNumber::create(0));
45 list->set(WebkitText, InterpolableNumber::create(0)); 45 list->set(QuirkInherit, InterpolableNumber::create(0));
46 return list.release(); 46 return list.release();
47 } 47 }
48 48
49 PassOwnPtr<InterpolableValue> CSSColorInterpolationType::createInterpolableColor (CSSValueID keyword) 49 PassOwnPtr<InterpolableValue> CSSColorInterpolationType::createInterpolableColor (CSSValueID keyword)
50 { 50 {
51 switch (keyword) { 51 switch (keyword) {
52 case CSSValueCurrentcolor: 52 case CSSValueCurrentcolor:
53 return createInterpolableColorForIndex(Currentcolor); 53 return createInterpolableColorForIndex(Currentcolor);
54 case CSSValueWebkitActivelink: 54 case CSSValueWebkitActivelink:
55 return createInterpolableColorForIndex(WebkitActivelink); 55 return createInterpolableColorForIndex(WebkitActivelink);
56 case CSSValueWebkitLink: 56 case CSSValueWebkitLink:
57 return createInterpolableColorForIndex(WebkitLink); 57 return createInterpolableColorForIndex(WebkitLink);
58 case CSSValueWebkitText: 58 case CSSValueInternalQuirkInherit:
59 return createInterpolableColorForIndex(WebkitText); 59 return createInterpolableColorForIndex(QuirkInherit);
60 case CSSValueWebkitFocusRingColor: 60 case CSSValueWebkitFocusRingColor:
61 return createInterpolableColor(LayoutTheme::theme().focusRingColor()); 61 return createInterpolableColor(LayoutTheme::theme().focusRingColor());
62 default: 62 default:
63 ASSERT(CSSPropertyParser::isColorKeyword(keyword)); 63 ASSERT(CSSPropertyParser::isColorKeyword(keyword));
64 return createInterpolableColor(StyleColor::colorFromKeyword(keyword)); 64 return createInterpolableColor(StyleColor::colorFromKeyword(keyword));
65 } 65 }
66 } 66 }
67 67
68 PassOwnPtr<InterpolableValue> CSSColorInterpolationType::createInterpolableColor (const StyleColor& color) 68 PassOwnPtr<InterpolableValue> CSSColorInterpolationType::createInterpolableColor (const StyleColor& color)
69 { 69 {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 currentStyleColor = currentColorGetter(CSSPropertyWebkitTextFillColo r, *state.style()); 112 currentStyleColor = currentColorGetter(CSSPropertyWebkitTextFillColo r, *state.style());
113 if (currentStyleColor.isCurrentColor()) 113 if (currentStyleColor.isCurrentColor())
114 currentStyleColor = currentColorGetter(CSSPropertyColor, *state.styl e()); 114 currentStyleColor = currentColorGetter(CSSPropertyColor, *state.styl e());
115 addPremultipliedColor(red, green, blue, alpha, currentcolorFraction, cur rentStyleColor.color()); 115 addPremultipliedColor(red, green, blue, alpha, currentcolorFraction, cur rentStyleColor.color());
116 } 116 }
117 const TextLinkColors& colors = state.document().textLinkColors(); 117 const TextLinkColors& colors = state.document().textLinkColors();
118 if (double webkitActivelinkFraction = toInterpolableNumber(list.get(WebkitAc tivelink))->value()) 118 if (double webkitActivelinkFraction = toInterpolableNumber(list.get(WebkitAc tivelink))->value())
119 addPremultipliedColor(red, green, blue, alpha, webkitActivelinkFraction, colors.activeLinkColor()); 119 addPremultipliedColor(red, green, blue, alpha, webkitActivelinkFraction, colors.activeLinkColor());
120 if (double webkitLinkFraction = toInterpolableNumber(list.get(WebkitLink))-> value()) 120 if (double webkitLinkFraction = toInterpolableNumber(list.get(WebkitLink))-> value())
121 addPremultipliedColor(red, green, blue, alpha, webkitLinkFraction, isVis ited ? colors.visitedLinkColor() : colors.linkColor()); 121 addPremultipliedColor(red, green, blue, alpha, webkitLinkFraction, isVis ited ? colors.visitedLinkColor() : colors.linkColor());
122 if (double webkitTextFraction = toInterpolableNumber(list.get(WebkitText))-> value()) 122 if (double quirkInheritFraction = toInterpolableNumber(list.get(QuirkInherit ))->value())
123 addPremultipliedColor(red, green, blue, alpha, webkitTextFraction, color s.textColor()); 123 addPremultipliedColor(red, green, blue, alpha, quirkInheritFraction, col ors.textColor());
124 124
125 alpha = clampTo<double>(alpha, 0, 255); 125 alpha = clampTo<double>(alpha, 0, 255);
126 if (alpha == 0) 126 if (alpha == 0)
127 return Color::transparent; 127 return Color::transparent;
128 128
129 return makeRGBA( 129 return makeRGBA(
130 round(red / alpha), 130 round(red / alpha),
131 round(green / alpha), 131 round(green / alpha),
132 round(blue / alpha), 132 round(blue / alpha),
133 round(alpha)); 133 round(alpha));
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 { 215 {
216 const InterpolableList& colorPair = toInterpolableList(interpolableValue); 216 const InterpolableList& colorPair = toInterpolableList(interpolableValue);
217 ASSERT(colorPair.length() == InterpolableColorPairIndexCount); 217 ASSERT(colorPair.length() == InterpolableColorPairIndexCount);
218 ColorPropertyFunctions::setUnvisitedColor(cssProperty(), *environment.state( ).style(), 218 ColorPropertyFunctions::setUnvisitedColor(cssProperty(), *environment.state( ).style(),
219 resolveInterpolableColor(*colorPair.get(Unvisited), environment.state(), false, cssProperty() == CSSPropertyTextDecorationColor)); 219 resolveInterpolableColor(*colorPair.get(Unvisited), environment.state(), false, cssProperty() == CSSPropertyTextDecorationColor));
220 ColorPropertyFunctions::setVisitedColor(cssProperty(), *environment.state(). style(), 220 ColorPropertyFunctions::setVisitedColor(cssProperty(), *environment.state(). style(),
221 resolveInterpolableColor(*colorPair.get(Visited), environment.state(), t rue, cssProperty() == CSSPropertyTextDecorationColor)); 221 resolveInterpolableColor(*colorPair.get(Visited), environment.state(), t rue, cssProperty() == CSSPropertyTextDecorationColor));
222 } 222 }
223 223
224 } // namespace blink 224 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698