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

Unified 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: 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 side-by-side diff with in-line comments
Download patch
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 f4af3baec2c01ecd349be6a74f379f56a1af6294..c38a1f0e48875f95bc1bb87e700af58c8779c226 100644
--- a/third_party/WebKit/Source/core/layout/LayoutBlock.h
+++ b/third_party/WebKit/Source/core/layout/LayoutBlock.h
@@ -44,7 +44,7 @@ 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 WTF::HashMap<const LayoutBox*, LayoutBlock*> TrackedContainerMap;
typedef Vector<WordMeasurement, 64> WordMeasurements;
enum ContainingBlockState { NewContainingBlock, SameContainingBlock };
@@ -159,25 +159,22 @@ public:
static void removePositionedObject(LayoutBox*);
void removePositionedObjects(LayoutBlock*, ContainingBlockState = SameContainingBlock);
- TrackedLayoutBoxListHashSet* positionedObjects() const;
+ TrackedLayoutBoxListHashSet* positionedObjects() const { return hasPositionedObjects() ? positionedObjectsInternal() : nullptr; }
bool hasPositionedObjects() const
{
- TrackedLayoutBoxListHashSet* objects = positionedObjects();
- return objects && !objects->isEmpty();
+ ASSERT(m_hasPositionedObjects ? (positionedObjectsInternal() && !positionedObjectsInternal()->isEmpty()) : !positionedObjectsInternal());
+ return m_hasPositionedObjects;
}
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* o) const { return hasPercentHeightDescendants() && percentHeightDescendantsInternal()->contains(o); }
- TrackedLayoutBoxListHashSet* percentHeightDescendants() const;
+ TrackedLayoutBoxListHashSet* percentHeightDescendants() const { return hasPercentHeightDescendants() ? percentHeightDescendantsInternal() : nullptr; }
bool hasPercentHeightDescendants() const
{
- TrackedLayoutBoxListHashSet* descendants = percentHeightDescendants();
- return descendants && !descendants->isEmpty();
+ ASSERT(m_hasPercentHeightDescendants ? (percentHeightDescendantsInternal() && !percentHeightDescendantsInternal()->isEmpty()) : !percentHeightDescendantsInternal());
+ return m_hasPercentHeightDescendants;
}
void notifyScrollbarThicknessChanged() { m_widthAvailableToChildrenChanged = true; }
@@ -399,8 +396,8 @@ private:
bool isSelfCollapsingBlock() const override;
- void insertIntoTrackedLayoutBoxMaps(LayoutBox* descendant, TrackedDescendantsMap*&, TrackedContainerMap*&);
- static void removeFromTrackedLayoutBoxMaps(LayoutBox* descendant, TrackedDescendantsMap*&, TrackedContainerMap*&);
+ TrackedLayoutBoxListHashSet* positionedObjectsInternal() const;
+ TrackedLayoutBoxListHashSet* percentHeightDescendantsInternal() const;
Node* nodeForHitTest() const;
@@ -496,6 +493,9 @@ protected:
mutable unsigned m_descendantsWithFloatsMarkedForLayout : 1;
mutable unsigned m_needsRecalcLogicalWidthAfterLayoutChildren : 1;
+ unsigned m_hasPositionedObjects : 1;
+ unsigned m_hasPercentHeightDescendants : 1;
+
// LayoutRubyBase objects need to be able to split and merge, moving their children around
// (calling moveChildTo, moveAllChildrenTo, and makeChildrenNonInline).
friend class LayoutRubyBase;

Powered by Google App Engine
This is Rietveld 408576698