OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. |
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) | 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) |
8 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 8 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
9 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. | 9 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. |
10 * Copyright (C) 2013 Google Inc. All rights reserved. | 10 * Copyright (C) 2013 Google Inc. All rights reserved. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
52 m_visitedLinkColor = Color(85, 26, 139); | 52 m_visitedLinkColor = Color(85, 26, 139); |
53 } | 53 } |
54 | 54 |
55 void TextLinkColors::resetActiveLinkColor() | 55 void TextLinkColors::resetActiveLinkColor() |
56 { | 56 { |
57 m_activeLinkColor = Color(255, 0, 0); | 57 m_activeLinkColor = Color(255, 0, 0); |
58 } | 58 } |
59 | 59 |
60 static Color colorForCSSValue(CSSValueID cssValueId) | 60 static Color colorForCSSValue(CSSValueID cssValueId) |
61 { | 61 { |
62 struct ColorValue { | 62 if (const char* valueName = getValueName(cssValueId)) { |
63 CSSValueID cssValueId; | 63 if (const NamedColor* namedColor = findColor(valueName, strlen(valueName ))) |
fs
2015/07/16 17:06:03
This is likely a bit slower than the previous code
| |
64 RGBA32 color; | 64 return Color(namedColor->ARGBValue); |
65 }; | |
66 | |
67 static const ColorValue colorValues[] = { | |
68 { CSSValueAqua, 0xFF00FFFF }, | |
69 { CSSValueBlack, 0xFF000000 }, | |
70 { CSSValueBlue, 0xFF0000FF }, | |
71 { CSSValueFuchsia, 0xFFFF00FF }, | |
72 { CSSValueGray, 0xFF808080 }, | |
73 { CSSValueGreen, 0xFF008000 }, | |
74 { CSSValueGrey, 0xFF808080 }, | |
75 { CSSValueLime, 0xFF00FF00 }, | |
76 { CSSValueMaroon, 0xFF800000 }, | |
77 { CSSValueNavy, 0xFF000080 }, | |
78 { CSSValueOlive, 0xFF808000 }, | |
79 { CSSValueOrange, 0xFFFFA500 }, | |
80 { CSSValuePurple, 0xFF800080 }, | |
81 { CSSValueRed, 0xFFFF0000 }, | |
82 { CSSValueSilver, 0xFFC0C0C0 }, | |
83 { CSSValueTeal, 0xFF008080 }, | |
84 { CSSValueTransparent, 0x00000000 }, | |
85 { CSSValueWhite, 0xFFFFFFFF }, | |
86 { CSSValueYellow, 0xFFFFFF00 }, | |
87 { CSSValueInvalid, CSSValueInvalid } | |
88 }; | |
89 | |
90 for (const ColorValue* col = colorValues; col->cssValueId; ++col) { | |
91 if (col->cssValueId == cssValueId) | |
92 return col->color; | |
93 } | 65 } |
94 return LayoutTheme::theme().systemColor(cssValueId); | 66 return LayoutTheme::theme().systemColor(cssValueId); |
95 } | 67 } |
96 | 68 |
97 Color TextLinkColors::colorFromPrimitiveValue(const CSSPrimitiveValue* value, Co lor currentColor, bool forVisitedLink) const | 69 Color TextLinkColors::colorFromPrimitiveValue(const CSSPrimitiveValue* value, Co lor currentColor, bool forVisitedLink) const |
98 { | 70 { |
99 if (value->isRGBColor()) | 71 if (value->isRGBColor()) |
100 return Color(value->getRGBA32Value()); | 72 return Color(value->getRGBA32Value()); |
101 | 73 |
102 CSSValueID valueID = value->getValueID(); | 74 CSSValueID valueID = value->getValueID(); |
(...skipping 10 matching lines...) Expand all Loading... | |
113 return LayoutTheme::theme().focusRingColor(); | 85 return LayoutTheme::theme().focusRingColor(); |
114 case CSSValueInvert: // We don't support outline-color: invert | 86 case CSSValueInvert: // We don't support outline-color: invert |
115 case CSSValueCurrentcolor: | 87 case CSSValueCurrentcolor: |
116 return currentColor; | 88 return currentColor; |
117 default: | 89 default: |
118 return colorForCSSValue(valueID); | 90 return colorForCSSValue(valueID); |
119 } | 91 } |
120 } | 92 } |
121 | 93 |
122 } | 94 } |
OLD | NEW |