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

Side by Side Diff: Source/core/css/StyleResolverState.cpp

Issue 15072003: Move StyleResolver and related classes to core/css/resolver (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/css/StyleResolverState.h ('k') | Source/core/css/TransformBuilder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
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.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 *
20 */
21
22 #include "config.h"
23 #include "core/css/StyleResolverState.h"
24
25 #include "core/css/CSSPrimitiveValueMappings.h"
26 #include "core/dom/Node.h"
27 #include "core/dom/NodeRenderingContext.h"
28 #include "core/dom/NodeRenderStyle.h"
29 #include "core/dom/StyledElement.h"
30 #include "core/dom/VisitedLinkState.h"
31 #include "core/rendering/RenderTheme.h"
32
33 namespace WebCore {
34
35 void StyleResolverState::cacheBorderAndBackground()
36 {
37 m_hasUAAppearance = m_style->hasAppearance();
38 if (m_hasUAAppearance) {
39 m_borderData = m_style->border();
40 m_backgroundData = *m_style->backgroundLayers();
41 m_backgroundColor = m_style->backgroundColor();
42 }
43 }
44
45 void StyleResolverState::clear()
46 {
47 m_element = 0;
48 m_styledElement = 0;
49 m_parentStyle = 0;
50 m_parentNode = 0;
51 m_regionForStyling = 0;
52 m_pendingImageProperties.clear();
53 m_hasPendingShaders = false;
54 #if ENABLE(SVG)
55 m_pendingSVGDocuments.clear();
56 #endif
57 }
58
59 void StyleResolverState::initElement(Element* e)
60 {
61 m_element = e;
62 m_styledElement = e && e->isStyledElement() ? static_cast<StyledElement*>(e) : 0;
63 m_elementLinkState = e ? e->document()->visitedLinkState()->determineLinkSta te(e) : NotInsideLink;
64 }
65
66 void StyleResolverState::initForStyleResolve(Document* document, Element* e, Ren derStyle* parentStyle, RenderRegion* regionForStyling)
67 {
68 m_regionForStyling = regionForStyling;
69
70 if (e) {
71 NodeRenderingContext context(e);
72 m_parentNode = context.parentNodeForRenderingAndStyle();
73 m_parentStyle = context.resetStyleInheritance() ? 0 :
74 parentStyle ? parentStyle :
75 m_parentNode ? m_parentNode->renderStyle() : 0;
76 m_distributedToInsertionPoint = context.insertionPoint();
77 } else {
78 m_parentNode = 0;
79 m_parentStyle = parentStyle;
80 m_distributedToInsertionPoint = false;
81 }
82
83 Node* docElement = e ? e->document()->documentElement() : 0;
84 RenderStyle* docStyle = document->renderStyle();
85 m_rootElementStyle = docElement && e != docElement ? docElement->renderStyle () : docStyle;
86
87 m_style = 0;
88 m_pendingImageProperties.clear();
89 m_fontDirty = false;
90 }
91
92
93 static Color colorForCSSValue(int cssValueId)
94 {
95 struct ColorValue {
96 int cssValueId;
97 RGBA32 color;
98 };
99
100 static const ColorValue colorValues[] = {
101 { CSSValueAqua, 0xFF00FFFF },
102 { CSSValueBlack, 0xFF000000 },
103 { CSSValueBlue, 0xFF0000FF },
104 { CSSValueFuchsia, 0xFFFF00FF },
105 { CSSValueGray, 0xFF808080 },
106 { CSSValueGreen, 0xFF008000 },
107 { CSSValueGrey, 0xFF808080 },
108 { CSSValueLime, 0xFF00FF00 },
109 { CSSValueMaroon, 0xFF800000 },
110 { CSSValueNavy, 0xFF000080 },
111 { CSSValueOlive, 0xFF808000 },
112 { CSSValueOrange, 0xFFFFA500 },
113 { CSSValuePurple, 0xFF800080 },
114 { CSSValueRed, 0xFFFF0000 },
115 { CSSValueSilver, 0xFFC0C0C0 },
116 { CSSValueTeal, 0xFF008080 },
117 { CSSValueTransparent, 0x00000000 },
118 { CSSValueWhite, 0xFFFFFFFF },
119 { CSSValueYellow, 0xFFFFFF00 },
120 { 0, 0 }
121 };
122
123 for (const ColorValue* col = colorValues; col->cssValueId; ++col) {
124 if (col->cssValueId == cssValueId)
125 return col->color;
126 }
127 return RenderTheme::defaultTheme()->systemColor(cssValueId);
128 }
129
130 Color StyleResolverState::colorFromPrimitiveValue(CSSPrimitiveValue* value, bool forVisitedLink) const
131 {
132 if (value->isRGBColor())
133 return Color(value->getRGBA32Value());
134
135 int ident = value->getIdent();
136 switch (ident) {
137 case 0:
138 return Color();
139 case CSSValueWebkitText:
140 return document()->textColor();
141 case CSSValueWebkitLink:
142 return (element()->isLink() && forVisitedLink) ? document()->visitedLink Color() : document()->linkColor();
143 case CSSValueWebkitActivelink:
144 return document()->activeLinkColor();
145 case CSSValueWebkitFocusRingColor:
146 return RenderTheme::focusRingColor();
147 case CSSValueCurrentcolor:
148 return style()->color();
149 default:
150 return colorForCSSValue(ident);
151 }
152 }
153
154
155 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/css/StyleResolverState.h ('k') | Source/core/css/TransformBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698