1/*
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
3 *           (C) 2000 Antti Koivisto (koivisto@kde.org)
4 *           (C) 2000 Dirk Mueller (mueller@kde.org)
5 *           (C) 2004 Allan Sandfeld Jensen (kde@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
44namespace WebCore {
45
46class AffineTransform;
47class AnimationController;
48class HitTestResult;
49class InlineBox;
50class InlineFlowBox;
51class OverlapTestRequestClient;
52class Path;
53class Position;
54class RenderBoxModelObject;
55class RenderInline;
56class RenderBlock;
57class RenderFlow;
58class RenderLayer;
59class RenderTheme;
60class TransformState;
61class VisiblePosition;
62#if ENABLE(SVG)
63class RenderSVGResourceContainer;
64#endif
65
66struct PaintInfo;
67
68enum HitTestFilter {
69    HitTestAll,
70    HitTestSelf,
71    HitTestDescendants
72};
73
74enum 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.
83enum BoxSide {
84    BSTop,
85    BSRight,
86    BSBottom,
87    BSLeft
88};
89
90const int caretWidth = 1;
91
92#if ENABLE(DASHBOARD_SUPPORT)
93struct 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.
111class RenderObject : public CachedResourceClient {
112    friend class RenderBlock;
113    friend class RenderBox;
114    friend class RenderLayer;
115    friend class RenderObjectChildList;
116    friend class RenderSVGContainer;
117public:
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
211protected:
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    //////////////////////////////////////////
218private:
219    void addAbsoluteRectForLayer(IntRect& result);
220    void setLayerNeedsFullRepaint();
221
222public:
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
242private:
243    // The normal operator new is disallowed on all render objects.
244    void* operator new(size_t) throw();
245
246public:
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    inline bool isBeforeOrAfterContent() const;
316    static inline bool isBeforeContent(const RenderObject* obj) { return obj && obj->isBeforeContent(); }
317    static inline bool isAfterContent(const RenderObject* obj) { return obj && obj->isAfterContent(); }
318    static inline bool isBeforeOrAfterContent(const RenderObject* obj) { return obj && obj->isBeforeOrAfterContent(); }
319
320    bool childrenInline() const { return m_childrenInline; }
321    void setChildrenInline(bool b = true) { m_childrenInline = b; }
322    bool hasColumns() const { return m_hasColumns; }
323    void setHasColumns(bool b = true) { m_hasColumns = b; }
324
325    virtual bool requiresForcedStyleRecalcPropagation() const { return false; }
326
327#if ENABLE(MATHML)
328    virtual bool isRenderMathMLBlock() const { return false; }
329#endif // ENABLE(MATHML)
330
331#if ENABLE(SVG)
332    // FIXME: Until all SVG renders can be subclasses of RenderSVGModelObject we have
333    // to add SVG renderer methods to RenderObject with an ASSERT_NOT_REACHED() default implementation.
334    virtual bool isSVGRoot() const { return false; }
335    virtual bool isSVGContainer() const { return false; }
336    virtual bool isSVGViewportContainer() const { return false; }
337    virtual bool isSVGGradientStop() const { return false; }
338    virtual bool isSVGHiddenContainer() const { return false; }
339    virtual bool isSVGPath() const { return false; }
340    virtual bool isSVGText() const { return false; }
341    virtual bool isSVGTextPath() const { return false; }
342    virtual bool isSVGInline() const { return false; }
343    virtual bool isSVGInlineText() const { return false; }
344    virtual bool isSVGImage() const { return false; }
345    virtual bool isSVGForeignObject() const { return false; }
346    virtual bool isSVGResourceContainer() const { return false; }
347    virtual bool isSVGResourceFilter() const { return false; }
348    virtual bool isSVGResourceFilterPrimitive() const { return false; }
349    virtual bool isSVGShadowTreeRootContainer() const { return false; }
350
351    virtual RenderSVGResourceContainer* toRenderSVGResourceContainer();
352
353    // FIXME: Those belong into a SVG specific base-class for all renderers (see above)
354    // Unfortunately we don't have such a class yet, because it's not possible for all renderers
355    // to inherit from RenderSVGObject -> RenderObject (some need RenderBlock inheritance for instance)
356    virtual void setNeedsTransformUpdate() { }
357    virtual void setNeedsBoundariesUpdate();
358
359    // Per SVG 1.1 objectBoundingBox ignores clipping, masking, filter effects, opacity and stroke-width.
360    // This is used for all computation of objectBoundingBox relative units and by SVGLocateable::getBBox().
361    // NOTE: Markers are not specifically ignored here by SVG 1.1 spec, but we ignore them
362    // since stroke-width is ignored (and marker size can depend on stroke-width).
363    // objectBoundingBox is returned local coordinates.
364    // The name objectBoundingBox is taken from the SVG 1.1 spec.
365    virtual FloatRect objectBoundingBox() const;
366    virtual FloatRect strokeBoundingBox() const;
367
368    // Returns the smallest rectangle enclosing all of the painted content
369    // respecting clipping, masking, filters, opacity, stroke-width and markers
370    virtual FloatRect repaintRectInLocalCoordinates() const;
371
372    // This only returns the transform="" value from the element
373    // most callsites want localToParentTransform() instead.
374    virtual AffineTransform localTransform() const;
375
376    // Returns the full transform mapping from local coordinates to local coords for the parent SVG renderer
377    // This includes any viewport transforms and x/y offsets as well as the transform="" value off the element.
378    virtual const AffineTransform& localToParentTransform() const;
379
380    // SVG uses FloatPoint precise hit testing, and passes the point in parent
381    // coordinates instead of in repaint container coordinates.  Eventually the
382    // rest of the rendering tree will move to a similar model.
383    virtual bool nodeAtFloatPoint(const HitTestRequest&, HitTestResult&, const FloatPoint& pointInParent, HitTestAction);
384#endif
385
386    bool isAnonymous() const { return m_isAnonymous; }
387    void setIsAnonymous(bool b) { m_isAnonymous = b; }
388    bool isAnonymousBlock() const
389    {
390        // This function is kept in sync with anonymous block creation conditions in
391        // RenderBlock::createAnonymousBlock(). This includes creating an anonymous
392        // RenderBlock having a BLOCK or BOX display. Other classes such as RenderTextFragment
393        // are not RenderBlocks and will return false. See https://bugs.webkit.org/show_bug.cgi?id=56709.
394        return m_isAnonymous && (style()->display() == BLOCK || style()->display() == BOX) && style()->styleType() == NOPSEUDO && isRenderBlock() && !isListMarker();
395    }
396    bool isAnonymousColumnsBlock() const { return style()->specifiesColumns() && isAnonymousBlock(); }
397    bool isAnonymousColumnSpanBlock() const { return style()->columnSpan() && isAnonymousBlock(); }
398    bool isElementContinuation() const { return node() && node()->renderer() != this; }
399    bool isInlineElementContinuation() const { return isElementContinuation() && isInline(); }
400    bool isBlockElementContinuation() const { return isElementContinuation() && !isInline(); }
401    virtual RenderBoxModelObject* virtualContinuation() const { return 0; }
402
403    bool isFloating() const { return m_floating; }
404    bool isPositioned() const { return m_positioned; } // absolute or fixed positioning
405    bool isRelPositioned() const { return m_relPositioned; } // relative positioning
406    bool isText() const  { return m_isText; }
407    bool isBox() const { return m_isBox; }
408    bool isInline() const { return m_inline; }  // inline object
409    bool isRunIn() const { return style()->display() == RUN_IN; } // run-in object
410    bool isDragging() const { return m_isDragging; }
411    bool isReplaced() const { return m_replaced; } // a "replaced" element (see CSS)
412    bool isHorizontalWritingMode() const { return m_horizontalWritingMode; }
413
414    bool hasLayer() const { return m_hasLayer; }
415
416    bool hasBoxDecorations() const { return m_paintBackground; }
417    bool mustRepaintBackgroundOrBorder() const;
418    bool hasBackground() const { return style()->hasBackground(); }
419    bool needsLayout() const { return m_needsLayout || m_normalChildNeedsLayout || m_posChildNeedsLayout || m_needsSimplifiedNormalFlowLayout || m_needsPositionedMovementLayout; }
420    bool selfNeedsLayout() const { return m_needsLayout; }
421    bool needsPositionedMovementLayout() const { return m_needsPositionedMovementLayout; }
422    bool needsPositionedMovementLayoutOnly() const { return m_needsPositionedMovementLayout && !m_needsLayout && !m_normalChildNeedsLayout && !m_posChildNeedsLayout && !m_needsSimplifiedNormalFlowLayout; }
423    bool posChildNeedsLayout() const { return m_posChildNeedsLayout; }
424    bool needsSimplifiedNormalFlowLayout() const { return m_needsSimplifiedNormalFlowLayout; }
425    bool normalChildNeedsLayout() const { return m_normalChildNeedsLayout; }
426
427    bool preferredLogicalWidthsDirty() const { return m_preferredLogicalWidthsDirty; }
428
429    bool isSelectionBorder() const;
430
431    bool hasClip() const { return isPositioned() && style()->hasClip(); }
432    bool hasOverflowClip() const { return m_hasOverflowClip; }
433
434    bool hasTransform() const { return m_hasTransform; }
435    bool hasMask() const { return style() && style()->hasMask(); }
436
437    inline bool preservesNewline() const;
438
439#if !HAVE(PATH_BASED_BORDER_RADIUS_DRAWING)
440    // FIXME: This function should be removed when all ports implement GraphicsContext::clipConvexPolygon()!!
441    // At that time, everyone can use RenderObject::drawBoxSideFromPath() instead. This should happen soon.
442    void drawArcForBoxSide(GraphicsContext*, int x, int y, float thickness, const IntSize& radius, int angleStart,
443                           int angleSpan, BoxSide, Color, EBorderStyle, bool firstCorner);
444#endif
445
446    IntRect borderInnerRect(const IntRect&, unsigned short topWidth, unsigned short bottomWidth,
447                            unsigned short leftWidth, unsigned short rightWidth) const;
448
449    // The pseudo element style can be cached or uncached.  Use the cached method if the pseudo element doesn't respect
450    // any pseudo classes (and therefore has no concept of changing state).
451    RenderStyle* getCachedPseudoStyle(PseudoId, RenderStyle* parentStyle = 0) const;
452    PassRefPtr<RenderStyle> getUncachedPseudoStyle(PseudoId, RenderStyle* parentStyle = 0, RenderStyle* ownStyle = 0) const;
453
454    virtual void updateDragState(bool dragOn);
455
456    RenderView* view() const;
457
458    // Returns true if this renderer is rooted, and optionally returns the hosting view (the root of the hierarchy).
459    bool isRooted(RenderView** = 0);
460
461    Node* node() const { return m_isAnonymous ? 0 : m_node; }
462
463    // Returns the styled node that caused the generation of this renderer.
464    // This is the same as node() except for renderers of :before and :after
465    // pseudo elements for which their parent node is returned.
466    Node* generatingNode() const { return m_node == document() ? 0 : m_node; }
467    void setNode(Node* node) { m_node = node; }
468
469    Document* document() const { return m_node->document(); }
470    Frame* frame() const { return document()->frame(); }
471
472    bool hasOutlineAnnotation() const;
473    bool hasOutline() const { return style()->hasOutline() || hasOutlineAnnotation(); }
474
475    // Returns the object containing this one. Can be different from parent for positioned elements.
476    // If repaintContainer and repaintContainerSkipped are not null, on return *repaintContainerSkipped
477    // is true if the renderer returned is an ancestor of repaintContainer.
478    RenderObject* container(RenderBoxModelObject* repaintContainer = 0, bool* repaintContainerSkipped = 0) const;
479
480    virtual RenderObject* hoverAncestor() const { return parent(); }
481
482    // IE Extension that can be called on any RenderObject.  See the implementation for the details.
483    RenderBoxModelObject* offsetParent() const;
484
485    void markContainingBlocksForLayout(bool scheduleRelayout = true, RenderObject* newRoot = 0);
486    void setNeedsLayout(bool b, bool markParents = true);
487    void setChildNeedsLayout(bool b, bool markParents = true);
488    void setNeedsPositionedMovementLayout();
489    void setNeedsSimplifiedNormalFlowLayout();
490    void setPreferredLogicalWidthsDirty(bool, bool markParents = true);
491    void invalidateContainerPreferredLogicalWidths();
492
493    void setNeedsLayoutAndPrefWidthsRecalc()
494    {
495        setNeedsLayout(true);
496        setPreferredLogicalWidthsDirty(true);
497    }
498
499    void setPositioned(bool b = true)  { m_positioned = b;  }
500    void setRelPositioned(bool b = true) { m_relPositioned = b; }
501    void setFloating(bool b = true) { m_floating = b; }
502    void setInline(bool b = true) { m_inline = b; }
503    void setHasBoxDecorations(bool b = true) { m_paintBackground = b; }
504    void setIsText() { m_isText = true; }
505    void setIsBox() { m_isBox = true; }
506    void setReplaced(bool b = true) { m_replaced = b; }
507    void setHorizontalWritingMode(bool b = true) { m_horizontalWritingMode = b; }
508    void setHasOverflowClip(bool b = true) { m_hasOverflowClip = b; }
509    void setHasLayer(bool b = true) { m_hasLayer = b; }
510    void setHasTransform(bool b = true) { m_hasTransform = b; }
511    void setHasReflection(bool b = true) { m_hasReflection = b; }
512
513    void scheduleRelayout();
514
515    void updateFillImages(const FillLayer*, const FillLayer*);
516    void updateImage(StyleImage*, StyleImage*);
517
518    virtual void paint(PaintInfo&, int tx, int ty);
519
520    // Recursive function that computes the size and position of this object and all its descendants.
521    virtual void layout();
522
523    /* This function performs a layout only if one is needed. */
524    void layoutIfNeeded() { if (needsLayout()) layout(); }
525
526    // used for element state updates that cannot be fixed with a
527    // repaint and do not need a relayout
528    virtual void updateFromElement() { }
529
530#if ENABLE(DASHBOARD_SUPPORT)
531    virtual void addDashboardRegions(Vector<DashboardRegionValue>&);
532    void collectDashboardRegions(Vector<DashboardRegionValue>&);
533#endif
534
535    bool hitTest(const HitTestRequest&, HitTestResult&, const IntPoint&, int tx, int ty, HitTestFilter = HitTestAll);
536    virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction);
537    virtual void updateHitTestResult(HitTestResult&, const IntPoint&);
538
539    VisiblePosition positionForCoordinates(int x, int y);
540    virtual VisiblePosition positionForPoint(const IntPoint&);
541    VisiblePosition createVisiblePosition(int offset, EAffinity);
542    VisiblePosition createVisiblePosition(const Position&);
543
544    virtual void dirtyLinesFromChangedChild(RenderObject*);
545
546    // Called to update a style that is allowed to trigger animations.
547    // FIXME: Right now this will typically be called only when updating happens from the DOM on explicit elements.
548    // We don't yet handle generated content animation such as first-letter or before/after (we'll worry about this later).
549    void setAnimatableStyle(PassRefPtr<RenderStyle>);
550
551    // Set the style of the object and update the state of the object accordingly.
552    virtual void setStyle(PassRefPtr<RenderStyle>);
553
554    // Updates only the local style ptr of the object.  Does not update the state of the object,
555    // and so only should be called when the style is known not to have changed (or from setStyle).
556    void setStyleInternal(PassRefPtr<RenderStyle>);
557
558    // returns the containing block level element for this element.
559    RenderBlock* containingBlock() const;
560
561    // Convert the given local point to absolute coordinates
562    // FIXME: Temporary. If useTransforms is true, take transforms into account. Eventually localToAbsolute() will always be transform-aware.
563    FloatPoint localToAbsolute(const FloatPoint& localPoint = FloatPoint(), bool fixed = false, bool useTransforms = false) const;
564    FloatPoint absoluteToLocal(const FloatPoint&, bool fixed = false, bool useTransforms = false) const;
565
566    // Convert a local quad to absolute coordinates, taking transforms into account.
567    FloatQuad localToAbsoluteQuad(const FloatQuad& quad, bool fixed = false) const
568    {
569        return localToContainerQuad(quad, 0, fixed);
570    }
571    // Convert a local quad into the coordinate system of container, taking transforms into account.
572    FloatQuad localToContainerQuad(const FloatQuad&, RenderBoxModelObject* repaintContainer, bool fixed = false) const;
573
574    // Return the offset from the container() renderer (excluding transforms). In multi-column layout,
575    // different offsets apply at different points, so return the offset that applies to the given point.
576    virtual IntSize offsetFromContainer(RenderObject*, const IntPoint&) const;
577    // Return the offset from an object up the container() chain. Asserts that none of the intermediate objects have transforms.
578    IntSize offsetFromAncestorContainer(RenderObject*) const;
579
580    virtual void absoluteRects(Vector<IntRect>&, int, int) { }
581    // FIXME: useTransforms should go away eventually
582    IntRect absoluteBoundingBoxRect(bool useTransforms = false);
583
584    // Build an array of quads in absolute coords for line boxes
585    virtual void absoluteQuads(Vector<FloatQuad>&) { }
586
587    void absoluteFocusRingQuads(Vector<FloatQuad>&);
588
589    // the rect that will be painted if this object is passed as the paintingRoot
590    IntRect paintingRootRect(IntRect& topLevelRect);
591
592    virtual int minPreferredLogicalWidth() const { return 0; }
593    virtual int maxPreferredLogicalWidth() const { return 0; }
594
595    RenderStyle* style() const { return m_style.get(); }
596    RenderStyle* firstLineStyle() const { return document()->usesFirstLineRules() ? firstLineStyleSlowCase() : style(); }
597    RenderStyle* style(bool firstLine) const { return firstLine ? firstLineStyle() : style(); }
598
599    // Used only by Element::pseudoStyleCacheIsInvalid to get a first line style based off of a
600    // given new style, without accessing the cache.
601    PassRefPtr<RenderStyle> uncachedFirstLineStyle(RenderStyle*) const;
602
603    // Anonymous blocks that are part of of a continuation chain will return their inline continuation's outline style instead.
604    // This is typically only relevant when repainting.
605    virtual RenderStyle* outlineStyleForRepaint() const { return style(); }
606
607    void getTextDecorationColors(int decorations, Color& underline, Color& overline,
608                                 Color& linethrough, bool quirksMode = false);
609
610    // Return the RenderBox in the container chain which is responsible for painting this object, or 0
611    // if painting is root-relative. This is the container that should be passed to the 'forRepaint'
612    // methods.
613    RenderBoxModelObject* containerForRepaint() const;
614    // Actually do the repaint of rect r for this object which has been computed in the coordinate space
615    // of repaintContainer. If repaintContainer is 0, repaint via the view.
616    void repaintUsingContainer(RenderBoxModelObject* repaintContainer, const IntRect& r, bool immediate = false);
617
618    // Repaint the entire object.  Called when, e.g., the color of a border changes, or when a border
619    // style changes.
620    void repaint(bool immediate = false);
621
622    // Repaint a specific subrectangle within a given object.  The rect |r| is in the object's coordinate space.
623    void repaintRectangle(const IntRect&, bool immediate = false);
624
625    // Repaint only if our old bounds and new bounds are different. The caller may pass in newBounds and newOutlineBox if they are known.
626    bool repaintAfterLayoutIfNeeded(RenderBoxModelObject* repaintContainer, const IntRect& oldBounds, const IntRect& oldOutlineBox, const IntRect* newBoundsPtr = 0, const IntRect* newOutlineBoxPtr = 0);
627
628    // Repaint only if the object moved.
629    virtual void repaintDuringLayoutIfMoved(const IntRect& rect);
630
631    // Called to repaint a block's floats.
632    virtual void repaintOverhangingFloats(bool paintAllDescendants = false);
633
634    bool checkForRepaintDuringLayout() const;
635
636    // Returns the rect that should be repainted whenever this object changes.  The rect is in the view's
637    // coordinate space.  This method deals with outlines and overflow.
638    IntRect absoluteClippedOverflowRect()
639    {
640        return clippedOverflowRectForRepaint(0);
641    }
642    virtual IntRect clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer);
643    virtual IntRect rectWithOutlineForRepaint(RenderBoxModelObject* repaintContainer, int outlineWidth);
644
645    // Given a rect in the object's coordinate space, compute a rect suitable for repainting
646    // that rect in view coordinates.
647    void computeAbsoluteRepaintRect(IntRect& r, bool fixed = false)
648    {
649        return computeRectForRepaint(0, r, fixed);
650    }
651    // Given a rect in the object's coordinate space, compute a rect suitable for repainting
652    // that rect in the coordinate space of repaintContainer.
653    virtual void computeRectForRepaint(RenderBoxModelObject* repaintContainer, IntRect&, bool fixed = false);
654
655    // If multiple-column layout results in applying an offset to the given point, add the same
656    // offset to the given size.
657    virtual void adjustForColumns(IntSize&, const IntPoint&) const { }
658
659    virtual unsigned int length() const { return 1; }
660
661    bool isFloatingOrPositioned() const { return (isFloating() || isPositioned()); }
662
663    bool isTransparent() const { return style()->opacity() < 1.0f; }
664    float opacity() const { return style()->opacity(); }
665
666    bool hasReflection() const { return m_hasReflection; }
667
668    // Applied as a "slop" to dirty rect checks during the outline painting phase's dirty-rect checks.
669    int maximalOutlineSize(PaintPhase) const;
670
671    void setHasMarkupTruncation(bool b = true) { m_hasMarkupTruncation = b; }
672    bool hasMarkupTruncation() const { return m_hasMarkupTruncation; }
673
674    enum SelectionState {
675        SelectionNone, // The object is not selected.
676        SelectionStart, // The object either contains the start of a selection run or is the start of a run
677        SelectionInside, // The object is fully encompassed by a selection run
678        SelectionEnd, // The object either contains the end of a selection run or is the end of a run
679        SelectionBoth // The object contains an entire run or is the sole selected object in that run
680    };
681
682    // The current selection state for an object.  For blocks, the state refers to the state of the leaf
683    // descendants (as described above in the SelectionState enum declaration).
684    SelectionState selectionState() const { return static_cast<SelectionState>(m_selectionState);; }
685
686    // Sets the selection state for an object.
687    virtual void setSelectionState(SelectionState state) { m_selectionState = state; }
688
689    // A single rectangle that encompasses all of the selected objects within this object.  Used to determine the tightest
690    // possible bounding box for the selection.
691    IntRect selectionRect(bool clipToVisibleContent = true) { return selectionRectForRepaint(0, clipToVisibleContent); }
692    virtual IntRect selectionRectForRepaint(RenderBoxModelObject* /*repaintContainer*/, bool /*clipToVisibleContent*/ = true) { return IntRect(); }
693
694    // Whether or not an object can be part of the leaf elements of the selection.
695    virtual bool canBeSelectionLeaf() const { return false; }
696
697    // Whether or not a block has selected children.
698    bool hasSelectedChildren() const { return m_selectionState != SelectionNone; }
699
700    // Obtains the selection colors that should be used when painting a selection.
701    Color selectionBackgroundColor() const;
702    Color selectionForegroundColor() const;
703    Color selectionEmphasisMarkColor() const;
704
705    // Whether or not a given block needs to paint selection gaps.
706    virtual bool shouldPaintSelectionGaps() const { return false; }
707
708#if ENABLE(DRAG_SUPPORT)
709    Node* draggableNode(bool dhtmlOK, bool uaOK, int x, int y, bool& dhtmlWillDrag) const;
710#endif
711
712    /**
713     * Returns the local coordinates of the caret within this render object.
714     * @param caretOffset zero-based offset determining position within the render object.
715     * @param extraWidthToEndOfLine optional out arg to give extra width to end of line -
716     * useful for character range rect computations
717     */
718    virtual IntRect localCaretRect(InlineBox*, int caretOffset, int* extraWidthToEndOfLine = 0);
719
720    bool isMarginBeforeQuirk() const { return m_marginBeforeQuirk; }
721    bool isMarginAfterQuirk() const { return m_marginAfterQuirk; }
722    void setMarginBeforeQuirk(bool b = true) { m_marginBeforeQuirk = b; }
723    void setMarginAfterQuirk(bool b = true) { m_marginAfterQuirk = b; }
724
725    // When performing a global document tear-down, the renderer of the document is cleared.  We use this
726    // as a hook to detect the case of document destruction and don't waste time doing unnecessary work.
727    bool documentBeingDestroyed() const;
728
729    virtual void destroy();
730
731    // Virtual function helpers for CSS3 Flexible Box Layout
732    virtual bool isFlexibleBox() const { return false; }
733    virtual bool isFlexingChildren() const { return false; }
734    virtual bool isStretchingChildren() const { return false; }
735
736    virtual bool isCombineText() const { return false; }
737
738    virtual int caretMinOffset() const;
739    virtual int caretMaxOffset() const;
740    virtual unsigned caretMaxRenderedOffset() const;
741
742    virtual int previousOffset(int current) const;
743    virtual int previousOffsetForBackwardDeletion(int current) const;
744    virtual int nextOffset(int current) const;
745
746    virtual void imageChanged(CachedImage*, const IntRect* = 0);
747    virtual void imageChanged(WrappedImagePtr, const IntRect* = 0) { }
748    virtual bool willRenderImage(CachedImage*);
749
750    void selectionStartEnd(int& spos, int& epos) const;
751
752    bool hasOverrideSize() const { return m_hasOverrideSize; }
753    void setHasOverrideSize(bool b) { m_hasOverrideSize = b; }
754
755    void remove() { if (parent()) parent()->removeChild(this); }
756
757    AnimationController* animation() const;
758
759    bool visibleToHitTesting() const { return style()->visibility() == VISIBLE && style()->pointerEvents() != PE_NONE; }
760
761    // Map points and quads through elements, potentially via 3d transforms. You should never need to call these directly; use
762    // localToAbsolute/absoluteToLocal methods instead.
763    virtual void mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool useTransforms, bool fixed, TransformState&) const;
764    virtual void mapAbsoluteToLocalPoint(bool fixed, bool useTransforms, TransformState&) const;
765
766    bool shouldUseTransformFromContainer(const RenderObject* container) const;
767    void getTransformFromContainer(const RenderObject* container, const IntSize& offsetInContainer, TransformationMatrix&) const;
768
769    virtual void addFocusRingRects(Vector<IntRect>&, int /*tx*/, int /*ty*/) { };
770
771    IntRect absoluteOutlineBounds() const
772    {
773        return outlineBoundsForRepaint(0);
774    }
775
776protected:
777    // Overrides should call the superclass at the end
778    virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle);
779    // Overrides should call the superclass at the start
780    virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
781    void propagateStyleToAnonymousChildren();
782
783    void drawLineForBoxSide(GraphicsContext*, int x1, int y1, int x2, int y2, BoxSide,
784                            Color, EBorderStyle, int adjbw1, int adjbw2, bool antialias = false);
785
786    void paintFocusRing(GraphicsContext*, int tx, int ty, RenderStyle*);
787    void paintOutline(GraphicsContext*, int tx, int ty, int w, int h);
788    void addPDFURLRect(GraphicsContext*, const IntRect&);
789
790    virtual IntRect viewRect() const;
791
792    void adjustRectForOutlineAndShadow(IntRect&) const;
793
794    void arenaDelete(RenderArena*, void* objectBase);
795
796    virtual IntRect outlineBoundsForRepaint(RenderBoxModelObject* /*repaintContainer*/, IntPoint* /*cachedOffsetToRepaintContainer*/ = 0) const { return IntRect(); }
797
798    class LayoutRepainter {
799    public:
800        LayoutRepainter(RenderObject& object, bool checkForRepaint, const IntRect* oldBounds = 0)
801            : m_object(object)
802            , m_repaintContainer(0)
803            , m_checkForRepaint(checkForRepaint)
804        {
805            if (m_checkForRepaint) {
806                m_repaintContainer = m_object.containerForRepaint();
807                m_oldBounds = oldBounds ? *oldBounds : m_object.clippedOverflowRectForRepaint(m_repaintContainer);
808                m_oldOutlineBox = m_object.outlineBoundsForRepaint(m_repaintContainer);
809            }
810        }
811
812        // Return true if it repainted.
813        bool repaintAfterLayout()
814        {
815            return m_checkForRepaint ? m_object.repaintAfterLayoutIfNeeded(m_repaintContainer, m_oldBounds, m_oldOutlineBox) : false;
816        }
817
818        bool checkForRepaint() const { return m_checkForRepaint; }
819
820    private:
821        RenderObject& m_object;
822        RenderBoxModelObject* m_repaintContainer;
823        IntRect m_oldBounds;
824        IntRect m_oldOutlineBox;
825        bool m_checkForRepaint;
826    };
827
828private:
829    RenderStyle* firstLineStyleSlowCase() const;
830    StyleDifference adjustStyleDifference(StyleDifference, unsigned contextSensitiveProperties) const;
831
832    Color selectionColor(int colorProperty) const;
833
834    RefPtr<RenderStyle> m_style;
835
836    Node* m_node;
837
838    RenderObject* m_parent;
839    RenderObject* m_previous;
840    RenderObject* m_next;
841
842#ifndef NDEBUG
843    bool m_hasAXObject;
844    bool m_setNeedsLayoutForbidden : 1;
845#endif
846
847    // 32 bits have been used here. THERE ARE NO FREE BITS AVAILABLE.
848    bool m_needsLayout               : 1;
849    bool m_needsPositionedMovementLayout :1;
850    bool m_normalChildNeedsLayout    : 1;
851    bool m_posChildNeedsLayout       : 1;
852    bool m_needsSimplifiedNormalFlowLayout  : 1;
853    bool m_preferredLogicalWidthsDirty           : 1;
854    bool m_floating                  : 1;
855
856    bool m_positioned                : 1;
857    bool m_relPositioned             : 1;
858    bool m_paintBackground           : 1; // if the box has something to paint in the
859                                          // background painting phase (background, border, etc)
860
861    bool m_isAnonymous               : 1;
862    bool m_isText                    : 1;
863    bool m_isBox                     : 1;
864    bool m_inline                    : 1;
865    bool m_replaced                  : 1;
866    bool m_horizontalWritingMode : 1;
867    bool m_isDragging                : 1;
868
869    bool m_hasLayer                  : 1;
870    bool m_hasOverflowClip           : 1; // Set in the case of overflow:auto/scroll/hidden
871    bool m_hasTransform              : 1;
872    bool m_hasReflection             : 1;
873
874    bool m_hasOverrideSize           : 1;
875
876public:
877    bool m_hasCounterNodeMap         : 1;
878    bool m_everHadLayout             : 1;
879
880private:
881    // These bitfields are moved here from subclasses to pack them together
882    // from RenderBlock
883    bool m_childrenInline : 1;
884    bool m_marginBeforeQuirk : 1;
885    bool m_marginAfterQuirk : 1;
886    bool m_hasMarkupTruncation : 1;
887    unsigned m_selectionState : 3; // SelectionState
888    bool m_hasColumns : 1;
889
890    // from RenderTableCell
891    bool m_cellWidthChanged : 1;
892
893private:
894    // Store state between styleWillChange and styleDidChange
895    static bool s_affectsParentBlock;
896};
897
898inline bool RenderObject::documentBeingDestroyed() const
899{
900    return !document()->renderer();
901}
902
903inline bool RenderObject::isBeforeContent() const
904{
905    if (style()->styleType() != BEFORE)
906        return false;
907    // Text nodes don't have their own styles, so ignore the style on a text node.
908    if (isText() && !isBR())
909        return false;
910    return true;
911}
912
913inline bool RenderObject::isAfterContent() const
914{
915    if (style()->styleType() != AFTER)
916        return false;
917    // Text nodes don't have their own styles, so ignore the style on a text node.
918    if (isText() && !isBR())
919        return false;
920    return true;
921}
922
923inline bool RenderObject::isBeforeOrAfterContent() const
924{
925    return isBeforeContent() || isAfterContent();
926}
927
928inline void RenderObject::setNeedsLayout(bool b, bool markParents)
929{
930    bool alreadyNeededLayout = m_needsLayout;
931    m_needsLayout = b;
932    if (b) {
933        ASSERT(!isSetNeedsLayoutForbidden());
934        if (!alreadyNeededLayout) {
935            if (markParents)
936                markContainingBlocksForLayout();
937            if (hasLayer())
938                setLayerNeedsFullRepaint();
939        }
940    } else {
941        m_everHadLayout = true;
942        m_posChildNeedsLayout = false;
943        m_needsSimplifiedNormalFlowLayout = false;
944        m_normalChildNeedsLayout = false;
945        m_needsPositionedMovementLayout = false;
946    }
947}
948
949inline void RenderObject::setChildNeedsLayout(bool b, bool markParents)
950{
951    bool alreadyNeededLayout = m_normalChildNeedsLayout;
952    m_normalChildNeedsLayout = b;
953    if (b) {
954        ASSERT(!isSetNeedsLayoutForbidden());
955        if (!alreadyNeededLayout && markParents)
956            markContainingBlocksForLayout();
957    } else {
958        m_posChildNeedsLayout = false;
959        m_needsSimplifiedNormalFlowLayout = false;
960        m_normalChildNeedsLayout = false;
961        m_needsPositionedMovementLayout = false;
962    }
963}
964
965inline void RenderObject::setNeedsPositionedMovementLayout()
966{
967    bool alreadyNeededLayout = m_needsPositionedMovementLayout;
968    m_needsPositionedMovementLayout = true;
969    ASSERT(!isSetNeedsLayoutForbidden());
970    if (!alreadyNeededLayout) {
971        markContainingBlocksForLayout();
972        if (hasLayer())
973            setLayerNeedsFullRepaint();
974    }
975}
976
977inline void RenderObject::setNeedsSimplifiedNormalFlowLayout()
978{
979    bool alreadyNeededLayout = m_needsSimplifiedNormalFlowLayout;
980    m_needsSimplifiedNormalFlowLayout = true;
981    ASSERT(!isSetNeedsLayoutForbidden());
982    if (!alreadyNeededLayout) {
983        markContainingBlocksForLayout();
984        if (hasLayer())
985            setLayerNeedsFullRepaint();
986    }
987}
988
989inline bool objectIsRelayoutBoundary(const RenderObject *obj)
990{
991    // FIXME: In future it may be possible to broaden this condition in order to improve performance.
992    // Table cells are excluded because even when their CSS height is fixed, their height()
993    // may depend on their contents.
994    return obj->isTextControl()
995        || (obj->hasOverflowClip() && !obj->style()->width().isIntrinsicOrAuto() && !obj->style()->height().isIntrinsicOrAuto() && !obj->style()->height().isPercent() && !obj->isTableCell())
996#if ENABLE(SVG)
997           || obj->isSVGRoot()
998#endif
999           ;
1000}
1001
1002inline void RenderObject::markContainingBlocksForLayout(bool scheduleRelayout, RenderObject* newRoot)
1003{
1004    ASSERT(!scheduleRelayout || !newRoot);
1005
1006    RenderObject* o = container();
1007    RenderObject* last = this;
1008
1009    bool simplifiedNormalFlowLayout = needsSimplifiedNormalFlowLayout() && !selfNeedsLayout() && !normalChildNeedsLayout();
1010
1011    while (o) {
1012        // Don't mark the outermost object of an unrooted subtree. That object will be
1013        // marked when the subtree is added to the document.
1014        RenderObject* container = o->container();
1015        if (!container && !o->isRenderView())
1016            return;
1017        if (!last->isText() && (last->style()->position() == FixedPosition || last->style()->position() == AbsolutePosition)) {
1018            while (o && !o->isRenderBlock()) // Skip relatively positioned inlines and get to the enclosing RenderBlock.
1019                o = o->container();
1020            if (!o || o->m_posChildNeedsLayout)
1021                return;
1022            o->m_posChildNeedsLayout = true;
1023            simplifiedNormalFlowLayout = true;
1024            ASSERT(!o->isSetNeedsLayoutForbidden());
1025        } else if (simplifiedNormalFlowLayout) {
1026            if (o->m_needsSimplifiedNormalFlowLayout)
1027                return;
1028            o->m_needsSimplifiedNormalFlowLayout = true;
1029            ASSERT(!o->isSetNeedsLayoutForbidden());
1030        } else {
1031            if (o->m_normalChildNeedsLayout)
1032                return;
1033            o->m_normalChildNeedsLayout = true;
1034            ASSERT(!o->isSetNeedsLayoutForbidden());
1035        }
1036
1037        if (o == newRoot)
1038            return;
1039
1040        last = o;
1041        if (scheduleRelayout && objectIsRelayoutBoundary(last))
1042            break;
1043        o = container;
1044    }
1045
1046    if (scheduleRelayout)
1047        last->scheduleRelayout();
1048}
1049
1050inline bool RenderObject::preservesNewline() const
1051{
1052#if ENABLE(SVG)
1053    if (isSVGInlineText())
1054        return false;
1055#endif
1056
1057    return style()->preserveNewline();
1058}
1059
1060inline void makeMatrixRenderable(TransformationMatrix& matrix, bool has3DRendering)
1061{
1062#if !ENABLE(3D_RENDERING)
1063    UNUSED_PARAM(has3DRendering);
1064    matrix.makeAffine();
1065#else
1066    if (!has3DRendering)
1067        matrix.makeAffine();
1068#endif
1069}
1070
1071inline int adjustForAbsoluteZoom(int value, RenderObject* renderer)
1072{
1073    return adjustForAbsoluteZoom(value, renderer->style());
1074}
1075
1076inline FloatPoint adjustFloatPointForAbsoluteZoom(const FloatPoint& point, RenderObject* renderer)
1077{
1078    // The result here is in floats, so we don't need the truncation hack from the integer version above.
1079    float zoomFactor = renderer->style()->effectiveZoom();
1080    if (zoomFactor == 1)
1081        return point;
1082    return FloatPoint(point.x() / zoomFactor, point.y() / zoomFactor);
1083}
1084
1085inline void adjustFloatQuadForAbsoluteZoom(FloatQuad& quad, RenderObject* renderer)
1086{
1087    quad.setP1(adjustFloatPointForAbsoluteZoom(quad.p1(), renderer));
1088    quad.setP2(adjustFloatPointForAbsoluteZoom(quad.p2(), renderer));
1089    quad.setP3(adjustFloatPointForAbsoluteZoom(quad.p3(), renderer));
1090    quad.setP4(adjustFloatPointForAbsoluteZoom(quad.p4(), renderer));
1091}
1092
1093inline void adjustFloatRectForAbsoluteZoom(FloatRect& rect, RenderObject* renderer)
1094{
1095    RenderStyle* style = renderer->style();
1096    rect.setX(adjustFloatForAbsoluteZoom(rect.x(), style));
1097    rect.setY(adjustFloatForAbsoluteZoom(rect.y(), style));
1098    rect.setWidth(adjustFloatForAbsoluteZoom(rect.width(), style));
1099    rect.setHeight(adjustFloatForAbsoluteZoom(rect.height(), style));
1100}
1101
1102inline FloatPoint adjustFloatPointForPageScale(const FloatPoint& point, float pageScale)
1103{
1104    if (pageScale == 1)
1105        return point;
1106    return FloatPoint(point.x() / pageScale, point.y() / pageScale);
1107}
1108
1109inline void adjustFloatQuadForPageScale(FloatQuad& quad, float pageScale)
1110{
1111    if (pageScale == 1)
1112        return;
1113    quad.setP1(adjustFloatPointForPageScale(quad.p1(), pageScale));
1114    quad.setP2(adjustFloatPointForPageScale(quad.p2(), pageScale));
1115    quad.setP3(adjustFloatPointForPageScale(quad.p3(), pageScale));
1116    quad.setP4(adjustFloatPointForPageScale(quad.p4(), pageScale));
1117}
1118
1119inline void adjustFloatRectForPageScale(FloatRect& rect, float pageScale)
1120{
1121    if (pageScale == 1)
1122        return;
1123    rect.setX(rect.x() / pageScale);
1124    rect.setY(rect.y() / pageScale);
1125    rect.setWidth(rect.width() / pageScale);
1126    rect.setHeight(rect.height() / pageScale);
1127}
1128
1129} // namespace WebCore
1130
1131#ifndef NDEBUG
1132// Outside the WebCore namespace for ease of invocation from gdb.
1133void showTree(const WebCore::RenderObject*);
1134void showRenderTree(const WebCore::RenderObject* object1);
1135// We don't make object2 an optional parameter so that showRenderTree
1136// can be called from gdb easily.
1137void showRenderTree(const WebCore::RenderObject* object1, const WebCore::RenderObject* object2);
1138#endif
1139
1140#endif // RenderObject_h
1141