OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (C) 2003, 2009, 2012 Apple Inc. All rights reserved. | |
3 * Copyright (C) 2013 Intel Corporation. All rights reserved. | |
4 * | |
5 * Portions are Copyright (C) 1998 Netscape Communications Corporation. | |
6 * | |
7 * Other contributors: | |
8 * Robert O'Callahan <roc+@cs.cmu.edu> | |
9 * David Baron <dbaron@fas.harvard.edu> | |
10 * Christian Biesinger <cbiesinger@web.de> | |
11 * Randall Jesup <rjesup@wgate.com> | |
12 * Roland Mainz <roland.mainz@informatik.med.uni-giessen.de> | |
13 * Josh Soref <timeless@mac.com> | |
14 * Boris Zbarsky <bzbarsky@mit.edu> | |
15 * | |
16 * This library is free software; you can redistribute it and/or | |
17 * modify it under the terms of the GNU Lesser General Public | |
18 * License as published by the Free Software Foundation; either | |
19 * version 2.1 of the License, or (at your option) any later version. | |
20 * | |
21 * This library is distributed in the hope that it will be useful, | |
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
24 * Lesser General Public License for more details. | |
25 * | |
26 * You should have received a copy of the GNU Lesser General Public | |
27 * License along with this library; if not, write to the Free Software | |
28 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 US
A | |
29 * | |
30 * Alternatively, the contents of this file may be used under the terms | |
31 * of either the Mozilla Public License Version 1.1, found at | |
32 * http://www.mozilla.org/MPL/ (the "MPL") or the GNU General Public | |
33 * License Version 2.0, found at http://www.fsf.org/copyleft/gpl.html | |
34 * (the "GPL"), in which case the provisions of the MPL or the GPL are | |
35 * applicable instead of those above. If you wish to allow use of your | |
36 * version of this file only under the terms of one of those two | |
37 * licenses (the MPL or the GPL) and not to allow others to use your | |
38 * version of this file under the LGPL, indicate your decision by | |
39 * deletingthe provisions above and replace them with the notice and | |
40 * other provisions required by the MPL or the GPL, as the case may be. | |
41 * If you do not delete the provisions above, a recipient may use your | |
42 * version of this file under any of the LGPL, the MPL or the GPL. | |
43 */ | |
44 | |
45 #ifndef RenderLayer_h | |
46 #define RenderLayer_h | |
47 | |
48 #include "core/rendering/LayerFragment.h" | |
49 #include "core/rendering/RenderBox.h" | |
50 #include "core/rendering/RenderLayerClipper.h" | |
51 #include "core/rendering/RenderLayerFilterInfo.h" | |
52 #include "core/rendering/RenderLayerReflectionInfo.h" | |
53 #include "core/rendering/RenderLayerScrollableArea.h" | |
54 #include "core/rendering/RenderLayerStackingNode.h" | |
55 #include "core/rendering/RenderLayerStackingNodeIterator.h" | |
56 #include "platform/graphics/CompositingReasons.h" | |
57 #include "public/platform/WebBlendMode.h" | |
58 #include "wtf/OwnPtr.h" | |
59 | |
60 namespace blink { | |
61 | |
62 class FilterEffectRenderer; | |
63 class FilterOperations; | |
64 class HitTestRequest; | |
65 class HitTestResult; | |
66 class HitTestingTransformState; | |
67 class CompositedLayerMapping; | |
68 class RenderLayerCompositor; | |
69 class RenderStyle; | |
70 class TransformationMatrix; | |
71 | |
72 enum IncludeSelfOrNot { IncludeSelf, ExcludeSelf }; | |
73 | |
74 enum CompositingQueryMode { | |
75 CompositingQueriesAreAllowed, | |
76 CompositingQueriesAreOnlyAllowedInCertainDocumentLifecyclePhases | |
77 }; | |
78 | |
79 // FIXME: remove this once the compositing query ASSERTS are no longer hit. | |
80 class DisableCompositingQueryAsserts { | |
81 WTF_MAKE_NONCOPYABLE(DisableCompositingQueryAsserts); | |
82 public: | |
83 DisableCompositingQueryAsserts(); | |
84 private: | |
85 TemporaryChange<CompositingQueryMode> m_disabler; | |
86 }; | |
87 | |
88 class RenderLayer { | |
89 WTF_MAKE_NONCOPYABLE(RenderLayer); | |
90 public: | |
91 RenderLayer(RenderLayerModelObject*, LayerType); | |
92 ~RenderLayer(); | |
93 | |
94 String debugName() const; | |
95 | |
96 RenderLayerModelObject* renderer() const { return m_renderer; } | |
97 RenderBox* renderBox() const { return m_renderer && m_renderer->isBox() ? to
RenderBox(m_renderer) : 0; } | |
98 RenderLayer* parent() const { return m_parent; } | |
99 RenderLayer* previousSibling() const { return m_previous; } | |
100 RenderLayer* nextSibling() const { return m_next; } | |
101 RenderLayer* firstChild() const { return m_first; } | |
102 RenderLayer* lastChild() const { return m_last; } | |
103 | |
104 const RenderLayer* compositingContainer() const; | |
105 | |
106 void addChild(RenderLayer* newChild, RenderLayer* beforeChild = 0); | |
107 RenderLayer* removeChild(RenderLayer*); | |
108 | |
109 void removeOnlyThisLayer(); | |
110 void insertOnlyThisLayer(); | |
111 | |
112 void styleChanged(StyleDifference, const RenderStyle* oldStyle); | |
113 | |
114 // FIXME: Many people call this function while it has out-of-date informatio
n. | |
115 bool isSelfPaintingLayer() const { return m_isSelfPaintingLayer; } | |
116 | |
117 void setLayerType(LayerType layerType) { m_layerType = layerType; } | |
118 | |
119 bool isTransparent() const { return renderer()->isTransparent() || renderer(
)->style()->hasBlendMode() || renderer()->hasMask(); } | |
120 | |
121 bool isReflection() const { return renderer()->isReplica(); } | |
122 RenderLayerReflectionInfo* reflectionInfo() { return m_reflectionInfo.get();
} | |
123 const RenderLayerReflectionInfo* reflectionInfo() const { return m_reflectio
nInfo.get(); } | |
124 | |
125 const RenderLayer* root() const | |
126 { | |
127 const RenderLayer* curr = this; | |
128 while (curr->parent()) | |
129 curr = curr->parent(); | |
130 return curr; | |
131 } | |
132 | |
133 const LayoutPoint& location() const { ASSERT(!m_needsPositionUpdate); return
m_location; } | |
134 // FIXME: size() should ASSERT(!m_needsPositionUpdate) as well, but that fai
ls in some tests, | |
135 // for example, fast/repaint/clipped-relative.html. | |
136 const IntSize& size() const { return m_size; } | |
137 void setSizeHackForLayoutTreeAsText(const IntSize& size) { m_size = size; } | |
138 | |
139 LayoutRect rect() const { return LayoutRect(location(), LayoutSize(size()));
} | |
140 | |
141 bool isRootLayer() const { return m_isRootLayer; } | |
142 | |
143 RenderLayerCompositor* compositor() const; | |
144 | |
145 // Notification from the renderer that its content changed (e.g. current fra
me of image changed). | |
146 // Allows updates of layer content without invalidating paint. | |
147 void contentChanged(ContentChangeType); | |
148 | |
149 void updateLayerPositionsAfterLayout(); | |
150 void updateLayerPositionsAfterOverflowScroll(); | |
151 | |
152 bool isPaginated() const { return m_isPaginated; } | |
153 RenderLayer* enclosingPaginationLayer() const { return m_enclosingPagination
Layer; } | |
154 | |
155 void updateTransformationMatrix(); | |
156 RenderLayer* renderingContextRoot(); | |
157 | |
158 const LayoutSize& offsetForInFlowPosition() const { return m_offsetForInFlow
Position; } | |
159 | |
160 void blockSelectionGapsBoundsChanged(); | |
161 void addBlockSelectionGapsBounds(const LayoutRect&); | |
162 void clearBlockSelectionGapsBounds(); | |
163 void invalidatePaintForBlockSelectionGaps(); | |
164 IntRect blockSelectionGapsBounds() const; | |
165 bool hasBlockSelectionGapBounds() const; | |
166 | |
167 RenderLayerStackingNode* stackingNode() { return m_stackingNode.get(); } | |
168 const RenderLayerStackingNode* stackingNode() const { return m_stackingNode.
get(); } | |
169 | |
170 bool subtreeIsInvisible() const { return !hasVisibleContent() && !hasVisible
Descendant(); } | |
171 | |
172 // FIXME: hasVisibleContent() should call updateDescendantDependentFlags() i
f m_visibleContentStatusDirty. | |
173 bool hasVisibleContent() const { ASSERT(!m_visibleContentStatusDirty); retur
n m_hasVisibleContent; } | |
174 | |
175 // FIXME: hasVisibleDescendant() should call updateDescendantDependentFlags(
) if m_visibleDescendantStatusDirty. | |
176 bool hasVisibleDescendant() const { ASSERT(!m_visibleDescendantStatusDirty);
return m_hasVisibleDescendant; } | |
177 | |
178 void dirtyVisibleContentStatus(); | |
179 void potentiallyDirtyVisibleContentStatus(EVisibility); | |
180 | |
181 bool hasBoxDecorationsOrBackground() const; | |
182 bool hasVisibleBoxDecorations() const; | |
183 // True if this layer container renderers that paint. | |
184 bool hasNonEmptyChildRenderers() const; | |
185 | |
186 // Will ensure that hasNonCompositiedChild are up to date. | |
187 void updateScrollingStateAfterCompositingChange(); | |
188 bool hasVisibleNonLayerContent() const { return m_hasVisibleNonLayerContent;
} | |
189 bool hasNonCompositedChild() const { ASSERT(isAllowedToQueryCompositingState
()); return m_hasNonCompositedChild; } | |
190 | |
191 // Gets the nearest enclosing positioned ancestor layer (also includes | |
192 // the <html> layer and the root layer). | |
193 RenderLayer* enclosingPositionedAncestor() const; | |
194 | |
195 bool isPaintInvalidationContainer() const; | |
196 | |
197 // Do *not* call this method unless you know what you are dooing. You probab
ly want to call enclosingCompositingLayerForPaintInvalidation() instead. | |
198 // If includeSelf is true, may return this. | |
199 RenderLayer* enclosingLayerWithCompositedLayerMapping(IncludeSelfOrNot) cons
t; | |
200 | |
201 // Returns the enclosing layer root into which this layer paints, inclusive
of this one. Note that the enclosing layer may or may not have its own | |
202 // GraphicsLayer backing, but is nevertheless the root for a call to the Ren
derLayer::paint*() methods. | |
203 RenderLayer* enclosingLayerForPaintInvalidation() const; | |
204 | |
205 RenderLayer* enclosingLayerForPaintInvalidationCrossingFrameBoundaries() con
st; | |
206 | |
207 bool hasAncestorWithFilterOutsets() const; | |
208 | |
209 bool canUseConvertToLayerCoords() const | |
210 { | |
211 // These RenderObjects have an impact on their layers without the render
ers knowing about it. | |
212 return !renderer()->hasColumns() && !renderer()->hasTransformRelatedProp
erty() && !renderer()->isSVGRoot(); | |
213 } | |
214 | |
215 void convertToLayerCoords(const RenderLayer* ancestorLayer, LayoutPoint&) co
nst; | |
216 void convertToLayerCoords(const RenderLayer* ancestorLayer, LayoutRect&) con
st; | |
217 | |
218 // Does the same as convertToLayerCoords() when not in multicol. For multico
l, however, | |
219 // convertToLayerCoords() calculates the offset in flow-thread coordinates (
what the layout | |
220 // engine uses internally), while this method calculates the visual coordina
tes; i.e. it figures | |
221 // out which column the layer starts in and adds in the offset. See | |
222 // http://www.chromium.org/developers/design-documents/multi-column-layout f
or more info. | |
223 LayoutPoint visualOffsetFromAncestor(const RenderLayer* ancestorLayer) const
; | |
224 | |
225 // The hitTest() method looks for mouse events by walking layers that inters
ect the point from front to back. | |
226 bool hitTest(const HitTestRequest&, HitTestResult&); | |
227 bool hitTest(const HitTestRequest&, const HitTestLocation&, HitTestResult&); | |
228 | |
229 // Pass offsetFromRoot if known. | |
230 bool intersectsDamageRect(const LayoutRect& layerBounds, const LayoutRect& d
amageRect, const RenderLayer* rootLayer, const LayoutPoint* offsetFromRoot = 0)
const; | |
231 | |
232 // Bounding box relative to some ancestor layer. Pass offsetFromRoot if know
n. | |
233 LayoutRect physicalBoundingBox(const RenderLayer* ancestorLayer, const Layou
tPoint* offsetFromRoot = 0) const; | |
234 LayoutRect physicalBoundingBoxIncludingReflectionAndStackingChildren(const R
enderLayer* ancestorLayer, const LayoutPoint& offsetFromRoot) const; | |
235 LayoutRect fragmentsBoundingBox(const RenderLayer* ancestorLayer) const; | |
236 | |
237 LayoutRect boundingBoxForCompositingOverlapTest() const; | |
238 | |
239 // If true, this layer's children are included in its bounds for overlap tes
ting. | |
240 // We can't rely on the children's positions if this layer has a filter that
could have moved the children's pixels around. | |
241 bool overlapBoundsIncludeChildren() const { return hasFilter() && renderer()
->style()->filter().hasFilterThatMovesPixels(); } | |
242 | |
243 enum CalculateBoundsOptions { | |
244 ApplyBoundsChickenEggHacks, | |
245 DoNotApplyBoundsChickenEggHacks, | |
246 }; | |
247 LayoutRect boundingBoxForCompositing(const RenderLayer* ancestorLayer = 0, C
alculateBoundsOptions = DoNotApplyBoundsChickenEggHacks) const; | |
248 | |
249 LayoutUnit staticInlinePosition() const { return m_staticInlinePosition; } | |
250 LayoutUnit staticBlockPosition() const { return m_staticBlockPosition; } | |
251 | |
252 void setStaticInlinePosition(LayoutUnit position) { m_staticInlinePosition =
position; } | |
253 void setStaticBlockPosition(LayoutUnit position) { m_staticBlockPosition = p
osition; } | |
254 | |
255 LayoutSize subpixelAccumulation() const; | |
256 void setSubpixelAccumulation(const LayoutSize&); | |
257 | |
258 bool hasTransformRelatedProperty() const { return renderer()->hasTransformRe
latedProperty(); } | |
259 // Note that this transform has the transform-origin baked in. | |
260 TransformationMatrix* transform() const { return m_transform.get(); } | |
261 void setTransform(PassOwnPtr<TransformationMatrix> transform) { m_transform
= transform; } | |
262 void clearTransform() { m_transform.clear(); } | |
263 | |
264 // currentTransform computes a transform which takes accelerated animations
into account. The | |
265 // resulting transform has transform-origin baked in. If the layer does not
have a transform, | |
266 // returns the identity matrix. | |
267 TransformationMatrix currentTransform(RenderStyle::ApplyTransformOrigin = Re
nderStyle::IncludeTransformOrigin) const; | |
268 TransformationMatrix renderableTransform(PaintBehavior) const; | |
269 | |
270 // Get the perspective transform, which is applied to transformed sublayers. | |
271 // Returns true if the layer has a -webkit-perspective. | |
272 // Note that this transform has the perspective-origin baked in. | |
273 TransformationMatrix perspectiveTransform() const; | |
274 FloatPoint perspectiveOrigin() const; | |
275 bool preserves3D() const { return renderer()->style()->transformStyle3D() ==
TransformStyle3DPreserve3D; } | |
276 bool has3DTransform() const { return m_transform && !m_transform->isAffine()
; } | |
277 | |
278 // FIXME: reflections should force transform-style to be flat in the style:
https://bugs.webkit.org/show_bug.cgi?id=106959 | |
279 bool shouldPreserve3D() const { return !renderer()->hasReflection() && rende
rer()->style()->transformStyle3D() == TransformStyle3DPreserve3D; } | |
280 | |
281 void filterNeedsPaintInvalidation(); | |
282 bool hasFilter() const { return renderer()->hasFilter(); } | |
283 | |
284 void* operator new(size_t); | |
285 // Only safe to call from RenderLayerModelObject::destroyLayer() | |
286 void operator delete(void*); | |
287 | |
288 CompositingState compositingState() const; | |
289 | |
290 // This returns true if our document is in a phase of its lifestyle during w
hich | |
291 // compositing state may legally be read. | |
292 bool isAllowedToQueryCompositingState() const; | |
293 | |
294 // Don't null check this. | |
295 CompositedLayerMapping* compositedLayerMapping() const; | |
296 GraphicsLayer* graphicsLayerBacking() const; | |
297 GraphicsLayer* graphicsLayerBackingForScrolling() const; | |
298 // NOTE: If you are using hasCompositedLayerMapping to determine the state o
f compositing for this layer, | |
299 // (and not just to do bookkeeping related to the mapping like, say, allocat
ing or deallocating a mapping), | |
300 // then you may have incorrect logic. Use compositingState() instead. | |
301 // FIXME: This is identical to null checking compositedLayerMapping(), why n
ot just call that? | |
302 bool hasCompositedLayerMapping() const { return m_compositedLayerMapping.get
(); } | |
303 void ensureCompositedLayerMapping(); | |
304 void clearCompositedLayerMapping(bool layerBeingDestroyed = false); | |
305 CompositedLayerMapping* groupedMapping() const { return m_groupedMapping; } | |
306 void setGroupedMapping(CompositedLayerMapping* groupedMapping, bool layerBei
ngDestroyed = false); | |
307 | |
308 bool hasCompositedMask() const; | |
309 bool hasCompositedClippingMask() const; | |
310 bool needsCompositedScrolling() const { return m_scrollableArea && m_scrolla
bleArea->needsCompositedScrolling(); } | |
311 | |
312 // Computes the position of the given render object in the space of |paintIn
validationContainer|. | |
313 // FIXME: invert the logic to have paint invalidation containers take care o
f painting objects into them, rather than the reverse. | |
314 // This will allow us to clean up this static method messiness. | |
315 static LayoutPoint positionFromPaintInvalidationBacking(const RenderObject*,
const RenderLayerModelObject* paintInvalidationContainer, const PaintInvalidati
onState* = 0); | |
316 | |
317 static void mapPointToPaintBackingCoordinates(const RenderLayerModelObject*
paintInvalidationContainer, FloatPoint&); | |
318 static void mapRectToPaintBackingCoordinates(const RenderLayerModelObject* p
aintInvalidationContainer, LayoutRect&); | |
319 | |
320 // Adjusts the given rect (in the coordinate space of the RenderObject) to t
he coordinate space of |paintInvalidationContainer|'s GraphicsLayer backing. | |
321 static void mapRectToPaintInvalidationBacking(const RenderObject*, const Ren
derLayerModelObject* paintInvalidationContainer, LayoutRect&, const PaintInvalid
ationState* = 0); | |
322 | |
323 // Computes the bounding paint invalidation rect for |renderObject|, in the
coordinate space of |paintInvalidationContainer|'s GraphicsLayer backing. | |
324 static LayoutRect computePaintInvalidationRect(const RenderObject*, const Re
nderLayer* paintInvalidationContainer, const PaintInvalidationState* = 0); | |
325 | |
326 bool paintsWithTransparency(PaintBehavior paintBehavior) const | |
327 { | |
328 return isTransparent() && ((paintBehavior & PaintBehaviorFlattenComposit
ingLayers) || compositingState() != PaintsIntoOwnBacking); | |
329 } | |
330 | |
331 bool paintsWithTransform(PaintBehavior) const; | |
332 | |
333 // Returns true if background phase is painted opaque in the given rect. | |
334 // The query rect is given in local coordinates. | |
335 bool backgroundIsKnownToBeOpaqueInRect(const LayoutRect&) const; | |
336 | |
337 bool containsDirtyOverlayScrollbars() const { return m_containsDirtyOverlayS
crollbars; } | |
338 void setContainsDirtyOverlayScrollbars(bool dirtyScrollbars) { m_containsDir
tyOverlayScrollbars = dirtyScrollbars; } | |
339 | |
340 FilterOperations computeFilterOperations(const RenderStyle*); | |
341 bool paintsWithFilters() const; | |
342 FilterEffectRenderer* filterRenderer() const | |
343 { | |
344 RenderLayerFilterInfo* filterInfo = this->filterInfo(); | |
345 return filterInfo ? filterInfo->renderer() : 0; | |
346 } | |
347 | |
348 RenderLayerFilterInfo* filterInfo() const { return hasFilterInfo() ? RenderL
ayerFilterInfo::filterInfoForRenderLayer(this) : 0; } | |
349 RenderLayerFilterInfo* ensureFilterInfo() { return RenderLayerFilterInfo::cr
eateFilterInfoForRenderLayerIfNeeded(this); } | |
350 void removeFilterInfoIfNeeded() | |
351 { | |
352 if (hasFilterInfo()) | |
353 RenderLayerFilterInfo::removeFilterInfoForRenderLayer(this); | |
354 } | |
355 | |
356 bool hasFilterInfo() const { return m_hasFilterInfo; } | |
357 void setHasFilterInfo(bool hasFilterInfo) { m_hasFilterInfo = hasFilterInfo;
} | |
358 | |
359 void updateFilters(const RenderStyle* oldStyle, const RenderStyle* newStyle)
; | |
360 | |
361 Node* enclosingElement() const; | |
362 | |
363 bool isInTopLayer() const; | |
364 | |
365 bool scrollsWithViewport() const; | |
366 bool scrollsWithRespectTo(const RenderLayer*) const; | |
367 | |
368 void addLayerHitTestRects(LayerHitTestRects&) const; | |
369 | |
370 // Compute rects only for this layer | |
371 void computeSelfHitTestRects(LayerHitTestRects&) const; | |
372 | |
373 // FIXME: This should probably return a ScrollableArea but a lot of internal
methods are mistakenly exposed. | |
374 RenderLayerScrollableArea* scrollableArea() const { return m_scrollableArea.
get(); } | |
375 RenderLayerClipper& clipper() { return m_clipper; } | |
376 const RenderLayerClipper& clipper() const { return m_clipper; } | |
377 | |
378 inline bool isPositionedContainer() const | |
379 { | |
380 // FIXME: This is not in sync with containingBlock. | |
381 // RenderObject::canContainFixedPositionedObject() should probably be us
ed | |
382 // instead. | |
383 RenderLayerModelObject* layerRenderer = renderer(); | |
384 return isRootLayer() || layerRenderer->isPositioned() || hasTransformRel
atedProperty(); | |
385 } | |
386 | |
387 bool scrollsOverflow() const; | |
388 | |
389 CompositingReasons potentialCompositingReasonsFromStyle() const { return m_p
otentialCompositingReasonsFromStyle; } | |
390 void setPotentialCompositingReasonsFromStyle(CompositingReasons reasons) { A
SSERT(reasons == (reasons & CompositingReasonComboAllStyleDeterminedReasons)); m
_potentialCompositingReasonsFromStyle = reasons; } | |
391 | |
392 bool hasStyleDeterminedDirectCompositingReasons() const { return m_potential
CompositingReasonsFromStyle & CompositingReasonComboAllDirectStyleDeterminedReas
ons; } | |
393 | |
394 class AncestorDependentCompositingInputs { | |
395 public: | |
396 AncestorDependentCompositingInputs() | |
397 : opacityAncestor(0) | |
398 , transformAncestor(0) | |
399 , filterAncestor(0) | |
400 , clippingContainer(0) | |
401 , ancestorScrollingLayer(0) | |
402 , scrollParent(0) | |
403 , clipParent(0) | |
404 , hasAncestorWithClipPath(false) | |
405 { } | |
406 | |
407 IntRect clippedAbsoluteBoundingBox; | |
408 const RenderLayer* opacityAncestor; | |
409 const RenderLayer* transformAncestor; | |
410 const RenderLayer* filterAncestor; | |
411 const RenderObject* clippingContainer; | |
412 const RenderLayer* ancestorScrollingLayer; | |
413 | |
414 // A scroll parent is a compositor concept. It's only needed in blink | |
415 // because we need to use it as a promotion trigger. A layer has a | |
416 // scroll parent if neither its compositor scrolling ancestor, nor any | |
417 // other layer scrolled by this ancestor, is a stacking ancestor of this | |
418 // layer. Layers with scroll parents must be scrolled with the main | |
419 // scrolling layer by the compositor. | |
420 const RenderLayer* scrollParent; | |
421 | |
422 // A clip parent is another compositor concept that has leaked into | |
423 // blink so that it may be used as a promotion trigger. Layers with clip | |
424 // parents escape the clip of a stacking tree ancestor. The compositor | |
425 // needs to know about clip parents in order to circumvent its normal | |
426 // clipping logic. | |
427 const RenderLayer* clipParent; | |
428 | |
429 unsigned hasAncestorWithClipPath : 1; | |
430 }; | |
431 | |
432 class DescendantDependentCompositingInputs { | |
433 public: | |
434 DescendantDependentCompositingInputs() | |
435 : hasDescendantWithClipPath(false) | |
436 , hasNonIsolatedDescendantWithBlendMode(false) | |
437 { } | |
438 | |
439 unsigned hasDescendantWithClipPath : 1; | |
440 unsigned hasNonIsolatedDescendantWithBlendMode : 1; | |
441 }; | |
442 | |
443 void setNeedsCompositingInputsUpdate(); | |
444 bool childNeedsCompositingInputsUpdate() const { return m_childNeedsComposit
ingInputsUpdate; } | |
445 bool needsCompositingInputsUpdate() const | |
446 { | |
447 // While we're updating the compositing inputs, these values may differ. | |
448 // We should never be asking for this value when that is the case. | |
449 ASSERT(m_needsDescendantDependentCompositingInputsUpdate == m_needsAnces
torDependentCompositingInputsUpdate); | |
450 return m_needsDescendantDependentCompositingInputsUpdate; | |
451 } | |
452 | |
453 void updateAncestorDependentCompositingInputs(const AncestorDependentComposi
tingInputs&); | |
454 void updateDescendantDependentCompositingInputs(const DescendantDependentCom
positingInputs&); | |
455 void didUpdateCompositingInputs(); | |
456 | |
457 const AncestorDependentCompositingInputs& ancestorDependentCompositingInputs
() const { ASSERT(!m_needsAncestorDependentCompositingInputsUpdate); return m_an
cestorDependentCompositingInputs; } | |
458 const DescendantDependentCompositingInputs& descendantDependentCompositingIn
puts() const { ASSERT(!m_needsDescendantDependentCompositingInputsUpdate); retur
n m_descendantDependentCompositingInputs; } | |
459 | |
460 IntRect clippedAbsoluteBoundingBox() const { return ancestorDependentComposi
tingInputs().clippedAbsoluteBoundingBox; } | |
461 const RenderLayer* opacityAncestor() const { return ancestorDependentComposi
tingInputs().opacityAncestor; } | |
462 const RenderLayer* transformAncestor() const { return ancestorDependentCompo
sitingInputs().transformAncestor; } | |
463 const RenderLayer* filterAncestor() const { return ancestorDependentComposit
ingInputs().filterAncestor; } | |
464 const RenderObject* clippingContainer() const { return ancestorDependentComp
ositingInputs().clippingContainer; } | |
465 const RenderLayer* ancestorScrollingLayer() const { return ancestorDependent
CompositingInputs().ancestorScrollingLayer; } | |
466 RenderLayer* scrollParent() const { return const_cast<RenderLayer*>(ancestor
DependentCompositingInputs().scrollParent); } | |
467 RenderLayer* clipParent() const { return const_cast<RenderLayer*>(ancestorDe
pendentCompositingInputs().clipParent); } | |
468 bool hasAncestorWithClipPath() const { return ancestorDependentCompositingIn
puts().hasAncestorWithClipPath; } | |
469 bool hasDescendantWithClipPath() const { return descendantDependentCompositi
ngInputs().hasDescendantWithClipPath; } | |
470 bool hasNonIsolatedDescendantWithBlendMode() const; | |
471 | |
472 bool lostGroupedMapping() const { ASSERT(isAllowedToQueryCompositingState())
; return m_lostGroupedMapping; } | |
473 void setLostGroupedMapping(bool b) { m_lostGroupedMapping = b; } | |
474 | |
475 CompositingReasons compositingReasons() const { ASSERT(isAllowedToQueryCompo
sitingState()); return m_compositingReasons; } | |
476 void setCompositingReasons(CompositingReasons, CompositingReasons mask = Com
positingReasonAll); | |
477 | |
478 bool hasCompositingDescendant() const { ASSERT(isAllowedToQueryCompositingSt
ate()); return m_hasCompositingDescendant; } | |
479 void setHasCompositingDescendant(bool); | |
480 | |
481 bool shouldIsolateCompositedDescendants() const { ASSERT(isAllowedToQueryCom
positingState()); return m_shouldIsolateCompositedDescendants; } | |
482 void setShouldIsolateCompositedDescendants(bool); | |
483 | |
484 void updateDescendantDependentFlags(); | |
485 void updateDescendantDependentFlagsForEntireSubtree(); | |
486 | |
487 void updateOrRemoveFilterEffectRenderer(); | |
488 | |
489 void updateSelfPaintingLayer(); | |
490 | |
491 RenderLayer* enclosingTransformedAncestor() const; | |
492 LayoutPoint computeOffsetFromTransformedAncestor() const; | |
493 | |
494 void didUpdateNeedsCompositedScrolling(); | |
495 | |
496 void setShouldDoFullPaintInvalidationIncludingNonCompositingDescendants(); | |
497 | |
498 bool hasSelfPaintingLayerDescendant() const | |
499 { | |
500 if (m_hasSelfPaintingLayerDescendantDirty) | |
501 updateHasSelfPaintingLayerDescendant(); | |
502 ASSERT(!m_hasSelfPaintingLayerDescendantDirty); | |
503 return m_hasSelfPaintingLayerDescendant; | |
504 } | |
505 LayoutRect paintingExtent(const RenderLayer* rootLayer, const LayoutRect& pa
intDirtyRect, const LayoutSize& subPixelAccumulation, PaintBehavior); | |
506 void collectFragments(LayerFragments&, const RenderLayer* rootLayer, const L
ayoutRect& dirtyRect, | |
507 ClipRectsCacheSlot, OverlayScrollbarSizeRelevancy inOverlayScrollbarSize
Relevancy = IgnoreOverlayScrollbarSize, | |
508 ShouldRespectOverflowClip = RespectOverflowClip, const LayoutPoint* offs
etFromRoot = 0, | |
509 const LayoutSize& subPixelAccumulation = LayoutSize(), const LayoutRect*
layerBoundingBox = 0); | |
510 | |
511 LayoutPoint renderBoxLocation() const { return renderer()->isBox() ? toRende
rBox(renderer())->location() : LayoutPoint(); } | |
512 | |
513 enum TransparencyClipBoxBehavior { | |
514 PaintingTransparencyClipBox, | |
515 HitTestingTransparencyClipBox | |
516 }; | |
517 | |
518 enum TransparencyClipBoxMode { | |
519 DescendantsOfTransparencyClipBox, | |
520 RootOfTransparencyClipBox | |
521 }; | |
522 | |
523 static LayoutRect transparencyClipBox(const RenderLayer*, const RenderLayer*
rootLayer, TransparencyClipBoxBehavior transparencyBehavior, | |
524 TransparencyClipBoxMode transparencyMode, const LayoutSize& subPixelAccu
mulation, PaintBehavior = 0); | |
525 | |
526 private: | |
527 // Bounding box in the coordinates of this layer. | |
528 LayoutRect logicalBoundingBox() const; | |
529 | |
530 bool hasOverflowControls() const; | |
531 | |
532 void dirtyAncestorChainHasSelfPaintingLayerDescendantStatus(); | |
533 | |
534 // Returns true if the position changed. | |
535 bool updateLayerPosition(); | |
536 | |
537 void updateLayerPositionRecursive(); | |
538 void updateLayerPositionsAfterScrollRecursive(); | |
539 | |
540 void setNextSibling(RenderLayer* next) { m_next = next; } | |
541 void setPreviousSibling(RenderLayer* prev) { m_previous = prev; } | |
542 void setFirstChild(RenderLayer* first) { m_first = first; } | |
543 void setLastChild(RenderLayer* last) { m_last = last; } | |
544 | |
545 void updateHasSelfPaintingLayerDescendant() const; | |
546 RenderLayer* hitTestLayer(RenderLayer* rootLayer, RenderLayer* containerLaye
r, const HitTestRequest& request, HitTestResult& result, | |
547 const LayoutRect& hitTestRect, const HitTestLocati
on&, bool appliedTransform, | |
548 const HitTestingTransformState* transformState = 0
, double* zOffset = 0); | |
549 RenderLayer* hitTestLayerByApplyingTransform(RenderLayer* rootLayer, RenderL
ayer* containerLayer, const HitTestRequest&, HitTestResult&, | |
550 const LayoutRect& hitTestRect, const HitTestLocation&, const HitTestingT
ransformState* = 0, double* zOffset = 0, | |
551 const LayoutPoint& translationOffset = LayoutPoint()); | |
552 RenderLayer* hitTestChildren(ChildrenIteration, RenderLayer* rootLayer, cons
t HitTestRequest&, HitTestResult&, | |
553 const LayoutRect& hitTestRect, const HitTestLocatio
n&, | |
554 const HitTestingTransformState* transformState, dou
ble* zOffsetForDescendants, double* zOffset, | |
555 const HitTestingTransformState* unflattenedTransfor
mState, bool depthSortDescendants); | |
556 RenderLayer* hitTestPaginatedChildLayer(RenderLayer* childLayer, RenderLayer
* rootLayer, const HitTestRequest& request, HitTestResult& result, | |
557 const LayoutRect& hitTestRect, const
HitTestLocation&, | |
558 const HitTestingTransformState* tran
sformState, double* zOffset); | |
559 RenderLayer* hitTestChildLayerColumns(RenderLayer* childLayer, RenderLayer*
rootLayer, const HitTestRequest& request, HitTestResult& result, | |
560 const LayoutRect& hitTestRect, const H
itTestLocation&, | |
561 const HitTestingTransformState* transf
ormState, double* zOffset, | |
562 const Vector<RenderLayer*>& columnLaye
rs, size_t columnIndex); | |
563 | |
564 PassRefPtr<HitTestingTransformState> createLocalTransformState(RenderLayer*
rootLayer, RenderLayer* containerLayer, | |
565 const LayoutRect& hitTestRect, const HitTestLocation
&, | |
566 const HitTestingTransformState* containerTransformSt
ate, | |
567 const LayoutPoint& translationOffset = LayoutPoint()
) const; | |
568 | |
569 bool hitTestContents(const HitTestRequest&, HitTestResult&, const LayoutRect
& layerBounds, const HitTestLocation&, HitTestFilter) const; | |
570 bool hitTestContentsForFragments(const LayerFragments&, const HitTestRequest
&, HitTestResult&, const HitTestLocation&, HitTestFilter, bool& insideClipRect)
const; | |
571 RenderLayer* hitTestTransformedLayerInFragments(RenderLayer* rootLayer, Rend
erLayer* containerLayer, const HitTestRequest&, HitTestResult&, | |
572 const LayoutRect& hitTestRect, const HitTestLocation&, const HitTestingT
ransformState* = 0, double* zOffset = 0); | |
573 | |
574 bool childBackgroundIsKnownToBeOpaqueInRect(const LayoutRect&) const; | |
575 | |
576 bool shouldBeSelfPaintingLayer() const; | |
577 | |
578 // FIXME: We should only create the stacking node if needed. | |
579 bool requiresStackingNode() const { return true; } | |
580 void updateStackingNode(); | |
581 | |
582 void updateReflectionInfo(const RenderStyle*); | |
583 | |
584 // FIXME: We could lazily allocate our ScrollableArea based on style propert
ies ('overflow', ...) | |
585 // but for now, we are always allocating it for RenderBox as it's safer. | |
586 bool requiresScrollableArea() const { return renderBox(); } | |
587 void updateScrollableArea(); | |
588 | |
589 void dirtyAncestorChainVisibleDescendantStatus(); | |
590 | |
591 bool attemptDirectCompositingUpdate(StyleDifference, const RenderStyle* oldS
tyle); | |
592 void updateTransform(const RenderStyle* oldStyle, RenderStyle* newStyle); | |
593 | |
594 void dirty3DTransformedDescendantStatus(); | |
595 // Both updates the status, and returns true if descendants of this have 3d. | |
596 bool update3DTransformedDescendantStatus(); | |
597 | |
598 void updateOrRemoveFilterClients(); | |
599 | |
600 void updatePaginationRecursive(bool needsPaginationUpdate = false); | |
601 void updatePagination(); | |
602 void clearPaginationRecursive(); | |
603 | |
604 // FIXME: Temporary. Remove when new columns come online. | |
605 bool useRegionBasedColumns() const; | |
606 | |
607 LayerType m_layerType; | |
608 | |
609 // Self-painting layer is an optimization where we avoid the heavy RenderLay
er painting | |
610 // machinery for a RenderLayer allocated only to handle the overflow clip ca
se. | |
611 // FIXME(crbug.com/332791): Self-painting layer should be merged into the ov
erflow-only concept. | |
612 unsigned m_isSelfPaintingLayer : 1; | |
613 | |
614 // If have no self-painting descendants, we don't have to walk our children
during painting. This can lead to | |
615 // significant savings, especially if the tree has lots of non-self-painting
layers grouped together (e.g. table cells). | |
616 mutable unsigned m_hasSelfPaintingLayerDescendant : 1; | |
617 mutable unsigned m_hasSelfPaintingLayerDescendantDirty : 1; | |
618 | |
619 const unsigned m_isRootLayer : 1; | |
620 | |
621 unsigned m_visibleContentStatusDirty : 1; | |
622 unsigned m_hasVisibleContent : 1; | |
623 unsigned m_visibleDescendantStatusDirty : 1; | |
624 unsigned m_hasVisibleDescendant : 1; | |
625 | |
626 unsigned m_hasVisibleNonLayerContent : 1; | |
627 | |
628 unsigned m_isPaginated : 1; // If we think this layer is split by a multi-co
lumn ancestor, then this bit will be set. | |
629 | |
630 #if ENABLE(ASSERT) | |
631 unsigned m_needsPositionUpdate : 1; | |
632 #endif | |
633 | |
634 unsigned m_3DTransformedDescendantStatusDirty : 1; | |
635 // Set on a stacking context layer that has 3D descendants anywhere | |
636 // in a preserves3D hierarchy. Hint to do 3D-aware hit testing. | |
637 unsigned m_has3DTransformedDescendant : 1; | |
638 | |
639 unsigned m_containsDirtyOverlayScrollbars : 1; | |
640 | |
641 unsigned m_hasFilterInfo : 1; | |
642 unsigned m_needsAncestorDependentCompositingInputsUpdate : 1; | |
643 unsigned m_needsDescendantDependentCompositingInputsUpdate : 1; | |
644 unsigned m_childNeedsCompositingInputsUpdate : 1; | |
645 | |
646 // Used only while determining what layers should be composited. Applies to
the tree of z-order lists. | |
647 unsigned m_hasCompositingDescendant : 1; | |
648 | |
649 // Applies to the real render layer tree (i.e., the tree determined by the l
ayer's parent and children and | |
650 // as opposed to the tree formed by the z-order and normal flow lists). | |
651 unsigned m_hasNonCompositedChild : 1; | |
652 | |
653 // Should be for stacking contexts having unisolated blending descendants. | |
654 unsigned m_shouldIsolateCompositedDescendants : 1; | |
655 | |
656 // True if this render layer just lost its grouped mapping due to the Compos
itedLayerMapping being destroyed, | |
657 // and we don't yet know to what graphics layer this RenderLayer will be ass
igned. | |
658 unsigned m_lostGroupedMapping : 1; | |
659 | |
660 RenderLayerModelObject* m_renderer; | |
661 | |
662 RenderLayer* m_parent; | |
663 RenderLayer* m_previous; | |
664 RenderLayer* m_next; | |
665 RenderLayer* m_first; | |
666 RenderLayer* m_last; | |
667 | |
668 // Our current relative position offset. | |
669 LayoutSize m_offsetForInFlowPosition; | |
670 | |
671 // Our (x,y) coordinates are in our parent layer's coordinate space. | |
672 LayoutPoint m_location; | |
673 | |
674 // The layer's width/height | |
675 IntSize m_size; | |
676 | |
677 // Cached normal flow values for absolute positioned elements with static le
ft/top values. | |
678 LayoutUnit m_staticInlinePosition; | |
679 LayoutUnit m_staticBlockPosition; | |
680 | |
681 OwnPtr<TransformationMatrix> m_transform; | |
682 | |
683 // Pointer to the enclosing RenderLayer that caused us to be paginated. It i
s 0 if we are not paginated. | |
684 // | |
685 // See RenderMultiColumnFlowThread and | |
686 // https://sites.google.com/a/chromium.org/dev/developers/design-documents/m
ulti-column-layout | |
687 // for more information about the multicol implementation. It's important to
understand the | |
688 // difference between flow thread coordinates and visual coordinates when wo
rking with multicol | |
689 // in RenderLayer, since RenderLayer is one of the few places where we have
to worry about the | |
690 // visual ones. Internally we try to use flow-thread coordinates whenever po
ssible. | |
691 RenderLayer* m_enclosingPaginationLayer; | |
692 | |
693 // These compositing reasons are updated whenever style changes, not while u
pdating compositing layers. | |
694 // They should not be used to infer the compositing state of this layer. | |
695 CompositingReasons m_potentialCompositingReasonsFromStyle; | |
696 | |
697 // Once computed, indicates all that a layer needs to become composited usin
g the CompositingReasons enum bitfield. | |
698 CompositingReasons m_compositingReasons; | |
699 | |
700 DescendantDependentCompositingInputs m_descendantDependentCompositingInputs; | |
701 AncestorDependentCompositingInputs m_ancestorDependentCompositingInputs; | |
702 | |
703 IntRect m_blockSelectionGapsBounds; | |
704 | |
705 OwnPtr<CompositedLayerMapping> m_compositedLayerMapping; | |
706 OwnPtr<RenderLayerScrollableArea> m_scrollableArea; | |
707 | |
708 CompositedLayerMapping* m_groupedMapping; | |
709 | |
710 RenderLayerClipper m_clipper; // FIXME: Lazily allocate? | |
711 OwnPtr<RenderLayerStackingNode> m_stackingNode; | |
712 OwnPtr<RenderLayerReflectionInfo> m_reflectionInfo; | |
713 | |
714 LayoutSize m_subpixelAccumulation; // The accumulated subpixel offset of a c
omposited layer's composited bounds compared to absolute coordinates. | |
715 }; | |
716 | |
717 } // namespace blink | |
718 | |
719 #ifndef NDEBUG | |
720 // Outside the WebCore namespace for ease of invocation from gdb. | |
721 void showLayerTree(const blink::RenderLayer*); | |
722 void showLayerTree(const blink::RenderObject*); | |
723 #endif | |
724 | |
725 #endif // RenderLayer_h | |
OLD | NEW |