• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2003, 2009 Apple Inc. All rights reserved.
3  *
4  * Portions are Copyright (C) 1998 Netscape Communications Corporation.
5  *
6  * Other contributors:
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>
14  *
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.
19  *
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.
24  *
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
28  *
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.
42  */
43 
44 #ifndef RenderLayer_h
45 #define RenderLayer_h
46 
47 #include "RenderBox.h"
48 #include "ScrollBehavior.h"
49 #include "ScrollbarClient.h"
50 #include "Timer.h"
51 #include <wtf/OwnPtr.h>
52 
53 namespace WebCore {
54 
55 class CachedResource;
56 class HitTestRequest;
57 class HitTestResult;
58 class HitTestingTransformState;
59 class RenderFrameSet;
60 class RenderMarquee;
61 class RenderReplica;
62 class RenderScrollbarPart;
63 class RenderStyle;
64 class RenderTable;
65 class RenderText;
66 class RenderView;
67 class Scrollbar;
68 class TransformationMatrix;
69 
70 #if USE(ACCELERATED_COMPOSITING)
71 class RenderLayerBacking;
72 class RenderLayerCompositor;
73 #endif
74 
75 class ClipRects {
76 public:
ClipRects()77     ClipRects()
78         : m_refCnt(0)
79         , m_fixed(false)
80     {
81     }
82 
ClipRects(const IntRect & r)83     ClipRects(const IntRect& r)
84         : m_overflowClipRect(r)
85         , m_fixedClipRect(r)
86         , m_posClipRect(r)
87         , m_refCnt(0)
88         , m_fixed(false)
89     {
90     }
91 
ClipRects(const ClipRects & other)92     ClipRects(const ClipRects& other)
93         : m_overflowClipRect(other.overflowClipRect())
94         , m_fixedClipRect(other.fixedClipRect())
95         , m_posClipRect(other.posClipRect())
96         , m_refCnt(0)
97         , m_fixed(other.fixed())
98     {
99     }
100 
reset(const IntRect & r)101     void reset(const IntRect& r)
102     {
103         m_overflowClipRect = r;
104         m_fixedClipRect = r;
105         m_posClipRect = r;
106         m_fixed = false;
107     }
108 
overflowClipRect()109     const IntRect& overflowClipRect() const { return m_overflowClipRect; }
setOverflowClipRect(const IntRect & r)110     void setOverflowClipRect(const IntRect& r) { m_overflowClipRect = r; }
111 
fixedClipRect()112     const IntRect& fixedClipRect() const { return m_fixedClipRect; }
setFixedClipRect(const IntRect & r)113     void setFixedClipRect(const IntRect&r) { m_fixedClipRect = r; }
114 
posClipRect()115     const IntRect& posClipRect() const { return m_posClipRect; }
setPosClipRect(const IntRect & r)116     void setPosClipRect(const IntRect& r) { m_posClipRect = r; }
117 
fixed()118     bool fixed() const { return m_fixed; }
setFixed(bool fixed)119     void setFixed(bool fixed) { m_fixed = fixed; }
120 
ref()121     void ref() { m_refCnt++; }
deref(RenderArena * renderArena)122     void deref(RenderArena* renderArena) { if (--m_refCnt == 0) destroy(renderArena); }
123 
124     void destroy(RenderArena*);
125 
126     // Overloaded new operator.
127     void* operator new(size_t, RenderArena*) throw();
128 
129     // Overridden to prevent the normal delete from being called.
130     void operator delete(void*, size_t);
131 
132     bool operator==(const ClipRects& other) const
133     {
134         return m_overflowClipRect == other.overflowClipRect() &&
135                m_fixedClipRect == other.fixedClipRect() &&
136                m_posClipRect == other.posClipRect() &&
137                m_fixed == other.fixed();
138     }
139 
140     ClipRects& operator=(const ClipRects& other)
141     {
142         m_overflowClipRect = other.overflowClipRect();
143         m_fixedClipRect = other.fixedClipRect();
144         m_posClipRect = other.posClipRect();
145         m_fixed = other.fixed();
146         return *this;
147     }
148 
infiniteRect()149     static IntRect infiniteRect() { return IntRect(INT_MIN/2, INT_MIN/2, INT_MAX, INT_MAX); }
150 
151 private:
152     // The normal operator new is disallowed on all render objects.
153     void* operator new(size_t) throw();
154 
155 private:
156     IntRect m_overflowClipRect;
157     IntRect m_fixedClipRect;
158     IntRect m_posClipRect;
159     unsigned m_refCnt : 31;
160     bool m_fixed : 1;
161 };
162 
163 class RenderLayer : public ScrollbarClient {
164 public:
165     friend class RenderReplica;
166 
167     RenderLayer(RenderBoxModelObject*);
168     ~RenderLayer();
169 
renderer()170     RenderBoxModelObject* renderer() const { return m_renderer; }
renderBox()171     RenderBox* renderBox() const { return m_renderer && m_renderer->isBox() ? toRenderBox(m_renderer) : 0; }
parent()172     RenderLayer* parent() const { return m_parent; }
previousSibling()173     RenderLayer* previousSibling() const { return m_previous; }
nextSibling()174     RenderLayer* nextSibling() const { return m_next; }
firstChild()175     RenderLayer* firstChild() const { return m_first; }
lastChild()176     RenderLayer* lastChild() const { return m_last; }
177 
178     void addChild(RenderLayer* newChild, RenderLayer* beforeChild = 0);
179     RenderLayer* removeChild(RenderLayer*);
180 
181     void removeOnlyThisLayer();
182     void insertOnlyThisLayer();
183 
184     void repaintIncludingDescendants();
185 
186 #if USE(ACCELERATED_COMPOSITING)
187     // Indicate that the layer contents need to be repainted. Only has an effect
188     // if layer compositing is being used,
189     void setBackingNeedsRepaint();
190     void setBackingNeedsRepaintInRect(const IntRect& r); // r is in the coordinate space of the layer's render object
191     void repaintIncludingNonCompositingDescendants(RenderBoxModelObject* repaintContainer);
192 #endif
193 
194     void styleChanged(StyleDifference, const RenderStyle*);
195 
marquee()196     RenderMarquee* marquee() const { return m_marquee; }
197 
isNormalFlowOnly()198     bool isNormalFlowOnly() const { return m_isNormalFlowOnly; }
199     bool isSelfPaintingLayer() const;
200 
201     bool requiresSlowRepaints() const;
202 
203     bool isTransparent() const;
204     RenderLayer* transparentPaintingAncestor();
205     void beginTransparencyLayers(GraphicsContext*, const RenderLayer* rootLayer);
206 
hasReflection()207     bool hasReflection() const { return renderer()->hasReflection(); }
reflection()208     RenderReplica* reflection() const { return m_reflection; }
209     RenderLayer* reflectionLayer() const;
210 
root()211     const RenderLayer* root() const
212     {
213         const RenderLayer* curr = this;
214         while (curr->parent())
215             curr = curr->parent();
216         return curr;
217     }
218 
x()219     int x() const { return m_x; }
y()220     int y() const { return m_y; }
setLocation(int x,int y)221     void setLocation(int x, int y)
222     {
223         m_x = x;
224         m_y = y;
225     }
226 
width()227     int width() const { return m_width; }
height()228     int height() const { return m_height; }
setWidth(int w)229     void setWidth(int w) { m_width = w; }
setHeight(int h)230     void setHeight(int h) { m_height = h; }
231 
232     int scrollWidth();
233     int scrollHeight();
234 
235     void panScrollFromPoint(const IntPoint&);
236 
237     // Scrolling methods for layers that can scroll their overflow.
238     void scrollByRecursively(int xDelta, int yDelta);
239     void addScrolledContentOffset(int& x, int& y) const;
240     void subtractScrolledContentOffset(int& x, int& y) const;
scrolledContentOffset()241     IntSize scrolledContentOffset() const { return IntSize(scrollXOffset() + m_scrollLeftOverflow, scrollYOffset()); }
242 
scrollXOffset()243     int scrollXOffset() const { return m_scrollX + m_scrollOriginX; }
scrollYOffset()244     int scrollYOffset() const { return m_scrollY; }
245 
246     void scrollToOffset(int x, int y, bool updateScrollbars = true, bool repaint = true);
scrollToXOffset(int x)247     void scrollToXOffset(int x) { scrollToOffset(x, m_scrollY); }
scrollToYOffset(int y)248     void scrollToYOffset(int y) { scrollToOffset(m_scrollX + m_scrollOriginX, y); }
249     void scrollRectToVisible(const IntRect&, bool scrollToAnchor = false, const ScrollAlignment& alignX = ScrollAlignment::alignCenterIfNeeded, const ScrollAlignment& alignY = ScrollAlignment::alignCenterIfNeeded);
250 
251     IntRect getRectToExpose(const IntRect& visibleRect, const IntRect& exposeRect, const ScrollAlignment& alignX, const ScrollAlignment& alignY);
252 
253     void setHasHorizontalScrollbar(bool);
254     void setHasVerticalScrollbar(bool);
255 
256     PassRefPtr<Scrollbar> createScrollbar(ScrollbarOrientation);
257     void destroyScrollbar(ScrollbarOrientation);
258 
horizontalScrollbar()259     Scrollbar* horizontalScrollbar() const { return m_hBar.get(); }
verticalScrollbar()260     Scrollbar* verticalScrollbar() const { return m_vBar.get(); }
261 
262     int verticalScrollbarWidth() const;
263     int horizontalScrollbarHeight() const;
264 
265     void positionOverflowControls(int tx, int ty);
266     bool isPointInResizeControl(const IntPoint& absolutePoint) const;
267     bool hitTestOverflowControls(HitTestResult&, const IntPoint& localPoint);
268     IntSize offsetFromResizeCorner(const IntPoint& absolutePoint) const;
269 
270     void paintOverflowControls(GraphicsContext*, int tx, int ty, const IntRect& damageRect);
271     void paintScrollCorner(GraphicsContext*, int tx, int ty, const IntRect& damageRect);
272     void paintResizer(GraphicsContext*, int tx, int ty, const IntRect& damageRect);
273 
274     void updateScrollInfoAfterLayout();
275 
276     bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1.0f);
277     void autoscroll();
278 
279     void resize(const PlatformMouseEvent&, const IntSize&);
inResizeMode()280     bool inResizeMode() const { return m_inResizeMode; }
setInResizeMode(bool b)281     void setInResizeMode(bool b) { m_inResizeMode = b; }
282 
isRootLayer()283     bool isRootLayer() const { return renderer()->isRenderView(); }
284 
285 #if USE(ACCELERATED_COMPOSITING)
286     RenderLayerCompositor* compositor() const;
287 
288     // Notification from the renderer that its content changed (e.g. current frame of image changed).
289     // Allows updates of layer content without repainting.
290     void rendererContentChanged();
291 #endif
292 
293     // Returns true if the accelerated compositing is enabled
294     bool hasAcceleratedCompositing() const;
295 
296     void updateLayerPosition();
297 
298     enum UpdateLayerPositionsFlag {
299         DoFullRepaint = 1,
300         CheckForRepaint = 1 << 1,
301         UpdateCompositingLayers = 1 << 2,
302     };
303     typedef unsigned UpdateLayerPositionsFlags;
304     void updateLayerPositions(UpdateLayerPositionsFlags = DoFullRepaint | UpdateCompositingLayers);
305 
306     void updateTransform();
307 
relativePositionOffset(int & relX,int & relY)308     void relativePositionOffset(int& relX, int& relY) const { relX += m_relX; relY += m_relY; }
relativePositionOffset()309     IntSize relativePositionOffset() const { return IntSize(m_relX, m_relY); }
310 
311     void clearClipRectsIncludingDescendants();
312     void clearClipRects();
313 
314     // Get the enclosing stacking context for this layer.  A stacking context is a layer
315     // that has a non-auto z-index.
316     RenderLayer* stackingContext() const;
isStackingContext()317     bool isStackingContext() const { return !hasAutoZIndex() || renderer()->isRenderView(); }
318 
319     void dirtyZOrderLists();
320     void dirtyStackingContextZOrderLists();
321     void updateZOrderLists();
posZOrderList()322     Vector<RenderLayer*>* posZOrderList() const { return m_posZOrderList; }
negZOrderList()323     Vector<RenderLayer*>* negZOrderList() const { return m_negZOrderList; }
324 
325     void dirtyNormalFlowList();
326     void updateNormalFlowList();
normalFlowList()327     Vector<RenderLayer*>* normalFlowList() const { return m_normalFlowList; }
328 
hasVisibleContent()329     bool hasVisibleContent() const { return m_hasVisibleContent; }
330     void setHasVisibleContent(bool);
331     void dirtyVisibleContentStatus();
332 
333     // Gets the nearest enclosing positioned ancestor layer (also includes
334     // the <html> layer and the root layer).
335     RenderLayer* enclosingPositionedAncestor() const;
336 
337 #if USE(ACCELERATED_COMPOSITING)
338     // Enclosing compositing layer; if includeSelf is true, may return this.
339     RenderLayer* enclosingCompositingLayer(bool includeSelf = true) const;
340     // Ancestor compositing layer, excluding this.
ancestorCompositingLayer()341     RenderLayer* ancestorCompositingLayer() const { return enclosingCompositingLayer(false); }
342 #endif
343 
344     void convertToLayerCoords(const RenderLayer* ancestorLayer, int& x, int& y) const;
345 
hasAutoZIndex()346     bool hasAutoZIndex() const { return renderer()->style()->hasAutoZIndex(); }
zIndex()347     int zIndex() const { return renderer()->style()->zIndex(); }
348 
349     // The two main functions that use the layer system.  The paint method
350     // paints the layers that intersect the damage rect from back to
351     // front.  The hitTest method looks for mouse events by walking
352     // layers that intersect the point from front to back.
353     void paint(GraphicsContext*, const IntRect& damageRect, PaintRestriction = PaintRestrictionNone, RenderObject* paintingRoot = 0);
354     bool hitTest(const HitTestRequest&, HitTestResult&);
355 
356     // This method figures out our layerBounds in coordinates relative to
357     // |rootLayer}.  It also computes our background and foreground clip rects
358     // for painting/event handling.
359     void calculateRects(const RenderLayer* rootLayer, const IntRect& paintDirtyRect, IntRect& layerBounds,
360                         IntRect& backgroundRect, IntRect& foregroundRect, IntRect& outlineRect, bool temporaryClipRects = false) const;
361 
362     // Compute and cache clip rects computed with the given layer as the root
363     void updateClipRects(const RenderLayer* rootLayer);
364     // Compute and return the clip rects. If useCached is true, will used previously computed clip rects on ancestors
365     // (rather than computing them all from scratch up the parent chain).
366     void calculateClipRects(const RenderLayer* rootLayer, ClipRects&, bool useCached = false) const;
clipRects()367     ClipRects* clipRects() const { return m_clipRects; }
368 
369     IntRect childrenClipRect() const; // Returns the foreground clip rect of the layer in the document's coordinate space.
370     IntRect selfClipRect() const; // Returns the background clip rect of the layer in the document's coordinate space.
371 
372     bool intersectsDamageRect(const IntRect& layerBounds, const IntRect& damageRect, const RenderLayer* rootLayer) const;
373 
374     // Bounding box relative to some ancestor layer.
375     IntRect boundingBox(const RenderLayer* rootLayer) const;
376     // Bounding box in the coordinates of this layer.
377     IntRect localBoundingBox() const;
378     // Bounding box relative to the root.
379     IntRect absoluteBoundingBox() const;
380 
381     void updateHoverActiveState(const HitTestRequest&, HitTestResult&);
382 
383     // Return a cached repaint rect, computed relative to the layer renderer's containerForRepaint.
repaintRect()384     IntRect repaintRect() const { return m_repaintRect; }
385     void computeRepaintRects();
386     void setNeedsFullRepaint(bool f = true) { m_needsFullRepaint = f; }
387 
staticX()388     int staticX() const { return m_staticX; }
staticY()389     int staticY() const { return m_staticY; }
setStaticX(int staticX)390     void setStaticX(int staticX) { m_staticX = staticX; }
391     void setStaticY(int staticY);
392 
hasTransform()393     bool hasTransform() const { return renderer()->hasTransform(); }
394     // Note that this transform has the transform-origin baked in.
transform()395     TransformationMatrix* transform() const { return m_transform.get(); }
396     // currentTransform computes a transform which takes accelerated animations into account. The
397     // resulting transform has transform-origin baked in. If the layer does not have a transform,
398     // returns the identity matrix.
399     TransformationMatrix currentTransform() const;
400 
401     // Get the perspective transform, which is applied to transformed sublayers.
402     // Returns true if the layer has a -webkit-perspective.
403     // Note that this transform has the perspective-origin baked in.
404     TransformationMatrix perspectiveTransform() const;
405     FloatPoint perspectiveOrigin() const;
preserves3D()406     bool preserves3D() const { return renderer()->style()->transformStyle3D() == TransformStyle3DPreserve3D; }
has3DTransform()407     bool has3DTransform() const { return m_transform && !m_transform->isAffine(); }
408 
409      // Overloaded new operator.  Derived classes must override operator new
410     // in order to allocate out of the RenderArena.
411     void* operator new(size_t, RenderArena*) throw();
412 
413     // Overridden to prevent the normal delete from being called.
414     void operator delete(void*, size_t);
415 
416 #if USE(ACCELERATED_COMPOSITING)
isComposited()417     bool isComposited() const { return m_backing != 0; }
backing()418     RenderLayerBacking* backing() const { return m_backing.get(); }
419     RenderLayerBacking* ensureBacking();
420     void clearBacking();
421 #else
isComposited()422     bool isComposited() const { return false; }
423 #endif
424 
paintsWithTransparency()425     bool paintsWithTransparency() const
426     {
427         return isTransparent() && !isComposited();
428     }
429 
paintsWithTransform()430     bool paintsWithTransform() const
431     {
432         return transform() && !isComposited();
433     }
434 
435 private:
436     // The normal operator new is disallowed on all render objects.
437     void* operator new(size_t) throw();
438 
439 private:
setNextSibling(RenderLayer * next)440     void setNextSibling(RenderLayer* next) { m_next = next; }
setPreviousSibling(RenderLayer * prev)441     void setPreviousSibling(RenderLayer* prev) { m_previous = prev; }
442     void setParent(RenderLayer* parent);
setFirstChild(RenderLayer * first)443     void setFirstChild(RenderLayer* first) { m_first = first; }
setLastChild(RenderLayer * last)444     void setLastChild(RenderLayer* last) { m_last = last; }
445 
renderBoxX()446     int renderBoxX() const { return renderer()->isBox() ? toRenderBox(renderer())->x() : 0; }
renderBoxY()447     int renderBoxY() const { return renderer()->isBox() ? toRenderBox(renderer())->y() : 0; }
448 
449     void collectLayers(Vector<RenderLayer*>*&, Vector<RenderLayer*>*&);
450 
451     void updateLayerListsIfNeeded();
452     void updateCompositingAndLayerListsIfNeeded();
453 
454     enum PaintLayerFlag {
455         PaintLayerHaveTransparency = 1,
456         PaintLayerAppliedTransform = 1 << 1,
457         PaintLayerTemporaryClipRects = 1 << 2,
458         PaintLayerPaintingReflection = 1 << 3
459     };
460 
461     typedef unsigned PaintLayerFlags;
462 
463     void paintLayer(RenderLayer* rootLayer, GraphicsContext*, const IntRect& paintDirtyRect,
464                     PaintRestriction, RenderObject* paintingRoot, RenderObject::OverlapTestRequestMap* = 0,
465                     PaintLayerFlags paintFlags = 0);
466 
467     RenderLayer* hitTestLayer(RenderLayer* rootLayer, RenderLayer* containerLayer, const HitTestRequest& request, HitTestResult& result,
468                             const IntRect& hitTestRect, const IntPoint& hitTestPoint, bool appliedTransform,
469                             const HitTestingTransformState* transformState = 0, double* zOffset = 0);
470 
471     PassRefPtr<HitTestingTransformState> createLocalTransformState(RenderLayer* rootLayer, RenderLayer* containerLayer,
472                             const IntRect& hitTestRect, const IntPoint& hitTestPoint,
473                             const HitTestingTransformState* containerTransformState) const;
474 
475     bool hitTestContents(const HitTestRequest&, HitTestResult&, const IntRect& layerBounds, const IntPoint& hitTestPoint, HitTestFilter) const;
476 
477     void computeScrollDimensions(bool* needHBar = 0, bool* needVBar = 0);
478 
479     bool shouldBeNormalFlowOnly() const;
480 
481     // ScrollBarClient interface
482     virtual void valueChanged(Scrollbar*);
483     virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&);
484     virtual bool isActive() const;
485     virtual bool scrollbarCornerPresent() const;
486     virtual IntRect convertFromScrollbarToContainingView(const Scrollbar*, const IntRect&) const;
487     virtual IntRect convertFromContainingViewToScrollbar(const Scrollbar*, const IntRect&) const;
488     virtual IntPoint convertFromScrollbarToContainingView(const Scrollbar*, const IntPoint&) const;
489     virtual IntPoint convertFromContainingViewToScrollbar(const Scrollbar*, const IntPoint&) const;
490 
491     IntSize scrollbarOffset(const Scrollbar*) const;
492 
493     void updateOverflowStatus(bool horizontalOverflow, bool verticalOverflow);
494 
495     void childVisibilityChanged(bool newVisibility);
496     void dirtyVisibleDescendantStatus();
497     void updateVisibilityStatus();
498 
499     // This flag is computed by RenderLayerCompositor, which knows more about 3d hierarchies than we do.
setHas3DTransformedDescendant(bool b)500     void setHas3DTransformedDescendant(bool b) { m_has3DTransformedDescendant = b; }
has3DTransformedDescendant()501     bool has3DTransformedDescendant() const { return m_has3DTransformedDescendant; }
502 
503     void dirty3DTransformedDescendantStatus();
504     // Both updates the status, and returns true if descendants of this have 3d.
505     bool update3DTransformedDescendantStatus();
506 
507     Node* enclosingElement() const;
508 
509     void createReflection();
510     void updateReflectionStyle();
paintingInsideReflection()511     bool paintingInsideReflection() const { return m_paintingInsideReflection; }
setPaintingInsideReflection(bool b)512     void setPaintingInsideReflection(bool b) { m_paintingInsideReflection = b; }
513 
514     void parentClipRects(const RenderLayer* rootLayer, ClipRects&, bool temporaryClipRects = false) const;
515 
516     RenderLayer* enclosingTransformedAncestor() const;
517 
518     // Convert a point in absolute coords into layer coords, taking transforms into account
519     IntPoint absoluteToContents(const IntPoint&) const;
520 
521     void updateScrollCornerStyle();
522     void updateResizerStyle();
523 
524 #if USE(ACCELERATED_COMPOSITING)
hasCompositingDescendant()525     bool hasCompositingDescendant() const { return m_hasCompositingDescendant; }
setHasCompositingDescendant(bool b)526     void setHasCompositingDescendant(bool b)  { m_hasCompositingDescendant = b; }
527 
mustOverlapCompositedLayers()528     bool mustOverlapCompositedLayers() const { return m_mustOverlapCompositedLayers; }
setMustOverlapCompositedLayers(bool b)529     void setMustOverlapCompositedLayers(bool b) { m_mustOverlapCompositedLayers = b; }
530 #endif
531 
532 private:
533     friend class RenderLayerBacking;
534     friend class RenderLayerCompositor;
535     friend class RenderBoxModelObject;
536 
537     // Only safe to call from RenderBoxModelObject::destroyLayer(RenderArena*)
538     void destroy(RenderArena*);
539 
540 protected:
541     RenderBoxModelObject* m_renderer;
542 
543     RenderLayer* m_parent;
544     RenderLayer* m_previous;
545     RenderLayer* m_next;
546     RenderLayer* m_first;
547     RenderLayer* m_last;
548 
549     IntRect m_repaintRect; // Cached repaint rects. Used by layout.
550     IntRect m_outlineBox;
551 
552     // Our current relative position offset.
553     int m_relX;
554     int m_relY;
555 
556     // Our (x,y) coordinates are in our parent layer's coordinate space.
557     int m_x;
558     int m_y;
559 
560     // The layer's width/height
561     int m_width;
562     int m_height;
563 
564     // Our scroll offsets if the view is scrolled.
565     int m_scrollX;
566     int m_scrollY;
567     int m_scrollOriginX;        // only non-zero for rtl content
568     int m_scrollLeftOverflow;   // only non-zero for rtl content
569 
570     // The width/height of our scrolled area.
571     int m_scrollWidth;
572     int m_scrollHeight;
573 
574     // For layers with overflow, we have a pair of scrollbars.
575     RefPtr<Scrollbar> m_hBar;
576     RefPtr<Scrollbar> m_vBar;
577 
578     // Keeps track of whether the layer is currently resizing, so events can cause resizing to start and stop.
579     bool m_inResizeMode;
580 
581     // For layers that establish stacking contexts, m_posZOrderList holds a sorted list of all the
582     // descendant layers within the stacking context that have z-indices of 0 or greater
583     // (auto will count as 0).  m_negZOrderList holds descendants within our stacking context with negative
584     // z-indices.
585     Vector<RenderLayer*>* m_posZOrderList;
586     Vector<RenderLayer*>* m_negZOrderList;
587 
588     // This list contains child layers that cannot create stacking contexts.  For now it is just
589     // overflow layers, but that may change in the future.
590     Vector<RenderLayer*>* m_normalFlowList;
591 
592     ClipRects* m_clipRects;      // Cached clip rects used when painting and hit testing.
593 #ifndef NDEBUG
594     const RenderLayer* m_clipRectsRoot;   // Root layer used to compute clip rects.
595 #endif
596 
597     bool m_scrollDimensionsDirty : 1;
598     bool m_zOrderListsDirty : 1;
599     bool m_normalFlowListDirty: 1;
600     bool m_isNormalFlowOnly : 1;
601 
602     bool m_usedTransparency : 1; // Tracks whether we need to close a transparent layer, i.e., whether
603                                  // we ended up painting this layer or any descendants (and therefore need to
604                                  // blend).
605     bool m_paintingInsideReflection : 1;  // A state bit tracking if we are painting inside a replica.
606     bool m_inOverflowRelayout : 1;
607     bool m_needsFullRepaint : 1;
608 
609     bool m_overflowStatusDirty : 1;
610     bool m_horizontalOverflow : 1;
611     bool m_verticalOverflow : 1;
612     bool m_visibleContentStatusDirty : 1;
613     bool m_hasVisibleContent : 1;
614     bool m_visibleDescendantStatusDirty : 1;
615     bool m_hasVisibleDescendant : 1;
616 
617     bool m_3DTransformedDescendantStatusDirty : 1;
618     bool m_has3DTransformedDescendant : 1;  // Set on a stacking context layer that has 3D descendants anywhere
619                                             // in a preserves3D hierarchy. Hint to do 3D-aware hit testing.
620 #if USE(ACCELERATED_COMPOSITING)
621     bool m_hasCompositingDescendant : 1;
622     bool m_mustOverlapCompositedLayers : 1;
623 #endif
624 
625     RenderMarquee* m_marquee; // Used by layers with overflow:marquee
626 
627     // Cached normal flow values for absolute positioned elements with static left/top values.
628     int m_staticX;
629     int m_staticY;
630 
631     OwnPtr<TransformationMatrix> m_transform;
632 
633     // May ultimately be extended to many replicas (with their own paint order).
634     RenderReplica* m_reflection;
635 
636     // Renderers to hold our custom scroll corner and resizer.
637     RenderScrollbarPart* m_scrollCorner;
638     RenderScrollbarPart* m_resizer;
639 
640 #if USE(ACCELERATED_COMPOSITING)
641     OwnPtr<RenderLayerBacking> m_backing;
642 #endif
643 };
644 
645 } // namespace WebCore
646 
647 #endif // RenderLayer_h
648