OLD | NEW |
---|---|
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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
133 // | 133 // |
134 // The purpose of the layout tree is to do layout (aka reflow) and store its res ults for painting and | 134 // The purpose of the layout tree is to do layout (aka reflow) and store its res ults for painting and |
135 // hit-testing. | 135 // hit-testing. |
136 // Layout is the process of sizing and positioning Nodes on the page. In Blink, layouts always start | 136 // Layout is the process of sizing and positioning Nodes on the page. In Blink, layouts always start |
137 // from a relayout boundary (see objectIsRelayoutBoundary in LayoutObject.cpp). As such, we need to mark | 137 // from a relayout boundary (see objectIsRelayoutBoundary in LayoutObject.cpp). As such, we need to mark |
138 // the ancestors all the way to the enclosing relayout boundary in order to do a correct layout. | 138 // the ancestors all the way to the enclosing relayout boundary in order to do a correct layout. |
139 // | 139 // |
140 // Due to the high cost of layout, a lot of effort is done to avoid doing full l ayouts of nodes. | 140 // Due to the high cost of layout, a lot of effort is done to avoid doing full l ayouts of nodes. |
141 // This is why there are several types of layout available to bypass the complex operations. See the | 141 // This is why there are several types of layout available to bypass the complex operations. See the |
142 // comments on the layout booleans in LayoutObjectBitfields below about the diff erent layouts. | 142 // comments on the layout booleans in LayoutObjectBitfields below about the diff erent layouts. |
143 // | |
144 // To save memory, especially for the common child class LayoutText, LayoutObjec t doesn't provide | |
145 // storage for children. Descendant classes that do allow children have to have a LayoutObjectChildList | |
146 // member that stores the actual children and override virtualChildren(). | |
143 class CORE_EXPORT LayoutObject : public ImageResourceClient { | 147 class CORE_EXPORT LayoutObject : public ImageResourceClient { |
144 friend class LayoutObjectChildList; | 148 friend class LayoutObjectChildList; |
145 WTF_MAKE_NONCOPYABLE(LayoutObject); | 149 WTF_MAKE_NONCOPYABLE(LayoutObject); |
146 public: | 150 public: |
147 // Anonymous objects should pass the document as their node, and they will t hen automatically be | 151 // Anonymous objects should pass the document as their node, and they will t hen automatically be |
148 // marked as anonymous in the constructor. | 152 // marked as anonymous in the constructor. |
149 explicit LayoutObject(Node*); | 153 explicit LayoutObject(Node*); |
150 ~LayoutObject() override; | 154 ~LayoutObject() override; |
151 | 155 |
152 // Returns the name of the layout object. | 156 // Returns the name of the layout object. |
(...skipping 18 matching lines...) Expand all Loading... | |
171 return children->firstChild(); | 175 return children->firstChild(); |
172 return nullptr; | 176 return nullptr; |
173 } | 177 } |
174 LayoutObject* slowLastChild() const | 178 LayoutObject* slowLastChild() const |
175 { | 179 { |
176 if (const LayoutObjectChildList* children = virtualChildren()) | 180 if (const LayoutObjectChildList* children = virtualChildren()) |
177 return children->lastChild(); | 181 return children->lastChild(); |
178 return nullptr; | 182 return nullptr; |
179 } | 183 } |
180 | 184 |
185 // See comment in the class description as to why there is no child. | |
181 virtual LayoutObjectChildList* virtualChildren() { return nullptr; } | 186 virtual LayoutObjectChildList* virtualChildren() { return nullptr; } |
182 virtual const LayoutObjectChildList* virtualChildren() const { return nullpt r; } | 187 virtual const LayoutObjectChildList* virtualChildren() const { return nullpt r; } |
183 | 188 |
184 LayoutObject* nextInPreOrder() const; | 189 LayoutObject* nextInPreOrder() const; |
185 LayoutObject* nextInPreOrder(const LayoutObject* stayWithin) const; | 190 LayoutObject* nextInPreOrder(const LayoutObject* stayWithin) const; |
186 LayoutObject* nextInPreOrderAfterChildren() const; | 191 LayoutObject* nextInPreOrderAfterChildren() const; |
187 LayoutObject* nextInPreOrderAfterChildren(const LayoutObject* stayWithin) co nst; | 192 LayoutObject* nextInPreOrderAfterChildren(const LayoutObject* stayWithin) co nst; |
188 LayoutObject* previousInPreOrder() const; | 193 LayoutObject* previousInPreOrder() const; |
189 LayoutObject* previousInPreOrder(const LayoutObject* stayWithin) const; | 194 LayoutObject* previousInPreOrder(const LayoutObject* stayWithin) const; |
190 LayoutObject* childAt(unsigned) const; | 195 LayoutObject* childAt(unsigned) const; |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
327 void showLayoutTreeForThis() const; | 332 void showLayoutTreeForThis() const; |
328 void showLineTreeForThis() const; | 333 void showLineTreeForThis() const; |
329 | 334 |
330 void showLayoutObject() const; | 335 void showLayoutObject() const; |
331 // We don't make printedCharacters an optional parameter so that | 336 // We don't make printedCharacters an optional parameter so that |
332 // showLayoutObject can be called from gdb easily. | 337 // showLayoutObject can be called from gdb easily. |
333 void showLayoutObject(int printedCharacters) const; | 338 void showLayoutObject(int printedCharacters) const; |
334 void showLayoutTreeAndMark(const LayoutObject* markedObject1 = nullptr, cons t char* markedLabel1 = nullptr, const LayoutObject* markedObject2 = nullptr, con st char* markedLabel2 = nullptr, int depth = 0) const; | 339 void showLayoutTreeAndMark(const LayoutObject* markedObject1 = nullptr, cons t char* markedLabel1 = nullptr, const LayoutObject* markedObject2 = nullptr, con st char* markedLabel2 = nullptr, int depth = 0) const; |
335 #endif | 340 #endif |
336 | 341 |
342 // This function is used to create the appropriate LayoutObject based | |
343 // on the style, in particular 'display' and 'content'. | |
344 // "display: none" is the only time this function will return nullptr. | |
345 // | |
346 // For renderer creation, the inline-* values create the same renderer | |
347 // as the non-inline version. The difference is that inline-* sets | |
348 // m_isInline below. This means that "display: inline-table" creates | |
mstensho (USE GERRIT)
2015/08/31 19:48:07
"below", as in "during initialization"?
Julien - ping for review
2015/08/31 22:38:53
"below" as in ↓ (unicode FTW!)
Changed anyway as
mstensho (USE GERRIT)
2015/09/01 07:56:23
☑
| |
349 // a LayoutTable, like "display: table". | |
350 // | |
351 // Ideally every Element::createLayoutObject would call this function to | |
mstensho (USE GERRIT)
2015/08/31 19:48:07
I either don't understand or don't agree.
Isn't i
Julien - ping for review
2015/08/31 22:38:53
No Presto code open showroom please :)
We have a
mstensho (USE GERRIT)
2015/09/01 07:56:23
At the same time, those people should be thankful
Julien - ping for review
2015/09/01 16:18:29
Actually that's what I am advocating. Currently we
mstensho (USE GERRIT)
2015/09/01 18:15:28
Okay, I cannot think of a lot else to extract, but
| |
352 // respond to 'display' but there are deep rooted assumptions about | |
353 // which LayoutObject is created on a fair number of Elements. This | |
354 // function also doesn't handle the default association between a tag | |
355 // and its renderer (e.g. <iframe> creates a LayoutIFrame even if the | |
356 // initial 'display' value is inline). | |
337 static LayoutObject* createObject(Element*, const ComputedStyle&); | 357 static LayoutObject* createObject(Element*, const ComputedStyle&); |
338 | 358 |
339 // LayoutObjects are allocated out of the rendering partition. | 359 // LayoutObjects are allocated out of the rendering partition. |
340 void* operator new(size_t); | 360 void* operator new(size_t); |
341 void operator delete(void*); | 361 void operator delete(void*); |
342 | 362 |
343 public: | 363 public: |
344 bool isPseudoElement() const { return node() && node()->isPseudoElement(); } | 364 bool isPseudoElement() const { return node() && node()->isPseudoElement(); } |
345 | 365 |
346 virtual bool isBoxModelObject() const { return false; } | 366 virtual bool isBoxModelObject() const { return false; } |
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1162 | 1182 |
1163 // Overrides should call the superclass at the end. m_style will be 0 the fi rst time | 1183 // Overrides should call the superclass at the end. m_style will be 0 the fi rst time |
1164 // this function will be called. | 1184 // this function will be called. |
1165 virtual void styleWillChange(StyleDifference, const ComputedStyle& newStyle) ; | 1185 virtual void styleWillChange(StyleDifference, const ComputedStyle& newStyle) ; |
1166 // Overrides should call the superclass at the start. |oldStyle| will be 0 t he first | 1186 // Overrides should call the superclass at the start. |oldStyle| will be 0 t he first |
1167 // time this function is called. | 1187 // time this function is called. |
1168 virtual void styleDidChange(StyleDifference, const ComputedStyle* oldStyle); | 1188 virtual void styleDidChange(StyleDifference, const ComputedStyle* oldStyle); |
1169 void propagateStyleToAnonymousChildren(bool blockChildrenOnly = false); | 1189 void propagateStyleToAnonymousChildren(bool blockChildrenOnly = false); |
1170 | 1190 |
1171 protected: | 1191 protected: |
1192 // This function is called before calling the destructor so that some clean- up | |
1193 // can happen regardless of whether they call a virtual function or not. As a | |
1194 // rule of thumb, this function should be preferred to the destructor. See | |
1195 // destroy() that is the one calling willBeDestroyed(). | |
1196 // | |
1197 // There are 2 types of destructions: regular destructions and tree tear-dow n. | |
1198 // Regular destructions happen when the renderer is not needed anymore (e.g. | |
1199 // 'display' changed or the DOM Node was removed). | |
1200 // Tree tear-down is when the whole tree destroyed during navigation. It is | |
1201 // handled in the code by checking if documentBeingDestroyed() returns 'true '. | |
1202 // In this case, the code skips some unneeded expensive operations as we kno w | |
1203 // the tree is not reused (e.g. avoid clearing the containing block's line b ox). | |
1172 virtual void willBeDestroyed(); | 1204 virtual void willBeDestroyed(); |
1173 | 1205 |
1174 virtual void insertedIntoTree(); | 1206 virtual void insertedIntoTree(); |
1175 virtual void willBeRemovedFromTree(); | 1207 virtual void willBeRemovedFromTree(); |
1176 | 1208 |
1177 void setDocumentForAnonymous(Document* document) { ASSERT(isAnonymous()); m_ node = document; } | 1209 void setDocumentForAnonymous(Document* document) { ASSERT(isAnonymous()); m_ node = document; } |
1178 | 1210 |
1179 // Add hit-test rects for the layout tree rooted at this node to the provide d collection on a | 1211 // Add hit-test rects for the layout tree rooted at this node to the provide d collection on a |
1180 // per-Layer basis. | 1212 // per-Layer basis. |
1181 // currentLayer must be the enclosing layer, and layerOffset is the current offset within | 1213 // currentLayer must be the enclosing layer, and layerOffset is the current offset within |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1423 ADD_BOOLEAN_BITFIELD(shouldInvalidateOverflowForPaint, ShouldInvalidateO verflowForPaint); // TODO(wangxianzhu): Remove for slimming paint v2. | 1455 ADD_BOOLEAN_BITFIELD(shouldInvalidateOverflowForPaint, ShouldInvalidateO verflowForPaint); // TODO(wangxianzhu): Remove for slimming paint v2. |
1424 ADD_BOOLEAN_BITFIELD(childShouldCheckForPaintInvalidation, ChildShouldCh eckForPaintInvalidation); | 1456 ADD_BOOLEAN_BITFIELD(childShouldCheckForPaintInvalidation, ChildShouldCh eckForPaintInvalidation); |
1425 ADD_BOOLEAN_BITFIELD(mayNeedPaintInvalidation, MayNeedPaintInvalidation) ; | 1457 ADD_BOOLEAN_BITFIELD(mayNeedPaintInvalidation, MayNeedPaintInvalidation) ; |
1426 ADD_BOOLEAN_BITFIELD(shouldInvalidateSelection, ShouldInvalidateSelectio n); // TODO(wangxianzhu): Remove for slimming paint v2. | 1458 ADD_BOOLEAN_BITFIELD(shouldInvalidateSelection, ShouldInvalidateSelectio n); // TODO(wangxianzhu): Remove for slimming paint v2. |
1427 ADD_BOOLEAN_BITFIELD(neededLayoutBecauseOfChildren, NeededLayoutBecauseO fChildren); // TODO(wangxianzhu): Remove for slimming paint v2. | 1459 ADD_BOOLEAN_BITFIELD(neededLayoutBecauseOfChildren, NeededLayoutBecauseO fChildren); // TODO(wangxianzhu): Remove for slimming paint v2. |
1428 ADD_BOOLEAN_BITFIELD(floating, Floating); | 1460 ADD_BOOLEAN_BITFIELD(floating, Floating); |
1429 | 1461 |
1430 ADD_BOOLEAN_BITFIELD(isAnonymous, IsAnonymous); | 1462 ADD_BOOLEAN_BITFIELD(isAnonymous, IsAnonymous); |
1431 ADD_BOOLEAN_BITFIELD(isText, IsText); | 1463 ADD_BOOLEAN_BITFIELD(isText, IsText); |
1432 ADD_BOOLEAN_BITFIELD(isBox, IsBox); | 1464 ADD_BOOLEAN_BITFIELD(isBox, IsBox); |
1465 | |
1466 // This boolean represents whether the LayoutObject is laid out as part | |
1467 // of the current line (inline) or generate a new formatting context | |
mstensho (USE GERRIT)
2015/08/31 19:48:07
Doesn't necessarily generate a new formatting cont
Julien - ping for review
2015/08/31 22:38:53
Fair point, changed to some better CSS lingo:
//
mstensho (USE GERRIT)
2015/09/01 07:56:23
Nice!
| |
1468 // (e.g. block, grid, flex ...). | |
1433 ADD_BOOLEAN_BITFIELD(isInline, IsInline); | 1469 ADD_BOOLEAN_BITFIELD(isInline, IsInline); |
1470 | |
1434 ADD_BOOLEAN_BITFIELD(isReplaced, IsReplaced); | 1471 ADD_BOOLEAN_BITFIELD(isReplaced, IsReplaced); |
1435 ADD_BOOLEAN_BITFIELD(horizontalWritingMode, HorizontalWritingMode); | 1472 ADD_BOOLEAN_BITFIELD(horizontalWritingMode, HorizontalWritingMode); |
1436 ADD_BOOLEAN_BITFIELD(isDragging, IsDragging); | 1473 ADD_BOOLEAN_BITFIELD(isDragging, IsDragging); |
1437 | 1474 |
1438 ADD_BOOLEAN_BITFIELD(hasLayer, HasLayer); | 1475 ADD_BOOLEAN_BITFIELD(hasLayer, HasLayer); |
1439 ADD_BOOLEAN_BITFIELD(hasOverflowClip, HasOverflowClip); // Set in the ca se of overflow:auto/scroll/hidden | 1476 ADD_BOOLEAN_BITFIELD(hasOverflowClip, HasOverflowClip); // Set in the ca se of overflow:auto/scroll/hidden |
1440 ADD_BOOLEAN_BITFIELD(hasTransformRelatedProperty, HasTransformRelatedPro perty); | 1477 ADD_BOOLEAN_BITFIELD(hasTransformRelatedProperty, HasTransformRelatedPro perty); |
1441 ADD_BOOLEAN_BITFIELD(hasReflection, HasReflection); | 1478 ADD_BOOLEAN_BITFIELD(hasReflection, HasReflection); |
1442 | 1479 |
1443 ADD_BOOLEAN_BITFIELD(hasCounterNodeMap, HasCounterNodeMap); | 1480 ADD_BOOLEAN_BITFIELD(hasCounterNodeMap, HasCounterNodeMap); |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1753 void showTree(const blink::LayoutObject*); | 1790 void showTree(const blink::LayoutObject*); |
1754 void showLineTree(const blink::LayoutObject*); | 1791 void showLineTree(const blink::LayoutObject*); |
1755 void showLayoutTree(const blink::LayoutObject* object1); | 1792 void showLayoutTree(const blink::LayoutObject* object1); |
1756 // We don't make object2 an optional parameter so that showLayoutTree | 1793 // We don't make object2 an optional parameter so that showLayoutTree |
1757 // can be called from gdb easily. | 1794 // can be called from gdb easily. |
1758 void showLayoutTree(const blink::LayoutObject* object1, const blink::LayoutObjec t* object2); | 1795 void showLayoutTree(const blink::LayoutObject* object1, const blink::LayoutObjec t* object2); |
1759 | 1796 |
1760 #endif | 1797 #endif |
1761 | 1798 |
1762 #endif // LayoutObject_h | 1799 #endif // LayoutObject_h |
OLD | NEW |