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

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, 3 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 // Sets the parent of this object but doesn't add it as a child of the paren t.
265 void setDangerousOneWayParent(LayoutObject*);
266
267 private:
269 ////////////////////////////////////////// 268 //////////////////////////////////////////
270 // Helper functions. Dangerous to use! 269 // Helper functions. Dangerous to use!
271 void setPreviousSibling(LayoutObject* previous) { m_previous = previous; } 270 void setPreviousSibling(LayoutObject* previous) { m_previous = previous; }
272 void setNextSibling(LayoutObject* next) { m_next = next; } 271 void setNextSibling(LayoutObject* next) { m_next = next; }
273 void setParent(LayoutObject* parent) 272 void setParent(LayoutObject* parent)
274 { 273 {
275 m_parent = parent; 274 m_parent = parent;
276 275
277 // Only update if our flow thread state is different from our new parent and if we're not a LayoutFlowThread. 276 // 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 277 // 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; 1045 void invalidateDisplayItemClient(const DisplayItemClientWrapper&) const;
1047 void invalidateDisplayItemClientForNonCompositingDescendants() const { inval idateDisplayItemClientForNonCompositingDescendantsOf(*this); } 1046 void invalidateDisplayItemClientForNonCompositingDescendants() const { inval idateDisplayItemClientForNonCompositingDescendantsOf(*this); }
1048 // A normal object should use invalidateDisplayItemClientForNonCompositingDe scendants() 1047 // A normal object should use invalidateDisplayItemClientForNonCompositingDe scendants()
1049 // to invalidate its descendants which are painted on the same backing. Howe ver, for 1048 // 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 1049 // 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 1050 // 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. 1051 // 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. 1052 // FIXME: should we hook up scrollbar parts in the layout tree? crbug.com/48 4263.
1054 void invalidateDisplayItemClientForNonCompositingDescendantsOf(const LayoutO bject&) const; 1053 void invalidateDisplayItemClientForNonCompositingDescendantsOf(const LayoutO bject&) const;
1055 1054
1055 // Called before anonymousChild.setStyle(). Override to set custom styles fo r the child.
1056 virtual void updateAnonymousChildStyle(const LayoutObject& anonymousChild, C omputedStyle& style) const { }
1057
1056 protected: 1058 protected:
1057 enum LayoutObjectType { 1059 enum LayoutObjectType {
1058 LayoutObjectBr, 1060 LayoutObjectBr,
1059 LayoutObjectCanvas, 1061 LayoutObjectCanvas,
1060 LayoutObjectFieldset, 1062 LayoutObjectFieldset,
1061 LayoutObjectCounter, 1063 LayoutObjectCounter,
1062 LayoutObjectDetailsMarker, 1064 LayoutObjectDetailsMarker,
1063 LayoutObjectEmbeddedObject, 1065 LayoutObjectEmbeddedObject,
1064 LayoutObjectFileUploadControl, 1066 LayoutObjectFileUploadControl,
1065 LayoutObjectFrame, 1067 LayoutObjectFrame,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1126 1128
1127 inline bool layerCreationAllowedForSubtree() const; 1129 inline bool layerCreationAllowedForSubtree() const;
1128 1130
1129 // Overrides should call the superclass at the end. m_style will be 0 the fi rst time 1131 // Overrides should call the superclass at the end. m_style will be 0 the fi rst time
1130 // this function will be called. 1132 // this function will be called.
1131 virtual void styleWillChange(StyleDifference, const ComputedStyle& newStyle) ; 1133 virtual void styleWillChange(StyleDifference, const ComputedStyle& newStyle) ;
1132 // Overrides should call the superclass at the start. |oldStyle| will be 0 t he first 1134 // Overrides should call the superclass at the start. |oldStyle| will be 0 t he first
1133 // time this function is called. 1135 // time this function is called.
1134 virtual void styleDidChange(StyleDifference, const ComputedStyle* oldStyle); 1136 virtual void styleDidChange(StyleDifference, const ComputedStyle* oldStyle);
1135 void propagateStyleToAnonymousChildren(bool blockChildrenOnly = false); 1137 void propagateStyleToAnonymousChildren(bool blockChildrenOnly = false);
1136 virtual void updateAnonymousChildStyle(const LayoutObject& child, ComputedSt yle& style) const { }
1137 1138
1138 protected: 1139 protected:
1139 virtual void willBeDestroyed(); 1140 virtual void willBeDestroyed();
1140 1141
1141 virtual void insertedIntoTree(); 1142 virtual void insertedIntoTree();
1142 virtual void willBeRemovedFromTree(); 1143 virtual void willBeRemovedFromTree();
1143 1144
1144 void setDocumentForAnonymous(Document* document) { ASSERT(isAnonymous()); m_ node = document; } 1145 void setDocumentForAnonymous(Document* document) { ASSERT(isAnonymous()); m_ node = document; }
1145 1146
1146 // Add hit-test rects for the layout tree rooted at this node to the provide d collection on a 1147 // 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); 1177 virtual PaintInvalidationReason invalidatePaintIfNeeded(PaintInvalidationSta te&, const LayoutBoxModelObject& paintInvalidationContainer);
1177 1178
1178 // When this object is invalidated for paint, this method is called to inval idate any DisplayItemClients 1179 // 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., 1180 // 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 1181 // not including children which will be invalidated normally during invalida teTreeIfNeeded() and
1181 // parts which are invalidated separately (e.g. scrollbars). 1182 // parts which are invalidated separately (e.g. scrollbars).
1182 virtual void invalidateDisplayItemClients(const LayoutBoxModelObject& paintI nvalidationContainer) const; 1183 virtual void invalidateDisplayItemClients(const LayoutBoxModelObject& paintI nvalidationContainer) const;
1183 1184
1184 void setIsSlowRepaintObject(bool); 1185 void setIsSlowRepaintObject(bool);
1185 1186
1187 void clearSelfNeedsOverflowRecalcAfterStyleChange() { m_bitfields.setSelfNee dsOverflowRecalcAfterStyleChange(false); }
1188 void clearChildNeedsOverflowRecalcAfterStyleChange() { m_bitfields.setChildN eedsOverflowRecalcAfterStyleChange(false); }
1189 void setShouldInvalidateOverflowForPaint() { m_bitfields.setShouldInvalidate OverflowForPaint(true); }
1190 void setEverHadLayout() { m_bitfields.setEverHadLayout(true); }
1191
1192 // Remove this object and all descendants from the containing LayoutFlowThre ad.
1193 void removeFromLayoutFlowThread();
1194
1186 private: 1195 private:
1187 const LayoutRect& previousPaintInvalidationRect() const { return m_previousP aintInvalidationRect; } 1196 const LayoutRect& previousPaintInvalidationRect() const { return m_previousP aintInvalidationRect; }
1188 1197
1189 // Adjusts a paint invalidation rect in the space of |m_previousPaintInvalid ationRect| and |m_previousPositionFromPaintInvalidationBacking| 1198 // Adjusts a paint invalidation rect in the space of |m_previousPaintInvalid ationRect| and |m_previousPositionFromPaintInvalidationBacking|
1190 // to be in the space of the |paintInvalidationContainer|, 1199 // to be in the space of the |paintInvalidationContainer|,
1191 // if needed. They can be different only if |paintInvalidationContainer| is a composited scroller. 1200 // if needed. They can be different only if |paintInvalidationContainer| is a composited scroller.
1192 void adjustInvalidationRectForCompositedScrolling(LayoutRect&, const LayoutB oxModelObject& paintInvalidationContainer) const; 1201 void adjustInvalidationRectForCompositedScrolling(LayoutRect&, const LayoutB oxModelObject& paintInvalidationContainer) const;
1193 1202
1194 void clearLayoutRootIfNeeded() const; 1203 void clearLayoutRootIfNeeded() const;
1195 1204
(...skipping 19 matching lines...) Expand all
1215 inline void invalidateContainerPreferredLogicalWidths(); 1224 inline void invalidateContainerPreferredLogicalWidths();
1216 1225
1217 void invalidatePaintIncludingNonCompositingDescendantsInternal(const LayoutB oxModelObject& repaintContainer); 1226 void invalidatePaintIncludingNonCompositingDescendantsInternal(const LayoutB oxModelObject& repaintContainer);
1218 1227
1219 LayoutRect previousSelectionRectForPaintInvalidation() const; 1228 LayoutRect previousSelectionRectForPaintInvalidation() const;
1220 void setPreviousSelectionRectForPaintInvalidation(const LayoutRect&); 1229 void setPreviousSelectionRectForPaintInvalidation(const LayoutRect&);
1221 1230
1222 const LayoutBoxModelObject* enclosingCompositedContainer() const; 1231 const LayoutBoxModelObject* enclosingCompositedContainer() const;
1223 1232
1224 LayoutFlowThread* locateFlowThreadContainingBlock() const; 1233 LayoutFlowThread* locateFlowThreadContainingBlock() const;
1225 void removeFromLayoutFlowThread();
1226 void removeFromLayoutFlowThreadRecursive(LayoutFlowThread*); 1234 void removeFromLayoutFlowThreadRecursive(LayoutFlowThread*);
1227 1235
1228 ComputedStyle* cachedFirstLineStyle() const; 1236 ComputedStyle* cachedFirstLineStyle() const;
1229 StyleDifference adjustStyleDifference(StyleDifference) const; 1237 StyleDifference adjustStyleDifference(StyleDifference) const;
1230 1238
1231 Color selectionColor(int colorProperty, const GlobalPaintFlags) const; 1239 Color selectionColor(int colorProperty, const GlobalPaintFlags) const;
1232 1240
1233 void removeShapeImageClient(ShapeValue*); 1241 void removeShapeImageClient(ShapeValue*);
1234 1242
1235 #if ENABLE(ASSERT) 1243 #if ENABLE(ASSERT)
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1403 #undef ADD_BOOLEAN_BITFIELD 1411 #undef ADD_BOOLEAN_BITFIELD
1404 1412
1405 LayoutObjectBitfields m_bitfields; 1413 LayoutObjectBitfields m_bitfields;
1406 1414
1407 void setSelfNeedsLayout(bool b) { m_bitfields.setSelfNeedsLayout(b); } 1415 void setSelfNeedsLayout(bool b) { m_bitfields.setSelfNeedsLayout(b); }
1408 void setNeedsPositionedMovementLayout(bool b) { m_bitfields.setNeedsPosition edMovementLayout(b); } 1416 void setNeedsPositionedMovementLayout(bool b) { m_bitfields.setNeedsPosition edMovementLayout(b); }
1409 void setNormalChildNeedsLayout(bool b) { m_bitfields.setNormalChildNeedsLayo ut(b); } 1417 void setNormalChildNeedsLayout(bool b) { m_bitfields.setNormalChildNeedsLayo ut(b); }
1410 void setPosChildNeedsLayout(bool b) { m_bitfields.setPosChildNeedsLayout(b); } 1418 void setPosChildNeedsLayout(bool b) { m_bitfields.setPosChildNeedsLayout(b); }
1411 void setNeedsSimplifiedNormalFlowLayout(bool b) { m_bitfields.setNeedsSimpli fiedNormalFlowLayout(b); } 1419 void setNeedsSimplifiedNormalFlowLayout(bool b) { m_bitfields.setNeedsSimpli fiedNormalFlowLayout(b); }
1412 void setIsDragging(bool b) { m_bitfields.setIsDragging(b); } 1420 void setIsDragging(bool b) { m_bitfields.setIsDragging(b); }
1413 void setEverHadLayout(bool b) { m_bitfields.setEverHadLayout(b); } 1421 void clearShouldInvalidateOverflowForPaint() { m_bitfields.setShouldInvalida teOverflowForPaint(false); }
1414 void setShouldInvalidateOverflowForPaint(bool b) { m_bitfields.setShouldInva lidateOverflowForPaint(b); } 1422 void setSelfNeedsOverflowRecalcAfterStyleChange() { m_bitfields.setSelfNeeds OverflowRecalcAfterStyleChange(true); }
1415 void setSelfNeedsOverflowRecalcAfterStyleChange(bool b) { m_bitfields.setSel fNeedsOverflowRecalcAfterStyleChange(b); } 1423 void setChildNeedsOverflowRecalcAfterStyleChange() { m_bitfields.setChildNee dsOverflowRecalcAfterStyleChange(true); }
1416 void setChildNeedsOverflowRecalcAfterStyleChange(bool b) { m_bitfields.setCh ildNeedsOverflowRecalcAfterStyleChange(b); }
1417 1424
1418 private: 1425 private:
1419 // Store state between styleWillChange and styleDidChange 1426 // Store state between styleWillChange and styleDidChange
1420 static bool s_affectsParentBlock; 1427 static bool s_affectsParentBlock;
1421 1428
1422 // This stores the paint invalidation rect from the previous frame. This rec t does *not* account for composited scrolling. See 1429 // This stores the paint invalidation rect from the previous frame. This rec t does *not* account for composited scrolling. See
1423 // adjustInvalidationRectForCompositedScrolling(). 1430 // adjustInvalidationRectForCompositedScrolling().
1424 LayoutRect m_previousPaintInvalidationRect; 1431 LayoutRect m_previousPaintInvalidationRect;
1425 1432
1426 // This stores the position in the paint invalidation backing's coordinate. 1433 // This stores the position in the paint invalidation backing's coordinate.
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1505 1512
1506 inline void LayoutObject::setNeedsLayoutAndFullPaintInvalidation(LayoutInvalidat ionReasonForTracing reason, MarkingBehavior markParents, SubtreeLayoutScope* lay outer) 1513 inline void LayoutObject::setNeedsLayoutAndFullPaintInvalidation(LayoutInvalidat ionReasonForTracing reason, MarkingBehavior markParents, SubtreeLayoutScope* lay outer)
1507 { 1514 {
1508 setNeedsLayout(reason, markParents, layouter); 1515 setNeedsLayout(reason, markParents, layouter);
1509 setShouldDoFullPaintInvalidation(); 1516 setShouldDoFullPaintInvalidation();
1510 } 1517 }
1511 1518
1512 inline void LayoutObject::clearNeedsLayout() 1519 inline void LayoutObject::clearNeedsLayout()
1513 { 1520 {
1514 // Set flags for later stages/cycles. 1521 // Set flags for later stages/cycles.
1515 setEverHadLayout(true); 1522 setEverHadLayout();
1516 setMayNeedPaintInvalidation(); 1523 setMayNeedPaintInvalidation();
1517 m_bitfields.setNeededLayoutBecauseOfChildren(needsLayoutBecauseOfChildren()) ; 1524 m_bitfields.setNeededLayoutBecauseOfChildren(needsLayoutBecauseOfChildren()) ;
1518 1525
1519 // Clear needsLayout flags. 1526 // Clear needsLayout flags.
1520 setSelfNeedsLayout(false); 1527 setSelfNeedsLayout(false);
1521 setPosChildNeedsLayout(false); 1528 setPosChildNeedsLayout(false);
1522 setNeedsSimplifiedNormalFlowLayout(false); 1529 setNeedsSimplifiedNormalFlowLayout(false);
1523 setNormalChildNeedsLayout(false); 1530 setNormalChildNeedsLayout(false);
1524 setNeedsPositionedMovementLayout(false); 1531 setNeedsPositionedMovementLayout(false);
1525 setAncestorLineBoxDirty(false); 1532 setAncestorLineBoxDirty(false);
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1656 void showTree(const blink::LayoutObject*); 1663 void showTree(const blink::LayoutObject*);
1657 void showLineTree(const blink::LayoutObject*); 1664 void showLineTree(const blink::LayoutObject*);
1658 void showLayoutTree(const blink::LayoutObject* object1); 1665 void showLayoutTree(const blink::LayoutObject* object1);
1659 // We don't make object2 an optional parameter so that showLayoutTree 1666 // We don't make object2 an optional parameter so that showLayoutTree
1660 // can be called from gdb easily. 1667 // can be called from gdb easily.
1661 void showLayoutTree(const blink::LayoutObject* object1, const blink::LayoutObjec t* object2); 1668 void showLayoutTree(const blink::LayoutObject* object1, const blink::LayoutObjec t* object2);
1662 1669
1663 #endif 1670 #endif
1664 1671
1665 #endif // LayoutObject_h 1672 #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