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

Side by Side Diff: sky/engine/core/rendering/RenderLayer.h

Issue 961053002: Assorted cleanup of RenderLayer. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « sky/engine/core/rendering/RenderBox.cpp ('k') | sky/engine/core/rendering/RenderLayer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2003, 2009, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2003, 2009, 2012 Apple Inc. All rights reserved.
3 * Copyright (C) 2013 Intel Corporation. All rights reserved. 3 * Copyright (C) 2013 Intel Corporation. All rights reserved.
4 * 4 *
5 * Portions are Copyright (C) 1998 Netscape Communications Corporation. 5 * Portions are Copyright (C) 1998 Netscape Communications Corporation.
6 * 6 *
7 * Other contributors: 7 * Other contributors:
8 * Robert O'Callahan <roc+@cs.cmu.edu> 8 * Robert O'Callahan <roc+@cs.cmu.edu>
9 * David Baron <dbaron@fas.harvard.edu> 9 * David Baron <dbaron@fas.harvard.edu>
10 * Christian Biesinger <cbiesinger@web.de> 10 * Christian Biesinger <cbiesinger@web.de>
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 66
67 enum BorderRadiusClippingRule { IncludeSelfForBorderRadius, DoNotIncludeSelfForB orderRadius }; 67 enum BorderRadiusClippingRule { IncludeSelfForBorderRadius, DoNotIncludeSelfForB orderRadius };
68 enum IncludeSelfOrNot { IncludeSelf, ExcludeSelf }; 68 enum IncludeSelfOrNot { IncludeSelf, ExcludeSelf };
69 69
70 class RenderLayer { 70 class RenderLayer {
71 WTF_MAKE_NONCOPYABLE(RenderLayer); 71 WTF_MAKE_NONCOPYABLE(RenderLayer);
72 public: 72 public:
73 RenderLayer(RenderBox*, LayerType); 73 RenderLayer(RenderBox*, LayerType);
74 ~RenderLayer(); 74 ~RenderLayer();
75 75
76 String debugName() const;
77
78 RenderBox* renderer() const { return m_renderer; } 76 RenderBox* renderer() const { return m_renderer; }
79 // FIXME(sky): Remove
80 RenderBox* renderBox() const { return m_renderer; }
81 RenderLayer* parent() const { return m_parent; } 77 RenderLayer* parent() const { return m_parent; }
82 RenderLayer* previousSibling() const { return m_previous; } 78 RenderLayer* previousSibling() const { return m_previous; }
83 RenderLayer* nextSibling() const { return m_next; } 79 RenderLayer* nextSibling() const { return m_next; }
84 RenderLayer* firstChild() const { return m_first; } 80 RenderLayer* firstChild() const { return m_first; }
85 RenderLayer* lastChild() const { return m_last; } 81 RenderLayer* lastChild() const { return m_last; }
86 82
87 void addChild(RenderLayer* newChild, RenderLayer* beforeChild = 0); 83 void addChild(RenderLayer* newChild, RenderLayer* beforeChild = 0);
88 RenderLayer* removeChild(RenderLayer*); 84 RenderLayer* removeChild(RenderLayer*);
89 85
90 void removeOnlyThisLayer(); 86 void removeOnlyThisLayer();
91 void insertOnlyThisLayer(); 87 void insertOnlyThisLayer();
92 88
93 void styleChanged(StyleDifference, const RenderStyle* oldStyle); 89 void styleChanged(StyleDifference, const RenderStyle* oldStyle);
94
95 // FIXME: Many people call this function while it has out-of-date informatio n.
96 bool isSelfPaintingLayer() const { return m_isSelfPaintingLayer; } 90 bool isSelfPaintingLayer() const { return m_isSelfPaintingLayer; }
97
98 void setLayerType(LayerType layerType) { m_layerType = layerType; } 91 void setLayerType(LayerType layerType) { m_layerType = layerType; }
99 92
100 bool isTransparent() const { return renderer()->isTransparent(); }
101
102 const RenderLayer* root() const 93 const RenderLayer* root() const
103 { 94 {
104 const RenderLayer* curr = this; 95 const RenderLayer* curr = this;
105 while (curr->parent()) 96 while (curr->parent())
106 curr = curr->parent(); 97 curr = curr->parent();
107 return curr; 98 return curr;
108 } 99 }
109 100
110 LayoutPoint location() const; 101 LayoutPoint location() const;
111 IntSize size() const; 102 IntSize size() const;
112
113 LayoutRect rect() const { return LayoutRect(location(), size()); } 103 LayoutRect rect() const { return LayoutRect(location(), size()); }
114 104
115 bool isRootLayer() const { return m_isRootLayer; } 105 bool isRootLayer() const { return m_isRootLayer; }
116 106
117 void updateLayerPositionsAfterLayout(); 107 void updateLayerPositionsAfterLayout();
118
119 void updateTransformationMatrix(); 108 void updateTransformationMatrix();
120 RenderLayer* renderingContextRoot();
121 109
122 RenderLayerStackingNode* stackingNode() { return m_stackingNode.get(); } 110 RenderLayerStackingNode* stackingNode() { return m_stackingNode.get(); }
123 const RenderLayerStackingNode* stackingNode() const { return m_stackingNode. get(); } 111 const RenderLayerStackingNode* stackingNode() const { return m_stackingNode. get(); }
124 112
125 bool hasBoxDecorationsOrBackground() const;
126 bool hasVisibleBoxDecorations() const;
127 // True if this layer container renderers that paint.
128 bool hasNonEmptyChildRenderers() const;
129
130 // Gets the nearest enclosing positioned ancestor layer (also includes 113 // Gets the nearest enclosing positioned ancestor layer (also includes
131 // the <html> layer and the root layer). 114 // the <html> layer and the root layer).
132 RenderLayer* enclosingPositionedAncestor() const; 115 RenderLayer* enclosingPositionedAncestor() const;
133 116
134 RenderLayer* enclosingOverflowClipLayer(IncludeSelfOrNot = IncludeSelf) cons t;
135
136 const RenderLayer* compositingContainer() const; 117 const RenderLayer* compositingContainer() const;
137 118
138 void convertToLayerCoords(const RenderLayer* ancestorLayer, LayoutPoint&) co nst; 119 void convertToLayerCoords(const RenderLayer* ancestorLayer, LayoutPoint&) co nst;
139 void convertToLayerCoords(const RenderLayer* ancestorLayer, LayoutRect&) con st; 120 void convertToLayerCoords(const RenderLayer* ancestorLayer, LayoutRect&) con st;
140 121
141 // Pass offsetFromRoot if known. 122 // Pass offsetFromRoot if known.
142 bool intersectsDamageRect(const LayoutRect& layerBounds, const LayoutRect& d amageRect, const RenderLayer* rootLayer, const LayoutPoint* offsetFromRoot = 0) const; 123 bool intersectsDamageRect(const LayoutRect& layerBounds, const LayoutRect& d amageRect, const RenderLayer* rootLayer, const LayoutPoint* offsetFromRoot = 0) const;
143 124
144 // Bounding box relative to some ancestor layer. Pass offsetFromRoot if know n. 125 // Bounding box relative to some ancestor layer. Pass offsetFromRoot if know n.
145 LayoutRect physicalBoundingBox(const RenderLayer* ancestorLayer, const Layou tPoint* offsetFromRoot = 0) const; 126 LayoutRect physicalBoundingBox(const RenderLayer* ancestorLayer, const Layou tPoint* offsetFromRoot = 0) const;
146 LayoutRect physicalBoundingBoxIncludingReflectionAndStackingChildren(const R enderLayer* ancestorLayer, const LayoutPoint& offsetFromRoot) const; 127 LayoutRect physicalBoundingBoxIncludingReflectionAndStackingChildren(const R enderLayer* ancestorLayer, const LayoutPoint& offsetFromRoot) const;
147
148 // If true, this layer's children are included in its bounds for overlap tes ting.
149 // We can't rely on the children's positions if this layer has a filter that could have moved the children's pixels around.
150 bool overlapBoundsIncludeChildren() const { return hasFilter() && renderer() ->style()->filter().hasFilterThatMovesPixels(); }
151
152 LayoutRect boundingBoxForCompositing(const RenderLayer* ancestorLayer = 0) c onst; 128 LayoutRect boundingBoxForCompositing(const RenderLayer* ancestorLayer = 0) c onst;
153 129
154 LayoutSize subpixelAccumulation() const;
155 void setSubpixelAccumulation(const LayoutSize&);
156
157 bool hasTransform() const { return renderer()->hasTransform(); }
158 // This transform has the transform-origin baked in. 130 // This transform has the transform-origin baked in.
159 TransformationMatrix* transform() const { return m_transform.get(); } 131 TransformationMatrix* transform() const { return m_transform.get(); }
160 132
161 // Get the perspective transform, which is applied to transformed sublayers.
162 // Returns true if the layer has a -webkit-perspective.
163 // Note that this transform has the perspective-origin baked in.
164 TransformationMatrix perspectiveTransform() const;
165 FloatPoint perspectiveOrigin() const;
166 bool preserves3D() const { return renderer()->style()->transformStyle3D() == TransformStyle3DPreserve3D; } 133 bool preserves3D() const { return renderer()->style()->transformStyle3D() == TransformStyle3DPreserve3D; }
167 bool has3DTransform() const { return m_transform && !m_transform->isAffine() ; } 134 bool has3DTransform() const { return m_transform && !m_transform->isAffine() ; }
168 135
169 bool has3DTransformedDescendant() const { return m_has3DTransformedDescendan t; } 136 bool has3DTransformedDescendant() const { return m_has3DTransformedDescendan t; }
170 // Both updates the status, and returns true if descendants of this have 3d. 137 // Both updates the status, and returns true if descendants of this have 3d.
171 bool update3DTransformedDescendantStatus(); 138 bool update3DTransformedDescendantStatus();
172 139
173 // FIXME: reflections should force transform-style to be flat in the style: https://bugs.webkit.org/show_bug.cgi?id=106959 140 // FIXME: reflections should force transform-style to be flat in the style: https://bugs.webkit.org/show_bug.cgi?id=106959
174 bool shouldPreserve3D() const { return renderer()->style()->transformStyle3D () == TransformStyle3DPreserve3D; } 141 bool shouldPreserve3D() const { return renderer()->style()->transformStyle3D () == TransformStyle3DPreserve3D; }
175 142
176 bool hasFilter() const { return renderer()->hasFilter(); }
177
178 void* operator new(size_t); 143 void* operator new(size_t);
179 // Only safe to call from RenderBox::destroyLayer() 144 // Only safe to call from RenderBox::destroyLayer()
180 void operator delete(void*); 145 void operator delete(void*);
181 146
182 FilterEffectRenderer* filterRenderer() const 147 FilterEffectRenderer* filterRenderer() const
183 { 148 {
184 RenderLayerFilterInfo* filterInfo = this->filterInfo(); 149 RenderLayerFilterInfo* filterInfo = this->filterInfo();
185 return filterInfo ? filterInfo->renderer() : 0; 150 return filterInfo ? filterInfo->renderer() : 0;
186 } 151 }
187 152
188 RenderLayerFilterInfo* filterInfo() const { return hasFilterInfo() ? RenderL ayerFilterInfo::filterInfoForRenderLayer(this) : 0; } 153 RenderLayerFilterInfo* filterInfo() const { return hasFilterInfo() ? RenderL ayerFilterInfo::filterInfoForRenderLayer(this) : 0; }
189 RenderLayerFilterInfo* ensureFilterInfo() { return RenderLayerFilterInfo::cr eateFilterInfoForRenderLayerIfNeeded(this); } 154 RenderLayerFilterInfo* ensureFilterInfo() { return RenderLayerFilterInfo::cr eateFilterInfoForRenderLayerIfNeeded(this); }
190 void removeFilterInfoIfNeeded() 155 void removeFilterInfoIfNeeded()
191 { 156 {
192 if (hasFilterInfo()) 157 if (hasFilterInfo())
193 RenderLayerFilterInfo::removeFilterInfoForRenderLayer(this); 158 RenderLayerFilterInfo::removeFilterInfoForRenderLayer(this);
194 } 159 }
195 160
196 bool hasFilterInfo() const { return m_hasFilterInfo; } 161 bool hasFilterInfo() const { return m_hasFilterInfo; }
197 void setHasFilterInfo(bool hasFilterInfo) { m_hasFilterInfo = hasFilterInfo; } 162 void setHasFilterInfo(bool hasFilterInfo) { m_hasFilterInfo = hasFilterInfo; }
198 163
199 void updateFilters(const RenderStyle* oldStyle, const RenderStyle* newStyle) ;
200
201 RenderLayerClipper& clipper() { return m_clipper; } 164 RenderLayerClipper& clipper() { return m_clipper; }
202 const RenderLayerClipper& clipper() const { return m_clipper; } 165 const RenderLayerClipper& clipper() const { return m_clipper; }
203 166
204 inline bool isPositionedContainer() const 167 inline bool isPositionedContainer() const
205 { 168 {
206 // FIXME: This is not in sync with containingBlock. 169 // FIXME: This is not in sync with containingBlock.
207 RenderBox* layerRenderer = renderer(); 170 return isRootLayer() || renderer()->isPositioned() || renderer()->hasTra nsform();
208 return isRootLayer() || layerRenderer->isPositioned() || hasTransform();
209 } 171 }
210 172
211 void clipToRect(const LayerPaintingInfo&, GraphicsContext*, const ClipRect&, BorderRadiusClippingRule = IncludeSelfForBorderRadius); 173 void clipToRect(const LayerPaintingInfo&, GraphicsContext*, const ClipRect&, BorderRadiusClippingRule = IncludeSelfForBorderRadius);
212 void restoreClip(GraphicsContext*, const LayoutRect& paintDirtyRect, const C lipRect&); 174 void restoreClip(GraphicsContext*, const LayoutRect& paintDirtyRect, const C lipRect&);
213 175
214 private: 176 private:
215 // Bounding box in the coordinates of this layer. 177 // Bounding box in the coordinates of this layer.
216 LayoutRect logicalBoundingBox() const; 178 LayoutRect logicalBoundingBox() const;
217 179
218 void setNextSibling(RenderLayer* next) { m_next = next; } 180 void setNextSibling(RenderLayer* next) { m_next = next; }
219 void setPreviousSibling(RenderLayer* prev) { m_previous = prev; } 181 void setPreviousSibling(RenderLayer* prev) { m_previous = prev; }
220 void setFirstChild(RenderLayer* first) { m_first = first; } 182 void setFirstChild(RenderLayer* first) { m_first = first; }
221 void setLastChild(RenderLayer* last) { m_last = last; } 183 void setLastChild(RenderLayer* last) { m_last = last; }
222 184
223 LayoutPoint renderBoxLocation() const { return renderer()->location(); }
224
225 bool shouldBeSelfPaintingLayer() const; 185 bool shouldBeSelfPaintingLayer() const;
226 186
227 // FIXME: We should only create the stacking node if needed. 187 void updateFilters(const RenderStyle* oldStyle, const RenderStyle* newStyle) ;
228 bool requiresStackingNode() const { return true; }
229 void updateStackingNode();
230
231 void updateTransform(const RenderStyle* oldStyle, RenderStyle* newStyle); 188 void updateTransform(const RenderStyle* oldStyle, RenderStyle* newStyle);
232 189
233 void dirty3DTransformedDescendantStatus(); 190 void dirty3DTransformedDescendantStatus();
234 191
235 LayerType m_layerType; 192 LayerType m_layerType;
236 193
237 // Self-painting layer is an optimization where we avoid the heavy RenderLay er painting 194 // Self-painting layer is an optimization where we avoid the heavy RenderLay er painting
238 // machinery for a RenderLayer allocated only to handle the overflow clip ca se. 195 // machinery for a RenderLayer allocated only to handle the overflow clip ca se.
239 // FIXME(crbug.com/332791): Self-painting layer should be merged into the ov erflow-only concept. 196 // FIXME(crbug.com/332791): Self-painting layer should be merged into the ov erflow-only concept.
240 unsigned m_isSelfPaintingLayer : 1; 197 unsigned m_isSelfPaintingLayer : 1;
(...skipping 12 matching lines...) Expand all
253 RenderLayer* m_parent; 210 RenderLayer* m_parent;
254 RenderLayer* m_previous; 211 RenderLayer* m_previous;
255 RenderLayer* m_next; 212 RenderLayer* m_next;
256 RenderLayer* m_first; 213 RenderLayer* m_first;
257 RenderLayer* m_last; 214 RenderLayer* m_last;
258 215
259 OwnPtr<TransformationMatrix> m_transform; 216 OwnPtr<TransformationMatrix> m_transform;
260 217
261 RenderLayerClipper m_clipper; // FIXME: Lazily allocate? 218 RenderLayerClipper m_clipper; // FIXME: Lazily allocate?
262 OwnPtr<RenderLayerStackingNode> m_stackingNode; 219 OwnPtr<RenderLayerStackingNode> m_stackingNode;
263
264 LayoutSize m_subpixelAccumulation; // The accumulated subpixel offset of a c omposited layer's composited bounds compared to absolute coordinates.
265 }; 220 };
266 221
267 } // namespace blink 222 } // namespace blink
268 223
269 #endif // SKY_ENGINE_CORE_RENDERING_RENDERLAYER_H_ 224 #endif // SKY_ENGINE_CORE_RENDERING_RENDERLAYER_H_
OLDNEW
« no previous file with comments | « sky/engine/core/rendering/RenderBox.cpp ('k') | sky/engine/core/rendering/RenderLayer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698