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

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: 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
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 class DangerousLayoutTreeMutator {
leviw_travelin_and_unemployed 2015/08/21 21:10:42 I'd refactor this out of the other changes since i
265 private:
266 friend class DeprecatedPaintLayerReflectionInfo;
267 friend class DeprecatedPaintLayerScrollableArea;
268 friend class LayoutBlock;
269
270 DangerousLayoutTreeMutator(LayoutObject& thisObject) : m_thisObject(this Object) { }
271
272 void setPreviousSibling(LayoutObject* previous) { m_thisObject.setPrevio usSibling(previous); }
273 void setNextSibling(LayoutObject* next) { m_thisObject.setNextSibling(ne xt); }
274 void setParent(LayoutObject* parent) { m_thisObject.setParent(parent); }
275 void removeFromLayoutFlowThread() { m_thisObject.removeFromLayoutFlowThr ead(); }
276
277 LayoutObject& m_thisObject;
278 };
279
280 private:
269 ////////////////////////////////////////// 281 //////////////////////////////////////////
270 // Helper functions. Dangerous to use! 282 // Helper functions. Dangerous to use!
271 void setPreviousSibling(LayoutObject* previous) { m_previous = previous; } 283 void setPreviousSibling(LayoutObject* previous) { m_previous = previous; }
272 void setNextSibling(LayoutObject* next) { m_next = next; } 284 void setNextSibling(LayoutObject* next) { m_next = next; }
273 void setParent(LayoutObject* parent) 285 void setParent(LayoutObject* parent)
274 { 286 {
275 m_parent = parent; 287 m_parent = parent;
276 288
277 // Only update if our flow thread state is different from our new parent and if we're not a LayoutFlowThread. 289 // 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 290 // 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; 1058 void invalidateDisplayItemClient(const DisplayItemClientWrapper&) const;
1047 void invalidateDisplayItemClientForNonCompositingDescendants() const { inval idateDisplayItemClientForNonCompositingDescendantsOf(*this); } 1059 void invalidateDisplayItemClientForNonCompositingDescendants() const { inval idateDisplayItemClientForNonCompositingDescendantsOf(*this); }
1048 // A normal object should use invalidateDisplayItemClientForNonCompositingDe scendants() 1060 // A normal object should use invalidateDisplayItemClientForNonCompositingDe scendants()
1049 // to invalidate its descendants which are painted on the same backing. Howe ver, for 1061 // 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 1062 // 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 1063 // 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. 1064 // 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. 1065 // FIXME: should we hook up scrollbar parts in the layout tree? crbug.com/48 4263.
1054 void invalidateDisplayItemClientForNonCompositingDescendantsOf(const LayoutO bject&) const; 1066 void invalidateDisplayItemClientForNonCompositingDescendantsOf(const LayoutO bject&) const;
1055 1067
1068 virtual void updateAnonymousChildStyle(const LayoutObject& child, ComputedSt yle& style) const { }
1069
1056 protected: 1070 protected:
1057 enum LayoutObjectType { 1071 enum LayoutObjectType {
1058 LayoutObjectBr, 1072 LayoutObjectBr,
1059 LayoutObjectCanvas, 1073 LayoutObjectCanvas,
1060 LayoutObjectFieldset, 1074 LayoutObjectFieldset,
1061 LayoutObjectCounter, 1075 LayoutObjectCounter,
1062 LayoutObjectDetailsMarker, 1076 LayoutObjectDetailsMarker,
1063 LayoutObjectEmbeddedObject, 1077 LayoutObjectEmbeddedObject,
1064 LayoutObjectFileUploadControl, 1078 LayoutObjectFileUploadControl,
1065 LayoutObjectFrame, 1079 LayoutObjectFrame,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1126 1140
1127 inline bool layerCreationAllowedForSubtree() const; 1141 inline bool layerCreationAllowedForSubtree() const;
1128 1142
1129 // Overrides should call the superclass at the end. m_style will be 0 the fi rst time 1143 // Overrides should call the superclass at the end. m_style will be 0 the fi rst time
1130 // this function will be called. 1144 // this function will be called.
1131 virtual void styleWillChange(StyleDifference, const ComputedStyle& newStyle) ; 1145 virtual void styleWillChange(StyleDifference, const ComputedStyle& newStyle) ;
1132 // Overrides should call the superclass at the start. |oldStyle| will be 0 t he first 1146 // Overrides should call the superclass at the start. |oldStyle| will be 0 t he first
1133 // time this function is called. 1147 // time this function is called.
1134 virtual void styleDidChange(StyleDifference, const ComputedStyle* oldStyle); 1148 virtual void styleDidChange(StyleDifference, const ComputedStyle* oldStyle);
1135 void propagateStyleToAnonymousChildren(bool blockChildrenOnly = false); 1149 void propagateStyleToAnonymousChildren(bool blockChildrenOnly = false);
1136 virtual void updateAnonymousChildStyle(const LayoutObject& child, ComputedSt yle& style) const { }
1137 1150
1138 protected: 1151 protected:
1139 virtual void willBeDestroyed(); 1152 virtual void willBeDestroyed();
1140 1153
1141 virtual void insertedIntoTree(); 1154 virtual void insertedIntoTree();
1142 virtual void willBeRemovedFromTree(); 1155 virtual void willBeRemovedFromTree();
1143 1156
1144 void setDocumentForAnonymous(Document* document) { ASSERT(isAnonymous()); m_ node = document; } 1157 void setDocumentForAnonymous(Document* document) { ASSERT(isAnonymous()); m_ node = document; }
1145 1158
1146 // Add hit-test rects for the layout tree rooted at this node to the provide d collection on a 1159 // 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); 1189 virtual PaintInvalidationReason invalidatePaintIfNeeded(PaintInvalidationSta te&, const LayoutBoxModelObject& paintInvalidationContainer);
1177 1190
1178 // When this object is invalidated for paint, this method is called to inval idate any DisplayItemClients 1191 // 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., 1192 // 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 1193 // not including children which will be invalidated normally during invalida teTreeIfNeeded() and
1181 // parts which are invalidated separately (e.g. scrollbars). 1194 // parts which are invalidated separately (e.g. scrollbars).
1182 virtual void invalidateDisplayItemClients(const LayoutBoxModelObject& paintI nvalidationContainer) const; 1195 virtual void invalidateDisplayItemClients(const LayoutBoxModelObject& paintI nvalidationContainer) const;
1183 1196
1184 void setIsSlowRepaintObject(bool); 1197 void setIsSlowRepaintObject(bool);
1185 1198
1199 void clearSelfNeedsOverflowRecalcAfterStyleChange() { m_bitfields.setSelfNee dsOverflowRecalcAfterStyleChange(false); }
1200 void clearChildNeedsOverflowRecalcAfterStyleChange() { m_bitfields.setChildN eedsOverflowRecalcAfterStyleChange(false); }
1201 void setShouldInvalidateOverflowForPaint() { m_bitfields.setShouldInvalidate OverflowForPaint(true); }
1202 void setEverHadLayout() { m_bitfields.setEverHadLayout(true); }
1203
1186 private: 1204 private:
1187 const LayoutRect& previousPaintInvalidationRect() const { return m_previousP aintInvalidationRect; } 1205 const LayoutRect& previousPaintInvalidationRect() const { return m_previousP aintInvalidationRect; }
1188 1206
1189 // Adjusts a paint invalidation rect in the space of |m_previousPaintInvalid ationRect| and |m_previousPositionFromPaintInvalidationBacking| 1207 // Adjusts a paint invalidation rect in the space of |m_previousPaintInvalid ationRect| and |m_previousPositionFromPaintInvalidationBacking|
1190 // to be in the space of the |paintInvalidationContainer|, 1208 // to be in the space of the |paintInvalidationContainer|,
1191 // if needed. They can be different only if |paintInvalidationContainer| is a composited scroller. 1209 // if needed. They can be different only if |paintInvalidationContainer| is a composited scroller.
1192 void adjustInvalidationRectForCompositedScrolling(LayoutRect&, const LayoutB oxModelObject& paintInvalidationContainer) const; 1210 void adjustInvalidationRectForCompositedScrolling(LayoutRect&, const LayoutB oxModelObject& paintInvalidationContainer) const;
1193 1211
1194 void clearLayoutRootIfNeeded() const; 1212 void clearLayoutRootIfNeeded() const;
1195 1213
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1403 #undef ADD_BOOLEAN_BITFIELD 1421 #undef ADD_BOOLEAN_BITFIELD
1404 1422
1405 LayoutObjectBitfields m_bitfields; 1423 LayoutObjectBitfields m_bitfields;
1406 1424
1407 void setSelfNeedsLayout(bool b) { m_bitfields.setSelfNeedsLayout(b); } 1425 void setSelfNeedsLayout(bool b) { m_bitfields.setSelfNeedsLayout(b); }
1408 void setNeedsPositionedMovementLayout(bool b) { m_bitfields.setNeedsPosition edMovementLayout(b); } 1426 void setNeedsPositionedMovementLayout(bool b) { m_bitfields.setNeedsPosition edMovementLayout(b); }
1409 void setNormalChildNeedsLayout(bool b) { m_bitfields.setNormalChildNeedsLayo ut(b); } 1427 void setNormalChildNeedsLayout(bool b) { m_bitfields.setNormalChildNeedsLayo ut(b); }
1410 void setPosChildNeedsLayout(bool b) { m_bitfields.setPosChildNeedsLayout(b); } 1428 void setPosChildNeedsLayout(bool b) { m_bitfields.setPosChildNeedsLayout(b); }
1411 void setNeedsSimplifiedNormalFlowLayout(bool b) { m_bitfields.setNeedsSimpli fiedNormalFlowLayout(b); } 1429 void setNeedsSimplifiedNormalFlowLayout(bool b) { m_bitfields.setNeedsSimpli fiedNormalFlowLayout(b); }
1412 void setIsDragging(bool b) { m_bitfields.setIsDragging(b); } 1430 void setIsDragging(bool b) { m_bitfields.setIsDragging(b); }
1413 void setEverHadLayout(bool b) { m_bitfields.setEverHadLayout(b); } 1431 void clearShouldInvalidateOverflowForPaint() { m_bitfields.setShouldInvalida teOverflowForPaint(false); }
1414 void setShouldInvalidateOverflowForPaint(bool b) { m_bitfields.setShouldInva lidateOverflowForPaint(b); } 1432 void setSelfNeedsOverflowRecalcAfterStyleChange() { m_bitfields.setSelfNeeds OverflowRecalcAfterStyleChange(true); }
1415 void setSelfNeedsOverflowRecalcAfterStyleChange(bool b) { m_bitfields.setSel fNeedsOverflowRecalcAfterStyleChange(b); } 1433 void setChildNeedsOverflowRecalcAfterStyleChange() { m_bitfields.setChildNee dsOverflowRecalcAfterStyleChange(true); }
1416 void setChildNeedsOverflowRecalcAfterStyleChange(bool b) { m_bitfields.setCh ildNeedsOverflowRecalcAfterStyleChange(b); }
1417 1434
1418 private: 1435 private:
1419 // Store state between styleWillChange and styleDidChange 1436 // Store state between styleWillChange and styleDidChange
1420 static bool s_affectsParentBlock; 1437 static bool s_affectsParentBlock;
1421 1438
1422 // This stores the paint invalidation rect from the previous frame. This rec t does *not* account for composited scrolling. See 1439 // This stores the paint invalidation rect from the previous frame. This rec t does *not* account for composited scrolling. See
1423 // adjustInvalidationRectForCompositedScrolling(). 1440 // adjustInvalidationRectForCompositedScrolling().
1424 LayoutRect m_previousPaintInvalidationRect; 1441 LayoutRect m_previousPaintInvalidationRect;
1425 1442
1426 // This stores the position in the paint invalidation backing's coordinate. 1443 // This stores the position in the paint invalidation backing's coordinate.
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1505 1522
1506 inline void LayoutObject::setNeedsLayoutAndFullPaintInvalidation(LayoutInvalidat ionReasonForTracing reason, MarkingBehavior markParents, SubtreeLayoutScope* lay outer) 1523 inline void LayoutObject::setNeedsLayoutAndFullPaintInvalidation(LayoutInvalidat ionReasonForTracing reason, MarkingBehavior markParents, SubtreeLayoutScope* lay outer)
1507 { 1524 {
1508 setNeedsLayout(reason, markParents, layouter); 1525 setNeedsLayout(reason, markParents, layouter);
1509 setShouldDoFullPaintInvalidation(); 1526 setShouldDoFullPaintInvalidation();
1510 } 1527 }
1511 1528
1512 inline void LayoutObject::clearNeedsLayout() 1529 inline void LayoutObject::clearNeedsLayout()
1513 { 1530 {
1514 // Set flags for later stages/cycles. 1531 // Set flags for later stages/cycles.
1515 setEverHadLayout(true); 1532 setEverHadLayout();
1516 setMayNeedPaintInvalidation(); 1533 setMayNeedPaintInvalidation();
1517 m_bitfields.setNeededLayoutBecauseOfChildren(needsLayoutBecauseOfChildren()) ; 1534 m_bitfields.setNeededLayoutBecauseOfChildren(needsLayoutBecauseOfChildren()) ;
1518 1535
1519 // Clear needsLayout flags. 1536 // Clear needsLayout flags.
1520 setSelfNeedsLayout(false); 1537 setSelfNeedsLayout(false);
1521 setPosChildNeedsLayout(false); 1538 setPosChildNeedsLayout(false);
1522 setNeedsSimplifiedNormalFlowLayout(false); 1539 setNeedsSimplifiedNormalFlowLayout(false);
1523 setNormalChildNeedsLayout(false); 1540 setNormalChildNeedsLayout(false);
1524 setNeedsPositionedMovementLayout(false); 1541 setNeedsPositionedMovementLayout(false);
1525 setAncestorLineBoxDirty(false); 1542 setAncestorLineBoxDirty(false);
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1656 void showTree(const blink::LayoutObject*); 1673 void showTree(const blink::LayoutObject*);
1657 void showLineTree(const blink::LayoutObject*); 1674 void showLineTree(const blink::LayoutObject*);
1658 void showLayoutTree(const blink::LayoutObject* object1); 1675 void showLayoutTree(const blink::LayoutObject* object1);
1659 // We don't make object2 an optional parameter so that showLayoutTree 1676 // We don't make object2 an optional parameter so that showLayoutTree
1660 // can be called from gdb easily. 1677 // can be called from gdb easily.
1661 void showLayoutTree(const blink::LayoutObject* object1, const blink::LayoutObjec t* object2); 1678 void showLayoutTree(const blink::LayoutObject* object1, const blink::LayoutObjec t* object2);
1662 1679
1663 #endif 1680 #endif
1664 1681
1665 #endif // LayoutObject_h 1682 #endif // LayoutObject_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698