зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1025669 - part 1, Implement layout of block margins for box-decoration-break:clone. r=roc
This commit is contained in:
Родитель
cb30f027c3
Коммит
c9b13e133b
|
@ -2886,14 +2886,17 @@ nsBlockFrame::IsEmpty()
|
|||
|
||||
bool
|
||||
nsBlockFrame::ShouldApplyBStartMargin(nsBlockReflowState& aState,
|
||||
nsLineBox* aLine)
|
||||
nsLineBox* aLine,
|
||||
nsIFrame* aChildFrame)
|
||||
{
|
||||
if (aState.GetFlag(BRS_APPLYBSTARTMARGIN)) {
|
||||
// Apply short-circuit check to avoid searching the line list
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!aState.IsAdjacentWithTop()) {
|
||||
if (!aState.IsAdjacentWithTop() ||
|
||||
aChildFrame->StyleBorder()->mBoxDecorationBreak ==
|
||||
NS_STYLE_BOX_DECORATION_BREAK_CLONE) {
|
||||
// If we aren't at the top Y coordinate then something of non-zero
|
||||
// height must have been placed. Therefore the childs top-margin
|
||||
// applies.
|
||||
|
@ -2955,11 +2958,12 @@ nsBlockFrame::ReflowBlockFrame(nsBlockReflowState& aState,
|
|||
|
||||
// See if we should apply the top margin. If the block frame being
|
||||
// reflowed is a continuation (non-null prev-in-flow) then we don't
|
||||
// apply its top margin because it's not significant. Otherwise, dig
|
||||
// deeper.
|
||||
bool applyBStartMargin =
|
||||
!frame->GetPrevInFlow() && ShouldApplyBStartMargin(aState, aLine);
|
||||
|
||||
// apply its top margin because it's not significant unless it has
|
||||
// 'box-decoration-break:clone'. Otherwise, dig deeper.
|
||||
bool applyBStartMargin = (frame->StyleBorder()->mBoxDecorationBreak ==
|
||||
NS_STYLE_BOX_DECORATION_BREAK_CLONE ||
|
||||
!frame->GetPrevInFlow()) &&
|
||||
ShouldApplyBStartMargin(aState, aLine, frame);
|
||||
if (applyBStartMargin) {
|
||||
// The HasClearance setting is only valid if ShouldApplyBStartMargin
|
||||
// returned false (in which case the top-margin-root set our
|
||||
|
@ -3427,7 +3431,7 @@ nsBlockFrame::ReflowInlineFrames(nsBlockReflowState& aState,
|
|||
|
||||
// Setup initial coordinate system for reflowing the inline frames
|
||||
// into. Apply a previous block frame's bottom margin first.
|
||||
if (ShouldApplyBStartMargin(aState, aLine)) {
|
||||
if (ShouldApplyBStartMargin(aState, aLine, aLine->mFirstChild)) {
|
||||
aState.mBCoord += aState.mPrevBEndMargin.get();
|
||||
}
|
||||
nsFlowAreaRect floatAvailableSpace = aState.GetFloatAvailableSpace();
|
||||
|
|
|
@ -637,7 +637,8 @@ protected:
|
|||
// Methods for individual frame reflow
|
||||
|
||||
bool ShouldApplyBStartMargin(nsBlockReflowState& aState,
|
||||
nsLineBox* aLine);
|
||||
nsLineBox* aLine,
|
||||
nsIFrame* aChildFrame);
|
||||
|
||||
void ReflowBlockFrame(nsBlockReflowState& aState,
|
||||
line_iterator aLine,
|
||||
|
|
|
@ -49,15 +49,18 @@ nsBlockReflowState::nsBlockReflowState(const nsHTMLReflowState& aReflowState,
|
|||
SetFlag(BRS_ISOVERFLOWCONTAINER,
|
||||
IS_TRUE_OVERFLOW_CONTAINER(aFrame));
|
||||
|
||||
mBorderPadding.ApplySkipSides(aFrame->GetLogicalSkipSides(&aReflowState));
|
||||
int logicalSkipSides = aFrame->GetLogicalSkipSides(&aReflowState);
|
||||
mBorderPadding.ApplySkipSides(logicalSkipSides);
|
||||
|
||||
// Note that mContainerWidth is the physical width!
|
||||
mContainerWidth = aReflowState.ComputedWidth() + mBorderPadding.LeftRight(wm);
|
||||
|
||||
if (aBStartMarginRoot || 0 != mBorderPadding.BStart(wm)) {
|
||||
if ((aBStartMarginRoot && !(logicalSkipSides & LOGICAL_SIDE_B_START)) ||
|
||||
0 != mBorderPadding.BStart(wm)) {
|
||||
SetFlag(BRS_ISBSTARTMARGINROOT, true);
|
||||
}
|
||||
if (aBEndMarginRoot || 0 != mBorderPadding.BEnd(wm)) {
|
||||
if ((aBEndMarginRoot && !(logicalSkipSides & LOGICAL_SIDE_B_END)) ||
|
||||
0 != mBorderPadding.BEnd(wm)) {
|
||||
SetFlag(BRS_ISBENDMARGINROOT, true);
|
||||
}
|
||||
if (GetFlag(BRS_ISBSTARTMARGINROOT)) {
|
||||
|
@ -166,6 +169,20 @@ nsBlockReflowState::ComputeReplacedBlockOffsetsForFloats(nsIFrame* aFrame,
|
|||
aRightResult = rightOffset;
|
||||
}
|
||||
|
||||
static nscoord
|
||||
GetBEndMarginClone(nsIFrame* aFrame,
|
||||
nsRenderingContext* aRenderingContext,
|
||||
const LogicalRect& aContentArea,
|
||||
WritingMode aWritingMode)
|
||||
{
|
||||
if (aFrame->StyleBorder()->mBoxDecorationBreak ==
|
||||
NS_STYLE_BOX_DECORATION_BREAK_CLONE) {
|
||||
nsCSSOffsetState os(aFrame, aRenderingContext, aContentArea.Width(aWritingMode));
|
||||
return os.ComputedLogicalMargin().BEnd(aWritingMode);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Compute the amount of available space for reflowing a block frame
|
||||
// at the current Y coordinate. This method assumes that
|
||||
// GetAvailableSpace has already been called.
|
||||
|
@ -188,7 +205,8 @@ nsBlockReflowState::ComputeBlockAvailSpace(nsIFrame* aFrame,
|
|||
result.BStart(wm) = mBCoord;
|
||||
result.BSize(wm) = GetFlag(BRS_UNCONSTRAINEDBSIZE)
|
||||
? NS_UNCONSTRAINEDSIZE
|
||||
: mReflowState.AvailableBSize() - mBCoord;
|
||||
: mReflowState.AvailableBSize() - mBCoord
|
||||
- GetBEndMarginClone(aFrame, mReflowState.rendContext, mContentArea, wm);
|
||||
// mBCoord might be greater than mBEndEdge if the block's top margin pushes
|
||||
// it off the page/column. Negative available height can confuse other code
|
||||
// and is nonsense in principle.
|
||||
|
|
Загрузка…
Ссылка в новой задаче