Home | History | Annotate | Download | only in rendering
      1 /*
      2  * Copyright (C) 2000 Lars Knoll (knoll (at) kde.org)
      3  *           (C) 2000 Antti Koivisto (koivisto (at) kde.org)
      4  *           (C) 2000 Dirk Mueller (mueller (at) kde.org)
      5  *           (C) 2004 Allan Sandfeld Jensen (kde (at) carewolf.com)
      6  * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
      7  * Copyright (C) 2009 Google Inc. All rights reserved.
      8  *
      9  * This library is free software; you can redistribute it and/or
     10  * modify it under the terms of the GNU Library General Public
     11  * License as published by the Free Software Foundation; either
     12  * version 2 of the License, or (at your option) any later version.
     13  *
     14  * This library is distributed in the hope that it will be useful,
     15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     17  * Library General Public License for more details.
     18  *
     19  * You should have received a copy of the GNU Library General Public License
     20  * along with this library; see the file COPYING.LIB.  If not, write to
     21  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
     22  * Boston, MA 02110-1301, USA.
     23  *
     24  */
     25 
     26 #ifndef RenderObject_h
     27 #define RenderObject_h
     28 
     29 #include "CachedResourceClient.h"
     30 #include "Document.h"
     31 #include "Element.h"
     32 #include "FloatQuad.h"
     33 #include "PaintPhase.h"
     34 #include "RenderObjectChildList.h"
     35 #include "RenderStyle.h"
     36 #include "TextAffinity.h"
     37 #include "TransformationMatrix.h"
     38 #include <wtf/UnusedParam.h>
     39 
     40 #if USE(CG) || USE(CAIRO) || PLATFORM(QT)
     41 #define HAVE_PATH_BASED_BORDER_RADIUS_DRAWING 1
     42 #endif
     43 
     44 namespace WebCore {
     45 
     46 class AffineTransform;
     47 class AnimationController;
     48 class HitTestResult;
     49 class InlineBox;
     50 class InlineFlowBox;
     51 class OverlapTestRequestClient;
     52 class Path;
     53 class Position;
     54 class RenderBoxModelObject;
     55 class RenderInline;
     56 class RenderBlock;
     57 class RenderFlow;
     58 class RenderLayer;
     59 class RenderTheme;
     60 class TransformState;
     61 class VisiblePosition;
     62 #if ENABLE(SVG)
     63 class RenderSVGResourceContainer;
     64 #endif
     65 
     66 struct PaintInfo;
     67 
     68 enum HitTestFilter {
     69     HitTestAll,
     70     HitTestSelf,
     71     HitTestDescendants
     72 };
     73 
     74 enum HitTestAction {
     75     HitTestBlockBackground,
     76     HitTestChildBlockBackground,
     77     HitTestChildBlockBackgrounds,
     78     HitTestFloat,
     79     HitTestForeground
     80 };
     81 
     82 // Sides used when drawing borders and outlines. The values should run clockwise from top.
     83 enum BoxSide {
     84     BSTop,
     85     BSRight,
     86     BSBottom,
     87     BSLeft
     88 };
     89 
     90 const int caretWidth = 1;
     91 
     92 #if ENABLE(DASHBOARD_SUPPORT)
     93 struct DashboardRegionValue {
     94     bool operator==(const DashboardRegionValue& o) const
     95     {
     96         return type == o.type && bounds == o.bounds && clip == o.clip && label == o.label;
     97     }
     98     bool operator!=(const DashboardRegionValue& o) const
     99     {
    100         return !(*this == o);
    101     }
    102 
    103     String label;
    104     IntRect bounds;
    105     IntRect clip;
    106     int type;
    107 };
    108 #endif
    109 
    110 // Base class for all rendering tree objects.
    111 class RenderObject : public CachedResourceClient {
    112     friend class RenderBlock;
    113     friend class RenderBox;
    114     friend class RenderLayer;
    115     friend class RenderObjectChildList;
    116     friend class RenderSVGContainer;
    117 public:
    118     // Anonymous objects should pass the document as their node, and they will then automatically be
    119     // marked as anonymous in the constructor.
    120     RenderObject(Node*);
    121     virtual ~RenderObject();
    122 
    123     RenderTheme* theme() const;
    124 
    125     virtual const char* renderName() const = 0;
    126 
    127     RenderObject* parent() const { return m_parent; }
    128     bool isDescendantOf(const RenderObject*) const;
    129 
    130     RenderObject* previousSibling() const { return m_previous; }
    131     RenderObject* nextSibling() const { return m_next; }
    132 
    133     RenderObject* firstChild() const
    134     {
    135         if (const RenderObjectChildList* children = virtualChildren())
    136             return children->firstChild();
    137         return 0;
    138     }
    139     RenderObject* lastChild() const
    140     {
    141         if (const RenderObjectChildList* children = virtualChildren())
    142             return children->lastChild();
    143         return 0;
    144     }
    145     RenderObject* beforePseudoElementRenderer() const
    146     {
    147         if (const RenderObjectChildList* children = virtualChildren())
    148             return children->beforePseudoElementRenderer(this);
    149         return 0;
    150     }
    151     RenderObject* afterPseudoElementRenderer() const
    152     {
    153         if (const RenderObjectChildList* children = virtualChildren())
    154             return children->afterPseudoElementRenderer(this);
    155         return 0;
    156     }
    157     virtual RenderObjectChildList* virtualChildren() { return 0; }
    158     virtual const RenderObjectChildList* virtualChildren() const { return 0; }
    159 
    160     RenderObject* nextInPreOrder() const;
    161     RenderObject* nextInPreOrder(const RenderObject* stayWithin) const;
    162     RenderObject* nextInPreOrderAfterChildren() const;
    163     RenderObject* nextInPreOrderAfterChildren(const RenderObject* stayWithin) const;
    164     RenderObject* previousInPreOrder() const;
    165     RenderObject* childAt(unsigned) const;
    166 
    167     RenderObject* firstLeafChild() const;
    168     RenderObject* lastLeafChild() const;
    169 
    170     // The following six functions are used when the render tree hierarchy changes to make sure layers get
    171     // properly added and removed.  Since containership can be implemented by any subclass, and since a hierarchy
    172     // can contain a mixture of boxes and other object types, these functions need to be in the base class.
    173     RenderLayer* enclosingLayer() const;
    174     void addLayers(RenderLayer* parentLayer, RenderObject* newObject);
    175     void removeLayers(RenderLayer* parentLayer);
    176     void moveLayers(RenderLayer* oldParent, RenderLayer* newParent);
    177     RenderLayer* findNextLayer(RenderLayer* parentLayer, RenderObject* startPoint, bool checkParent = true);
    178 
    179     // Convenience function for getting to the nearest enclosing box of a RenderObject.
    180     RenderBox* enclosingBox() const;
    181     RenderBoxModelObject* enclosingBoxModelObject() const;
    182 
    183     virtual bool isEmpty() const { return firstChild() == 0; }
    184 
    185 #ifndef NDEBUG
    186     void setHasAXObject(bool flag) { m_hasAXObject = flag; }
    187     bool hasAXObject() const { return m_hasAXObject; }
    188     bool isSetNeedsLayoutForbidden() const { return m_setNeedsLayoutForbidden; }
    189     void setNeedsLayoutIsForbidden(bool flag) { m_setNeedsLayoutForbidden = flag; }
    190 #endif
    191 
    192     // Obtains the nearest enclosing block (including this block) that contributes a first-line style to our inline
    193     // children.
    194     virtual RenderBlock* firstLineBlock() const;
    195 
    196     // Called when an object that was floating or positioned becomes a normal flow object
    197     // again.  We have to make sure the render tree updates as needed to accommodate the new
    198     // normal flow object.
    199     void handleDynamicFloatPositionChange();
    200 
    201     // RenderObject tree manipulation
    202     //////////////////////////////////////////
    203     virtual bool canHaveChildren() const { return virtualChildren(); }
    204     virtual bool isChildAllowed(RenderObject*, RenderStyle*) const { return true; }
    205     virtual void addChild(RenderObject* newChild, RenderObject* beforeChild = 0);
    206     virtual void addChildIgnoringContinuation(RenderObject* newChild, RenderObject* beforeChild = 0) { return addChild(newChild, beforeChild); }
    207     virtual void removeChild(RenderObject*);
    208     virtual bool createsAnonymousWrapper() const { return false; }
    209     //////////////////////////////////////////
    210 
    211 protected:
    212     //////////////////////////////////////////
    213     // Helper functions. Dangerous to use!
    214     void setPreviousSibling(RenderObject* previous) { m_previous = previous; }
    215     void setNextSibling(RenderObject* next) { m_next = next; }
    216     void setParent(RenderObject* parent) { m_parent = parent; }
    217     //////////////////////////////////////////
    218 private:
    219     void addAbsoluteRectForLayer(IntRect& result);
    220     void setLayerNeedsFullRepaint();
    221 
    222 public:
    223 #ifndef NDEBUG
    224     void showTreeForThis() const;
    225 
    226     void showRenderObject() const;
    227     // We don't make printedCharacters an optional parameter so that
    228     // showRenderObject can be called from gdb easily.
    229     void showRenderObject(int printedCharacters) const;
    230     void showRenderTreeAndMark(const RenderObject* markedObject1 = 0, const char* markedLabel1 = 0, const RenderObject* markedObject2 = 0, const char* markedLabel2 = 0, int depth = 0) const;
    231 #endif
    232 
    233     static RenderObject* createObject(Node*, RenderStyle*);
    234 
    235     // Overloaded new operator.  Derived classes must override operator new
    236     // in order to allocate out of the RenderArena.
    237     void* operator new(size_t, RenderArena*) throw();
    238 
    239     // Overridden to prevent the normal delete from being called.
    240     void operator delete(void*, size_t);
    241 
    242 private:
    243     // The normal operator new is disallowed on all render objects.
    244     void* operator new(size_t) throw();
    245 
    246 public:
    247     RenderArena* renderArena() const { return document()->renderArena(); }
    248 
    249     virtual bool isApplet() const { return false; }
    250     virtual bool isBR() const { return false; }
    251     virtual bool isBlockFlow() const { return false; }
    252     virtual bool isBoxModelObject() const { return false; }
    253     virtual bool isCounter() const { return false; }
    254     virtual bool isQuote() const { return false; }
    255     virtual bool isDetails() const { return false; }
    256     virtual bool isDetailsMarker() const { return false; }
    257     virtual bool isEmbeddedObject() const { return false; }
    258     virtual bool isFieldset() const { return false; }
    259     virtual bool isFileUploadControl() const { return false; }
    260     virtual bool isFrame() const { return false; }
    261     virtual bool isFrameSet() const { return false; }
    262     virtual bool isImage() const { return false; }
    263     virtual bool isInlineBlockOrInlineTable() const { return false; }
    264     virtual bool isListBox() const { return false; }
    265     virtual bool isListItem() const { return false; }
    266     virtual bool isListMarker() const { return false; }
    267     virtual bool isMedia() const { return false; }
    268     virtual bool isMenuList() const { return false; }
    269 #if ENABLE(METER_TAG)
    270     virtual bool isMeter() const { return false; }
    271 #endif
    272 #if ENABLE(PROGRESS_TAG)
    273     virtual bool isProgress() const { return false; }
    274 #endif
    275     virtual bool isRenderBlock() const { return false; }
    276     virtual bool isRenderButton() const { return false; }
    277     virtual bool isRenderIFrame() const { return false; }
    278     virtual bool isRenderImage() const { return false; }
    279     virtual bool isRenderInline() const { return false; }
    280     virtual bool isRenderPart() const { return false; }
    281     virtual bool isRenderView() const { return false; }
    282     virtual bool isReplica() const { return false; }
    283 
    284     virtual bool isRuby() const { return false; }
    285     virtual bool isRubyBase() const { return false; }
    286     virtual bool isRubyRun() const { return false; }
    287     virtual bool isRubyText() const { return false; }
    288 
    289     virtual bool isSlider() const { return false; }
    290     virtual bool isSummary() const { return false; }
    291     virtual bool isTable() const { return false; }
    292     virtual bool isTableCell() const { return false; }
    293     virtual bool isTableCol() const { return false; }
    294     virtual bool isTableRow() const { return false; }
    295     virtual bool isTableSection() const { return false; }
    296     virtual bool isTextControl() const { return false; }
    297     virtual bool isTextArea() const { return false; }
    298     virtual bool isTextField() const { return false; }
    299     virtual bool isVideo() const { return false; }
    300     virtual bool isWidget() const { return false; }
    301     virtual bool isCanvas() const { return false; }
    302 #if ENABLE(FULLSCREEN_API)
    303     virtual bool isRenderFullScreen() const { return false; }
    304 #endif
    305 
    306     bool isRoot() const { return document()->documentElement() == m_node; }
    307     bool isBody() const;
    308     bool isHR() const;
    309     bool isLegend() const;
    310 
    311     bool isHTMLMarquee() const;
    312 
    313     inline bool isBeforeContent() const;
    314     inline bool isAfterContent() const;
    315     static inline bool isBeforeContent(const RenderObject* obj) { return obj && obj->isBeforeContent(); }
    316     static inline bool isAfterContent(const RenderObject* obj) { return obj && obj->isAfterContent(); }
    317 
    318     bool childrenInline() const { return m_childrenInline; }
    319     void setChildrenInline(bool b = true) { m_childrenInline = b; }
    320     bool hasColumns() const { return m_hasColumns; }
    321     void setHasColumns(bool b = true) { m_hasColumns = b; }
    322 
    323     virtual bool requiresForcedStyleRecalcPropagation() const { return false; }
    324 
    325 #if ENABLE(MATHML)
    326     virtual bool isRenderMathMLBlock() const { return false; }
    327 #endif // ENABLE(MATHML)
    328 
    329 #if ENABLE(SVG)
    330     // FIXME: Until all SVG renders can be subclasses of RenderSVGModelObject we have
    331     // to add SVG renderer methods to RenderObject with an ASSERT_NOT_REACHED() default implementation.
    332     virtual bool isSVGRoot() const { return false; }
    333     virtual bool isSVGContainer() const { return false; }
    334     virtual bool isSVGViewportContainer() const { return false; }
    335     virtual bool isSVGGradientStop() const { return false; }
    336     virtual bool isSVGHiddenContainer() const { return false; }
    337     virtual bool isSVGPath() const { return false; }
    338     virtual bool isSVGText() const { return false; }
    339     virtual bool isSVGTextPath() const { return false; }
    340     virtual bool isSVGInline() const { return false; }
    341     virtual bool isSVGInlineText() const { return false; }
    342     virtual bool isSVGImage() const { return false; }
    343     virtual bool isSVGForeignObject() const { return false; }
    344     virtual bool isSVGResourceContainer() const { return false; }
    345     virtual bool isSVGResourceFilter() const { return false; }
    346     virtual bool isSVGResourceFilterPrimitive() const { return false; }
    347     virtual bool isSVGShadowTreeRootContainer() const { return false; }
    348 
    349     virtual RenderSVGResourceContainer* toRenderSVGResourceContainer();
    350 
    351     // FIXME: Those belong into a SVG specific base-class for all renderers (see above)
    352     // Unfortunately we don't have such a class yet, because it's not possible for all renderers
    353     // to inherit from RenderSVGObject -> RenderObject (some need RenderBlock inheritance for instance)
    354     virtual void setNeedsTransformUpdate() { }
    355     virtual void setNeedsBoundariesUpdate();
    356 
    357     // Per SVG 1.1 objectBoundingBox ignores clipping, masking, filter effects, opacity and stroke-width.
    358     // This is used for all computation of objectBoundingBox relative units and by SVGLocateable::getBBox().
    359     // NOTE: Markers are not specifically ignored here by SVG 1.1 spec, but we ignore them
    360     // since stroke-width is ignored (and marker size can depend on stroke-width).
    361     // objectBoundingBox is returned local coordinates.
    362     // The name objectBoundingBox is taken from the SVG 1.1 spec.
    363     virtual FloatRect objectBoundingBox() const;
    364     virtual FloatRect strokeBoundingBox() const;
    365 
    366     // Returns the smallest rectangle enclosing all of the painted content
    367     // respecting clipping, masking, filters, opacity, stroke-width and markers
    368     virtual FloatRect repaintRectInLocalCoordinates() const;
    369 
    370     // This only returns the transform="" value from the element
    371     // most callsites want localToParentTransform() instead.
    372     virtual AffineTransform localTransform() const;
    373 
    374     // Returns the full transform mapping from local coordinates to local coords for the parent SVG renderer
    375     // This includes any viewport transforms and x/y offsets as well as the transform="" value off the element.
    376     virtual const AffineTransform& localToParentTransform() const;
    377 
    378     // SVG uses FloatPoint precise hit testing, and passes the point in parent
    379     // coordinates instead of in repaint container coordinates.  Eventually the
    380     // rest of the rendering tree will move to a similar model.
    381     virtual bool nodeAtFloatPoint(const HitTestRequest&, HitTestResult&, const FloatPoint& pointInParent, HitTestAction);
    382 #endif
    383 
    384     bool isAnonymous() const { return m_isAnonymous; }
    385     void setIsAnonymous(bool b) { m_isAnonymous = b; }
    386     bool isAnonymousBlock() const
    387     {
    388         // This function is kept in sync with anonymous block creation conditions in
    389         // RenderBlock::createAnonymousBlock(). This includes creating an anonymous
    390         // RenderBlock having a BLOCK or BOX display. Other classes such as RenderTextFragment
    391         // are not RenderBlocks and will return false. See https://bugs.webkit.org/show_bug.cgi?id=56709.
    392         return m_isAnonymous && (style()->display() == BLOCK || style()->display() == BOX) && style()->styleType() == NOPSEUDO && isRenderBlock() && !isListMarker();
    393     }
    394     bool isAnonymousColumnsBlock() const { return style()->specifiesColumns() && isAnonymousBlock(); }
    395     bool isAnonymousColumnSpanBlock() const { return style()->columnSpan() && isAnonymousBlock(); }
    396     bool isElementContinuation() const { return node() && node()->renderer() != this; }
    397     bool isInlineElementContinuation() const { return isElementContinuation() && isInline(); }
    398     bool isBlockElementContinuation() const { return isElementContinuation() && !isInline(); }
    399     virtual RenderBoxModelObject* virtualContinuation() const { return 0; }
    400 
    401     bool isFloating() const { return m_floating; }
    402     bool isPositioned() const { return m_positioned; } // absolute or fixed positioning
    403     bool isRelPositioned() const { return m_relPositioned; } // relative positioning
    404     bool isText() const  { return m_isText; }
    405     bool isBox() const { return m_isBox; }
    406     bool isInline() const { return m_inline; }  // inline object
    407     bool isRunIn() const { return style()->display() == RUN_IN; } // run-in object
    408     bool isDragging() const { return m_isDragging; }
    409     bool isReplaced() const { return m_replaced; } // a "replaced" element (see CSS)
    410     bool isHorizontalWritingMode() const { return m_horizontalWritingMode; }
    411 
    412     bool hasLayer() const { return m_hasLayer; }
    413 
    414     bool hasBoxDecorations() const { return m_paintBackground; }
    415     bool mustRepaintBackgroundOrBorder() const;
    416     bool hasBackground() const { return style()->hasBackground(); }
    417     bool needsLayout() const { return m_needsLayout || m_normalChildNeedsLayout || m_posChildNeedsLayout || m_needsSimplifiedNormalFlowLayout || m_needsPositionedMovementLayout; }
    418     bool selfNeedsLayout() const { return m_needsLayout; }
    419     bool needsPositionedMovementLayout() const { return m_needsPositionedMovementLayout; }
    420     bool needsPositionedMovementLayoutOnly() const { return m_needsPositionedMovementLayout && !m_needsLayout && !m_normalChildNeedsLayout && !m_posChildNeedsLayout && !m_needsSimplifiedNormalFlowLayout; }
    421     bool posChildNeedsLayout() const { return m_posChildNeedsLayout; }
    422     bool needsSimplifiedNormalFlowLayout() const { return m_needsSimplifiedNormalFlowLayout; }
    423     bool normalChildNeedsLayout() const { return m_normalChildNeedsLayout; }
    424 
    425     bool preferredLogicalWidthsDirty() const { return m_preferredLogicalWidthsDirty; }
    426 
    427     bool isSelectionBorder() const;
    428 
    429     bool hasClip() const { return isPositioned() && style()->hasClip(); }
    430     bool hasOverflowClip() const { return m_hasOverflowClip; }
    431 
    432     bool hasTransform() const { return m_hasTransform; }
    433     bool hasMask() const { return style() && style()->hasMask(); }
    434 
    435     inline bool preservesNewline() const;
    436 
    437 #if !HAVE(PATH_BASED_BORDER_RADIUS_DRAWING)
    438     // FIXME: This function should be removed when all ports implement GraphicsContext::clipConvexPolygon()!!
    439     // At that time, everyone can use RenderObject::drawBoxSideFromPath() instead. This should happen soon.
    440     void drawArcForBoxSide(GraphicsContext*, int x, int y, float thickness, const IntSize& radius, int angleStart,
    441                            int angleSpan, BoxSide, Color, EBorderStyle, bool firstCorner);
    442 #endif
    443 
    444     IntRect borderInnerRect(const IntRect&, unsigned short topWidth, unsigned short bottomWidth,
    445                             unsigned short leftWidth, unsigned short rightWidth) const;
    446 
    447     // The pseudo element style can be cached or uncached.  Use the cached method if the pseudo element doesn't respect
    448     // any pseudo classes (and therefore has no concept of changing state).
    449     RenderStyle* getCachedPseudoStyle(PseudoId, RenderStyle* parentStyle = 0) const;
    450     PassRefPtr<RenderStyle> getUncachedPseudoStyle(PseudoId, RenderStyle* parentStyle = 0, RenderStyle* ownStyle = 0) const;
    451 
    452     virtual void updateDragState(bool dragOn);
    453 
    454     RenderView* view() const;
    455 
    456     // Returns true if this renderer is rooted, and optionally returns the hosting view (the root of the hierarchy).
    457     bool isRooted(RenderView** = 0);
    458 
    459     Node* node() const { return m_isAnonymous ? 0 : m_node; }
    460 
    461     // Returns the styled node that caused the generation of this renderer.
    462     // This is the same as node() except for renderers of :before and :after
    463     // pseudo elements for which their parent node is returned.
    464     Node* generatingNode() const { return m_node == document() ? 0 : m_node; }
    465     void setNode(Node* node) { m_node = node; }
    466 
    467     Document* document() const { return m_node->document(); }
    468     Frame* frame() const { return document()->frame(); }
    469 
    470     bool hasOutlineAnnotation() const;
    471     bool hasOutline() const { return style()->hasOutline() || hasOutlineAnnotation(); }
    472 
    473     // Returns the object containing this one. Can be different from parent for positioned elements.
    474     // If repaintContainer and repaintContainerSkipped are not null, on return *repaintContainerSkipped
    475     // is true if the renderer returned is an ancestor of repaintContainer.
    476     RenderObject* container(RenderBoxModelObject* repaintContainer = 0, bool* repaintContainerSkipped = 0) const;
    477 
    478     virtual RenderObject* hoverAncestor() const { return parent(); }
    479 
    480     // IE Extension that can be called on any RenderObject.  See the implementation for the details.
    481     RenderBoxModelObject* offsetParent() const;
    482 
    483     void markContainingBlocksForLayout(bool scheduleRelayout = true, RenderObject* newRoot = 0);
    484     void setNeedsLayout(bool b, bool markParents = true);
    485     void setChildNeedsLayout(bool b, bool markParents = true);
    486     void setNeedsPositionedMovementLayout();
    487     void setNeedsSimplifiedNormalFlowLayout();
    488     void setPreferredLogicalWidthsDirty(bool, bool markParents = true);
    489     void invalidateContainerPreferredLogicalWidths();
    490 
    491     void setNeedsLayoutAndPrefWidthsRecalc()
    492     {
    493         setNeedsLayout(true);
    494         setPreferredLogicalWidthsDirty(true);
    495     }
    496 
    497     void setPositioned(bool b = true)  { m_positioned = b;  }
    498     void setRelPositioned(bool b = true) { m_relPositioned = b; }
    499     void setFloating(bool b = true) { m_floating = b; }
    500     void setInline(bool b = true) { m_inline = b; }
    501     void setHasBoxDecorations(bool b = true) { m_paintBackground = b; }
    502     void setIsText() { m_isText = true; }
    503     void setIsBox() { m_isBox = true; }
    504     void setReplaced(bool b = true) { m_replaced = b; }
    505     void setHorizontalWritingMode(bool b = true) { m_horizontalWritingMode = b; }
    506     void setHasOverflowClip(bool b = true) { m_hasOverflowClip = b; }
    507     void setHasLayer(bool b = true) { m_hasLayer = b; }
    508     void setHasTransform(bool b = true) { m_hasTransform = b; }
    509     void setHasReflection(bool b = true) { m_hasReflection = b; }
    510 
    511     void scheduleRelayout();
    512 
    513     void updateFillImages(const FillLayer*, const FillLayer*);
    514     void updateImage(StyleImage*, StyleImage*);
    515 
    516     virtual void paint(PaintInfo&, int tx, int ty);
    517 
    518     // Recursive function that computes the size and position of this object and all its descendants.
    519     virtual void layout();
    520 
    521     /* This function performs a layout only if one is needed. */
    522     void layoutIfNeeded() { if (needsLayout()) layout(); }
    523 
    524     // used for element state updates that cannot be fixed with a
    525     // repaint and do not need a relayout
    526     virtual void updateFromElement() { }
    527 
    528 #if ENABLE(DASHBOARD_SUPPORT)
    529     virtual void addDashboardRegions(Vector<DashboardRegionValue>&);
    530     void collectDashboardRegions(Vector<DashboardRegionValue>&);
    531 #endif
    532 
    533     bool hitTest(const HitTestRequest&, HitTestResult&, const IntPoint&, int tx, int ty, HitTestFilter = HitTestAll);
    534     virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction);
    535     virtual void updateHitTestResult(HitTestResult&, const IntPoint&);
    536 
    537     VisiblePosition positionForCoordinates(int x, int y);
    538     virtual VisiblePosition positionForPoint(const IntPoint&);
    539     VisiblePosition createVisiblePosition(int offset, EAffinity);
    540     VisiblePosition createVisiblePosition(const Position&);
    541 
    542     virtual void dirtyLinesFromChangedChild(RenderObject*);
    543 
    544     // Called to update a style that is allowed to trigger animations.
    545     // FIXME: Right now this will typically be called only when updating happens from the DOM on explicit elements.
    546     // We don't yet handle generated content animation such as first-letter or before/after (we'll worry about this later).
    547     void setAnimatableStyle(PassRefPtr<RenderStyle>);
    548 
    549     // Set the style of the object and update the state of the object accordingly.
    550     virtual void setStyle(PassRefPtr<RenderStyle>);
    551 
    552     // Updates only the local style ptr of the object.  Does not update the state of the object,
    553     // and so only should be called when the style is known not to have changed (or from setStyle).
    554     void setStyleInternal(PassRefPtr<RenderStyle>);
    555 
    556     // returns the containing block level element for this element.
    557     RenderBlock* containingBlock() const;
    558 
    559     // Convert the given local point to absolute coordinates
    560     // FIXME: Temporary. If useTransforms is true, take transforms into account. Eventually localToAbsolute() will always be transform-aware.
    561     FloatPoint localToAbsolute(const FloatPoint& localPoint = FloatPoint(), bool fixed = false, bool useTransforms = false) const;
    562     FloatPoint absoluteToLocal(const FloatPoint&, bool fixed = false, bool useTransforms = false) const;
    563 
    564     // Convert a local quad to absolute coordinates, taking transforms into account.
    565     FloatQuad localToAbsoluteQuad(const FloatQuad& quad, bool fixed = false) const
    566     {
    567         return localToContainerQuad(quad, 0, fixed);
    568     }
    569     // Convert a local quad into the coordinate system of container, taking transforms into account.
    570     FloatQuad localToContainerQuad(const FloatQuad&, RenderBoxModelObject* repaintContainer, bool fixed = false) const;
    571 
    572     // Return the offset from the container() renderer (excluding transforms). In multi-column layout,
    573     // different offsets apply at different points, so return the offset that applies to the given point.
    574     virtual IntSize offsetFromContainer(RenderObject*, const IntPoint&) const;
    575     // Return the offset from an object up the container() chain. Asserts that none of the intermediate objects have transforms.
    576     IntSize offsetFromAncestorContainer(RenderObject*) const;
    577 
    578     virtual void absoluteRects(Vector<IntRect>&, int, int) { }
    579     // FIXME: useTransforms should go away eventually
    580     IntRect absoluteBoundingBoxRect(bool useTransforms = false);
    581 
    582     // Build an array of quads in absolute coords for line boxes
    583     virtual void absoluteQuads(Vector<FloatQuad>&) { }
    584 
    585     void absoluteFocusRingQuads(Vector<FloatQuad>&);
    586 
    587     // the rect that will be painted if this object is passed as the paintingRoot
    588     IntRect paintingRootRect(IntRect& topLevelRect);
    589 
    590     virtual int minPreferredLogicalWidth() const { return 0; }
    591     virtual int maxPreferredLogicalWidth() const { return 0; }
    592 
    593     RenderStyle* style() const { return m_style.get(); }
    594     RenderStyle* firstLineStyle() const { return document()->usesFirstLineRules() ? firstLineStyleSlowCase() : style(); }
    595     RenderStyle* style(bool firstLine) const { return firstLine ? firstLineStyle() : style(); }
    596 
    597     // Used only by Element::pseudoStyleCacheIsInvalid to get a first line style based off of a
    598     // given new style, without accessing the cache.
    599     PassRefPtr<RenderStyle> uncachedFirstLineStyle(RenderStyle*) const;
    600 
    601     // Anonymous blocks that are part of of a continuation chain will return their inline continuation's outline style instead.
    602     // This is typically only relevant when repainting.
    603     virtual RenderStyle* outlineStyleForRepaint() const { return style(); }
    604 
    605     void getTextDecorationColors(int decorations, Color& underline, Color& overline,
    606                                  Color& linethrough, bool quirksMode = false);
    607 
    608     // Return the RenderBox in the container chain which is responsible for painting this object, or 0
    609     // if painting is root-relative. This is the container that should be passed to the 'forRepaint'
    610     // methods.
    611     RenderBoxModelObject* containerForRepaint() const;
    612     // Actually do the repaint of rect r for this object which has been computed in the coordinate space
    613     // of repaintContainer. If repaintContainer is 0, repaint via the view.
    614     void repaintUsingContainer(RenderBoxModelObject* repaintContainer, const IntRect& r, bool immediate = false);
    615 
    616     // Repaint the entire object.  Called when, e.g., the color of a border changes, or when a border
    617     // style changes.
    618     void repaint(bool immediate = false);
    619 
    620     // Repaint a specific subrectangle within a given object.  The rect |r| is in the object's coordinate space.
    621     void repaintRectangle(const IntRect&, bool immediate = false);
    622 
    623     // Repaint only if our old bounds and new bounds are different. The caller may pass in newBounds and newOutlineBox if they are known.
    624     bool repaintAfterLayoutIfNeeded(RenderBoxModelObject* repaintContainer, const IntRect& oldBounds, const IntRect& oldOutlineBox, const IntRect* newBoundsPtr = 0, const IntRect* newOutlineBoxPtr = 0);
    625 
    626     // Repaint only if the object moved.
    627     virtual void repaintDuringLayoutIfMoved(const IntRect& rect);
    628 
    629     // Called to repaint a block's floats.
    630     virtual void repaintOverhangingFloats(bool paintAllDescendants = false);
    631 
    632     bool checkForRepaintDuringLayout() const;
    633 
    634     // Returns the rect that should be repainted whenever this object changes.  The rect is in the view's
    635     // coordinate space.  This method deals with outlines and overflow.
    636     IntRect absoluteClippedOverflowRect()
    637     {
    638         return clippedOverflowRectForRepaint(0);
    639     }
    640     virtual IntRect clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer);
    641     virtual IntRect rectWithOutlineForRepaint(RenderBoxModelObject* repaintContainer, int outlineWidth);
    642 
    643     // Given a rect in the object's coordinate space, compute a rect suitable for repainting
    644     // that rect in view coordinates.
    645     void computeAbsoluteRepaintRect(IntRect& r, bool fixed = false)
    646     {
    647         return computeRectForRepaint(0, r, fixed);
    648     }
    649     // Given a rect in the object's coordinate space, compute a rect suitable for repainting
    650     // that rect in the coordinate space of repaintContainer.
    651     virtual void computeRectForRepaint(RenderBoxModelObject* repaintContainer, IntRect&, bool fixed = false);
    652 
    653     // If multiple-column layout results in applying an offset to the given point, add the same
    654     // offset to the given size.
    655     virtual void adjustForColumns(IntSize&, const IntPoint&) const { }
    656 
    657     virtual unsigned int length() const { return 1; }
    658 
    659     bool isFloatingOrPositioned() const { return (isFloating() || isPositioned()); }
    660 
    661     bool isTransparent() const { return style()->opacity() < 1.0f; }
    662     float opacity() const { return style()->opacity(); }
    663 
    664     bool hasReflection() const { return m_hasReflection; }
    665 
    666     // Applied as a "slop" to dirty rect checks during the outline painting phase's dirty-rect checks.
    667     int maximalOutlineSize(PaintPhase) const;
    668 
    669     void setHasMarkupTruncation(bool b = true) { m_hasMarkupTruncation = b; }
    670     bool hasMarkupTruncation() const { return m_hasMarkupTruncation; }
    671 
    672     enum SelectionState {
    673         SelectionNone, // The object is not selected.
    674         SelectionStart, // The object either contains the start of a selection run or is the start of a run
    675         SelectionInside, // The object is fully encompassed by a selection run
    676         SelectionEnd, // The object either contains the end of a selection run or is the end of a run
    677         SelectionBoth // The object contains an entire run or is the sole selected object in that run
    678     };
    679 
    680     // The current selection state for an object.  For blocks, the state refers to the state of the leaf
    681     // descendants (as described above in the SelectionState enum declaration).
    682     SelectionState selectionState() const { return static_cast<SelectionState>(m_selectionState);; }
    683 
    684     // Sets the selection state for an object.
    685     virtual void setSelectionState(SelectionState state) { m_selectionState = state; }
    686 
    687     // A single rectangle that encompasses all of the selected objects within this object.  Used to determine the tightest
    688     // possible bounding box for the selection.
    689     IntRect selectionRect(bool clipToVisibleContent = true) { return selectionRectForRepaint(0, clipToVisibleContent); }
    690     virtual IntRect selectionRectForRepaint(RenderBoxModelObject* /*repaintContainer*/, bool /*clipToVisibleContent*/ = true) { return IntRect(); }
    691 
    692     // Whether or not an object can be part of the leaf elements of the selection.
    693     virtual bool canBeSelectionLeaf() const { return false; }
    694 
    695     // Whether or not a block has selected children.
    696     bool hasSelectedChildren() const { return m_selectionState != SelectionNone; }
    697 
    698     // Obtains the selection colors that should be used when painting a selection.
    699     Color selectionBackgroundColor() const;
    700     Color selectionForegroundColor() const;
    701     Color selectionEmphasisMarkColor() const;
    702 
    703     // Whether or not a given block needs to paint selection gaps.
    704     virtual bool shouldPaintSelectionGaps() const { return false; }
    705 
    706 #if ENABLE(DRAG_SUPPORT)
    707     Node* draggableNode(bool dhtmlOK, bool uaOK, int x, int y, bool& dhtmlWillDrag) const;
    708 #endif
    709 
    710     /**
    711      * Returns the local coordinates of the caret within this render object.
    712      * @param caretOffset zero-based offset determining position within the render object.
    713      * @param extraWidthToEndOfLine optional out arg to give extra width to end of line -
    714      * useful for character range rect computations
    715      */
    716     virtual IntRect localCaretRect(InlineBox*, int caretOffset, int* extraWidthToEndOfLine = 0);
    717 
    718     bool isMarginBeforeQuirk() const { return m_marginBeforeQuirk; }
    719     bool isMarginAfterQuirk() const { return m_marginAfterQuirk; }
    720     void setMarginBeforeQuirk(bool b = true) { m_marginBeforeQuirk = b; }
    721     void setMarginAfterQuirk(bool b = true) { m_marginAfterQuirk = b; }
    722 
    723     // When performing a global document tear-down, the renderer of the document is cleared.  We use this
    724     // as a hook to detect the case of document destruction and don't waste time doing unnecessary work.
    725     bool documentBeingDestroyed() const;
    726 
    727     virtual void destroy();
    728 
    729     // Virtual function helpers for CSS3 Flexible Box Layout
    730     virtual bool isFlexibleBox() const { return false; }
    731     virtual bool isFlexingChildren() const { return false; }
    732     virtual bool isStretchingChildren() const { return false; }
    733 
    734     virtual bool isCombineText() const { return false; }
    735 
    736     virtual int caretMinOffset() const;
    737     virtual int caretMaxOffset() const;
    738     virtual unsigned caretMaxRenderedOffset() const;
    739 
    740     virtual int previousOffset(int current) const;
    741     virtual int previousOffsetForBackwardDeletion(int current) const;
    742     virtual int nextOffset(int current) const;
    743 
    744     virtual void imageChanged(CachedImage*, const IntRect* = 0);
    745     virtual void imageChanged(WrappedImagePtr, const IntRect* = 0) { }
    746     virtual bool willRenderImage(CachedImage*);
    747 
    748     void selectionStartEnd(int& spos, int& epos) const;
    749 
    750     bool hasOverrideSize() const { return m_hasOverrideSize; }
    751     void setHasOverrideSize(bool b) { m_hasOverrideSize = b; }
    752 
    753     void remove() { if (parent()) parent()->removeChild(this); }
    754 
    755     AnimationController* animation() const;
    756 
    757     bool visibleToHitTesting() const { return style()->visibility() == VISIBLE && style()->pointerEvents() != PE_NONE; }
    758 
    759     // Map points and quads through elements, potentially via 3d transforms. You should never need to call these directly; use
    760     // localToAbsolute/absoluteToLocal methods instead.
    761     virtual void mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool useTransforms, bool fixed, TransformState&) const;
    762     virtual void mapAbsoluteToLocalPoint(bool fixed, bool useTransforms, TransformState&) const;
    763 
    764     bool shouldUseTransformFromContainer(const RenderObject* container) const;
    765     void getTransformFromContainer(const RenderObject* container, const IntSize& offsetInContainer, TransformationMatrix&) const;
    766 
    767     virtual void addFocusRingRects(Vector<IntRect>&, int /*tx*/, int /*ty*/) { };
    768 
    769     IntRect absoluteOutlineBounds() const
    770     {
    771         return outlineBoundsForRepaint(0);
    772     }
    773 
    774 protected:
    775     // Overrides should call the superclass at the end
    776     virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle);
    777     // Overrides should call the superclass at the start
    778     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
    779 
    780     void drawLineForBoxSide(GraphicsContext*, int x1, int y1, int x2, int y2, BoxSide,
    781                             Color, EBorderStyle, int adjbw1, int adjbw2, bool antialias = false);
    782 
    783     void paintFocusRing(GraphicsContext*, int tx, int ty, RenderStyle*);
    784     void paintOutline(GraphicsContext*, int tx, int ty, int w, int h);
    785     void addPDFURLRect(GraphicsContext*, const IntRect&);
    786 
    787     virtual IntRect viewRect() const;
    788 
    789     void adjustRectForOutlineAndShadow(IntRect&) const;
    790 
    791     void arenaDelete(RenderArena*, void* objectBase);
    792 
    793     virtual IntRect outlineBoundsForRepaint(RenderBoxModelObject* /*repaintContainer*/, IntPoint* /*cachedOffsetToRepaintContainer*/ = 0) const { return IntRect(); }
    794 
    795     class LayoutRepainter {
    796     public:
    797         LayoutRepainter(RenderObject& object, bool checkForRepaint, const IntRect* oldBounds = 0)
    798             : m_object(object)
    799             , m_repaintContainer(0)
    800             , m_checkForRepaint(checkForRepaint)
    801         {
    802             if (m_checkForRepaint) {
    803                 m_repaintContainer = m_object.containerForRepaint();
    804                 m_oldBounds = oldBounds ? *oldBounds : m_object.clippedOverflowRectForRepaint(m_repaintContainer);
    805                 m_oldOutlineBox = m_object.outlineBoundsForRepaint(m_repaintContainer);
    806             }
    807         }
    808 
    809         // Return true if it repainted.
    810         bool repaintAfterLayout()
    811         {
    812             return m_checkForRepaint ? m_object.repaintAfterLayoutIfNeeded(m_repaintContainer, m_oldBounds, m_oldOutlineBox) : false;
    813         }
    814 
    815         bool checkForRepaint() const { return m_checkForRepaint; }
    816 
    817     private:
    818         RenderObject& m_object;
    819         RenderBoxModelObject* m_repaintContainer;
    820         IntRect m_oldBounds;
    821         IntRect m_oldOutlineBox;
    822         bool m_checkForRepaint;
    823     };
    824 
    825 private:
    826     RenderStyle* firstLineStyleSlowCase() const;
    827     StyleDifference adjustStyleDifference(StyleDifference, unsigned contextSensitiveProperties) const;
    828 
    829     Color selectionColor(int colorProperty) const;
    830 
    831     RefPtr<RenderStyle> m_style;
    832 
    833     Node* m_node;
    834 
    835     RenderObject* m_parent;
    836     RenderObject* m_previous;
    837     RenderObject* m_next;
    838 
    839 #ifndef NDEBUG
    840     bool m_hasAXObject;
    841     bool m_setNeedsLayoutForbidden : 1;
    842 #endif
    843 
    844     // 32 bits have been used here. THERE ARE NO FREE BITS AVAILABLE.
    845     bool m_needsLayout               : 1;
    846     bool m_needsPositionedMovementLayout :1;
    847     bool m_normalChildNeedsLayout    : 1;
    848     bool m_posChildNeedsLayout       : 1;
    849     bool m_needsSimplifiedNormalFlowLayout  : 1;
    850     bool m_preferredLogicalWidthsDirty           : 1;
    851     bool m_floating                  : 1;
    852 
    853     bool m_positioned                : 1;
    854     bool m_relPositioned             : 1;
    855     bool m_paintBackground           : 1; // if the box has something to paint in the
    856                                           // background painting phase (background, border, etc)
    857 
    858     bool m_isAnonymous               : 1;
    859     bool m_isText                    : 1;
    860     bool m_isBox                     : 1;
    861     bool m_inline                    : 1;
    862     bool m_replaced                  : 1;
    863     bool m_horizontalWritingMode : 1;
    864     bool m_isDragging                : 1;
    865 
    866     bool m_hasLayer                  : 1;
    867     bool m_hasOverflowClip           : 1; // Set in the case of overflow:auto/scroll/hidden
    868     bool m_hasTransform              : 1;
    869     bool m_hasReflection             : 1;
    870 
    871     bool m_hasOverrideSize           : 1;
    872 
    873 public:
    874     bool m_hasCounterNodeMap         : 1;
    875     bool m_everHadLayout             : 1;
    876 
    877 private:
    878     // These bitfields are moved here from subclasses to pack them together
    879     // from RenderBlock
    880     bool m_childrenInline : 1;
    881     bool m_marginBeforeQuirk : 1;
    882     bool m_marginAfterQuirk : 1;
    883     bool m_hasMarkupTruncation : 1;
    884     unsigned m_selectionState : 3; // SelectionState
    885     bool m_hasColumns : 1;
    886 
    887     // from RenderTableCell
    888     bool m_cellWidthChanged : 1;
    889 
    890 private:
    891     // Store state between styleWillChange and styleDidChange
    892     static bool s_affectsParentBlock;
    893 };
    894 
    895 inline bool RenderObject::documentBeingDestroyed() const
    896 {
    897     return !document()->renderer();
    898 }
    899 
    900 inline bool RenderObject::isBeforeContent() const
    901 {
    902     if (style()->styleType() != BEFORE)
    903         return false;
    904     // Text nodes don't have their own styles, so ignore the style on a text node.
    905     if (isText() && !isBR())
    906         return false;
    907     return true;
    908 }
    909 
    910 inline bool RenderObject::isAfterContent() const
    911 {
    912     if (style()->styleType() != AFTER)
    913         return false;
    914     // Text nodes don't have their own styles, so ignore the style on a text node.
    915     if (isText() && !isBR())
    916         return false;
    917     return true;
    918 }
    919 
    920 inline void RenderObject::setNeedsLayout(bool b, bool markParents)
    921 {
    922     bool alreadyNeededLayout = m_needsLayout;
    923     m_needsLayout = b;
    924     if (b) {
    925         ASSERT(!isSetNeedsLayoutForbidden());
    926         if (!alreadyNeededLayout) {
    927             if (markParents)
    928                 markContainingBlocksForLayout();
    929             if (hasLayer())
    930                 setLayerNeedsFullRepaint();
    931         }
    932     } else {
    933         m_everHadLayout = true;
    934         m_posChildNeedsLayout = false;
    935         m_needsSimplifiedNormalFlowLayout = false;
    936         m_normalChildNeedsLayout = false;
    937         m_needsPositionedMovementLayout = false;
    938     }
    939 }
    940 
    941 inline void RenderObject::setChildNeedsLayout(bool b, bool markParents)
    942 {
    943     bool alreadyNeededLayout = m_normalChildNeedsLayout;
    944     m_normalChildNeedsLayout = b;
    945     if (b) {
    946         ASSERT(!isSetNeedsLayoutForbidden());
    947         if (!alreadyNeededLayout && markParents)
    948             markContainingBlocksForLayout();
    949     } else {
    950         m_posChildNeedsLayout = false;
    951         m_needsSimplifiedNormalFlowLayout = false;
    952         m_normalChildNeedsLayout = false;
    953         m_needsPositionedMovementLayout = false;
    954     }
    955 }
    956 
    957 inline void RenderObject::setNeedsPositionedMovementLayout()
    958 {
    959     bool alreadyNeededLayout = m_needsPositionedMovementLayout;
    960     m_needsPositionedMovementLayout = true;
    961     ASSERT(!isSetNeedsLayoutForbidden());
    962     if (!alreadyNeededLayout) {
    963         markContainingBlocksForLayout();
    964         if (hasLayer())
    965             setLayerNeedsFullRepaint();
    966     }
    967 }
    968 
    969 inline void RenderObject::setNeedsSimplifiedNormalFlowLayout()
    970 {
    971     bool alreadyNeededLayout = m_needsSimplifiedNormalFlowLayout;
    972     m_needsSimplifiedNormalFlowLayout = true;
    973     ASSERT(!isSetNeedsLayoutForbidden());
    974     if (!alreadyNeededLayout) {
    975         markContainingBlocksForLayout();
    976         if (hasLayer())
    977             setLayerNeedsFullRepaint();
    978     }
    979 }
    980 
    981 inline bool objectIsRelayoutBoundary(const RenderObject *obj)
    982 {
    983     // FIXME: In future it may be possible to broaden this condition in order to improve performance.
    984     // Table cells are excluded because even when their CSS height is fixed, their height()
    985     // may depend on their contents.
    986     return obj->isTextControl()
    987         || (obj->hasOverflowClip() && !obj->style()->width().isIntrinsicOrAuto() && !obj->style()->height().isIntrinsicOrAuto() && !obj->style()->height().isPercent() && !obj->isTableCell())
    988 #if ENABLE(SVG)
    989            || obj->isSVGRoot()
    990 #endif
    991            ;
    992 }
    993 
    994 inline void RenderObject::markContainingBlocksForLayout(bool scheduleRelayout, RenderObject* newRoot)
    995 {
    996     ASSERT(!scheduleRelayout || !newRoot);
    997 
    998     RenderObject* o = container();
    999     RenderObject* last = this;
   1000 
   1001     bool simplifiedNormalFlowLayout = needsSimplifiedNormalFlowLayout() && !selfNeedsLayout() && !normalChildNeedsLayout();
   1002 
   1003     while (o) {
   1004         // Don't mark the outermost object of an unrooted subtree. That object will be
   1005         // marked when the subtree is added to the document.
   1006         RenderObject* container = o->container();
   1007         if (!container && !o->isRenderView())
   1008             return;
   1009         if (!last->isText() && (last->style()->position() == FixedPosition || last->style()->position() == AbsolutePosition)) {
   1010             while (o && !o->isRenderBlock()) // Skip relatively positioned inlines and get to the enclosing RenderBlock.
   1011                 o = o->container();
   1012             if (!o || o->m_posChildNeedsLayout)
   1013                 return;
   1014             o->m_posChildNeedsLayout = true;
   1015             simplifiedNormalFlowLayout = true;
   1016             ASSERT(!o->isSetNeedsLayoutForbidden());
   1017         } else if (simplifiedNormalFlowLayout) {
   1018             if (o->m_needsSimplifiedNormalFlowLayout)
   1019                 return;
   1020             o->m_needsSimplifiedNormalFlowLayout = true;
   1021             ASSERT(!o->isSetNeedsLayoutForbidden());
   1022         } else {
   1023             if (o->m_normalChildNeedsLayout)
   1024                 return;
   1025             o->m_normalChildNeedsLayout = true;
   1026             ASSERT(!o->isSetNeedsLayoutForbidden());
   1027         }
   1028 
   1029         if (o == newRoot)
   1030             return;
   1031 
   1032         last = o;
   1033         if (scheduleRelayout && objectIsRelayoutBoundary(last))
   1034             break;
   1035         o = container;
   1036     }
   1037 
   1038     if (scheduleRelayout)
   1039         last->scheduleRelayout();
   1040 }
   1041 
   1042 inline bool RenderObject::preservesNewline() const
   1043 {
   1044 #if ENABLE(SVG)
   1045     if (isSVGInlineText())
   1046         return false;
   1047 #endif
   1048 
   1049     return style()->preserveNewline();
   1050 }
   1051 
   1052 inline void makeMatrixRenderable(TransformationMatrix& matrix, bool has3DRendering)
   1053 {
   1054 #if !ENABLE(3D_RENDERING)
   1055     UNUSED_PARAM(has3DRendering);
   1056     matrix.makeAffine();
   1057 #else
   1058     if (!has3DRendering)
   1059         matrix.makeAffine();
   1060 #endif
   1061 }
   1062 
   1063 inline int adjustForAbsoluteZoom(int value, RenderObject* renderer)
   1064 {
   1065     return adjustForAbsoluteZoom(value, renderer->style());
   1066 }
   1067 
   1068 inline FloatPoint adjustFloatPointForAbsoluteZoom(const FloatPoint& point, RenderObject* renderer)
   1069 {
   1070     // The result here is in floats, so we don't need the truncation hack from the integer version above.
   1071     float zoomFactor = renderer->style()->effectiveZoom();
   1072     if (zoomFactor == 1)
   1073         return point;
   1074     return FloatPoint(point.x() / zoomFactor, point.y() / zoomFactor);
   1075 }
   1076 
   1077 inline void adjustFloatQuadForAbsoluteZoom(FloatQuad& quad, RenderObject* renderer)
   1078 {
   1079     quad.setP1(adjustFloatPointForAbsoluteZoom(quad.p1(), renderer));
   1080     quad.setP2(adjustFloatPointForAbsoluteZoom(quad.p2(), renderer));
   1081     quad.setP3(adjustFloatPointForAbsoluteZoom(quad.p3(), renderer));
   1082     quad.setP4(adjustFloatPointForAbsoluteZoom(quad.p4(), renderer));
   1083 }
   1084 
   1085 inline void adjustFloatRectForAbsoluteZoom(FloatRect& rect, RenderObject* renderer)
   1086 {
   1087     RenderStyle* style = renderer->style();
   1088     rect.setX(adjustFloatForAbsoluteZoom(rect.x(), style));
   1089     rect.setY(adjustFloatForAbsoluteZoom(rect.y(), style));
   1090     rect.setWidth(adjustFloatForAbsoluteZoom(rect.width(), style));
   1091     rect.setHeight(adjustFloatForAbsoluteZoom(rect.height(), style));
   1092 }
   1093 
   1094 inline FloatPoint adjustFloatPointForPageScale(const FloatPoint& point, float pageScale)
   1095 {
   1096     if (pageScale == 1)
   1097         return point;
   1098     return FloatPoint(point.x() / pageScale, point.y() / pageScale);
   1099 }
   1100 
   1101 inline void adjustFloatQuadForPageScale(FloatQuad& quad, float pageScale)
   1102 {
   1103     if (pageScale == 1)
   1104         return;
   1105     quad.setP1(adjustFloatPointForPageScale(quad.p1(), pageScale));
   1106     quad.setP2(adjustFloatPointForPageScale(quad.p2(), pageScale));
   1107     quad.setP3(adjustFloatPointForPageScale(quad.p3(), pageScale));
   1108     quad.setP4(adjustFloatPointForPageScale(quad.p4(), pageScale));
   1109 }
   1110 
   1111 inline void adjustFloatRectForPageScale(FloatRect& rect, float pageScale)
   1112 {
   1113     if (pageScale == 1)
   1114         return;
   1115     rect.setX(rect.x() / pageScale);
   1116     rect.setY(rect.y() / pageScale);
   1117     rect.setWidth(rect.width() / pageScale);
   1118     rect.setHeight(rect.height() / pageScale);
   1119 }
   1120 
   1121 } // namespace WebCore
   1122 
   1123 #ifndef NDEBUG
   1124 // Outside the WebCore namespace for ease of invocation from gdb.
   1125 void showTree(const WebCore::RenderObject*);
   1126 void showRenderTree(const WebCore::RenderObject* object1);
   1127 // We don't make object2 an optional parameter so that showRenderTree
   1128 // can be called from gdb easily.
   1129 void showRenderTree(const WebCore::RenderObject* object1, const WebCore::RenderObject* object2);
   1130 #endif
   1131 
   1132 #endif // RenderObject_h
   1133