Index: third_party/WebKit/Source/core/layout/LayoutBlock.h |
diff --git a/third_party/WebKit/Source/core/layout/LayoutBlock.h b/third_party/WebKit/Source/core/layout/LayoutBlock.h |
index 2ae34b93f839fef30594c5d818e5b9ad6f845d69..122343d57e1e6dcd22e0cc5c25ed1ee97db3817b 100644 |
--- a/third_party/WebKit/Source/core/layout/LayoutBlock.h |
+++ b/third_party/WebKit/Source/core/layout/LayoutBlock.h |
@@ -43,12 +43,30 @@ class LayoutInline; |
class WordMeasurement; |
typedef WTF::ListHashSet<LayoutBox*, 16> TrackedLayoutBoxListHashSet; |
-typedef WTF::HashMap<const LayoutBlock*, OwnPtr<TrackedLayoutBoxListHashSet>> TrackedDescendantsMap; |
-typedef WTF::HashMap<const LayoutBox*, OwnPtr<HashSet<LayoutBlock*>>> TrackedContainerMap; |
typedef Vector<WordMeasurement, 64> WordMeasurements; |
enum ContainingBlockState { NewContainingBlock, SameContainingBlock }; |
+class LayoutBlockRareData : public LayoutBoxRareData { |
+public: |
+ // This set keeps track of the positioned objects associated with a containing |
+ // block. |
+ // |
+ // This set is populated during layout. It is kept across layouts to handle |
+ // that we skip unchanged sub-trees during layout, in such a way that we are |
+ // able to lay out deeply nested out-of-flow descendants if their containing |
+ // block got laid out. The set could be invalidated during style change but |
+ // keeping track of containing blocks at that time is complicated (we are in |
+ // the middle of recomputing the style so we can't rely on any of its |
+ // information), which is why it's easier to just update it for every layout. |
+ OwnPtr<TrackedLayoutBoxListHashSet> m_positionedDescendants; |
+ |
+ // This set keeps track of the descendants whose 'height' is percentage associated |
+ // with a containing block. Like |m_positionedDescendants|, it is also recomputed |
+ // for every layout (see the comment above about why). |
+ OwnPtr<TrackedLayoutBoxListHashSet> m_percentHeightDescendants; |
+}; |
+ |
// LayoutBlock is the class that is used by any LayoutObject |
// that is a containing block. |
// http://www.w3.org/TR/CSS2/visuren.html#containing-block |
@@ -156,10 +174,10 @@ public: |
virtual void layoutBlock(bool relayoutChildren); |
void insertPositionedObject(LayoutBox*); |
- static void removePositionedObject(LayoutBox*); |
+ void removePositionedObject(LayoutBox*); |
void removePositionedObjects(LayoutBlock*, ContainingBlockState = SameContainingBlock); |
- TrackedLayoutBoxListHashSet* positionedObjects() const; |
+ TrackedLayoutBoxListHashSet* positionedObjects() const { return layoutBlockRareData() ? layoutBlockRareData()->m_positionedDescendants.get() : nullptr; } |
bool hasPositionedObjects() const |
{ |
TrackedLayoutBoxListHashSet* objects = positionedObjects(); |
@@ -167,13 +185,10 @@ public: |
} |
void addPercentHeightDescendant(LayoutBox*); |
- static void removePercentHeightDescendant(LayoutBox*); |
- static bool hasPercentHeightContainerMap(); |
- static bool hasPercentHeightDescendant(LayoutBox*); |
- static void clearPercentHeightDescendantsFrom(LayoutBox*); |
- static void removePercentHeightDescendantIfNeeded(LayoutBox*); |
+ void removePercentHeightDescendant(LayoutBox*); |
+ bool hasPercentHeightDescendant(LayoutBox*); |
- TrackedLayoutBoxListHashSet* percentHeightDescendants() const; |
+ TrackedLayoutBoxListHashSet* percentHeightDescendants() const { return layoutBlockRareData() ? layoutBlockRareData()->m_percentHeightDescendants.get() : nullptr; } |
bool hasPercentHeightDescendants() const |
{ |
TrackedLayoutBoxListHashSet* descendants = percentHeightDescendants(); |
@@ -399,9 +414,6 @@ private: |
bool isSelfCollapsingBlock() const override; |
- void insertIntoTrackedLayoutBoxMaps(LayoutBox* descendant, TrackedDescendantsMap*&, TrackedContainerMap*&); |
- static void removeFromTrackedLayoutBoxMaps(LayoutBox* descendant, TrackedDescendantsMap*&, TrackedContainerMap*&); |
- |
Node* nodeForHitTest() const; |
bool tryLayoutDoingPositionedMovementOnly(); |
@@ -484,6 +496,10 @@ protected: |
virtual bool canCollapseAnonymousBlockChild() const { return true; } |
+ LayoutBlockRareData* layoutBlockRareData() const { return static_cast<LayoutBlockRareData*>(rareData()); } |
+ LayoutBlockRareData& ensureLayoutBlockRareData() { return static_cast<LayoutBlockRareData&>(ensureRareData()); } |
+ LayoutBoxRareData* createRareData() override { return new LayoutBlockRareData; } |
+ |
LayoutObjectChildList m_children; |
LineBoxList m_lineBoxes; // All of the root line boxes created for this block flow. For example, <div>Hello<br>world.</div> will have two total lines for the <div>. |