Fix the issue that Web Audio test case fails on PR3.
[framework/web/webkit-efl.git] / Source / WebCore / rendering / RenderObject.h
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 "CachedImage.h"
30 #include "Document.h"
31 #include "Element.h"
32 #include "FractionalLayoutUnit.h"
33 #include "FloatQuad.h"
34 #include "LayoutTypes.h"
35 #include "PaintPhase.h"
36 #include "RenderObjectChildList.h"
37 #include "RenderStyle.h"
38 #include "ScrollBehavior.h"
39 #include "TextAffinity.h"
40 #include "TransformationMatrix.h"
41 #include <wtf/HashSet.h>
42 #include <wtf/UnusedParam.h>
43
44 namespace WebCore {
45
46 class AffineTransform;
47 class AnimationController;
48 class Cursor;
49 class HitTestPoint;
50 class HitTestResult;
51 class InlineBox;
52 class InlineFlowBox;
53 class OverlapTestRequestClient;
54 class Path;
55 class Position;
56 class RenderBoxModelObject;
57 class RenderInline;
58 class RenderBlock;
59 class RenderFlowThread;
60 class RenderGeometryMap;
61 class RenderLayer;
62 class RenderTable;
63 class RenderTheme;
64 class TransformState;
65 class VisiblePosition;
66 #if ENABLE(SVG)
67 class RenderSVGResourceContainer;
68 #endif
69
70 struct PaintInfo;
71
72 enum CursorDirective {
73     SetCursorBasedOnStyle,
74     SetCursor,
75     DoNotSetCursor
76 };
77
78 enum HitTestFilter {
79     HitTestAll,
80     HitTestSelf,
81     HitTestDescendants
82 };
83
84 enum HitTestAction {
85     HitTestBlockBackground,
86     HitTestChildBlockBackground,
87     HitTestChildBlockBackgrounds,
88     HitTestFloat,
89     HitTestForeground
90 };
91
92 // Sides used when drawing borders and outlines. The values should run clockwise from top.
93 enum BoxSide {
94     BSTop,
95     BSRight,
96     BSBottom,
97     BSLeft
98 };
99
100 enum MarkingBehavior {
101     MarkOnlyThis,
102     MarkContainingBlockChain,
103 };
104
105 #if ENABLE(TIZEN_ENLARGE_CARET_WIDTH)
106 const int caretWidth = 3;
107 #else
108 const int caretWidth = 1;
109 #endif
110 enum PlaceGeneratedRunInFlag {
111     PlaceGeneratedRunIn,
112     DoNotPlaceGeneratedRunIn
113 };
114 #if ENABLE(DASHBOARD_SUPPORT)
115 struct DashboardRegionValue {
116     bool operator==(const DashboardRegionValue& o) const
117     {
118         return type == o.type && bounds == o.bounds && clip == o.clip && label == o.label;
119     }
120     bool operator!=(const DashboardRegionValue& o) const
121     {
122         return !(*this == o);
123     }
124
125     String label;
126     LayoutRect bounds;
127     LayoutRect clip;
128     int type;
129 };
130 #endif
131
132 typedef WTF::HashSet<const RenderObject*> RenderObjectAncestorLineboxDirtySet;
133
134 #ifndef NDEBUG
135 const int showTreeCharacterOffset = 39;
136 #endif
137
138 // Base class for all rendering tree objects.
139 class RenderObject : public CachedImageClient {
140     friend class LayoutRepainter;
141     friend class RenderBlock;
142     friend class RenderBox;
143     friend class RenderLayer;
144     friend class RenderObjectChildList;
145     friend class RenderSVGContainer;
146 public:
147     // Anonymous objects should pass the document as their node, and they will then automatically be
148     // marked as anonymous in the constructor.
149     RenderObject(Node*);
150     virtual ~RenderObject();
151
152     RenderTheme* theme() const;
153
154     virtual const char* renderName() const = 0;
155
156     RenderObject* parent() const { return m_parent; }
157     bool isDescendantOf(const RenderObject*) const;
158
159     RenderObject* previousSibling() const { return m_previous; }
160     RenderObject* nextSibling() const { return m_next; }
161
162     RenderObject* firstChild() const
163     {
164         if (const RenderObjectChildList* children = virtualChildren())
165             return children->firstChild();
166         return 0;
167     }
168     RenderObject* lastChild() const
169     {
170         if (const RenderObjectChildList* children = virtualChildren())
171             return children->lastChild();
172         return 0;
173     }
174     RenderObject* beforePseudoElementRenderer() const
175     {
176         if (const RenderObjectChildList* children = virtualChildren())
177             return children->beforePseudoElementRenderer(this);
178         return 0;
179     }
180
181     // This function only returns the renderer of the "after" pseudoElement if it is a child of
182     // this renderer. If "continuations" exist, the function returns 0 even if the element that
183     // generated this renderer has an "after" pseudo-element.
184     RenderObject* afterPseudoElementRenderer() const
185     {
186         if (const RenderObjectChildList* children = virtualChildren())
187             return children->afterPseudoElementRenderer(this);
188         return 0;
189     }
190
191     virtual RenderObjectChildList* virtualChildren() { return 0; }
192     virtual const RenderObjectChildList* virtualChildren() const { return 0; }
193
194     RenderObject* nextInPreOrder() const;
195     RenderObject* nextInPreOrder(const RenderObject* stayWithin) const;
196     RenderObject* nextInPreOrderAfterChildren() const;
197     RenderObject* nextInPreOrderAfterChildren(const RenderObject* stayWithin) const;
198     RenderObject* previousInPreOrder() const;
199     RenderObject* previousInPreOrder(const RenderObject* stayWithin) const;
200     RenderObject* childAt(unsigned) const;
201
202     RenderObject* firstLeafChild() const;
203     RenderObject* lastLeafChild() const;
204
205     // The following six functions are used when the render tree hierarchy changes to make sure layers get
206     // properly added and removed.  Since containership can be implemented by any subclass, and since a hierarchy
207     // can contain a mixture of boxes and other object types, these functions need to be in the base class.
208     RenderLayer* enclosingLayer() const;
209     void addLayers(RenderLayer* parentLayer);
210     void removeLayers(RenderLayer* parentLayer);
211     void moveLayers(RenderLayer* oldParent, RenderLayer* newParent);
212     RenderLayer* findNextLayer(RenderLayer* parentLayer, RenderObject* startPoint, bool checkParent = true);
213
214     // Scrolling is a RenderBox concept, however some code just cares about recursively scrolling our enclosing ScrollableArea(s).
215     bool scrollRectToVisible(const LayoutRect&, const ScrollAlignment& alignX = ScrollAlignment::alignCenterIfNeeded, const ScrollAlignment& alignY = ScrollAlignment::alignCenterIfNeeded);
216
217     // Convenience function for getting to the nearest enclosing box of a RenderObject.
218     RenderBox* enclosingBox() const;
219     RenderBoxModelObject* enclosingBoxModelObject() const;
220
221     // Function to return our enclosing flow thread if we are contained inside one.
222     RenderFlowThread* enclosingRenderFlowThread() const;
223
224     virtual bool isEmpty() const { return firstChild() == 0; }
225
226 #ifndef NDEBUG
227     void setHasAXObject(bool flag) { m_hasAXObject = flag; }
228     bool hasAXObject() const { return m_hasAXObject; }
229     bool isSetNeedsLayoutForbidden() const { return m_setNeedsLayoutForbidden; }
230     void setNeedsLayoutIsForbidden(bool flag) { m_setNeedsLayoutForbidden = flag; }
231 #endif
232
233     // Obtains the nearest enclosing block (including this block) that contributes a first-line style to our inline
234     // children.
235     virtual RenderBlock* firstLineBlock() const;
236
237     // Called when an object that was floating or positioned becomes a normal flow object
238     // again.  We have to make sure the render tree updates as needed to accommodate the new
239     // normal flow object.
240     void handleDynamicFloatPositionChange();
241     
242     // RenderObject tree manipulation
243     //////////////////////////////////////////
244     virtual bool canHaveChildren() const { return virtualChildren(); }
245     virtual bool canHaveGeneratedChildren() const;
246     virtual bool isChildAllowed(RenderObject*, RenderStyle*) const { return true; }
247     virtual void addChild(RenderObject* newChild, RenderObject* beforeChild = 0);
248     virtual void addChildIgnoringContinuation(RenderObject* newChild, RenderObject* beforeChild = 0) { return addChild(newChild, beforeChild); }
249     virtual void removeChild(RenderObject*);
250     virtual bool createsAnonymousWrapper() const { return false; }
251     //////////////////////////////////////////
252
253 protected:
254     //////////////////////////////////////////
255     // Helper functions. Dangerous to use!
256     void setPreviousSibling(RenderObject* previous) { m_previous = previous; }
257     void setNextSibling(RenderObject* next) { m_next = next; }
258     void setParent(RenderObject* parent)
259     {
260         m_parent = parent;
261         if (parent && parent->inRenderFlowThread())
262             setInRenderFlowThread(true);
263         else if (!parent && inRenderFlowThread())
264             setInRenderFlowThread(false);
265     }
266     //////////////////////////////////////////
267 private:
268     void addAbsoluteRectForLayer(LayoutRect& result);
269     void setLayerNeedsFullRepaint();
270     void setLayerNeedsFullRepaintForPositionedMovementLayout();
271
272 public:
273 #ifndef NDEBUG
274     void showTreeForThis() const;
275     void showRenderTreeForThis() const;
276     void showLineTreeForThis() const;
277
278     void showRenderObject() const;
279     // We don't make printedCharacters an optional parameter so that
280     // showRenderObject can be called from gdb easily.
281     void showRenderObject(int printedCharacters) const;
282     void showRenderTreeAndMark(const RenderObject* markedObject1 = 0, const char* markedLabel1 = 0, const RenderObject* markedObject2 = 0, const char* markedLabel2 = 0, int depth = 0) const;
283 #endif
284
285     static RenderObject* createObject(Node*, RenderStyle*);
286
287     // Overloaded new operator.  Derived classes must override operator new
288     // in order to allocate out of the RenderArena.
289     void* operator new(size_t, RenderArena*);
290
291     // Overridden to prevent the normal delete from being called.
292     void operator delete(void*, size_t);
293
294 private:
295     // The normal operator new is disallowed on all render objects.
296     void* operator new(size_t) throw();
297
298 public:
299     RenderArena* renderArena() const { return document()->renderArena(); }
300
301     virtual bool isBR() const { return false; }
302     virtual bool isBlockFlow() const { return false; }
303     virtual bool isBoxModelObject() const { return false; }
304     virtual bool isCounter() const { return false; }
305     virtual bool isQuote() const { return false; }
306
307 #if ENABLE(DETAILS_ELEMENT)
308     virtual bool isDetailsMarker() const { return false; }
309 #endif
310     virtual bool isEmbeddedObject() const { return false; }
311     virtual bool isFieldset() const { return false; }
312     virtual bool isFileUploadControl() const { return false; }
313     virtual bool isFrame() const { return false; }
314     virtual bool isFrameSet() const { return false; }
315     virtual bool isImage() const { return false; }
316     virtual bool isInlineBlockOrInlineTable() const { return false; }
317     virtual bool isListBox() const { return false; }
318     virtual bool isListItem() const { return false; }
319     virtual bool isListMarker() const { return false; }
320     virtual bool isMedia() const { return false; }
321     virtual bool isMenuList() const { return false; }
322 #if ENABLE(METER_ELEMENT)
323     virtual bool isMeter() const { return false; }
324 #endif
325 #if ENABLE(PROGRESS_ELEMENT)
326     virtual bool isProgress() const { return false; }
327 #endif
328     virtual bool isRenderBlock() const { return false; }
329     virtual bool isRenderButton() const { return false; }
330     virtual bool isRenderIFrame() const { return false; }
331     virtual bool isRenderImage() const { return false; }
332     virtual bool isRenderInline() const { return false; }
333     virtual bool isRenderPart() const { return false; }
334     virtual bool isRenderRegion() const { return false; }
335     virtual bool isRenderView() const { return false; }
336     virtual bool isReplica() const { return false; }
337
338     virtual bool isRuby() const { return false; }
339     virtual bool isRubyBase() const { return false; }
340     virtual bool isRubyRun() const { return false; }
341     virtual bool isRubyText() const { return false; }
342
343     virtual bool isSlider() const { return false; }
344     virtual bool isSliderThumb() const { return false; }
345     virtual bool isTable() const { return false; }
346     virtual bool isTableCell() const { return false; }
347     virtual bool isRenderTableCol() const { return false; }
348     virtual bool isTableCaption() const { return false; }
349     virtual bool isTableRow() const { return false; }
350     virtual bool isTableSection() const { return false; }
351     virtual bool isTextControl() const { return false; }
352     virtual bool isTextArea() const { return false; }
353     virtual bool isTextField() const { return false; }
354     virtual bool isVideo() const { return false; }
355     virtual bool isWidget() const { return false; }
356     virtual bool isCanvas() const { return false; }
357 #if ENABLE(FULLSCREEN_API)
358     virtual bool isRenderFullScreen() const { return false; }
359     virtual bool isRenderFullScreenPlaceholder() const { return false; }
360 #endif
361
362     virtual bool isRenderFlowThread() const { return false; }
363     virtual bool isRenderNamedFlowThread() const { return false; }
364     
365     virtual bool isRenderMultiColumnBlock() const { return false; }
366     virtual bool isRenderMultiColumnSet() const { return false; }
367
368     virtual bool isRenderScrollbarPart() const { return false; }
369     bool canHaveRegionStyle() const { return isRenderBlock() && !isAnonymous() && !isRenderFlowThread(); }
370
371     bool isRoot() const { return document()->documentElement() == m_node; }
372     bool isBody() const;
373     bool isHR() const;
374     bool isLegend() const;
375
376     bool isHTMLMarquee() const;
377
378     bool isTablePart() const { return isTableCell() || isRenderTableCol() || isTableCaption() || isTableRow() || isTableSection(); }
379
380     inline bool isBeforeContent() const;
381     inline bool isAfterContent() const;
382     inline bool isBeforeOrAfterContent() const;
383     static inline bool isBeforeContent(const RenderObject* obj) { return obj && obj->isBeforeContent(); }
384     static inline bool isAfterContent(const RenderObject* obj) { return obj && obj->isAfterContent(); }
385     static inline bool isBeforeOrAfterContent(const RenderObject* obj) { return obj && obj->isBeforeOrAfterContent(); }
386
387     bool hasCounterNodeMap() const { return m_bitfields.hasCounterNodeMap(); }
388     void setHasCounterNodeMap(bool hasCounterNodeMap) { m_bitfields.setHasCounterNodeMap(hasCounterNodeMap); }
389     bool everHadLayout() const { return m_bitfields.everHadLayout(); }
390
391     bool childrenInline() const { return m_bitfields.childrenInline(); }
392     void setChildrenInline(bool b) { m_bitfields.setChildrenInline(b); }
393     bool hasColumns() const { return m_bitfields.hasColumns(); }
394     void setHasColumns(bool b = true) { m_bitfields.setHasColumns(b); }
395
396     bool ancestorLineBoxDirty() const { return s_ancestorLineboxDirtySet && s_ancestorLineboxDirtySet->contains(this); }
397     void setAncestorLineBoxDirty(bool b = true)
398     {
399         if (b) {
400             if (!s_ancestorLineboxDirtySet)
401                 s_ancestorLineboxDirtySet = new RenderObjectAncestorLineboxDirtySet;
402             s_ancestorLineboxDirtySet->add(this);
403             setNeedsLayout(true);
404         } else if (s_ancestorLineboxDirtySet) {
405             s_ancestorLineboxDirtySet->remove(this);
406             if (s_ancestorLineboxDirtySet->isEmpty()) {
407                 delete s_ancestorLineboxDirtySet;
408                 s_ancestorLineboxDirtySet = 0;
409             }
410         }
411     }
412
413     bool inRenderFlowThread() const { return m_bitfields.inRenderFlowThread(); }
414     void setInRenderFlowThread(bool b = true) { m_bitfields.setInRenderFlowThread(b); }
415
416     virtual bool requiresForcedStyleRecalcPropagation() const { return false; }
417
418 #if ENABLE(MATHML)
419     virtual bool isRenderMathMLBlock() const { return false; }
420 #endif // ENABLE(MATHML)
421
422 #if ENABLE(SVG)
423     // FIXME: Until all SVG renders can be subclasses of RenderSVGModelObject we have
424     // to add SVG renderer methods to RenderObject with an ASSERT_NOT_REACHED() default implementation.
425     virtual bool isSVGRoot() const { return false; }
426     virtual bool isSVGContainer() const { return false; }
427     virtual bool isSVGTransformableContainer() const { return false; }
428     virtual bool isSVGViewportContainer() const { return false; }
429     virtual bool isSVGGradientStop() const { return false; }
430     virtual bool isSVGHiddenContainer() const { return false; }
431     virtual bool isSVGPath() const { return false; }
432     virtual bool isSVGShape() const { return false; }
433     virtual bool isSVGText() const { return false; }
434     virtual bool isSVGTextPath() const { return false; }
435     virtual bool isSVGInline() const { return false; }
436     virtual bool isSVGInlineText() const { return false; }
437     virtual bool isSVGImage() const { return false; }
438     virtual bool isSVGForeignObject() const { return false; }
439     virtual bool isSVGResourceContainer() const { return false; }
440     virtual bool isSVGResourceFilter() const { return false; }
441     virtual bool isSVGResourceFilterPrimitive() const { return false; }
442
443     virtual RenderSVGResourceContainer* toRenderSVGResourceContainer();
444
445     // FIXME: Those belong into a SVG specific base-class for all renderers (see above)
446     // Unfortunately we don't have such a class yet, because it's not possible for all renderers
447     // to inherit from RenderSVGObject -> RenderObject (some need RenderBlock inheritance for instance)
448     virtual void setNeedsTransformUpdate() { }
449     virtual void setNeedsBoundariesUpdate();
450
451     // Per SVG 1.1 objectBoundingBox ignores clipping, masking, filter effects, opacity and stroke-width.
452     // This is used for all computation of objectBoundingBox relative units and by SVGLocatable::getBBox().
453     // NOTE: Markers are not specifically ignored here by SVG 1.1 spec, but we ignore them
454     // since stroke-width is ignored (and marker size can depend on stroke-width).
455     // objectBoundingBox is returned local coordinates.
456     // The name objectBoundingBox is taken from the SVG 1.1 spec.
457     virtual FloatRect objectBoundingBox() const;
458     virtual FloatRect strokeBoundingBox() const;
459
460     // Returns the smallest rectangle enclosing all of the painted content
461     // respecting clipping, masking, filters, opacity, stroke-width and markers
462     virtual FloatRect repaintRectInLocalCoordinates() const;
463
464     // This only returns the transform="" value from the element
465     // most callsites want localToParentTransform() instead.
466     virtual AffineTransform localTransform() const;
467
468     // Returns the full transform mapping from local coordinates to local coords for the parent SVG renderer
469     // This includes any viewport transforms and x/y offsets as well as the transform="" value off the element.
470     virtual const AffineTransform& localToParentTransform() const;
471
472     // SVG uses FloatPoint precise hit testing, and passes the point in parent
473     // coordinates instead of in repaint container coordinates.  Eventually the
474     // rest of the rendering tree will move to a similar model.
475     virtual bool nodeAtFloatPoint(const HitTestRequest&, HitTestResult&, const FloatPoint& pointInParent, HitTestAction);
476 #endif
477
478     bool isAnonymous() const { return m_bitfields.isAnonymous(); }
479     void setIsAnonymous(bool b) { m_bitfields.setIsAnonymous(b); }
480     bool isAnonymousBlock() const
481     {
482         // This function is kept in sync with anonymous block creation conditions in
483         // RenderBlock::createAnonymousBlock(). This includes creating an anonymous
484         // RenderBlock having a BLOCK or BOX display. Other classes such as RenderTextFragment
485         // are not RenderBlocks and will return false. See https://bugs.webkit.org/show_bug.cgi?id=56709. 
486         return isAnonymous() && (style()->display() == BLOCK || style()->display() == BOX) && style()->styleType() == NOPSEUDO && isRenderBlock() && !isListMarker()
487 #if ENABLE(FULLSCREEN_API)
488             && !isRenderFullScreen()
489             && !isRenderFullScreenPlaceholder()
490 #endif
491 #if ENABLE(MATHML)
492             && !isRenderMathMLBlock()
493 #endif
494             ;
495     }
496     bool isAnonymousColumnsBlock() const { return style()->specifiesColumns() && isAnonymousBlock(); }
497     bool isAnonymousColumnSpanBlock() const { return style()->columnSpan() && isAnonymousBlock(); }
498     bool isElementContinuation() const { return node() && node()->renderer() != this; }
499     bool isInlineElementContinuation() const { return isElementContinuation() && isInline(); }
500     bool isBlockElementContinuation() const { return isElementContinuation() && !isInline(); }
501     virtual RenderBoxModelObject* virtualContinuation() const { return 0; }
502
503     bool isFloating() const { return m_bitfields.floating(); }
504     bool isOutOfFlowPositioned() const { return m_bitfields.positioned(); } // absolute or fixed positioning
505     bool isInFlowPositioned() const { return m_bitfields.relPositioned(); } // relative positioning
506     bool isRelPositioned() const { return m_bitfields.relPositioned(); } // relative positioning
507     bool isText() const  { return m_bitfields.isText(); }
508     bool isBox() const { return m_bitfields.isBox(); }
509     bool isInline() const { return m_bitfields.isInline(); } // inline object
510     bool isRunIn() const { return style()->display() == RUN_IN; } // run-in object
511     bool isDragging() const { return m_bitfields.isDragging(); }
512     bool isReplaced() const { return m_bitfields.isReplaced(); } // a "replaced" element (see CSS)
513     bool isHorizontalWritingMode() const { return m_bitfields.horizontalWritingMode(); }
514
515     bool hasLayer() const { return m_bitfields.hasLayer(); }
516     
517     bool hasBoxDecorations() const { return m_bitfields.paintBackground(); }
518     bool borderImageIsLoadedAndCanBeRendered() const;
519     bool mustRepaintBackgroundOrBorder() const;
520     bool hasBackground() const { return style()->hasBackground(); }
521     bool needsLayout() const
522     {
523         return m_bitfields.needsLayout() || m_bitfields.normalChildNeedsLayout() || m_bitfields.posChildNeedsLayout()
524             || m_bitfields.needsSimplifiedNormalFlowLayout() || m_bitfields.needsPositionedMovementLayout();
525     }
526
527     bool selfNeedsLayout() const { return m_bitfields.needsLayout(); }
528     bool needsPositionedMovementLayout() const { return m_bitfields.needsPositionedMovementLayout(); }
529     bool needsPositionedMovementLayoutOnly() const
530     {
531         return m_bitfields.needsPositionedMovementLayout() && !m_bitfields.needsLayout() && !m_bitfields.normalChildNeedsLayout()
532             && !m_bitfields.posChildNeedsLayout() && !m_bitfields.needsSimplifiedNormalFlowLayout();
533     }
534
535     bool posChildNeedsLayout() const { return m_bitfields.posChildNeedsLayout(); }
536     bool needsSimplifiedNormalFlowLayout() const { return m_bitfields.needsSimplifiedNormalFlowLayout(); }
537     bool normalChildNeedsLayout() const { return m_bitfields.normalChildNeedsLayout(); }
538     
539     bool preferredLogicalWidthsDirty() const { return m_bitfields.preferredLogicalWidthsDirty(); }
540
541     bool isSelectionBorder() const;
542
543     bool hasClip() const { return isOutOfFlowPositioned() && style()->hasClip(); }
544     bool hasOverflowClip() const { return m_bitfields.hasOverflowClip(); }
545     bool hasClipOrOverflowClip() const { return hasClip() || hasOverflowClip(); }
546
547     bool hasTransform() const { return m_bitfields.hasTransform(); }
548     bool hasMask() const { return style() && style()->hasMask(); }
549     bool hasClipPath() const { return style() && style()->clipPath(); }
550     bool hasHiddenBackface() const { return style() && style()->backfaceVisibility() == BackfaceVisibilityHidden; }
551
552 #if ENABLE(CSS_FILTERS)
553     bool hasFilter() const { return style() && style()->hasFilter(); }
554 #else
555     bool hasFilter() const { return false; }
556 #endif
557
558     inline bool preservesNewline() const;
559
560     // The pseudo element style can be cached or uncached.  Use the cached method if the pseudo element doesn't respect
561     // any pseudo classes (and therefore has no concept of changing state).
562     RenderStyle* getCachedPseudoStyle(PseudoId, RenderStyle* parentStyle = 0) const;
563     PassRefPtr<RenderStyle> getUncachedPseudoStyle(PseudoId, RenderStyle* parentStyle = 0, RenderStyle* ownStyle = 0) const;
564     
565     virtual void updateDragState(bool dragOn);
566
567     // Inlined into RenderView.h for performance and to avoid a cyclic dependency.
568     RenderView* view() const;
569
570     // Returns true if this renderer is rooted, and optionally returns the hosting view (the root of the hierarchy).
571     bool isRooted(RenderView** = 0);
572
573     Node* node() const { return isAnonymous() ? 0 : m_node; }
574
575     // Returns the styled node that caused the generation of this renderer.
576     // This is the same as node() except for renderers of :before and :after
577     // pseudo elements for which their parent node is returned.
578     Node* generatingNode() const { return m_node == document() ? 0 : m_node; }
579     void setNode(Node* node) { m_node = node; }
580
581     Document* document() const { return m_node->document(); }
582     Frame* frame() const { return document()->frame(); }
583
584     bool hasOutlineAnnotation() const;
585     bool hasOutline() const { return style()->hasOutline() || hasOutlineAnnotation(); }
586
587     // Returns the object containing this one. Can be different from parent for positioned elements.
588     // If repaintContainer and repaintContainerSkipped are not null, on return *repaintContainerSkipped
589     // is true if the renderer returned is an ancestor of repaintContainer.
590     RenderObject* container(const RenderBoxModelObject* repaintContainer = 0, bool* repaintContainerSkipped = 0) const;
591
592     virtual RenderObject* hoverAncestor() const { return parent(); }
593
594     // IE Extension that can be called on any RenderObject.  See the implementation for the details.
595     RenderBoxModelObject* offsetParent() const;
596
597     void markContainingBlocksForLayout(bool scheduleRelayout = true, RenderObject* newRoot = 0);
598     void setNeedsLayout(bool needsLayout, MarkingBehavior = MarkContainingBlockChain);
599     void setChildNeedsLayout(bool childNeedsLayout, MarkingBehavior = MarkContainingBlockChain);
600     void setNeedsPositionedMovementLayout();
601     void setNeedsSimplifiedNormalFlowLayout();
602     void setPreferredLogicalWidthsDirty(bool, MarkingBehavior = MarkContainingBlockChain);
603     void invalidateContainerPreferredLogicalWidths();
604     
605     void setNeedsLayoutAndPrefWidthsRecalc()
606     {
607         setNeedsLayout(true);
608         setPreferredLogicalWidthsDirty(true);
609     }
610
611     void setPositioned(bool b = true)  { m_bitfields.setPositioned(b);  }
612     void setRelPositioned(bool b = true) { m_bitfields.setRelPositioned(b); }
613     void setFloating(bool b = true) { m_bitfields.setFloating(b); }
614     void setInline(bool b = true) { m_bitfields.setIsInline(b); }
615     void setHasBoxDecorations(bool b = true) { m_bitfields.setPaintBackground(b); }
616     void setIsText() { m_bitfields.setIsText(true); }
617     void setIsBox() { m_bitfields.setIsBox(true); }
618     void setReplaced(bool b = true) { m_bitfields.setIsReplaced(b); }
619     void setHorizontalWritingMode(bool b = true) { m_bitfields.setHorizontalWritingMode(b); }
620     void setHasOverflowClip(bool b = true) { m_bitfields.setHasOverflowClip(b); }
621     void setHasLayer(bool b = true) { m_bitfields.setHasLayer(b); }
622     void setHasTransform(bool b = true) { m_bitfields.setHasTransform(b); }
623     void setHasReflection(bool b = true) { m_bitfields.setHasReflection(b); }
624
625     void scheduleRelayout();
626
627     void updateFillImages(const FillLayer*, const FillLayer*);
628     void updateImage(StyleImage*, StyleImage*);
629
630     virtual void paint(PaintInfo&, const LayoutPoint&);
631
632     // Recursive function that computes the size and position of this object and all its descendants.
633     virtual void layout();
634
635     /* This function performs a layout only if one is needed. */
636     void layoutIfNeeded() { if (needsLayout()) layout(); }
637     
638     // used for element state updates that cannot be fixed with a
639     // repaint and do not need a relayout
640     virtual void updateFromElement() { }
641
642 #if ENABLE(DASHBOARD_SUPPORT)
643     virtual void addDashboardRegions(Vector<DashboardRegionValue>&);
644     void collectDashboardRegions(Vector<DashboardRegionValue>&);
645 #endif
646
647     bool isComposited() const;
648
649     bool hitTest(const HitTestRequest&, HitTestResult&, const HitTestPoint& pointInContainer, const LayoutPoint& accumulatedOffset, HitTestFilter = HitTestAll);
650     virtual void updateHitTestResult(HitTestResult&, const LayoutPoint&);
651     virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestPoint& pointInContainer, const LayoutPoint& accumulatedOffset, HitTestAction);
652
653     virtual VisiblePosition positionForPoint(const LayoutPoint&);
654     VisiblePosition createVisiblePosition(int offset, EAffinity);
655     VisiblePosition createVisiblePosition(const Position&);
656
657     virtual void dirtyLinesFromChangedChild(RenderObject*);
658
659     // Called to update a style that is allowed to trigger animations.
660     // FIXME: Right now this will typically be called only when updating happens from the DOM on explicit elements.
661     // We don't yet handle generated content animation such as first-letter or before/after (we'll worry about this later).
662     void setAnimatableStyle(PassRefPtr<RenderStyle>);
663
664     // Set the style of the object and update the state of the object accordingly.
665     virtual void setStyle(PassRefPtr<RenderStyle>);
666
667     // Updates only the local style ptr of the object.  Does not update the state of the object,
668     // and so only should be called when the style is known not to have changed (or from setStyle).
669     void setStyleInternal(PassRefPtr<RenderStyle>);
670
671     // returns the containing block level element for this element.
672     RenderBlock* containingBlock() const;
673
674     // Convert the given local point to absolute coordinates
675     // FIXME: Temporary. If useTransforms is true, take transforms into account. Eventually localToAbsolute() will always be transform-aware.
676     FloatPoint localToAbsolute(const FloatPoint& localPoint = FloatPoint(), bool fixed = false, bool useTransforms = false) const;
677     FloatPoint absoluteToLocal(const FloatPoint&, bool fixed = false, bool useTransforms = false) const;
678
679     // Convert a local quad to absolute coordinates, taking transforms into account.
680 #if ENABLE(TIZEN_NOT_USE_TRANSFORM_INFO_WHEN_GETTING_CARET_RECT)
681     FloatQuad localToAbsoluteQuad(const FloatQuad& quad, bool fixed = false, bool* wasFixed = 0, bool useTransforms = true) const
682     {
683         return localToContainerQuad(quad, 0, fixed, wasFixed, useTransforms);
684     }
685 #else
686     FloatQuad localToAbsoluteQuad(const FloatQuad& quad, bool fixed = false, bool* wasFixed = 0) const
687     {
688         return localToContainerQuad(quad, 0, fixed, wasFixed);
689     }
690 #endif
691
692     // Convert a local quad into the coordinate system of container, taking transforms into account.
693 #if ENABLE(TIZEN_NOT_USE_TRANSFORM_INFO_WHEN_GETTING_CARET_RECT)
694     FloatQuad localToContainerQuad(const FloatQuad&, RenderBoxModelObject* repaintContainer, bool fixed = false, bool* wasFixed = 0, bool useTransforms = true) const;
695 #else
696     FloatQuad localToContainerQuad(const FloatQuad&, RenderBoxModelObject* repaintContainer, bool fixed = false, bool* wasFixed = 0) const;
697 #endif
698
699     FloatPoint localToContainerPoint(const FloatPoint&, RenderBoxModelObject* repaintContainer, bool fixed = false, bool* wasFixed = 0) const;
700
701     // Return the offset from the container() renderer (excluding transforms). In multi-column layout,
702     // different offsets apply at different points, so return the offset that applies to the given point.
703     virtual LayoutSize offsetFromContainer(RenderObject*, const LayoutPoint&, bool* offsetDependsOnPoint = 0) const;
704     // Return the offset from an object up the container() chain. Asserts that none of the intermediate objects have transforms.
705     LayoutSize offsetFromAncestorContainer(RenderObject*) const;
706     
707     virtual void absoluteRects(Vector<IntRect>&, const LayoutPoint&) const { }
708
709     // FIXME: useTransforms should go away eventually
710     IntRect absoluteBoundingBoxRect(bool useTransform = true) const;
711     IntRect absoluteBoundingBoxRectIgnoringTransforms() const { return absoluteBoundingBoxRect(false); }
712
713     // Build an array of quads in absolute coords for line boxes
714     virtual void absoluteQuads(Vector<FloatQuad>&, bool* /*wasFixed*/ = 0) const { }
715
716     void absoluteFocusRingQuads(Vector<FloatQuad>&);
717
718     // the rect that will be painted if this object is passed as the paintingRoot
719     LayoutRect paintingRootRect(LayoutRect& topLevelRect);
720
721     virtual LayoutUnit minPreferredLogicalWidth() const { return 0; }
722     virtual LayoutUnit maxPreferredLogicalWidth() const { return 0; }
723
724     RenderStyle* style() const { return m_style.get(); }
725     RenderStyle* firstLineStyle() const { return document()->usesFirstLineRules() ? firstLineStyleSlowCase() : style(); }
726     RenderStyle* style(bool firstLine) const { return firstLine ? firstLineStyle() : style(); }
727
728     // Used only by Element::pseudoStyleCacheIsInvalid to get a first line style based off of a
729     // given new style, without accessing the cache.
730     PassRefPtr<RenderStyle> uncachedFirstLineStyle(RenderStyle*) const;
731
732     // Anonymous blocks that are part of of a continuation chain will return their inline continuation's outline style instead.
733     // This is typically only relevant when repainting.
734     virtual RenderStyle* outlineStyleForRepaint() const { return style(); }
735     
736     virtual CursorDirective getCursor(const LayoutPoint&, Cursor&) const;
737
738     void getTextDecorationColors(int decorations, Color& underline, Color& overline, Color& linethrough, bool quirksMode = false, bool firstlineStyle = false);
739
740     // Return the RenderBox in the container chain which is responsible for painting this object, or 0
741     // if painting is root-relative. This is the container that should be passed to the 'forRepaint'
742     // methods.
743     RenderBoxModelObject* containerForRepaint() const;
744     // Actually do the repaint of rect r for this object which has been computed in the coordinate space
745     // of repaintContainer. If repaintContainer is 0, repaint via the view.
746     void repaintUsingContainer(RenderBoxModelObject* repaintContainer, const LayoutRect&, bool immediate = false);
747     
748     // Repaint the entire object.  Called when, e.g., the color of a border changes, or when a border
749     // style changes.
750     void repaint(bool immediate = false);
751
752     // Repaint a specific subrectangle within a given object.  The rect |r| is in the object's coordinate space.
753     void repaintRectangle(const LayoutRect&, bool immediate = false);
754
755     // Repaint only if our old bounds and new bounds are different. The caller may pass in newBounds and newOutlineBox if they are known.
756     bool repaintAfterLayoutIfNeeded(RenderBoxModelObject* repaintContainer, const LayoutRect& oldBounds, const LayoutRect& oldOutlineBox, const LayoutRect* newBoundsPtr = 0, const LayoutRect* newOutlineBoxPtr = 0);
757
758     // Repaint only if the object moved.
759     virtual void repaintDuringLayoutIfMoved(const LayoutRect&);
760
761     // Called to repaint a block's floats.
762     virtual void repaintOverhangingFloats(bool paintAllDescendants = false);
763
764     bool checkForRepaintDuringLayout() const;
765
766     // Returns the rect that should be repainted whenever this object changes.  The rect is in the view's
767     // coordinate space.  This method deals with outlines and overflow.
768     LayoutRect absoluteClippedOverflowRect() const
769     {
770         return clippedOverflowRectForRepaint(0);
771     }
772     IntRect pixelSnappedAbsoluteClippedOverflowRect() const;
773     virtual LayoutRect clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer) const;
774     virtual LayoutRect rectWithOutlineForRepaint(RenderBoxModelObject* repaintContainer, LayoutUnit outlineWidth) const;
775
776     // Given a rect in the object's coordinate space, compute a rect suitable for repainting
777     // that rect in view coordinates.
778     void computeAbsoluteRepaintRect(LayoutRect& r, bool fixed = false) const
779     {
780         computeRectForRepaint(0, r, fixed);
781     }
782     // Given a rect in the object's coordinate space, compute a rect suitable for repainting
783     // that rect in the coordinate space of repaintContainer.
784     virtual void computeRectForRepaint(RenderBoxModelObject* repaintContainer, LayoutRect&, bool fixed = false) const;
785     virtual void computeFloatRectForRepaint(RenderBoxModelObject* repaintContainer, FloatRect& repaintRect, bool fixed = false) const;
786
787     // If multiple-column layout results in applying an offset to the given point, add the same
788     // offset to the given size.
789     virtual void adjustForColumns(LayoutSize&, const LayoutPoint&) const { }
790     LayoutSize offsetForColumns(const LayoutPoint& point) const
791     {
792         LayoutSize offset;
793         adjustForColumns(offset, point);
794         return offset;
795     }
796
797     virtual unsigned int length() const { return 1; }
798
799     bool isFloatingOrOutOfFlowPositioned() const { return (isFloating() || isOutOfFlowPositioned()); }
800
801     bool isTransparent() const { return style()->opacity() < 1.0f; }
802     float opacity() const { return style()->opacity(); }
803
804     bool hasReflection() const { return m_bitfields.hasReflection(); }
805
806     // Applied as a "slop" to dirty rect checks during the outline painting phase's dirty-rect checks.
807     int maximalOutlineSize(PaintPhase) const;
808
809     enum SelectionState {
810         SelectionNone, // The object is not selected.
811         SelectionStart, // The object either contains the start of a selection run or is the start of a run
812         SelectionInside, // The object is fully encompassed by a selection run
813         SelectionEnd, // The object either contains the end of a selection run or is the end of a run
814         SelectionBoth // The object contains an entire run or is the sole selected object in that run
815     };
816
817     // The current selection state for an object.  For blocks, the state refers to the state of the leaf
818     // descendants (as described above in the SelectionState enum declaration).
819     SelectionState selectionState() const { return m_bitfields.selectionState(); }
820     virtual void setSelectionState(SelectionState state) { m_bitfields.setSelectionState(state); }
821     inline void setSelectionStateIfNeeded(SelectionState);
822     bool canUpdateSelectionOnRootLineBoxes();
823
824     // A single rectangle that encompasses all of the selected objects within this object.  Used to determine the tightest
825     // possible bounding box for the selection.
826     LayoutRect selectionRect(bool clipToVisibleContent = true) { return selectionRectForRepaint(0, clipToVisibleContent); }
827     virtual LayoutRect selectionRectForRepaint(RenderBoxModelObject* /*repaintContainer*/, bool /*clipToVisibleContent*/ = true) { return LayoutRect(); }
828
829     virtual bool canBeSelectionLeaf() const { return false; }
830     bool hasSelectedChildren() const { return selectionState() != SelectionNone; }
831
832     // Obtains the selection colors that should be used when painting a selection.
833     Color selectionBackgroundColor() const;
834     Color selectionForegroundColor() const;
835     Color selectionEmphasisMarkColor() const;
836
837     // Whether or not a given block needs to paint selection gaps.
838     virtual bool shouldPaintSelectionGaps() const { return false; }
839
840     /**
841      * Returns the local coordinates of the caret within this render object.
842      * @param caretOffset zero-based offset determining position within the render object.
843      * @param extraWidthToEndOfLine optional out arg to give extra width to end of line -
844      * useful for character range rect computations
845      */
846     virtual LayoutRect localCaretRect(InlineBox*, int caretOffset, LayoutUnit* extraWidthToEndOfLine = 0);
847
848     bool isMarginBeforeQuirk() const { return m_bitfields.marginBeforeQuirk(); }
849     bool isMarginAfterQuirk() const { return m_bitfields.marginAfterQuirk(); }
850     void setMarginBeforeQuirk(bool b = true) { m_bitfields.setMarginBeforeQuirk(b); }
851     void setMarginAfterQuirk(bool b = true) { m_bitfields.setMarginAfterQuirk(b); }
852
853     // When performing a global document tear-down, the renderer of the document is cleared.  We use this
854     // as a hook to detect the case of document destruction and don't waste time doing unnecessary work.
855     bool documentBeingDestroyed() const;
856
857     void destroyAndCleanupAnonymousWrappers();
858     virtual void destroy();
859
860     // Virtual function helpers for the deprecated Flexible Box Layout (display: -webkit-box).
861     virtual bool isDeprecatedFlexibleBox() const { return false; }
862     virtual bool isFlexingChildren() const { return false; }
863     virtual bool isStretchingChildren() const { return false; }
864
865     // Virtual function helper for the new FlexibleBox Layout (display: -webkit-flex).
866     virtual bool isFlexibleBox() const { return false; }
867
868     bool isFlexibleBoxIncludingDeprecated() const
869     {
870         return isFlexibleBox() || isDeprecatedFlexibleBox();
871     }
872
873     virtual bool isCombineText() const { return false; }
874
875     virtual int caretMinOffset() const;
876     virtual int caretMaxOffset() const;
877
878     virtual int previousOffset(int current) const;
879     virtual int previousOffsetForBackwardDeletion(int current) const;
880     virtual int nextOffset(int current) const;
881
882     virtual void imageChanged(CachedImage*, const IntRect* = 0);
883     virtual void imageChanged(WrappedImagePtr, const IntRect* = 0) { }
884     virtual bool willRenderImage(CachedImage*);
885
886     void selectionStartEnd(int& spos, int& epos) const;
887     
888     void remove() { if (parent()) parent()->removeChild(this); }
889
890     AnimationController* animation() const;
891
892     bool visibleToHitTesting() const { return style()->visibility() == VISIBLE && style()->pointerEvents() != PE_NONE; }
893
894     // Map points and quads through elements, potentially via 3d transforms. You should never need to call these directly; use
895     // localToAbsolute/absoluteToLocal methods instead.
896     enum ApplyContainerFlipOrNot { DoNotApplyContainerFlip, ApplyContainerFlip };
897     virtual void mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool useTransforms, bool fixed, TransformState&, ApplyContainerFlipOrNot = ApplyContainerFlip, bool* wasFixed = 0) const;
898     virtual void mapAbsoluteToLocalPoint(bool fixed, bool useTransforms, TransformState&) const;
899
900     // Pushes state onto RenderGeometryMap about how to map coordinates from this renderer to its container, or ancestorToStopAt (whichever is encountered first).
901     // Returns the renderer which was mapped to (container or ancestorToStopAt).
902     virtual const RenderObject* pushMappingToContainer(const RenderBoxModelObject* ancestorToStopAt, RenderGeometryMap&) const;
903     
904     bool shouldUseTransformFromContainer(const RenderObject* container) const;
905     void getTransformFromContainer(const RenderObject* container, const LayoutSize& offsetInContainer, TransformationMatrix&) const;
906     
907     virtual void addFocusRingRects(Vector<IntRect>&, const LayoutPoint&) { };
908
909     LayoutRect absoluteOutlineBounds() const
910     {
911         return outlineBoundsForRepaint(0);
912     }
913
914     // Return the renderer whose background style is used to paint the root background. Should only be called on the renderer for which isRoot() is true.
915     RenderObject* rendererForRootBackground();
916
917     RespectImageOrientationEnum shouldRespectImageOrientation() const;
918
919 protected:
920     inline bool layerCreationAllowedForSubtree() const;
921
922     // Overrides should call the superclass at the end
923     virtual void styleWillChange(StyleDifference, const RenderStyle* newStyle);
924     // Overrides should call the superclass at the start
925     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
926     void propagateStyleToAnonymousChildren(bool blockChildrenOnly = false);
927
928     void drawLineForBoxSide(GraphicsContext*, int x1, int y1, int x2, int y2, BoxSide,
929                             Color, EBorderStyle, int adjbw1, int adjbw2, bool antialias = false);
930
931     void paintFocusRing(GraphicsContext*, const LayoutPoint&, RenderStyle*);
932     void paintOutline(GraphicsContext*, const LayoutRect&);
933     void addPDFURLRect(GraphicsContext*, const LayoutRect&);
934
935     virtual LayoutRect viewRect() const;
936
937     void adjustRectForOutlineAndShadow(LayoutRect&) const;
938
939     void clearLayoutRootIfNeeded() const;
940     virtual void willBeDestroyed();
941     void arenaDelete(RenderArena*, void* objectBase);
942
943     virtual LayoutRect outlineBoundsForRepaint(RenderBoxModelObject* /*repaintContainer*/, LayoutPoint* /*cachedOffsetToRepaintContainer*/ = 0) const { return LayoutRect(); }
944
945 private:
946     RenderStyle* firstLineStyleSlowCase() const;
947     StyleDifference adjustStyleDifference(StyleDifference, unsigned contextSensitiveProperties) const;
948
949     Color selectionColor(int colorProperty) const;
950
951 #ifndef NDEBUG
952     void checkBlockPositionedObjectsNeedLayout();
953 #endif
954
955     RefPtr<RenderStyle> m_style;
956
957     Node* m_node;
958
959     RenderObject* m_parent;
960     RenderObject* m_previous;
961     RenderObject* m_next;
962
963     static RenderObjectAncestorLineboxDirtySet* s_ancestorLineboxDirtySet;
964
965 #ifndef NDEBUG
966     bool m_hasAXObject             : 1;
967     bool m_setNeedsLayoutForbidden : 1;
968 #endif
969
970 #define ADD_BOOLEAN_BITFIELD(name, Name) \
971     private:\
972         unsigned m_##name : 1;\
973     public:\
974         bool name() const { return m_##name; }\
975         void set##Name(bool name) { m_##name = name; }\
976
977     class RenderObjectBitfields {
978     public:
979         RenderObjectBitfields(Node* node)
980             : m_needsLayout(false)
981             , m_needsPositionedMovementLayout(false)
982             , m_normalChildNeedsLayout(false)
983             , m_posChildNeedsLayout(false)
984             , m_needsSimplifiedNormalFlowLayout(false)
985             , m_preferredLogicalWidthsDirty(false)
986             , m_floating(false)
987             , m_positioned(false)
988             , m_relPositioned(false)
989             , m_paintBackground(false)
990             , m_isAnonymous(node == node->document())
991             , m_isText(false)
992             , m_isBox(false)
993             , m_isInline(true)
994             , m_isReplaced(false)
995             , m_horizontalWritingMode(true)
996             , m_isDragging(false)
997             , m_hasLayer(false)
998             , m_hasOverflowClip(false)
999             , m_hasTransform(false)
1000             , m_hasReflection(false)
1001             , m_hasCounterNodeMap(false)
1002             , m_everHadLayout(false)
1003             , m_inRenderFlowThread(false)
1004             , m_childrenInline(false)
1005             , m_marginBeforeQuirk(false) 
1006             , m_marginAfterQuirk(false)
1007             , m_hasColumns(false)
1008             , m_selectionState(SelectionNone)
1009         {
1010         }
1011         
1012         // 32 bits have been used here. THERE ARE NO FREE BITS AVAILABLE.
1013         ADD_BOOLEAN_BITFIELD(needsLayout, NeedsLayout);
1014         ADD_BOOLEAN_BITFIELD(needsPositionedMovementLayout, NeedsPositionedMovementLayout);
1015         ADD_BOOLEAN_BITFIELD(normalChildNeedsLayout, NormalChildNeedsLayout);
1016         ADD_BOOLEAN_BITFIELD(posChildNeedsLayout, PosChildNeedsLayout);
1017         ADD_BOOLEAN_BITFIELD(needsSimplifiedNormalFlowLayout, NeedsSimplifiedNormalFlowLayout);
1018         ADD_BOOLEAN_BITFIELD(preferredLogicalWidthsDirty, PreferredLogicalWidthsDirty);
1019         ADD_BOOLEAN_BITFIELD(floating, Floating);
1020
1021         ADD_BOOLEAN_BITFIELD(positioned, Positioned);
1022         ADD_BOOLEAN_BITFIELD(relPositioned, RelPositioned);
1023         ADD_BOOLEAN_BITFIELD(paintBackground, PaintBackground); // if the box has something to paint in the
1024         // background painting phase (background, border, etc)
1025
1026         ADD_BOOLEAN_BITFIELD(isAnonymous, IsAnonymous);
1027         ADD_BOOLEAN_BITFIELD(isText, IsText);
1028         ADD_BOOLEAN_BITFIELD(isBox, IsBox);
1029         ADD_BOOLEAN_BITFIELD(isInline, IsInline);
1030         ADD_BOOLEAN_BITFIELD(isReplaced, IsReplaced);
1031         ADD_BOOLEAN_BITFIELD(horizontalWritingMode, HorizontalWritingMode);
1032         ADD_BOOLEAN_BITFIELD(isDragging, IsDragging);
1033
1034         ADD_BOOLEAN_BITFIELD(hasLayer, HasLayer);
1035         ADD_BOOLEAN_BITFIELD(hasOverflowClip, HasOverflowClip); // Set in the case of overflow:auto/scroll/hidden
1036         ADD_BOOLEAN_BITFIELD(hasTransform, HasTransform);
1037         ADD_BOOLEAN_BITFIELD(hasReflection, HasReflection);
1038
1039         ADD_BOOLEAN_BITFIELD(hasCounterNodeMap, HasCounterNodeMap);
1040         ADD_BOOLEAN_BITFIELD(everHadLayout, EverHadLayout);
1041
1042         // These bitfields are moved here from subclasses to pack them together.
1043         // from RenderFlowThread
1044         ADD_BOOLEAN_BITFIELD(inRenderFlowThread, InRenderFlowThread);
1045
1046         // from RenderBlock
1047         ADD_BOOLEAN_BITFIELD(childrenInline, ChildrenInline);
1048         ADD_BOOLEAN_BITFIELD(marginBeforeQuirk, MarginBeforeQuirk);
1049         ADD_BOOLEAN_BITFIELD(marginAfterQuirk, MarginAfterQuirk);
1050         ADD_BOOLEAN_BITFIELD(hasColumns, HasColumns);
1051
1052     private:
1053         unsigned m_selectionState : 3; // SelectionState
1054
1055     public:
1056         ALWAYS_INLINE SelectionState selectionState() const { return static_cast<SelectionState>(m_selectionState); }
1057         ALWAYS_INLINE void setSelectionState(SelectionState selectionState) { m_selectionState = selectionState; }
1058     };
1059
1060 #undef ADD_BOOLEAN_BITFIELD
1061
1062     RenderObjectBitfields m_bitfields;
1063
1064     void setNeedsPositionedMovementLayout(bool b) { m_bitfields.setNeedsPositionedMovementLayout(b); }
1065     void setNormalChildNeedsLayout(bool b) { m_bitfields.setNormalChildNeedsLayout(b); }
1066     void setPosChildNeedsLayout(bool b) { m_bitfields.setPosChildNeedsLayout(b); }
1067     void setNeedsSimplifiedNormalFlowLayout(bool b) { m_bitfields.setNeedsSimplifiedNormalFlowLayout(b); }
1068     void setPaintBackground(bool b) { m_bitfields.setPaintBackground(b); }
1069     void setIsDragging(bool b) { m_bitfields.setIsDragging(b); }
1070     void setEverHadLayout(bool b) { m_bitfields.setEverHadLayout(b); }
1071
1072 private:
1073     // Store state between styleWillChange and styleDidChange
1074     static bool s_affectsParentBlock;
1075 };
1076
1077 inline bool RenderObject::documentBeingDestroyed() const
1078 {
1079     return !document()->renderer();
1080 }
1081
1082 inline bool RenderObject::isBeforeContent() const
1083 {
1084     if (style()->styleType() != BEFORE)
1085         return false;
1086     // Text nodes don't have their own styles, so ignore the style on a text node.
1087     if (isText() && !isBR())
1088         return false;
1089     return true;
1090 }
1091
1092 inline bool RenderObject::isAfterContent() const
1093 {
1094     if (style()->styleType() != AFTER)
1095         return false;
1096     // Text nodes don't have their own styles, so ignore the style on a text node.
1097     if (isText() && !isBR())
1098         return false;
1099     return true;
1100 }
1101
1102 inline bool RenderObject::isBeforeOrAfterContent() const
1103 {
1104     return isBeforeContent() || isAfterContent();
1105 }
1106
1107 inline void RenderObject::setNeedsLayout(bool needsLayout, MarkingBehavior markParents)
1108 {
1109     bool alreadyNeededLayout = m_bitfields.needsLayout();
1110     m_bitfields.setNeedsLayout(needsLayout);
1111     if (needsLayout) {
1112         ASSERT(!isSetNeedsLayoutForbidden());
1113         if (!alreadyNeededLayout) {
1114             if (markParents == MarkContainingBlockChain)
1115                 markContainingBlocksForLayout();
1116             if (hasLayer())
1117                 setLayerNeedsFullRepaint();
1118         }
1119     } else {
1120         setEverHadLayout(true);
1121         setPosChildNeedsLayout(false);
1122         setNeedsSimplifiedNormalFlowLayout(false);
1123         setNormalChildNeedsLayout(false);
1124         setNeedsPositionedMovementLayout(false);
1125         setAncestorLineBoxDirty(false);
1126 #ifndef NDEBUG
1127         checkBlockPositionedObjectsNeedLayout();
1128 #endif
1129     }
1130 }
1131
1132 inline void RenderObject::setChildNeedsLayout(bool childNeedsLayout, MarkingBehavior markParents)
1133 {
1134     bool alreadyNeededLayout = normalChildNeedsLayout();
1135     setNormalChildNeedsLayout(childNeedsLayout);
1136     if (childNeedsLayout) {
1137         ASSERT(!isSetNeedsLayoutForbidden());
1138         if (!alreadyNeededLayout && markParents == MarkContainingBlockChain)
1139             markContainingBlocksForLayout();
1140     } else {
1141         setPosChildNeedsLayout(false);
1142         setNeedsSimplifiedNormalFlowLayout(false);
1143         setNormalChildNeedsLayout(false);
1144         setNeedsPositionedMovementLayout(false);
1145     }
1146 }
1147
1148 inline void RenderObject::setNeedsPositionedMovementLayout()
1149 {
1150     bool alreadyNeededLayout = needsPositionedMovementLayout();
1151     setNeedsPositionedMovementLayout(true);
1152     ASSERT(!isSetNeedsLayoutForbidden());
1153     if (!alreadyNeededLayout) {
1154         markContainingBlocksForLayout();
1155         if (hasLayer())
1156             setLayerNeedsFullRepaintForPositionedMovementLayout();
1157     }
1158 }
1159
1160 inline void RenderObject::setNeedsSimplifiedNormalFlowLayout()
1161 {
1162     bool alreadyNeededLayout = needsSimplifiedNormalFlowLayout();
1163     setNeedsSimplifiedNormalFlowLayout(true);
1164     ASSERT(!isSetNeedsLayoutForbidden());
1165     if (!alreadyNeededLayout) {
1166         markContainingBlocksForLayout();
1167         if (hasLayer())
1168             setLayerNeedsFullRepaint();
1169     }
1170 }
1171
1172 inline bool RenderObject::preservesNewline() const
1173 {
1174 #if ENABLE(SVG)
1175     if (isSVGInlineText())
1176         return false;
1177 #endif
1178         
1179     return style()->preserveNewline();
1180 }
1181
1182 inline bool RenderObject::layerCreationAllowedForSubtree() const
1183 {
1184 #if ENABLE(SVG)
1185     RenderObject* parentRenderer = parent();
1186     while (parentRenderer) {
1187         if (parentRenderer->isSVGHiddenContainer())
1188             return false;
1189         parentRenderer = parentRenderer->parent();
1190     }
1191 #endif
1192
1193     return true;
1194 }
1195
1196 inline void RenderObject::setSelectionStateIfNeeded(SelectionState state)
1197 {
1198     if (selectionState() == state)
1199         return;
1200
1201     setSelectionState(state);
1202 }
1203
1204 inline void makeMatrixRenderable(TransformationMatrix& matrix, bool has3DRendering)
1205 {
1206 #if !ENABLE(3D_RENDERING)
1207     UNUSED_PARAM(has3DRendering);
1208     matrix.makeAffine();
1209 #else
1210     if (!has3DRendering)
1211         matrix.makeAffine();
1212 #endif
1213 }
1214
1215 inline int adjustForAbsoluteZoom(int value, RenderObject* renderer)
1216 {
1217     return adjustForAbsoluteZoom(value, renderer->style());
1218 }
1219
1220 inline void adjustFloatQuadForAbsoluteZoom(FloatQuad& quad, RenderObject* renderer)
1221 {
1222     float zoom = renderer->style()->effectiveZoom();
1223     if (zoom != 1)
1224         quad.scale(1 / zoom, 1 / zoom);
1225 }
1226
1227 inline void adjustFloatRectForAbsoluteZoom(FloatRect& rect, RenderObject* renderer)
1228 {
1229     float zoom = renderer->style()->effectiveZoom();
1230     if (zoom != 1)
1231         rect.scale(1 / zoom, 1 / zoom);
1232 }
1233
1234 } // namespace WebCore
1235
1236 #ifndef NDEBUG
1237 // Outside the WebCore namespace for ease of invocation from gdb.
1238 void showTree(const WebCore::RenderObject*);
1239 void showLineTree(const WebCore::RenderObject*);
1240 void showRenderTree(const WebCore::RenderObject* object1);
1241 // We don't make object2 an optional parameter so that showRenderTree
1242 // can be called from gdb easily.
1243 void showRenderTree(const WebCore::RenderObject* object1, const WebCore::RenderObject* object2);
1244 #endif
1245
1246 #endif // RenderObject_h