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

Side by Side Diff: Source/core/css/resolver/StyleResolverState.h

Issue 889563002: Make RenderObject::style() return a const object (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated change after Doug's review. Created 5 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 | Annotate | Revision Log
OLDNEW
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 27 matching lines...) Expand all
38 38
39 namespace blink { 39 namespace blink {
40 40
41 class CSSAnimationUpdate; 41 class CSSAnimationUpdate;
42 class FontDescription; 42 class FontDescription;
43 43
44 class StyleResolverState { 44 class StyleResolverState {
45 STACK_ALLOCATED(); 45 STACK_ALLOCATED();
46 WTF_MAKE_NONCOPYABLE(StyleResolverState); 46 WTF_MAKE_NONCOPYABLE(StyleResolverState);
47 public: 47 public:
48 StyleResolverState(Document&, const ElementResolveContext&, LayoutStyle* par entStyle); 48 StyleResolverState(Document&, const ElementResolveContext&, const LayoutStyl e* parentStyle);
49 StyleResolverState(Document&, Element*, LayoutStyle* parentStyle = 0); 49 StyleResolverState(Document&, Element*, const LayoutStyle* parentStyle = 0);
50 ~StyleResolverState(); 50 ~StyleResolverState();
51 51
52 // In FontFaceSet and CanvasRenderingContext2D, we don't have an element to grab the document from. 52 // In FontFaceSet and CanvasRenderingContext2D, we don't have an element to grab the document from.
53 // This is why we have to store the document separately. 53 // This is why we have to store the document separately.
54 Document& document() const { return *m_document; } 54 Document& document() const { return *m_document; }
55 // These are all just pass-through methods to ElementResolveContext. 55 // These are all just pass-through methods to ElementResolveContext.
56 Element* element() const { return m_elementContext.element(); } 56 Element* element() const { return m_elementContext.element(); }
57 const ContainerNode* parentNode() const { return m_elementContext.parentNode (); } 57 const ContainerNode* parentNode() const { return m_elementContext.parentNode (); }
58 const LayoutStyle* rootElementStyle() const { return m_elementContext.rootEl ementStyle(); } 58 const LayoutStyle* rootElementStyle() const { return m_elementContext.rootEl ementStyle(); }
59 EInsideLink elementLinkState() const { return m_elementContext.elementLinkSt ate(); } 59 EInsideLink elementLinkState() const { return m_elementContext.elementLinkSt ate(); }
(...skipping 16 matching lines...) Expand all
76 76
77 const CSSToLengthConversionData& cssToLengthConversionData() const { return m_cssToLengthConversionData; } 77 const CSSToLengthConversionData& cssToLengthConversionData() const { return m_cssToLengthConversionData; }
78 78
79 void setConversionFontSizes(const CSSToLengthConversionData::FontSizes& font Sizes) { m_cssToLengthConversionData.setFontSizes(fontSizes); } 79 void setConversionFontSizes(const CSSToLengthConversionData::FontSizes& font Sizes) { m_cssToLengthConversionData.setFontSizes(fontSizes); }
80 void setConversionZoom(float zoom) { m_cssToLengthConversionData.setZoom(zoo m); } 80 void setConversionZoom(float zoom) { m_cssToLengthConversionData.setZoom(zoo m); }
81 81
82 void setAnimationUpdate(PassOwnPtrWillBeRawPtr<CSSAnimationUpdate>); 82 void setAnimationUpdate(PassOwnPtrWillBeRawPtr<CSSAnimationUpdate>);
83 const CSSAnimationUpdate* animationUpdate() { return m_animationUpdate.get() ; } 83 const CSSAnimationUpdate* animationUpdate() { return m_animationUpdate.get() ; }
84 PassOwnPtrWillBeRawPtr<CSSAnimationUpdate> takeAnimationUpdate(); 84 PassOwnPtrWillBeRawPtr<CSSAnimationUpdate> takeAnimationUpdate();
85 85
86 void setParentStyle(PassRefPtr<LayoutStyle> parentStyle) { m_parentStyle = p arentStyle; } 86 void setParentStyle(PassRefPtr<LayoutStyle> parentStyle) { m_overrideParentS tyle = parentStyle; }
87 const LayoutStyle* parentStyle() const { return m_parentStyle.get(); } 87 const LayoutStyle* parentStyle() const
88 LayoutStyle* parentStyle() { return m_parentStyle.get(); } 88 {
89 if (m_overrideParentStyle)
90 return m_overrideParentStyle.get();
91 return m_parentStyle;
92 }
89 93
90 // FIXME: These are effectively side-channel "out parameters" for the variou s 94 // FIXME: These are effectively side-channel "out parameters" for the variou s
91 // map functions. When we map from CSS to style objects we use this state ob ject 95 // map functions. When we map from CSS to style objects we use this state ob ject
92 // to track various meta-data about that mapping (e.g. if it's cache-able). 96 // to track various meta-data about that mapping (e.g. if it's cache-able).
93 // We need to move this data off of StyleResolverState and closer to the 97 // We need to move this data off of StyleResolverState and closer to the
94 // objects it applies to. Possibly separating (immutable) inputs from (mutab le) outputs. 98 // objects it applies to. Possibly separating (immutable) inputs from (mutab le) outputs.
95 void setApplyPropertyToRegularStyle(bool isApply) { m_applyPropertyToRegular Style = isApply; } 99 void setApplyPropertyToRegularStyle(bool isApply) { m_applyPropertyToRegular Style = isApply; }
96 void setApplyPropertyToVisitedLinkStyle(bool isApply) { m_applyPropertyToVis itedLinkStyle = isApply; } 100 void setApplyPropertyToVisitedLinkStyle(bool isApply) { m_applyPropertyToVis itedLinkStyle = isApply; }
97 bool applyPropertyToRegularStyle() const { return m_applyPropertyToRegularSt yle; } 101 bool applyPropertyToRegularStyle() const { return m_applyPropertyToRegularSt yle; }
98 bool applyPropertyToVisitedLinkStyle() const { return m_applyPropertyToVisit edLinkStyle; } 102 bool applyPropertyToVisitedLinkStyle() const { return m_applyPropertyToVisit edLinkStyle; }
(...skipping 22 matching lines...) Expand all
121 { 125 {
122 return m_elementStyleResources.styleImage(document(), document().textLin kColors(), style()->color(), propertyId, value); 126 return m_elementStyleResources.styleImage(document(), document().textLin kColors(), style()->color(), propertyId, value);
123 } 127 }
124 128
125 FontBuilder& fontBuilder() { return m_fontBuilder; } 129 FontBuilder& fontBuilder() { return m_fontBuilder; }
126 // FIXME: These exist as a primitive way to track mutations to font-related properties 130 // FIXME: These exist as a primitive way to track mutations to font-related properties
127 // on a LayoutStyle. As designed, these are very error-prone, as some caller s 131 // on a LayoutStyle. As designed, these are very error-prone, as some caller s
128 // set these directly on the LayoutStyle w/o telling us. Presumably we'll 132 // set these directly on the LayoutStyle w/o telling us. Presumably we'll
129 // want to design a better wrapper around LayoutStyle for tracking these mut ations 133 // want to design a better wrapper around LayoutStyle for tracking these mut ations
130 // and separate it from StyleResolverState. 134 // and separate it from StyleResolverState.
131 const FontDescription& parentFontDescription() { return m_parentStyle->fontD escription(); } 135 const FontDescription& parentFontDescription() { return parentStyle()->fontD escription(); }
132 136
133 void setZoom(float f) 137 void setZoom(float f)
134 { 138 {
135 if (m_style->setZoom(f)) 139 if (m_style->setZoom(f))
136 m_fontBuilder.didChangeEffectiveZoom(); 140 m_fontBuilder.didChangeEffectiveZoom();
137 } 141 }
138 void setEffectiveZoom(float f) 142 void setEffectiveZoom(float f)
139 { 143 {
140 if (m_style->setEffectiveZoom(f)) 144 if (m_style->setEffectiveZoom(f))
141 m_fontBuilder.didChangeEffectiveZoom(); 145 m_fontBuilder.didChangeEffectiveZoom();
(...skipping 13 matching lines...) Expand all
155 ElementResolveContext m_elementContext; 159 ElementResolveContext m_elementContext;
156 RawPtrWillBeMember<Document> m_document; 160 RawPtrWillBeMember<Document> m_document;
157 161
158 // m_style is the primary output for each element's style resolve. 162 // m_style is the primary output for each element's style resolve.
159 RefPtr<LayoutStyle> m_style; 163 RefPtr<LayoutStyle> m_style;
160 164
161 CSSToLengthConversionData m_cssToLengthConversionData; 165 CSSToLengthConversionData m_cssToLengthConversionData;
162 166
163 // m_parentStyle is not always just ElementResolveContext::parentStyle, 167 // m_parentStyle is not always just ElementResolveContext::parentStyle,
164 // so we keep it separate. 168 // so we keep it separate.
165 RefPtr<LayoutStyle> m_parentStyle; 169 const LayoutStyle* m_parentStyle;
170 RefPtr<LayoutStyle> m_overrideParentStyle;
166 171
167 OwnPtrWillBeMember<CSSAnimationUpdate> m_animationUpdate; 172 OwnPtrWillBeMember<CSSAnimationUpdate> m_animationUpdate;
168 173
169 bool m_applyPropertyToRegularStyle; 174 bool m_applyPropertyToRegularStyle;
170 bool m_applyPropertyToVisitedLinkStyle; 175 bool m_applyPropertyToVisitedLinkStyle;
171 176
172 FontBuilder m_fontBuilder; 177 FontBuilder m_fontBuilder;
173 178
174 OwnPtr<CachedUAStyle> m_cachedUAStyle; 179 OwnPtr<CachedUAStyle> m_cachedUAStyle;
175 180
176 ElementStyleResources m_elementStyleResources; 181 ElementStyleResources m_elementStyleResources;
177 }; 182 };
178 183
179 } // namespace blink 184 } // namespace blink
180 185
181 #endif // StyleResolverState_h 186 #endif // StyleResolverState_h
OLDNEW
« no previous file with comments | « Source/core/css/resolver/StyleResolver.cpp ('k') | Source/core/css/resolver/StyleResolverState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698