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

Side by Side Diff: Source/core/layout/LayoutBlock.h

Issue 1304953005: Add some class documentation to LayoutBlock (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebaselined change after outlinemap removal. 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 | « no previous file | Source/core/layout/LayoutBlock.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) 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 class LayoutInline; 42 class LayoutInline;
43 class WordMeasurement; 43 class WordMeasurement;
44 44
45 typedef WTF::ListHashSet<LayoutBox*, 16> TrackedLayoutBoxListHashSet; 45 typedef WTF::ListHashSet<LayoutBox*, 16> TrackedLayoutBoxListHashSet;
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 // LayoutBlock is the class that is used by any LayoutObject
53 // that is a containing block.
54 // http://www.w3.org/TR/CSS2/visuren.html#containing-block
55 // See also LayoutObject::containingBlock() that is the function
56 // used to get the containing block of a LayoutObject.
57 //
58 // CSS is inconsistent and allows inline elements (LayoutInline) to be
59 // containing blocks, even though they are not blocks. Our
60 // implementation is as confused with inlines. See e.g.
61 // LayoutObject::containingBlock() vs LayoutObject::container().
62 //
63 // Containing blocks are a central concept for layout, in
64 // particular to the layout of out-of-flow positioned
65 // elements. They are used to determine the sizing as well
66 // as the positioning of the LayoutObjects.
67 //
68 // Out-of-flow positioned elements are laid out by their
69 // containing blocks so LayoutBlock keeps track of them
70 // through |gPositionedDescendantsMap| (see LayoutBlock.cpp).
71 // See LayoutBlock::layoutPositionedObjects() for the logic
72 // to lay them out.
73 //
74 //
75 // ***** HANDLING OUT-OF-FLOW POSITIONED OBJECTS *****
76 // Care should be taken to handle out-of-flow positioned objects during
77 // certain tree walks (e.g. layout()). The rule is that anything that
78 // cares about containing blocks should skip the out-of-flow elements
79 // in the normal tree walk and do an optional follow-up pass for them
80 // using LayoutBlock::positionedObjects().
81 // Not doing so will result in passing the wrong containing
82 // block as tree walks will always pass the parent as the
83 // containing block.
84 //
85 // Sample code of how to handle positioned objects in LayoutBlock:
86 //
87 // for (LayoutObject* child = firstChild(); child; child = child->nextSibling()) {
88 // if (child->isOutOfFlowPositioned())
89 // continue;
90 //
91 // // Handle normal flow children.
92 // ...
93 // }
94 // for (LayoutObject positionedObject : positionedObjects()) {
95 // // Handle out-of-flow positioned objects.
96 // ...
97 // }
52 class CORE_EXPORT LayoutBlock : public LayoutBox { 98 class CORE_EXPORT LayoutBlock : public LayoutBox {
53 public: 99 public:
54 friend class LineLayoutState; 100 friend class LineLayoutState;
55 101
56 protected: 102 protected:
57 explicit LayoutBlock(ContainerNode*); 103 explicit LayoutBlock(ContainerNode*);
58 ~LayoutBlock() override; 104 ~LayoutBlock() override;
59 105
60 public: 106 public:
61 LayoutObject* firstChild() const { ASSERT(children() == virtualChildren()); return children()->firstChild(); } 107 LayoutObject* firstChild() const { ASSERT(children() == virtualChildren()); return children()->firstChild(); }
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 // FIXME: This is temporary as we move code that accesses block flow 467 // FIXME: This is temporary as we move code that accesses block flow
422 // member variables out of LayoutBlock and into LayoutBlockFlow. 468 // member variables out of LayoutBlock and into LayoutBlockFlow.
423 friend class LayoutBlockFlow; 469 friend class LayoutBlockFlow;
424 }; 470 };
425 471
426 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutBlock, isLayoutBlock()); 472 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutBlock, isLayoutBlock());
427 473
428 } // namespace blink 474 } // namespace blink
429 475
430 #endif // LayoutBlock_h 476 #endif // LayoutBlock_h
OLDNEW
« no previous file with comments | « no previous file | Source/core/layout/LayoutBlock.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698