Commit f19cf120 authored by cbiesinger's avatar cbiesinger Committed by Commit bot

Switch override containing block sizes to use LayoutRareData

...instead of the ugly global map.

R=rego@igalia.com,jfernandez@igalia.com

Review-Url: https://codereview.chromium.org/2262973002
Cr-Commit-Position: refs/heads/master@{#413466}
parent e4c61a66
...@@ -71,10 +71,6 @@ namespace blink { ...@@ -71,10 +71,6 @@ namespace blink {
// Used by flexible boxes when flexing this element and by table cells. // Used by flexible boxes when flexing this element and by table cells.
typedef WTF::HashMap<const LayoutBox*, LayoutUnit> OverrideSizeMap; typedef WTF::HashMap<const LayoutBox*, LayoutUnit> OverrideSizeMap;
// Used by grid elements to properly size their grid items.
// FIXME: Move these into LayoutBoxRareData.
static OverrideSizeMap* gOverrideContainingBlockLogicalHeightMap = nullptr;
static OverrideSizeMap* gOverrideContainingBlockLogicalWidthMap = nullptr;
static OverrideSizeMap* gExtraInlineOffsetMap = nullptr; static OverrideSizeMap* gExtraInlineOffsetMap = nullptr;
static OverrideSizeMap* gExtraBlockOffsetMap = nullptr; static OverrideSizeMap* gExtraBlockOffsetMap = nullptr;
...@@ -1139,58 +1135,58 @@ LayoutUnit LayoutBox::overrideLogicalContentHeight() const ...@@ -1139,58 +1135,58 @@ LayoutUnit LayoutBox::overrideLogicalContentHeight() const
// TODO (lajava) Now that we have implemented these functions based on physical direction, we'd rather remove the logical ones. // TODO (lajava) Now that we have implemented these functions based on physical direction, we'd rather remove the logical ones.
LayoutUnit LayoutBox::overrideContainingBlockContentLogicalWidth() const LayoutUnit LayoutBox::overrideContainingBlockContentLogicalWidth() const
{ {
ASSERT(hasOverrideContainingBlockLogicalWidth()); DCHECK(hasOverrideContainingBlockLogicalWidth());
return gOverrideContainingBlockLogicalWidthMap->get(this); return m_rareData->m_overrideContainingBlockContentLogicalWidth;
} }
// TODO (lajava) Shouldn't we implement these functions based on physical direction ?. // TODO (lajava) Shouldn't we implement these functions based on physical direction ?.
LayoutUnit LayoutBox::overrideContainingBlockContentLogicalHeight() const LayoutUnit LayoutBox::overrideContainingBlockContentLogicalHeight() const
{ {
ASSERT(hasOverrideContainingBlockLogicalHeight()); DCHECK(hasOverrideContainingBlockLogicalHeight());
return gOverrideContainingBlockLogicalHeightMap->get(this); return m_rareData->m_overrideContainingBlockContentLogicalHeight;
} }
// TODO (lajava) Shouldn't we implement these functions based on physical direction ?. // TODO (lajava) Shouldn't we implement these functions based on physical direction ?.
bool LayoutBox::hasOverrideContainingBlockLogicalWidth() const bool LayoutBox::hasOverrideContainingBlockLogicalWidth() const
{ {
return gOverrideContainingBlockLogicalWidthMap && gOverrideContainingBlockLogicalWidthMap->contains(this); return m_rareData && m_rareData->m_hasOverrideContainingBlockContentLogicalWidth;
} }
// TODO (lajava) Shouldn't we implement these functions based on physical direction ?. // TODO (lajava) Shouldn't we implement these functions based on physical direction ?.
bool LayoutBox::hasOverrideContainingBlockLogicalHeight() const bool LayoutBox::hasOverrideContainingBlockLogicalHeight() const
{ {
return gOverrideContainingBlockLogicalHeightMap && gOverrideContainingBlockLogicalHeightMap->contains(this); return m_rareData && m_rareData->m_hasOverrideContainingBlockContentLogicalHeight;
} }
// TODO (lajava) Shouldn't we implement these functions based on physical direction ?. // TODO (lajava) Shouldn't we implement these functions based on physical direction ?.
void LayoutBox::setOverrideContainingBlockContentLogicalWidth(LayoutUnit logicalWidth) void LayoutBox::setOverrideContainingBlockContentLogicalWidth(LayoutUnit logicalWidth)
{ {
if (!gOverrideContainingBlockLogicalWidthMap) ensureRareData().m_overrideContainingBlockContentLogicalWidth = logicalWidth;
gOverrideContainingBlockLogicalWidthMap = new OverrideSizeMap; ensureRareData().m_hasOverrideContainingBlockContentLogicalWidth = true;
gOverrideContainingBlockLogicalWidthMap->set(this, logicalWidth);
} }
// TODO (lajava) Shouldn't we implement these functions based on physical direction ?. // TODO (lajava) Shouldn't we implement these functions based on physical direction ?.
void LayoutBox::setOverrideContainingBlockContentLogicalHeight(LayoutUnit logicalHeight) void LayoutBox::setOverrideContainingBlockContentLogicalHeight(LayoutUnit logicalHeight)
{ {
if (!gOverrideContainingBlockLogicalHeightMap) ensureRareData().m_overrideContainingBlockContentLogicalHeight = logicalHeight;
gOverrideContainingBlockLogicalHeightMap = new OverrideSizeMap; ensureRareData().m_hasOverrideContainingBlockContentLogicalHeight = true;
gOverrideContainingBlockLogicalHeightMap->set(this, logicalHeight);
} }
// TODO (lajava) Shouldn't we implement these functions based on physical direction ?. // TODO (lajava) Shouldn't we implement these functions based on physical direction ?.
void LayoutBox::clearContainingBlockOverrideSize() void LayoutBox::clearContainingBlockOverrideSize()
{ {
if (gOverrideContainingBlockLogicalWidthMap) if (!m_rareData)
gOverrideContainingBlockLogicalWidthMap->remove(this); return;
clearOverrideContainingBlockContentLogicalHeight(); ensureRareData().m_hasOverrideContainingBlockContentLogicalWidth = false;
ensureRareData().m_hasOverrideContainingBlockContentLogicalHeight = false;
} }
// TODO (lajava) Shouldn't we implement these functions based on physical direction ?. // TODO (lajava) Shouldn't we implement these functions based on physical direction ?.
void LayoutBox::clearOverrideContainingBlockContentLogicalHeight() void LayoutBox::clearOverrideContainingBlockContentLogicalHeight()
{ {
if (gOverrideContainingBlockLogicalHeightMap) if (!m_rareData)
gOverrideContainingBlockLogicalHeightMap->remove(this); return;
ensureRareData().m_hasOverrideContainingBlockContentLogicalHeight = false;
} }
LayoutUnit LayoutBox::extraInlineOffset() const LayoutUnit LayoutBox::extraInlineOffset() const
......
...@@ -61,8 +61,10 @@ struct LayoutBoxRareData { ...@@ -61,8 +61,10 @@ struct LayoutBoxRareData {
public: public:
LayoutBoxRareData() LayoutBoxRareData()
: m_spannerPlaceholder(nullptr) : m_spannerPlaceholder(nullptr)
, m_overrideLogicalContentHeight(-1)
, m_overrideLogicalContentWidth(-1) , m_overrideLogicalContentWidth(-1)
, m_overrideLogicalContentHeight(-1)
, m_hasOverrideContainingBlockContentLogicalWidth(false)
, m_hasOverrideContainingBlockContentLogicalHeight(false)
, m_percentHeightContainer(nullptr) , m_percentHeightContainer(nullptr)
, m_snapContainer(nullptr) , m_snapContainer(nullptr)
, m_snapAreas(nullptr) , m_snapAreas(nullptr)
...@@ -72,8 +74,13 @@ public: ...@@ -72,8 +74,13 @@ public:
// For spanners, the spanner placeholder that lays us out within the multicol container. // For spanners, the spanner placeholder that lays us out within the multicol container.
LayoutMultiColumnSpannerPlaceholder* m_spannerPlaceholder; LayoutMultiColumnSpannerPlaceholder* m_spannerPlaceholder;
LayoutUnit m_overrideLogicalContentHeight;
LayoutUnit m_overrideLogicalContentWidth; LayoutUnit m_overrideLogicalContentWidth;
LayoutUnit m_overrideLogicalContentHeight;
bool m_hasOverrideContainingBlockContentLogicalWidth;
bool m_hasOverrideContainingBlockContentLogicalHeight;
LayoutUnit m_overrideContainingBlockContentLogicalWidth;
LayoutUnit m_overrideContainingBlockContentLogicalHeight;
LayoutUnit m_pageLogicalOffset; LayoutUnit m_pageLogicalOffset;
LayoutUnit m_paginationStrut; LayoutUnit m_paginationStrut;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment