| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. | 3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 #include "config.h" | 22 #include "config.h" |
| 23 #include "core/css/resolver/StyleResolverState.h" | 23 #include "core/css/resolver/StyleResolverState.h" |
| 24 | 24 |
| 25 #include "core/dom/Element.h" | 25 #include "core/dom/Element.h" |
| 26 #include "core/dom/Node.h" | 26 #include "core/dom/Node.h" |
| 27 #include "core/dom/NodeRenderStyle.h" | 27 #include "core/dom/NodeRenderStyle.h" |
| 28 #include "core/dom/NodeRenderingContext.h" | 28 #include "core/dom/NodeRenderingContext.h" |
| 29 #include "core/dom/VisitedLinkState.h" | 29 #include "core/dom/VisitedLinkState.h" |
| 30 #include "core/page/Page.h" | 30 #include "core/page/Page.h" |
| 31 #include "core/rendering/RenderTheme.h" | |
| 32 | 31 |
| 33 namespace WebCore { | 32 namespace WebCore { |
| 34 | 33 |
| 35 void StyleResolverState::cacheBorderAndBackground() | 34 void StyleResolverState::cacheBorderAndBackground() |
| 36 { | 35 { |
| 37 m_hasUAAppearance = m_style->hasAppearance(); | 36 m_hasUAAppearance = m_style->hasAppearance(); |
| 38 if (m_hasUAAppearance) { | 37 if (m_hasUAAppearance) { |
| 39 m_borderData = m_style->border(); | 38 m_borderData = m_style->border(); |
| 40 m_backgroundData = *m_style->backgroundLayers(); | 39 m_backgroundData = *m_style->backgroundLayers(); |
| 41 m_backgroundColor = m_style->backgroundColor(); | 40 m_backgroundColor = m_style->backgroundColor(); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 m_rootElementStyle = docElement && e != docElement ? docElement->renderStyle
() : docStyle; | 91 m_rootElementStyle = docElement && e != docElement ? docElement->renderStyle
() : docStyle; |
| 93 | 92 |
| 94 m_style = 0; | 93 m_style = 0; |
| 95 m_elementStyleResources.clear(); | 94 m_elementStyleResources.clear(); |
| 96 m_fontDirty = false; | 95 m_fontDirty = false; |
| 97 | 96 |
| 98 if (Page* page = document->page()) | 97 if (Page* page = document->page()) |
| 99 m_elementStyleResources.setDeviceScaleFactor(page->deviceScaleFactor()); | 98 m_elementStyleResources.setDeviceScaleFactor(page->deviceScaleFactor()); |
| 100 } | 99 } |
| 101 | 100 |
| 102 | |
| 103 static Color colorForCSSValue(CSSValueID cssValueId) | |
| 104 { | |
| 105 struct ColorValue { | |
| 106 CSSValueID cssValueId; | |
| 107 RGBA32 color; | |
| 108 }; | |
| 109 | |
| 110 static const ColorValue colorValues[] = { | |
| 111 { CSSValueAqua, 0xFF00FFFF }, | |
| 112 { CSSValueBlack, 0xFF000000 }, | |
| 113 { CSSValueBlue, 0xFF0000FF }, | |
| 114 { CSSValueFuchsia, 0xFFFF00FF }, | |
| 115 { CSSValueGray, 0xFF808080 }, | |
| 116 { CSSValueGreen, 0xFF008000 }, | |
| 117 { CSSValueGrey, 0xFF808080 }, | |
| 118 { CSSValueLime, 0xFF00FF00 }, | |
| 119 { CSSValueMaroon, 0xFF800000 }, | |
| 120 { CSSValueNavy, 0xFF000080 }, | |
| 121 { CSSValueOlive, 0xFF808000 }, | |
| 122 { CSSValueOrange, 0xFFFFA500 }, | |
| 123 { CSSValuePurple, 0xFF800080 }, | |
| 124 { CSSValueRed, 0xFFFF0000 }, | |
| 125 { CSSValueSilver, 0xFFC0C0C0 }, | |
| 126 { CSSValueTeal, 0xFF008080 }, | |
| 127 { CSSValueTransparent, 0x00000000 }, | |
| 128 { CSSValueWhite, 0xFFFFFFFF }, | |
| 129 { CSSValueYellow, 0xFFFFFF00 }, | |
| 130 { CSSValueInvalid, CSSValueInvalid } | |
| 131 }; | |
| 132 | |
| 133 for (const ColorValue* col = colorValues; col->cssValueId; ++col) { | |
| 134 if (col->cssValueId == cssValueId) | |
| 135 return col->color; | |
| 136 } | |
| 137 return RenderTheme::defaultTheme()->systemColor(cssValueId); | |
| 138 } | |
| 139 | |
| 140 Color StyleResolverState::resolveColorFromPrimitiveValue(CSSPrimitiveValue* valu
e, bool forVisitedLink) | |
| 141 { | |
| 142 if (value->isRGBColor()) | |
| 143 return Color(value->getRGBA32Value()); | |
| 144 | |
| 145 CSSValueID valueID = value->getValueID(); | |
| 146 switch (valueID) { | |
| 147 case 0: | |
| 148 return Color(); | |
| 149 case CSSValueWebkitText: | |
| 150 return document()->textLinkColors().textColor(); | |
| 151 case CSSValueWebkitLink: | |
| 152 return (element()->isLink() && forVisitedLink) ? document()->textLinkCol
ors().visitedLinkColor() : document()->textLinkColors().linkColor(); | |
| 153 case CSSValueWebkitActivelink: | |
| 154 return document()->textLinkColors().activeLinkColor(); | |
| 155 case CSSValueWebkitFocusRingColor: | |
| 156 return RenderTheme::focusRingColor(); | |
| 157 case CSSValueCurrentcolor: | |
| 158 m_isMatchedPropertiesCacheable = false; | |
| 159 return style()->color(); | |
| 160 default: | |
| 161 return colorForCSSValue(valueID); | |
| 162 } | |
| 163 } | |
| 164 | |
| 165 } // namespace WebCore | 101 } // namespace WebCore |
| OLD | NEW |