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

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

Issue 1544423002: Improve positioned/percentHeight descendant/container tracking (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: virtual destructor Created 4 years, 11 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
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 25 matching lines...) Expand all
36 #include "wtf/OwnPtr.h" 36 #include "wtf/OwnPtr.h"
37 37
38 namespace blink { 38 namespace blink {
39 39
40 class LineLayoutState; 40 class LineLayoutState;
41 struct PaintInfo; 41 struct PaintInfo;
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;
47 typedef WTF::HashMap<const LayoutBox*, OwnPtr<HashSet<LayoutBlock*>>> TrackedCon tainerMap;
48 typedef Vector<WordMeasurement, 64> WordMeasurements; 46 typedef Vector<WordMeasurement, 64> WordMeasurements;
49 47
50 enum ContainingBlockState { NewContainingBlock, SameContainingBlock }; 48 enum ContainingBlockState { NewContainingBlock, SameContainingBlock };
51 49
50 class LayoutBlockRareData : public LayoutBoxRareData {
51 public:
52 // This set keeps track of the positioned objects associated with a containi ng
53 // block.
54 //
55 // This set is populated during layout. It is kept across layouts to handle
56 // that we skip unchanged sub-trees during layout, in such a way that we are
57 // able to lay out deeply nested out-of-flow descendants if their containing
58 // block got laid out. The set could be invalidated during style change but
59 // keeping track of containing blocks at that time is complicated (we are in
60 // the middle of recomputing the style so we can't rely on any of its
61 // information), which is why it's easier to just update it for every layout .
62 OwnPtr<TrackedLayoutBoxListHashSet> m_positionedDescendants;
63
64 // This set keeps track of the descendants whose 'height' is percentage asso ciated
65 // with a containing block. Like |m_positionedDescendants|, it is also recom puted
66 // for every layout (see the comment above about why).
67 OwnPtr<TrackedLayoutBoxListHashSet> m_percentHeightDescendants;
68 };
69
52 // LayoutBlock is the class that is used by any LayoutObject 70 // LayoutBlock is the class that is used by any LayoutObject
53 // that is a containing block. 71 // that is a containing block.
54 // http://www.w3.org/TR/CSS2/visuren.html#containing-block 72 // http://www.w3.org/TR/CSS2/visuren.html#containing-block
55 // See also LayoutObject::containingBlock() that is the function 73 // See also LayoutObject::containingBlock() that is the function
56 // used to get the containing block of a LayoutObject. 74 // used to get the containing block of a LayoutObject.
57 // 75 //
58 // CSS is inconsistent and allows inline elements (LayoutInline) to be 76 // CSS is inconsistent and allows inline elements (LayoutInline) to be
59 // containing blocks, even though they are not blocks. Our 77 // containing blocks, even though they are not blocks. Our
60 // implementation is as confused with inlines. See e.g. 78 // implementation is as confused with inlines. See e.g.
61 // LayoutObject::containingBlock() vs LayoutObject::container(). 79 // LayoutObject::containingBlock() vs LayoutObject::container().
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 public: 167 public:
150 // FIXME-BLOCKFLOW: Remove virtualizaion when all callers have moved to Layo utBlockFlow 168 // FIXME-BLOCKFLOW: Remove virtualizaion when all callers have moved to Layo utBlockFlow
151 virtual void deleteLineBoxTree(); 169 virtual void deleteLineBoxTree();
152 170
153 void addChild(LayoutObject* newChild, LayoutObject* beforeChild = nullptr) o verride; 171 void addChild(LayoutObject* newChild, LayoutObject* beforeChild = nullptr) o verride;
154 void removeChild(LayoutObject*) override; 172 void removeChild(LayoutObject*) override;
155 173
156 virtual void layoutBlock(bool relayoutChildren); 174 virtual void layoutBlock(bool relayoutChildren);
157 175
158 void insertPositionedObject(LayoutBox*); 176 void insertPositionedObject(LayoutBox*);
159 static void removePositionedObject(LayoutBox*); 177 void removePositionedObject(LayoutBox*);
160 void removePositionedObjects(LayoutBlock*, ContainingBlockState = SameContai ningBlock); 178 void removePositionedObjects(LayoutBlock*, ContainingBlockState = SameContai ningBlock);
161 179
162 TrackedLayoutBoxListHashSet* positionedObjects() const; 180 TrackedLayoutBoxListHashSet* positionedObjects() const { return layoutBlockR areData() ? layoutBlockRareData()->m_positionedDescendants.get() : nullptr; }
163 bool hasPositionedObjects() const 181 bool hasPositionedObjects() const
164 { 182 {
165 TrackedLayoutBoxListHashSet* objects = positionedObjects(); 183 TrackedLayoutBoxListHashSet* objects = positionedObjects();
166 return objects && !objects->isEmpty(); 184 return objects && !objects->isEmpty();
167 } 185 }
168 186
169 void addPercentHeightDescendant(LayoutBox*); 187 void addPercentHeightDescendant(LayoutBox*);
170 static void removePercentHeightDescendant(LayoutBox*); 188 void removePercentHeightDescendant(LayoutBox*);
171 static bool hasPercentHeightContainerMap(); 189 bool hasPercentHeightDescendant(LayoutBox*);
172 static bool hasPercentHeightDescendant(LayoutBox*);
173 static void clearPercentHeightDescendantsFrom(LayoutBox*);
174 static void removePercentHeightDescendantIfNeeded(LayoutBox*);
175 190
176 TrackedLayoutBoxListHashSet* percentHeightDescendants() const; 191 TrackedLayoutBoxListHashSet* percentHeightDescendants() const { return layou tBlockRareData() ? layoutBlockRareData()->m_percentHeightDescendants.get() : nul lptr; }
177 bool hasPercentHeightDescendants() const 192 bool hasPercentHeightDescendants() const
178 { 193 {
179 TrackedLayoutBoxListHashSet* descendants = percentHeightDescendants(); 194 TrackedLayoutBoxListHashSet* descendants = percentHeightDescendants();
180 return descendants && !descendants->isEmpty(); 195 return descendants && !descendants->isEmpty();
181 } 196 }
182 197
183 void notifyScrollbarThicknessChanged() { m_widthAvailableToChildrenChanged = true; } 198 void notifyScrollbarThicknessChanged() { m_widthAvailableToChildrenChanged = true; }
184 199
185 void setHasMarkupTruncation(bool b) { m_hasMarkupTruncation = b; } 200 void setHasMarkupTruncation(bool b) { m_hasMarkupTruncation = b; }
186 bool hasMarkupTruncation() const { return m_hasMarkupTruncation; } 201 bool hasMarkupTruncation() const { return m_hasMarkupTruncation; }
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 407
393 static void collapseAnonymousBlockChild(LayoutBlock* parent, LayoutBlock* ch ild); 408 static void collapseAnonymousBlockChild(LayoutBlock* parent, LayoutBlock* ch ild);
394 void makeChildrenInlineIfPossible(); 409 void makeChildrenInlineIfPossible();
395 410
396 void dirtyLinesFromChangedChild(LayoutObject* child) final { m_lineBoxes.dir tyLinesFromChangedChild(LineLayoutItem(this), LineLayoutItem(child)); } 411 void dirtyLinesFromChangedChild(LayoutObject* child) final { m_lineBoxes.dir tyLinesFromChangedChild(LineLayoutItem(this), LineLayoutItem(child)); }
397 412
398 void addChildIgnoringContinuation(LayoutObject* newChild, LayoutObject* befo reChild) override; 413 void addChildIgnoringContinuation(LayoutObject* newChild, LayoutObject* befo reChild) override;
399 414
400 bool isSelfCollapsingBlock() const override; 415 bool isSelfCollapsingBlock() const override;
401 416
402 void insertIntoTrackedLayoutBoxMaps(LayoutBox* descendant, TrackedDescendant sMap*&, TrackedContainerMap*&);
403 static void removeFromTrackedLayoutBoxMaps(LayoutBox* descendant, TrackedDes cendantsMap*&, TrackedContainerMap*&);
404
405 Node* nodeForHitTest() const; 417 Node* nodeForHitTest() const;
406 418
407 bool tryLayoutDoingPositionedMovementOnly(); 419 bool tryLayoutDoingPositionedMovementOnly();
408 420
409 bool avoidsFloats() const override { return true; } 421 bool avoidsFloats() const override { return true; }
410 422
411 bool hitTestChildren(HitTestResult&, const HitTestLocation& locationInContai ner, const LayoutPoint& accumulatedOffset, HitTestAction); 423 bool hitTestChildren(HitTestResult&, const HitTestLocation& locationInContai ner, const LayoutPoint& accumulatedOffset, HitTestAction);
412 // FIXME-BLOCKFLOW: Remove virtualizaion when all callers have moved to Layo utBlockFlow 424 // FIXME-BLOCKFLOW: Remove virtualizaion when all callers have moved to Layo utBlockFlow
413 virtual bool hitTestFloats(HitTestResult&, const HitTestLocation&, const Lay outPoint&) { return false; } 425 virtual bool hitTestFloats(HitTestResult&, const HitTestLocation&, const Lay outPoint&) { return false; }
414 426
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 // applying any forced or unforced break, if needed. 489 // applying any forced or unforced break, if needed.
478 void paginatedContentWasLaidOut(LayoutUnit logicalTopOffsetAfterPagination); 490 void paginatedContentWasLaidOut(LayoutUnit logicalTopOffsetAfterPagination);
479 491
480 // Adjust from painting offsets to the local coords of this layoutObject 492 // Adjust from painting offsets to the local coords of this layoutObject
481 void offsetForContents(LayoutPoint&) const; 493 void offsetForContents(LayoutPoint&) const;
482 494
483 virtual bool updateLogicalWidthAndColumnWidth(); 495 virtual bool updateLogicalWidthAndColumnWidth();
484 496
485 virtual bool canCollapseAnonymousBlockChild() const { return true; } 497 virtual bool canCollapseAnonymousBlockChild() const { return true; }
486 498
499 LayoutBlockRareData* layoutBlockRareData() const { return static_cast<Layout BlockRareData*>(rareData()); }
500 LayoutBlockRareData& ensureLayoutBlockRareData() { return static_cast<Layout BlockRareData&>(ensureRareData()); }
501 LayoutBoxRareData* createRareData() override { return new LayoutBlockRareDat a; }
502
487 LayoutObjectChildList m_children; 503 LayoutObjectChildList m_children;
488 LineBoxList m_lineBoxes; // All of the root line boxes created for this bloc k flow. For example, <div>Hello<br>world.</div> will have two total lines for t he <div>. 504 LineBoxList m_lineBoxes; // All of the root line boxes created for this bloc k flow. For example, <div>Hello<br>world.</div> will have two total lines for t he <div>.
489 505
490 unsigned m_hasMarginBeforeQuirk : 1; // Note these quirk values can't be put in LayoutBlockRareData since they are set too frequently. 506 unsigned m_hasMarginBeforeQuirk : 1; // Note these quirk values can't be put in LayoutBlockRareData since they are set too frequently.
491 unsigned m_hasMarginAfterQuirk : 1; 507 unsigned m_hasMarginAfterQuirk : 1;
492 unsigned m_beingDestroyed : 1; 508 unsigned m_beingDestroyed : 1;
493 unsigned m_hasMarkupTruncation : 1; 509 unsigned m_hasMarkupTruncation : 1;
494 unsigned m_widthAvailableToChildrenChanged : 1; 510 unsigned m_widthAvailableToChildrenChanged : 1;
495 mutable unsigned m_hasOnlySelfCollapsingChildren : 1; 511 mutable unsigned m_hasOnlySelfCollapsingChildren : 1;
496 mutable unsigned m_descendantsWithFloatsMarkedForLayout : 1; 512 mutable unsigned m_descendantsWithFloatsMarkedForLayout : 1;
497 mutable unsigned m_needsRecalcLogicalWidthAfterLayoutChildren : 1; 513 mutable unsigned m_needsRecalcLogicalWidthAfterLayoutChildren : 1;
498 514
499 // LayoutRubyBase objects need to be able to split and merge, moving their c hildren around 515 // LayoutRubyBase objects need to be able to split and merge, moving their c hildren around
500 // (calling moveChildTo, moveAllChildrenTo, and makeChildrenNonInline). 516 // (calling moveChildTo, moveAllChildrenTo, and makeChildrenNonInline).
501 friend class LayoutRubyBase; 517 friend class LayoutRubyBase;
502 // FIXME-BLOCKFLOW: Remove this when the line layout stuff has all moved out of LayoutBlock 518 // FIXME-BLOCKFLOW: Remove this when the line layout stuff has all moved out of LayoutBlock
503 friend class LineBreaker; 519 friend class LineBreaker;
504 520
505 // FIXME: This is temporary as we move code that accesses block flow 521 // FIXME: This is temporary as we move code that accesses block flow
506 // member variables out of LayoutBlock and into LayoutBlockFlow. 522 // member variables out of LayoutBlock and into LayoutBlockFlow.
507 friend class LayoutBlockFlow; 523 friend class LayoutBlockFlow;
508 }; 524 };
509 525
510 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutBlock, isLayoutBlock()); 526 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutBlock, isLayoutBlock());
511 527
512 } // namespace blink 528 } // namespace blink
513 529
514 #endif // LayoutBlock_h 530 #endif // LayoutBlock_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698