Chromium Code Reviews| Index: Source/core/rendering/RenderBox.cpp |
| diff --git a/Source/core/rendering/RenderBox.cpp b/Source/core/rendering/RenderBox.cpp |
| index 7e63fe333b7890e7e5c48a84f0ad34a67eb493fb..c42504563036a8b938deaa1d462c55def17afff4 100644 |
| --- a/Source/core/rendering/RenderBox.cpp |
| +++ b/Source/core/rendering/RenderBox.cpp |
| @@ -72,6 +72,8 @@ typedef WTF::HashMap<const RenderBox*, LayoutUnit> OverrideSizeMap; |
| // FIXME: Move these into RenderBoxRareData. |
| static OverrideSizeMap* gOverrideContainingBlockLogicalHeightMap = 0; |
| static OverrideSizeMap* gOverrideContainingBlockLogicalWidthMap = 0; |
| +static OverrideSizeMap* gOverrideInlineOffsetMap = 0; |
| +static OverrideSizeMap* gOverrideBlockOffsetMap = 0; |
| // Size of border belt for autoscroll. When mouse pointer in border belt, |
| @@ -103,6 +105,7 @@ void RenderBox::willBeDestroyed() |
| { |
| clearOverrideSize(); |
| clearContainingBlockOverrideSize(); |
| + clearOverrideInlineAndBlockOffests(); |
| RenderBlock::removePercentHeightDescendantIfNeeded(this); |
| @@ -1011,6 +1014,50 @@ void RenderBox::clearOverrideContainingBlockContentLogicalHeight() |
| gOverrideContainingBlockLogicalHeightMap->remove(this); |
| } |
| +LayoutUnit RenderBox::overrideInlineOffset() const |
| +{ |
| + ASSERT(hasOverrideInlineOffset()); |
| + return gOverrideInlineOffsetMap->get(this); |
| +} |
| + |
| +LayoutUnit RenderBox::overrideBlockOffset() const |
| +{ |
| + ASSERT(hasOverrideBlockOffset()); |
| + return gOverrideBlockOffsetMap->get(this); |
| +} |
| + |
| +bool RenderBox::hasOverrideInlineOffset() const |
| +{ |
| + return gOverrideInlineOffsetMap && gOverrideInlineOffsetMap->contains(this); |
| +} |
| + |
| +bool RenderBox::hasOverrideBlockOffset() const |
| +{ |
| + return gOverrideBlockOffsetMap && gOverrideBlockOffsetMap->contains(this); |
| +} |
| + |
| +void RenderBox::setOverrideInlineOffset(LayoutUnit inlineOffest) |
| +{ |
| + if (!gOverrideInlineOffsetMap) |
| + gOverrideInlineOffsetMap = new OverrideSizeMap; |
| + gOverrideInlineOffsetMap->set(this, inlineOffest); |
| +} |
| + |
| +void RenderBox::setOverrideBlockOffset(LayoutUnit blockOffest) |
| +{ |
| + if (!gOverrideBlockOffsetMap) |
| + gOverrideBlockOffsetMap = new OverrideSizeMap; |
| + gOverrideBlockOffsetMap->set(this, blockOffest); |
| +} |
| + |
| +void RenderBox::clearOverrideInlineAndBlockOffests() |
| +{ |
| + if (gOverrideInlineOffsetMap) |
| + gOverrideInlineOffsetMap->remove(this); |
| + if (gOverrideBlockOffsetMap) |
| + gOverrideBlockOffsetMap->remove(this); |
| +} |
| + |
| LayoutUnit RenderBox::adjustBorderBoxLogicalWidthForBoxSizing(LayoutUnit width) const |
| { |
| LayoutUnit bordersPlusPadding = borderAndPaddingLogicalWidth(); |
| @@ -2617,6 +2664,9 @@ LayoutUnit RenderBox::containingBlockLogicalWidthForPositioned(const RenderBoxMo |
| } |
| } |
| + if (hasOverrideContainingBlockLogicalWidth()) |
| + return overrideContainingBlockContentLogicalWidth(); |
| + |
| if (containingBlock->isBox()) |
| return toRenderBox(containingBlock)->clientLogicalWidth(); |
| @@ -2657,6 +2707,9 @@ LayoutUnit RenderBox::containingBlockLogicalHeightForPositioned(const RenderBoxM |
| } |
| } |
| + if (hasOverrideContainingBlockLogicalHeight()) |
| + return overrideContainingBlockContentLogicalHeight(); |
| + |
| if (containingBlock->isBox()) { |
| const RenderBlock* cb = containingBlock->isRenderBlock() ? |
| toRenderBlock(containingBlock) : containingBlock->containingBlock(); |
| @@ -2843,6 +2896,9 @@ void RenderBox::computePositionedLogicalWidth(LogicalExtentComputedValues& compu |
| } |
| } |
| + if (hasOverrideInlineOffset() && !style()->hasStaticInlinePosition(isHorizontal)) |
|
Julien - ping for review
2014/12/02 20:46:05
This adds one hash lookup for every layout with po
Manuel Rego
2014/12/03 09:48:58
Nice catch. We can even minimize this more if we c
|
| + computedValues.m_position += overrideInlineOffset(); |
| + |
| computedValues.m_extent += bordersPlusPadding; |
| } |
| @@ -3153,6 +3209,9 @@ void RenderBox::computePositionedLogicalHeight(LogicalExtentComputedValues& comp |
| } |
| } |
| + if (hasOverrideBlockOffset() && !style()->hasStaticBlockPosition(isHorizontalWritingMode())) |
| + computedValues.m_position += overrideBlockOffset(); |
| + |
| // Set final height value. |
| computedValues.m_extent += bordersPlusPadding; |
| } |