Home | History | Annotate | Download | only in rendering
      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 (at) fas.harvard.edu>
      9  *   Christian Biesinger <cbiesinger (at) web.de>
     10  *   Randall Jesup <rjesup (at) wgate.com>
     11  *   Roland Mainz <roland.mainz (at) informatik.med.uni-giessen.de>
     12  *   Josh Soref <timeless (at) mac.com>
     13  *   Boris Zbarsky <bzbarsky (at) 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:
     77     ClipRects()
     78         : m_refCnt(0)
     79         , m_fixed(false)
     80     {
     81     }
     82 
     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 
     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 
    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 
    109     const IntRect& overflowClipRect() const { return m_overflowClipRect; }
    110     void setOverflowClipRect(const IntRect& r) { m_overflowClipRect = r; }
    111 
    112     const IntRect& fixedClipRect() const { return m_fixedClipRect; }
    113     void setFixedClipRect(const IntRect&r) { m_fixedClipRect = r; }
    114 
    115     const IntRect& posClipRect() const { return m_posClipRect; }
    116     void setPosClipRect(const IntRect& r) { m_posClipRect = r; }
    117 
    118     bool fixed() const { return m_fixed; }
    119     void setFixed(bool fixed) { m_fixed = fixed; }
    120 
    121     void ref() { m_refCnt++; }
    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 
    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 
    170     RenderBoxModelObject* renderer() const { return m_renderer; }
    171     RenderBox* renderBox() const { return m_renderer && m_renderer->isBox() ? toRenderBox(m_renderer) : 0; }
    172     RenderLayer* parent() const { return m_parent; }
    173     RenderLayer* previousSibling() const { return m_previous; }
    174     RenderLayer* nextSibling() const { return m_next; }
    175     RenderLayer* firstChild() const { return m_first; }
    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 
    196     RenderMarquee* marquee() const { return m_marquee; }
    197 
    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, PaintBehavior);
    206 
    207     bool hasReflection() const { return renderer()->hasReflection(); }
    208     bool isReflection() const { return renderer()->isReplica(); }
    209     RenderReplica* reflection() const { return m_reflection; }
    210     RenderLayer* reflectionLayer() const;
    211 
    212     const RenderLayer* root() const
    213     {
    214         const RenderLayer* curr = this;
    215         while (curr->parent())
    216             curr = curr->parent();
    217         return curr;
    218     }
    219 
    220     int x() const { return m_x; }
    221     int y() const { return m_y; }
    222     void setLocation(int x, int y)
    223     {
    224         m_x = x;
    225         m_y = y;
    226     }
    227 
    228     int width() const { return m_width; }
    229     int height() const { return m_height; }
    230     void setWidth(int w) { m_width = w; }
    231     void setHeight(int h) { m_height = h; }
    232 
    233     int scrollWidth();
    234     int scrollHeight();
    235 
    236     void panScrollFromPoint(const IntPoint&);
    237 
    238     // Scrolling methods for layers that can scroll their overflow.
    239     void scrollByRecursively(int xDelta, int yDelta);
    240     void addScrolledContentOffset(int& x, int& y) const;
    241     void subtractScrolledContentOffset(int& x, int& y) const;
    242     IntSize scrolledContentOffset() const { return IntSize(scrollXOffset() + m_scrollLeftOverflow, scrollYOffset()); }
    243 
    244     int scrollXOffset() const { return m_scrollX + m_scrollOriginX; }
    245     int scrollYOffset() const { return m_scrollY; }
    246 
    247     void scrollToOffset(int x, int y, bool updateScrollbars = true, bool repaint = true);
    248     void scrollToXOffset(int x) { scrollToOffset(x, m_scrollY); }
    249     void scrollToYOffset(int y) { scrollToOffset(m_scrollX + m_scrollOriginX, y); }
    250     void scrollRectToVisible(const IntRect&, bool scrollToAnchor = false, const ScrollAlignment& alignX = ScrollAlignment::alignCenterIfNeeded, const ScrollAlignment& alignY = ScrollAlignment::alignCenterIfNeeded);
    251 
    252     IntRect getRectToExpose(const IntRect& visibleRect, const IntRect& exposeRect, const ScrollAlignment& alignX, const ScrollAlignment& alignY);
    253 
    254     void setHasHorizontalScrollbar(bool);
    255     void setHasVerticalScrollbar(bool);
    256 
    257     PassRefPtr<Scrollbar> createScrollbar(ScrollbarOrientation);
    258     void destroyScrollbar(ScrollbarOrientation);
    259 
    260     Scrollbar* horizontalScrollbar() const { return m_hBar.get(); }
    261     Scrollbar* verticalScrollbar() const { return m_vBar.get(); }
    262 
    263     int verticalScrollbarWidth() const;
    264     int horizontalScrollbarHeight() const;
    265 
    266     bool hasOverflowControls() const;
    267     void positionOverflowControls(int tx, int ty);
    268     bool isPointInResizeControl(const IntPoint& absolutePoint) const;
    269     bool hitTestOverflowControls(HitTestResult&, const IntPoint& localPoint);
    270     IntSize offsetFromResizeCorner(const IntPoint& absolutePoint) const;
    271 
    272     void paintOverflowControls(GraphicsContext*, int tx, int ty, const IntRect& damageRect);
    273     void paintScrollCorner(GraphicsContext*, int tx, int ty, const IntRect& damageRect);
    274     void paintResizer(GraphicsContext*, int tx, int ty, const IntRect& damageRect);
    275 
    276     void updateScrollInfoAfterLayout();
    277 
    278     bool scroll(ScrollDirection, ScrollGranularity, float multiplier = 1.0f);
    279     void autoscroll();
    280 
    281     void resize(const PlatformMouseEvent&, const IntSize&);
    282     bool inResizeMode() const { return m_inResizeMode; }
    283     void setInResizeMode(bool b) { m_inResizeMode = b; }
    284 
    285     bool isRootLayer() const { return renderer()->isRenderView(); }
    286 
    287 #if USE(ACCELERATED_COMPOSITING)
    288     RenderLayerCompositor* compositor() const;
    289 
    290     // Notification from the renderer that its content changed (e.g. current frame of image changed).
    291     // Allows updates of layer content without repainting.
    292     void rendererContentChanged();
    293 #endif
    294 
    295     // Returns true if the accelerated compositing is enabled
    296     bool hasAcceleratedCompositing() const;
    297 
    298     void updateLayerPosition();
    299 
    300     enum UpdateLayerPositionsFlag {
    301         DoFullRepaint = 1,
    302         CheckForRepaint = 1 << 1,
    303         IsCompositingUpdateRoot = 1 << 2,
    304         UpdateCompositingLayers = 1 << 3,
    305     };
    306     typedef unsigned UpdateLayerPositionsFlags;
    307     void updateLayerPositions(UpdateLayerPositionsFlags = DoFullRepaint | IsCompositingUpdateRoot | UpdateCompositingLayers);
    308 
    309     void updateTransform();
    310 
    311     void relativePositionOffset(int& relX, int& relY) const { relX += m_relX; relY += m_relY; }
    312     IntSize relativePositionOffset() const { return IntSize(m_relX, m_relY); }
    313 
    314     void clearClipRectsIncludingDescendants();
    315     void clearClipRects();
    316 
    317     void addBlockSelectionGapsBounds(const IntRect&);
    318     void clearBlockSelectionGapsBounds();
    319     void repaintBlockSelectionGaps();
    320 
    321     // Get the enclosing stacking context for this layer.  A stacking context is a layer
    322     // that has a non-auto z-index.
    323     RenderLayer* stackingContext() const;
    324 #if ENABLE(COMPOSITED_FIXED_ELEMENTS)
    325     bool isFixed() const { return renderer()->isPositioned() && renderer()->style()->position() == FixedPosition; }
    326     // If fixed elements are composited, they will be containing children
    327     bool isStackingContext() const {
    328       return !hasAutoZIndex() || renderer()->isRenderView() || (isComposited() && isFixed());
    329     }
    330 #else
    331     bool isStackingContext() const { return !hasAutoZIndex() || renderer()->isRenderView() ; }
    332 #endif
    333 
    334     void dirtyZOrderLists();
    335     void dirtyStackingContextZOrderLists();
    336     void updateZOrderLists();
    337     Vector<RenderLayer*>* posZOrderList() const { return m_posZOrderList; }
    338     Vector<RenderLayer*>* negZOrderList() const { return m_negZOrderList; }
    339 
    340     void dirtyNormalFlowList();
    341     void updateNormalFlowList();
    342     Vector<RenderLayer*>* normalFlowList() const { return m_normalFlowList; }
    343 
    344     bool hasVisibleContent() const { return m_hasVisibleContent; }
    345     bool hasVisibleDescendant() const { return m_hasVisibleDescendant; }
    346     void setHasVisibleContent(bool);
    347     void dirtyVisibleContentStatus();
    348 
    349     // Gets the nearest enclosing positioned ancestor layer (also includes
    350     // the <html> layer and the root layer).
    351     RenderLayer* enclosingPositionedAncestor() const;
    352 
    353     // The layer relative to which clipping rects for this layer are computed.
    354     RenderLayer* clippingRoot() const;
    355 
    356 #if USE(ACCELERATED_COMPOSITING)
    357     // Enclosing compositing layer; if includeSelf is true, may return this.
    358     RenderLayer* enclosingCompositingLayer(bool includeSelf = true) const;
    359     // Ancestor compositing layer, excluding this.
    360     RenderLayer* ancestorCompositingLayer() const { return enclosingCompositingLayer(false); }
    361 #endif
    362 
    363     void convertToLayerCoords(const RenderLayer* ancestorLayer, int& x, int& y) const;
    364 
    365     bool hasAutoZIndex() const { return renderer()->style()->hasAutoZIndex(); }
    366     int zIndex() const { return renderer()->style()->zIndex(); }
    367 
    368     // The two main functions that use the layer system.  The paint method
    369     // paints the layers that intersect the damage rect from back to
    370     // front.  The hitTest method looks for mouse events by walking
    371     // layers that intersect the point from front to back.
    372     void paint(GraphicsContext*, const IntRect& damageRect, PaintBehavior = PaintBehaviorNormal, RenderObject* paintingRoot = 0);
    373     bool hitTest(const HitTestRequest&, HitTestResult&);
    374 
    375     // This method figures out our layerBounds in coordinates relative to
    376     // |rootLayer}.  It also computes our background and foreground clip rects
    377     // for painting/event handling.
    378     void calculateRects(const RenderLayer* rootLayer, const IntRect& paintDirtyRect, IntRect& layerBounds,
    379                         IntRect& backgroundRect, IntRect& foregroundRect, IntRect& outlineRect, bool temporaryClipRects = false) const;
    380 
    381     // Compute and cache clip rects computed with the given layer as the root
    382     void updateClipRects(const RenderLayer* rootLayer);
    383     // Compute and return the clip rects. If useCached is true, will used previously computed clip rects on ancestors
    384     // (rather than computing them all from scratch up the parent chain).
    385     void calculateClipRects(const RenderLayer* rootLayer, ClipRects&, bool useCached = false) const;
    386     ClipRects* clipRects() const { return m_clipRects; }
    387 
    388     IntRect childrenClipRect() const; // Returns the foreground clip rect of the layer in the document's coordinate space.
    389     IntRect selfClipRect() const; // Returns the background clip rect of the layer in the document's coordinate space.
    390 
    391     bool intersectsDamageRect(const IntRect& layerBounds, const IntRect& damageRect, const RenderLayer* rootLayer) const;
    392 
    393     // Bounding box relative to some ancestor layer.
    394     IntRect boundingBox(const RenderLayer* rootLayer) const;
    395     // Bounding box in the coordinates of this layer.
    396     IntRect localBoundingBox() const;
    397     // Bounding box relative to the root.
    398     IntRect absoluteBoundingBox() const;
    399 
    400     void updateHoverActiveState(const HitTestRequest&, HitTestResult&);
    401 
    402     // Return a cached repaint rect, computed relative to the layer renderer's containerForRepaint.
    403     IntRect repaintRect() const { return m_repaintRect; }
    404     void computeRepaintRects();
    405     void setNeedsFullRepaint(bool f = true) { m_needsFullRepaint = f; }
    406 
    407     int staticX() const { return m_staticX; }
    408     int staticY() const { return m_staticY; }
    409     void setStaticX(int staticX) { m_staticX = staticX; }
    410     void setStaticY(int staticY) { m_staticY = staticY; }
    411 
    412     bool hasTransform() const { return renderer()->hasTransform(); }
    413     // Note that this transform has the transform-origin baked in.
    414     TransformationMatrix* transform() const { return m_transform.get(); }
    415     // currentTransform computes a transform which takes accelerated animations into account. The
    416     // resulting transform has transform-origin baked in. If the layer does not have a transform,
    417     // returns the identity matrix.
    418     TransformationMatrix currentTransform() const;
    419     TransformationMatrix renderableTransform(PaintBehavior) const;
    420 
    421     // Get the perspective transform, which is applied to transformed sublayers.
    422     // Returns true if the layer has a -webkit-perspective.
    423     // Note that this transform has the perspective-origin baked in.
    424     TransformationMatrix perspectiveTransform() const;
    425     FloatPoint perspectiveOrigin() const;
    426     bool preserves3D() const { return renderer()->style()->transformStyle3D() == TransformStyle3DPreserve3D; }
    427     bool has3DTransform() const { return m_transform && !m_transform->isAffine(); }
    428 
    429      // Overloaded new operator.  Derived classes must override operator new
    430     // in order to allocate out of the RenderArena.
    431     void* operator new(size_t, RenderArena*) throw();
    432 
    433     // Overridden to prevent the normal delete from being called.
    434     void operator delete(void*, size_t);
    435 
    436 #if USE(ACCELERATED_COMPOSITING)
    437     bool isComposited() const { return m_backing != 0; }
    438     bool hasCompositedMask() const;
    439     RenderLayerBacking* backing() const { return m_backing.get(); }
    440     RenderLayerBacking* ensureBacking();
    441     void clearBacking();
    442 #else
    443     bool isComposited() const { return false; }
    444     bool hasCompositedMask() const { return false; }
    445 #endif
    446 
    447     bool paintsWithTransparency(PaintBehavior paintBehavior) const
    448     {
    449         return isTransparent() && ((paintBehavior & PaintBehaviorFlattenCompositingLayers) || !isComposited());
    450     }
    451 
    452     bool paintsWithTransform(PaintBehavior paintBehavior) const
    453     {
    454         return transform() && ((paintBehavior & PaintBehaviorFlattenCompositingLayers) || !isComposited());
    455     }
    456 
    457 private:
    458     // The normal operator new is disallowed on all render objects.
    459     void* operator new(size_t) throw();
    460 
    461 private:
    462     void setNextSibling(RenderLayer* next) { m_next = next; }
    463     void setPreviousSibling(RenderLayer* prev) { m_previous = prev; }
    464     void setParent(RenderLayer* parent);
    465     void setFirstChild(RenderLayer* first) { m_first = first; }
    466     void setLastChild(RenderLayer* last) { m_last = last; }
    467 
    468     int renderBoxX() const { return renderer()->isBox() ? toRenderBox(renderer())->x() : 0; }
    469     int renderBoxY() const { return renderer()->isBox() ? toRenderBox(renderer())->y() : 0; }
    470 
    471     void collectLayers(Vector<RenderLayer*>*&, Vector<RenderLayer*>*&);
    472 
    473     void updateLayerListsIfNeeded();
    474     void updateCompositingAndLayerListsIfNeeded();
    475 
    476     enum PaintLayerFlag {
    477         PaintLayerHaveTransparency = 1,
    478         PaintLayerAppliedTransform = 1 << 1,
    479         PaintLayerTemporaryClipRects = 1 << 2,
    480         PaintLayerPaintingReflection = 1 << 3
    481     };
    482 
    483     typedef unsigned PaintLayerFlags;
    484 
    485     void paintLayer(RenderLayer* rootLayer, GraphicsContext*, const IntRect& paintDirtyRect,
    486                     PaintBehavior, RenderObject* paintingRoot, RenderObject::OverlapTestRequestMap* = 0,
    487                     PaintLayerFlags paintFlags = 0);
    488 
    489     RenderLayer* hitTestLayer(RenderLayer* rootLayer, RenderLayer* containerLayer, const HitTestRequest& request, HitTestResult& result,
    490                             const IntRect& hitTestRect, const IntPoint& hitTestPoint, bool appliedTransform,
    491                             const HitTestingTransformState* transformState = 0, double* zOffset = 0);
    492 
    493     PassRefPtr<HitTestingTransformState> createLocalTransformState(RenderLayer* rootLayer, RenderLayer* containerLayer,
    494                             const IntRect& hitTestRect, const IntPoint& hitTestPoint,
    495                             const HitTestingTransformState* containerTransformState) const;
    496 
    497     bool hitTestContents(const HitTestRequest&, HitTestResult&, const IntRect& layerBounds, const IntPoint& hitTestPoint, HitTestFilter) const;
    498 
    499     void computeScrollDimensions(bool* needHBar = 0, bool* needVBar = 0);
    500 
    501     bool shouldBeNormalFlowOnly() const;
    502 
    503     // ScrollBarClient interface
    504     virtual void valueChanged(Scrollbar*);
    505     virtual void invalidateScrollbarRect(Scrollbar*, const IntRect&);
    506     virtual bool isActive() const;
    507     virtual bool scrollbarCornerPresent() const;
    508     virtual IntRect convertFromScrollbarToContainingView(const Scrollbar*, const IntRect&) const;
    509     virtual IntRect convertFromContainingViewToScrollbar(const Scrollbar*, const IntRect&) const;
    510     virtual IntPoint convertFromScrollbarToContainingView(const Scrollbar*, const IntPoint&) const;
    511     virtual IntPoint convertFromContainingViewToScrollbar(const Scrollbar*, const IntPoint&) const;
    512 
    513     IntSize scrollbarOffset(const Scrollbar*) const;
    514 
    515     void updateOverflowStatus(bool horizontalOverflow, bool verticalOverflow);
    516 
    517     void childVisibilityChanged(bool newVisibility);
    518     void dirtyVisibleDescendantStatus();
    519     void updateVisibilityStatus();
    520 
    521     // This flag is computed by RenderLayerCompositor, which knows more about 3d hierarchies than we do.
    522     void setHas3DTransformedDescendant(bool b) { m_has3DTransformedDescendant = b; }
    523     bool has3DTransformedDescendant() const { return m_has3DTransformedDescendant; }
    524 
    525     void dirty3DTransformedDescendantStatus();
    526     // Both updates the status, and returns true if descendants of this have 3d.
    527     bool update3DTransformedDescendantStatus();
    528 
    529     Node* enclosingElement() const;
    530 
    531     void createReflection();
    532     void removeReflection();
    533 
    534     void updateReflectionStyle();
    535     bool paintingInsideReflection() const { return m_paintingInsideReflection; }
    536     void setPaintingInsideReflection(bool b) { m_paintingInsideReflection = b; }
    537 
    538     void parentClipRects(const RenderLayer* rootLayer, ClipRects&, bool temporaryClipRects = false) const;
    539     IntRect backgroundClipRect(const RenderLayer* rootLayer, bool temporaryClipRects) const;
    540 
    541     RenderLayer* enclosingTransformedAncestor() const;
    542 
    543     // Convert a point in absolute coords into layer coords, taking transforms into account
    544     IntPoint absoluteToContents(const IntPoint&) const;
    545 
    546     void updateScrollCornerStyle();
    547     void updateResizerStyle();
    548 
    549 #if USE(ACCELERATED_COMPOSITING)
    550     bool hasCompositingDescendant() const { return m_hasCompositingDescendant; }
    551     void setHasCompositingDescendant(bool b)  { m_hasCompositingDescendant = b; }
    552 
    553     bool mustOverlapCompositedLayers() const { return m_mustOverlapCompositedLayers; }
    554     void setMustOverlapCompositedLayers(bool b) { m_mustOverlapCompositedLayers = b; }
    555 #endif
    556 
    557 private:
    558     friend class RenderLayerBacking;
    559     friend class RenderLayerCompositor;
    560     friend class RenderBoxModelObject;
    561 
    562     // Only safe to call from RenderBoxModelObject::destroyLayer(RenderArena*)
    563     void destroy(RenderArena*);
    564 
    565 protected:
    566     RenderBoxModelObject* m_renderer;
    567 
    568     RenderLayer* m_parent;
    569     RenderLayer* m_previous;
    570     RenderLayer* m_next;
    571     RenderLayer* m_first;
    572     RenderLayer* m_last;
    573 
    574     IntRect m_repaintRect; // Cached repaint rects. Used by layout.
    575     IntRect m_outlineBox;
    576 
    577     // Our current relative position offset.
    578     int m_relX;
    579     int m_relY;
    580 
    581     // Our (x,y) coordinates are in our parent layer's coordinate space.
    582     int m_x;
    583     int m_y;
    584 
    585     // The layer's width/height
    586     int m_width;
    587     int m_height;
    588 
    589     // Our scroll offsets if the view is scrolled.
    590     int m_scrollX;
    591     int m_scrollY;
    592     int m_scrollOriginX;        // only non-zero for rtl content
    593     int m_scrollLeftOverflow;   // only non-zero for rtl content
    594 
    595     // The width/height of our scrolled area.
    596     int m_scrollWidth;
    597     int m_scrollHeight;
    598 
    599     // For layers with overflow, we have a pair of scrollbars.
    600     RefPtr<Scrollbar> m_hBar;
    601     RefPtr<Scrollbar> m_vBar;
    602 
    603     // Keeps track of whether the layer is currently resizing, so events can cause resizing to start and stop.
    604     bool m_inResizeMode;
    605 
    606     // For layers that establish stacking contexts, m_posZOrderList holds a sorted list of all the
    607     // descendant layers within the stacking context that have z-indices of 0 or greater
    608     // (auto will count as 0).  m_negZOrderList holds descendants within our stacking context with negative
    609     // z-indices.
    610     Vector<RenderLayer*>* m_posZOrderList;
    611     Vector<RenderLayer*>* m_negZOrderList;
    612 
    613     // This list contains child layers that cannot create stacking contexts.  For now it is just
    614     // overflow layers, but that may change in the future.
    615     Vector<RenderLayer*>* m_normalFlowList;
    616 
    617     ClipRects* m_clipRects;      // Cached clip rects used when painting and hit testing.
    618 #ifndef NDEBUG
    619     const RenderLayer* m_clipRectsRoot;   // Root layer used to compute clip rects.
    620 #endif
    621 
    622     bool m_scrollDimensionsDirty : 1;
    623     bool m_zOrderListsDirty : 1;
    624     bool m_normalFlowListDirty: 1;
    625     bool m_isNormalFlowOnly : 1;
    626 
    627     bool m_usedTransparency : 1; // Tracks whether we need to close a transparent layer, i.e., whether
    628                                  // we ended up painting this layer or any descendants (and therefore need to
    629                                  // blend).
    630     bool m_paintingInsideReflection : 1;  // A state bit tracking if we are painting inside a replica.
    631     bool m_inOverflowRelayout : 1;
    632     bool m_needsFullRepaint : 1;
    633 
    634     bool m_overflowStatusDirty : 1;
    635     bool m_horizontalOverflow : 1;
    636     bool m_verticalOverflow : 1;
    637     bool m_visibleContentStatusDirty : 1;
    638     bool m_hasVisibleContent : 1;
    639     bool m_visibleDescendantStatusDirty : 1;
    640     bool m_hasVisibleDescendant : 1;
    641 
    642     bool m_3DTransformedDescendantStatusDirty : 1;
    643     bool m_has3DTransformedDescendant : 1;  // Set on a stacking context layer that has 3D descendants anywhere
    644                                             // in a preserves3D hierarchy. Hint to do 3D-aware hit testing.
    645 #if USE(ACCELERATED_COMPOSITING)
    646     bool m_hasCompositingDescendant : 1;
    647     bool m_mustOverlapCompositedLayers : 1;
    648 #endif
    649 
    650     RenderMarquee* m_marquee; // Used by layers with overflow:marquee
    651 
    652     // Cached normal flow values for absolute positioned elements with static left/top values.
    653     int m_staticX;
    654     int m_staticY;
    655 
    656     OwnPtr<TransformationMatrix> m_transform;
    657 
    658     // May ultimately be extended to many replicas (with their own paint order).
    659     RenderReplica* m_reflection;
    660 
    661     // Renderers to hold our custom scroll corner and resizer.
    662     RenderScrollbarPart* m_scrollCorner;
    663     RenderScrollbarPart* m_resizer;
    664 
    665 private:
    666     IntRect m_blockSelectionGapsBounds;
    667 
    668 #if USE(ACCELERATED_COMPOSITING)
    669     OwnPtr<RenderLayerBacking> m_backing;
    670 #endif
    671 };
    672 
    673 } // namespace WebCore
    674 
    675 #ifndef NDEBUG
    676 // Outside the WebCore namespace for ease of invocation from gdb.
    677 void showLayerTree(const WebCore::RenderLayer* layer);
    678 #endif
    679 
    680 #endif // RenderLayer_h
    681