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

Side by Side Diff: Source/core/layout/LayoutObject.h

Issue 1306993002: Cleanup friends of LayoutObject (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: document Created 5 years, 4 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
« no previous file with comments | « Source/core/layout/LayoutBlockFlow.cpp ('k') | Source/core/layout/LayoutObject.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Antti Koivisto (koivisto@kde.org) 3 * (C) 2000 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) 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. 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. 7 * Copyright (C) 2009 Google Inc. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 }; 110 };
111 111
112 typedef WTF::HashMap<const DeprecatedPaintLayer*, Vector<LayoutRect>> LayerHitTe stRects; 112 typedef WTF::HashMap<const DeprecatedPaintLayer*, Vector<LayoutRect>> LayerHitTe stRects;
113 113
114 #ifndef NDEBUG 114 #ifndef NDEBUG
115 const int showTreeCharacterOffset = 39; 115 const int showTreeCharacterOffset = 39;
116 #endif 116 #endif
117 117
118 // Base class for all layout tree objects. 118 // Base class for all layout tree objects.
119 class CORE_EXPORT LayoutObject : public ImageResourceClient { 119 class CORE_EXPORT LayoutObject : public ImageResourceClient {
120 friend class LayoutBlock;
121 friend class LayoutBlockFlow;
122 friend class DeprecatedPaintLayerReflectionInfo; // For setParent
123 friend class DeprecatedPaintLayerScrollableArea; // For setParent.
124 friend class LayoutObjectChildList; 120 friend class LayoutObjectChildList;
125 WTF_MAKE_NONCOPYABLE(LayoutObject); 121 WTF_MAKE_NONCOPYABLE(LayoutObject);
126 public: 122 public:
127 // Anonymous objects should pass the document as their node, and they will t hen automatically be 123 // Anonymous objects should pass the document as their node, and they will t hen automatically be
128 // marked as anonymous in the constructor. 124 // marked as anonymous in the constructor.
129 explicit LayoutObject(Node*); 125 explicit LayoutObject(Node*);
130 ~LayoutObject() override; 126 ~LayoutObject() override;
131 127
132 // Returns the name of the layout object. 128 // Returns the name of the layout object.
133 virtual const char* name() const = 0; 129 virtual const char* name() const = 0;
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 // LayoutObject tree manipulation 254 // LayoutObject tree manipulation
259 ////////////////////////////////////////// 255 //////////////////////////////////////////
260 virtual bool canHaveChildren() const { return virtualChildren(); } 256 virtual bool canHaveChildren() const { return virtualChildren(); }
261 virtual bool isChildAllowed(LayoutObject*, const ComputedStyle&) const { ret urn true; } 257 virtual bool isChildAllowed(LayoutObject*, const ComputedStyle&) const { ret urn true; }
262 virtual void addChild(LayoutObject* newChild, LayoutObject* beforeChild = nu llptr); 258 virtual void addChild(LayoutObject* newChild, LayoutObject* beforeChild = nu llptr);
263 virtual void addChildIgnoringContinuation(LayoutObject* newChild, LayoutObje ct* beforeChild = nullptr) { return addChild(newChild, beforeChild); } 259 virtual void addChildIgnoringContinuation(LayoutObject* newChild, LayoutObje ct* beforeChild = nullptr) { return addChild(newChild, beforeChild); }
264 virtual void removeChild(LayoutObject*); 260 virtual void removeChild(LayoutObject*);
265 virtual bool createsAnonymousWrapper() const { return false; } 261 virtual bool createsAnonymousWrapper() const { return false; }
266 ////////////////////////////////////////// 262 //////////////////////////////////////////
267 263
268 protected: 264 void setDangerousOneWayParent(LayoutObject* parent)
chrishtr 2015/08/26 02:59:19 I don't think this needs to be inline.
Xianzhu 2015/08/26 16:12:04 Done.
265 {
266 ASSERT(!previousSibling());
267 ASSERT(!nextSibling());
268 ASSERT(!parent || !m_parent);
269 setParent(parent);
270 }
271
272 private:
269 ////////////////////////////////////////// 273 //////////////////////////////////////////
270 // Helper functions. Dangerous to use! 274 // Helper functions. Dangerous to use!
271 void setPreviousSibling(LayoutObject* previous) { m_previous = previous; } 275 void setPreviousSibling(LayoutObject* previous) { m_previous = previous; }
272 void setNextSibling(LayoutObject* next) { m_next = next; } 276 void setNextSibling(LayoutObject* next) { m_next = next; }
273 void setParent(LayoutObject* parent) 277 void setParent(LayoutObject* parent)
274 { 278 {
275 m_parent = parent; 279 m_parent = parent;
276 280
277 // Only update if our flow thread state is different from our new parent and if we're not a LayoutFlowThread. 281 // Only update if our flow thread state is different from our new parent and if we're not a LayoutFlowThread.
278 // A LayoutFlowThread is always considered to be inside itself, so it ne ver has to change its state 282 // A LayoutFlowThread is always considered to be inside itself, so it ne ver has to change its state
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after
1046 void invalidateDisplayItemClient(const DisplayItemClientWrapper&) const; 1050 void invalidateDisplayItemClient(const DisplayItemClientWrapper&) const;
1047 void invalidateDisplayItemClientForNonCompositingDescendants() const { inval idateDisplayItemClientForNonCompositingDescendantsOf(*this); } 1051 void invalidateDisplayItemClientForNonCompositingDescendants() const { inval idateDisplayItemClientForNonCompositingDescendantsOf(*this); }
1048 // A normal object should use invalidateDisplayItemClientForNonCompositingDe scendants() 1052 // A normal object should use invalidateDisplayItemClientForNonCompositingDe scendants()
1049 // to invalidate its descendants which are painted on the same backing. Howe ver, for 1053 // to invalidate its descendants which are painted on the same backing. Howe ver, for
1050 // an object (e.g. LayoutScrollbarPart, custom scroll corner, custom resizer ) which is 1054 // an object (e.g. LayoutScrollbarPart, custom scroll corner, custom resizer ) which is
1051 // not hooked up in the layout tree and not able to find its paint backing, it should 1055 // not hooked up in the layout tree and not able to find its paint backing, it should
1052 // let its owning layout object call the following function. 1056 // let its owning layout object call the following function.
1053 // FIXME: should we hook up scrollbar parts in the layout tree? crbug.com/48 4263. 1057 // FIXME: should we hook up scrollbar parts in the layout tree? crbug.com/48 4263.
1054 void invalidateDisplayItemClientForNonCompositingDescendantsOf(const LayoutO bject&) const; 1058 void invalidateDisplayItemClientForNonCompositingDescendantsOf(const LayoutO bject&) const;
1055 1059
1060 // Called before anonymousChild.setStyle(). Override to set custom styles fo r the child.
1061 virtual void updateAnonymousChildStyle(const LayoutObject& anonymousChild, C omputedStyle& style) const { }
1062
1056 protected: 1063 protected:
1057 enum LayoutObjectType { 1064 enum LayoutObjectType {
1058 LayoutObjectBr, 1065 LayoutObjectBr,
1059 LayoutObjectCanvas, 1066 LayoutObjectCanvas,
1060 LayoutObjectFieldset, 1067 LayoutObjectFieldset,
1061 LayoutObjectCounter, 1068 LayoutObjectCounter,
1062 LayoutObjectDetailsMarker, 1069 LayoutObjectDetailsMarker,
1063 LayoutObjectEmbeddedObject, 1070 LayoutObjectEmbeddedObject,
1064 LayoutObjectFileUploadControl, 1071 LayoutObjectFileUploadControl,
1065 LayoutObjectFrame, 1072 LayoutObjectFrame,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1126 1133
1127 inline bool layerCreationAllowedForSubtree() const; 1134 inline bool layerCreationAllowedForSubtree() const;
1128 1135
1129 // Overrides should call the superclass at the end. m_style will be 0 the fi rst time 1136 // Overrides should call the superclass at the end. m_style will be 0 the fi rst time
1130 // this function will be called. 1137 // this function will be called.
1131 virtual void styleWillChange(StyleDifference, const ComputedStyle& newStyle) ; 1138 virtual void styleWillChange(StyleDifference, const ComputedStyle& newStyle) ;
1132 // Overrides should call the superclass at the start. |oldStyle| will be 0 t he first 1139 // Overrides should call the superclass at the start. |oldStyle| will be 0 t he first
1133 // time this function is called. 1140 // time this function is called.
1134 virtual void styleDidChange(StyleDifference, const ComputedStyle* oldStyle); 1141 virtual void styleDidChange(StyleDifference, const ComputedStyle* oldStyle);
1135 void propagateStyleToAnonymousChildren(bool blockChildrenOnly = false); 1142 void propagateStyleToAnonymousChildren(bool blockChildrenOnly = false);
1136 virtual void updateAnonymousChildStyle(const LayoutObject& child, ComputedSt yle& style) const { }
1137 1143
1138 protected: 1144 protected:
1139 virtual void willBeDestroyed(); 1145 virtual void willBeDestroyed();
1140 1146
1141 virtual void insertedIntoTree(); 1147 virtual void insertedIntoTree();
1142 virtual void willBeRemovedFromTree(); 1148 virtual void willBeRemovedFromTree();
1143 1149
1144 void setDocumentForAnonymous(Document* document) { ASSERT(isAnonymous()); m_ node = document; } 1150 void setDocumentForAnonymous(Document* document) { ASSERT(isAnonymous()); m_ node = document; }
1145 1151
1146 // Add hit-test rects for the layout tree rooted at this node to the provide d collection on a 1152 // Add hit-test rects for the layout tree rooted at this node to the provide d collection on a
(...skipping 29 matching lines...) Expand all
1176 virtual PaintInvalidationReason invalidatePaintIfNeeded(PaintInvalidationSta te&, const LayoutBoxModelObject& paintInvalidationContainer); 1182 virtual PaintInvalidationReason invalidatePaintIfNeeded(PaintInvalidationSta te&, const LayoutBoxModelObject& paintInvalidationContainer);
1177 1183
1178 // When this object is invalidated for paint, this method is called to inval idate any DisplayItemClients 1184 // When this object is invalidated for paint, this method is called to inval idate any DisplayItemClients
1179 // owned by this object, including the object itself, LayoutText/LayoutInlin e line boxes, etc., 1185 // owned by this object, including the object itself, LayoutText/LayoutInlin e line boxes, etc.,
1180 // not including children which will be invalidated normally during invalida teTreeIfNeeded() and 1186 // not including children which will be invalidated normally during invalida teTreeIfNeeded() and
1181 // parts which are invalidated separately (e.g. scrollbars). 1187 // parts which are invalidated separately (e.g. scrollbars).
1182 virtual void invalidateDisplayItemClients(const LayoutBoxModelObject& paintI nvalidationContainer) const; 1188 virtual void invalidateDisplayItemClients(const LayoutBoxModelObject& paintI nvalidationContainer) const;
1183 1189
1184 void setIsSlowRepaintObject(bool); 1190 void setIsSlowRepaintObject(bool);
1185 1191
1192 void clearSelfNeedsOverflowRecalcAfterStyleChange() { m_bitfields.setSelfNee dsOverflowRecalcAfterStyleChange(false); }
1193 void clearChildNeedsOverflowRecalcAfterStyleChange() { m_bitfields.setChildN eedsOverflowRecalcAfterStyleChange(false); }
1194 void setShouldInvalidateOverflowForPaint() { m_bitfields.setShouldInvalidate OverflowForPaint(true); }
1195 void setEverHadLayout() { m_bitfields.setEverHadLayout(true); }
1196
1197 // Remove this object and all descendants from the containing LayoutFlowThre ad.
1198 void removeFromLayoutFlowThread();
1199
1186 private: 1200 private:
1187 const LayoutRect& previousPaintInvalidationRect() const { return m_previousP aintInvalidationRect; } 1201 const LayoutRect& previousPaintInvalidationRect() const { return m_previousP aintInvalidationRect; }
1188 1202
1189 // Adjusts a paint invalidation rect in the space of |m_previousPaintInvalid ationRect| and |m_previousPositionFromPaintInvalidationBacking| 1203 // Adjusts a paint invalidation rect in the space of |m_previousPaintInvalid ationRect| and |m_previousPositionFromPaintInvalidationBacking|
1190 // to be in the space of the |paintInvalidationContainer|, 1204 // to be in the space of the |paintInvalidationContainer|,
1191 // if needed. They can be different only if |paintInvalidationContainer| is a composited scroller. 1205 // if needed. They can be different only if |paintInvalidationContainer| is a composited scroller.
1192 void adjustInvalidationRectForCompositedScrolling(LayoutRect&, const LayoutB oxModelObject& paintInvalidationContainer) const; 1206 void adjustInvalidationRectForCompositedScrolling(LayoutRect&, const LayoutB oxModelObject& paintInvalidationContainer) const;
1193 1207
1194 void clearLayoutRootIfNeeded() const; 1208 void clearLayoutRootIfNeeded() const;
1195 1209
(...skipping 19 matching lines...) Expand all
1215 inline void invalidateContainerPreferredLogicalWidths(); 1229 inline void invalidateContainerPreferredLogicalWidths();
1216 1230
1217 void invalidatePaintIncludingNonCompositingDescendantsInternal(const LayoutB oxModelObject& repaintContainer); 1231 void invalidatePaintIncludingNonCompositingDescendantsInternal(const LayoutB oxModelObject& repaintContainer);
1218 1232
1219 LayoutRect previousSelectionRectForPaintInvalidation() const; 1233 LayoutRect previousSelectionRectForPaintInvalidation() const;
1220 void setPreviousSelectionRectForPaintInvalidation(const LayoutRect&); 1234 void setPreviousSelectionRectForPaintInvalidation(const LayoutRect&);
1221 1235
1222 const LayoutBoxModelObject* enclosingCompositedContainer() const; 1236 const LayoutBoxModelObject* enclosingCompositedContainer() const;
1223 1237
1224 LayoutFlowThread* locateFlowThreadContainingBlock() const; 1238 LayoutFlowThread* locateFlowThreadContainingBlock() const;
1225 void removeFromLayoutFlowThread();
1226 void removeFromLayoutFlowThreadRecursive(LayoutFlowThread*); 1239 void removeFromLayoutFlowThreadRecursive(LayoutFlowThread*);
1227 1240
1228 ComputedStyle* cachedFirstLineStyle() const; 1241 ComputedStyle* cachedFirstLineStyle() const;
1229 StyleDifference adjustStyleDifference(StyleDifference) const; 1242 StyleDifference adjustStyleDifference(StyleDifference) const;
1230 1243
1231 Color selectionColor(int colorProperty, const GlobalPaintFlags) const; 1244 Color selectionColor(int colorProperty, const GlobalPaintFlags) const;
1232 1245
1233 void removeShapeImageClient(ShapeValue*); 1246 void removeShapeImageClient(ShapeValue*);
1234 1247
1235 #if ENABLE(ASSERT) 1248 #if ENABLE(ASSERT)
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1403 #undef ADD_BOOLEAN_BITFIELD 1416 #undef ADD_BOOLEAN_BITFIELD
1404 1417
1405 LayoutObjectBitfields m_bitfields; 1418 LayoutObjectBitfields m_bitfields;
1406 1419
1407 void setSelfNeedsLayout(bool b) { m_bitfields.setSelfNeedsLayout(b); } 1420 void setSelfNeedsLayout(bool b) { m_bitfields.setSelfNeedsLayout(b); }
1408 void setNeedsPositionedMovementLayout(bool b) { m_bitfields.setNeedsPosition edMovementLayout(b); } 1421 void setNeedsPositionedMovementLayout(bool b) { m_bitfields.setNeedsPosition edMovementLayout(b); }
1409 void setNormalChildNeedsLayout(bool b) { m_bitfields.setNormalChildNeedsLayo ut(b); } 1422 void setNormalChildNeedsLayout(bool b) { m_bitfields.setNormalChildNeedsLayo ut(b); }
1410 void setPosChildNeedsLayout(bool b) { m_bitfields.setPosChildNeedsLayout(b); } 1423 void setPosChildNeedsLayout(bool b) { m_bitfields.setPosChildNeedsLayout(b); }
1411 void setNeedsSimplifiedNormalFlowLayout(bool b) { m_bitfields.setNeedsSimpli fiedNormalFlowLayout(b); } 1424 void setNeedsSimplifiedNormalFlowLayout(bool b) { m_bitfields.setNeedsSimpli fiedNormalFlowLayout(b); }
1412 void setIsDragging(bool b) { m_bitfields.setIsDragging(b); } 1425 void setIsDragging(bool b) { m_bitfields.setIsDragging(b); }
1413 void setEverHadLayout(bool b) { m_bitfields.setEverHadLayout(b); } 1426 void clearShouldInvalidateOverflowForPaint() { m_bitfields.setShouldInvalida teOverflowForPaint(false); }
1414 void setShouldInvalidateOverflowForPaint(bool b) { m_bitfields.setShouldInva lidateOverflowForPaint(b); } 1427 void setSelfNeedsOverflowRecalcAfterStyleChange() { m_bitfields.setSelfNeeds OverflowRecalcAfterStyleChange(true); }
1415 void setSelfNeedsOverflowRecalcAfterStyleChange(bool b) { m_bitfields.setSel fNeedsOverflowRecalcAfterStyleChange(b); } 1428 void setChildNeedsOverflowRecalcAfterStyleChange() { m_bitfields.setChildNee dsOverflowRecalcAfterStyleChange(true); }
1416 void setChildNeedsOverflowRecalcAfterStyleChange(bool b) { m_bitfields.setCh ildNeedsOverflowRecalcAfterStyleChange(b); }
1417 1429
1418 private: 1430 private:
1419 // Store state between styleWillChange and styleDidChange 1431 // Store state between styleWillChange and styleDidChange
1420 static bool s_affectsParentBlock; 1432 static bool s_affectsParentBlock;
1421 1433
1422 // This stores the paint invalidation rect from the previous frame. This rec t does *not* account for composited scrolling. See 1434 // This stores the paint invalidation rect from the previous frame. This rec t does *not* account for composited scrolling. See
1423 // adjustInvalidationRectForCompositedScrolling(). 1435 // adjustInvalidationRectForCompositedScrolling().
1424 LayoutRect m_previousPaintInvalidationRect; 1436 LayoutRect m_previousPaintInvalidationRect;
1425 1437
1426 // This stores the position in the paint invalidation backing's coordinate. 1438 // This stores the position in the paint invalidation backing's coordinate.
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1505 1517
1506 inline void LayoutObject::setNeedsLayoutAndFullPaintInvalidation(LayoutInvalidat ionReasonForTracing reason, MarkingBehavior markParents, SubtreeLayoutScope* lay outer) 1518 inline void LayoutObject::setNeedsLayoutAndFullPaintInvalidation(LayoutInvalidat ionReasonForTracing reason, MarkingBehavior markParents, SubtreeLayoutScope* lay outer)
1507 { 1519 {
1508 setNeedsLayout(reason, markParents, layouter); 1520 setNeedsLayout(reason, markParents, layouter);
1509 setShouldDoFullPaintInvalidation(); 1521 setShouldDoFullPaintInvalidation();
1510 } 1522 }
1511 1523
1512 inline void LayoutObject::clearNeedsLayout() 1524 inline void LayoutObject::clearNeedsLayout()
1513 { 1525 {
1514 // Set flags for later stages/cycles. 1526 // Set flags for later stages/cycles.
1515 setEverHadLayout(true); 1527 setEverHadLayout();
1516 setMayNeedPaintInvalidation(); 1528 setMayNeedPaintInvalidation();
1517 m_bitfields.setNeededLayoutBecauseOfChildren(needsLayoutBecauseOfChildren()) ; 1529 m_bitfields.setNeededLayoutBecauseOfChildren(needsLayoutBecauseOfChildren()) ;
1518 1530
1519 // Clear needsLayout flags. 1531 // Clear needsLayout flags.
1520 setSelfNeedsLayout(false); 1532 setSelfNeedsLayout(false);
1521 setPosChildNeedsLayout(false); 1533 setPosChildNeedsLayout(false);
1522 setNeedsSimplifiedNormalFlowLayout(false); 1534 setNeedsSimplifiedNormalFlowLayout(false);
1523 setNormalChildNeedsLayout(false); 1535 setNormalChildNeedsLayout(false);
1524 setNeedsPositionedMovementLayout(false); 1536 setNeedsPositionedMovementLayout(false);
1525 setAncestorLineBoxDirty(false); 1537 setAncestorLineBoxDirty(false);
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1656 void showTree(const blink::LayoutObject*); 1668 void showTree(const blink::LayoutObject*);
1657 void showLineTree(const blink::LayoutObject*); 1669 void showLineTree(const blink::LayoutObject*);
1658 void showLayoutTree(const blink::LayoutObject* object1); 1670 void showLayoutTree(const blink::LayoutObject* object1);
1659 // We don't make object2 an optional parameter so that showLayoutTree 1671 // We don't make object2 an optional parameter so that showLayoutTree
1660 // can be called from gdb easily. 1672 // can be called from gdb easily.
1661 void showLayoutTree(const blink::LayoutObject* object1, const blink::LayoutObjec t* object2); 1673 void showLayoutTree(const blink::LayoutObject* object1, const blink::LayoutObjec t* object2);
1662 1674
1663 #endif 1675 #endif
1664 1676
1665 #endif // LayoutObject_h 1677 #endif // LayoutObject_h
OLDNEW
« no previous file with comments | « Source/core/layout/LayoutBlockFlow.cpp ('k') | Source/core/layout/LayoutObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698