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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 | 75 |
76 private: | 76 private: |
77 Element* m_element; | 77 Element* m_element; |
78 ContainerNode* m_parentNode; | 78 ContainerNode* m_parentNode; |
79 RenderStyle* m_rootElementStyle; | 79 RenderStyle* m_rootElementStyle; |
80 EInsideLink m_elementLinkState; | 80 EInsideLink m_elementLinkState; |
81 bool m_distributedToInsertionPoint; | 81 bool m_distributedToInsertionPoint; |
82 bool m_resetStyleInheritance; | 82 bool m_resetStyleInheritance; |
83 }; | 83 }; |
84 | 84 |
| 85 // Initializes a StyleResolverState within a scope. |
| 86 class ScopedStyleResolution { |
| 87 public: |
| 88 ScopedStyleResolution(StyleResolverState*, Document*, Element*, RenderStyle*
parentStyle = 0, RenderRegion* regionForStyling = 0); |
| 89 ~ScopedStyleResolution(); |
| 90 private: |
| 91 StyleResolverState* m_state; |
| 92 }; |
| 93 |
85 class StyleResolverState { | 94 class StyleResolverState { |
86 WTF_MAKE_NONCOPYABLE(StyleResolverState); | 95 WTF_MAKE_NONCOPYABLE(StyleResolverState); |
87 public: | 96 public: |
88 StyleResolverState() | 97 StyleResolverState() |
89 : m_regionForStyling(0) | 98 : m_regionForStyling(0) |
90 , m_applyPropertyToRegularStyle(true) | 99 , m_applyPropertyToRegularStyle(true) |
91 , m_applyPropertyToVisitedLinkStyle(false) | 100 , m_applyPropertyToVisitedLinkStyle(false) |
92 , m_lineHeightValue(0) | 101 , m_lineHeightValue(0) |
93 , m_fontDirty(false) | 102 , m_fontDirty(false) |
94 , m_styleMap(*this, m_elementStyleResources) | 103 , m_styleMap(*this, m_elementStyleResources) |
95 { } | 104 { } |
96 | 105 |
97 void initForStyleResolve(Document*, Element*, RenderStyle* parentStyle = 0,
RenderRegion* regionForStyling = 0); | |
98 void clear(); | |
99 | |
100 // These are all just pass-through methods to ElementResolveContext. | 106 // These are all just pass-through methods to ElementResolveContext. |
101 Document* document() const { return m_elementContext.document(); } | 107 Document* document() const { return m_elementContext.document(); } |
102 Element* element() const { return m_elementContext.element(); } | 108 Element* element() const { return m_elementContext.element(); } |
103 const ContainerNode* parentNode() const { return m_elementContext.parentNode
(); } | 109 const ContainerNode* parentNode() const { return m_elementContext.parentNode
(); } |
104 RenderStyle* rootElementStyle() const { return m_elementContext.rootElementS
tyle(); } | 110 RenderStyle* rootElementStyle() const { return m_elementContext.rootElementS
tyle(); } |
105 EInsideLink elementLinkState() const { return m_elementContext.elementLinkSt
ate(); } | 111 EInsideLink elementLinkState() const { return m_elementContext.elementLinkSt
ate(); } |
106 bool distributedToInsertionPoint() const { return m_elementContext.distribut
edToInsertionPoint(); } | 112 bool distributedToInsertionPoint() const { return m_elementContext.distribut
edToInsertionPoint(); } |
107 | 113 |
108 const ElementResolveContext elementContext() const { return m_elementContext
; } | 114 const ElementResolveContext elementContext() const { return m_elementContext
; } |
109 | 115 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 // of each individual length value in the render style / tree. CSSPrimitiveV
alue::computeLength*() | 175 // of each individual length value in the render style / tree. CSSPrimitiveV
alue::computeLength*() |
170 // multiplies each resolved length with the zoom multiplier - so for SVG we
need to disable that. | 176 // multiplies each resolved length with the zoom multiplier - so for SVG we
need to disable that. |
171 // Though all CSS values that can be applied to outermost <svg> elements (wi
dth/height/border/padding...) | 177 // Though all CSS values that can be applied to outermost <svg> elements (wi
dth/height/border/padding...) |
172 // need to respect the scaling. RenderBox (the parent class of RenderSVGRoot
) grabs values like | 178 // need to respect the scaling. RenderBox (the parent class of RenderSVGRoot
) grabs values like |
173 // width/height/border/padding/... from the RenderStyle -> for SVG these val
ues would never scale, | 179 // width/height/border/padding/... from the RenderStyle -> for SVG these val
ues would never scale, |
174 // if we'd pass a 1.0 zoom factor everyhwere. So we only pass a zoom factor
of 1.0 for specific | 180 // if we'd pass a 1.0 zoom factor everyhwere. So we only pass a zoom factor
of 1.0 for specific |
175 // properties that are NOT allowed to scale within a zoomed SVG document (le
tter/word-spacing/font-size). | 181 // properties that are NOT allowed to scale within a zoomed SVG document (le
tter/word-spacing/font-size). |
176 bool useSVGZoomRules() const { return element() && element()->isSVGElement()
; } | 182 bool useSVGZoomRules() const { return element() && element()->isSVGElement()
; } |
177 | 183 |
178 private: | 184 private: |
| 185 friend class ScopedStyleResolution; |
| 186 |
| 187 void initForStyleResolve(Document*, Element*, RenderStyle* parentStyle = 0,
RenderRegion* regionForStyling = 0); |
| 188 void clear(); |
| 189 |
179 void initElement(Element*); | 190 void initElement(Element*); |
180 | 191 |
181 ElementResolveContext m_elementContext; | 192 ElementResolveContext m_elementContext; |
182 | 193 |
183 // m_style is the primary output for each element's style resolve. | 194 // m_style is the primary output for each element's style resolve. |
184 RefPtr<RenderStyle> m_style; | 195 RefPtr<RenderStyle> m_style; |
185 | 196 |
186 // m_parentStyle is not always just element->parentNode()->style() | 197 // m_parentStyle is not always just element->parentNode()->style() |
187 // so we keep it separate from m_elementContext. | 198 // so we keep it separate from m_elementContext. |
188 RefPtr<RenderStyle> m_parentStyle; | 199 RefPtr<RenderStyle> m_parentStyle; |
(...skipping 19 matching lines...) Expand all Loading... |
208 | 219 |
209 ElementStyleResources m_elementStyleResources; | 220 ElementStyleResources m_elementStyleResources; |
210 // CSSToStyleMap is a pure-logic class and only contains | 221 // CSSToStyleMap is a pure-logic class and only contains |
211 // a back-pointer to this object. | 222 // a back-pointer to this object. |
212 CSSToStyleMap m_styleMap; | 223 CSSToStyleMap m_styleMap; |
213 }; | 224 }; |
214 | 225 |
215 } // namespace WebCore | 226 } // namespace WebCore |
216 | 227 |
217 #endif // StyleResolverState_h | 228 #endif // StyleResolverState_h |
OLD | NEW |