Chromium Code Reviews| 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 LayoutRect bounds; | 108 LayoutRect bounds; |
| 109 bool draggable; | 109 bool draggable; |
| 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 // LayoutObject is the base class for all layout tree objects. |
| 119 // | |
|
pdr.
2015/08/27 04:09:48
It may be useful to add a blurb about the layout t
Julien - ping for review
2015/08/27 18:56:55
Added:
// The root of the LayoutObject tree is th
| |
| 120 // LayoutObjects form a tree structure that is a close mapping of the DOM tree. | |
| 121 // Some LayoutObjects don't have an associated Node and are called "anonymous" ( see the constructor | |
|
skobes
2015/08/27 00:55:03
Also mention that some Nodes don't have an associa
Julien - ping for review
2015/08/27 18:56:54
Added:
// Also some Node don't have an associated
| |
| 122 // below). Anonymous LayoutObjects exists for several purposes but are usually r equired by CSS. A | |
| 123 // good example is anonymous table parts (http://www.w3.org/TR/CSS21/tables.html #anonymous-boxes). | |
| 124 // | |
| 125 // Because the SVG and CSS classes both inherit from this object, functions can belong to either | |
| 126 // realm and sometimes to both. | |
| 127 // | |
| 128 // The purpose of the layout tree is to do layout (aka reflow) and store its res ults for painting and | |
| 129 // hit-testing. | |
| 130 // Layout is the process of sizing and positioning Nodes on the page. In Blink, layouts always start | |
|
skobes
2015/08/27 00:55:03
Shouldn't that be "sizing and positioning LayoutOb
Julien - ping for review
2015/08/27 18:56:55
Conceptually either phrasing works and I don't fee
| |
| 131 // from a relayout boundary (see objectIsRelayoutBoundary in LayoutObject.cpp). As such, we need to mark | |
| 132 // the ancestors all the way to the enclosing relayout boundary in order to do a correct layout. | |
| 133 // | |
| 134 // Due to the hight cost of layout, a lot of effort is done to avoid doing full layouts of nodes. | |
|
skobes
2015/08/27 00:55:03
typo: "high cost"
Julien - ping for review
2015/08/27 18:56:55
Corrected.
| |
| 135 // This is why there are several types of layout available to bypass the complex operations. See the | |
| 136 // comments on the layout booleans in LayoutObjectBitfields below about the diff erent layouts. | |
| 119 class CORE_EXPORT LayoutObject : public ImageResourceClient { | 137 class CORE_EXPORT LayoutObject : public ImageResourceClient { |
| 120 friend class LayoutBlock; | 138 friend class LayoutBlock; |
| 121 friend class LayoutBlockFlow; | 139 friend class LayoutBlockFlow; |
| 122 friend class DeprecatedPaintLayerReflectionInfo; // For setParent | 140 friend class DeprecatedPaintLayerReflectionInfo; // For setParent |
| 123 friend class DeprecatedPaintLayerScrollableArea; // For setParent. | 141 friend class DeprecatedPaintLayerScrollableArea; // For setParent. |
| 124 friend class LayoutObjectChildList; | 142 friend class LayoutObjectChildList; |
| 125 WTF_MAKE_NONCOPYABLE(LayoutObject); | 143 WTF_MAKE_NONCOPYABLE(LayoutObject); |
| 126 public: | 144 public: |
| 127 // Anonymous objects should pass the document as their node, and they will t hen automatically be | 145 // Anonymous objects should pass the document as their node, and they will t hen automatically be |
| 128 // marked as anonymous in the constructor. | 146 // marked as anonymous in the constructor. |
| (...skipping 1139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1268 enum PositionedState { | 1286 enum PositionedState { |
| 1269 IsStaticallyPositioned = 0, | 1287 IsStaticallyPositioned = 0, |
| 1270 IsRelativelyPositioned = 1, | 1288 IsRelativelyPositioned = 1, |
| 1271 IsOutOfFlowPositioned = 2, | 1289 IsOutOfFlowPositioned = 2, |
| 1272 IsStickyPositioned = 3, | 1290 IsStickyPositioned = 3, |
| 1273 }; | 1291 }; |
| 1274 | 1292 |
| 1275 public: | 1293 public: |
| 1276 LayoutObjectBitfields(Node* node) | 1294 LayoutObjectBitfields(Node* node) |
| 1277 : m_selfNeedsLayout(false) | 1295 : m_selfNeedsLayout(false) |
| 1296 , m_needsPositionedMovementLayout(false) | |
| 1297 , m_normalChildNeedsLayout(false) | |
| 1298 , m_posChildNeedsLayout(false) | |
| 1299 , m_needsSimplifiedNormalFlowLayout(false) | |
| 1300 , m_preferredLogicalWidthsDirty(false) | |
| 1278 , m_shouldInvalidateOverflowForPaint(false) | 1301 , m_shouldInvalidateOverflowForPaint(false) |
| 1279 , m_childShouldCheckForPaintInvalidation(false) | 1302 , m_childShouldCheckForPaintInvalidation(false) |
| 1280 , m_mayNeedPaintInvalidation(false) | 1303 , m_mayNeedPaintInvalidation(false) |
| 1281 , m_shouldInvalidateSelection(false) | 1304 , m_shouldInvalidateSelection(false) |
| 1282 , m_neededLayoutBecauseOfChildren(false) | 1305 , m_neededLayoutBecauseOfChildren(false) |
| 1283 , m_needsPositionedMovementLayout(false) | |
| 1284 , m_normalChildNeedsLayout(false) | |
| 1285 , m_posChildNeedsLayout(false) | |
| 1286 , m_needsSimplifiedNormalFlowLayout(false) | |
| 1287 , m_preferredLogicalWidthsDirty(false) | |
| 1288 , m_floating(false) | 1306 , m_floating(false) |
| 1289 , m_selfNeedsOverflowRecalcAfterStyleChange(false) | 1307 , m_selfNeedsOverflowRecalcAfterStyleChange(false) |
| 1290 , m_childNeedsOverflowRecalcAfterStyleChange(false) | 1308 , m_childNeedsOverflowRecalcAfterStyleChange(false) |
| 1291 , m_isAnonymous(!node) | 1309 , m_isAnonymous(!node) |
| 1292 , m_isText(false) | 1310 , m_isText(false) |
| 1293 , m_isBox(false) | 1311 , m_isBox(false) |
| 1294 , m_isInline(true) | 1312 , m_isInline(true) |
| 1295 , m_isReplaced(false) | 1313 , m_isReplaced(false) |
| 1296 , m_horizontalWritingMode(true) | 1314 , m_horizontalWritingMode(true) |
| 1297 , m_isDragging(false) | 1315 , m_isDragging(false) |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 1312 , m_lastBoxDecorationBackgroundObscured(false) | 1330 , m_lastBoxDecorationBackgroundObscured(false) |
| 1313 , m_isSlowRepaintObject(false) | 1331 , m_isSlowRepaintObject(false) |
| 1314 , m_positionedState(IsStaticallyPositioned) | 1332 , m_positionedState(IsStaticallyPositioned) |
| 1315 , m_selectionState(SelectionNone) | 1333 , m_selectionState(SelectionNone) |
| 1316 , m_boxDecorationBackgroundState(NoBoxDecorationBackground) | 1334 , m_boxDecorationBackgroundState(NoBoxDecorationBackground) |
| 1317 , m_fullPaintInvalidationReason(PaintInvalidationNone) | 1335 , m_fullPaintInvalidationReason(PaintInvalidationNone) |
| 1318 { | 1336 { |
| 1319 } | 1337 } |
| 1320 | 1338 |
| 1321 // 32 bits have been used in the first word, and 16 in the second. | 1339 // 32 bits have been used in the first word, and 16 in the second. |
| 1340 | |
| 1341 // Self needs layout means that this layout object is marked for a full layout. | |
| 1342 // This is the default layout but it is expensive as it recomputes every thing. | |
|
dsinclair
2015/08/27 14:09:24
It won't, necessarily, re-layout children if they
Julien - ping for review
2015/08/27 18:56:55
That's not correct. I added a comment to LayoutObj
| |
| 1343 // For CSS boxes, this includes the width (laying out the line boxes aga in), the margins | |
| 1344 // (due to block collapsing margins), the positions, the height and the potential overflow. | |
| 1322 ADD_BOOLEAN_BITFIELD(selfNeedsLayout, SelfNeedsLayout); | 1345 ADD_BOOLEAN_BITFIELD(selfNeedsLayout, SelfNeedsLayout); |
| 1346 | |
| 1347 // A positioned movement layout is a specialized type of layout used on positioned objects | |
| 1348 // that only visually moved. This layout is used when changing 'top'/'le ft' on a positioned | |
| 1349 // element or margins on an out-of-flow one. Because the following opera tions don't impact | |
| 1350 // the size of the object or sibling LayoutObjects, this layout is very lightweight. | |
| 1351 // | |
| 1352 // Positioned movement layout is implemented in LayoutBlock::simplifiedL ayout. | |
| 1353 ADD_BOOLEAN_BITFIELD(needsPositionedMovementLayout, NeedsPositionedMovem entLayout); | |
| 1354 | |
| 1355 // This boolean is set when a normal flow ('position' == static || relat ive) child requires | |
| 1356 // layout (but this object doesn't). Due to the nature of CSS, relaying out a child can cause | |
|
pdr.
2015/08/27 04:09:48
Nit: "relaying" was a little confusing to me.
May
Julien - ping for review
2015/08/27 18:56:54
Applied your suggestion.
| |
| 1357 // this object to resize (e.g. if 'height' is auto). | |
| 1358 ADD_BOOLEAN_BITFIELD(normalChildNeedsLayout, NormalChildNeedsLayout); | |
| 1359 | |
| 1360 // This boolean is set when an out-of-flow positioned ('position' == fix ed || absolute) child | |
| 1361 // requires layout (but this object doesn't). | |
| 1362 ADD_BOOLEAN_BITFIELD(posChildNeedsLayout, PosChildNeedsLayout); | |
| 1363 | |
| 1364 // Simplified normal flow layout only relayouts the normal flow children , ignoring the | |
| 1365 // out-of-flow descendants. | |
| 1366 // | |
| 1367 // The implementation of this layout is in Simplified LayoutBlock::simpl ifiedNormalFlowLayout. | |
|
dsinclair
2015/08/27 14:09:24
nit: Is that Simplified supposed to be there?
Julien - ping for review
2015/08/27 18:56:55
Hell no! Removed.
| |
| 1368 ADD_BOOLEAN_BITFIELD(needsSimplifiedNormalFlowLayout, NeedsSimplifiedNor malFlowLayout); | |
| 1369 | |
| 1370 // Some properties only have a visual impact and don't impact the actual layout position and | |
| 1371 // sizes of the object. An example of this is the 'transform' property, who doesn't modify the | |
| 1372 // layout but gets applied at paint time. | |
| 1373 // Setting this flag only recompute the overflow information. | |
|
wkorman
2015/08/27 05:02:30
recomputes
Julien - ping for review
2015/08/27 18:56:54
Done.
| |
| 1374 ADD_BOOLEAN_BITFIELD(selfNeedsOverflowRecalcAfterStyleChange, SelfNeedsO verflowRecalcAfterStyleChange); | |
| 1375 | |
| 1376 // This flag is set on the ancestor of a LayoutObject needing | |
| 1377 // selfNeedsOverflowRecalcAfterStyleChange. This is needed as a descenda nt overflow can | |
| 1378 // bleed into its containing block's so we have to recompute it in some case. | |
|
wkorman
2015/08/27 05:02:30
cases
Julien - ping for review
2015/08/27 18:56:55
Done.
| |
| 1379 ADD_BOOLEAN_BITFIELD(childNeedsOverflowRecalcAfterStyleChange, ChildNeed sOverflowRecalcAfterStyleChange); | |
| 1380 | |
| 1381 // The preferred logical widths are the intrinsic sizes of this element. | |
| 1382 // Intrinsic means that they depend purely on the content, not on the st yle | |
|
skobes
2015/08/27 00:55:03
This seems wrong, some styles certainly affect the
Julien - ping for review
2015/08/27 18:56:55
You're right that it's not accurate. Only referrin
| |
| 1383 // set on the elements. | |
| 1384 // | |
| 1385 // Blink stores them in LayoutBox (m_minPreferredLogicalWidth and | |
| 1386 // m_maxPreferredLogicalWidth). They are lazily computed during layout. | |
| 1387 // | |
| 1388 // Setting this boolean marks both widths for recomputation when | |
| 1389 // LayoutBox::minPreferredLogicalWidth() or maxPreferredLogicalWidth() i s called. | |
| 1390 ADD_BOOLEAN_BITFIELD(preferredLogicalWidthsDirty, PreferredLogicalWidths Dirty); | |
| 1391 | |
| 1323 ADD_BOOLEAN_BITFIELD(shouldInvalidateOverflowForPaint, ShouldInvalidateO verflowForPaint); // TODO(wangxianzhu): Remove for slimming paint v2. | 1392 ADD_BOOLEAN_BITFIELD(shouldInvalidateOverflowForPaint, ShouldInvalidateO verflowForPaint); // TODO(wangxianzhu): Remove for slimming paint v2. |
| 1324 ADD_BOOLEAN_BITFIELD(childShouldCheckForPaintInvalidation, ChildShouldCh eckForPaintInvalidation); | 1393 ADD_BOOLEAN_BITFIELD(childShouldCheckForPaintInvalidation, ChildShouldCh eckForPaintInvalidation); |
| 1325 ADD_BOOLEAN_BITFIELD(mayNeedPaintInvalidation, MayNeedPaintInvalidation) ; | 1394 ADD_BOOLEAN_BITFIELD(mayNeedPaintInvalidation, MayNeedPaintInvalidation) ; |
| 1326 ADD_BOOLEAN_BITFIELD(shouldInvalidateSelection, ShouldInvalidateSelectio n); // TODO(wangxianzhu): Remove for slimming paint v2. | 1395 ADD_BOOLEAN_BITFIELD(shouldInvalidateSelection, ShouldInvalidateSelectio n); // TODO(wangxianzhu): Remove for slimming paint v2. |
| 1327 ADD_BOOLEAN_BITFIELD(neededLayoutBecauseOfChildren, NeededLayoutBecauseO fChildren); // TODO(wangxianzhu): Remove for slimming paint v2. | 1396 ADD_BOOLEAN_BITFIELD(neededLayoutBecauseOfChildren, NeededLayoutBecauseO fChildren); // TODO(wangxianzhu): Remove for slimming paint v2. |
| 1328 ADD_BOOLEAN_BITFIELD(needsPositionedMovementLayout, NeedsPositionedMovem entLayout); | |
| 1329 ADD_BOOLEAN_BITFIELD(normalChildNeedsLayout, NormalChildNeedsLayout); | |
| 1330 ADD_BOOLEAN_BITFIELD(posChildNeedsLayout, PosChildNeedsLayout); | |
| 1331 ADD_BOOLEAN_BITFIELD(needsSimplifiedNormalFlowLayout, NeedsSimplifiedNor malFlowLayout); | |
| 1332 ADD_BOOLEAN_BITFIELD(preferredLogicalWidthsDirty, PreferredLogicalWidths Dirty); | |
| 1333 ADD_BOOLEAN_BITFIELD(floating, Floating); | 1397 ADD_BOOLEAN_BITFIELD(floating, Floating); |
| 1334 ADD_BOOLEAN_BITFIELD(selfNeedsOverflowRecalcAfterStyleChange, SelfNeedsO verflowRecalcAfterStyleChange); | |
| 1335 ADD_BOOLEAN_BITFIELD(childNeedsOverflowRecalcAfterStyleChange, ChildNeed sOverflowRecalcAfterStyleChange); | |
| 1336 | 1398 |
| 1337 ADD_BOOLEAN_BITFIELD(isAnonymous, IsAnonymous); | 1399 ADD_BOOLEAN_BITFIELD(isAnonymous, IsAnonymous); |
| 1338 ADD_BOOLEAN_BITFIELD(isText, IsText); | 1400 ADD_BOOLEAN_BITFIELD(isText, IsText); |
| 1339 ADD_BOOLEAN_BITFIELD(isBox, IsBox); | 1401 ADD_BOOLEAN_BITFIELD(isBox, IsBox); |
| 1340 ADD_BOOLEAN_BITFIELD(isInline, IsInline); | 1402 ADD_BOOLEAN_BITFIELD(isInline, IsInline); |
| 1341 ADD_BOOLEAN_BITFIELD(isReplaced, IsReplaced); | 1403 ADD_BOOLEAN_BITFIELD(isReplaced, IsReplaced); |
| 1342 ADD_BOOLEAN_BITFIELD(horizontalWritingMode, HorizontalWritingMode); | 1404 ADD_BOOLEAN_BITFIELD(horizontalWritingMode, HorizontalWritingMode); |
| 1343 ADD_BOOLEAN_BITFIELD(isDragging, IsDragging); | 1405 ADD_BOOLEAN_BITFIELD(isDragging, IsDragging); |
| 1344 | 1406 |
| 1345 ADD_BOOLEAN_BITFIELD(hasLayer, HasLayer); | 1407 ADD_BOOLEAN_BITFIELD(hasLayer, HasLayer); |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1656 void showTree(const blink::LayoutObject*); | 1718 void showTree(const blink::LayoutObject*); |
| 1657 void showLineTree(const blink::LayoutObject*); | 1719 void showLineTree(const blink::LayoutObject*); |
| 1658 void showLayoutTree(const blink::LayoutObject* object1); | 1720 void showLayoutTree(const blink::LayoutObject* object1); |
| 1659 // We don't make object2 an optional parameter so that showLayoutTree | 1721 // We don't make object2 an optional parameter so that showLayoutTree |
| 1660 // can be called from gdb easily. | 1722 // can be called from gdb easily. |
| 1661 void showLayoutTree(const blink::LayoutObject* object1, const blink::LayoutObjec t* object2); | 1723 void showLayoutTree(const blink::LayoutObject* object1, const blink::LayoutObjec t* object2); |
| 1662 | 1724 |
| 1663 #endif | 1725 #endif |
| 1664 | 1726 |
| 1665 #endif // LayoutObject_h | 1727 #endif // LayoutObject_h |
| OLD | NEW |