2 * Copyright (C) 2003, 2009, 2012, 2015 Apple Inc. All rights reserved.
4 * Portions are Copyright (C) 1998 Netscape Communications Corporation.
7 * Robert O'Callahan <roc+@cs.cmu.edu>
8 * David Baron <dbaron@fas.harvard.edu>
9 * Christian Biesinger <cbiesinger@web.de>
10 * Randall Jesup <rjesup@wgate.com>
11 * Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
12 * Josh Soref <timeless@mac.com>
13 * Boris Zbarsky <bzbarsky@mit.edu>
15 * This library is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU Lesser General Public
17 * License as published by the Free Software Foundation; either
18 * version 2.1 of the License, or (at your option) any later version.
20 * This library is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 * Lesser General Public License for more details.
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the Free Software
27 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
29 * Alternatively, the contents of this file may be used under the terms
30 * of either the Mozilla Public License Version 1.1, found at
31 * http://www.mozilla.org/MPL/ (the "MPL") or the GNU General Public
32 * License Version 2.0, found at http://www.fsf.org/copyleft/gpl.html
33 * (the "GPL"), in which case the provisions of the MPL or the GPL are
34 * applicable instead of those above. If you wish to allow use of your
35 * version of this file only under the terms of one of those two
36 * licenses (the MPL or the GPL) and not to allow others to use your
37 * version of this file under the LGPL, indicate your decision by
38 * deletingthe provisions above and replace them with the notice and
39 * other provisions required by the MPL or the GPL, as the case may be.
40 * If you do not delete the provisions above, a recipient may use your
41 * version of this file under any of the LGPL, the MPL or the GPL.
47 #include "GraphicsLayer.h"
48 #include "LayerFragment.h"
49 #include "PaintInfo.h"
50 #include "RenderBox.h"
51 #include "RenderPtr.h"
52 #include "ScrollableArea.h"
63 class FilterEffectRenderer;
64 class FilterEffectRendererHelper;
65 class FilterOperations;
68 class HitTestingTransformState;
69 class PaintFrequencyInfo;
70 class RenderFragmentedFlow;
71 class RenderGeometryMap;
72 class RenderLayerBacking;
73 class RenderLayerCompositor;
76 class RenderScrollbarPart;
80 class TransformationMatrix;
82 enum BorderRadiusClippingRule { IncludeSelfForBorderRadius, DoNotIncludeSelfForBorderRadius };
83 enum IncludeSelfOrNot { IncludeSelf, ExcludeSelf };
88 NeedsFullRepaintForPositionedMovementLayout
92 PaintingClipRects, // Relative to painting ancestor. Used for painting.
93 RootRelativeClipRects, // Relative to the ancestor treated as the root (e.g. transformed layer). Used for hit testing.
94 AbsoluteClipRects, // Relative to the RenderView's layer. Used for compositing overlap testing.
95 NumCachedClipRectsTypes,
100 enum ShouldRespectOverflowClip {
105 enum ShouldApplyRootOffsetToFragments {
106 ApplyRootOffsetToFragments,
107 IgnoreRootOffsetForFragments
110 enum LayerScrollCoordinationRole {
111 ViewportConstrained = 1 << 0,
114 typedef unsigned LayerScrollCoordinationRoles;
116 enum class RequestState {
124 class RenderLayer final : public ScrollableArea {
125 WTF_MAKE_FAST_ALLOCATED;
127 friend class RenderReplica;
129 explicit RenderLayer(RenderLayerModelObject&);
130 virtual ~RenderLayer();
133 // Called before the renderer's widget (if any) has been nulled out.
134 void willBeDestroyed();
138 RenderLayerModelObject& renderer() const { return m_renderer; }
139 RenderBox* renderBox() const { return is<RenderBox>(renderer()) ? &downcast<RenderBox>(renderer()) : nullptr; }
140 RenderLayer* parent() const { return m_parent; }
141 RenderLayer* previousSibling() const { return m_previous; }
142 RenderLayer* nextSibling() const { return m_next; }
143 RenderLayer* firstChild() const { return m_first; }
144 RenderLayer* lastChild() const { return m_last; }
146 void addChild(RenderLayer* newChild, RenderLayer* beforeChild = nullptr);
147 RenderLayer* removeChild(RenderLayer*);
149 Page& page() const { return renderer().page(); }
151 void removeOnlyThisLayer();
152 void insertOnlyThisLayer();
154 void repaintIncludingDescendants();
156 // Indicate that the layer contents need to be repainted. Only has an effect
157 // if layer compositing is being used.
158 void setBackingNeedsRepaint(GraphicsLayer::ShouldClipToLayer = GraphicsLayer::ClipToLayer);
160 // The rect is in the coordinate space of the layer's render object.
161 void setBackingNeedsRepaintInRect(const LayoutRect&, GraphicsLayer::ShouldClipToLayer = GraphicsLayer::ClipToLayer);
162 void repaintIncludingNonCompositingDescendants(RenderLayerModelObject* repaintContainer);
164 void styleChanged(StyleDifference, const RenderStyle* oldStyle);
166 RenderMarquee* marquee() const { return m_marquee.get(); }
168 bool isNormalFlowOnly() const { return m_isNormalFlowOnly; }
169 bool isSelfPaintingLayer() const { return m_isSelfPaintingLayer; }
171 bool cannotBlitToWindow() const;
173 bool isTransparent() const { return renderer().isTransparent() || renderer().hasMask(); }
175 bool hasReflection() const { return renderer().hasReflection(); }
176 bool isReflection() const { return renderer().isReplica(); }
177 RenderReplica* reflection() const { return m_reflection.get(); }
178 RenderLayer* reflectionLayer() const;
180 const RenderLayer* root() const
182 const RenderLayer* curr = this;
183 while (curr->parent())
184 curr = curr->parent();
188 const LayoutPoint& location() const { return m_topLeft; }
189 void setLocation(const LayoutPoint& p) { m_topLeft = p; }
191 const IntSize& size() const { return m_layerSize; }
192 void setSize(const IntSize& size) { m_layerSize = size; }
194 LayoutRect rect() const { return LayoutRect(location(), size()); }
196 int scrollWidth() const;
197 int scrollHeight() const;
199 void panScrollFromPoint(const IntPoint&);
201 // Scrolling methods for layers that can scroll their overflow.
202 void scrollByRecursively(const IntSize& delta, ScrollableArea** scrolledArea = nullptr);
204 WEBCORE_EXPORT void scrollToOffset(const ScrollOffset&, ScrollClamping = ScrollClamping::Clamped);
205 void scrollToXOffset(int x, ScrollClamping clamping = ScrollClamping::Clamped) { scrollToOffset(ScrollOffset(x, scrollOffset().y()), clamping); }
206 void scrollToYOffset(int y, ScrollClamping clamping = ScrollClamping::Clamped) { scrollToOffset(ScrollOffset(scrollOffset().x(), y), clamping); }
208 void scrollToXPosition(int x, ScrollClamping = ScrollClamping::Clamped);
209 void scrollToYPosition(int y, ScrollClamping = ScrollClamping::Clamped);
211 void setPostLayoutScrollPosition(std::optional<ScrollPosition>);
212 void applyPostLayoutScrollPositionIfNeeded();
214 ScrollOffset scrollOffset() const { return scrollOffsetFromPosition(m_scrollPosition); }
215 IntSize scrollableContentsSize() const;
217 void availableContentSizeChanged(AvailableSizeChangeReason) override;
219 // "absoluteRect" is in scaled document coordinates.
220 void scrollRectToVisible(SelectionRevealMode, const LayoutRect& absoluteRect, bool insideFixed, const ScrollAlignment& alignX, const ScrollAlignment& alignY);
222 bool scrollsOverflow() const;
223 bool hasScrollbars() const { return m_hBar || m_vBar; }
224 void setHasHorizontalScrollbar(bool);
225 void setHasVerticalScrollbar(bool);
227 Ref<Scrollbar> createScrollbar(ScrollbarOrientation);
228 void destroyScrollbar(ScrollbarOrientation);
230 bool hasHorizontalScrollbar() const { return horizontalScrollbar(); }
231 bool hasVerticalScrollbar() const { return verticalScrollbar(); }
233 // ScrollableArea overrides
234 ScrollPosition scrollPosition() const override { return m_scrollPosition; }
236 Scrollbar* horizontalScrollbar() const override { return m_hBar.get(); }
237 Scrollbar* verticalScrollbar() const override { return m_vBar.get(); }
238 ScrollableArea* enclosingScrollableArea() const override;
239 bool isScrollableOrRubberbandable() override;
240 bool hasScrollableOrRubberbandableAncestor() override;
241 #if ENABLE(CSS_SCROLL_SNAP)
242 void updateSnapOffsets() override;
246 #if ENABLE(TOUCH_EVENTS)
247 bool handleTouchEvent(const PlatformTouchEvent&) override;
250 void didStartScroll() override;
251 void didEndScroll() override;
252 void didUpdateScroll() override;
253 void setIsUserScroll(bool isUserScroll) override { m_inUserScroll = isUserScroll; }
255 bool isInUserScroll() const { return m_inUserScroll; }
257 bool requiresScrollBoundsOriginUpdate() const { return m_requiresScrollBoundsOriginUpdate; }
258 void setRequiresScrollBoundsOriginUpdate(bool requiresUpdate = true) { m_requiresScrollBoundsOriginUpdate = requiresUpdate; }
260 // Returns true when the layer could do touch scrolling, but doesn't look at whether there is actually scrollable overflow.
261 bool hasAcceleratedTouchScrolling() const;
262 // Returns true when there is actually scrollable overflow (requires layout to be up-to-date).
263 bool hasTouchScrollableOverflow() const;
265 bool hasAcceleratedTouchScrolling() const { return false; }
266 bool hasTouchScrollableOverflow() const { return false; }
268 bool usesAcceleratedScrolling() const;
270 int verticalScrollbarWidth(OverlayScrollbarSizeRelevancy = IgnoreOverlayScrollbarSize) const;
271 int horizontalScrollbarHeight(OverlayScrollbarSizeRelevancy = IgnoreOverlayScrollbarSize) const;
273 bool hasOverflowControls() const;
274 bool isPointInResizeControl(const IntPoint& absolutePoint) const;
275 bool hitTestOverflowControls(HitTestResult&, const IntPoint& localPoint);
276 IntSize offsetFromResizeCorner(const IntPoint& absolutePoint) const;
278 void paintOverflowControls(GraphicsContext&, const IntPoint&, const IntRect& damageRect, bool paintingOverlayControls = false);
279 void paintScrollCorner(GraphicsContext&, const IntPoint&, const IntRect& damageRect);
280 void paintResizer(GraphicsContext&, const LayoutPoint&, const LayoutRect& damageRect);
282 void updateScrollInfoAfterLayout();
284 bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1);
285 void autoscroll(const IntPoint&);
287 bool canResize() const;
288 void resize(const PlatformMouseEvent&, const LayoutSize&);
289 bool inResizeMode() const { return m_inResizeMode; }
290 void setInResizeMode(bool b) { m_inResizeMode = b; }
292 bool isRenderViewLayer() const { return m_isRenderViewLayer; }
294 RenderLayerCompositor& compositor() const;
296 // Notification from the renderer that its content changed (e.g. current frame of image changed).
297 // Allows updates of layer content without repainting.
298 void contentChanged(ContentChangeType);
300 bool canRender3DTransforms() const;
302 enum UpdateLayerPositionsFlag {
303 CheckForRepaint = 1 << 0,
304 NeedsFullRepaintInBacking = 1 << 1,
305 IsCompositingUpdateRoot = 1 << 2,
306 UpdateCompositingLayers = 1 << 3,
307 UpdatePagination = 1 << 4,
308 SeenTransformedLayer = 1 << 5,
309 Seen3DTransformedLayer = 1 << 6
311 typedef unsigned UpdateLayerPositionsFlags;
312 static const UpdateLayerPositionsFlags defaultFlags = CheckForRepaint | IsCompositingUpdateRoot | UpdateCompositingLayers;
314 void updateLayerPositionsAfterLayout(const RenderLayer* rootLayer, UpdateLayerPositionsFlags);
316 void updateLayerPositionsAfterOverflowScroll();
317 void updateLayerPositionsAfterDocumentScroll();
319 void positionNewlyCreatedOverflowControls();
321 bool hasCompositedLayerInEnclosingPaginationChain() const;
322 enum PaginationInclusionMode { ExcludeCompositedPaginatedLayers, IncludeCompositedPaginatedLayers };
323 RenderLayer* enclosingPaginationLayer(PaginationInclusionMode mode) const
325 if (mode == ExcludeCompositedPaginatedLayers && hasCompositedLayerInEnclosingPaginationChain())
327 return m_enclosingPaginationLayer;
330 void updateTransform();
332 #if ENABLE(CSS_COMPOSITING)
333 void updateBlendMode();
336 const LayoutSize& offsetForInFlowPosition() const { return m_offsetForInFlowPosition; }
338 void clearClipRectsIncludingDescendants(ClipRectsType typeToClear = AllClipRectTypes);
339 void clearClipRects(ClipRectsType typeToClear = AllClipRectTypes);
341 void addBlockSelectionGapsBounds(const LayoutRect&);
342 void clearBlockSelectionGapsBounds();
343 void repaintBlockSelectionGaps();
345 // A stacking context is a layer that has a non-auto z-index.
346 bool isStackingContext() const { return isStackingContext(&renderer().style()); }
348 // A stacking container can have z-order lists. All stacking contexts are
349 // stacking containers, but the converse is not true. Layers that use
350 // composited scrolling are stacking containers, but they may not
351 // necessarily be stacking contexts.
352 bool isStackingContainer() const { return isStackingContext() || needsCompositedScrolling(); }
354 // Gets the enclosing stacking container for this layer, excluding this
356 RenderLayer* stackingContainer() const;
358 // Gets the enclosing stacking container for this layer, possibly the layer
359 // itself, if it is a stacking container.
360 RenderLayer* enclosingStackingContainer() { return isStackingContainer() ? this : stackingContainer(); }
362 void dirtyZOrderLists();
363 void dirtyStackingContainerZOrderLists();
365 Vector<RenderLayer*>* posZOrderList() const
367 ASSERT(!m_zOrderListsDirty);
368 ASSERT(isStackingContainer() || !m_posZOrderList);
369 return m_posZOrderList.get();
372 bool hasNegativeZOrderList() const { return negZOrderList() && negZOrderList()->size(); }
374 Vector<RenderLayer*>* negZOrderList() const
376 ASSERT(!m_zOrderListsDirty);
377 ASSERT(isStackingContainer() || !m_negZOrderList);
378 return m_negZOrderList.get();
381 void dirtyNormalFlowList();
382 Vector<RenderLayer*>* normalFlowList() const { ASSERT(!m_normalFlowListDirty); return m_normalFlowList.get(); }
384 // Update our normal and z-index lists.
385 void updateLayerListsIfNeeded();
387 // Update the normal and z-index lists of our descendants.
388 void updateDescendantsLayerListsIfNeeded(bool recursive);
390 // FIXME: We should ASSERT(!m_visibleContentStatusDirty) here, but see https://bugs.webkit.org/show_bug.cgi?id=71044
391 // ditto for hasVisibleDescendant(), see https://bugs.webkit.org/show_bug.cgi?id=71277
392 bool hasVisibleContent() const { return m_hasVisibleContent; }
393 bool hasVisibleDescendant() const { return m_hasVisibleDescendant; }
395 void setHasVisibleContent();
396 void dirtyVisibleContentStatus();
398 bool hasVisibleBoxDecorationsOrBackground() const;
399 bool hasVisibleBoxDecorations() const;
401 struct PaintedContentRequest {
402 void makeStatesUndetermined()
404 if (hasPaintedContent == RequestState::Unknown)
405 hasPaintedContent = RequestState::Undetermined;
407 if (hasSubpixelAntialiasedText == RequestState::Unknown)
408 hasSubpixelAntialiasedText = RequestState::Undetermined;
411 void setHasPaintedContent() { hasPaintedContent = RequestState::True; }
412 void setHasSubpixelAntialiasedText() { hasSubpixelAntialiasedText = RequestState::True; }
414 bool needToDeterminePaintedContentState() const { return hasPaintedContent == RequestState::Unknown; }
415 bool needToDetermineSubpixelAntialiasedTextState() const { return hasSubpixelAntialiasedText == RequestState::Unknown; }
417 bool probablyHasPaintedContent() const { return hasPaintedContent == RequestState::True || hasPaintedContent == RequestState::Undetermined; }
418 bool probablyHasSubpixelAntialiasedText() const { return hasSubpixelAntialiasedText == RequestState::True || hasSubpixelAntialiasedText == RequestState::Undetermined; }
420 bool isSatisfied() const { return hasPaintedContent != RequestState::Unknown && hasSubpixelAntialiasedText != RequestState::Unknown; }
422 RequestState hasPaintedContent { RequestState::Unknown };
423 RequestState hasSubpixelAntialiasedText { RequestState::DontCare };
426 // Returns true if this layer has visible content (ignoring any child layers).
427 bool isVisuallyNonEmpty(PaintedContentRequest* = nullptr) const;
428 // True if this layer container renderers that paint.
429 bool hasNonEmptyChildRenderers(PaintedContentRequest&) const;
431 // FIXME: We should ASSERT(!m_hasSelfPaintingLayerDescendantDirty); here but we hit the same bugs as visible content above.
432 // Part of the issue is with subtree relayout: we don't check if our ancestors have some descendant flags dirty, missing some updates.
433 bool hasSelfPaintingLayerDescendant() const { return m_hasSelfPaintingLayerDescendant; }
435 // This returns true if we have an out of flow positioned descendant whose
436 // containing block is not a descendant of ours. If this is true, we cannot
437 // automatically opt into composited scrolling since this out of flow
438 // positioned descendant would become clipped by us, possibly altering the
439 // rendering of the page.
440 // FIXME: We should ASSERT(!m_hasOutOfFlowPositionedDescendantDirty); here but we may hit the same bugs as visible content above.
441 bool hasOutOfFlowPositionedDescendant() const { return m_hasOutOfFlowPositionedDescendant; }
443 // Gets the nearest enclosing positioned ancestor layer (also includes
444 // the <html> layer and the root layer).
445 RenderLayer* enclosingAncestorForPosition(EPosition) const;
447 // Returns the nearest enclosing layer that is scrollable.
448 RenderLayer* enclosingScrollableLayer() const;
450 // The layer relative to which clipping rects for this layer are computed.
451 RenderLayer* clippingRootForPainting() const;
453 RenderLayer* enclosingOverflowClipLayer(IncludeSelfOrNot) const;
455 // Enclosing compositing layer; if includeSelf is true, may return this.
456 RenderLayer* enclosingCompositingLayer(IncludeSelfOrNot = IncludeSelf) const;
457 RenderLayer* enclosingCompositingLayerForRepaint(IncludeSelfOrNot = IncludeSelf) const;
458 // Ancestor compositing layer, excluding this.
459 RenderLayer* ancestorCompositingLayer() const { return enclosingCompositingLayer(ExcludeSelf); }
461 RenderLayer* enclosingFilterLayer(IncludeSelfOrNot = IncludeSelf) const;
462 RenderLayer* enclosingFilterRepaintLayer() const;
463 void setFilterBackendNeedsRepaintingInRect(const LayoutRect&);
464 bool hasAncestorWithFilterOutsets() const;
466 bool canUseConvertToLayerCoords() const
468 // These RenderObject have an impact on their layers' without them knowing about it.
469 return !renderer().hasTransform() && !renderer().isSVGRoot();
472 // FIXME: adjustForColumns allows us to position compositing layers in columns correctly, but eventually they need to be split across columns too.
473 enum ColumnOffsetAdjustment { DontAdjustForColumns, AdjustForColumns };
474 void convertToPixelSnappedLayerCoords(const RenderLayer* ancestorLayer, IntPoint& location, ColumnOffsetAdjustment adjustForColumns = DontAdjustForColumns) const;
475 LayoutPoint convertToLayerCoords(const RenderLayer* ancestorLayer, const LayoutPoint&, ColumnOffsetAdjustment adjustForColumns = DontAdjustForColumns) const;
476 LayoutSize offsetFromAncestor(const RenderLayer*, ColumnOffsetAdjustment = DontAdjustForColumns) const;
478 int zIndex() const { return renderer().style().zIndex(); }
480 enum PaintLayerFlag {
481 PaintLayerHaveTransparency = 1 << 0,
482 PaintLayerAppliedTransform = 1 << 1,
483 PaintLayerTemporaryClipRects = 1 << 2,
484 PaintLayerPaintingReflection = 1 << 3,
485 PaintLayerPaintingOverlayScrollbars = 1 << 4,
486 PaintLayerPaintingCompositingBackgroundPhase = 1 << 5,
487 PaintLayerPaintingCompositingForegroundPhase = 1 << 6,
488 PaintLayerPaintingCompositingMaskPhase = 1 << 7,
489 PaintLayerPaintingCompositingClipPathPhase = 1 << 8,
490 PaintLayerPaintingCompositingScrollingPhase = 1 << 9,
491 PaintLayerPaintingOverflowContents = 1 << 10,
492 PaintLayerPaintingRootBackgroundOnly = 1 << 11,
493 PaintLayerPaintingSkipRootBackground = 1 << 12,
494 PaintLayerPaintingChildClippingMaskPhase = 1 << 13,
495 PaintLayerPaintingCompositingAllPhases = PaintLayerPaintingCompositingBackgroundPhase | PaintLayerPaintingCompositingForegroundPhase
498 typedef unsigned PaintLayerFlags;
500 enum class SecurityOriginPaintPolicy { AnyOrigin, AccessibleOriginOnly };
502 // The two main functions that use the layer system. The paint method
503 // paints the layers that intersect the damage rect from back to
504 // front. The hitTest method looks for mouse events by walking
505 // layers that intersect the point from front to back.
506 void paint(GraphicsContext&, const LayoutRect& damageRect, const LayoutSize& subpixelOffset = LayoutSize(), PaintBehavior = PaintBehaviorNormal,
507 RenderObject* subtreePaintRoot = nullptr, PaintLayerFlags = 0, SecurityOriginPaintPolicy = SecurityOriginPaintPolicy::AnyOrigin);
508 bool hitTest(const HitTestRequest&, HitTestResult&);
509 bool hitTest(const HitTestRequest&, const HitTestLocation&, HitTestResult&);
510 void paintOverlayScrollbars(GraphicsContext&, const LayoutRect& damageRect, PaintBehavior, RenderObject* subtreePaintRoot = nullptr);
512 struct ClipRectsContext {
513 ClipRectsContext(const RenderLayer* inRootLayer, ClipRectsType inClipRectsType, OverlayScrollbarSizeRelevancy inOverlayScrollbarSizeRelevancy = IgnoreOverlayScrollbarSize, ShouldRespectOverflowClip inRespectOverflowClip = RespectOverflowClip)
514 : rootLayer(inRootLayer)
515 , clipRectsType(inClipRectsType)
516 , overlayScrollbarSizeRelevancy(inOverlayScrollbarSizeRelevancy)
517 , respectOverflowClip(inRespectOverflowClip)
519 const RenderLayer* rootLayer;
520 ClipRectsType clipRectsType;
521 OverlayScrollbarSizeRelevancy overlayScrollbarSizeRelevancy;
522 ShouldRespectOverflowClip respectOverflowClip;
525 // This method figures out our layerBounds in coordinates relative to
526 // |rootLayer}. It also computes our background and foreground clip rects
527 // for painting/event handling.
528 // Pass offsetFromRoot if known.
529 void calculateRects(const ClipRectsContext&, const LayoutRect& paintDirtyRect, LayoutRect& layerBounds,
530 ClipRect& backgroundRect, ClipRect& foregroundRect, const LayoutSize& offsetFromRoot) const;
532 // Public just for RenderTreeAsText.
533 void collectFragments(LayerFragments&, const RenderLayer* rootLayer, const LayoutRect& dirtyRect,
534 PaginationInclusionMode,
535 ClipRectsType, OverlayScrollbarSizeRelevancy inOverlayScrollbarSizeRelevancy, ShouldRespectOverflowClip, const LayoutSize& offsetFromRoot,
536 const LayoutRect* layerBoundingBox = nullptr, ShouldApplyRootOffsetToFragments = IgnoreRootOffsetForFragments);
538 LayoutRect childrenClipRect() const; // Returns the foreground clip rect of the layer in the document's coordinate space.
539 LayoutRect selfClipRect() const; // Returns the background clip rect of the layer in the document's coordinate space.
540 LayoutRect localClipRect(bool& clipExceedsBounds) const; // Returns the background clip rect of the layer in the local coordinate space.
542 // Pass offsetFromRoot if known.
543 bool intersectsDamageRect(const LayoutRect& layerBounds, const LayoutRect& damageRect, const RenderLayer* rootLayer, const LayoutSize& offsetFromRoot, const LayoutRect* cachedBoundingBox = nullptr) const;
545 enum CalculateLayerBoundsFlag {
546 IncludeSelfTransform = 1 << 0,
547 UseLocalClipRectIfPossible = 1 << 1,
548 IncludeLayerFilterOutsets = 1 << 2,
549 ExcludeHiddenDescendants = 1 << 3,
550 DontConstrainForMask = 1 << 4,
551 IncludeCompositedDescendants = 1 << 5,
552 UseFragmentBoxesExcludingCompositing = 1 << 6,
553 UseFragmentBoxesIncludingCompositing = 1 << 7,
554 DefaultCalculateLayerBoundsFlags = IncludeSelfTransform | UseLocalClipRectIfPossible | IncludeLayerFilterOutsets | UseFragmentBoxesExcludingCompositing
556 typedef unsigned CalculateLayerBoundsFlags;
558 // Bounding box relative to some ancestor layer. Pass offsetFromRoot if known.
559 LayoutRect boundingBox(const RenderLayer* rootLayer, const LayoutSize& offsetFromRoot = LayoutSize(), CalculateLayerBoundsFlags = 0) const;
560 // Bounding box in the coordinates of this layer.
561 LayoutRect localBoundingBox(CalculateLayerBoundsFlags = 0) const;
562 // Deprecated: Pixel snapped bounding box relative to the root.
563 WEBCORE_EXPORT IntRect absoluteBoundingBox() const;
564 // Device pixel snapped bounding box relative to the root. absoluteBoundingBox() callers will be directed to this.
565 FloatRect absoluteBoundingBoxForPainting() const;
567 // Bounds used for layer overlap testing in RenderLayerCompositor.
568 LayoutRect overlapBounds() const { return overlapBoundsIncludeChildren() ? calculateLayerBounds(this, LayoutSize()) : localBoundingBox(); }
570 // Takes transform animations into account, returning true if they could be cheaply computed.
571 // Unlike overlapBounds, these bounds include descendant layers.
572 bool getOverlapBoundsIncludingChildrenAccountingForTransformAnimations(LayoutRect&) const;
574 // If true, this layer's children are included in its bounds for overlap testing.
575 // We can't rely on the children's positions if this layer has a filter that could have moved the children's pixels around.
576 bool overlapBoundsIncludeChildren() const { return hasFilter() && renderer().style().filter().hasFilterThatMovesPixels(); }
578 // Can pass offsetFromRoot if known.
579 LayoutRect calculateLayerBounds(const RenderLayer* ancestorLayer, const LayoutSize& offsetFromRoot, CalculateLayerBoundsFlags = DefaultCalculateLayerBoundsFlags) const;
581 // Return a cached repaint rect, computed relative to the layer renderer's containerForRepaint.
582 bool hasComputedRepaintRects() const { return renderer().hasRepaintLayoutRects(); }
583 LayoutRect repaintRectIncludingNonCompositingDescendants() const;
585 void setRepaintStatus(RepaintStatus status) { m_repaintStatus = status; }
586 RepaintStatus repaintStatus() const { return static_cast<RepaintStatus>(m_repaintStatus); }
588 LayoutUnit staticInlinePosition() const { return m_staticInlinePosition; }
589 LayoutUnit staticBlockPosition() const { return m_staticBlockPosition; }
591 void setStaticInlinePosition(LayoutUnit position) { m_staticInlinePosition = position; }
592 void setStaticBlockPosition(LayoutUnit position) { m_staticBlockPosition = position; }
595 bool adjustForIOSCaretWhenScrolling() const { return m_adjustForIOSCaretWhenScrolling; }
596 void setAdjustForIOSCaretWhenScrolling(bool adjustForIOSCaretWhenScrolling) { m_adjustForIOSCaretWhenScrolling = adjustForIOSCaretWhenScrolling; }
599 bool hasTransform() const { return renderer().hasTransform(); }
600 // Note that this transform has the transform-origin baked in.
601 TransformationMatrix* transform() const { return m_transform.get(); }
602 // currentTransform computes a transform which takes accelerated animations into account. The
603 // resulting transform has transform-origin baked in. If the layer does not have a transform,
604 // returns the identity matrix.
605 TransformationMatrix currentTransform(RenderStyle::ApplyTransformOrigin = RenderStyle::IncludeTransformOrigin) const;
606 TransformationMatrix renderableTransform(PaintBehavior) const;
608 // Get the perspective transform, which is applied to transformed sublayers.
609 // Returns true if the layer has a -webkit-perspective.
610 // Note that this transform has the perspective-origin baked in.
611 TransformationMatrix perspectiveTransform() const;
612 FloatPoint perspectiveOrigin() const;
613 bool preserves3D() const { return renderer().style().transformStyle3D() == TransformStyle3DPreserve3D; }
614 bool has3DTransform() const { return m_transform && !m_transform->isAffine(); }
616 void filterNeedsRepaint();
617 bool hasFilter() const { return renderer().hasFilter(); }
618 bool hasBackdropFilter() const
620 #if ENABLE(FILTERS_LEVEL_2)
621 return renderer().hasBackdropFilter();
627 #if ENABLE(CSS_COMPOSITING)
628 bool hasBlendMode() const { return renderer().hasBlendMode(); }
629 BlendMode blendMode() const { return static_cast<BlendMode>(m_blendMode); }
631 bool isolatesCompositedBlending() const { return m_hasNotIsolatedCompositedBlendingDescendants && isStackingContext(); }
632 bool hasNotIsolatedCompositedBlendingDescendants() const { return m_hasNotIsolatedCompositedBlendingDescendants; }
633 void setHasNotIsolatedCompositedBlendingDescendants(bool hasNotIsolatedCompositedBlendingDescendants)
635 m_hasNotIsolatedCompositedBlendingDescendants = hasNotIsolatedCompositedBlendingDescendants;
638 bool isolatesBlending() const { return hasNotIsolatedBlendingDescendants() && isStackingContext(); }
640 // FIXME: We should ASSERT(!m_hasNotIsolatedBlendingDescendantsStatusDirty); here but we hit the same bugs as visible content above.
641 bool hasNotIsolatedBlendingDescendants() const { return m_hasNotIsolatedBlendingDescendants; }
642 bool hasNotIsolatedBlendingDescendantsStatusDirty() const { return m_hasNotIsolatedBlendingDescendantsStatusDirty; }
644 bool hasBlendMode() const { return false; }
645 bool isolatesCompositedBlending() const { return false; }
646 bool isolatesBlending() const { return false; }
647 bool hasNotIsolatedBlendingDescendantsStatusDirty() const { return false; }
650 bool isComposited() const { return m_backing != 0; }
651 bool hasCompositingDescendant() const { return m_hasCompositingDescendant; }
652 bool hasCompositedMask() const;
653 RenderLayerBacking* backing() const { return m_backing.get(); }
654 RenderLayerBacking* ensureBacking();
655 void clearBacking(bool layerBeingDestroyed = false);
656 GraphicsLayer* layerForScrolling() const override;
657 GraphicsLayer* layerForHorizontalScrollbar() const override;
658 GraphicsLayer* layerForVerticalScrollbar() const override;
659 GraphicsLayer* layerForScrollCorner() const override;
660 bool usesCompositedScrolling() const override;
661 bool usesAsyncScrolling() const override;
662 WEBCORE_EXPORT bool needsCompositedScrolling() const;
664 bool paintsWithTransparency(PaintBehavior paintBehavior) const
666 return (isTransparent() || hasBlendMode() || (isolatesBlending() && !renderer().isDocumentElementRenderer())) && ((paintBehavior & PaintBehaviorFlattenCompositingLayers) || !isComposited());
669 bool paintsWithTransform(PaintBehavior) const;
670 bool shouldPaintMask(PaintBehavior, PaintLayerFlags) const;
671 bool shouldApplyClipPath(PaintBehavior, PaintLayerFlags) const;
673 // Returns true if background phase is painted opaque in the given rect.
674 // The query rect is given in local coordinates.
675 bool backgroundIsKnownToBeOpaqueInRect(const LayoutRect&) const;
677 bool scrollingMayRevealBackground() const;
679 bool containsDirtyOverlayScrollbars() const { return m_containsDirtyOverlayScrollbars; }
680 void setContainsDirtyOverlayScrollbars(bool dirtyScrollbars) { m_containsDirtyOverlayScrollbars = dirtyScrollbars; }
682 bool paintsWithFilters() const;
683 bool requiresFullLayerImageForFilters() const;
684 FilterEffectRenderer* filterRenderer() const;
687 bool layerListMutationAllowed() const { return m_layerListMutationAllowed; }
688 void setLayerListMutationAllowed(bool flag) { m_layerListMutationAllowed = flag; }
691 Element* enclosingElement() const;
693 enum ViewportConstrainedNotCompositedReason {
694 NoNotCompositedReason,
695 NotCompositedForBoundsOutOfView,
696 NotCompositedForNonViewContainer,
697 NotCompositedForNoVisibleContent,
700 void setViewportConstrainedNotCompositedReason(ViewportConstrainedNotCompositedReason reason) { m_viewportConstrainedNotCompositedReason = reason; }
701 ViewportConstrainedNotCompositedReason viewportConstrainedNotCompositedReason() const { return static_cast<ViewportConstrainedNotCompositedReason>(m_viewportConstrainedNotCompositedReason); }
703 bool isRenderFragmentedFlow() const { return renderer().isRenderFragmentedFlow(); }
704 bool isOutOfFlowRenderFragmentedFlow() const { return renderer().isOutOfFlowRenderFragmentedFlow(); }
705 bool isInsideFragmentedFlow() const { return renderer().fragmentedFlowState() != RenderObject::NotInsideFragmentedFlow; }
706 bool isDirtyRenderFragmentedFlow() const
708 ASSERT(isRenderFragmentedFlow());
709 return m_zOrderListsDirty || m_normalFlowListDirty;
712 RenderLayer* enclosingFragmentedFlowAncestor() const;
714 bool shouldPlaceBlockDirectionScrollbarOnLeft() const final { return renderer().shouldPlaceBlockDirectionScrollbarOnLeft(); }
716 WEBCORE_EXPORT void simulateFrequentPaint();
717 WEBCORE_EXPORT bool paintingFrequently() const;
718 void clearPaintFrequencyInfo();
721 enum CollectLayersBehavior { StopAtStackingContexts, StopAtStackingContainers };
723 struct LayerPaintingInfo {
724 LayerPaintingInfo(RenderLayer* inRootLayer, const LayoutRect& inDirtyRect, PaintBehavior inPaintBehavior, const LayoutSize& inSubpixelOffset, RenderObject* inSubtreePaintRoot = nullptr, OverlapTestRequestMap* inOverlapTestRequests = nullptr, bool inRequireSecurityOriginAccessForWidgets = false)
725 : rootLayer(inRootLayer)
726 , subtreePaintRoot(inSubtreePaintRoot)
727 , paintDirtyRect(inDirtyRect)
728 , subpixelOffset(inSubpixelOffset)
729 , overlapTestRequests(inOverlapTestRequests)
730 , paintBehavior(inPaintBehavior)
731 , requireSecurityOriginAccessForWidgets(inRequireSecurityOriginAccessForWidgets)
734 RenderLayer* rootLayer;
735 RenderObject* subtreePaintRoot; // Only paint descendants of this object.
736 LayoutRect paintDirtyRect; // Relative to rootLayer;
737 LayoutSize subpixelOffset;
738 OverlapTestRequestMap* overlapTestRequests; // May be null.
739 PaintBehavior paintBehavior;
740 bool requireSecurityOriginAccessForWidgets;
741 bool clipToDirtyRect { true };
744 // Compute, cache and return clip rects computed with the given layer as the root.
745 Ref<ClipRects> updateClipRects(const ClipRectsContext&);
746 // Compute and return the clip rects. If useCached is true, will used previously computed clip rects on ancestors
747 // (rather than computing them all from scratch up the parent chain).
748 void calculateClipRects(const ClipRectsContext&, ClipRects&) const;
749 ClipRects* clipRects(const ClipRectsContext&) const;
751 void updateZOrderLists();
752 void rebuildZOrderLists();
753 void rebuildZOrderLists(CollectLayersBehavior, std::unique_ptr<Vector<RenderLayer*>>&, std::unique_ptr<Vector<RenderLayer*>>&);
754 void clearZOrderLists();
756 void updateNormalFlowList();
758 // Non-auto z-index always implies stacking context here, because StyleResolver::adjustRenderStyle already adjusts z-index
759 // based on positioning and other criteria.
760 bool isStackingContext(const RenderStyle* style) const { return !style->hasAutoZIndex() || isRenderViewLayer() || m_forcedStackingContext; }
762 bool isDirtyStackingContainer() const { return m_zOrderListsDirty && isStackingContainer(); }
764 void setAncestorChainHasSelfPaintingLayerDescendant();
765 void dirtyAncestorChainHasSelfPaintingLayerDescendantStatus();
767 bool acceleratedCompositingForOverflowScrollEnabled() const;
768 void updateDescendantsAreContiguousInStackingOrder();
769 void updateDescendantsAreContiguousInStackingOrderRecursive(const HashMap<const RenderLayer*, int>&, int& minIndex, int& maxIndex, int& count, bool firstIteration);
771 void computeRepaintRects(const RenderLayerModelObject* repaintContainer, const RenderGeometryMap* = nullptr);
772 void computeRepaintRectsIncludingDescendants();
773 void clearRepaintRects();
775 LayoutRect clipRectRelativeToAncestor(RenderLayer* ancestor, LayoutSize offsetFromAncestor, const LayoutRect& constrainingRect) const;
777 void clipToRect(GraphicsContext&, const LayerPaintingInfo&, const ClipRect&, BorderRadiusClippingRule = IncludeSelfForBorderRadius);
778 void restoreClip(GraphicsContext&, const LayerPaintingInfo&, const ClipRect&);
780 bool shouldRepaintAfterLayout() const;
782 void updateSelfPaintingLayer();
783 void updateStackingContextsAfterStyleChange(const RenderStyle* oldStyle);
785 void updateScrollbarsAfterStyleChange(const RenderStyle* oldStyle);
786 void updateScrollbarsAfterLayout();
788 void setAncestorChainHasOutOfFlowPositionedDescendant(RenderBlock* containingBlock);
789 void dirtyAncestorChainHasOutOfFlowPositionedDescendantStatus();
790 void updateOutOfFlowPositioned(const RenderStyle* oldStyle);
792 void updateNeedsCompositedScrolling();
794 // Returns true if the position changed.
795 bool updateLayerPosition();
797 void updateLayerPositions(RenderGeometryMap* = nullptr, UpdateLayerPositionsFlags = defaultFlags);
799 enum UpdateLayerPositionsAfterScrollFlag {
801 IsOverflowScroll = 1 << 0,
802 HasSeenViewportConstrainedAncestor = 1 << 1,
803 HasSeenAncestorWithOverflowClip = 1 << 2,
804 HasChangedAncestor = 1 << 3
806 typedef unsigned UpdateLayerPositionsAfterScrollFlags;
807 void updateLayerPositionsAfterScroll(RenderGeometryMap*, UpdateLayerPositionsAfterScrollFlags = NoFlag);
809 ScrollOffset clampScrollOffset(const ScrollOffset&) const;
811 RenderLayer* enclosingPaginationLayerInSubtree(const RenderLayer* rootLayer, PaginationInclusionMode) const;
813 void setNextSibling(RenderLayer* next) { m_next = next; }
814 void setPreviousSibling(RenderLayer* prev) { m_previous = prev; }
815 void setParent(RenderLayer* parent);
816 void setFirstChild(RenderLayer* first) { m_first = first; }
817 void setLastChild(RenderLayer* last) { m_last = last; }
819 LayoutPoint renderBoxLocation() const { return is<RenderBox>(renderer()) ? downcast<RenderBox>(renderer()).location() : LayoutPoint(); }
821 void collectLayers(bool includeHiddenLayers, CollectLayersBehavior, std::unique_ptr<Vector<RenderLayer*>>&, std::unique_ptr<Vector<RenderLayer*>>&);
823 void updateCompositingAndLayerListsIfNeeded();
825 bool setupFontSubpixelQuantization(GraphicsContext&, bool& didQuantizeFonts);
827 Path computeClipPath(const LayoutSize& offsetFromRoot, LayoutRect& rootRelativeBounds, WindRule&) const;
829 bool setupClipPath(GraphicsContext&, const LayerPaintingInfo&, const LayoutSize& offsetFromRoot, LayoutRect& rootRelativeBounds, bool& rootRelativeBoundsComputed);
832 std::pair<FilterInfo*, std::unique_ptr<FilterEffectRendererHelper>> filterPainter(GraphicsContext&, PaintLayerFlags) const;
833 bool hasFilterThatIsPainting(GraphicsContext&, PaintLayerFlags) const;
834 std::unique_ptr<FilterEffectRendererHelper> setupFilters(GraphicsContext&, LayerPaintingInfo&, PaintLayerFlags, const LayoutSize& offsetFromRoot, LayoutRect& rootRelativeBounds, bool& rootRelativeBoundsComputed);
835 void applyFilters(FilterEffectRendererHelper*, GraphicsContext& originalContext, const LayerPaintingInfo&, const LayerFragments&);
837 void paintLayer(GraphicsContext&, const LayerPaintingInfo&, PaintLayerFlags);
838 void paintLayerContentsAndReflection(GraphicsContext&, const LayerPaintingInfo&, PaintLayerFlags);
839 void paintLayerByApplyingTransform(GraphicsContext&, const LayerPaintingInfo&, PaintLayerFlags, const LayoutSize& translationOffset = LayoutSize());
840 void paintLayerContents(GraphicsContext&, const LayerPaintingInfo&, PaintLayerFlags);
841 void paintList(Vector<RenderLayer*>*, GraphicsContext&, const LayerPaintingInfo&, PaintLayerFlags);
843 void updatePaintingInfoForFragments(LayerFragments&, const LayerPaintingInfo&, PaintLayerFlags, bool shouldPaintContent, const LayoutSize& offsetFromRoot);
844 void paintBackgroundForFragments(const LayerFragments&, GraphicsContext&, GraphicsContext& transparencyLayerContext,
845 const LayoutRect& transparencyPaintDirtyRect, bool haveTransparency, const LayerPaintingInfo&, PaintBehavior, RenderObject* paintingRootForRenderer);
846 void paintForegroundForFragments(const LayerFragments&, GraphicsContext&, GraphicsContext& transparencyLayerContext,
847 const LayoutRect& transparencyPaintDirtyRect, bool haveTransparency, const LayerPaintingInfo&, PaintBehavior, RenderObject* paintingRootForRenderer);
848 void paintForegroundForFragmentsWithPhase(PaintPhase, const LayerFragments&, GraphicsContext&, const LayerPaintingInfo&, PaintBehavior, RenderObject* paintingRootForRenderer);
849 void paintOutlineForFragments(const LayerFragments&, GraphicsContext&, const LayerPaintingInfo&, PaintBehavior, RenderObject* paintingRootForRenderer);
850 void paintOverflowControlsForFragments(const LayerFragments&, GraphicsContext&, const LayerPaintingInfo&);
851 void paintMaskForFragments(const LayerFragments&, GraphicsContext&, const LayerPaintingInfo&, PaintBehavior, RenderObject* paintingRootForRenderer);
852 void paintChildClippingMaskForFragments(const LayerFragments&, GraphicsContext&, const LayerPaintingInfo&, PaintBehavior, RenderObject* paintingRootForRenderer);
853 void paintTransformedLayerIntoFragments(GraphicsContext&, const LayerPaintingInfo&, PaintLayerFlags);
855 RenderLayer* transparentPaintingAncestor();
856 void beginTransparencyLayers(GraphicsContext&, const LayerPaintingInfo&, const LayoutRect& dirtyRect);
858 RenderLayer* hitTestLayer(RenderLayer* rootLayer, RenderLayer* containerLayer, const HitTestRequest& request, HitTestResult& result,
859 const LayoutRect& hitTestRect, const HitTestLocation&, bool appliedTransform,
860 const HitTestingTransformState* = nullptr, double* zOffset = nullptr);
861 RenderLayer* hitTestLayerByApplyingTransform(RenderLayer* rootLayer, RenderLayer* containerLayer, const HitTestRequest&, HitTestResult&,
862 const LayoutRect& hitTestRect, const HitTestLocation&, const HitTestingTransformState* = nullptr, double* zOffset = nullptr,
863 const LayoutSize& translationOffset = LayoutSize());
864 RenderLayer* hitTestList(Vector<RenderLayer*>*, RenderLayer* rootLayer, const HitTestRequest& request, HitTestResult& result,
865 const LayoutRect& hitTestRect, const HitTestLocation&,
866 const HitTestingTransformState*, double* zOffsetForDescendants, double* zOffset,
867 const HitTestingTransformState* unflattenedTransformState, bool depthSortDescendants);
869 Ref<HitTestingTransformState> createLocalTransformState(RenderLayer* rootLayer, RenderLayer* containerLayer,
870 const LayoutRect& hitTestRect, const HitTestLocation&,
871 const HitTestingTransformState* containerTransformState,
872 const LayoutSize& translationOffset = LayoutSize()) const;
874 bool hitTestContents(const HitTestRequest&, HitTestResult&, const LayoutRect& layerBounds, const HitTestLocation&, HitTestFilter) const;
875 bool hitTestContentsForFragments(const LayerFragments&, const HitTestRequest&, HitTestResult&, const HitTestLocation&, HitTestFilter, bool& insideClipRect) const;
876 bool hitTestResizerInFragments(const LayerFragments&, const HitTestLocation&) const;
877 RenderLayer* hitTestTransformedLayerInFragments(RenderLayer* rootLayer, RenderLayer* containerLayer, const HitTestRequest&, HitTestResult&,
878 const LayoutRect& hitTestRect, const HitTestLocation&, const HitTestingTransformState* = nullptr, double* zOffset = nullptr);
880 bool listBackgroundIsKnownToBeOpaqueInRect(const Vector<RenderLayer*>*, const LayoutRect&) const;
882 void computeScrollDimensions();
883 bool hasHorizontalOverflow() const;
884 bool hasVerticalOverflow() const;
885 bool hasScrollableHorizontalOverflow() const;
886 bool hasScrollableVerticalOverflow() const;
888 bool showsOverflowControls() const;
890 bool shouldBeNormalFlowOnly() const;
891 bool shouldBeSelfPaintingLayer() const;
893 int scrollOffset(ScrollbarOrientation) const override;
895 // ScrollableArea interface
896 void invalidateScrollbarRect(Scrollbar&, const IntRect&) override;
897 void invalidateScrollCornerRect(const IntRect&) override;
898 bool isActive() const override;
899 bool isScrollCornerVisible() const override;
900 IntRect scrollCornerRect() const override;
901 IntRect convertFromScrollbarToContainingView(const Scrollbar&, const IntRect&) const override;
902 IntRect convertFromContainingViewToScrollbar(const Scrollbar&, const IntRect&) const override;
903 IntPoint convertFromScrollbarToContainingView(const Scrollbar&, const IntPoint&) const override;
904 IntPoint convertFromContainingViewToScrollbar(const Scrollbar&, const IntPoint&) const override;
905 int scrollSize(ScrollbarOrientation) const override;
906 void setScrollOffset(const ScrollOffset&) override;
908 IntRect visibleContentRectInternal(VisibleContentRectIncludesScrollbars, VisibleContentRectBehavior) const override;
909 IntSize visibleSize() const override;
910 IntSize contentsSize() const override;
911 IntSize overhangAmount() const override;
912 IntPoint lastKnownMousePosition() const override;
913 bool isHandlingWheelEvent() const override;
914 bool shouldSuspendScrollAnimations() const override;
915 IntRect scrollableAreaBoundingBox(bool* isInsideFixed = nullptr) const override;
916 bool isRubberBandInProgress() const override;
917 bool forceUpdateScrollbarsOnMainThreadForPerformanceTesting() const override;
918 #if ENABLE(CSS_SCROLL_SNAP)
919 bool isScrollSnapInProgress() const override;
921 bool usesMockScrollAnimator() const override;
922 void logMockScrollAnimatorMessage(const String&) const override;
925 void registerAsTouchEventListenerForScrolling();
926 void unregisterAsTouchEventListenerForScrolling();
929 // Rectangle encompassing the scroll corner and resizer rect.
930 LayoutRect scrollCornerAndResizerRect() const;
932 // NOTE: This should only be called by the overriden setScrollOffset from ScrollableArea.
933 void scrollTo(const ScrollPosition&);
934 void updateCompositingLayersAfterScroll();
936 IntSize scrollbarOffset(const Scrollbar&) const;
938 void updateScrollableAreaSet(bool hasOverflow);
940 bool allowsCurrentScroll() const;
942 void dirtyAncestorChainVisibleDescendantStatus();
943 void setAncestorChainHasVisibleDescendant();
945 void updateDescendantDependentFlags(HashSet<const RenderObject*>* outOfFlowDescendantContainingBlocks = nullptr);
947 bool has3DTransformedDescendant() const { return m_has3DTransformedDescendant; }
949 bool hasTransformedAncestor() const { return m_hasTransformedAncestor; }
950 bool has3DTransformedAncestor() const { return m_has3DTransformedAncestor; }
952 void dirty3DTransformedDescendantStatus();
953 // Both updates the status, and returns true if descendants of this have 3d.
954 bool update3DTransformedDescendantStatus();
956 void createReflection();
957 void removeReflection();
959 RenderStyle createReflectionStyle();
960 bool paintingInsideReflection() const { return m_paintingInsideReflection; }
961 void setPaintingInsideReflection(bool b) { m_paintingInsideReflection = b; }
963 void updateOrRemoveFilterClients();
964 void updateOrRemoveFilterEffectRenderer();
966 #if ENABLE(CSS_COMPOSITING)
967 void updateAncestorChainHasBlendingDescendants();
968 void dirtyAncestorChainHasBlendingDescendants();
971 Ref<ClipRects> parentClipRects(const ClipRectsContext&) const;
972 ClipRect backgroundClipRect(const ClipRectsContext&) const;
974 RenderLayer* enclosingTransformedAncestor() const;
976 LayoutRect getRectToExpose(const LayoutRect& visibleRect, const LayoutRect& exposeRect, bool insideFixed, const ScrollAlignment& alignX, const ScrollAlignment& alignY) const;
978 // Convert a point in absolute coords into layer coords, taking transforms into account
979 LayoutPoint absoluteToContents(const LayoutPoint&) const;
981 void positionOverflowControls(const IntSize&);
982 void updateScrollCornerStyle();
983 void clearScrollCorner();
984 void updateResizerStyle();
987 void drawPlatformResizerImage(GraphicsContext&, const LayoutRect& resizerCornerRect);
989 void updatePagination();
991 void setHasCompositingDescendant(bool b) { m_hasCompositingDescendant = b; }
993 enum class IndirectCompositingReason {
998 GraphicalEffect, // opacity, mask, filter, transform etc.
1003 void setIndirectCompositingReason(IndirectCompositingReason reason) { m_indirectCompositingReason = static_cast<unsigned>(reason); }
1004 IndirectCompositingReason indirectCompositingReason() const { return static_cast<IndirectCompositingReason>(m_indirectCompositingReason); }
1005 bool mustCompositeForIndirectReasons() const { return m_indirectCompositingReason; }
1007 // Returns true if z ordering would not change if this layer were a stacking container.
1008 bool canBeStackingContainer() const;
1010 friend class RenderLayerBacking;
1011 friend class RenderLayerCompositor;
1012 friend class RenderLayerModelObject;
1014 LayoutUnit overflowTop() const;
1015 LayoutUnit overflowBottom() const;
1016 LayoutUnit overflowLeft() const;
1017 LayoutUnit overflowRight() const;
1019 IntRect rectForHorizontalScrollbar(const IntRect& borderBoxRect) const;
1020 IntRect rectForVerticalScrollbar(const IntRect& borderBoxRect) const;
1022 LayoutUnit verticalScrollbarStart(int minX, int maxX) const;
1023 LayoutUnit horizontalScrollbarStart(int minX) const;
1025 bool overflowControlsIntersectRect(const IntRect& localRect) const;
1027 // The bitfields are up here so they will fall into the padding from ScrollableArea on 64-bit.
1029 const bool m_isRenderViewLayer : 1;
1030 const bool m_forcedStackingContext : 1;
1032 // Keeps track of whether the layer is currently resizing, so events can cause resizing to start and stop.
1033 bool m_inResizeMode : 1;
1035 bool m_scrollDimensionsDirty : 1;
1036 bool m_zOrderListsDirty : 1;
1037 bool m_normalFlowListDirty: 1;
1038 bool m_isNormalFlowOnly : 1;
1040 bool m_isSelfPaintingLayer : 1;
1042 // If have no self-painting descendants, we don't have to walk our children during painting. This can lead to
1043 // significant savings, especially if the tree has lots of non-self-painting layers grouped together (e.g. table cells).
1044 bool m_hasSelfPaintingLayerDescendant : 1;
1045 bool m_hasSelfPaintingLayerDescendantDirty : 1;
1047 // If we have no out of flow positioned descendants and no non-descendant
1048 // appears between our descendants in stacking order, then we may become a
1049 // stacking context.
1050 bool m_hasOutOfFlowPositionedDescendant : 1;
1051 bool m_hasOutOfFlowPositionedDescendantDirty : 1;
1053 bool m_needsCompositedScrolling : 1;
1055 // If this is true, then no non-descendant appears between any of our
1056 // descendants in stacking order. This is one of the requirements of being
1057 // able to safely become a stacking context.
1058 bool m_descendantsAreContiguousInStackingOrder : 1;
1060 bool m_usedTransparency : 1; // Tracks whether we need to close a transparent layer, i.e., whether
1061 // we ended up painting this layer or any descendants (and therefore need to
1063 bool m_paintingInsideReflection : 1; // A state bit tracking if we are painting inside a replica.
1064 bool m_inOverflowRelayout : 1;
1065 unsigned m_repaintStatus : 2; // RepaintStatus
1067 bool m_visibleContentStatusDirty : 1;
1068 bool m_hasVisibleContent : 1;
1069 bool m_visibleDescendantStatusDirty : 1;
1070 bool m_hasVisibleDescendant : 1;
1071 bool m_registeredScrollableArea : 1;
1073 bool m_3DTransformedDescendantStatusDirty : 1;
1074 bool m_has3DTransformedDescendant : 1; // Set on a stacking context layer that has 3D descendants anywhere
1075 // in a preserves3D hierarchy. Hint to do 3D-aware hit testing.
1076 bool m_hasCompositingDescendant : 1; // In the z-order tree.
1078 bool m_hasTransformedAncestor : 1;
1079 bool m_has3DTransformedAncestor : 1;
1081 unsigned m_indirectCompositingReason : 3;
1082 unsigned m_viewportConstrainedNotCompositedReason : 2;
1085 bool m_adjustForIOSCaretWhenScrolling : 1;
1086 #if ENABLE(IOS_TOUCH_EVENTS)
1087 bool m_registeredAsTouchEventListenerForScrolling : 1;
1089 bool m_inUserScroll : 1;
1090 bool m_requiresScrollBoundsOriginUpdate : 1;
1093 bool m_containsDirtyOverlayScrollbars : 1;
1094 bool m_updatingMarqueePosition : 1;
1096 #if !ASSERT_DISABLED
1097 bool m_layerListMutationAllowed : 1;
1100 bool m_hasFilterInfo : 1;
1102 #if ENABLE(CSS_COMPOSITING)
1103 unsigned m_blendMode : 5;
1104 bool m_hasNotIsolatedCompositedBlendingDescendants : 1;
1105 bool m_hasNotIsolatedBlendingDescendants : 1;
1106 bool m_hasNotIsolatedBlendingDescendantsStatusDirty : 1;
1109 RenderLayerModelObject& m_renderer;
1111 RenderLayer* m_parent;
1112 RenderLayer* m_previous;
1113 RenderLayer* m_next;
1114 RenderLayer* m_first;
1115 RenderLayer* m_last;
1117 // Our current relative position offset.
1118 LayoutSize m_offsetForInFlowPosition;
1120 // Our (x,y) coordinates are in our parent layer's coordinate space.
1121 LayoutPoint m_topLeft;
1123 // The layer's width/height
1124 IntSize m_layerSize;
1126 ScrollPosition m_scrollPosition;
1127 std::optional<ScrollPosition> m_postLayoutScrollPosition;
1129 // The width/height of our scrolled area.
1130 IntSize m_scrollSize;
1132 // For layers with overflow, we have a pair of scrollbars.
1133 RefPtr<Scrollbar> m_hBar;
1134 RefPtr<Scrollbar> m_vBar;
1136 // For layers that establish stacking contexts, m_posZOrderList holds a sorted list of all the
1137 // descendant layers within the stacking context that have z-indices of 0 or greater
1138 // (auto will count as 0). m_negZOrderList holds descendants within our stacking context with negative
1140 std::unique_ptr<Vector<RenderLayer*>> m_posZOrderList;
1141 std::unique_ptr<Vector<RenderLayer*>> m_negZOrderList;
1143 // This list contains child layers that cannot create stacking contexts. For now it is just
1144 // overflow layers, but that may change in the future.
1145 std::unique_ptr<Vector<RenderLayer*>> m_normalFlowList;
1147 std::unique_ptr<ClipRectsCache> m_clipRectsCache;
1149 IntPoint m_cachedOverlayScrollbarOffset;
1151 std::unique_ptr<RenderMarquee> m_marquee; // Used for <marquee>.
1153 // Cached normal flow values for absolute positioned elements with static left/top values.
1154 LayoutUnit m_staticInlinePosition;
1155 LayoutUnit m_staticBlockPosition;
1157 std::unique_ptr<TransformationMatrix> m_transform;
1159 // May ultimately be extended to many replicas (with their own paint order).
1160 RenderPtr<RenderReplica> m_reflection;
1162 // Renderers to hold our custom scroll corner and resizer.
1163 RenderPtr<RenderScrollbarPart> m_scrollCorner;
1164 RenderPtr<RenderScrollbarPart> m_resizer;
1166 // Pointer to the enclosing RenderLayer that caused us to be paginated. It is 0 if we are not paginated.
1167 RenderLayer* m_enclosingPaginationLayer;
1169 IntRect m_blockSelectionGapsBounds;
1171 std::unique_ptr<RenderLayerBacking> m_backing;
1173 std::unique_ptr<PaintFrequencyInfo> m_paintFrequencyInfo;
1176 inline void RenderLayer::clearZOrderLists()
1178 ASSERT(!isStackingContainer());
1179 ASSERT(m_layerListMutationAllowed);
1181 m_posZOrderList = nullptr;
1182 m_negZOrderList = nullptr;
1185 inline void RenderLayer::updateZOrderLists()
1187 if (!m_zOrderListsDirty)
1190 if (!isStackingContainer()) {
1192 m_zOrderListsDirty = false;
1196 rebuildZOrderLists();
1199 #if !ASSERT_DISABLED
1200 class LayerListMutationDetector {
1202 LayerListMutationDetector(RenderLayer* layer)
1204 , m_previousMutationAllowedState(layer->layerListMutationAllowed())
1206 m_layer->setLayerListMutationAllowed(false);
1209 ~LayerListMutationDetector()
1211 m_layer->setLayerListMutationAllowed(m_previousMutationAllowedState);
1215 RenderLayer* m_layer;
1216 bool m_previousMutationAllowedState;
1220 void makeMatrixRenderable(TransformationMatrix&, bool has3DRendering);
1222 bool compositedWithOwnBackingStore(const RenderLayer&);
1224 WTF::TextStream& operator<<(WTF::TextStream&, const RenderLayer&);
1226 } // namespace WebCore
1228 #if ENABLE(TREE_DEBUGGING)
1229 // Outside the WebCore namespace for ease of invocation from lldb.
1230 void showLayerTree(const WebCore::RenderLayer*);
1231 void showLayerTree(const WebCore::RenderObject*);