2 * Copyright (C) 2003, 2009 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 "PaintInfo.h"
48 #include "RenderBox.h"
49 #include "ScrollBehavior.h"
50 #include "ScrollableArea.h"
51 #include <wtf/OwnPtr.h>
57 class HitTestingTransformState;
60 class RenderScrollbarPart;
64 class TransformationMatrix;
66 #if USE(ACCELERATED_COMPOSITING)
67 class RenderLayerBacking;
68 class RenderLayerCompositor;
79 ClipRects(const LayoutRect& r)
80 : m_overflowClipRect(r)
88 ClipRects(const ClipRects& other)
89 : m_overflowClipRect(other.overflowClipRect())
90 , m_fixedClipRect(other.fixedClipRect())
91 , m_posClipRect(other.posClipRect())
93 , m_fixed(other.fixed())
97 void reset(const LayoutRect& r)
99 m_overflowClipRect = r;
105 const LayoutRect& overflowClipRect() const { return m_overflowClipRect; }
106 void setOverflowClipRect(const LayoutRect& r) { m_overflowClipRect = r; }
108 const LayoutRect& fixedClipRect() const { return m_fixedClipRect; }
109 void setFixedClipRect(const LayoutRect&r) { m_fixedClipRect = r; }
111 const LayoutRect& posClipRect() const { return m_posClipRect; }
112 void setPosClipRect(const LayoutRect& r) { m_posClipRect = r; }
114 bool fixed() const { return m_fixed; }
115 void setFixed(bool fixed) { m_fixed = fixed; }
117 void ref() { m_refCnt++; }
118 void deref(RenderArena* renderArena) { if (--m_refCnt == 0) destroy(renderArena); }
120 void destroy(RenderArena*);
122 // Overloaded new operator.
123 void* operator new(size_t, RenderArena*) throw();
125 // Overridden to prevent the normal delete from being called.
126 void operator delete(void*, size_t);
128 bool operator==(const ClipRects& other) const
130 return m_overflowClipRect == other.overflowClipRect() &&
131 m_fixedClipRect == other.fixedClipRect() &&
132 m_posClipRect == other.posClipRect() &&
133 m_fixed == other.fixed();
136 ClipRects& operator=(const ClipRects& other)
138 m_overflowClipRect = other.overflowClipRect();
139 m_fixedClipRect = other.fixedClipRect();
140 m_posClipRect = other.posClipRect();
141 m_fixed = other.fixed();
146 // The normal operator new is disallowed on all render objects.
147 void* operator new(size_t) throw();
150 LayoutRect m_overflowClipRect;
151 LayoutRect m_fixedClipRect;
152 LayoutRect m_posClipRect;
153 unsigned m_refCnt : 31;
157 class RenderLayer : public ScrollableArea {
159 friend class RenderReplica;
161 RenderLayer(RenderBoxModelObject*);
164 RenderBoxModelObject* renderer() const { return m_renderer; }
165 RenderBox* renderBox() const { return m_renderer && m_renderer->isBox() ? toRenderBox(m_renderer) : 0; }
166 RenderLayer* parent() const { return m_parent; }
167 RenderLayer* previousSibling() const { return m_previous; }
168 RenderLayer* nextSibling() const { return m_next; }
169 RenderLayer* firstChild() const { return m_first; }
170 RenderLayer* lastChild() const { return m_last; }
172 void addChild(RenderLayer* newChild, RenderLayer* beforeChild = 0);
173 RenderLayer* removeChild(RenderLayer*);
175 void removeOnlyThisLayer();
176 void insertOnlyThisLayer();
178 void repaintIncludingDescendants();
180 #if USE(ACCELERATED_COMPOSITING)
181 // Indicate that the layer contents need to be repainted. Only has an effect
182 // if layer compositing is being used,
183 void setBackingNeedsRepaint();
184 void setBackingNeedsRepaintInRect(const LayoutRect&); // r is in the coordinate space of the layer's render object
185 void repaintIncludingNonCompositingDescendants(RenderBoxModelObject* repaintContainer);
188 void styleChanged(StyleDifference, const RenderStyle* oldStyle);
190 RenderMarquee* marquee() const { return m_marquee; }
192 bool isNormalFlowOnly() const { return m_isNormalFlowOnly; }
193 bool isSelfPaintingLayer() const;
195 bool cannotBlitToWindow() const;
197 bool isTransparent() const;
198 RenderLayer* transparentPaintingAncestor();
199 void beginTransparencyLayers(GraphicsContext*, const RenderLayer* rootLayer, PaintBehavior);
201 bool hasReflection() const { return renderer()->hasReflection(); }
202 bool isReflection() const { return renderer()->isReplica(); }
203 RenderReplica* reflection() const { return m_reflection; }
204 RenderLayer* reflectionLayer() const;
206 const RenderLayer* root() const
208 const RenderLayer* curr = this;
209 while (curr->parent())
210 curr = curr->parent();
214 const LayoutPoint& location() const { return m_topLeft; }
215 void setLocation(LayoutUnit x, LayoutUnit y) { m_topLeft = LayoutPoint(x, y); }
217 const LayoutSize& size() const { return m_layerSize; }
218 void setSize(const LayoutSize& size) { m_layerSize = size; }
220 LayoutRect rect() const { return LayoutRect(location(), size()); }
222 LayoutUnit scrollWidth();
223 LayoutUnit scrollHeight();
225 void panScrollFromPoint(const LayoutPoint&);
227 enum ScrollOffsetClamping {
228 ScrollOffsetUnclamped,
232 // Scrolling methods for layers that can scroll their overflow.
233 void scrollByRecursively(LayoutUnit xDelta, LayoutUnit yDelta, ScrollOffsetClamping = ScrollOffsetUnclamped);
235 LayoutSize scrolledContentOffset() const { return scrollOffset() + m_scrollOverflow; }
237 LayoutUnit scrollXOffset() const { return m_scrollOffset.width() + m_scrollOrigin.x(); }
238 LayoutUnit scrollYOffset() const { return m_scrollOffset.height() + m_scrollOrigin.y(); }
239 LayoutSize scrollOffset() const { return LayoutSize(scrollXOffset(), scrollYOffset()); }
241 void scrollToOffset(LayoutUnit, LayoutUnit, ScrollOffsetClamping = ScrollOffsetUnclamped);
242 void scrollToXOffset(LayoutUnit x, ScrollOffsetClamping clamp = ScrollOffsetUnclamped) { scrollToOffset(x, scrollYOffset(), clamp); }
243 void scrollToYOffset(LayoutUnit y, ScrollOffsetClamping clamp = ScrollOffsetUnclamped) { scrollToOffset(scrollXOffset(), y, clamp); }
245 void scrollRectToVisible(const LayoutRect&, const ScrollAlignment& alignX = ScrollAlignment::alignCenterIfNeeded, const ScrollAlignment& alignY = ScrollAlignment::alignCenterIfNeeded);
247 LayoutRect getRectToExpose(const LayoutRect& visibleRect, const LayoutRect& exposeRect, const ScrollAlignment& alignX, const ScrollAlignment& alignY);
249 bool scrollsOverflow() const;
250 bool allowsScrolling() const; // Returns true if at least one scrollbar is visible and enabled.
251 bool hasScrollbars() const { return m_hBar || m_vBar; }
252 virtual void didAddHorizontalScrollbar(Scrollbar*);
253 virtual void willRemoveHorizontalScrollbar(Scrollbar*);
254 void setHasHorizontalScrollbar(bool);
255 void setHasVerticalScrollbar(bool);
257 PassRefPtr<Scrollbar> createScrollbar(ScrollbarOrientation);
258 void destroyScrollbar(ScrollbarOrientation);
260 // ScrollableArea overrides
261 virtual Scrollbar* horizontalScrollbar() const { return m_hBar.get(); }
262 virtual Scrollbar* verticalScrollbar() const { return m_vBar.get(); }
263 virtual ScrollableArea* enclosingScrollableArea() const;
265 int verticalScrollbarWidth(OverlayScrollbarSizeRelevancy = IgnoreOverlayScrollbarSize) const;
266 int horizontalScrollbarHeight(OverlayScrollbarSizeRelevancy = IgnoreOverlayScrollbarSize) const;
268 bool hasOverflowControls() const;
269 bool isPointInResizeControl(const LayoutPoint& absolutePoint) const;
270 bool hitTestOverflowControls(HitTestResult&, const LayoutPoint& localPoint);
271 LayoutSize offsetFromResizeCorner(const LayoutPoint& absolutePoint) const;
273 void paintOverflowControls(GraphicsContext*, const LayoutPoint&, const LayoutRect& damageRect, bool paintingOverlayControls = false);
274 void paintScrollCorner(GraphicsContext*, const LayoutPoint&, const LayoutRect& damageRect);
275 void paintResizer(GraphicsContext*, const LayoutPoint&, const LayoutRect& damageRect);
277 void updateScrollInfoAfterLayout();
279 bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1);
282 void resize(const PlatformMouseEvent&, const LayoutSize&);
283 bool inResizeMode() const { return m_inResizeMode; }
284 void setInResizeMode(bool b) { m_inResizeMode = b; }
286 bool isRootLayer() const { return renderer()->isRenderView(); }
288 #if USE(ACCELERATED_COMPOSITING)
289 RenderLayerCompositor* compositor() const;
291 // Notification from the renderer that its content changed (e.g. current frame of image changed).
292 // Allows updates of layer content without repainting.
293 enum ContentChangeType { ImageChanged, MaskImageChanged, CanvasChanged, VideoChanged, FullScreenChanged };
294 void contentChanged(ContentChangeType);
297 // Returns true if the accelerated compositing is enabled
298 bool hasAcceleratedCompositing() const;
300 bool canRender3DTransforms() const;
302 void updateLayerPosition();
304 enum UpdateLayerPositionsFlag {
306 IsCompositingUpdateRoot = 1 << 1,
307 UpdateCompositingLayers = 1 << 2,
308 UpdatePagination = 1 << 3
310 typedef unsigned UpdateLayerPositionsFlags;
311 static const UpdateLayerPositionsFlags defaultFlags = CheckForRepaint | IsCompositingUpdateRoot | UpdateCompositingLayers;
312 // Providing |cachedOffset| prevents a outlineBoxForRepaint from walking back to the root for each layer in our subtree.
313 // This is an optimistic optimization that is not guaranteed to succeed.
314 void updateLayerPositions(LayoutPoint* offsetFromRoot, UpdateLayerPositionsFlags = defaultFlags);
316 void updateTransform();
318 void relativePositionOffset(LayoutUnit& relX, LayoutUnit& relY) const { relX += m_relativeOffset.width(); relY += m_relativeOffset.height(); }
319 const LayoutSize& relativePositionOffset() const { return m_relativeOffset; }
321 void clearClipRectsIncludingDescendants();
322 void clearClipRects();
324 void addBlockSelectionGapsBounds(const LayoutRect&);
325 void clearBlockSelectionGapsBounds();
326 void repaintBlockSelectionGaps();
328 // Get the enclosing stacking context for this layer. A stacking context is a layer
329 // that has a non-auto z-index.
330 RenderLayer* stackingContext() const;
331 bool isStackingContext() const { return !hasAutoZIndex() || renderer()->isRenderView(); }
333 void dirtyZOrderLists();
334 void dirtyStackingContextZOrderLists();
335 void updateZOrderLists();
336 Vector<RenderLayer*>* posZOrderList() const { return m_posZOrderList; }
337 Vector<RenderLayer*>* negZOrderList() const { return m_negZOrderList; }
339 void dirtyNormalFlowList();
340 void updateNormalFlowList();
341 Vector<RenderLayer*>* normalFlowList() const { return m_normalFlowList; }
343 bool hasVisibleContent() const { return m_hasVisibleContent; }
344 bool hasVisibleDescendant() const { return m_hasVisibleDescendant; }
345 void setHasVisibleContent(bool);
346 void dirtyVisibleContentStatus();
348 // Gets the nearest enclosing positioned ancestor layer (also includes
349 // the <html> layer and the root layer).
350 RenderLayer* enclosingPositionedAncestor() const;
352 // Returns the nearest enclosing layer that is scrollable.
353 RenderLayer* enclosingScrollableLayer() const;
355 // The layer relative to which clipping rects for this layer are computed.
356 RenderLayer* clippingRoot() const;
358 #if USE(ACCELERATED_COMPOSITING)
359 // Enclosing compositing layer; if includeSelf is true, may return this.
360 RenderLayer* enclosingCompositingLayer(bool includeSelf = true) const;
361 // Ancestor compositing layer, excluding this.
362 RenderLayer* ancestorCompositingLayer() const { return enclosingCompositingLayer(false); }
365 void convertToLayerCoords(const RenderLayer* ancestorLayer, LayoutPoint& location) const;
366 void convertToLayerCoords(const RenderLayer* ancestorLayer, LayoutRect&) const;
368 bool hasAutoZIndex() const { return renderer()->style()->hasAutoZIndex(); }
369 int zIndex() const { return renderer()->style()->zIndex(); }
371 // The two main functions that use the layer system. The paint method
372 // paints the layers that intersect the damage rect from back to
373 // front. The hitTest method looks for mouse events by walking
374 // layers that intersect the point from front to back.
375 void paint(GraphicsContext*, const LayoutRect& damageRect, PaintBehavior = PaintBehaviorNormal, RenderObject* paintingRoot = 0);
376 bool hitTest(const HitTestRequest&, HitTestResult&);
377 void paintOverlayScrollbars(GraphicsContext*, const LayoutRect& damageRect, PaintBehavior, RenderObject* paintingRoot);
379 // This method figures out our layerBounds in coordinates relative to
380 // |rootLayer}. It also computes our background and foreground clip rects
381 // for painting/event handling.
382 void calculateRects(const RenderLayer* rootLayer, const LayoutRect& paintDirtyRect, LayoutRect& layerBounds,
383 LayoutRect& backgroundRect, LayoutRect& foregroundRect, LayoutRect& outlineRect, bool temporaryClipRects = false,
384 OverlayScrollbarSizeRelevancy = IgnoreOverlayScrollbarSize) const;
386 // Compute and cache clip rects computed with the given layer as the root
387 void updateClipRects(const RenderLayer* rootLayer, OverlayScrollbarSizeRelevancy = IgnoreOverlayScrollbarSize);
388 // Compute and return the clip rects. If useCached is true, will used previously computed clip rects on ancestors
389 // (rather than computing them all from scratch up the parent chain).
390 void calculateClipRects(const RenderLayer* rootLayer, ClipRects&, bool useCached = false, OverlayScrollbarSizeRelevancy = IgnoreOverlayScrollbarSize) const;
391 ClipRects* clipRects() const { return m_clipRects; }
393 LayoutRect childrenClipRect() const; // Returns the foreground clip rect of the layer in the document's coordinate space.
394 LayoutRect selfClipRect() const; // Returns the background clip rect of the layer in the document's coordinate space.
396 bool intersectsDamageRect(const LayoutRect& layerBounds, const LayoutRect& damageRect, const RenderLayer* rootLayer) const;
398 // Bounding box relative to some ancestor layer.
399 LayoutRect boundingBox(const RenderLayer* rootLayer) const;
400 // Bounding box in the coordinates of this layer.
401 LayoutRect localBoundingBox() const;
402 // Bounding box relative to the root.
403 LayoutRect absoluteBoundingBox() const;
405 void updateHoverActiveState(const HitTestRequest&, HitTestResult&);
407 // WARNING: This method returns the offset for the parent as this is what updateLayerPositions expects.
408 LayoutPoint computeOffsetFromRoot(bool& hasLayerOffset) const;
410 // Return a cached repaint rect, computed relative to the layer renderer's containerForRepaint.
411 LayoutRect repaintRect() const { return m_repaintRect; }
412 LayoutRect repaintRectIncludingDescendants() const;
413 void updateLayerPositionsAfterScroll(bool fixed = false);
414 void setNeedsFullRepaint(bool f = true) { m_needsFullRepaint = f; }
416 int staticInlinePosition() const { return m_staticInlinePosition; }
417 int staticBlockPosition() const { return m_staticBlockPosition; }
418 void setStaticInlinePosition(int position) { m_staticInlinePosition = position; }
419 void setStaticBlockPosition(int position) { m_staticBlockPosition = position; }
421 bool hasTransform() const { return renderer()->hasTransform(); }
422 // Note that this transform has the transform-origin baked in.
423 TransformationMatrix* transform() const { return m_transform.get(); }
424 // currentTransform computes a transform which takes accelerated animations into account. The
425 // resulting transform has transform-origin baked in. If the layer does not have a transform,
426 // returns the identity matrix.
427 TransformationMatrix currentTransform() const;
428 TransformationMatrix renderableTransform(PaintBehavior) const;
430 // Get the perspective transform, which is applied to transformed sublayers.
431 // Returns true if the layer has a -webkit-perspective.
432 // Note that this transform has the perspective-origin baked in.
433 TransformationMatrix perspectiveTransform() const;
434 FloatPoint perspectiveOrigin() const;
435 bool preserves3D() const { return renderer()->style()->transformStyle3D() == TransformStyle3DPreserve3D; }
436 bool has3DTransform() const { return m_transform && !m_transform->isAffine(); }
438 // Overloaded new operator. Derived classes must override operator new
439 // in order to allocate out of the RenderArena.
440 void* operator new(size_t, RenderArena*) throw();
442 // Overridden to prevent the normal delete from being called.
443 void operator delete(void*, size_t);
445 #if USE(ACCELERATED_COMPOSITING)
446 bool isComposited() const { return m_backing != 0; }
447 bool hasCompositedMask() const;
448 RenderLayerBacking* backing() const { return m_backing.get(); }
449 RenderLayerBacking* ensureBacking();
451 virtual GraphicsLayer* layerForHorizontalScrollbar() const;
452 virtual GraphicsLayer* layerForVerticalScrollbar() const;
453 virtual GraphicsLayer* layerForScrollCorner() const;
455 bool isComposited() const { return false; }
456 bool hasCompositedMask() const { return false; }
459 bool paintsWithTransparency(PaintBehavior paintBehavior) const
461 return isTransparent() && ((paintBehavior & PaintBehaviorFlattenCompositingLayers) || !isComposited());
464 bool paintsWithTransform(PaintBehavior) const;
466 bool containsDirtyOverlayScrollbars() const { return m_containsDirtyOverlayScrollbars; }
467 void setContainsDirtyOverlayScrollbars(bool dirtyScrollbars) { m_containsDirtyOverlayScrollbars = dirtyScrollbars; }
470 void computeRepaintRects(IntPoint* offsetFromRoot = 0);
471 void clearRepaintRects();
473 // The normal operator new is disallowed on all render objects.
474 void* operator new(size_t) throw();
476 void setNextSibling(RenderLayer* next) { m_next = next; }
477 void setPreviousSibling(RenderLayer* prev) { m_previous = prev; }
478 void setParent(RenderLayer* parent);
479 void setFirstChild(RenderLayer* first) { m_first = first; }
480 void setLastChild(RenderLayer* last) { m_last = last; }
482 LayoutPoint renderBoxLocation() const { return renderer()->isBox() ? toRenderBox(renderer())->location() : LayoutPoint(); }
483 LayoutUnit renderBoxX() const { return renderBoxLocation().x(); }
484 LayoutUnit renderBoxY() const { return renderBoxLocation().y(); }
486 void collectLayers(Vector<RenderLayer*>*&, Vector<RenderLayer*>*&);
488 void updateLayerListsIfNeeded();
489 void updateCompositingAndLayerListsIfNeeded();
491 enum PaintLayerFlag {
492 PaintLayerHaveTransparency = 1,
493 PaintLayerAppliedTransform = 1 << 1,
494 PaintLayerTemporaryClipRects = 1 << 2,
495 PaintLayerPaintingReflection = 1 << 3,
496 PaintLayerPaintingOverlayScrollbars = 1 << 4
499 typedef unsigned PaintLayerFlags;
501 void paintLayer(RenderLayer* rootLayer, GraphicsContext*, const LayoutRect& paintDirtyRect,
502 PaintBehavior, RenderObject* paintingRoot, OverlapTestRequestMap* = 0,
503 PaintLayerFlags = 0);
504 void paintList(Vector<RenderLayer*>*, RenderLayer* rootLayer, GraphicsContext* p,
505 const LayoutRect& paintDirtyRect, PaintBehavior,
506 RenderObject* paintingRoot, OverlapTestRequestMap*,
508 void paintPaginatedChildLayer(RenderLayer* childLayer, RenderLayer* rootLayer, GraphicsContext*,
509 const LayoutRect& paintDirtyRect, PaintBehavior,
510 RenderObject* paintingRoot, OverlapTestRequestMap*,
512 void paintChildLayerIntoColumns(RenderLayer* childLayer, RenderLayer* rootLayer, GraphicsContext*,
513 const LayoutRect& paintDirtyRect, PaintBehavior,
514 RenderObject* paintingRoot, OverlapTestRequestMap*,
515 PaintLayerFlags, const Vector<RenderLayer*>& columnLayers, size_t columnIndex);
517 RenderLayer* hitTestLayer(RenderLayer* rootLayer, RenderLayer* containerLayer, const HitTestRequest& request, HitTestResult& result,
518 const LayoutRect& hitTestRect, const LayoutPoint& hitTestPoint, bool appliedTransform,
519 const HitTestingTransformState* transformState = 0, double* zOffset = 0);
520 RenderLayer* hitTestList(Vector<RenderLayer*>*, RenderLayer* rootLayer, const HitTestRequest& request, HitTestResult& result,
521 const LayoutRect& hitTestRect, const LayoutPoint& hitTestPoint,
522 const HitTestingTransformState* transformState, double* zOffsetForDescendants, double* zOffset,
523 const HitTestingTransformState* unflattenedTransformState, bool depthSortDescendants);
524 RenderLayer* hitTestPaginatedChildLayer(RenderLayer* childLayer, RenderLayer* rootLayer, const HitTestRequest& request, HitTestResult& result,
525 const LayoutRect& hitTestRect, const LayoutPoint& hitTestPoint,
526 const HitTestingTransformState* transformState, double* zOffset);
527 RenderLayer* hitTestChildLayerColumns(RenderLayer* childLayer, RenderLayer* rootLayer, const HitTestRequest& request, HitTestResult& result,
528 const LayoutRect& hitTestRect, const LayoutPoint& hitTestPoint,
529 const HitTestingTransformState* transformState, double* zOffset,
530 const Vector<RenderLayer*>& columnLayers, size_t columnIndex);
532 PassRefPtr<HitTestingTransformState> createLocalTransformState(RenderLayer* rootLayer, RenderLayer* containerLayer,
533 const LayoutRect& hitTestRect, const LayoutPoint& hitTestPoint,
534 const HitTestingTransformState* containerTransformState) const;
536 bool hitTestContents(const HitTestRequest&, HitTestResult&, const LayoutRect& layerBounds, const LayoutPoint& hitTestPoint, HitTestFilter) const;
538 void computeScrollDimensions(bool* needHBar = 0, bool* needVBar = 0);
540 bool shouldBeNormalFlowOnly() const;
542 LayoutUnit scrollPosition(Scrollbar*) const;
544 // ScrollableArea interface
545 virtual void invalidateScrollbarRect(Scrollbar*, const LayoutRect&);
546 virtual void invalidateScrollCornerRect(const LayoutRect&);
547 virtual bool isActive() const;
548 virtual bool isScrollCornerVisible() const;
549 virtual LayoutRect scrollCornerRect() const;
550 virtual LayoutRect convertFromScrollbarToContainingView(const Scrollbar*, const LayoutRect&) const;
551 virtual LayoutRect convertFromContainingViewToScrollbar(const Scrollbar*, const LayoutRect&) const;
552 virtual LayoutPoint convertFromScrollbarToContainingView(const Scrollbar*, const LayoutPoint&) const;
553 virtual LayoutPoint convertFromContainingViewToScrollbar(const Scrollbar*, const LayoutPoint&) const;
554 virtual LayoutUnit scrollSize(ScrollbarOrientation) const;
555 virtual void setScrollOffset(const LayoutPoint&);
556 virtual LayoutPoint scrollPosition() const;
557 virtual LayoutPoint minimumScrollPosition() const;
558 virtual LayoutPoint maximumScrollPosition() const;
559 virtual LayoutRect visibleContentRect(bool includeScrollbars) const;
560 virtual LayoutUnit visibleHeight() const;
561 virtual LayoutUnit visibleWidth() const;
562 virtual LayoutSize contentsSize() const;
563 virtual LayoutSize overhangAmount() const;
564 virtual LayoutPoint currentMousePosition() const;
565 virtual void didCompleteRubberBand(const LayoutSize&) const;
566 virtual bool shouldSuspendScrollAnimations() const;
567 virtual bool isOnActivePage() const;
569 // Rectangle encompassing the scroll corner and resizer rect.
570 LayoutRect scrollCornerAndResizerRect() const;
572 virtual void disconnectFromPage() { m_scrollableAreaPage = 0; }
574 // NOTE: This should only be called by the overriden setScrollOffset from ScrollableArea.
575 void scrollTo(LayoutUnit, LayoutUnit);
577 LayoutSize scrollbarOffset(const Scrollbar*) const;
579 void updateOverflowStatus(bool horizontalOverflow, bool verticalOverflow);
581 void childVisibilityChanged(bool newVisibility);
582 void dirtyVisibleDescendantStatus();
583 void updateVisibilityStatus();
585 // This flag is computed by RenderLayerCompositor, which knows more about 3d hierarchies than we do.
586 void setHas3DTransformedDescendant(bool b) { m_has3DTransformedDescendant = b; }
587 bool has3DTransformedDescendant() const { return m_has3DTransformedDescendant; }
589 void dirty3DTransformedDescendantStatus();
590 // Both updates the status, and returns true if descendants of this have 3d.
591 bool update3DTransformedDescendantStatus();
593 Node* enclosingElement() const;
595 void createReflection();
596 void removeReflection();
598 void updateReflectionStyle();
599 bool paintingInsideReflection() const { return m_paintingInsideReflection; }
600 void setPaintingInsideReflection(bool b) { m_paintingInsideReflection = b; }
602 void parentClipRects(const RenderLayer* rootLayer, ClipRects&, bool temporaryClipRects = false, OverlayScrollbarSizeRelevancy = IgnoreOverlayScrollbarSize) const;
603 LayoutRect backgroundClipRect(const RenderLayer* rootLayer, bool temporaryClipRects, OverlayScrollbarSizeRelevancy = IgnoreOverlayScrollbarSize) const;
605 RenderLayer* enclosingTransformedAncestor() const;
607 // Convert a point in absolute coords into layer coords, taking transforms into account
608 LayoutPoint absoluteToContents(const LayoutPoint&) const;
610 void positionOverflowControls(const LayoutSize&);
611 void updateScrollCornerStyle();
612 void updateResizerStyle();
614 void drawPlatformResizerImage(GraphicsContext*, LayoutRect resizerCornerRect);
616 void updatePagination();
617 bool isPaginated() const { return m_isPaginated; }
619 #if USE(ACCELERATED_COMPOSITING)
620 bool hasCompositingDescendant() const { return m_hasCompositingDescendant; }
621 void setHasCompositingDescendant(bool b) { m_hasCompositingDescendant = b; }
623 bool mustOverlapCompositedLayers() const { return m_mustOverlapCompositedLayers; }
624 void setMustOverlapCompositedLayers(bool b) { m_mustOverlapCompositedLayers = b; }
627 friend class RenderLayerBacking;
628 friend class RenderLayerCompositor;
629 friend class RenderBoxModelObject;
631 // Only safe to call from RenderBoxModelObject::destroyLayer(RenderArena*)
632 void destroy(RenderArena*);
634 LayoutUnit overflowTop() const;
635 LayoutUnit overflowBottom() const;
636 LayoutUnit overflowLeft() const;
637 LayoutUnit overflowRight() const;
639 bool canUseConvertToLayerCoords() const
641 // These RenderObject have an impact on their layers' without them knowing about it.
642 return !renderer()->hasColumns() && !renderer()->hasTransform() && !isComposited()
644 && !renderer()->isSVGRoot()
650 RenderBoxModelObject* m_renderer;
652 RenderLayer* m_parent;
653 RenderLayer* m_previous;
655 RenderLayer* m_first;
658 LayoutRect m_repaintRect; // Cached repaint rects. Used by layout.
659 LayoutRect m_outlineBox;
661 // Our current relative position offset.
662 LayoutSize m_relativeOffset;
664 // Our (x,y) coordinates are in our parent layer's coordinate space.
665 LayoutPoint m_topLeft;
667 // The layer's width/height
668 LayoutSize m_layerSize;
670 // Our scroll offsets if the view is scrolled.
671 LayoutSize m_scrollOffset;
673 LayoutSize m_scrollOverflow;
675 // The width/height of our scrolled area.
676 LayoutSize m_scrollSize;
678 // For layers with overflow, we have a pair of scrollbars.
679 RefPtr<Scrollbar> m_hBar;
680 RefPtr<Scrollbar> m_vBar;
682 // For layers that establish stacking contexts, m_posZOrderList holds a sorted list of all the
683 // descendant layers within the stacking context that have z-indices of 0 or greater
684 // (auto will count as 0). m_negZOrderList holds descendants within our stacking context with negative
686 Vector<RenderLayer*>* m_posZOrderList;
687 Vector<RenderLayer*>* m_negZOrderList;
689 // This list contains child layers that cannot create stacking contexts. For now it is just
690 // overflow layers, but that may change in the future.
691 Vector<RenderLayer*>* m_normalFlowList;
693 ClipRects* m_clipRects; // Cached clip rects used when painting and hit testing.
695 const RenderLayer* m_clipRectsRoot; // Root layer used to compute clip rects.
698 // Keeps track of whether the layer is currently resizing, so events can cause resizing to start and stop.
699 bool m_inResizeMode : 1;
701 bool m_scrollDimensionsDirty : 1;
702 bool m_zOrderListsDirty : 1;
703 bool m_normalFlowListDirty: 1;
704 bool m_isNormalFlowOnly : 1;
706 bool m_usedTransparency : 1; // Tracks whether we need to close a transparent layer, i.e., whether
707 // we ended up painting this layer or any descendants (and therefore need to
709 bool m_paintingInsideReflection : 1; // A state bit tracking if we are painting inside a replica.
710 bool m_inOverflowRelayout : 1;
711 bool m_needsFullRepaint : 1;
713 bool m_overflowStatusDirty : 1;
714 bool m_horizontalOverflow : 1;
715 bool m_verticalOverflow : 1;
716 bool m_visibleContentStatusDirty : 1;
717 bool m_hasVisibleContent : 1;
718 bool m_visibleDescendantStatusDirty : 1;
719 bool m_hasVisibleDescendant : 1;
721 bool m_isPaginated : 1; // If we think this layer is split by a multi-column ancestor, then this bit will be set.
723 bool m_3DTransformedDescendantStatusDirty : 1;
724 bool m_has3DTransformedDescendant : 1; // Set on a stacking context layer that has 3D descendants anywhere
725 // in a preserves3D hierarchy. Hint to do 3D-aware hit testing.
726 #if USE(ACCELERATED_COMPOSITING)
727 bool m_hasCompositingDescendant : 1; // In the z-order tree.
728 bool m_mustOverlapCompositedLayers : 1;
731 bool m_containsDirtyOverlayScrollbars : 1;
733 LayoutPoint m_cachedOverlayScrollbarOffset;
735 RenderMarquee* m_marquee; // Used by layers with overflow:marquee
737 // Cached normal flow values for absolute positioned elements with static left/top values.
738 int m_staticInlinePosition;
739 int m_staticBlockPosition;
741 OwnPtr<TransformationMatrix> m_transform;
743 // May ultimately be extended to many replicas (with their own paint order).
744 RenderReplica* m_reflection;
746 // Renderers to hold our custom scroll corner and resizer.
747 RenderScrollbarPart* m_scrollCorner;
748 RenderScrollbarPart* m_resizer;
751 LayoutRect m_blockSelectionGapsBounds;
753 #if USE(ACCELERATED_COMPOSITING)
754 OwnPtr<RenderLayerBacking> m_backing;
757 Page* m_scrollableAreaPage; // Page on which this is registered as a scrollable area.
760 } // namespace WebCore
763 // Outside the WebCore namespace for ease of invocation from gdb.
764 void showLayerTree(const WebCore::RenderLayer*);
765 void showLayerTree(const WebCore::RenderObject*);
768 #endif // RenderLayer_h