Commit b1e79166 authored by robhogan@gmail.com's avatar robhogan@gmail.com

Simplify Writing-Mode Related Calculation of Margins

Remove the very complicated logic from computeLogicalHeight() and
computeLogicalWidth() whose sole purpose was to use the writing mode of
the child vs the containing block when appropriate. The complexity was
unnecessary and the same result can be achieved by ensuring we use the
child's writing mode when computing the size of the box and the parent's
writing mode when computing the margins for position (e.g. for margin
collapsing).

Review URL: https://codereview.chromium.org/298563002

git-svn-id: svn://svn.chromium.org/blink/trunk@176154 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 4bd05cdc
......@@ -36,6 +36,7 @@ struct PaintInfo;
enum SizeType { MainOrPreferredSize, MinSize, MaxSize };
enum AvailableLogicalHeightType { ExcludeMarginBorderPadding, IncludeMarginBorderPadding };
enum OverlayScrollbarSizeRelevancy { IgnoreOverlayScrollbarSize, IncludeOverlayScrollbarSize };
enum MarginDirection { BlockDirection, InlineDirection };
enum ShouldComputePreferred { ComputeActual, ComputePreferred };
......@@ -385,12 +386,11 @@ public:
LayoutUnit m_position;
ComputedMarginValues m_margins;
};
// Resolve auto margins in the inline direction of the containing block so that objects can be pushed to the start, middle or end
// Resolve auto margins in the chosen direction of the containing block so that objects can be pushed to the start, middle or end
// of the containing block.
void computeInlineDirectionMargins(RenderBlock* containingBlock, LayoutUnit containerWidth, LayoutUnit childWidth, LayoutUnit& marginStart, LayoutUnit& marginEnd) const;
void computeMarginsForDirection(MarginDirection forDirection, const RenderBlock* containingBlock, LayoutUnit containerWidth, LayoutUnit childWidth, LayoutUnit& marginStart, LayoutUnit& marginEnd, Length marginStartLength, Length marginStartEnd) const;
// Used to resolve margins in the containing block's block-flow direction.
void computeBlockDirectionMargins(const RenderBlock* containingBlock, LayoutUnit& marginBefore, LayoutUnit& marginAfter) const;
void computeAndSetBlockDirectionMargins(const RenderBlock* containingBlock);
virtual LayoutUnit offsetFromLogicalTopOfFirstPage() const;
......
......@@ -302,20 +302,10 @@ void RenderTable::updateLogicalWidth()
}
// Finally, with our true width determined, compute our margins for real.
setMarginStart(0);
setMarginEnd(0);
if (!hasPerpendicularContainingBlock) {
ComputedMarginValues marginValues;
bool hasInvertedDirection = cb->style()->isLeftToRightDirection() == style()->isLeftToRightDirection();
computeInlineDirectionMargins(cb, availableLogicalWidth, logicalWidth(),
hasInvertedDirection ? marginValues.m_start : marginValues.m_end,
hasInvertedDirection ? marginValues.m_end : marginValues.m_start);
setMarginStart(marginValues.m_start);
setMarginEnd(marginValues.m_end);
} else {
setMarginStart(minimumValueForLength(style()->marginStart(), availableLogicalWidth));
setMarginEnd(minimumValueForLength(style()->marginEnd(), availableLogicalWidth));
}
ComputedMarginValues marginValues;
computeMarginsForDirection(InlineDirection, cb, availableLogicalWidth, logicalWidth(), marginValues.m_start, marginValues.m_end, style()->marginStart(), style()->marginEnd());
setMarginStart(marginValues.m_start);
setMarginEnd(marginValues.m_end);
// We should NEVER shrink the table below the min-content logical width, or else the table can't accomodate
// its own content which doesn't match CSS nor what authors expect.
......
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