Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(284)

Side by Side Diff: Source/core/rendering/RenderObject.h

Issue 899163003: Move rendering/RenderObject to layout/LayoutObject. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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, 2012 Apple Inc. All r ights 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 "core/dom/Document.h"
30 #include "core/dom/DocumentLifecycle.h"
31 #include "core/dom/Element.h"
32 #include "core/editing/TextAffinity.h"
33 #include "core/fetch/ImageResourceClient.h"
34 #include "core/html/HTMLElement.h"
35 #include "core/inspector/InspectorTraceEvents.h"
36 #include "core/layout/HitTestRequest.h"
37 #include "core/layout/compositing/CompositingState.h"
38 #include "core/layout/compositing/CompositingTriggers.h"
39 #include "core/rendering/PaintInvalidationState.h"
40 #include "core/rendering/PaintPhase.h"
41 #include "core/rendering/RenderObjectChildList.h"
42 #include "core/rendering/ScrollAlignment.h"
43 #include "core/rendering/SubtreeLayoutScope.h"
44 #include "core/rendering/style/RenderStyle.h"
45 #include "core/rendering/style/StyleInheritedData.h"
46 #include "platform/geometry/FloatQuad.h"
47 #include "platform/geometry/LayoutRect.h"
48 #include "platform/graphics/CompositingReasons.h"
49 #include "platform/graphics/PaintInvalidationReason.h"
50 #include "platform/graphics/paint/DisplayItemClient.h"
51 #include "platform/transforms/TransformationMatrix.h"
52
53 namespace blink {
54
55 class AffineTransform;
56 class Cursor;
57 class DisplayItemList;
58 class Document;
59 class HitTestLocation;
60 class HitTestResult;
61 class InlineBox;
62 class Position;
63 class PositionWithAffinity;
64 class PseudoStyleRequest;
65 class RenderBoxModelObject;
66 class RenderBlock;
67 class RenderFlowThread;
68 class RenderGeometryMap;
69 class Layer;
70 class LayoutLayerModelObject;
71 class RenderMultiColumnSpannerPlaceholder;
72 class RenderView;
73 class TransformState;
74
75 struct PaintInfo;
76
77 enum CursorDirective {
78 SetCursorBasedOnStyle,
79 SetCursor,
80 DoNotSetCursor
81 };
82
83 enum HitTestFilter {
84 HitTestAll,
85 HitTestSelf,
86 HitTestDescendants
87 };
88
89 enum HitTestAction {
90 HitTestBlockBackground,
91 HitTestChildBlockBackground,
92 HitTestChildBlockBackgrounds,
93 HitTestFloat,
94 HitTestForeground
95 };
96
97 enum MarkingBehavior {
98 MarkOnlyThis,
99 MarkContainingBlockChain,
100 };
101
102 enum MapCoordinatesMode {
103 IsFixed = 1 << 0,
104 UseTransforms = 1 << 1,
105 ApplyContainerFlip = 1 << 2,
106 TraverseDocumentBoundaries = 1 << 3,
107 };
108 typedef unsigned MapCoordinatesFlags;
109
110 const int caretWidth = 1;
111
112 struct AnnotatedRegionValue {
113 bool operator==(const AnnotatedRegionValue& o) const
114 {
115 return draggable == o.draggable && bounds == o.bounds;
116 }
117
118 LayoutRect bounds;
119 bool draggable;
120 };
121
122 typedef WTF::HashMap<const Layer*, Vector<LayoutRect>> LayerHitTestRects;
123
124 #ifndef NDEBUG
125 const int showTreeCharacterOffset = 39;
126 #endif
127
128 // Base class for all rendering tree objects.
129 class RenderObject : public ImageResourceClient {
130 friend class RenderBlock;
131 friend class RenderBlockFlow;
132 friend class LayerReflectionInfo; // For setParent
133 friend class LayerScrollableArea; // For setParent.
134 friend class RenderObjectChildList;
135 WTF_MAKE_NONCOPYABLE(RenderObject);
136 public:
137 // Anonymous objects should pass the document as their node, and they will t hen automatically be
138 // marked as anonymous in the constructor.
139 explicit RenderObject(Node*);
140 virtual ~RenderObject();
141
142 virtual const char* renderName() const = 0;
143
144 String debugName() const;
145
146 RenderObject* parent() const { return m_parent; }
147 bool isDescendantOf(const RenderObject*) const;
148
149 RenderObject* previousSibling() const { return m_previous; }
150 RenderObject* nextSibling() const { return m_next; }
151
152 RenderObject* slowFirstChild() const
153 {
154 if (const RenderObjectChildList* children = virtualChildren())
155 return children->firstChild();
156 return 0;
157 }
158 RenderObject* slowLastChild() const
159 {
160 if (const RenderObjectChildList* children = virtualChildren())
161 return children->lastChild();
162 return 0;
163 }
164
165 virtual RenderObjectChildList* virtualChildren() { return 0; }
166 virtual const RenderObjectChildList* virtualChildren() const { return 0; }
167
168 RenderObject* nextInPreOrder() const;
169 RenderObject* nextInPreOrder(const RenderObject* stayWithin) const;
170 RenderObject* nextInPreOrderAfterChildren() const;
171 RenderObject* nextInPreOrderAfterChildren(const RenderObject* stayWithin) co nst;
172 RenderObject* previousInPreOrder() const;
173 RenderObject* previousInPreOrder(const RenderObject* stayWithin) const;
174 RenderObject* childAt(unsigned) const;
175
176 RenderObject* lastLeafChild() const;
177
178 // The following six functions are used when the render tree hierarchy chang es to make sure layers get
179 // properly added and removed. Since containership can be implemented by an y subclass, and since a hierarchy
180 // can contain a mixture of boxes and other object types, these functions ne ed to be in the base class.
181 Layer* enclosingLayer() const;
182 void addLayers(Layer* parentLayer);
183 void removeLayers(Layer* parentLayer);
184 void moveLayers(Layer* oldParent, Layer* newParent);
185 Layer* findNextLayer(Layer* parentLayer, RenderObject* startPoint, bool chec kParent = true);
186
187 // Scrolling is a RenderBox concept, however some code just cares about recu rsively scrolling our enclosing ScrollableArea(s).
188 bool scrollRectToVisible(const LayoutRect&, const ScrollAlignment& alignX = ScrollAlignment::alignCenterIfNeeded, const ScrollAlignment& alignY = ScrollAlig nment::alignCenterIfNeeded);
189
190 // Convenience function for getting to the nearest enclosing box of a Render Object.
191 RenderBox* enclosingBox() const;
192 RenderBoxModelObject* enclosingBoxModelObject() const;
193
194 RenderBox* enclosingScrollableBox() const;
195
196 // Function to return our enclosing flow thread if we are contained inside o ne. This
197 // function follows the containing block chain.
198 RenderFlowThread* flowThreadContainingBlock() const
199 {
200 if (flowThreadState() == NotInsideFlowThread)
201 return 0;
202 return locateFlowThreadContainingBlock();
203 }
204
205 #if ENABLE(ASSERT)
206 void setHasAXObject(bool flag) { m_hasAXObject = flag; }
207 bool hasAXObject() const { return m_hasAXObject; }
208
209 // Helper class forbidding calls to setNeedsLayout() during its lifetime.
210 class SetLayoutNeededForbiddenScope {
211 public:
212 explicit SetLayoutNeededForbiddenScope(RenderObject&);
213 ~SetLayoutNeededForbiddenScope();
214 private:
215 RenderObject& m_renderObject;
216 bool m_preexistingForbidden;
217 };
218
219 void assertRendererLaidOut() const
220 {
221 #ifndef NDEBUG
222 if (needsLayout())
223 showRenderTreeForThis();
224 #endif
225 ASSERT_WITH_SECURITY_IMPLICATION(!needsLayout());
226 }
227
228 void assertSubtreeIsLaidOut() const
229 {
230 for (const RenderObject* renderer = this; renderer; renderer = renderer- >nextInPreOrder())
231 renderer->assertRendererLaidOut();
232 }
233
234 void assertRendererClearedPaintInvalidationState() const
235 {
236 #ifndef NDEBUG
237 if (paintInvalidationStateIsDirty()) {
238 showRenderTreeForThis();
239 ASSERT_NOT_REACHED();
240 }
241 #endif
242 }
243
244 void assertSubtreeClearedPaintInvalidationState() const
245 {
246 for (const RenderObject* renderer = this; renderer; renderer = renderer- >nextInPreOrder())
247 renderer->assertRendererClearedPaintInvalidationState();
248 }
249
250 #endif
251
252 // FIXME: This could be used when changing the size of a renderer without ch ildren to skip some invalidations.
253 bool rendererHasNoBoxEffect() const
254 {
255 return !style()->hasVisualOverflowingEffect() && !style()->hasBorder() & & !style()->hasBackground();
256 }
257
258 // Obtains the nearest enclosing block (including this block) that contribut es a first-line style to our inline
259 // children.
260 virtual RenderBlock* firstLineBlock() const;
261
262 // Called when an object that was floating or positioned becomes a normal fl ow object
263 // again. We have to make sure the render tree updates as needed to accommo date the new
264 // normal flow object.
265 void handleDynamicFloatPositionChange();
266
267 // RenderObject tree manipulation
268 //////////////////////////////////////////
269 virtual bool canHaveChildren() const { return virtualChildren(); }
270 virtual bool canHaveGeneratedChildren() const;
271 virtual bool isChildAllowed(RenderObject*, RenderStyle*) const { return true ; }
272 virtual void addChild(RenderObject* newChild, RenderObject* beforeChild = 0) ;
273 virtual void addChildIgnoringContinuation(RenderObject* newChild, RenderObje ct* beforeChild = 0) { return addChild(newChild, beforeChild); }
274 virtual void removeChild(RenderObject*);
275 virtual bool createsAnonymousWrapper() const { return false; }
276 //////////////////////////////////////////
277
278 protected:
279 //////////////////////////////////////////
280 // Helper functions. Dangerous to use!
281 void setPreviousSibling(RenderObject* previous) { m_previous = previous; }
282 void setNextSibling(RenderObject* next) { m_next = next; }
283 void setParent(RenderObject* parent)
284 {
285 m_parent = parent;
286
287 // Only update if our flow thread state is different from our new parent and if we're not a RenderFlowThread.
288 // A RenderFlowThread is always considered to be inside itself, so it ne ver has to change its state
289 // in response to parent changes.
290 FlowThreadState newState = parent ? parent->flowThreadState() : NotInsid eFlowThread;
291 if (newState != flowThreadState() && !isRenderFlowThread())
292 setFlowThreadStateIncludingDescendants(newState);
293 }
294
295 //////////////////////////////////////////
296 private:
297 #if ENABLE(ASSERT)
298 bool isSetNeedsLayoutForbidden() const { return m_setNeedsLayoutForbidden; }
299 void setNeedsLayoutIsForbidden(bool flag) { m_setNeedsLayoutForbidden = flag ; }
300 #endif
301
302 void addAbsoluteRectForLayer(LayoutRect& result);
303 bool requiresAnonymousTableWrappers(const RenderObject*) const;
304
305 // Gets pseudoStyle from Shadow host(in case of input elements)
306 // or from Parent element.
307 PassRefPtr<RenderStyle> getUncachedPseudoStyleFromParentOrShadowHost() const ;
308
309 bool skipInvalidationWhenLaidOutChildren() const;
310
311 public:
312 #ifndef NDEBUG
313 void showTreeForThis() const;
314 void showRenderTreeForThis() const;
315 void showLineTreeForThis() const;
316
317 void showRenderObject() const;
318 // We don't make printedCharacters an optional parameter so that
319 // showRenderObject can be called from gdb easily.
320 void showRenderObject(int printedCharacters) const;
321 void showRenderTreeAndMark(const RenderObject* markedObject1 = 0, const char * markedLabel1 = 0, const RenderObject* markedObject2 = 0, const char* markedLab el2 = 0, int depth = 0) const;
322 #endif
323
324 static RenderObject* createObject(Element*, RenderStyle*);
325 static unsigned instanceCount() { return s_instanceCount; }
326
327 // RenderObjects are allocated out of the rendering partition.
328 void* operator new(size_t);
329 void operator delete(void*);
330
331 public:
332 bool isPseudoElement() const { return node() && node()->isPseudoElement(); }
333
334 virtual bool isBoxModelObject() const { return false; }
335 bool isBR() const { return isOfType(RenderObjectBr); }
336 bool isCanvas() const { return isOfType(RenderObjectCanvas); }
337 bool isCounter() const { return isOfType(RenderObjectCounter); }
338 bool isDetailsMarker() const { return isOfType(RenderObjectDetailsMarker); }
339 bool isEmbeddedObject() const { return isOfType(RenderObjectEmbeddedObject); }
340 bool isFieldset() const { return isOfType(RenderObjectFieldset); }
341 bool isFileUploadControl() const { return isOfType(RenderObjectFileUploadCon trol); }
342 bool isFrame() const { return isOfType(RenderObjectFrame); }
343 bool isFrameSet() const { return isOfType(RenderObjectFrameSet); }
344 bool isLayoutTableCol() const { return isOfType(RenderObjectLayoutTableCol); }
345 bool isListBox() const { return isOfType(RenderObjectListBox); }
346 bool isListItem() const { return isOfType(RenderObjectListItem); }
347 bool isListMarker() const { return isOfType(RenderObjectListMarker); }
348 bool isMedia() const { return isOfType(RenderObjectMedia); }
349 bool isMenuList() const { return isOfType(RenderObjectMenuList); }
350 bool isMeter() const { return isOfType(RenderObjectMeter); }
351 bool isProgress() const { return isOfType(RenderObjectProgress); }
352 bool isQuote() const { return isOfType(RenderObjectQuote); }
353 bool isRenderButton() const { return isOfType(RenderObjectRenderButton); }
354 bool isRenderFullScreen() const { return isOfType(RenderObjectRenderFullScre en); }
355 bool isRenderFullScreenPlaceholder() const { return isOfType(RenderObjectRen derFullScreenPlaceholder); }
356 bool isRenderGrid() const { return isOfType(RenderObjectRenderGrid); }
357 bool isRenderIFrame() const { return isOfType(RenderObjectRenderIFrame); }
358 bool isRenderImage() const { return isOfType(RenderObjectRenderImage); }
359 bool isRenderMultiColumnSet() const { return isOfType(RenderObjectRenderMult iColumnSet); }
360 bool isRenderMultiColumnSpannerPlaceholder() const { return isOfType(RenderO bjectRenderMultiColumnSpannerPlaceholder); }
361 bool isRenderRegion() const { return isOfType(RenderObjectRenderRegion); }
362 bool isRenderScrollbarPart() const { return isOfType(RenderObjectRenderScrol lbarPart); }
363 bool isRenderView() const { return isOfType(RenderObjectRenderView); }
364 bool isReplica() const { return isOfType(RenderObjectReplica); }
365 bool isRuby() const { return isOfType(RenderObjectRuby); }
366 bool isRubyBase() const { return isOfType(RenderObjectRubyBase); }
367 bool isRubyRun() const { return isOfType(RenderObjectRubyRun); }
368 bool isRubyText() const { return isOfType(RenderObjectRubyText); }
369 bool isSlider() const { return isOfType(RenderObjectSlider); }
370 bool isSliderThumb() const { return isOfType(RenderObjectSliderThumb); }
371 bool isTable() const { return isOfType(RenderObjectTable); }
372 bool isTableCaption() const { return isOfType(RenderObjectTableCaption); }
373 bool isTableCell() const { return isOfType(RenderObjectTableCell); }
374 bool isTableRow() const { return isOfType(RenderObjectTableRow); }
375 bool isTableSection() const { return isOfType(RenderObjectTableSection); }
376 bool isTextArea() const { return isOfType(RenderObjectTextArea); }
377 bool isTextControl() const { return isOfType(RenderObjectTextControl); }
378 bool isTextField() const { return isOfType(RenderObjectTextField); }
379 bool isVideo() const { return isOfType(RenderObjectVideo); }
380 bool isWidget() const { return isOfType(RenderObjectWidget); }
381
382 virtual bool isImage() const { return false; }
383
384 virtual bool isInlineBlockOrInlineTable() const { return false; }
385 virtual bool isLayoutLayerModelObject() const { return false; }
386 virtual bool isRenderBlock() const { return false; }
387 virtual bool isRenderBlockFlow() const { return false; }
388 virtual bool isRenderFlowThread() const { return false; }
389 virtual bool isRenderInline() const { return false; }
390 virtual bool isRenderPart() const { return false; }
391
392 bool isDocumentElement() const { return document().documentElement() == m_no de; }
393 // isBody is called from RenderBox::styleWillChange and is thus quite hot.
394 bool isBody() const { return node() && node()->hasTagName(HTMLNames::bodyTag ); }
395 bool isHR() const;
396 bool isLegend() const;
397
398 bool isTablePart() const { return isTableCell() || isLayoutTableCol() || isT ableCaption() || isTableRow() || isTableSection(); }
399
400 inline bool isBeforeContent() const;
401 inline bool isAfterContent() const;
402 inline bool isBeforeOrAfterContent() const;
403 static inline bool isAfterContent(const RenderObject* obj) { return obj && o bj->isAfterContent(); }
404
405 bool hasCounterNodeMap() const { return m_bitfields.hasCounterNodeMap(); }
406 void setHasCounterNodeMap(bool hasCounterNodeMap) { m_bitfields.setHasCounte rNodeMap(hasCounterNodeMap); }
407 bool everHadLayout() const { return m_bitfields.everHadLayout(); }
408
409 bool childrenInline() const { return m_bitfields.childrenInline(); }
410 void setChildrenInline(bool b) { m_bitfields.setChildrenInline(b); }
411 bool hasColumns() const { return m_bitfields.hasColumns(); }
412 void setHasColumns(bool b = true) { m_bitfields.setHasColumns(b); }
413
414 bool alwaysCreateLineBoxesForRenderInline() const
415 {
416 ASSERT(isRenderInline());
417 return m_bitfields.alwaysCreateLineBoxesForRenderInline();
418 }
419 void setAlwaysCreateLineBoxesForRenderInline(bool alwaysCreateLineBoxes)
420 {
421 ASSERT(isRenderInline());
422 m_bitfields.setAlwaysCreateLineBoxesForRenderInline(alwaysCreateLineBoxe s);
423 }
424
425 bool ancestorLineBoxDirty() const { return m_bitfields.ancestorLineBoxDirty( ); }
426 void setAncestorLineBoxDirty(bool value = true)
427 {
428 m_bitfields.setAncestorLineBoxDirty(value);
429 if (value)
430 setNeedsLayoutAndFullPaintInvalidation();
431 }
432
433 enum FlowThreadState {
434 NotInsideFlowThread = 0,
435 InsideOutOfFlowThread = 1,
436 InsideInFlowThread = 2,
437 };
438
439 void setFlowThreadStateIncludingDescendants(FlowThreadState);
440
441 FlowThreadState flowThreadState() const { return m_bitfields.flowThreadState (); }
442 void setFlowThreadState(FlowThreadState state) { m_bitfields.setFlowThreadSt ate(state); }
443
444 // FIXME: Until all SVG renders can be subclasses of RenderSVGModelObject we have
445 // to add SVG renderer methods to RenderObject with an ASSERT_NOT_REACHED() default implementation.
446 bool isSVG() const { return isOfType(RenderObjectSVG); }
447 bool isSVGRoot() const { return isOfType(RenderObjectSVGRoot); }
448 bool isSVGContainer() const { return isOfType(RenderObjectSVGContainer); }
449 bool isSVGTransformableContainer() const { return isOfType(RenderObjectSVGTr ansformableContainer); }
450 bool isSVGViewportContainer() const { return isOfType(RenderObjectSVGViewpor tContainer); }
451 bool isSVGGradientStop() const { return isOfType(RenderObjectSVGGradientStop ); }
452 bool isSVGHiddenContainer() const { return isOfType(RenderObjectSVGHiddenCon tainer); }
453 bool isSVGShape() const { return isOfType(RenderObjectSVGShape); }
454 bool isSVGText() const { return isOfType(RenderObjectSVGText); }
455 bool isSVGTextPath() const { return isOfType(RenderObjectSVGTextPath); }
456 bool isSVGInline() const { return isOfType(RenderObjectSVGInline); }
457 bool isSVGInlineText() const { return isOfType(RenderObjectSVGInlineText); }
458 bool isSVGImage() const { return isOfType(RenderObjectSVGImage); }
459 bool isSVGForeignObject() const { return isOfType(RenderObjectSVGForeignObje ct); }
460 bool isSVGResourceContainer() const { return isOfType(RenderObjectSVGResourc eContainer); }
461 bool isSVGResourceFilter() const { return isOfType(RenderObjectSVGResourceFi lter); }
462 bool isSVGResourceFilterPrimitive() const { return isOfType(RenderObjectSVGR esourceFilterPrimitive); }
463
464 // FIXME: Those belong into a SVG specific base-class for all renderers (see above)
465 // Unfortunately we don't have such a class yet, because it's not possible f or all renderers
466 // to inherit from RenderSVGObject -> RenderObject (some need RenderBlock in heritance for instance)
467 virtual void setNeedsTransformUpdate() { }
468 virtual void setNeedsBoundariesUpdate();
469
470 bool isBlendingAllowed() const { return !isSVG() || (isSVGContainer() && !is SVGHiddenContainer()) || isSVGShape() || isSVGImage() || isSVGText(); }
471 virtual bool hasNonIsolatedBlendingDescendants() const { return false; }
472 enum DescendantIsolationState {
473 DescendantIsolationRequired,
474 DescendantIsolationNeedsUpdate,
475 };
476 virtual void descendantIsolationRequirementsChanged(DescendantIsolationState ) { }
477
478 // Per SVG 1.1 objectBoundingBox ignores clipping, masking, filter effects, opacity and stroke-width.
479 // This is used for all computation of objectBoundingBox relative units and by SVGLocatable::getBBox().
480 // NOTE: Markers are not specifically ignored here by SVG 1.1 spec, but we i gnore them
481 // since stroke-width is ignored (and marker size can depend on stroke-width ).
482 // objectBoundingBox is returned local coordinates.
483 // The name objectBoundingBox is taken from the SVG 1.1 spec.
484 virtual FloatRect objectBoundingBox() const;
485 virtual FloatRect strokeBoundingBox() const;
486
487 // Returns the smallest rectangle enclosing all of the painted content
488 // respecting clipping, masking, filters, opacity, stroke-width and markers
489 virtual FloatRect paintInvalidationRectInLocalCoordinates() const;
490
491 // This only returns the transform="" value from the element
492 // most callsites want localToParentTransform() instead.
493 virtual AffineTransform localTransform() const;
494
495 // Returns the full transform mapping from local coordinates to local coords for the parent SVG renderer
496 // This includes any viewport transforms and x/y offsets as well as the tran sform="" value off the element.
497 virtual const AffineTransform& localToParentTransform() const;
498
499 // SVG uses FloatPoint precise hit testing, and passes the point in parent
500 // coordinates instead of in paint invalidaiton container coordinates. Event ually the
501 // rest of the rendering tree will move to a similar model.
502 virtual bool nodeAtFloatPoint(const HitTestRequest&, HitTestResult&, const F loatPoint& pointInParent, HitTestAction);
503
504 bool isAnonymous() const { return m_bitfields.isAnonymous(); }
505 bool isAnonymousBlock() const
506 {
507 // This function is kept in sync with anonymous block creation condition s in
508 // RenderBlock::createAnonymousBlock(). This includes creating an anonym ous
509 // RenderBlock having a BLOCK or BOX display. Other classes such as Rend erTextFragment
510 // are not RenderBlocks and will return false. See https://bugs.webkit.o rg/show_bug.cgi?id=56709.
511 return isAnonymous() && (style()->display() == BLOCK || style()->display () == BOX) && style()->styleType() == NOPSEUDO && isRenderBlock() && !isListMark er() && !isRenderFlowThread() && !isRenderMultiColumnSet()
512 && !isRenderFullScreen()
513 && !isRenderFullScreenPlaceholder();
514 }
515 bool isAnonymousColumnsBlock() const { return style()->specifiesColumns() && isAnonymousBlock(); }
516 bool isAnonymousColumnSpanBlock() const { return style()->columnSpan() && is AnonymousBlock(); }
517 bool isElementContinuation() const { return node() && node()->renderer() != this; }
518 bool isInlineElementContinuation() const { return isElementContinuation() && isInline(); }
519 virtual RenderBoxModelObject* virtualContinuation() const { return 0; }
520
521 bool isFloating() const { return m_bitfields.floating(); }
522
523 bool isOutOfFlowPositioned() const { return m_bitfields.isOutOfFlowPositione d(); } // absolute or fixed positioning
524 bool isRelPositioned() const { return m_bitfields.isRelPositioned(); } // re lative positioning
525 bool isPositioned() const { return m_bitfields.isPositioned(); }
526
527 bool isText() const { return m_bitfields.isText(); }
528 bool isBox() const { return m_bitfields.isBox(); }
529 bool isInline() const { return m_bitfields.isInline(); } // inline object
530 bool isDragging() const { return m_bitfields.isDragging(); }
531 bool isReplaced() const { return m_bitfields.isReplaced(); } // a "replaced" element (see CSS)
532 bool isHorizontalWritingMode() const { return m_bitfields.horizontalWritingM ode(); }
533 bool hasFlippedBlocksWritingMode() const
534 {
535 return style()->isFlippedBlocksWritingMode();
536 }
537
538 bool hasLayer() const { return m_bitfields.hasLayer(); }
539
540 // "Box decoration background" includes all box decorations and backgrounds
541 // that are painted as the background of the object. It includes borders,
542 // box-shadows, background-color and background-image, etc.
543 enum BoxDecorationBackgroundState {
544 NoBoxDecorationBackground,
545 HasBoxDecorationBackgroundObscurationStatusInvalid,
546 HasBoxDecorationBackgroundKnownToBeObscured,
547 HasBoxDecorationBackgroundMayBeVisible,
548 };
549 bool hasBoxDecorationBackground() const { return m_bitfields.boxDecorationBa ckgroundState() != NoBoxDecorationBackground; }
550 bool boxDecorationBackgroundIsKnownToBeObscured();
551 bool canRenderBorderImage() const;
552 bool mustInvalidateBackgroundOrBorderPaintOnWidthChange() const;
553 bool mustInvalidateBackgroundOrBorderPaintOnHeightChange() const;
554 bool mustInvalidateFillLayersPaintOnWidthChange(const FillLayer&) const;
555 bool mustInvalidateFillLayersPaintOnHeightChange(const FillLayer&) const;
556 bool hasBackground() const { return style()->hasBackground(); }
557 bool hasEntirelyFixedBackground() const;
558
559 bool needsLayoutBecauseOfChildren() const { return needsLayout() && !selfNee dsLayout() && !needsPositionedMovementLayout() && !needsSimplifiedNormalFlowLayo ut(); }
560
561 bool needsLayout() const
562 {
563 return m_bitfields.selfNeedsLayout() || m_bitfields.normalChildNeedsLayo ut() || m_bitfields.posChildNeedsLayout()
564 || m_bitfields.needsSimplifiedNormalFlowLayout() || m_bitfields.need sPositionedMovementLayout();
565 }
566
567 bool selfNeedsLayout() const { return m_bitfields.selfNeedsLayout(); }
568 bool needsPositionedMovementLayout() const { return m_bitfields.needsPositio nedMovementLayout(); }
569 bool needsPositionedMovementLayoutOnly() const
570 {
571 return m_bitfields.needsPositionedMovementLayout() && !m_bitfields.selfN eedsLayout() && !m_bitfields.normalChildNeedsLayout()
572 && !m_bitfields.posChildNeedsLayout() && !m_bitfields.needsSimplifie dNormalFlowLayout();
573 }
574
575 bool posChildNeedsLayout() const { return m_bitfields.posChildNeedsLayout(); }
576 bool needsSimplifiedNormalFlowLayout() const { return m_bitfields.needsSimpl ifiedNormalFlowLayout(); }
577 bool normalChildNeedsLayout() const { return m_bitfields.normalChildNeedsLay out(); }
578
579 bool preferredLogicalWidthsDirty() const { return m_bitfields.preferredLogic alWidthsDirty(); }
580
581 bool needsOverflowRecalcAfterStyleChange() const { return m_bitfields.selfNe edsOverflowRecalcAfterStyleChange() || m_bitfields.childNeedsOverflowRecalcAfter StyleChange(); }
582 bool selfNeedsOverflowRecalcAfterStyleChange() const { return m_bitfields.se lfNeedsOverflowRecalcAfterStyleChange(); }
583 bool childNeedsOverflowRecalcAfterStyleChange() const { return m_bitfields.c hildNeedsOverflowRecalcAfterStyleChange(); }
584
585 bool isSelectionBorder() const;
586
587 bool hasClip() const { return isOutOfFlowPositioned() && !style()->hasAutoCl ip(); }
588 bool hasOverflowClip() const { return m_bitfields.hasOverflowClip(); }
589 bool hasClipOrOverflowClip() const { return hasClip() || hasOverflowClip(); }
590
591 bool hasTransformRelatedProperty() const { return m_bitfields.hasTransformRe latedProperty(); }
592 bool hasMask() const { return style() && style()->hasMask(); }
593 bool hasClipPath() const { return style() && style()->clipPath(); }
594 bool hasHiddenBackface() const { return style() && style()->backfaceVisibili ty() == BackfaceVisibilityHidden; }
595
596 bool hasFilter() const { return style() && style()->hasFilter(); }
597
598 bool hasShapeOutside() const { return style() && style()->shapeOutside(); }
599
600 inline bool preservesNewline() const;
601
602 // The pseudo element style can be cached or uncached. Use the cached metho d if the pseudo element doesn't respect
603 // any pseudo classes (and therefore has no concept of changing state).
604 RenderStyle* getCachedPseudoStyle(PseudoId, RenderStyle* parentStyle = 0) co nst;
605 PassRefPtr<RenderStyle> getUncachedPseudoStyle(const PseudoStyleRequest&, Re nderStyle* parentStyle = 0, RenderStyle* ownStyle = 0) const;
606
607 virtual void updateDragState(bool dragOn);
608
609 RenderView* view() const { return document().renderView(); };
610 FrameView* frameView() const { return document().view(); };
611
612 bool isRooted() const;
613
614 Node* node() const
615 {
616 return isAnonymous() ? 0 : m_node;
617 }
618
619 Node* nonPseudoNode() const
620 {
621 return isPseudoElement() ? 0 : node();
622 }
623
624 // FIXME: Why does RenderPart need this? crbug.com/422457
625 void clearNode() { m_node = nullptr; }
626
627 // Returns the styled node that caused the generation of this renderer.
628 // This is the same as node() except for renderers of :before, :after and
629 // :first-letter pseudo elements for which their parent node is returned.
630 Node* generatingNode() const { return isPseudoElement() ? node()->parentOrSh adowHostNode() : node(); }
631
632 Document& document() const { return m_node->document(); }
633 LocalFrame* frame() const { return document().frame(); }
634
635 virtual RenderMultiColumnSpannerPlaceholder* spannerPlaceholder() const { re turn 0; }
636 bool isColumnSpanAll() const { return style()->columnSpan() == ColumnSpanAll && spannerPlaceholder(); }
637
638 // Returns the object containing this one. Can be different from parent for positioned elements.
639 // If paintInvalidationContainer and paintInvalidationContainerSkipped are n ot null, on return *paintInvalidationContainerSkipped
640 // is true if the renderer returned is an ancestor of paintInvalidationConta iner.
641 RenderObject* container(const LayoutLayerModelObject* paintInvalidationConta iner = 0, bool* paintInvalidationContainerSkipped = 0) const;
642 RenderBlock* containerForFixedPosition(const LayoutLayerModelObject* paintIn validationContainer = 0, bool* paintInvalidationContainerSkipped = 0) const;
643
644 virtual RenderObject* hoverAncestor() const { return parent(); }
645
646 Element* offsetParent() const;
647
648 void markContainingBlocksForLayout(bool scheduleRelayout = true, RenderObjec t* newRoot = 0, SubtreeLayoutScope* = 0);
649 void setNeedsLayout(MarkingBehavior = MarkContainingBlockChain, SubtreeLayou tScope* = 0);
650 void setNeedsLayoutAndFullPaintInvalidation(MarkingBehavior = MarkContaining BlockChain, SubtreeLayoutScope* = 0);
651 void clearNeedsLayout();
652 void setChildNeedsLayout(MarkingBehavior = MarkContainingBlockChain, Subtree LayoutScope* = 0);
653 void setNeedsPositionedMovementLayout();
654 void setPreferredLogicalWidthsDirty(MarkingBehavior = MarkContainingBlockCha in);
655 void clearPreferredLogicalWidthsDirty();
656 void invalidateContainerPreferredLogicalWidths();
657
658 void setNeedsLayoutAndPrefWidthsRecalc()
659 {
660 setNeedsLayout();
661 setPreferredLogicalWidthsDirty();
662 }
663 void setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation()
664 {
665 setNeedsLayoutAndFullPaintInvalidation();
666 setPreferredLogicalWidthsDirty();
667 }
668
669 void setPositionState(EPosition position)
670 {
671 ASSERT((position != AbsolutePosition && position != FixedPosition) || is Box());
672 m_bitfields.setPositionedState(position);
673 }
674 void clearPositionedState() { m_bitfields.clearPositionedState(); }
675
676 void setFloating(bool isFloating) { m_bitfields.setFloating(isFloating); }
677 void setInline(bool isInline) { m_bitfields.setIsInline(isInline); }
678
679 void setHasBoxDecorationBackground(bool);
680 void invalidateBackgroundObscurationStatus();
681 virtual bool computeBackgroundIsKnownToBeObscured() { return false; }
682
683 void setIsText() { m_bitfields.setIsText(true); }
684 void setIsBox() { m_bitfields.setIsBox(true); }
685 void setReplaced(bool isReplaced) { m_bitfields.setIsReplaced(isReplaced); }
686 void setHorizontalWritingMode(bool hasHorizontalWritingMode) { m_bitfields.s etHorizontalWritingMode(hasHorizontalWritingMode); }
687 void setHasOverflowClip(bool hasOverflowClip) { m_bitfields.setHasOverflowCl ip(hasOverflowClip); }
688 void setHasLayer(bool hasLayer) { m_bitfields.setHasLayer(hasLayer); }
689 void setHasTransformRelatedProperty(bool hasTransform) { m_bitfields.setHasT ransformRelatedProperty(hasTransform); }
690 void setHasReflection(bool hasReflection) { m_bitfields.setHasReflection(has Reflection); }
691
692 void scheduleRelayout();
693
694 void updateFillImages(const FillLayer* oldLayers, const FillLayer& newLayers );
695 void updateImage(StyleImage*, StyleImage*);
696 void updateShapeImage(const ShapeValue*, const ShapeValue*);
697
698 // paintOffset is the offset from the origin of the GraphicsContext at which to paint the current object.
699 virtual void paint(const PaintInfo&, const LayoutPoint& paintOffset);
700
701 // Subclasses must reimplement this method to compute the size and position
702 // of this object and all its descendants.
703 virtual void layout() = 0;
704 virtual bool updateImageLoadingPriorities() { return false; }
705 void setHasPendingResourceUpdate(bool hasPendingResourceUpdate) { m_bitfield s.setHasPendingResourceUpdate(hasPendingResourceUpdate); }
706 bool hasPendingResourceUpdate() const { return m_bitfields.hasPendingResourc eUpdate(); }
707
708 /* This function performs a layout only if one is needed. */
709 void layoutIfNeeded() { if (needsLayout()) layout(); }
710
711 void forceLayout();
712 void forceChildLayout();
713
714 // Used for element state updates that cannot be fixed with a
715 // paint invalidation and do not need a relayout.
716 virtual void updateFromElement() { }
717
718 virtual void addAnnotatedRegions(Vector<AnnotatedRegionValue>&);
719 void collectAnnotatedRegions(Vector<AnnotatedRegionValue>&);
720
721 CompositingState compositingState() const;
722 virtual CompositingReasons additionalCompositingReasons() const;
723
724 bool hitTest(const HitTestRequest&, HitTestResult&, const HitTestLocation& l ocationInContainer, const LayoutPoint& accumulatedOffset, HitTestFilter = HitTes tAll);
725 virtual void updateHitTestResult(HitTestResult&, const LayoutPoint&);
726 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTes tLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAct ion);
727
728 virtual PositionWithAffinity positionForPoint(const LayoutPoint&);
729 PositionWithAffinity createPositionWithAffinity(int offset, EAffinity);
730 PositionWithAffinity createPositionWithAffinity(const Position&);
731
732 virtual void dirtyLinesFromChangedChild(RenderObject*);
733
734 // Set the style of the object and update the state of the object accordingl y.
735 void setStyle(PassRefPtr<RenderStyle>);
736
737 // Set the style of the object if it's generated content.
738 void setPseudoStyle(PassRefPtr<RenderStyle>);
739
740 // Updates only the local style ptr of the object. Does not update the stat e of the object,
741 // and so only should be called when the style is known not to have changed (or from setStyle).
742 void setStyleInternal(PassRefPtr<RenderStyle> style) { m_style = style; }
743
744 // returns the containing block level element for this element.
745 RenderBlock* containingBlock() const;
746
747 bool canContainFixedPositionObjects() const
748 {
749 return isRenderView() || (hasTransformRelatedProperty() && isRenderBlock ()) || isSVGForeignObject();
750 }
751
752 // Convert the given local point to absolute coordinates
753 // FIXME: Temporary. If UseTransforms is true, take transforms into account. Eventually localToAbsolute() will always be transform-aware.
754 FloatPoint localToAbsolute(const FloatPoint& localPoint = FloatPoint(), MapC oordinatesFlags = 0) const;
755 FloatPoint absoluteToLocal(const FloatPoint&, MapCoordinatesFlags = 0) const ;
756
757 // Convert a local quad to absolute coordinates, taking transforms into acco unt.
758 FloatQuad localToAbsoluteQuad(const FloatQuad& quad, MapCoordinatesFlags mod e = 0, bool* wasFixed = 0) const
759 {
760 return localToContainerQuad(quad, 0, mode, wasFixed);
761 }
762 // Convert an absolute quad to local coordinates.
763 FloatQuad absoluteToLocalQuad(const FloatQuad&, MapCoordinatesFlags mode = 0 ) const;
764
765 // Convert a local quad into the coordinate system of container, taking tran sforms into account.
766 FloatQuad localToContainerQuad(const FloatQuad&, const LayoutLayerModelObjec t* paintInvalidatinoContainer, MapCoordinatesFlags = 0, bool* wasFixed = 0) cons t;
767 FloatPoint localToContainerPoint(const FloatPoint&, const LayoutLayerModelOb ject* paintInvalidationContainer, MapCoordinatesFlags = 0, bool* wasFixed = 0, c onst PaintInvalidationState* = 0) const;
768
769 // Convert a local point into the coordinate system of backing coordinates. Also returns the backing layer if needed.
770 FloatPoint localToInvalidationBackingPoint(const LayoutPoint&, Layer** backi ngLayer = nullptr);
771
772 // Return the offset from the container() renderer (excluding transforms). I n multi-column layout,
773 // different offsets apply at different points, so return the offset that ap plies to the given point.
774 virtual LayoutSize offsetFromContainer(const RenderObject*, const LayoutPoin t&, bool* offsetDependsOnPoint = 0) const;
775 // Return the offset from an object up the container() chain. Asserts that n one of the intermediate objects have transforms.
776 LayoutSize offsetFromAncestorContainer(const RenderObject*) const;
777
778 virtual void absoluteRects(Vector<IntRect>&, const LayoutPoint&) const { }
779
780 IntRect absoluteBoundingBoxRect() const;
781 // FIXME: This function should go away eventually
782 IntRect absoluteBoundingBoxRectIgnoringTransforms() const;
783
784 // Build an array of quads in absolute coords for line boxes
785 virtual void absoluteQuads(Vector<FloatQuad>&, bool* /*wasFixed*/ = 0) const { }
786
787 virtual IntRect absoluteFocusRingBoundingBoxRect() const;
788
789 static FloatRect absoluteBoundingBoxRectForRange(const Range*);
790
791 // the rect that will be painted if this object is passed as the paintingRoo t
792 LayoutRect paintingRootRect(LayoutRect& topLevelRect);
793
794 virtual LayoutUnit minPreferredLogicalWidth() const { return 0; }
795 virtual LayoutUnit maxPreferredLogicalWidth() const { return 0; }
796
797 RenderStyle* style() const { return m_style.get(); }
798
799 // m_style can only be nullptr before the first style is set, thus most
800 // callers will never see a nullptr style and should use styleRef().
801 // FIXME: It would be better if style() returned a const reference.
802 const RenderStyle& styleRef() const { ASSERT(m_style); return *m_style; }
803
804 /* The following methods are inlined in RenderObjectInlines.h */
805 RenderStyle* firstLineStyle() const;
806 RenderStyle* style(bool firstLine) const;
807 const RenderStyle& styleRef(bool firstLine) const;
808
809 static inline Color resolveColor(const RenderStyle& styleToUse, int colorPro perty)
810 {
811 return styleToUse.visitedDependentColor(colorProperty);
812 }
813
814 inline Color resolveColor(int colorProperty) const
815 {
816 return style()->visitedDependentColor(colorProperty);
817 }
818
819 // Used only by Element::pseudoStyleCacheIsInvalid to get a first line style based off of a
820 // given new style, without accessing the cache.
821 PassRefPtr<RenderStyle> uncachedFirstLineStyle(RenderStyle*) const;
822
823 virtual CursorDirective getCursor(const LayoutPoint&, Cursor&) const;
824
825 struct AppliedTextDecoration {
826 Color color;
827 TextDecorationStyle style;
828 AppliedTextDecoration() : color(Color::transparent), style(TextDecoratio nStyleSolid) { }
829 };
830
831 void getTextDecorations(unsigned decorations, AppliedTextDecoration& underli ne, AppliedTextDecoration& overline, AppliedTextDecoration& linethrough, bool qu irksMode = false, bool firstlineStyle = false);
832
833 // Return the LayoutLayerModelObject in the container chain which is respons ible for painting this object, or 0
834 // if painting is root-relative. This is the container that should be passed to the 'forPaintInvalidation'
835 // methods.
836 const LayoutLayerModelObject* containerForPaintInvalidation() const;
837 const LayoutLayerModelObject* adjustCompositedContainerForSpecialAncestors(c onst LayoutLayerModelObject* paintInvalidationContainer) const;
838 bool isPaintInvalidationContainer() const;
839
840 LayoutRect computePaintInvalidationRect()
841 {
842 return computePaintInvalidationRect(containerForPaintInvalidation());
843 }
844
845 // Returns the paint invalidation rect for this RenderObject in the coordina te space of the paint backing (typically a GraphicsLayer) for |paintInvalidation Container|.
846 LayoutRect computePaintInvalidationRect(const LayoutLayerModelObject* paintI nvalidationContainer, const PaintInvalidationState* = 0) const;
847
848 // Returns the rect bounds needed to invalidate the paint of this object, in the coordinate space of the rendering backing of |paintInvalidationContainer|
849 LayoutRect boundsRectForPaintInvalidation(const LayoutLayerModelObject* pain tInvalidationContainer, const PaintInvalidationState* = 0) const;
850
851 // Actually do the paint invalidate of rect r for this object which has been computed in the coordinate space
852 // of the GraphicsLayer backing of |paintInvalidationContainer|. Note that t his coordinaten space is not the same
853 // as the local coordinate space of |paintInvalidationContainer| in the pres ence of layer squashing.
854 // If |paintInvalidationContainer| is 0, invalidate paints via the view.
855 // FIXME: |paintInvalidationContainer| should never be 0. See crbug.com/3636 99.
856 void invalidatePaintUsingContainer(const LayoutLayerModelObject* paintInvali dationContainer, const LayoutRect&, PaintInvalidationReason) const;
857
858 // Invalidate the paint of a specific subrectangle within a given object. Th e rect |r| is in the object's coordinate space.
859 void invalidatePaintRectangle(const LayoutRect&) const;
860
861 void invalidateSelectionIfNeeded(const LayoutLayerModelObject&, PaintInvalid ationReason);
862
863 // Walk the tree after layout issuing paint invalidations for renderers that have changed or moved, updating bounds that have changed, and clearing paint in validation state.
864 virtual void invalidateTreeIfNeeded(const PaintInvalidationState&);
865
866 virtual void invalidatePaintForOverflow();
867 void invalidatePaintForOverflowIfNeeded();
868
869 void invalidatePaintIncludingNonCompositingDescendants();
870
871 // Returns the rect that should have paint invalidated whenever this object changes. The rect is in the view's
872 // coordinate space. This method deals with outlines and overflow.
873 virtual LayoutRect absoluteClippedOverflowRect() const;
874 virtual LayoutRect clippedOverflowRectForPaintInvalidation(const LayoutLayer ModelObject* paintInvalidationContainer, const PaintInvalidationState* = 0) cons t;
875 virtual LayoutRect rectWithOutlineForPaintInvalidation(const LayoutLayerMode lObject* paintInvalidationContainer, LayoutUnit outlineWidth, const PaintInvalid ationState* = 0) const;
876
877 // Given a rect in the object's coordinate space, compute a rect suitable fo r invalidating paints of
878 // that rect in the coordinate space of paintInvalidationContainer.
879 virtual void mapRectToPaintInvalidationBacking(const LayoutLayerModelObject* paintInvalidationContainer, LayoutRect&, const PaintInvalidationState*) const;
880
881 // Return the offset to the column in which the specified point (in flow-thr ead coordinates)
882 // lives. This is used to convert a flow-thread point to a visual point.
883 virtual LayoutSize columnOffset(const LayoutPoint&) const { return LayoutSiz e(); }
884
885 virtual unsigned length() const { return 1; }
886
887 bool isFloatingOrOutOfFlowPositioned() const { return (isFloating() || isOut OfFlowPositioned()); }
888
889 bool isTransparent() const { return style()->hasOpacity(); }
890 float opacity() const { return style()->opacity(); }
891
892 bool hasReflection() const { return m_bitfields.hasReflection(); }
893
894 enum SelectionState {
895 SelectionNone, // The object is not selected.
896 SelectionStart, // The object either contains the start of a selection r un or is the start of a run
897 SelectionInside, // The object is fully encompassed by a selection run
898 SelectionEnd, // The object either contains the end of a selection run o r is the end of a run
899 SelectionBoth // The object contains an entire run or is the sole select ed object in that run
900 };
901
902 // The current selection state for an object. For blocks, the state refers to the state of the leaf
903 // descendants (as described above in the SelectionState enum declaration).
904 SelectionState selectionState() const { return m_bitfields.selectionState(); }
905 virtual void setSelectionState(SelectionState state) { m_bitfields.setSelect ionState(state); }
906 inline void setSelectionStateIfNeeded(SelectionState);
907 bool canUpdateSelectionOnRootLineBoxes() const;
908
909 // A single rectangle that encompasses all of the selected objects within th is object. Used to determine the tightest
910 // possible bounding box for the selection. The rect returned is in the coor dinate space of the paint invalidation container's backing.
911 virtual LayoutRect selectionRectForPaintInvalidation(const LayoutLayerModelO bject* /*paintInvalidationContainer*/) const { return LayoutRect(); }
912
913 virtual bool canBeSelectionLeaf() const { return false; }
914 bool hasSelectedChildren() const { return selectionState() != SelectionNone; }
915
916 bool isSelectable() const;
917 // Obtains the selection colors that should be used when painting a selectio n.
918 Color selectionBackgroundColor() const;
919 Color selectionForegroundColor() const;
920 Color selectionEmphasisMarkColor() const;
921
922 // Whether or not a given block needs to paint selection gaps.
923 virtual bool shouldPaintSelectionGaps() const { return false; }
924
925 /**
926 * Returns the local coordinates of the caret within this render object.
927 * @param caretOffset zero-based offset determining position within the rend er object.
928 * @param extraWidthToEndOfLine optional out arg to give extra width to end of line -
929 * useful for character range rect computations
930 */
931 virtual LayoutRect localCaretRect(InlineBox*, int caretOffset, LayoutUnit* e xtraWidthToEndOfLine = 0);
932
933 // When performing a global document tear-down, the renderer of the document is cleared. We use this
934 // as a hook to detect the case of document destruction and don't waste time doing unnecessary work.
935 bool documentBeingDestroyed() const;
936
937 void destroyAndCleanupAnonymousWrappers();
938 virtual void destroy();
939
940 // Virtual function helpers for the deprecated Flexible Box Layout (display: -webkit-box).
941 virtual bool isDeprecatedFlexibleBox() const { return false; }
942
943 // Virtual function helper for the new FlexibleBox Layout (display: -webkit- flex).
944 virtual bool isFlexibleBox() const { return false; }
945
946 bool isFlexibleBoxIncludingDeprecated() const
947 {
948 return isFlexibleBox() || isDeprecatedFlexibleBox();
949 }
950
951 virtual bool isCombineText() const { return false; }
952
953 virtual int caretMinOffset() const;
954 virtual int caretMaxOffset() const;
955
956 virtual int previousOffset(int current) const;
957 virtual int previousOffsetForBackwardDeletion(int current) const;
958 virtual int nextOffset(int current) const;
959
960 virtual void imageChanged(ImageResource*, const IntRect* = 0) override final ;
961 virtual void imageChanged(WrappedImagePtr, const IntRect* = 0) { }
962 virtual bool willRenderImage(ImageResource*) override final;
963 virtual bool getImageAnimationPolicy(ImageResource*, ImageAnimationPolicy&) override final;
964
965 void selectionStartEnd(int& spos, int& epos) const;
966
967 void remove() { if (parent()) parent()->removeChild(this); }
968
969 bool isInert() const;
970
971 bool supportsTouchAction() const;
972
973 bool visibleToHitTestRequest(const HitTestRequest& request) const { return s tyle()->visibility() == VISIBLE && (request.ignorePointerEventsNone() || style() ->pointerEvents() != PE_NONE) && !isInert(); }
974
975 bool visibleToHitTesting() const { return style()->visibility() == VISIBLE & & style()->pointerEvents() != PE_NONE && !isInert(); }
976
977 // Map points and quads through elements, potentially via 3d transforms. You should never need to call these directly; use
978 // localToAbsolute/absoluteToLocal methods instead.
979 virtual void mapLocalToContainer(const LayoutLayerModelObject* paintInvalida tionContainer, TransformState&, MapCoordinatesFlags = ApplyContainerFlip, bool* wasFixed = 0, const PaintInvalidationState* = 0) const;
980 virtual void mapAbsoluteToLocalPoint(MapCoordinatesFlags, TransformState&) c onst;
981
982 // Pushes state onto RenderGeometryMap about how to map coordinates from thi s renderer to its container, or ancestorToStopAt (whichever is encountered first ).
983 // Returns the renderer which was mapped to (container or ancestorToStopAt).
984 virtual const RenderObject* pushMappingToContainer(const LayoutLayerModelObj ect* ancestorToStopAt, RenderGeometryMap&) const;
985
986 bool shouldUseTransformFromContainer(const RenderObject* container) const;
987 void getTransformFromContainer(const RenderObject* container, const LayoutSi ze& offsetInContainer, TransformationMatrix&) const;
988
989 bool createsGroup() const { return isTransparent() || hasMask() || hasFilter () || style()->hasBlendMode(); }
990
991 virtual void addFocusRingRects(Vector<LayoutRect>&, const LayoutPoint& addit ionalOffset) const { }
992
993 // Compute a list of hit-test rectangles per layer rooted at this renderer.
994 virtual void computeLayerHitTestRects(LayerHitTestRects&) const;
995
996 // Return the renderer whose background style is used to paint the root back ground. Should only be called on the renderer for which isDocumentElement() is t rue.
997 RenderObject* rendererForRootBackground();
998
999 RespectImageOrientationEnum shouldRespectImageOrientation() const;
1000
1001 bool isRelayoutBoundaryForInspector() const;
1002
1003 // The previous paint invalidation rect in the object's previous paint backi ng.
1004 const LayoutRect& previousPaintInvalidationRect() const { return m_previousP aintInvalidationRect; }
1005 void setPreviousPaintInvalidationRect(const LayoutRect& rect) { m_previousPa intInvalidationRect = rect; }
1006
1007 // The previous position of the top-left corner of the object in its previou s paint backing.
1008 const LayoutPoint& previousPositionFromPaintInvalidationBacking() const { re turn m_previousPositionFromPaintInvalidationBacking; }
1009 void setPreviousPositionFromPaintInvalidationBacking(const LayoutPoint& posi tionFromPaintInvalidationBacking) { m_previousPositionFromPaintInvalidationBacki ng = positionFromPaintInvalidationBacking; }
1010
1011 bool shouldDoFullPaintInvalidation() const { return m_bitfields.fullPaintInv alidationReason() != PaintInvalidationNone; }
1012 void setShouldDoFullPaintInvalidation(PaintInvalidationReason = PaintInvalid ationFull);
1013 void clearShouldDoFullPaintInvalidation() { m_bitfields.setFullPaintInvalida tionReason(PaintInvalidationNone); }
1014
1015 bool shouldInvalidateOverflowForPaint() const { return m_bitfields.shouldInv alidateOverflowForPaint(); }
1016
1017 virtual void clearPaintInvalidationState(const PaintInvalidationState&);
1018
1019 // Indicates whether this render object was re-laid-out since the last frame .
1020 // The flag will be cleared during invalidateTreeIfNeeded.
1021 bool layoutDidGetCalledSinceLastFrame() const { return m_bitfields.layoutDid GetCalledSinceLastFrame(); }
1022
1023 bool mayNeedPaintInvalidation() const { return m_bitfields.mayNeedPaintInval idation(); }
1024 void setMayNeedPaintInvalidation();
1025 void clearMayNeedPaintInvalidation();
1026
1027 bool shouldInvalidateSelection() const { return m_bitfields.shouldInvalidate Selection(); }
1028 void setShouldInvalidateSelection()
1029 {
1030 if (!canUpdateSelectionOnRootLineBoxes())
1031 return;
1032
1033 m_bitfields.setShouldInvalidateSelection(true);
1034 markContainingBlockChainForPaintInvalidation();
1035 }
1036 void clearShouldInvalidateSelection() { m_bitfields.setShouldInvalidateSelec tion(false); }
1037
1038 bool neededLayoutBecauseOfChildren() const { return m_bitfields.neededLayout BecauseOfChildren(); }
1039 void setNeededLayoutBecauseOfChildren(bool b) { m_bitfields.setNeededLayoutB ecauseOfChildren(b); }
1040
1041 bool shouldCheckForPaintInvalidation(const PaintInvalidationState& paintInva lidationState) const
1042 {
1043 return paintInvalidationState.forceCheckForPaintInvalidation() || should CheckForPaintInvalidationRegardlessOfPaintInvalidationState();
1044 }
1045
1046 bool shouldCheckForPaintInvalidationRegardlessOfPaintInvalidationState() con st
1047 {
1048 return layoutDidGetCalledSinceLastFrame() || mayNeedPaintInvalidation() || shouldDoFullPaintInvalidation() || shouldInvalidateSelection();
1049 }
1050
1051 virtual bool supportsPaintInvalidationStateCachedOffsets() const { return !h asColumns() && !hasTransformRelatedProperty() && !hasReflection() && !style()->i sFlippedBlocksWritingMode(); }
1052
1053 void setNeedsOverflowRecalcAfterStyleChange();
1054 void markContainingBlocksForOverflowRecalc();
1055
1056 virtual LayoutRect viewRect() const;
1057
1058 DisplayItemClient displayItemClient() const { return toDisplayItemClient(thi s); }
1059
1060 protected:
1061 enum RenderObjectType {
1062 RenderObjectBr,
1063 RenderObjectCanvas,
1064 RenderObjectFieldset,
1065 RenderObjectCounter,
1066 RenderObjectDetailsMarker,
1067 RenderObjectEmbeddedObject,
1068 RenderObjectFileUploadControl,
1069 RenderObjectFrame,
1070 RenderObjectFrameSet,
1071 RenderObjectLayoutTableCol,
1072 RenderObjectListBox,
1073 RenderObjectListItem,
1074 RenderObjectListMarker,
1075 RenderObjectMedia,
1076 RenderObjectMenuList,
1077 RenderObjectMeter,
1078 RenderObjectProgress,
1079 RenderObjectQuote,
1080 RenderObjectRenderButton,
1081 RenderObjectRenderFlowThread,
1082 RenderObjectRenderFullScreen,
1083 RenderObjectRenderFullScreenPlaceholder,
1084 RenderObjectRenderGrid,
1085 RenderObjectRenderIFrame,
1086 RenderObjectRenderImage,
1087 RenderObjectRenderInline,
1088 RenderObjectRenderMultiColumnSet,
1089 RenderObjectRenderMultiColumnSpannerPlaceholder,
1090 RenderObjectRenderPart,
1091 RenderObjectRenderRegion,
1092 RenderObjectRenderScrollbarPart,
1093 RenderObjectRenderView,
1094 RenderObjectReplica,
1095 RenderObjectRuby,
1096 RenderObjectRubyBase,
1097 RenderObjectRubyRun,
1098 RenderObjectRubyText,
1099 RenderObjectSlider,
1100 RenderObjectSliderThumb,
1101 RenderObjectTable,
1102 RenderObjectTableCaption,
1103 RenderObjectTableCell,
1104 RenderObjectTableRow,
1105 RenderObjectTableSection,
1106 RenderObjectTextArea,
1107 RenderObjectTextControl,
1108 RenderObjectTextField,
1109 RenderObjectVideo,
1110 RenderObjectWidget,
1111
1112 RenderObjectSVG, /* Keep by itself? */
1113 RenderObjectSVGRoot,
1114 RenderObjectSVGContainer,
1115 RenderObjectSVGTransformableContainer,
1116 RenderObjectSVGViewportContainer,
1117 RenderObjectSVGHiddenContainer,
1118 RenderObjectSVGGradientStop,
1119 RenderObjectSVGShape,
1120 RenderObjectSVGText,
1121 RenderObjectSVGTextPath,
1122 RenderObjectSVGInline,
1123 RenderObjectSVGInlineText,
1124 RenderObjectSVGImage,
1125 RenderObjectSVGForeignObject,
1126 RenderObjectSVGResourceContainer,
1127 RenderObjectSVGResourceFilter,
1128 RenderObjectSVGResourceFilterPrimitive,
1129 };
1130 virtual bool isOfType(RenderObjectType type) const { return false; }
1131
1132 inline bool layerCreationAllowedForSubtree() const;
1133
1134 // Overrides should call the superclass at the end. m_style will be 0 the fi rst time
1135 // this function will be called.
1136 virtual void styleWillChange(StyleDifference, const RenderStyle& newStyle);
1137 // Overrides should call the superclass at the start. |oldStyle| will be 0 t he first
1138 // time this function is called.
1139 virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
1140 void propagateStyleToAnonymousChildren(bool blockChildrenOnly = false);
1141 virtual void updateAnonymousChildStyle(const RenderObject* child, RenderStyl e* style) const { }
1142
1143 protected:
1144 void setSelfMayNeedPaintInvalidation();
1145
1146 void clearLayoutRootIfNeeded() const;
1147 virtual void willBeDestroyed();
1148 void postDestroy();
1149
1150 virtual void insertedIntoTree();
1151 virtual void willBeRemovedFromTree();
1152
1153 void setDocumentForAnonymous(Document* document) { ASSERT(isAnonymous()); m_ node = document; }
1154
1155 // Add hit-test rects for the render tree rooted at this node to the provide d collection on a
1156 // per-Layer basis.
1157 // currentLayer must be the enclosing layer, and layerOffset is the current offset within
1158 // this layer. Subclass implementations will add any offset for this rendere r within it's
1159 // container, so callers should provide only the offset of the container wit hin it's layer.
1160 // containerRect is a rect that has already been added for the currentLayer which is likely to
1161 // be a container for child elements. Any rect wholly contained by container Rect can be
1162 // skipped.
1163 virtual void addLayerHitTestRects(LayerHitTestRects&, const Layer* currentLa yer, const LayoutPoint& layerOffset, const LayoutRect& containerRect) const;
1164
1165 // Add hit-test rects for this renderer only to the provided list. layerOffs et is the offset
1166 // of this renderer within the current layer that should be used for each re sult.
1167 virtual void computeSelfHitTestRects(Vector<LayoutRect>&, const LayoutPoint& layerOffset) const { };
1168
1169 virtual PaintInvalidationReason paintInvalidationReason(const LayoutLayerMod elObject& paintInvalidationContainer,
1170 const LayoutRect& oldPaintInvalidationRect, const LayoutPoint& oldPositi onFromPaintInvalidationBacking,
1171 const LayoutRect& newPaintInvalidationRect, const LayoutPoint& newPositi onFromPaintInvalidationBacking) const;
1172 virtual void incrementallyInvalidatePaint(const LayoutLayerModelObject& pain tInvalidationContainer, const LayoutRect& oldBounds, const LayoutRect& newBounds , const LayoutPoint& positionFromPaintInvalidationBacking);
1173 void fullyInvalidatePaint(const LayoutLayerModelObject& paintInvalidationCon tainer, PaintInvalidationReason, const LayoutRect& oldBounds, const LayoutRect& newBounds);
1174
1175 #if ENABLE(ASSERT)
1176 virtual bool paintInvalidationStateIsDirty() const
1177 {
1178 return neededLayoutBecauseOfChildren() || shouldCheckForPaintInvalidatio nRegardlessOfPaintInvalidationState();
1179 }
1180 #endif
1181
1182 virtual void invalidatePaintOfSubtreesIfNeeded(const PaintInvalidationState& childPaintInvalidationState);
1183 virtual PaintInvalidationReason invalidatePaintIfNeeded(const PaintInvalidat ionState&, const LayoutLayerModelObject& paintInvalidationContainer);
1184
1185 // When this object is invalidated for paint, this method is called to inval idate any DisplayItemClients
1186 // owned by this object, including the object itself, RenderText/RenderInlin e line boxes, scrollbars, etc.,
1187 // not including children which will be invalidated normally during invalida teTreeIfNeeded().
1188 virtual void invalidateDisplayItemClients(DisplayItemList*) const;
1189
1190 private:
1191 void setLayoutDidGetCalledSinceLastFrame()
1192 {
1193 m_bitfields.setLayoutDidGetCalledSinceLastFrame(true);
1194
1195 // Make sure our parent is marked as needing invalidation.
1196 // This would be unneeded if we allowed sub-tree invalidation (akin to s ub-tree layouts).
1197 markContainingBlockChainForPaintInvalidation();
1198 }
1199 void clearLayoutDidGetCalledSinceLastFrame() { m_bitfields.setLayoutDidGetCa lledSinceLastFrame(false); }
1200
1201 void invalidatePaintIncludingNonCompositingDescendantsInternal(const LayoutL ayerModelObject* repaintContainer);
1202
1203 LayoutRect previousSelectionRectForPaintInvalidation() const;
1204 void setPreviousSelectionRectForPaintInvalidation(const LayoutRect&);
1205
1206 const LayoutLayerModelObject* enclosingCompositedContainer() const;
1207
1208 RenderFlowThread* locateFlowThreadContainingBlock() const;
1209 void removeFromRenderFlowThread();
1210 void removeFromRenderFlowThreadRecursive(RenderFlowThread*);
1211
1212 RenderStyle* cachedFirstLineStyle() const;
1213 StyleDifference adjustStyleDifference(StyleDifference) const;
1214
1215 Color selectionColor(int colorProperty) const;
1216
1217 void removeShapeImageClient(ShapeValue*);
1218
1219 #if ENABLE(ASSERT)
1220 void checkBlockPositionedObjectsNeedLayout();
1221 #endif
1222
1223 void markContainingBlockChainForPaintInvalidation();
1224
1225 static bool isAllowedToModifyRenderTreeStructure(Document&);
1226
1227 RefPtr<RenderStyle> m_style;
1228
1229 // Oilpan: raw pointer back to the owning Node is considered safe.
1230 Node* m_node;
1231
1232 RenderObject* m_parent;
1233 RenderObject* m_previous;
1234 RenderObject* m_next;
1235
1236 #if ENABLE(ASSERT)
1237 unsigned m_hasAXObject : 1;
1238 unsigned m_setNeedsLayoutForbidden : 1;
1239 #endif
1240
1241 #define ADD_BOOLEAN_BITFIELD(name, Name) \
1242 private:\
1243 unsigned m_##name : 1;\
1244 public:\
1245 bool name() const { return m_##name; }\
1246 void set##Name(bool name) { m_##name = name; }\
1247
1248 class RenderObjectBitfields {
1249 enum PositionedState {
1250 IsStaticallyPositioned = 0,
1251 IsRelativelyPositioned = 1,
1252 IsOutOfFlowPositioned = 2,
1253 };
1254
1255 public:
1256 RenderObjectBitfields(Node* node)
1257 : m_selfNeedsLayout(false)
1258 , m_shouldInvalidateOverflowForPaint(false)
1259 // FIXME: We should remove mayNeedPaintInvalidation once we are able to
1260 // use the other layout flags to detect the same cases. crbug.com/37 0118
1261 , m_mayNeedPaintInvalidation(false)
1262 , m_shouldInvalidateSelection(false)
1263 , m_neededLayoutBecauseOfChildren(false)
1264 , m_needsPositionedMovementLayout(false)
1265 , m_normalChildNeedsLayout(false)
1266 , m_posChildNeedsLayout(false)
1267 , m_needsSimplifiedNormalFlowLayout(false)
1268 , m_preferredLogicalWidthsDirty(false)
1269 , m_floating(false)
1270 , m_selfNeedsOverflowRecalcAfterStyleChange(false)
1271 , m_childNeedsOverflowRecalcAfterStyleChange(false)
1272 , m_isAnonymous(!node)
1273 , m_isText(false)
1274 , m_isBox(false)
1275 , m_isInline(true)
1276 , m_isReplaced(false)
1277 , m_horizontalWritingMode(true)
1278 , m_isDragging(false)
1279 , m_hasLayer(false)
1280 , m_hasOverflowClip(false)
1281 , m_hasTransformRelatedProperty(false)
1282 , m_hasReflection(false)
1283 , m_hasCounterNodeMap(false)
1284 , m_everHadLayout(false)
1285 , m_ancestorLineBoxDirty(false)
1286 , m_layoutDidGetCalledSinceLastFrame(false)
1287 , m_hasPendingResourceUpdate(false)
1288 , m_childrenInline(false)
1289 , m_hasColumns(false)
1290 , m_alwaysCreateLineBoxesForRenderInline(false)
1291 , m_positionedState(IsStaticallyPositioned)
1292 , m_selectionState(SelectionNone)
1293 , m_flowThreadState(NotInsideFlowThread)
1294 , m_boxDecorationBackgroundState(NoBoxDecorationBackground)
1295 , m_fullPaintInvalidationReason(PaintInvalidationNone)
1296 {
1297 }
1298
1299 // 32 bits have been used in the first word, and 14 in the second.
1300 ADD_BOOLEAN_BITFIELD(selfNeedsLayout, SelfNeedsLayout);
1301 ADD_BOOLEAN_BITFIELD(shouldInvalidateOverflowForPaint, ShouldInvalidateO verflowForPaint);
1302 ADD_BOOLEAN_BITFIELD(mayNeedPaintInvalidation, MayNeedPaintInvalidation) ;
1303 ADD_BOOLEAN_BITFIELD(shouldInvalidateSelection, ShouldInvalidateSelectio n);
1304 ADD_BOOLEAN_BITFIELD(neededLayoutBecauseOfChildren, NeededLayoutBecauseO fChildren);
1305 ADD_BOOLEAN_BITFIELD(needsPositionedMovementLayout, NeedsPositionedMovem entLayout);
1306 ADD_BOOLEAN_BITFIELD(normalChildNeedsLayout, NormalChildNeedsLayout);
1307 ADD_BOOLEAN_BITFIELD(posChildNeedsLayout, PosChildNeedsLayout);
1308 ADD_BOOLEAN_BITFIELD(needsSimplifiedNormalFlowLayout, NeedsSimplifiedNor malFlowLayout);
1309 ADD_BOOLEAN_BITFIELD(preferredLogicalWidthsDirty, PreferredLogicalWidths Dirty);
1310 ADD_BOOLEAN_BITFIELD(floating, Floating);
1311 ADD_BOOLEAN_BITFIELD(selfNeedsOverflowRecalcAfterStyleChange, SelfNeedsO verflowRecalcAfterStyleChange);
1312 ADD_BOOLEAN_BITFIELD(childNeedsOverflowRecalcAfterStyleChange, ChildNeed sOverflowRecalcAfterStyleChange);
1313
1314 ADD_BOOLEAN_BITFIELD(isAnonymous, IsAnonymous);
1315 ADD_BOOLEAN_BITFIELD(isText, IsText);
1316 ADD_BOOLEAN_BITFIELD(isBox, IsBox);
1317 ADD_BOOLEAN_BITFIELD(isInline, IsInline);
1318 ADD_BOOLEAN_BITFIELD(isReplaced, IsReplaced);
1319 ADD_BOOLEAN_BITFIELD(horizontalWritingMode, HorizontalWritingMode);
1320 ADD_BOOLEAN_BITFIELD(isDragging, IsDragging);
1321
1322 ADD_BOOLEAN_BITFIELD(hasLayer, HasLayer);
1323 ADD_BOOLEAN_BITFIELD(hasOverflowClip, HasOverflowClip); // Set in the ca se of overflow:auto/scroll/hidden
1324 ADD_BOOLEAN_BITFIELD(hasTransformRelatedProperty, HasTransformRelatedPro perty);
1325 ADD_BOOLEAN_BITFIELD(hasReflection, HasReflection);
1326
1327 ADD_BOOLEAN_BITFIELD(hasCounterNodeMap, HasCounterNodeMap);
1328 ADD_BOOLEAN_BITFIELD(everHadLayout, EverHadLayout);
1329 ADD_BOOLEAN_BITFIELD(ancestorLineBoxDirty, AncestorLineBoxDirty);
1330
1331 ADD_BOOLEAN_BITFIELD(layoutDidGetCalledSinceLastFrame, LayoutDidGetCalle dSinceLastFrame);
1332
1333 ADD_BOOLEAN_BITFIELD(hasPendingResourceUpdate, HasPendingResourceUpdate) ;
1334
1335 // from RenderBlock
1336 ADD_BOOLEAN_BITFIELD(childrenInline, ChildrenInline);
1337 ADD_BOOLEAN_BITFIELD(hasColumns, HasColumns);
1338
1339 // from RenderInline
1340 ADD_BOOLEAN_BITFIELD(alwaysCreateLineBoxesForRenderInline, AlwaysCreateL ineBoxesForRenderInline);
1341
1342 private:
1343 unsigned m_positionedState : 2; // PositionedState
1344 unsigned m_selectionState : 3; // SelectionState
1345 unsigned m_flowThreadState : 2; // FlowThreadState
1346 unsigned m_boxDecorationBackgroundState : 2; // BoxDecorationBackgroundS tate
1347 unsigned m_fullPaintInvalidationReason : 5; // PaintInvalidationReason
1348
1349 public:
1350 bool isOutOfFlowPositioned() const { return m_positionedState == IsOutOf FlowPositioned; }
1351 bool isRelPositioned() const { return m_positionedState == IsRelativelyP ositioned; }
1352 bool isPositioned() const { return m_positionedState != IsStaticallyPosi tioned; }
1353
1354 void setPositionedState(int positionState)
1355 {
1356 // This mask maps FixedPosition and AbsolutePosition to IsOutOfFlowP ositioned, saving one bit.
1357 m_positionedState = static_cast<PositionedState>(positionState & 0x3 );
1358 }
1359 void clearPositionedState() { m_positionedState = StaticPosition; }
1360
1361 ALWAYS_INLINE SelectionState selectionState() const { return static_cast <SelectionState>(m_selectionState); }
1362 ALWAYS_INLINE void setSelectionState(SelectionState selectionState) { m_ selectionState = selectionState; }
1363
1364 ALWAYS_INLINE FlowThreadState flowThreadState() const { return static_ca st<FlowThreadState>(m_flowThreadState); }
1365 ALWAYS_INLINE void setFlowThreadState(FlowThreadState flowThreadState) { m_flowThreadState = flowThreadState; }
1366
1367 ALWAYS_INLINE BoxDecorationBackgroundState boxDecorationBackgroundState( ) const { return static_cast<BoxDecorationBackgroundState>(m_boxDecorationBackgr oundState); }
1368 ALWAYS_INLINE void setBoxDecorationBackgroundState(BoxDecorationBackgrou ndState s) { m_boxDecorationBackgroundState = s; }
1369
1370 PaintInvalidationReason fullPaintInvalidationReason() const { return sta tic_cast<PaintInvalidationReason>(m_fullPaintInvalidationReason); }
1371 void setFullPaintInvalidationReason(PaintInvalidationReason reason) { m_ fullPaintInvalidationReason = reason; }
1372 };
1373
1374 #undef ADD_BOOLEAN_BITFIELD
1375
1376 RenderObjectBitfields m_bitfields;
1377
1378 void setSelfNeedsLayout(bool b) { m_bitfields.setSelfNeedsLayout(b); }
1379 void setNeedsPositionedMovementLayout(bool b) { m_bitfields.setNeedsPosition edMovementLayout(b); }
1380 void setNormalChildNeedsLayout(bool b) { m_bitfields.setNormalChildNeedsLayo ut(b); }
1381 void setPosChildNeedsLayout(bool b) { m_bitfields.setPosChildNeedsLayout(b); }
1382 void setNeedsSimplifiedNormalFlowLayout(bool b) { m_bitfields.setNeedsSimpli fiedNormalFlowLayout(b); }
1383 void setIsDragging(bool b) { m_bitfields.setIsDragging(b); }
1384 void setEverHadLayout(bool b) { m_bitfields.setEverHadLayout(b); }
1385 void setShouldInvalidateOverflowForPaint(bool b) { m_bitfields.setShouldInva lidateOverflowForPaint(b); }
1386 void setSelfNeedsOverflowRecalcAfterStyleChange(bool b) { m_bitfields.setSel fNeedsOverflowRecalcAfterStyleChange(b); }
1387 void setChildNeedsOverflowRecalcAfterStyleChange(bool b) { m_bitfields.setCh ildNeedsOverflowRecalcAfterStyleChange(b); }
1388
1389 private:
1390 // Store state between styleWillChange and styleDidChange
1391 static bool s_affectsParentBlock;
1392
1393 // This stores the paint invalidation rect from the previous frame.
1394 LayoutRect m_previousPaintInvalidationRect;
1395
1396 // This stores the position in the paint invalidation backing's coordinate.
1397 // It is used to detect renderer shifts that forces a full invalidation.
1398 LayoutPoint m_previousPositionFromPaintInvalidationBacking;
1399
1400 static unsigned s_instanceCount;
1401 };
1402
1403 // FIXME: remove this once the render object lifecycle ASSERTS are no longer hit .
1404 class DeprecatedDisableModifyRenderTreeStructureAsserts {
1405 WTF_MAKE_NONCOPYABLE(DeprecatedDisableModifyRenderTreeStructureAsserts);
1406 public:
1407 DeprecatedDisableModifyRenderTreeStructureAsserts();
1408
1409 static bool canModifyRenderTreeStateInAnyState();
1410
1411 private:
1412 TemporaryChange<bool> m_disabler;
1413 };
1414
1415 // Allow equality comparisons of RenderObjects by reference or pointer, intercha ngeably.
1416 DEFINE_COMPARISON_OPERATORS_WITH_REFERENCES(RenderObject)
1417
1418 inline bool RenderObject::documentBeingDestroyed() const
1419 {
1420 return document().lifecycle().state() >= DocumentLifecycle::Stopping;
1421 }
1422
1423 inline bool RenderObject::isBeforeContent() const
1424 {
1425 if (style()->styleType() != BEFORE)
1426 return false;
1427 // Text nodes don't have their own styles, so ignore the style on a text nod e.
1428 if (isText() && !isBR())
1429 return false;
1430 return true;
1431 }
1432
1433 inline bool RenderObject::isAfterContent() const
1434 {
1435 if (style()->styleType() != AFTER)
1436 return false;
1437 // Text nodes don't have their own styles, so ignore the style on a text nod e.
1438 if (isText() && !isBR())
1439 return false;
1440 return true;
1441 }
1442
1443 inline bool RenderObject::isBeforeOrAfterContent() const
1444 {
1445 return isBeforeContent() || isAfterContent();
1446 }
1447
1448 // setNeedsLayout() won't cause full paint invalidations as
1449 // setNeedsLayoutAndFullPaintInvalidation() does. Otherwise the two methods are identical.
1450 inline void RenderObject::setNeedsLayout(MarkingBehavior markParents, SubtreeLay outScope* layouter)
1451 {
1452 TRACE_EVENT_INSTANT1(
1453 TRACE_DISABLED_BY_DEFAULT("devtools.timeline.invalidationTracking"),
1454 "LayoutInvalidationTracking",
1455 "data",
1456 InspectorLayoutInvalidationTrackingEvent::data(this));
1457 ASSERT(!isSetNeedsLayoutForbidden());
1458 bool alreadyNeededLayout = m_bitfields.selfNeedsLayout();
1459 setSelfNeedsLayout(true);
1460 if (!alreadyNeededLayout) {
1461 if (markParents == MarkContainingBlockChain && (!layouter || layouter->r oot() != this))
1462 markContainingBlocksForLayout(true, 0, layouter);
1463 }
1464 }
1465
1466 inline void RenderObject::setNeedsLayoutAndFullPaintInvalidation(MarkingBehavior markParents, SubtreeLayoutScope* layouter)
1467 {
1468 setNeedsLayout(markParents, layouter);
1469 setShouldDoFullPaintInvalidation();
1470 }
1471
1472 inline void RenderObject::clearNeedsLayout()
1473 {
1474 setNeededLayoutBecauseOfChildren(needsLayoutBecauseOfChildren());
1475 setLayoutDidGetCalledSinceLastFrame();
1476 setSelfNeedsLayout(false);
1477 setEverHadLayout(true);
1478 setPosChildNeedsLayout(false);
1479 setNeedsSimplifiedNormalFlowLayout(false);
1480 setNormalChildNeedsLayout(false);
1481 setNeedsPositionedMovementLayout(false);
1482 setAncestorLineBoxDirty(false);
1483 #if ENABLE(ASSERT)
1484 checkBlockPositionedObjectsNeedLayout();
1485 #endif
1486 }
1487
1488 inline void RenderObject::setChildNeedsLayout(MarkingBehavior markParents, Subtr eeLayoutScope* layouter)
1489 {
1490 ASSERT(!isSetNeedsLayoutForbidden());
1491 bool alreadyNeededLayout = normalChildNeedsLayout();
1492 setNormalChildNeedsLayout(true);
1493 // FIXME: Replace MarkOnlyThis with the SubtreeLayoutScope code path and rem ove the MarkingBehavior argument entirely.
1494 if (!alreadyNeededLayout && markParents == MarkContainingBlockChain && (!lay outer || layouter->root() != this))
1495 markContainingBlocksForLayout(true, 0, layouter);
1496 }
1497
1498 inline void RenderObject::setNeedsPositionedMovementLayout()
1499 {
1500 bool alreadyNeededLayout = needsPositionedMovementLayout();
1501 setNeedsPositionedMovementLayout(true);
1502 ASSERT(!isSetNeedsLayoutForbidden());
1503 if (!alreadyNeededLayout)
1504 markContainingBlocksForLayout();
1505 }
1506
1507 inline bool RenderObject::preservesNewline() const
1508 {
1509 if (isSVGInlineText())
1510 return false;
1511
1512 return style()->preserveNewline();
1513 }
1514
1515 inline bool RenderObject::layerCreationAllowedForSubtree() const
1516 {
1517 RenderObject* parentRenderer = parent();
1518 while (parentRenderer) {
1519 if (parentRenderer->isSVGHiddenContainer())
1520 return false;
1521 parentRenderer = parentRenderer->parent();
1522 }
1523
1524 return true;
1525 }
1526
1527 inline void RenderObject::setSelectionStateIfNeeded(SelectionState state)
1528 {
1529 if (selectionState() == state)
1530 return;
1531
1532 setSelectionState(state);
1533 }
1534
1535 inline void RenderObject::setHasBoxDecorationBackground(bool b)
1536 {
1537 if (!b) {
1538 m_bitfields.setBoxDecorationBackgroundState(NoBoxDecorationBackground);
1539 return;
1540 }
1541 if (hasBoxDecorationBackground())
1542 return;
1543 m_bitfields.setBoxDecorationBackgroundState(HasBoxDecorationBackgroundObscur ationStatusInvalid);
1544 }
1545
1546 inline void RenderObject::invalidateBackgroundObscurationStatus()
1547 {
1548 if (!hasBoxDecorationBackground())
1549 return;
1550 m_bitfields.setBoxDecorationBackgroundState(HasBoxDecorationBackgroundObscur ationStatusInvalid);
1551 }
1552
1553 inline bool RenderObject::boxDecorationBackgroundIsKnownToBeObscured()
1554 {
1555 if (m_bitfields.boxDecorationBackgroundState() == HasBoxDecorationBackground ObscurationStatusInvalid) {
1556 BoxDecorationBackgroundState state = computeBackgroundIsKnownToBeObscure d() ? HasBoxDecorationBackgroundKnownToBeObscured : HasBoxDecorationBackgroundMa yBeVisible;
1557 m_bitfields.setBoxDecorationBackgroundState(state);
1558 }
1559 return m_bitfields.boxDecorationBackgroundState() == HasBoxDecorationBackgro undKnownToBeObscured;
1560 }
1561
1562 inline void makeMatrixRenderable(TransformationMatrix& matrix, bool has3DRenderi ng)
1563 {
1564 if (!has3DRendering)
1565 matrix.makeAffine();
1566 }
1567
1568 inline int adjustForAbsoluteZoom(int value, RenderObject* renderer)
1569 {
1570 return adjustForAbsoluteZoom(value, renderer->style());
1571 }
1572
1573 inline double adjustDoubleForAbsoluteZoom(double value, RenderObject& renderer)
1574 {
1575 ASSERT(renderer.style());
1576 return adjustDoubleForAbsoluteZoom(value, *renderer.style());
1577 }
1578
1579 inline LayoutUnit adjustLayoutUnitForAbsoluteZoom(LayoutUnit value, RenderObject & renderer)
1580 {
1581 ASSERT(renderer.style());
1582 return adjustLayoutUnitForAbsoluteZoom(value, *renderer.style());
1583 }
1584
1585 inline void adjustFloatQuadForAbsoluteZoom(FloatQuad& quad, RenderObject& render er)
1586 {
1587 float zoom = renderer.style()->effectiveZoom();
1588 if (zoom != 1)
1589 quad.scale(1 / zoom, 1 / zoom);
1590 }
1591
1592 inline void adjustFloatRectForAbsoluteZoom(FloatRect& rect, RenderObject& render er)
1593 {
1594 float zoom = renderer.style()->effectiveZoom();
1595 if (zoom != 1)
1596 rect.scale(1 / zoom, 1 / zoom);
1597 }
1598
1599 inline double adjustScrollForAbsoluteZoom(double value, RenderObject& renderer)
1600 {
1601 ASSERT(renderer.style());
1602 return adjustScrollForAbsoluteZoom(value, *renderer.style());
1603 }
1604
1605 #define DEFINE_RENDER_OBJECT_TYPE_CASTS(thisType, predicate) \
1606 DEFINE_TYPE_CASTS(thisType, RenderObject, object, object->predicate, object. predicate)
1607
1608 } // namespace blink
1609
1610 #ifndef NDEBUG
1611 // Outside the WebCore namespace for ease of invocation from gdb.
1612 void showTree(const blink::RenderObject*);
1613 void showLineTree(const blink::RenderObject*);
1614 void showRenderTree(const blink::RenderObject* object1);
1615 // We don't make object2 an optional parameter so that showRenderTree
1616 // can be called from gdb easily.
1617 void showRenderTree(const blink::RenderObject* object1, const blink::RenderObjec t* object2);
1618
1619 #endif
1620
1621 #endif // RenderObject_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698