OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2007 David Smith (catfish.man@gmail.com) | 4 * (C) 2007 David Smith (catfish.man@gmail.com) |
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All r ights reserved. | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All r ights reserved. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
46 typedef WTF::HashMap<const LayoutBlock*, OwnPtr<TrackedLayoutBoxListHashSet>> Tr ackedDescendantsMap; | 46 typedef WTF::HashMap<const LayoutBlock*, OwnPtr<TrackedLayoutBoxListHashSet>> Tr ackedDescendantsMap; |
47 typedef WTF::HashMap<const LayoutBox*, OwnPtr<HashSet<LayoutBlock*>>> TrackedCon tainerMap; | 47 typedef WTF::HashMap<const LayoutBox*, OwnPtr<HashSet<LayoutBlock*>>> TrackedCon tainerMap; |
48 typedef Vector<WordMeasurement, 64> WordMeasurements; | 48 typedef Vector<WordMeasurement, 64> WordMeasurements; |
49 | 49 |
50 enum ContainingBlockState { NewContainingBlock, SameContainingBlock }; | 50 enum ContainingBlockState { NewContainingBlock, SameContainingBlock }; |
51 | 51 |
52 typedef WTF::HashMap<LayoutBlock*, OwnPtr<ListHashSet<LayoutInline*>>> Continuat ionOutlineTableMap; | 52 typedef WTF::HashMap<LayoutBlock*, OwnPtr<ListHashSet<LayoutInline*>>> Continuat ionOutlineTableMap; |
53 | 53 |
54 ContinuationOutlineTableMap* continuationOutlineTable(); | 54 ContinuationOutlineTableMap* continuationOutlineTable(); |
55 | 55 |
56 // LayoutBlock is the class that is used by any LayoutObject | |
57 // that is a containing block. | |
58 // http://www.w3.org/TR/CSS2/visuren.html#containing-block | |
59 // See also LayoutObject::containingBlock() that is the function | |
60 // used to get the containing block of a LayoutObject. | |
61 // | |
62 // CSS is inconsistent and allows inline elements (LayoutInline) to be | |
mstensho (USE GERRIT)
2015/08/31 19:28:52
A just description of the madness. :)
| |
63 // containing blocks, even though they are not blocks. Our | |
64 // implementation is as confused with inlines. See e.g. | |
65 // LayoutObject::containingBlock() vs LayoutObject::container(). | |
66 // | |
67 // Containing blocks are a central concept for layout, in | |
68 // particular to the layout of out-of-flow positioned | |
69 // elements. They are used to determine the sizing as well | |
70 // as the positioning of the LayoutObjects. | |
71 // | |
72 // Out-of-flow positioned elements are laid out by their | |
73 // containing blocks so LayoutBlock keeps track of them | |
74 // through |gPositionedDescendantsMap| (see LayoutBlock.cpp). | |
75 // See LayoutBlock::layoutPositionedObjects() for the logic | |
76 // to lay them out. | |
77 // | |
78 // | |
79 // ***** HANDLING OUT-OF-FLOW POSITIONED OBJECTS ***** | |
80 // Care should be taken to handle out-of-flow positioned objects during | |
81 // certain tree walks (e.g. layout()). The rule is that anything that | |
82 // cares about containing blocks should skip the out-of-flow elements | |
83 // in the normal tree walk and do an optional follow-up pass for them | |
84 // using LayoutBlock::positionedObjects(). | |
85 // Not doing so will result in passing the wrong containing | |
86 // block as tree walks will always pass the parent as the | |
87 // containing block. | |
88 // | |
89 // Sample code of how to handle positioned objects in LayoutBlock: | |
90 // | |
91 // for (LayoutObject* child = firstChild(); child; child = child->nextSibling()) { | |
92 // if (child->isOutOfFlowPositioned()) | |
93 // continue; | |
94 // | |
95 // // Handle normal flow children. | |
96 // ... | |
97 // } | |
98 // for (LayoutObject positionedObject : positionedObjects()) { | |
99 // // Handle out-of-flow positioned objects. | |
100 // ... | |
101 // } | |
56 class CORE_EXPORT LayoutBlock : public LayoutBox { | 102 class CORE_EXPORT LayoutBlock : public LayoutBox { |
57 public: | 103 public: |
58 friend class LineLayoutState; | 104 friend class LineLayoutState; |
59 | 105 |
60 protected: | 106 protected: |
61 explicit LayoutBlock(ContainerNode*); | 107 explicit LayoutBlock(ContainerNode*); |
62 ~LayoutBlock() override; | 108 ~LayoutBlock() override; |
63 | 109 |
64 public: | 110 public: |
65 LayoutObject* firstChild() const { ASSERT(children() == virtualChildren()); return children()->firstChild(); } | 111 LayoutObject* firstChild() const { ASSERT(children() == virtualChildren()); return children()->firstChild(); } |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
428 // FIXME: This is temporary as we move code that accesses block flow | 474 // FIXME: This is temporary as we move code that accesses block flow |
429 // member variables out of LayoutBlock and into LayoutBlockFlow. | 475 // member variables out of LayoutBlock and into LayoutBlockFlow. |
430 friend class LayoutBlockFlow; | 476 friend class LayoutBlockFlow; |
431 }; | 477 }; |
432 | 478 |
433 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutBlock, isLayoutBlock()); | 479 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutBlock, isLayoutBlock()); |
434 | 480 |
435 } // namespace blink | 481 } // namespace blink |
436 | 482 |
437 #endif // LayoutBlock_h | 483 #endif // LayoutBlock_h |
OLD | NEW |