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

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*, const RenderStyle&) const { retur n 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*, const 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 { return mutableStyleRef(); }
803 RenderStyle& mutableStyleRef() const { ASSERT(m_style); return *m_style; }
804
805 /* The following methods are inlined in RenderObjectInlines.h */
806 RenderStyle* firstLineStyle() const;
807 RenderStyle* style(bool firstLine) const;
808 const RenderStyle& styleRef(bool firstLine) const;
809
810 static inline Color resolveColor(const RenderStyle& styleToUse, int colorPro perty)
811 {
812 return styleToUse.visitedDependentColor(colorProperty);
813 }
814
815 inline Color resolveColor(int colorProperty) const
816 {
817 return style()->visitedDependentColor(colorProperty);
818 }
819
820 // Used only by Element::pseudoStyleCacheIsInvalid to get a first line style based off of a
821 // given new style, without accessing the cache.
822 PassRefPtr<RenderStyle> uncachedFirstLineStyle(RenderStyle*) const;
823
824 virtual CursorDirective getCursor(const LayoutPoint&, Cursor&) const;
825
826 struct AppliedTextDecoration {
827 Color color;
828 TextDecorationStyle style;
829 AppliedTextDecoration() : color(Color::transparent), style(TextDecoratio nStyleSolid) { }
830 };
831
832 void getTextDecorations(unsigned decorations, AppliedTextDecoration& underli ne, AppliedTextDecoration& overline, AppliedTextDecoration& linethrough, bool qu irksMode = false, bool firstlineStyle = false);
833
834 // Return the LayoutLayerModelObject in the container chain which is respons ible for painting this object, or 0
835 // if painting is root-relative. This is the container that should be passed to the 'forPaintInvalidation'
836 // methods.
837 const LayoutLayerModelObject* containerForPaintInvalidation() const;
838 const LayoutLayerModelObject* adjustCompositedContainerForSpecialAncestors(c onst LayoutLayerModelObject* paintInvalidationContainer) const;
839 bool isPaintInvalidationContainer() const;
840
841 LayoutRect computePaintInvalidationRect()
842 {
843 return computePaintInvalidationRect(containerForPaintInvalidation());
844 }
845
846 // Returns the paint invalidation rect for this RenderObject in the coordina te space of the paint backing (typically a GraphicsLayer) for |paintInvalidation Container|.
847 LayoutRect computePaintInvalidationRect(const LayoutLayerModelObject* paintI nvalidationContainer, const PaintInvalidationState* = 0) const;
848
849 // Returns the rect bounds needed to invalidate the paint of this object, in the coordinate space of the rendering backing of |paintInvalidationContainer|
850 LayoutRect boundsRectForPaintInvalidation(const LayoutLayerModelObject* pain tInvalidationContainer, const PaintInvalidationState* = 0) const;
851
852 // Actually do the paint invalidate of rect r for this object which has been computed in the coordinate space
853 // of the GraphicsLayer backing of |paintInvalidationContainer|. Note that t his coordinaten space is not the same
854 // as the local coordinate space of |paintInvalidationContainer| in the pres ence of layer squashing.
855 // If |paintInvalidationContainer| is 0, invalidate paints via the view.
856 // FIXME: |paintInvalidationContainer| should never be 0. See crbug.com/3636 99.
857 void invalidatePaintUsingContainer(const LayoutLayerModelObject* paintInvali dationContainer, const LayoutRect&, PaintInvalidationReason) const;
858
859 // Invalidate the paint of a specific subrectangle within a given object. Th e rect |r| is in the object's coordinate space.
860 void invalidatePaintRectangle(const LayoutRect&) const;
861
862 void invalidateSelectionIfNeeded(const LayoutLayerModelObject&, PaintInvalid ationReason);
863
864 // 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.
865 virtual void invalidateTreeIfNeeded(const PaintInvalidationState&);
866
867 virtual void invalidatePaintForOverflow();
868 void invalidatePaintForOverflowIfNeeded();
869
870 void invalidatePaintIncludingNonCompositingDescendants();
871
872 // Returns the rect that should have paint invalidated whenever this object changes. The rect is in the view's
873 // coordinate space. This method deals with outlines and overflow.
874 virtual LayoutRect absoluteClippedOverflowRect() const;
875 virtual LayoutRect clippedOverflowRectForPaintInvalidation(const LayoutLayer ModelObject* paintInvalidationContainer, const PaintInvalidationState* = 0) cons t;
876 virtual LayoutRect rectWithOutlineForPaintInvalidation(const LayoutLayerMode lObject* paintInvalidationContainer, LayoutUnit outlineWidth, const PaintInvalid ationState* = 0) const;
877
878 // Given a rect in the object's coordinate space, compute a rect suitable fo r invalidating paints of
879 // that rect in the coordinate space of paintInvalidationContainer.
880 virtual void mapRectToPaintInvalidationBacking(const LayoutLayerModelObject* paintInvalidationContainer, LayoutRect&, const PaintInvalidationState*) const;
881
882 // Return the offset to the column in which the specified point (in flow-thr ead coordinates)
883 // lives. This is used to convert a flow-thread point to a visual point.
884 virtual LayoutSize columnOffset(const LayoutPoint&) const { return LayoutSiz e(); }
885
886 virtual unsigned length() const { return 1; }
887
888 bool isFloatingOrOutOfFlowPositioned() const { return (isFloating() || isOut OfFlowPositioned()); }
889
890 bool isTransparent() const { return style()->hasOpacity(); }
891 float opacity() const { return style()->opacity(); }
892
893 bool hasReflection() const { return m_bitfields.hasReflection(); }
894
895 enum SelectionState {
896 SelectionNone, // The object is not selected.
897 SelectionStart, // The object either contains the start of a selection r un or is the start of a run
898 SelectionInside, // The object is fully encompassed by a selection run
899 SelectionEnd, // The object either contains the end of a selection run o r is the end of a run
900 SelectionBoth // The object contains an entire run or is the sole select ed object in that run
901 };
902
903 // The current selection state for an object. For blocks, the state refers to the state of the leaf
904 // descendants (as described above in the SelectionState enum declaration).
905 SelectionState selectionState() const { return m_bitfields.selectionState(); }
906 virtual void setSelectionState(SelectionState state) { m_bitfields.setSelect ionState(state); }
907 inline void setSelectionStateIfNeeded(SelectionState);
908 bool canUpdateSelectionOnRootLineBoxes() const;
909
910 // A single rectangle that encompasses all of the selected objects within th is object. Used to determine the tightest
911 // possible bounding box for the selection. The rect returned is in the coor dinate space of the paint invalidation container's backing.
912 virtual LayoutRect selectionRectForPaintInvalidation(const LayoutLayerModelO bject* /*paintInvalidationContainer*/) const { return LayoutRect(); }
913
914 virtual bool canBeSelectionLeaf() const { return false; }
915 bool hasSelectedChildren() const { return selectionState() != SelectionNone; }
916
917 bool isSelectable() const;
918 // Obtains the selection colors that should be used when painting a selectio n.
919 Color selectionBackgroundColor() const;
920 Color selectionForegroundColor() const;
921 Color selectionEmphasisMarkColor() const;
922
923 // Whether or not a given block needs to paint selection gaps.
924 virtual bool shouldPaintSelectionGaps() const { return false; }
925
926 /**
927 * Returns the local coordinates of the caret within this render object.
928 * @param caretOffset zero-based offset determining position within the rend er object.
929 * @param extraWidthToEndOfLine optional out arg to give extra width to end of line -
930 * useful for character range rect computations
931 */
932 virtual LayoutRect localCaretRect(InlineBox*, int caretOffset, LayoutUnit* e xtraWidthToEndOfLine = 0);
933
934 // When performing a global document tear-down, the renderer of the document is cleared. We use this
935 // as a hook to detect the case of document destruction and don't waste time doing unnecessary work.
936 bool documentBeingDestroyed() const;
937
938 void destroyAndCleanupAnonymousWrappers();
939 virtual void destroy();
940
941 // Virtual function helpers for the deprecated Flexible Box Layout (display: -webkit-box).
942 virtual bool isDeprecatedFlexibleBox() const { return false; }
943
944 // Virtual function helper for the new FlexibleBox Layout (display: -webkit- flex).
945 virtual bool isFlexibleBox() const { return false; }
946
947 bool isFlexibleBoxIncludingDeprecated() const
948 {
949 return isFlexibleBox() || isDeprecatedFlexibleBox();
950 }
951
952 virtual bool isCombineText() const { return false; }
953
954 virtual int caretMinOffset() const;
955 virtual int caretMaxOffset() const;
956
957 virtual int previousOffset(int current) const;
958 virtual int previousOffsetForBackwardDeletion(int current) const;
959 virtual int nextOffset(int current) const;
960
961 virtual void imageChanged(ImageResource*, const IntRect* = 0) override final ;
962 virtual void imageChanged(WrappedImagePtr, const IntRect* = 0) { }
963 virtual bool willRenderImage(ImageResource*) override final;
964 virtual bool getImageAnimationPolicy(ImageResource*, ImageAnimationPolicy&) override final;
965
966 void selectionStartEnd(int& spos, int& epos) const;
967
968 void remove() { if (parent()) parent()->removeChild(this); }
969
970 bool isInert() const;
971
972 bool supportsTouchAction() const;
973
974 bool visibleToHitTestRequest(const HitTestRequest& request) const { return s tyle()->visibility() == VISIBLE && (request.ignorePointerEventsNone() || style() ->pointerEvents() != PE_NONE) && !isInert(); }
975
976 bool visibleToHitTesting() const { return style()->visibility() == VISIBLE & & style()->pointerEvents() != PE_NONE && !isInert(); }
977
978 // Map points and quads through elements, potentially via 3d transforms. You should never need to call these directly; use
979 // localToAbsolute/absoluteToLocal methods instead.
980 virtual void mapLocalToContainer(const LayoutLayerModelObject* paintInvalida tionContainer, TransformState&, MapCoordinatesFlags = ApplyContainerFlip, bool* wasFixed = 0, const PaintInvalidationState* = 0) const;
981 virtual void mapAbsoluteToLocalPoint(MapCoordinatesFlags, TransformState&) c onst;
982
983 // Pushes state onto RenderGeometryMap about how to map coordinates from thi s renderer to its container, or ancestorToStopAt (whichever is encountered first ).
984 // Returns the renderer which was mapped to (container or ancestorToStopAt).
985 virtual const RenderObject* pushMappingToContainer(const LayoutLayerModelObj ect* ancestorToStopAt, RenderGeometryMap&) const;
986
987 bool shouldUseTransformFromContainer(const RenderObject* container) const;
988 void getTransformFromContainer(const RenderObject* container, const LayoutSi ze& offsetInContainer, TransformationMatrix&) const;
989
990 bool createsGroup() const { return isTransparent() || hasMask() || hasFilter () || style()->hasBlendMode(); }
991
992 virtual void addFocusRingRects(Vector<LayoutRect>&, const LayoutPoint& addit ionalOffset) const { }
993
994 // Compute a list of hit-test rectangles per layer rooted at this renderer.
995 virtual void computeLayerHitTestRects(LayerHitTestRects&) const;
996
997 // 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.
998 RenderObject* rendererForRootBackground();
999
1000 RespectImageOrientationEnum shouldRespectImageOrientation() const;
1001
1002 bool isRelayoutBoundaryForInspector() const;
1003
1004 // The previous paint invalidation rect in the object's previous paint backi ng.
1005 const LayoutRect& previousPaintInvalidationRect() const { return m_previousP aintInvalidationRect; }
1006 void setPreviousPaintInvalidationRect(const LayoutRect& rect) { m_previousPa intInvalidationRect = rect; }
1007
1008 // The previous position of the top-left corner of the object in its previou s paint backing.
1009 const LayoutPoint& previousPositionFromPaintInvalidationBacking() const { re turn m_previousPositionFromPaintInvalidationBacking; }
1010 void setPreviousPositionFromPaintInvalidationBacking(const LayoutPoint& posi tionFromPaintInvalidationBacking) { m_previousPositionFromPaintInvalidationBacki ng = positionFromPaintInvalidationBacking; }
1011
1012 bool shouldDoFullPaintInvalidation() const { return m_bitfields.fullPaintInv alidationReason() != PaintInvalidationNone; }
1013 void setShouldDoFullPaintInvalidation(PaintInvalidationReason = PaintInvalid ationFull);
1014 void clearShouldDoFullPaintInvalidation() { m_bitfields.setFullPaintInvalida tionReason(PaintInvalidationNone); }
1015
1016 bool shouldInvalidateOverflowForPaint() const { return m_bitfields.shouldInv alidateOverflowForPaint(); }
1017
1018 virtual void clearPaintInvalidationState(const PaintInvalidationState&);
1019
1020 // Indicates whether this render object was re-laid-out since the last frame .
1021 // The flag will be cleared during invalidateTreeIfNeeded.
1022 bool layoutDidGetCalledSinceLastFrame() const { return m_bitfields.layoutDid GetCalledSinceLastFrame(); }
1023
1024 bool mayNeedPaintInvalidation() const { return m_bitfields.mayNeedPaintInval idation(); }
1025 void setMayNeedPaintInvalidation();
1026 void clearMayNeedPaintInvalidation();
1027
1028 bool shouldInvalidateSelection() const { return m_bitfields.shouldInvalidate Selection(); }
1029 void setShouldInvalidateSelection()
1030 {
1031 if (!canUpdateSelectionOnRootLineBoxes())
1032 return;
1033
1034 m_bitfields.setShouldInvalidateSelection(true);
1035 markContainingBlockChainForPaintInvalidation();
1036 }
1037 void clearShouldInvalidateSelection() { m_bitfields.setShouldInvalidateSelec tion(false); }
1038
1039 bool neededLayoutBecauseOfChildren() const { return m_bitfields.neededLayout BecauseOfChildren(); }
1040 void setNeededLayoutBecauseOfChildren(bool b) { m_bitfields.setNeededLayoutB ecauseOfChildren(b); }
1041
1042 bool shouldCheckForPaintInvalidation(const PaintInvalidationState& paintInva lidationState) const
1043 {
1044 return paintInvalidationState.forceCheckForPaintInvalidation() || should CheckForPaintInvalidationRegardlessOfPaintInvalidationState();
1045 }
1046
1047 bool shouldCheckForPaintInvalidationRegardlessOfPaintInvalidationState() con st
1048 {
1049 return layoutDidGetCalledSinceLastFrame() || mayNeedPaintInvalidation() || shouldDoFullPaintInvalidation() || shouldInvalidateSelection();
1050 }
1051
1052 virtual bool supportsPaintInvalidationStateCachedOffsets() const { return !h asColumns() && !hasTransformRelatedProperty() && !hasReflection() && !style()->i sFlippedBlocksWritingMode(); }
1053
1054 void setNeedsOverflowRecalcAfterStyleChange();
1055 void markContainingBlocksForOverflowRecalc();
1056
1057 virtual LayoutRect viewRect() const;
1058
1059 DisplayItemClient displayItemClient() const { return toDisplayItemClient(thi s); }
1060
1061 protected:
1062 enum RenderObjectType {
1063 RenderObjectBr,
1064 RenderObjectCanvas,
1065 RenderObjectFieldset,
1066 RenderObjectCounter,
1067 RenderObjectDetailsMarker,
1068 RenderObjectEmbeddedObject,
1069 RenderObjectFileUploadControl,
1070 RenderObjectFrame,
1071 RenderObjectFrameSet,
1072 RenderObjectLayoutTableCol,
1073 RenderObjectListBox,
1074 RenderObjectListItem,
1075 RenderObjectListMarker,
1076 RenderObjectMedia,
1077 RenderObjectMenuList,
1078 RenderObjectMeter,
1079 RenderObjectProgress,
1080 RenderObjectQuote,
1081 RenderObjectRenderButton,
1082 RenderObjectRenderFlowThread,
1083 RenderObjectRenderFullScreen,
1084 RenderObjectRenderFullScreenPlaceholder,
1085 RenderObjectRenderGrid,
1086 RenderObjectRenderIFrame,
1087 RenderObjectRenderImage,
1088 RenderObjectRenderInline,
1089 RenderObjectRenderMultiColumnSet,
1090 RenderObjectRenderMultiColumnSpannerPlaceholder,
1091 RenderObjectRenderPart,
1092 RenderObjectRenderRegion,
1093 RenderObjectRenderScrollbarPart,
1094 RenderObjectRenderView,
1095 RenderObjectReplica,
1096 RenderObjectRuby,
1097 RenderObjectRubyBase,
1098 RenderObjectRubyRun,
1099 RenderObjectRubyText,
1100 RenderObjectSlider,
1101 RenderObjectSliderThumb,
1102 RenderObjectTable,
1103 RenderObjectTableCaption,
1104 RenderObjectTableCell,
1105 RenderObjectTableRow,
1106 RenderObjectTableSection,
1107 RenderObjectTextArea,
1108 RenderObjectTextControl,
1109 RenderObjectTextField,
1110 RenderObjectVideo,
1111 RenderObjectWidget,
1112
1113 RenderObjectSVG, /* Keep by itself? */
1114 RenderObjectSVGRoot,
1115 RenderObjectSVGContainer,
1116 RenderObjectSVGTransformableContainer,
1117 RenderObjectSVGViewportContainer,
1118 RenderObjectSVGHiddenContainer,
1119 RenderObjectSVGGradientStop,
1120 RenderObjectSVGShape,
1121 RenderObjectSVGText,
1122 RenderObjectSVGTextPath,
1123 RenderObjectSVGInline,
1124 RenderObjectSVGInlineText,
1125 RenderObjectSVGImage,
1126 RenderObjectSVGForeignObject,
1127 RenderObjectSVGResourceContainer,
1128 RenderObjectSVGResourceFilter,
1129 RenderObjectSVGResourceFilterPrimitive,
1130 };
1131 virtual bool isOfType(RenderObjectType type) const { return false; }
1132
1133 inline bool layerCreationAllowedForSubtree() const;
1134
1135 // Overrides should call the superclass at the end. m_style will be 0 the fi rst time
1136 // this function will be called.
1137 virtual void styleWillChange(StyleDifference, const RenderStyle& newStyle);
1138 // Overrides should call the superclass at the start. |oldStyle| will be 0 t he first
1139 // time this function is called.
1140 virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
1141 void propagateStyleToAnonymousChildren(bool blockChildrenOnly = false);
1142 virtual void updateAnonymousChildStyle(const RenderObject* child, RenderStyl e* style) const { }
1143
1144 protected:
1145 void setSelfMayNeedPaintInvalidation();
1146
1147 void clearLayoutRootIfNeeded() const;
1148 virtual void willBeDestroyed();
1149 void postDestroy();
1150
1151 virtual void insertedIntoTree();
1152 virtual void willBeRemovedFromTree();
1153
1154 void setDocumentForAnonymous(Document* document) { ASSERT(isAnonymous()); m_ node = document; }
1155
1156 // Add hit-test rects for the render tree rooted at this node to the provide d collection on a
1157 // per-Layer basis.
1158 // currentLayer must be the enclosing layer, and layerOffset is the current offset within
1159 // this layer. Subclass implementations will add any offset for this rendere r within it's
1160 // container, so callers should provide only the offset of the container wit hin it's layer.
1161 // containerRect is a rect that has already been added for the currentLayer which is likely to
1162 // be a container for child elements. Any rect wholly contained by container Rect can be
1163 // skipped.
1164 virtual void addLayerHitTestRects(LayerHitTestRects&, const Layer* currentLa yer, const LayoutPoint& layerOffset, const LayoutRect& containerRect) const;
1165
1166 // Add hit-test rects for this renderer only to the provided list. layerOffs et is the offset
1167 // of this renderer within the current layer that should be used for each re sult.
1168 virtual void computeSelfHitTestRects(Vector<LayoutRect>&, const LayoutPoint& layerOffset) const { };
1169
1170 virtual PaintInvalidationReason paintInvalidationReason(const LayoutLayerMod elObject& paintInvalidationContainer,
1171 const LayoutRect& oldPaintInvalidationRect, const LayoutPoint& oldPositi onFromPaintInvalidationBacking,
1172 const LayoutRect& newPaintInvalidationRect, const LayoutPoint& newPositi onFromPaintInvalidationBacking) const;
1173 virtual void incrementallyInvalidatePaint(const LayoutLayerModelObject& pain tInvalidationContainer, const LayoutRect& oldBounds, const LayoutRect& newBounds , const LayoutPoint& positionFromPaintInvalidationBacking);
1174 void fullyInvalidatePaint(const LayoutLayerModelObject& paintInvalidationCon tainer, PaintInvalidationReason, const LayoutRect& oldBounds, const LayoutRect& newBounds);
1175
1176 #if ENABLE(ASSERT)
1177 virtual bool paintInvalidationStateIsDirty() const
1178 {
1179 return neededLayoutBecauseOfChildren() || shouldCheckForPaintInvalidatio nRegardlessOfPaintInvalidationState();
1180 }
1181 #endif
1182
1183 virtual void invalidatePaintOfSubtreesIfNeeded(const PaintInvalidationState& childPaintInvalidationState);
1184 virtual PaintInvalidationReason invalidatePaintIfNeeded(const PaintInvalidat ionState&, const LayoutLayerModelObject& paintInvalidationContainer);
1185
1186 // When this object is invalidated for paint, this method is called to inval idate any DisplayItemClients
1187 // owned by this object, including the object itself, RenderText/RenderInlin e line boxes, scrollbars, etc.,
1188 // not including children which will be invalidated normally during invalida teTreeIfNeeded().
1189 virtual void invalidateDisplayItemClients(DisplayItemList*) const;
1190
1191 private:
1192 void setLayoutDidGetCalledSinceLastFrame()
1193 {
1194 m_bitfields.setLayoutDidGetCalledSinceLastFrame(true);
1195
1196 // Make sure our parent is marked as needing invalidation.
1197 // This would be unneeded if we allowed sub-tree invalidation (akin to s ub-tree layouts).
1198 markContainingBlockChainForPaintInvalidation();
1199 }
1200 void clearLayoutDidGetCalledSinceLastFrame() { m_bitfields.setLayoutDidGetCa lledSinceLastFrame(false); }
1201
1202 void invalidatePaintIncludingNonCompositingDescendantsInternal(const LayoutL ayerModelObject* repaintContainer);
1203
1204 LayoutRect previousSelectionRectForPaintInvalidation() const;
1205 void setPreviousSelectionRectForPaintInvalidation(const LayoutRect&);
1206
1207 const LayoutLayerModelObject* enclosingCompositedContainer() const;
1208
1209 RenderFlowThread* locateFlowThreadContainingBlock() const;
1210 void removeFromRenderFlowThread();
1211 void removeFromRenderFlowThreadRecursive(RenderFlowThread*);
1212
1213 RenderStyle* cachedFirstLineStyle() const;
1214 StyleDifference adjustStyleDifference(StyleDifference) const;
1215
1216 Color selectionColor(int colorProperty) const;
1217
1218 void removeShapeImageClient(ShapeValue*);
1219
1220 #if ENABLE(ASSERT)
1221 void checkBlockPositionedObjectsNeedLayout();
1222 #endif
1223
1224 void markContainingBlockChainForPaintInvalidation();
1225
1226 static bool isAllowedToModifyRenderTreeStructure(Document&);
1227
1228 RefPtr<RenderStyle> m_style;
1229
1230 // Oilpan: raw pointer back to the owning Node is considered safe.
1231 Node* m_node;
1232
1233 RenderObject* m_parent;
1234 RenderObject* m_previous;
1235 RenderObject* m_next;
1236
1237 #if ENABLE(ASSERT)
1238 unsigned m_hasAXObject : 1;
1239 unsigned m_setNeedsLayoutForbidden : 1;
1240 #endif
1241
1242 #define ADD_BOOLEAN_BITFIELD(name, Name) \
1243 private:\
1244 unsigned m_##name : 1;\
1245 public:\
1246 bool name() const { return m_##name; }\
1247 void set##Name(bool name) { m_##name = name; }\
1248
1249 class RenderObjectBitfields {
1250 enum PositionedState {
1251 IsStaticallyPositioned = 0,
1252 IsRelativelyPositioned = 1,
1253 IsOutOfFlowPositioned = 2,
1254 };
1255
1256 public:
1257 RenderObjectBitfields(Node* node)
1258 : m_selfNeedsLayout(false)
1259 , m_shouldInvalidateOverflowForPaint(false)
1260 // FIXME: We should remove mayNeedPaintInvalidation once we are able to
1261 // use the other layout flags to detect the same cases. crbug.com/37 0118
1262 , m_mayNeedPaintInvalidation(false)
1263 , m_shouldInvalidateSelection(false)
1264 , m_neededLayoutBecauseOfChildren(false)
1265 , m_needsPositionedMovementLayout(false)
1266 , m_normalChildNeedsLayout(false)
1267 , m_posChildNeedsLayout(false)
1268 , m_needsSimplifiedNormalFlowLayout(false)
1269 , m_preferredLogicalWidthsDirty(false)
1270 , m_floating(false)
1271 , m_selfNeedsOverflowRecalcAfterStyleChange(false)
1272 , m_childNeedsOverflowRecalcAfterStyleChange(false)
1273 , m_isAnonymous(!node)
1274 , m_isText(false)
1275 , m_isBox(false)
1276 , m_isInline(true)
1277 , m_isReplaced(false)
1278 , m_horizontalWritingMode(true)
1279 , m_isDragging(false)
1280 , m_hasLayer(false)
1281 , m_hasOverflowClip(false)
1282 , m_hasTransformRelatedProperty(false)
1283 , m_hasReflection(false)
1284 , m_hasCounterNodeMap(false)
1285 , m_everHadLayout(false)
1286 , m_ancestorLineBoxDirty(false)
1287 , m_layoutDidGetCalledSinceLastFrame(false)
1288 , m_hasPendingResourceUpdate(false)
1289 , m_childrenInline(false)
1290 , m_hasColumns(false)
1291 , m_alwaysCreateLineBoxesForRenderInline(false)
1292 , m_positionedState(IsStaticallyPositioned)
1293 , m_selectionState(SelectionNone)
1294 , m_flowThreadState(NotInsideFlowThread)
1295 , m_boxDecorationBackgroundState(NoBoxDecorationBackground)
1296 , m_fullPaintInvalidationReason(PaintInvalidationNone)
1297 {
1298 }
1299
1300 // 32 bits have been used in the first word, and 14 in the second.
1301 ADD_BOOLEAN_BITFIELD(selfNeedsLayout, SelfNeedsLayout);
1302 ADD_BOOLEAN_BITFIELD(shouldInvalidateOverflowForPaint, ShouldInvalidateO verflowForPaint);
1303 ADD_BOOLEAN_BITFIELD(mayNeedPaintInvalidation, MayNeedPaintInvalidation) ;
1304 ADD_BOOLEAN_BITFIELD(shouldInvalidateSelection, ShouldInvalidateSelectio n);
1305 ADD_BOOLEAN_BITFIELD(neededLayoutBecauseOfChildren, NeededLayoutBecauseO fChildren);
1306 ADD_BOOLEAN_BITFIELD(needsPositionedMovementLayout, NeedsPositionedMovem entLayout);
1307 ADD_BOOLEAN_BITFIELD(normalChildNeedsLayout, NormalChildNeedsLayout);
1308 ADD_BOOLEAN_BITFIELD(posChildNeedsLayout, PosChildNeedsLayout);
1309 ADD_BOOLEAN_BITFIELD(needsSimplifiedNormalFlowLayout, NeedsSimplifiedNor malFlowLayout);
1310 ADD_BOOLEAN_BITFIELD(preferredLogicalWidthsDirty, PreferredLogicalWidths Dirty);
1311 ADD_BOOLEAN_BITFIELD(floating, Floating);
1312 ADD_BOOLEAN_BITFIELD(selfNeedsOverflowRecalcAfterStyleChange, SelfNeedsO verflowRecalcAfterStyleChange);
1313 ADD_BOOLEAN_BITFIELD(childNeedsOverflowRecalcAfterStyleChange, ChildNeed sOverflowRecalcAfterStyleChange);
1314
1315 ADD_BOOLEAN_BITFIELD(isAnonymous, IsAnonymous);
1316 ADD_BOOLEAN_BITFIELD(isText, IsText);
1317 ADD_BOOLEAN_BITFIELD(isBox, IsBox);
1318 ADD_BOOLEAN_BITFIELD(isInline, IsInline);
1319 ADD_BOOLEAN_BITFIELD(isReplaced, IsReplaced);
1320 ADD_BOOLEAN_BITFIELD(horizontalWritingMode, HorizontalWritingMode);
1321 ADD_BOOLEAN_BITFIELD(isDragging, IsDragging);
1322
1323 ADD_BOOLEAN_BITFIELD(hasLayer, HasLayer);
1324 ADD_BOOLEAN_BITFIELD(hasOverflowClip, HasOverflowClip); // Set in the ca se of overflow:auto/scroll/hidden
1325 ADD_BOOLEAN_BITFIELD(hasTransformRelatedProperty, HasTransformRelatedPro perty);
1326 ADD_BOOLEAN_BITFIELD(hasReflection, HasReflection);
1327
1328 ADD_BOOLEAN_BITFIELD(hasCounterNodeMap, HasCounterNodeMap);
1329 ADD_BOOLEAN_BITFIELD(everHadLayout, EverHadLayout);
1330 ADD_BOOLEAN_BITFIELD(ancestorLineBoxDirty, AncestorLineBoxDirty);
1331
1332 ADD_BOOLEAN_BITFIELD(layoutDidGetCalledSinceLastFrame, LayoutDidGetCalle dSinceLastFrame);
1333
1334 ADD_BOOLEAN_BITFIELD(hasPendingResourceUpdate, HasPendingResourceUpdate) ;
1335
1336 // from RenderBlock
1337 ADD_BOOLEAN_BITFIELD(childrenInline, ChildrenInline);
1338 ADD_BOOLEAN_BITFIELD(hasColumns, HasColumns);
1339
1340 // from RenderInline
1341 ADD_BOOLEAN_BITFIELD(alwaysCreateLineBoxesForRenderInline, AlwaysCreateL ineBoxesForRenderInline);
1342
1343 private:
1344 unsigned m_positionedState : 2; // PositionedState
1345 unsigned m_selectionState : 3; // SelectionState
1346 unsigned m_flowThreadState : 2; // FlowThreadState
1347 unsigned m_boxDecorationBackgroundState : 2; // BoxDecorationBackgroundS tate
1348 unsigned m_fullPaintInvalidationReason : 5; // PaintInvalidationReason
1349
1350 public:
1351 bool isOutOfFlowPositioned() const { return m_positionedState == IsOutOf FlowPositioned; }
1352 bool isRelPositioned() const { return m_positionedState == IsRelativelyP ositioned; }
1353 bool isPositioned() const { return m_positionedState != IsStaticallyPosi tioned; }
1354
1355 void setPositionedState(int positionState)
1356 {
1357 // This mask maps FixedPosition and AbsolutePosition to IsOutOfFlowP ositioned, saving one bit.
1358 m_positionedState = static_cast<PositionedState>(positionState & 0x3 );
1359 }
1360 void clearPositionedState() { m_positionedState = StaticPosition; }
1361
1362 ALWAYS_INLINE SelectionState selectionState() const { return static_cast <SelectionState>(m_selectionState); }
1363 ALWAYS_INLINE void setSelectionState(SelectionState selectionState) { m_ selectionState = selectionState; }
1364
1365 ALWAYS_INLINE FlowThreadState flowThreadState() const { return static_ca st<FlowThreadState>(m_flowThreadState); }
1366 ALWAYS_INLINE void setFlowThreadState(FlowThreadState flowThreadState) { m_flowThreadState = flowThreadState; }
1367
1368 ALWAYS_INLINE BoxDecorationBackgroundState boxDecorationBackgroundState( ) const { return static_cast<BoxDecorationBackgroundState>(m_boxDecorationBackgr oundState); }
1369 ALWAYS_INLINE void setBoxDecorationBackgroundState(BoxDecorationBackgrou ndState s) { m_boxDecorationBackgroundState = s; }
1370
1371 PaintInvalidationReason fullPaintInvalidationReason() const { return sta tic_cast<PaintInvalidationReason>(m_fullPaintInvalidationReason); }
1372 void setFullPaintInvalidationReason(PaintInvalidationReason reason) { m_ fullPaintInvalidationReason = reason; }
1373 };
1374
1375 #undef ADD_BOOLEAN_BITFIELD
1376
1377 RenderObjectBitfields m_bitfields;
1378
1379 void setSelfNeedsLayout(bool b) { m_bitfields.setSelfNeedsLayout(b); }
1380 void setNeedsPositionedMovementLayout(bool b) { m_bitfields.setNeedsPosition edMovementLayout(b); }
1381 void setNormalChildNeedsLayout(bool b) { m_bitfields.setNormalChildNeedsLayo ut(b); }
1382 void setPosChildNeedsLayout(bool b) { m_bitfields.setPosChildNeedsLayout(b); }
1383 void setNeedsSimplifiedNormalFlowLayout(bool b) { m_bitfields.setNeedsSimpli fiedNormalFlowLayout(b); }
1384 void setIsDragging(bool b) { m_bitfields.setIsDragging(b); }
1385 void setEverHadLayout(bool b) { m_bitfields.setEverHadLayout(b); }
1386 void setShouldInvalidateOverflowForPaint(bool b) { m_bitfields.setShouldInva lidateOverflowForPaint(b); }
1387 void setSelfNeedsOverflowRecalcAfterStyleChange(bool b) { m_bitfields.setSel fNeedsOverflowRecalcAfterStyleChange(b); }
1388 void setChildNeedsOverflowRecalcAfterStyleChange(bool b) { m_bitfields.setCh ildNeedsOverflowRecalcAfterStyleChange(b); }
1389
1390 private:
1391 // Store state between styleWillChange and styleDidChange
1392 static bool s_affectsParentBlock;
1393
1394 // This stores the paint invalidation rect from the previous frame.
1395 LayoutRect m_previousPaintInvalidationRect;
1396
1397 // This stores the position in the paint invalidation backing's coordinate.
1398 // It is used to detect renderer shifts that forces a full invalidation.
1399 LayoutPoint m_previousPositionFromPaintInvalidationBacking;
1400
1401 static unsigned s_instanceCount;
1402 };
1403
1404 // FIXME: remove this once the render object lifecycle ASSERTS are no longer hit .
1405 class DeprecatedDisableModifyRenderTreeStructureAsserts {
1406 WTF_MAKE_NONCOPYABLE(DeprecatedDisableModifyRenderTreeStructureAsserts);
1407 public:
1408 DeprecatedDisableModifyRenderTreeStructureAsserts();
1409
1410 static bool canModifyRenderTreeStateInAnyState();
1411
1412 private:
1413 TemporaryChange<bool> m_disabler;
1414 };
1415
1416 // Allow equality comparisons of RenderObjects by reference or pointer, intercha ngeably.
1417 DEFINE_COMPARISON_OPERATORS_WITH_REFERENCES(RenderObject)
1418
1419 inline bool RenderObject::documentBeingDestroyed() const
1420 {
1421 return document().lifecycle().state() >= DocumentLifecycle::Stopping;
1422 }
1423
1424 inline bool RenderObject::isBeforeContent() const
1425 {
1426 if (style()->styleType() != BEFORE)
1427 return false;
1428 // Text nodes don't have their own styles, so ignore the style on a text nod e.
1429 if (isText() && !isBR())
1430 return false;
1431 return true;
1432 }
1433
1434 inline bool RenderObject::isAfterContent() const
1435 {
1436 if (style()->styleType() != AFTER)
1437 return false;
1438 // Text nodes don't have their own styles, so ignore the style on a text nod e.
1439 if (isText() && !isBR())
1440 return false;
1441 return true;
1442 }
1443
1444 inline bool RenderObject::isBeforeOrAfterContent() const
1445 {
1446 return isBeforeContent() || isAfterContent();
1447 }
1448
1449 // setNeedsLayout() won't cause full paint invalidations as
1450 // setNeedsLayoutAndFullPaintInvalidation() does. Otherwise the two methods are identical.
1451 inline void RenderObject::setNeedsLayout(MarkingBehavior markParents, SubtreeLay outScope* layouter)
1452 {
1453 TRACE_EVENT_INSTANT1(
1454 TRACE_DISABLED_BY_DEFAULT("devtools.timeline.invalidationTracking"),
1455 "LayoutInvalidationTracking",
1456 "data",
1457 InspectorLayoutInvalidationTrackingEvent::data(this));
1458 ASSERT(!isSetNeedsLayoutForbidden());
1459 bool alreadyNeededLayout = m_bitfields.selfNeedsLayout();
1460 setSelfNeedsLayout(true);
1461 if (!alreadyNeededLayout) {
1462 if (markParents == MarkContainingBlockChain && (!layouter || layouter->r oot() != this))
1463 markContainingBlocksForLayout(true, 0, layouter);
1464 }
1465 }
1466
1467 inline void RenderObject::setNeedsLayoutAndFullPaintInvalidation(MarkingBehavior markParents, SubtreeLayoutScope* layouter)
1468 {
1469 setNeedsLayout(markParents, layouter);
1470 setShouldDoFullPaintInvalidation();
1471 }
1472
1473 inline void RenderObject::clearNeedsLayout()
1474 {
1475 setNeededLayoutBecauseOfChildren(needsLayoutBecauseOfChildren());
1476 setLayoutDidGetCalledSinceLastFrame();
1477 setSelfNeedsLayout(false);
1478 setEverHadLayout(true);
1479 setPosChildNeedsLayout(false);
1480 setNeedsSimplifiedNormalFlowLayout(false);
1481 setNormalChildNeedsLayout(false);
1482 setNeedsPositionedMovementLayout(false);
1483 setAncestorLineBoxDirty(false);
1484 #if ENABLE(ASSERT)
1485 checkBlockPositionedObjectsNeedLayout();
1486 #endif
1487 }
1488
1489 inline void RenderObject::setChildNeedsLayout(MarkingBehavior markParents, Subtr eeLayoutScope* layouter)
1490 {
1491 ASSERT(!isSetNeedsLayoutForbidden());
1492 bool alreadyNeededLayout = normalChildNeedsLayout();
1493 setNormalChildNeedsLayout(true);
1494 // FIXME: Replace MarkOnlyThis with the SubtreeLayoutScope code path and rem ove the MarkingBehavior argument entirely.
1495 if (!alreadyNeededLayout && markParents == MarkContainingBlockChain && (!lay outer || layouter->root() != this))
1496 markContainingBlocksForLayout(true, 0, layouter);
1497 }
1498
1499 inline void RenderObject::setNeedsPositionedMovementLayout()
1500 {
1501 bool alreadyNeededLayout = needsPositionedMovementLayout();
1502 setNeedsPositionedMovementLayout(true);
1503 ASSERT(!isSetNeedsLayoutForbidden());
1504 if (!alreadyNeededLayout)
1505 markContainingBlocksForLayout();
1506 }
1507
1508 inline bool RenderObject::preservesNewline() const
1509 {
1510 if (isSVGInlineText())
1511 return false;
1512
1513 return style()->preserveNewline();
1514 }
1515
1516 inline bool RenderObject::layerCreationAllowedForSubtree() const
1517 {
1518 RenderObject* parentRenderer = parent();
1519 while (parentRenderer) {
1520 if (parentRenderer->isSVGHiddenContainer())
1521 return false;
1522 parentRenderer = parentRenderer->parent();
1523 }
1524
1525 return true;
1526 }
1527
1528 inline void RenderObject::setSelectionStateIfNeeded(SelectionState state)
1529 {
1530 if (selectionState() == state)
1531 return;
1532
1533 setSelectionState(state);
1534 }
1535
1536 inline void RenderObject::setHasBoxDecorationBackground(bool b)
1537 {
1538 if (!b) {
1539 m_bitfields.setBoxDecorationBackgroundState(NoBoxDecorationBackground);
1540 return;
1541 }
1542 if (hasBoxDecorationBackground())
1543 return;
1544 m_bitfields.setBoxDecorationBackgroundState(HasBoxDecorationBackgroundObscur ationStatusInvalid);
1545 }
1546
1547 inline void RenderObject::invalidateBackgroundObscurationStatus()
1548 {
1549 if (!hasBoxDecorationBackground())
1550 return;
1551 m_bitfields.setBoxDecorationBackgroundState(HasBoxDecorationBackgroundObscur ationStatusInvalid);
1552 }
1553
1554 inline bool RenderObject::boxDecorationBackgroundIsKnownToBeObscured()
1555 {
1556 if (m_bitfields.boxDecorationBackgroundState() == HasBoxDecorationBackground ObscurationStatusInvalid) {
1557 BoxDecorationBackgroundState state = computeBackgroundIsKnownToBeObscure d() ? HasBoxDecorationBackgroundKnownToBeObscured : HasBoxDecorationBackgroundMa yBeVisible;
1558 m_bitfields.setBoxDecorationBackgroundState(state);
1559 }
1560 return m_bitfields.boxDecorationBackgroundState() == HasBoxDecorationBackgro undKnownToBeObscured;
1561 }
1562
1563 inline void makeMatrixRenderable(TransformationMatrix& matrix, bool has3DRenderi ng)
1564 {
1565 if (!has3DRendering)
1566 matrix.makeAffine();
1567 }
1568
1569 inline int adjustForAbsoluteZoom(int value, RenderObject* renderer)
1570 {
1571 return adjustForAbsoluteZoom(value, renderer->style());
1572 }
1573
1574 inline double adjustDoubleForAbsoluteZoom(double value, RenderObject& renderer)
1575 {
1576 ASSERT(renderer.style());
1577 return adjustDoubleForAbsoluteZoom(value, *renderer.style());
1578 }
1579
1580 inline LayoutUnit adjustLayoutUnitForAbsoluteZoom(LayoutUnit value, RenderObject & renderer)
1581 {
1582 ASSERT(renderer.style());
1583 return adjustLayoutUnitForAbsoluteZoom(value, *renderer.style());
1584 }
1585
1586 inline void adjustFloatQuadForAbsoluteZoom(FloatQuad& quad, RenderObject& render er)
1587 {
1588 float zoom = renderer.style()->effectiveZoom();
1589 if (zoom != 1)
1590 quad.scale(1 / zoom, 1 / zoom);
1591 }
1592
1593 inline void adjustFloatRectForAbsoluteZoom(FloatRect& rect, RenderObject& render er)
1594 {
1595 float zoom = renderer.style()->effectiveZoom();
1596 if (zoom != 1)
1597 rect.scale(1 / zoom, 1 / zoom);
1598 }
1599
1600 inline double adjustScrollForAbsoluteZoom(double value, RenderObject& renderer)
1601 {
1602 ASSERT(renderer.style());
1603 return adjustScrollForAbsoluteZoom(value, *renderer.style());
1604 }
1605
1606 #define DEFINE_RENDER_OBJECT_TYPE_CASTS(thisType, predicate) \
1607 DEFINE_TYPE_CASTS(thisType, RenderObject, object, object->predicate, object. predicate)
1608
1609 } // namespace blink
1610
1611 #ifndef NDEBUG
1612 // Outside the WebCore namespace for ease of invocation from gdb.
1613 void showTree(const blink::RenderObject*);
1614 void showLineTree(const blink::RenderObject*);
1615 void showRenderTree(const blink::RenderObject* object1);
1616 // We don't make object2 an optional parameter so that showRenderTree
1617 // can be called from gdb easily.
1618 void showRenderTree(const blink::RenderObject* object1, const blink::RenderObjec t* object2);
1619
1620 #endif
1621
1622 #endif // RenderObject_h
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderMultiColumnSpannerPlaceholder.h ('k') | Source/core/rendering/RenderObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698