diff options
-rw-r--r-- | layout/generic/ReflowInput.cpp | 64 | ||||
-rw-r--r-- | layout/generic/ReflowInput.h | 30 | ||||
-rw-r--r-- | layout/generic/nsFrame.cpp | 14 | ||||
-rw-r--r-- | layout/generic/nsFrame.h | 2 | ||||
-rw-r--r-- | layout/reftests/css-grid/grid-auto-min-sizing-definite-001-ref.html | 47 | ||||
-rw-r--r-- | layout/reftests/css-grid/grid-item-sizing-percent-001-ref.html | 4 | ||||
-rw-r--r-- | layout/reftests/css-grid/grid-item-sizing-percent-001.html | 4 | ||||
-rw-r--r-- | layout/reftests/css-grid/grid-item-sizing-px-001.html | 4 | ||||
-rw-r--r-- | layout/reftests/css-grid/reftest.list | 2 | ||||
-rw-r--r-- | layout/reftests/w3c-css/submitted/flexbox/flexbox-mbp-horiz-004-ref.xhtml | 28 | ||||
-rw-r--r-- | layout/reftests/w3c-css/submitted/flexbox/flexbox-mbp-horiz-004.xhtml | 20 |
11 files changed, 71 insertions, 148 deletions
diff --git a/layout/generic/ReflowInput.cpp b/layout/generic/ReflowInput.cpp index a8756cea2..bbff77ad4 100644 --- a/layout/generic/ReflowInput.cpp +++ b/layout/generic/ReflowInput.cpp @@ -154,11 +154,6 @@ FontSizeInflationListMarginAdjustment(const nsIFrame* aFrame) return 0; } -// NOTE: If we ever want to use SizeComputationInput for a flex item or a -// grid item, we need to make it take the containing-block block-size as -// well as the inline-size, since flex items and grid items resolve -// block-direction percent margins and padding against the -// containing-block block-size, rather than its inline-size. SizeComputationInput::SizeComputationInput(nsIFrame *aFrame, nsRenderingContext *aRenderingContext, WritingMode aContainingBlockWritingMode, @@ -167,16 +162,9 @@ SizeComputationInput::SizeComputationInput(nsIFrame *aFrame, , mRenderingContext(aRenderingContext) , mWritingMode(aFrame->GetWritingMode()) { - MOZ_ASSERT(!aFrame->IsFlexOrGridItem(), - "We're about to resolve percent margin & padding " - "values against CB inline size, which is incorrect for " - "flex/grid items. " - "Additionally for grid items, this path doesn't handle baseline " - "padding contribution - see SizeComputationInput::InitOffsets"); - LogicalSize cbSize(aContainingBlockWritingMode, aContainingBlockISize, - aContainingBlockISize); ReflowInputFlags flags; - InitOffsets(aContainingBlockWritingMode, cbSize, mFrame->GetType(), flags); + InitOffsets(aContainingBlockWritingMode, aContainingBlockISize, + mFrame->GetType(), flags); } // Initialize a reflow state for a child frame's reflow. Some state @@ -2132,27 +2120,6 @@ IsSideCaption(nsIFrame* aFrame, const nsStyleDisplay* aStyleDisplay, captionSide == NS_STYLE_CAPTION_SIDE_RIGHT; } -// Flex/grid items resolve block-axis percentage margin & padding against the -// containing block block-size (also for abs/fixed-pos child frames). -// For everything else: the CSS21 spec requires that margin and padding -// percentage values are calculated with respect to the inline-size of the -// containing block, even for margin & padding in the block axis. -static LogicalSize -OffsetPercentBasis(const nsIFrame* aFrame, - WritingMode aWM, - const LogicalSize& aContainingBlockSize) -{ - LogicalSize offsetPercentBasis = aContainingBlockSize; - if (MOZ_LIKELY(!aFrame->GetParent() || - !aFrame->GetParent()->IsFlexOrGridContainer())) { - offsetPercentBasis.BSize(aWM) = offsetPercentBasis.ISize(aWM); - } else if (offsetPercentBasis.BSize(aWM) == NS_AUTOHEIGHT) { - offsetPercentBasis.BSize(aWM) = 0; - } - - return offsetPercentBasis; -} - // XXX refactor this code to have methods for each set of properties // we are computing: width,height,line-height; margin; offsets @@ -2173,7 +2140,7 @@ ReflowInput::InitConstraints(nsPresContext* aPresContext, // height equal to the available space if (nullptr == mParentReflowInput || mFlags.mDummyParentReflowInput) { // XXXldb This doesn't mean what it used to! - InitOffsets(wm, OffsetPercentBasis(mFrame, wm, aContainingBlockSize), + InitOffsets(wm, aContainingBlockSize.ISize(wm), aFrameType, mFlags, aBorder, aPadding); // Override mComputedMargin since reflow roots start from the // frame's boundary, which is inside the margin. @@ -2230,8 +2197,7 @@ ReflowInput::InitConstraints(nsPresContext* aPresContext, // For calculating positioning offsets, margins, borders and // padding, we use the writing mode of the containing block WritingMode cbwm = cbrs->GetWritingMode(); - InitOffsets(cbwm, OffsetPercentBasis(mFrame, cbwm, - cbSize.ConvertTo(cbwm, wm)), + InitOffsets(cbwm, cbSize.ConvertTo(cbwm, wm).ISize(cbwm), aFrameType, mFlags, aBorder, aPadding); // For calculating the size of this box, we use its own writing mode @@ -2505,7 +2471,7 @@ UpdateProp(FrameProperties& aProps, void SizeComputationInput::InitOffsets(WritingMode aWM, - const LogicalSize& aPercentBasis, + nscoord aPercentBasis, nsIAtom* aFrameType, ReflowInputFlags aFlags, const nsMargin* aBorder, @@ -2876,7 +2842,7 @@ ReflowInput::CalcLineHeight(nsIContent* aContent, bool SizeComputationInput::ComputeMargin(WritingMode aWM, - const LogicalSize& aPercentBasis) + nscoord aPercentBasis) { // SVG text frames have no margin. if (mFrame->IsSVGText()) { @@ -2893,17 +2859,17 @@ SizeComputationInput::ComputeMargin(WritingMode aWM, // (http://dev.w3.org/csswg/css-writing-modes-3/#orthogonal-flows) LogicalMargin m(aWM); m.IStart(aWM) = nsLayoutUtils:: - ComputeCBDependentValue(aPercentBasis.ISize(aWM), + ComputeCBDependentValue(aPercentBasis, styleMargin->mMargin.GetIStart(aWM)); m.IEnd(aWM) = nsLayoutUtils:: - ComputeCBDependentValue(aPercentBasis.ISize(aWM), + ComputeCBDependentValue(aPercentBasis, styleMargin->mMargin.GetIEnd(aWM)); m.BStart(aWM) = nsLayoutUtils:: - ComputeCBDependentValue(aPercentBasis.BSize(aWM), + ComputeCBDependentValue(aPercentBasis, styleMargin->mMargin.GetBStart(aWM)); m.BEnd(aWM) = nsLayoutUtils:: - ComputeCBDependentValue(aPercentBasis.BSize(aWM), + ComputeCBDependentValue(aPercentBasis, styleMargin->mMargin.GetBEnd(aWM)); SetComputedLogicalMargin(aWM, m); @@ -2924,7 +2890,7 @@ SizeComputationInput::ComputeMargin(WritingMode aWM, bool SizeComputationInput::ComputePadding(WritingMode aWM, - const LogicalSize& aPercentBasis, + nscoord aPercentBasis, nsIAtom* aFrameType) { // If style can provide us the padding directly, then use it. @@ -2945,17 +2911,17 @@ SizeComputationInput::ComputePadding(WritingMode aWM, // clamp negative calc() results to 0 LogicalMargin p(aWM); p.IStart(aWM) = std::max(0, nsLayoutUtils:: - ComputeCBDependentValue(aPercentBasis.ISize(aWM), + ComputeCBDependentValue(aPercentBasis, stylePadding->mPadding.GetIStart(aWM))); p.IEnd(aWM) = std::max(0, nsLayoutUtils:: - ComputeCBDependentValue(aPercentBasis.ISize(aWM), + ComputeCBDependentValue(aPercentBasis, stylePadding->mPadding.GetIEnd(aWM))); p.BStart(aWM) = std::max(0, nsLayoutUtils:: - ComputeCBDependentValue(aPercentBasis.BSize(aWM), + ComputeCBDependentValue(aPercentBasis, stylePadding->mPadding.GetBStart(aWM))); p.BEnd(aWM) = std::max(0, nsLayoutUtils:: - ComputeCBDependentValue(aPercentBasis.BSize(aWM), + ComputeCBDependentValue(aPercentBasis, stylePadding->mPadding.GetBEnd(aWM))); SetComputedLogicalPadding(aWM, p); diff --git a/layout/generic/ReflowInput.h b/layout/generic/ReflowInput.h index 09c980b72..1d2df6af6 100644 --- a/layout/generic/ReflowInput.h +++ b/layout/generic/ReflowInput.h @@ -245,7 +245,7 @@ public: static void* DisplayInitOffsetsEnter( nsIFrame* aFrame, SizeComputationInput* aState, - const mozilla::LogicalSize& aPercentBasis, + nscoord aPercentBasis, const nsMargin* aBorder, const nsMargin* aPadding); static void DisplayInitOffsetsExit(nsIFrame* aFrame, @@ -260,19 +260,12 @@ private: * * @param aWM Writing mode of the containing block * @param aPercentBasis - * Logical size in the writing mode of the containing block to use - * for resolving percentage margin values in the inline and block - * axes. - * The inline size is usually the containing block inline-size - * (width if writing mode is horizontal, and height if vertical). - * The block size is usually the containing block inline-size, per - * CSS21 sec 8.3 (read in conjunction with CSS Writing Modes sec - * 7.2), but may be the containing block block-size, e.g. in CSS3 - * Flexbox and Grid. + * Inline size of the containing block (in its own writing mode), to use + * for resolving percentage margin values in the inline and block axes. * @return true if the margin is dependent on the containing block size. */ bool ComputeMargin(mozilla::WritingMode aWM, - const mozilla::LogicalSize& aPercentBasis); + nscoord aPercentBasis); /** * Computes padding values from the specified padding style information, and @@ -280,25 +273,18 @@ private: * * @param aWM Writing mode of the containing block * @param aPercentBasis - * Logical size in the writing mode of the containing block to use - * for resolving percentage padding values in the inline and block - * axes. - * The inline size is usually the containing block inline-size - * (width if writing mode is horizontal, and height if vertical). - * The block size is usually the containing block inline-size, per - * CSS21 sec 8.3 (read in conjunction with CSS Writing Modes sec - * 7.2), but may be the containing block block-size, e.g. in CSS3 - * Flexbox and Grid. + * Inline size of the containing block (in its own writing mode), to use + * for resolving percentage padding values in the inline and block axes. * @return true if the padding is dependent on the containing block size. */ bool ComputePadding(mozilla::WritingMode aWM, - const mozilla::LogicalSize& aPercentBasis, + nscoord aPercentBasis, nsIAtom* aFrameType); protected: void InitOffsets(mozilla::WritingMode aWM, - const mozilla::LogicalSize& aPercentBasis, + nscoord aPercentBasis, nsIAtom* aFrameType, ReflowInputFlags aFlags, const nsMargin* aBorder = nullptr, diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index 418fa16b7..fa5b24d40 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -10289,8 +10289,8 @@ DR_init_constraints_cookie::~DR_init_constraints_cookie() DR_init_offsets_cookie::DR_init_offsets_cookie( nsIFrame* aFrame, - SizeComputationInput* aState, - const LogicalSize& aPercentBasis, + SizeComputationInput* aState, + nscoord aPercentBasis, const nsMargin* aMargin, const nsMargin* aPadding) : mFrame(aFrame) @@ -11243,7 +11243,7 @@ ReflowInput::DisplayInitConstraintsExit(nsIFrame* aFrame, /* static */ void* SizeComputationInput::DisplayInitOffsetsEnter(nsIFrame* aFrame, SizeComputationInput* aState, - const LogicalSize& aPercentBasis, + nscoord aPercentBasis, const nsMargin* aBorder, const nsMargin* aPadding) { @@ -11258,12 +11258,10 @@ SizeComputationInput::DisplayInitOffsetsEnter(nsIFrame* aFrame, if (treeNode && treeNode->mDisplay) { DR_state->DisplayFrameTypeInfo(aFrame, treeNode->mIndent); - char horizPctBasisStr[16]; - char vertPctBasisStr[16]; + char pctBasisStr[16]; WritingMode wm = aState->GetWritingMode(); - DR_state->PrettyUC(aPercentBasis.ISize(wm), horizPctBasisStr, 16); - DR_state->PrettyUC(aPercentBasis.BSize(wm), vertPctBasisStr, 16); - printf("InitOffsets pct_basis=%s,%s", horizPctBasisStr, vertPctBasisStr); + DR_state->PrettyUC(aPercentBasis, pctBasisStr, 16); + printf("InitOffsets pct_basis=%s", pctBasisStr); DR_state->PrintMargin("b", aBorder); DR_state->PrintMargin("p", aPadding); diff --git a/layout/generic/nsFrame.h b/layout/generic/nsFrame.h index f996f57d7..af1c95ef2 100644 --- a/layout/generic/nsFrame.h +++ b/layout/generic/nsFrame.h @@ -845,7 +845,7 @@ public: struct DR_init_offsets_cookie { DR_init_offsets_cookie(nsIFrame* aFrame, mozilla::SizeComputationInput* aState, - const mozilla::LogicalSize& aPercentBasis, + nscoord aPercentBasis, const nsMargin* aBorder, const nsMargin* aPadding); ~DR_init_offsets_cookie(); diff --git a/layout/reftests/css-grid/grid-auto-min-sizing-definite-001-ref.html b/layout/reftests/css-grid/grid-auto-min-sizing-definite-001-ref.html index a0d9180a2..8858b4ea8 100644 --- a/layout/reftests/css-grid/grid-auto-min-sizing-definite-001-ref.html +++ b/layout/reftests/css-grid/grid-auto-min-sizing-definite-001-ref.html @@ -62,40 +62,31 @@ b40 { z-index: 1; position:relative; } -w { - position:absolute; - background: lime; - border-width: 1px 0 0 3px; - border-style: solid; - height:48px; - width:75px; -} -.v > w { - border-width: 3px 0 0 1px; - left:-1px; top:-3px; - height:53px; - width:61px; -} -.h.r { margin-left:19px; padding: 1px 15px 37px 30px; } -.v .h > w { - height:48px; - width:45px; -} -.v.r > w { - height:53px; - width:61px; +.h.r { + height: 42px; + width: 42px; + /* This margin-left is 20% of 98px-wide grid area */ + margin-left: 19.6px; + /* This padding-bottom is 10% of 98px wide grid area */ + /* This padding-left is 30% of 98px wide grid area */ + padding: 1px 3px 9.8px 29.4px; } -.v .v > w { - height:41px; - width:45px; +.v.r { + height: 42px; + width: 42px; + /* This margin-left is 20% of 54px-wide grid area */ + margin-left: 10.8px; + /* This padding-bottom is 10% of 54px wide grid area */ + /* This padding-left is 30% of 54px wide grid area */ + padding: 1px 3px 5.4px 16.2px; } .r { position:relative; } .t6 { width:46px; } -.t8 { width:118px; } +.t8 { width:118px; height: 102.5px; } -xx { +xx { display: block; background: lime; padding:32px 32px 16px 32px; @@ -114,7 +105,7 @@ xx { <div class="grid"><span class="v"><x></x></span></div> <div class="grid t6"><span class="v bb"><x></x></span></div> <div class="grid"><span class="v"><x></x></span><span class="v"><x></x></span></div> -<div class="grid t8"><span class="v r"><w></w><b40></b40></span></div> +<div class="grid t8"><span class="v r"><b40></b40></span></div> <div class="grid"><xx class="v"></xx></div> <div class="grid v"><xx class="h"></xx></div> diff --git a/layout/reftests/css-grid/grid-item-sizing-percent-001-ref.html b/layout/reftests/css-grid/grid-item-sizing-percent-001-ref.html index 3a7f2d6bb..4996f8b9c 100644 --- a/layout/reftests/css-grid/grid-item-sizing-percent-001-ref.html +++ b/layout/reftests/css-grid/grid-item-sizing-percent-001-ref.html @@ -30,8 +30,8 @@ body,html { color:black; background:white; font-size:16px; padding:0; margin:0; } .p { padding:2px 3px; } .m { margin:2px 3px; } -.c1.p,.c2.p { padding:5px 9px; } -.c1.m,.c2.m { margin:5px 9px; } +.c1.p,.c2.p { padding:6px 9px; } +.c1.m,.c2.m { margin:6px 9px; } .b { border:solid black; } #t1 { width:50px; height: 20px; } diff --git a/layout/reftests/css-grid/grid-item-sizing-percent-001.html b/layout/reftests/css-grid/grid-item-sizing-percent-001.html index cc5948968..960247592 100644 --- a/layout/reftests/css-grid/grid-item-sizing-percent-001.html +++ b/layout/reftests/css-grid/grid-item-sizing-percent-001.html @@ -48,8 +48,8 @@ body,html { color:black; background:white; font-size:16px; padding:0; margin:0; box-sizing: border-box; } -.p { padding:10% 6%; } -.m { margin:10% 6%; } +.p { padding:4% 6%; } +.m { margin:4% 6%; } .b { border:solid black; } </style> diff --git a/layout/reftests/css-grid/grid-item-sizing-px-001.html b/layout/reftests/css-grid/grid-item-sizing-px-001.html index a004365fc..7e58d831d 100644 --- a/layout/reftests/css-grid/grid-item-sizing-px-001.html +++ b/layout/reftests/css-grid/grid-item-sizing-px-001.html @@ -46,8 +46,8 @@ body,html { color:black; background:white; font-size:16px; padding:0; margin:0; .p { padding:2px 3px; } .m { margin:2px 3px; } -.c1.p,.c2.p { padding:5px 9px; } -.c1.m,.c2.m { margin:5px 9px; } +.c1.p,.c2.p { padding:6px 9px; } +.c1.m,.c2.m { margin:6px 9px; } .b { border:solid black; } </style> diff --git a/layout/reftests/css-grid/reftest.list b/layout/reftests/css-grid/reftest.list index 093e2faee..c2ee57c1a 100644 --- a/layout/reftests/css-grid/reftest.list +++ b/layout/reftests/css-grid/reftest.list @@ -45,7 +45,7 @@ skip-if(Android) fuzzy-if(winWidget,1,32) == grid-placement-auto-implicit-001.ht == vrl-grid-placement-auto-row-sparse-001.html vrl-grid-placement-auto-row-sparse-001-ref.html == grid-relpos-items-001.html grid-relpos-items-001-ref.html == grid-item-sizing-percent-001.html grid-item-sizing-percent-001-ref.html -== grid-item-sizing-percent-002.html grid-item-sizing-percent-002-ref.html +fails == grid-item-sizing-percent-002.html grid-item-sizing-percent-002-ref.html # bug 1434397 == grid-item-sizing-percent-003.html grid-item-sizing-percent-003-ref.html == grid-item-sizing-percent-004.html grid-item-sizing-percent-004-ref.html == grid-item-sizing-px-001.html grid-item-sizing-percent-001-ref.html diff --git a/layout/reftests/w3c-css/submitted/flexbox/flexbox-mbp-horiz-004-ref.xhtml b/layout/reftests/w3c-css/submitted/flexbox/flexbox-mbp-horiz-004-ref.xhtml index 00db4823e..beefa0abf 100644 --- a/layout/reftests/w3c-css/submitted/flexbox/flexbox-mbp-horiz-004-ref.xhtml +++ b/layout/reftests/w3c-css/submitted/flexbox/flexbox-mbp-horiz-004-ref.xhtml @@ -4,8 +4,7 @@ http://creativecommons.org/publicdomain/zero/1.0/ --> <!-- Reference case - identical to the testcase, but with with the flex items' - vertical margin and padding values set to 0 by default, and then set to - specific pixel values for the items that have a 50px percent-basis. + margin and padding values set to explicit pixel values. --> <html xmlns="http://www.w3.org/1999/xhtml"> <head> @@ -21,27 +20,10 @@ } div.height50 { height: 50px; } - .marginA { margin: 0 8% 0 4%; } - .marginB { margin: 0 10% 0 14%; } - .paddingA { padding: 0 6% 0 2%; } - .paddingB { padding: 0 8% 0 12%; } - - div.height50 > .marginA { - margin-top: 5px; - margin-bottom: 3px; - } - div.height50 > .marginB { - margin-top: 4px; - margin-bottom: 6px; - } - div.height50 > .paddingA { - padding-top: 4px; - padding-bottom: 2px; - } - div.height50 > .paddingB { - padding-top: 3px; - padding-bottom: 5px; - } + .marginA { margin: 20px 16px 12px 8px; } + .marginB { margin: 16px 20px 24px 28px; } + .paddingA { padding: 16px 12px 8px 4px; } + .paddingB { padding: 12px 16px 20px 24px; } div.child1 { flex: none; diff --git a/layout/reftests/w3c-css/submitted/flexbox/flexbox-mbp-horiz-004.xhtml b/layout/reftests/w3c-css/submitted/flexbox/flexbox-mbp-horiz-004.xhtml index 545e54f71..b513253fd 100644 --- a/layout/reftests/w3c-css/submitted/flexbox/flexbox-mbp-horiz-004.xhtml +++ b/layout/reftests/w3c-css/submitted/flexbox/flexbox-mbp-horiz-004.xhtml @@ -3,19 +3,17 @@ Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ --> -<!-- Testcase with percent-valued padding and/or margin on flex items. The spec - says that percentage values on padding/margin-top and -bottom should be - resolved against the flex container's height (not its width, as would - be the case in a block). +<!-- Testcase with percent-valued padding and/or margin on flex items. + The spec allows these to be resolved against the flex container's + inline size (regardless of which axis the percent padding/margin is in). --> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>CSS Test: Testing percent-valued padding and margin on flex items</title> <link rel="author" title="Daniel Holbert" href="mailto:dholbert@mozilla.com"/> - <link rel="help" href="http://www.w3.org/TR/css-flexbox-1/#layout-algorithm"/> + <link rel="help" href="https://www.w3.org/TR/css-flexbox-1/#item-margins"/> <link rel="match" href="flexbox-mbp-horiz-004-ref.xhtml"/> <style> - div { border: 0; } div.flexbox { width: 200px; display: flex; @@ -52,8 +50,9 @@ </style> </head> <body> - <!-- Flex container is auto-height - vertical margin and padding should - resolve to 0, since they don't have anything to resolve % against. --> + <!-- Flex container is auto-height - this shouldn't impact percent + margin/padding resolution, since they resolve against container's + inline-size, i.e. its width in this case. --> <div class="flexbox" ><div class="child1 paddingA"><div class="filler"/></div ><div class="child2 paddingB"><div class="filler"/></div @@ -61,8 +60,9 @@ ><div class="child2 marginB"></div ></div> - <!-- Flex container has height: 50px - vertical margin and padding should - resolve % values against that. --> + <!-- Flex container has height: 50px - again, this shouldn't impact percent + margin/padding resolution, since they resolve against container's + inline-size, i.e. its width in this case. --> <div class="flexbox height50" ><div class="child1 paddingA"><div class="filler"/></div ><div class="child2 paddingB"><div class="filler"/></div |