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

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

Issue 23601011: Have StyleResolver / StyleResolverState deal with Document references, not pointers (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Update StyleResolverState as well Created 7 years, 3 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 25 matching lines...) Expand all
36 #include "core/rendering/style/StyleInheritedData.h" 36 #include "core/rendering/style/StyleInheritedData.h"
37 37
38 namespace WebCore { 38 namespace WebCore {
39 39
40 class FontDescription; 40 class FontDescription;
41 class RenderRegion; 41 class RenderRegion;
42 42
43 class StyleResolverState { 43 class StyleResolverState {
44 WTF_MAKE_NONCOPYABLE(StyleResolverState); 44 WTF_MAKE_NONCOPYABLE(StyleResolverState);
45 public: 45 public:
46 StyleResolverState(Document*, Element*, RenderStyle* parentStyle = 0, Render Region* regionForStyling = 0); 46 StyleResolverState(Document&, Element*, RenderStyle* parentStyle = 0, Render Region* regionForStyling = 0);
47 ~StyleResolverState(); 47 ~StyleResolverState();
48 48
49 // In FontLoader and CanvasRenderingContext2D, we don't have an element to g rab the document from. 49 // In FontLoader and CanvasRenderingContext2D, we don't have an element to g rab the document from.
50 // This is why we have to store the document separately. 50 // This is why we have to store the document separately.
51 Document* document() const { return m_document; } 51 Document& document() const { return m_document; }
52 // These are all just pass-through methods to ElementResolveContext. 52 // These are all just pass-through methods to ElementResolveContext.
53 Element* element() const { return m_elementContext.element(); } 53 Element* element() const { return m_elementContext.element(); }
54 const ContainerNode* parentNode() const { return m_elementContext.parentNode (); } 54 const ContainerNode* parentNode() const { return m_elementContext.parentNode (); }
55 const RenderStyle* rootElementStyle() const { return m_elementContext.rootEl ementStyle(); } 55 const RenderStyle* rootElementStyle() const { return m_elementContext.rootEl ementStyle(); }
56 EInsideLink elementLinkState() const { return m_elementContext.elementLinkSt ate(); } 56 EInsideLink elementLinkState() const { return m_elementContext.elementLinkSt ate(); }
57 bool distributedToInsertionPoint() const { return m_elementContext.distribut edToInsertionPoint(); } 57 bool distributedToInsertionPoint() const { return m_elementContext.distribut edToInsertionPoint(); }
58 58
59 const ElementResolveContext& elementContext() const { return m_elementContex t; } 59 const ElementResolveContext& elementContext() const { return m_elementContex t; }
60 60
61 void setStyle(PassRefPtr<RenderStyle> style) { m_style = style; } 61 void setStyle(PassRefPtr<RenderStyle> style) { m_style = style; }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 94
95 ElementStyleResources& elementStyleResources() { return m_elementStyleResour ces; } 95 ElementStyleResources& elementStyleResources() { return m_elementStyleResour ces; }
96 const CSSToStyleMap& styleMap() const { return m_styleMap; } 96 const CSSToStyleMap& styleMap() const { return m_styleMap; }
97 CSSToStyleMap& styleMap() { return m_styleMap; } 97 CSSToStyleMap& styleMap() { return m_styleMap; }
98 98
99 // FIXME: Once styleImage can be made to not take a StyleResolverState 99 // FIXME: Once styleImage can be made to not take a StyleResolverState
100 // this convenience function should be removed. As-is, without this, call 100 // this convenience function should be removed. As-is, without this, call
101 // sites are extremely verbose. 101 // sites are extremely verbose.
102 PassRefPtr<StyleImage> styleImage(CSSPropertyID propertyId, CSSValue* value) 102 PassRefPtr<StyleImage> styleImage(CSSPropertyID propertyId, CSSValue* value)
103 { 103 {
104 return m_elementStyleResources.styleImage(document()->textLinkColors(), propertyId, value); 104 return m_elementStyleResources.styleImage(document().textLinkColors(), p ropertyId, value);
105 } 105 }
106 106
107 FontBuilder& fontBuilder() { return m_fontBuilder; } 107 FontBuilder& fontBuilder() { return m_fontBuilder; }
108 // FIXME: These exist as a primitive way to track mutations to font-related properties 108 // FIXME: These exist as a primitive way to track mutations to font-related properties
109 // on a RenderStyle. As designed, these are very error-prone, as some caller s 109 // on a RenderStyle. As designed, these are very error-prone, as some caller s
110 // set these directly on the RenderStyle w/o telling us. Presumably we'll 110 // set these directly on the RenderStyle w/o telling us. Presumably we'll
111 // want to design a better wrapper around RenderStyle for tracking these mut ations 111 // want to design a better wrapper around RenderStyle for tracking these mut ations
112 // and separate it from StyleResolverState. 112 // and separate it from StyleResolverState.
113 const FontDescription& parentFontDescription() { return m_parentStyle->fontD escription(); } 113 const FontDescription& parentFontDescription() { return m_parentStyle->fontD escription(); }
114 void setZoom(float f) { m_fontBuilder.didChangeFontParameters(m_style->setZo om(f)); } 114 void setZoom(float f) { m_fontBuilder.didChangeFontParameters(m_style->setZo om(f)); }
115 void setEffectiveZoom(float f) { m_fontBuilder.didChangeFontParameters(m_sty le->setEffectiveZoom(f)); } 115 void setEffectiveZoom(float f) { m_fontBuilder.didChangeFontParameters(m_sty le->setEffectiveZoom(f)); }
116 void setWritingMode(WritingMode writingMode) { m_fontBuilder.didChangeFontPa rameters(m_style->setWritingMode(writingMode)); } 116 void setWritingMode(WritingMode writingMode) { m_fontBuilder.didChangeFontPa rameters(m_style->setWritingMode(writingMode)); }
117 void setTextOrientation(TextOrientation textOrientation) { m_fontBuilder.did ChangeFontParameters(m_style->setTextOrientation(textOrientation)); } 117 void setTextOrientation(TextOrientation textOrientation) { m_fontBuilder.did ChangeFontParameters(m_style->setTextOrientation(textOrientation)); }
118 118
119 // SVG handles zooming in a different way compared to CSS. The whole documen t is scaled instead 119 // SVG handles zooming in a different way compared to CSS. The whole documen t is scaled instead
120 // of each individual length value in the render style / tree. CSSPrimitiveV alue::computeLength*() 120 // of each individual length value in the render style / tree. CSSPrimitiveV alue::computeLength*()
121 // multiplies each resolved length with the zoom multiplier - so for SVG we need to disable that. 121 // multiplies each resolved length with the zoom multiplier - so for SVG we need to disable that.
122 // Though all CSS values that can be applied to outermost <svg> elements (wi dth/height/border/padding...) 122 // Though all CSS values that can be applied to outermost <svg> elements (wi dth/height/border/padding...)
123 // need to respect the scaling. RenderBox (the parent class of RenderSVGRoot ) grabs values like 123 // need to respect the scaling. RenderBox (the parent class of RenderSVGRoot ) grabs values like
124 // width/height/border/padding/... from the RenderStyle -> for SVG these val ues would never scale, 124 // width/height/border/padding/... from the RenderStyle -> for SVG these val ues would never scale,
125 // if we'd pass a 1.0 zoom factor everyhwere. So we only pass a zoom factor of 1.0 for specific 125 // if we'd pass a 1.0 zoom factor everyhwere. So we only pass a zoom factor of 1.0 for specific
126 // properties that are NOT allowed to scale within a zoomed SVG document (le tter/word-spacing/font-size). 126 // properties that are NOT allowed to scale within a zoomed SVG document (le tter/word-spacing/font-size).
127 bool useSVGZoomRules() const { return element() && element()->isSVGElement() ; } 127 bool useSVGZoomRules() const { return element() && element()->isSVGElement() ; }
128 128
129 private: 129 private:
130 friend class StyleResolveScope; 130 friend class StyleResolveScope;
131 131
132 void initElement(Element*); 132 void initElement(Element*);
133 133
134 Document* m_document;
135 ElementResolveContext m_elementContext; 134 ElementResolveContext m_elementContext;
135 Document& m_document;
136 136
137 // m_style is the primary output for each element's style resolve. 137 // m_style is the primary output for each element's style resolve.
138 RefPtr<RenderStyle> m_style; 138 RefPtr<RenderStyle> m_style;
139 139
140 // m_parentStyle is not always just element->parentNode()->style() 140 // m_parentStyle is not always just element->parentNode()->style()
141 // so we keep it separate from m_elementContext. 141 // so we keep it separate from m_elementContext.
142 RefPtr<RenderStyle> m_parentStyle; 142 RefPtr<RenderStyle> m_parentStyle;
143 143
144 OwnPtr<CSSAnimationUpdate> m_animationUpdate; 144 OwnPtr<CSSAnimationUpdate> m_animationUpdate;
145 145
(...skipping 14 matching lines...) Expand all
160 ElementStyleResources m_elementStyleResources; 160 ElementStyleResources m_elementStyleResources;
161 // CSSToStyleMap is a pure-logic class and only contains 161 // CSSToStyleMap is a pure-logic class and only contains
162 // a back-pointer to this object. 162 // a back-pointer to this object.
163 CSSToStyleMap m_styleMap; 163 CSSToStyleMap m_styleMap;
164 Vector<AtomicString> m_contentAttrValues; 164 Vector<AtomicString> m_contentAttrValues;
165 }; 165 };
166 166
167 } // namespace WebCore 167 } // namespace WebCore
168 168
169 #endif // StyleResolverState_h 169 #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