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.
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.
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.
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.
26 #ifndef RenderObject_h
27 #define RenderObject_h
29 #include "CachedImage.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>
46 class AffineTransform;
47 class AnimationController;
53 class OverlapTestRequestClient;
56 class RenderBoxModelObject;
59 class RenderFlowThread;
60 class RenderGeometryMap;
65 class VisiblePosition;
67 class RenderSVGResourceContainer;
72 enum CursorDirective {
73 SetCursorBasedOnStyle,
85 HitTestBlockBackground,
86 HitTestChildBlockBackground,
87 HitTestChildBlockBackgrounds,
92 // Sides used when drawing borders and outlines. The values should run clockwise from top.
100 enum MarkingBehavior {
102 MarkContainingBlockChain,
105 #if ENABLE(TIZEN_ENLARGE_CARET_WIDTH)
106 const int caretWidth = 3;
108 const int caretWidth = 1;
110 enum PlaceGeneratedRunInFlag {
112 DoNotPlaceGeneratedRunIn
114 #if ENABLE(DASHBOARD_SUPPORT)
115 struct DashboardRegionValue {
116 bool operator==(const DashboardRegionValue& o) const
118 return type == o.type && bounds == o.bounds && clip == o.clip && label == o.label;
120 bool operator!=(const DashboardRegionValue& o) const
122 return !(*this == o);
132 typedef WTF::HashSet<const RenderObject*> RenderObjectAncestorLineboxDirtySet;
135 const int showTreeCharacterOffset = 39;
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;
147 // Anonymous objects should pass the document as their node, and they will then automatically be
148 // marked as anonymous in the constructor.
150 virtual ~RenderObject();
152 RenderTheme* theme() const;
154 virtual const char* renderName() const = 0;
156 RenderObject* parent() const { return m_parent; }
157 bool isDescendantOf(const RenderObject*) const;
159 RenderObject* previousSibling() const { return m_previous; }
160 RenderObject* nextSibling() const { return m_next; }
162 RenderObject* firstChild() const
164 if (const RenderObjectChildList* children = virtualChildren())
165 return children->firstChild();
168 RenderObject* lastChild() const
170 if (const RenderObjectChildList* children = virtualChildren())
171 return children->lastChild();
174 RenderObject* beforePseudoElementRenderer() const
176 if (const RenderObjectChildList* children = virtualChildren())
177 return children->beforePseudoElementRenderer(this);
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
186 if (const RenderObjectChildList* children = virtualChildren())
187 return children->afterPseudoElementRenderer(this);
191 virtual RenderObjectChildList* virtualChildren() { return 0; }
192 virtual const RenderObjectChildList* virtualChildren() const { return 0; }
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;
202 RenderObject* firstLeafChild() const;
203 RenderObject* lastLeafChild() const;
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);
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);
217 // Convenience function for getting to the nearest enclosing box of a RenderObject.
218 RenderBox* enclosingBox() const;
219 RenderBoxModelObject* enclosingBoxModelObject() const;
221 // Function to return our enclosing flow thread if we are contained inside one.
222 RenderFlowThread* enclosingRenderFlowThread() const;
224 virtual bool isEmpty() const { return firstChild() == 0; }
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; }
233 // Obtains the nearest enclosing block (including this block) that contributes a first-line style to our inline
235 virtual RenderBlock* firstLineBlock() const;
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();
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 //////////////////////////////////////////
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)
261 if (parent && parent->inRenderFlowThread())
262 setInRenderFlowThread(true);
263 else if (!parent && inRenderFlowThread())
264 setInRenderFlowThread(false);
266 //////////////////////////////////////////
268 void addAbsoluteRectForLayer(LayoutRect& result);
269 void setLayerNeedsFullRepaint();
270 void setLayerNeedsFullRepaintForPositionedMovementLayout();
274 void showTreeForThis() const;
275 void showRenderTreeForThis() const;
276 void showLineTreeForThis() const;
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;
285 static RenderObject* createObject(Node*, RenderStyle*);
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*);
291 // Overridden to prevent the normal delete from being called.
292 void operator delete(void*, size_t);
295 // The normal operator new is disallowed on all render objects.
296 void* operator new(size_t) throw();
299 RenderArena* renderArena() const { return document()->renderArena(); }
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; }
307 #if ENABLE(DETAILS_ELEMENT)
308 virtual bool isDetailsMarker() const { return false; }
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; }
325 #if ENABLE(PROGRESS_ELEMENT)
326 virtual bool isProgress() const { return false; }
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; }
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; }
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; }
362 virtual bool isRenderFlowThread() const { return false; }
363 virtual bool isRenderNamedFlowThread() const { return false; }
365 virtual bool isRenderMultiColumnBlock() const { return false; }
366 virtual bool isRenderMultiColumnSet() const { return false; }
368 virtual bool isRenderScrollbarPart() const { return false; }
369 bool canHaveRegionStyle() const { return isRenderBlock() && !isAnonymous() && !isRenderFlowThread(); }
371 bool isRoot() const { return document()->documentElement() == m_node; }
374 bool isLegend() const;
376 bool isHTMLMarquee() const;
378 bool isTablePart() const { return isTableCell() || isRenderTableCol() || isTableCaption() || isTableRow() || isTableSection(); }
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(); }
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(); }
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); }
396 bool ancestorLineBoxDirty() const { return s_ancestorLineboxDirtySet && s_ancestorLineboxDirtySet->contains(this); }
397 void setAncestorLineBoxDirty(bool b = true)
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;
413 bool inRenderFlowThread() const { return m_bitfields.inRenderFlowThread(); }
414 void setInRenderFlowThread(bool b = true) { m_bitfields.setInRenderFlowThread(b); }
416 virtual bool requiresForcedStyleRecalcPropagation() const { return false; }
419 virtual bool isRenderMathMLBlock() const { return false; }
420 #endif // ENABLE(MATHML)
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; }
443 virtual RenderSVGResourceContainer* toRenderSVGResourceContainer();
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();
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;
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;
464 // This only returns the transform="" value from the element
465 // most callsites want localToParentTransform() instead.
466 virtual AffineTransform localTransform() const;
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;
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);
478 bool isAnonymous() const { return m_bitfields.isAnonymous(); }
479 void setIsAnonymous(bool b) { m_bitfields.setIsAnonymous(b); }
480 bool isAnonymousBlock() const
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()
492 && !isRenderMathMLBlock()
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; }
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(); }
515 bool hasLayer() const { return m_bitfields.hasLayer(); }
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
523 return m_bitfields.needsLayout() || m_bitfields.normalChildNeedsLayout() || m_bitfields.posChildNeedsLayout()
524 || m_bitfields.needsSimplifiedNormalFlowLayout() || m_bitfields.needsPositionedMovementLayout();
527 bool selfNeedsLayout() const { return m_bitfields.needsLayout(); }
528 bool needsPositionedMovementLayout() const { return m_bitfields.needsPositionedMovementLayout(); }
529 bool needsPositionedMovementLayoutOnly() const
531 return m_bitfields.needsPositionedMovementLayout() && !m_bitfields.needsLayout() && !m_bitfields.normalChildNeedsLayout()
532 && !m_bitfields.posChildNeedsLayout() && !m_bitfields.needsSimplifiedNormalFlowLayout();
535 bool posChildNeedsLayout() const { return m_bitfields.posChildNeedsLayout(); }
536 bool needsSimplifiedNormalFlowLayout() const { return m_bitfields.needsSimplifiedNormalFlowLayout(); }
537 bool normalChildNeedsLayout() const { return m_bitfields.normalChildNeedsLayout(); }
539 bool preferredLogicalWidthsDirty() const { return m_bitfields.preferredLogicalWidthsDirty(); }
541 bool isSelectionBorder() const;
543 bool hasClip() const { return isOutOfFlowPositioned() && style()->hasClip(); }
544 bool hasOverflowClip() const { return m_bitfields.hasOverflowClip(); }
545 bool hasClipOrOverflowClip() const { return hasClip() || hasOverflowClip(); }
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; }
552 #if ENABLE(CSS_FILTERS)
553 bool hasFilter() const { return style() && style()->hasFilter(); }
555 bool hasFilter() const { return false; }
558 inline bool preservesNewline() const;
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;
565 virtual void updateDragState(bool dragOn);
567 // Inlined into RenderView.h for performance and to avoid a cyclic dependency.
568 RenderView* view() const;
570 // Returns true if this renderer is rooted, and optionally returns the hosting view (the root of the hierarchy).
571 bool isRooted(RenderView** = 0);
573 Node* node() const { return isAnonymous() ? 0 : m_node; }
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; }
581 Document* document() const { return m_node->document(); }
582 Frame* frame() const { return document()->frame(); }
584 bool hasOutlineAnnotation() const;
585 bool hasOutline() const { return style()->hasOutline() || hasOutlineAnnotation(); }
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;
592 virtual RenderObject* hoverAncestor() const { return parent(); }
594 // IE Extension that can be called on any RenderObject. See the implementation for the details.
595 RenderBoxModelObject* offsetParent() const;
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();
605 void setNeedsLayoutAndPrefWidthsRecalc()
607 setNeedsLayout(true);
608 setPreferredLogicalWidthsDirty(true);
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); }
625 void scheduleRelayout();
627 void updateFillImages(const FillLayer*, const FillLayer*);
628 void updateImage(StyleImage*, StyleImage*);
630 virtual void paint(PaintInfo&, const LayoutPoint&);
632 // Recursive function that computes the size and position of this object and all its descendants.
633 virtual void layout();
635 /* This function performs a layout only if one is needed. */
636 void layoutIfNeeded() { if (needsLayout()) layout(); }
638 // used for element state updates that cannot be fixed with a
639 // repaint and do not need a relayout
640 virtual void updateFromElement() { }
642 #if ENABLE(DASHBOARD_SUPPORT)
643 virtual void addDashboardRegions(Vector<DashboardRegionValue>&);
644 void collectDashboardRegions(Vector<DashboardRegionValue>&);
647 bool isComposited() const;
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);
653 virtual VisiblePosition positionForPoint(const LayoutPoint&);
654 VisiblePosition createVisiblePosition(int offset, EAffinity);
655 VisiblePosition createVisiblePosition(const Position&);
657 virtual void dirtyLinesFromChangedChild(RenderObject*);
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>);
664 // Set the style of the object and update the state of the object accordingly.
665 virtual void setStyle(PassRefPtr<RenderStyle>);
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>);
671 // returns the containing block level element for this element.
672 RenderBlock* containingBlock() const;
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;
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
683 return localToContainerQuad(quad, 0, fixed, wasFixed, useTransforms);
686 FloatQuad localToAbsoluteQuad(const FloatQuad& quad, bool fixed = false, bool* wasFixed = 0) const
688 return localToContainerQuad(quad, 0, fixed, wasFixed);
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;
696 FloatQuad localToContainerQuad(const FloatQuad&, RenderBoxModelObject* repaintContainer, bool fixed = false, bool* wasFixed = 0) const;
699 FloatPoint localToContainerPoint(const FloatPoint&, RenderBoxModelObject* repaintContainer, bool fixed = false, bool* wasFixed = 0) const;
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;
707 virtual void absoluteRects(Vector<IntRect>&, const LayoutPoint&) const { }
709 // FIXME: useTransforms should go away eventually
710 IntRect absoluteBoundingBoxRect(bool useTransform = true) const;
711 IntRect absoluteBoundingBoxRectIgnoringTransforms() const { return absoluteBoundingBoxRect(false); }
713 // Build an array of quads in absolute coords for line boxes
714 virtual void absoluteQuads(Vector<FloatQuad>&, bool* /*wasFixed*/ = 0) const { }
716 void absoluteFocusRingQuads(Vector<FloatQuad>&);
718 // the rect that will be painted if this object is passed as the paintingRoot
719 LayoutRect paintingRootRect(LayoutRect& topLevelRect);
721 virtual LayoutUnit minPreferredLogicalWidth() const { return 0; }
722 virtual LayoutUnit maxPreferredLogicalWidth() const { return 0; }
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(); }
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;
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(); }
736 virtual CursorDirective getCursor(const LayoutPoint&, Cursor&) const;
738 void getTextDecorationColors(int decorations, Color& underline, Color& overline, Color& linethrough, bool quirksMode = false, bool firstlineStyle = false);
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'
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);
748 // Repaint the entire object. Called when, e.g., the color of a border changes, or when a border
750 void repaint(bool immediate = false);
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);
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);
758 // Repaint only if the object moved.
759 virtual void repaintDuringLayoutIfMoved(const LayoutRect&);
761 // Called to repaint a block's floats.
762 virtual void repaintOverhangingFloats(bool paintAllDescendants = false);
764 bool checkForRepaintDuringLayout() const;
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
770 return clippedOverflowRectForRepaint(0);
772 IntRect pixelSnappedAbsoluteClippedOverflowRect() const;
773 virtual LayoutRect clippedOverflowRectForRepaint(RenderBoxModelObject* repaintContainer) const;
774 virtual LayoutRect rectWithOutlineForRepaint(RenderBoxModelObject* repaintContainer, LayoutUnit outlineWidth) const;
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
780 computeRectForRepaint(0, r, fixed);
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;
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
793 adjustForColumns(offset, point);
797 virtual unsigned int length() const { return 1; }
799 bool isFloatingOrOutOfFlowPositioned() const { return (isFloating() || isOutOfFlowPositioned()); }
801 bool isTransparent() const { return style()->opacity() < 1.0f; }
802 float opacity() const { return style()->opacity(); }
804 bool hasReflection() const { return m_bitfields.hasReflection(); }
806 // Applied as a "slop" to dirty rect checks during the outline painting phase's dirty-rect checks.
807 int maximalOutlineSize(PaintPhase) const;
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
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();
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(); }
829 virtual bool canBeSelectionLeaf() const { return false; }
830 bool hasSelectedChildren() const { return selectionState() != SelectionNone; }
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;
837 // Whether or not a given block needs to paint selection gaps.
838 virtual bool shouldPaintSelectionGaps() const { return false; }
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
846 virtual LayoutRect localCaretRect(InlineBox*, int caretOffset, LayoutUnit* extraWidthToEndOfLine = 0);
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); }
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;
857 void destroyAndCleanupAnonymousWrappers();
858 virtual void destroy();
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; }
865 // Virtual function helper for the new FlexibleBox Layout (display: -webkit-flex).
866 virtual bool isFlexibleBox() const { return false; }
868 bool isFlexibleBoxIncludingDeprecated() const
870 return isFlexibleBox() || isDeprecatedFlexibleBox();
873 virtual bool isCombineText() const { return false; }
875 virtual int caretMinOffset() const;
876 virtual int caretMaxOffset() const;
878 virtual int previousOffset(int current) const;
879 virtual int previousOffsetForBackwardDeletion(int current) const;
880 virtual int nextOffset(int current) const;
882 virtual void imageChanged(CachedImage*, const IntRect* = 0);
883 virtual void imageChanged(WrappedImagePtr, const IntRect* = 0) { }
884 virtual bool willRenderImage(CachedImage*);
886 void selectionStartEnd(int& spos, int& epos) const;
888 void remove() { if (parent()) parent()->removeChild(this); }
890 AnimationController* animation() const;
892 bool visibleToHitTesting() const { return style()->visibility() == VISIBLE && style()->pointerEvents() != PE_NONE; }
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;
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;
904 bool shouldUseTransformFromContainer(const RenderObject* container) const;
905 void getTransformFromContainer(const RenderObject* container, const LayoutSize& offsetInContainer, TransformationMatrix&) const;
907 virtual void addFocusRingRects(Vector<IntRect>&, const LayoutPoint&) { };
909 LayoutRect absoluteOutlineBounds() const
911 return outlineBoundsForRepaint(0);
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();
917 RespectImageOrientationEnum shouldRespectImageOrientation() const;
920 inline bool layerCreationAllowedForSubtree() const;
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);
928 void drawLineForBoxSide(GraphicsContext*, int x1, int y1, int x2, int y2, BoxSide,
929 Color, EBorderStyle, int adjbw1, int adjbw2, bool antialias = false);
931 void paintFocusRing(GraphicsContext*, const LayoutPoint&, RenderStyle*);
932 void paintOutline(GraphicsContext*, const LayoutRect&);
933 void addPDFURLRect(GraphicsContext*, const LayoutRect&);
935 virtual LayoutRect viewRect() const;
937 void adjustRectForOutlineAndShadow(LayoutRect&) const;
939 void clearLayoutRootIfNeeded() const;
940 virtual void willBeDestroyed();
941 void arenaDelete(RenderArena*, void* objectBase);
943 virtual LayoutRect outlineBoundsForRepaint(RenderBoxModelObject* /*repaintContainer*/, LayoutPoint* /*cachedOffsetToRepaintContainer*/ = 0) const { return LayoutRect(); }
946 RenderStyle* firstLineStyleSlowCase() const;
947 StyleDifference adjustStyleDifference(StyleDifference, unsigned contextSensitiveProperties) const;
949 Color selectionColor(int colorProperty) const;
952 void checkBlockPositionedObjectsNeedLayout();
955 RefPtr<RenderStyle> m_style;
959 RenderObject* m_parent;
960 RenderObject* m_previous;
961 RenderObject* m_next;
963 static RenderObjectAncestorLineboxDirtySet* s_ancestorLineboxDirtySet;
966 bool m_hasAXObject : 1;
967 bool m_setNeedsLayoutForbidden : 1;
970 #define ADD_BOOLEAN_BITFIELD(name, Name) \
972 unsigned m_##name : 1;\
974 bool name() const { return m_##name; }\
975 void set##Name(bool name) { m_##name = name; }\
977 class RenderObjectBitfields {
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)
987 , m_positioned(false)
988 , m_relPositioned(false)
989 , m_paintBackground(false)
990 , m_isAnonymous(node == node->document())
994 , m_isReplaced(false)
995 , m_horizontalWritingMode(true)
996 , m_isDragging(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)
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);
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)
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);
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);
1039 ADD_BOOLEAN_BITFIELD(hasCounterNodeMap, HasCounterNodeMap);
1040 ADD_BOOLEAN_BITFIELD(everHadLayout, EverHadLayout);
1042 // These bitfields are moved here from subclasses to pack them together.
1043 // from RenderFlowThread
1044 ADD_BOOLEAN_BITFIELD(inRenderFlowThread, InRenderFlowThread);
1047 ADD_BOOLEAN_BITFIELD(childrenInline, ChildrenInline);
1048 ADD_BOOLEAN_BITFIELD(marginBeforeQuirk, MarginBeforeQuirk);
1049 ADD_BOOLEAN_BITFIELD(marginAfterQuirk, MarginAfterQuirk);
1050 ADD_BOOLEAN_BITFIELD(hasColumns, HasColumns);
1053 unsigned m_selectionState : 3; // SelectionState
1056 ALWAYS_INLINE SelectionState selectionState() const { return static_cast<SelectionState>(m_selectionState); }
1057 ALWAYS_INLINE void setSelectionState(SelectionState selectionState) { m_selectionState = selectionState; }
1060 #undef ADD_BOOLEAN_BITFIELD
1062 RenderObjectBitfields m_bitfields;
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); }
1073 // Store state between styleWillChange and styleDidChange
1074 static bool s_affectsParentBlock;
1077 inline bool RenderObject::documentBeingDestroyed() const
1079 return !document()->renderer();
1082 inline bool RenderObject::isBeforeContent() const
1084 if (style()->styleType() != BEFORE)
1086 // Text nodes don't have their own styles, so ignore the style on a text node.
1087 if (isText() && !isBR())
1092 inline bool RenderObject::isAfterContent() const
1094 if (style()->styleType() != AFTER)
1096 // Text nodes don't have their own styles, so ignore the style on a text node.
1097 if (isText() && !isBR())
1102 inline bool RenderObject::isBeforeOrAfterContent() const
1104 return isBeforeContent() || isAfterContent();
1107 inline void RenderObject::setNeedsLayout(bool needsLayout, MarkingBehavior markParents)
1109 bool alreadyNeededLayout = m_bitfields.needsLayout();
1110 m_bitfields.setNeedsLayout(needsLayout);
1112 ASSERT(!isSetNeedsLayoutForbidden());
1113 if (!alreadyNeededLayout) {
1114 if (markParents == MarkContainingBlockChain)
1115 markContainingBlocksForLayout();
1117 setLayerNeedsFullRepaint();
1120 setEverHadLayout(true);
1121 setPosChildNeedsLayout(false);
1122 setNeedsSimplifiedNormalFlowLayout(false);
1123 setNormalChildNeedsLayout(false);
1124 setNeedsPositionedMovementLayout(false);
1125 setAncestorLineBoxDirty(false);
1127 checkBlockPositionedObjectsNeedLayout();
1132 inline void RenderObject::setChildNeedsLayout(bool childNeedsLayout, MarkingBehavior markParents)
1134 bool alreadyNeededLayout = normalChildNeedsLayout();
1135 setNormalChildNeedsLayout(childNeedsLayout);
1136 if (childNeedsLayout) {
1137 ASSERT(!isSetNeedsLayoutForbidden());
1138 if (!alreadyNeededLayout && markParents == MarkContainingBlockChain)
1139 markContainingBlocksForLayout();
1141 setPosChildNeedsLayout(false);
1142 setNeedsSimplifiedNormalFlowLayout(false);
1143 setNormalChildNeedsLayout(false);
1144 setNeedsPositionedMovementLayout(false);
1148 inline void RenderObject::setNeedsPositionedMovementLayout()
1150 bool alreadyNeededLayout = needsPositionedMovementLayout();
1151 setNeedsPositionedMovementLayout(true);
1152 ASSERT(!isSetNeedsLayoutForbidden());
1153 if (!alreadyNeededLayout) {
1154 markContainingBlocksForLayout();
1156 setLayerNeedsFullRepaintForPositionedMovementLayout();
1160 inline void RenderObject::setNeedsSimplifiedNormalFlowLayout()
1162 bool alreadyNeededLayout = needsSimplifiedNormalFlowLayout();
1163 setNeedsSimplifiedNormalFlowLayout(true);
1164 ASSERT(!isSetNeedsLayoutForbidden());
1165 if (!alreadyNeededLayout) {
1166 markContainingBlocksForLayout();
1168 setLayerNeedsFullRepaint();
1172 inline bool RenderObject::preservesNewline() const
1175 if (isSVGInlineText())
1179 return style()->preserveNewline();
1182 inline bool RenderObject::layerCreationAllowedForSubtree() const
1185 RenderObject* parentRenderer = parent();
1186 while (parentRenderer) {
1187 if (parentRenderer->isSVGHiddenContainer())
1189 parentRenderer = parentRenderer->parent();
1196 inline void RenderObject::setSelectionStateIfNeeded(SelectionState state)
1198 if (selectionState() == state)
1201 setSelectionState(state);
1204 inline void makeMatrixRenderable(TransformationMatrix& matrix, bool has3DRendering)
1206 #if !ENABLE(3D_RENDERING)
1207 UNUSED_PARAM(has3DRendering);
1208 matrix.makeAffine();
1210 if (!has3DRendering)
1211 matrix.makeAffine();
1215 inline int adjustForAbsoluteZoom(int value, RenderObject* renderer)
1217 return adjustForAbsoluteZoom(value, renderer->style());
1220 inline void adjustFloatQuadForAbsoluteZoom(FloatQuad& quad, RenderObject* renderer)
1222 float zoom = renderer->style()->effectiveZoom();
1224 quad.scale(1 / zoom, 1 / zoom);
1227 inline void adjustFloatRectForAbsoluteZoom(FloatRect& rect, RenderObject* renderer)
1229 float zoom = renderer->style()->effectiveZoom();
1231 rect.scale(1 / zoom, 1 / zoom);
1234 } // namespace WebCore
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);
1246 #endif // RenderObject_h