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

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: Fix windows build break 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 26 matching lines...) Expand all
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; 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*, LayoutBlock*> TrackedContainerMap;
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 52 // LayoutBlock is the class that is used by any LayoutObject
53 // that is a containing block. 53 // that is a containing block.
54 // http://www.w3.org/TR/CSS2/visuren.html#containing-block 54 // http://www.w3.org/TR/CSS2/visuren.html#containing-block
55 // See also LayoutObject::containingBlock() that is the function 55 // See also LayoutObject::containingBlock() that is the function
56 // used to get the containing block of a LayoutObject. 56 // used to get the containing block of a LayoutObject.
57 // 57 //
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 152
153 void addChild(LayoutObject* newChild, LayoutObject* beforeChild = nullptr) o verride; 153 void addChild(LayoutObject* newChild, LayoutObject* beforeChild = nullptr) o verride;
154 void removeChild(LayoutObject*) override; 154 void removeChild(LayoutObject*) override;
155 155
156 virtual void layoutBlock(bool relayoutChildren); 156 virtual void layoutBlock(bool relayoutChildren);
157 157
158 void insertPositionedObject(LayoutBox*); 158 void insertPositionedObject(LayoutBox*);
159 static void removePositionedObject(LayoutBox*); 159 static void removePositionedObject(LayoutBox*);
160 void removePositionedObjects(LayoutBlock*, ContainingBlockState = SameContai ningBlock); 160 void removePositionedObjects(LayoutBlock*, ContainingBlockState = SameContai ningBlock);
161 161
162 TrackedLayoutBoxListHashSet* positionedObjects() const; 162 TrackedLayoutBoxListHashSet* positionedObjects() const { return hasPositione dObjects() ? positionedObjectsInternal() : nullptr; }
163 bool hasPositionedObjects() const 163 bool hasPositionedObjects() const
164 { 164 {
165 TrackedLayoutBoxListHashSet* objects = positionedObjects(); 165 ASSERT(static_cast<bool>(m_hasPositionedObjects) == (positionedObjectsIn ternal() && !positionedObjectsInternal()->isEmpty()));
166 return objects && !objects->isEmpty(); 166 return m_hasPositionedObjects;
167 } 167 }
168 168
169 void addPercentHeightDescendant(LayoutBox*); 169 void addPercentHeightDescendant(LayoutBox*);
170 static void removePercentHeightDescendant(LayoutBox*); 170 void removePercentHeightDescendant(LayoutBox*);
171 static bool hasPercentHeightContainerMap(); 171 bool hasPercentHeightDescendant(LayoutBox* o) const { return hasPercentHeigh tDescendants() && percentHeightDescendants()->contains(o); }
esprehn 2016/01/20 00:01:49 this checks the bit twice, you want to call the In
Xianzhu 2016/01/20 02:33:26 Done.
172 static bool hasPercentHeightDescendant(LayoutBox*);
173 static void clearPercentHeightDescendantsFrom(LayoutBox*);
174 static void removePercentHeightDescendantIfNeeded(LayoutBox*);
175 172
176 TrackedLayoutBoxListHashSet* percentHeightDescendants() const; 173 TrackedLayoutBoxListHashSet* percentHeightDescendants() const { return hasPe rcentHeightDescendants() ? percentHeightDescendantsInternal() : nullptr; }
177 bool hasPercentHeightDescendants() const 174 bool hasPercentHeightDescendants() const
178 { 175 {
179 TrackedLayoutBoxListHashSet* descendants = percentHeightDescendants(); 176 ASSERT(static_cast<bool>(m_hasPercentHeightDescendants) == (percentHeigh tDescendantsInternal() && !percentHeightDescendantsInternal()->isEmpty()));
esprehn 2016/01/20 00:01:48 I would do this as: (!m_hasPercentHeightDescendan
Xianzhu 2016/01/20 02:33:26 This will miss check of another side: when m_hasPe
180 return descendants && !descendants->isEmpty(); 177 return m_hasPercentHeightDescendants;
181 } 178 }
182 179
183 void notifyScrollbarThicknessChanged() { m_widthAvailableToChildrenChanged = true; } 180 void notifyScrollbarThicknessChanged() { m_widthAvailableToChildrenChanged = true; }
184 181
185 void setHasMarkupTruncation(bool b) { m_hasMarkupTruncation = b; } 182 void setHasMarkupTruncation(bool b) { m_hasMarkupTruncation = b; }
186 bool hasMarkupTruncation() const { return m_hasMarkupTruncation; } 183 bool hasMarkupTruncation() const { return m_hasMarkupTruncation; }
187 184
188 void setHasMarginBeforeQuirk(bool b) { m_hasMarginBeforeQuirk = b; } 185 void setHasMarginBeforeQuirk(bool b) { m_hasMarginBeforeQuirk = b; }
189 void setHasMarginAfterQuirk(bool b) { m_hasMarginAfterQuirk = b; } 186 void setHasMarginAfterQuirk(bool b) { m_hasMarginAfterQuirk = b; }
190 187
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 389
393 static void collapseAnonymousBlockChild(LayoutBlock* parent, LayoutBlock* ch ild); 390 static void collapseAnonymousBlockChild(LayoutBlock* parent, LayoutBlock* ch ild);
394 void makeChildrenInlineIfPossible(); 391 void makeChildrenInlineIfPossible();
395 392
396 void dirtyLinesFromChangedChild(LayoutObject* child) final { m_lineBoxes.dir tyLinesFromChangedChild(LineLayoutItem(this), LineLayoutItem(child)); } 393 void dirtyLinesFromChangedChild(LayoutObject* child) final { m_lineBoxes.dir tyLinesFromChangedChild(LineLayoutItem(this), LineLayoutItem(child)); }
397 394
398 void addChildIgnoringContinuation(LayoutObject* newChild, LayoutObject* befo reChild) override; 395 void addChildIgnoringContinuation(LayoutObject* newChild, LayoutObject* befo reChild) override;
399 396
400 bool isSelfCollapsingBlock() const override; 397 bool isSelfCollapsingBlock() const override;
401 398
402 void insertIntoTrackedLayoutBoxMaps(LayoutBox* descendant, TrackedDescendant sMap*&, TrackedContainerMap*&); 399 void insertIntoTrackedDescendantsMap(LayoutBox*, TrackedDescendantsMap*&);
403 static void removeFromTrackedLayoutBoxMaps(LayoutBox* descendant, TrackedDes cendantsMap*&, TrackedContainerMap*&); 400 TrackedLayoutBoxListHashSet* positionedObjectsInternal() const;
401 TrackedLayoutBoxListHashSet* percentHeightDescendantsInternal() const;
404 402
405 Node* nodeForHitTest() const; 403 Node* nodeForHitTest() const;
406 404
407 bool tryLayoutDoingPositionedMovementOnly(); 405 bool tryLayoutDoingPositionedMovementOnly();
408 406
409 bool avoidsFloats() const override { return true; } 407 bool avoidsFloats() const override { return true; }
410 408
411 bool hitTestChildren(HitTestResult&, const HitTestLocation& locationInContai ner, const LayoutPoint& accumulatedOffset, HitTestAction); 409 bool hitTestChildren(HitTestResult&, const HitTestLocation& locationInContai ner, const LayoutPoint& accumulatedOffset, HitTestAction);
412 // FIXME-BLOCKFLOW: Remove virtualizaion when all callers have moved to Layo utBlockFlow 410 // FIXME-BLOCKFLOW: Remove virtualizaion when all callers have moved to Layo utBlockFlow
413 virtual bool hitTestFloats(HitTestResult&, const HitTestLocation&, const Lay outPoint&) { return false; } 411 virtual bool hitTestFloats(HitTestResult&, const HitTestLocation&, const Lay outPoint&) { return false; }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 487
490 unsigned m_hasMarginBeforeQuirk : 1; // Note these quirk values can't be put in LayoutBlockRareData since they are set too frequently. 488 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; 489 unsigned m_hasMarginAfterQuirk : 1;
492 unsigned m_beingDestroyed : 1; 490 unsigned m_beingDestroyed : 1;
493 unsigned m_hasMarkupTruncation : 1; 491 unsigned m_hasMarkupTruncation : 1;
494 unsigned m_widthAvailableToChildrenChanged : 1; 492 unsigned m_widthAvailableToChildrenChanged : 1;
495 mutable unsigned m_hasOnlySelfCollapsingChildren : 1; 493 mutable unsigned m_hasOnlySelfCollapsingChildren : 1;
496 mutable unsigned m_descendantsWithFloatsMarkedForLayout : 1; 494 mutable unsigned m_descendantsWithFloatsMarkedForLayout : 1;
497 mutable unsigned m_needsRecalcLogicalWidthAfterLayoutChildren : 1; 495 mutable unsigned m_needsRecalcLogicalWidthAfterLayoutChildren : 1;
498 496
497 unsigned m_hasPositionedObjects : 1;
498 unsigned m_hasPercentHeightDescendants : 1;
499
499 // LayoutRubyBase objects need to be able to split and merge, moving their c hildren around 500 // LayoutRubyBase objects need to be able to split and merge, moving their c hildren around
500 // (calling moveChildTo, moveAllChildrenTo, and makeChildrenNonInline). 501 // (calling moveChildTo, moveAllChildrenTo, and makeChildrenNonInline).
501 friend class LayoutRubyBase; 502 friend class LayoutRubyBase;
502 // FIXME-BLOCKFLOW: Remove this when the line layout stuff has all moved out of LayoutBlock 503 // FIXME-BLOCKFLOW: Remove this when the line layout stuff has all moved out of LayoutBlock
503 friend class LineBreaker; 504 friend class LineBreaker;
504 505
505 // FIXME: This is temporary as we move code that accesses block flow 506 // FIXME: This is temporary as we move code that accesses block flow
506 // member variables out of LayoutBlock and into LayoutBlockFlow. 507 // member variables out of LayoutBlock and into LayoutBlockFlow.
507 friend class LayoutBlockFlow; 508 friend class LayoutBlockFlow;
508 }; 509 };
509 510
510 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutBlock, isLayoutBlock()); 511 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutBlock, isLayoutBlock());
511 512
512 } // namespace blink 513 } // namespace blink
513 514
514 #endif // LayoutBlock_h 515 #endif // LayoutBlock_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698