From 1da0e8a095d82dd6b9ad0c0a45a7ee3b9d80ded7 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Tue, 13 Feb 2018 19:26:43 +0100 Subject: Never shrink line heights as a result of minimumFontSize. See: MoonchildProductions/Pale-Moon#1614. --- layout/style/nsRuleNode.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'layout') diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp index b22002d87..fa29fe0f1 100644 --- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -4686,7 +4686,8 @@ nsRuleNode::ComputeTextData(void* aStartStruct, if (font->mSize != 0) { lh = nscoord(float(lh) * float(font->mFont.size) / float(font->mSize)); } else { - lh = minimumFontSize; + // Never shrink line heights as a result of minFontSize + lh = std::max(lh, minimumFontSize); } } text->mLineHeight.SetCoordValue(lh); -- cgit v1.2.3 From 4c697043da9fe3f58a7e070dad74eab6972695a0 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Tue, 20 Feb 2018 14:01:05 +0100 Subject: Remove windows-xp and windows-vista from @media(-moz-os-version) --- layout/style/nsMediaFeatures.cpp | 2 -- layout/style/test/chrome/bug418986-2.js | 2 -- layout/style/test/test_media_queries.html | 2 -- 3 files changed, 6 deletions(-) (limited to 'layout') diff --git a/layout/style/nsMediaFeatures.cpp b/layout/style/nsMediaFeatures.cpp index 052ce58e8..5a54d5455 100644 --- a/layout/style/nsMediaFeatures.cpp +++ b/layout/style/nsMediaFeatures.cpp @@ -70,8 +70,6 @@ struct OperatingSystemVersionInfo { // Os version identities used in the -moz-os-version media query. const OperatingSystemVersionInfo osVersionStrings[] = { - { LookAndFeel::eOperatingSystemVersion_WindowsXP, L"windows-xp" }, - { LookAndFeel::eOperatingSystemVersion_WindowsVista, L"windows-vista" }, { LookAndFeel::eOperatingSystemVersion_Windows7, L"windows-win7" }, { LookAndFeel::eOperatingSystemVersion_Windows8, L"windows-win8" }, { LookAndFeel::eOperatingSystemVersion_Windows10, L"windows-win10" } diff --git a/layout/style/test/chrome/bug418986-2.js b/layout/style/test/chrome/bug418986-2.js index 4336f4abd..b083f48ee 100644 --- a/layout/style/test/chrome/bug418986-2.js +++ b/layout/style/test/chrome/bug418986-2.js @@ -53,8 +53,6 @@ var suppressed_toggles = [ // Possible values for '-moz-os-version' var windows_versions = [ - "windows-xp", - "windows-vista", "windows-win7", "windows-win8", "windows-win10", diff --git a/layout/style/test/test_media_queries.html b/layout/style/test/test_media_queries.html index 479306a55..d503fad0b 100644 --- a/layout/style/test/test_media_queries.html +++ b/layout/style/test/test_media_queries.html @@ -713,8 +713,6 @@ function run() { expression_should_not_be_parseable("-moz-windows-theme: "); // os version media queries (currently windows only) - expression_should_be_parseable("-moz-os-version: windows-xp"); - expression_should_be_parseable("-moz-os-version: windows-vista"); expression_should_be_parseable("-moz-os-version: windows-win7"); expression_should_be_parseable("-moz-os-version: windows-win8"); expression_should_be_parseable("-moz-os-version: windows-win10"); -- cgit v1.2.3 From 4fd939e8c9dd97c45e7fcd1314f3ab482a2cf23d Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Thu, 10 Aug 2017 18:01:49 +0200 Subject: JS - make window.pageYOffset/pageXOffset/scrollX/scrollY double --- layout/forms/test/test_bug562447.html | 6 +++--- layout/forms/test/test_bug564115.html | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'layout') diff --git a/layout/forms/test/test_bug562447.html b/layout/forms/test/test_bug562447.html index 53f84428e..99f691871 100644 --- a/layout/forms/test/test_bug562447.html +++ b/layout/forms/test/test_bug562447.html @@ -23,7 +23,7 @@ addLoadEvent(function() { setTimeout(function() { // Make sure that we're scrolled by 5000px - is(window.pageYOffset, 5000, "Make sure we're scrolled correctly"); + is(Math.round(window.pageYOffset), 5000, "Make sure we're scrolled correctly"); // Scroll back up, and mess with the input box along the way var input = document.getElementById("WhyDoYouFocusMe"); @@ -38,14 +38,14 @@ addLoadEvent(function() { window.scrollTo(0, 5000); setTimeout(function() { - is(window.pageYOffset, 5000, "Sanity check"); + is(Math.round(window.pageYOffset), 5000, "Sanity check"); window.scrollTo(0, 0); input.focus(); input.blur(); setTimeout(function() { - isnot(window.pageYOffset, 0, "This time we shouldn't be scrolled up"); + isnot(Math.round(window.pageYOffset), 0, "This time we shouldn't be scrolled up"); SimpleTest.finish(); }, 0); diff --git a/layout/forms/test/test_bug564115.html b/layout/forms/test/test_bug564115.html index 5723b55d5..ffd4222ca 100644 --- a/layout/forms/test/test_bug564115.html +++ b/layout/forms/test/test_bug564115.html @@ -30,12 +30,12 @@ addLoadEvent(function() { win.scrollTo(0, 5000); setTimeout(function() { - is(win.pageYOffset, 5000, "Page should be scrolled correctly"); + is(Math.round(win.pageYOffset), 5000, "Page should be scrolled correctly"); // Refocus the window SimpleTest.waitForFocus(function() { SimpleTest.waitForFocus(function() { - is(win.pageYOffset, 5000, + is(Math.round(win.pageYOffset), 5000, "The page's scroll offset should not have been changed"); win.close(); -- cgit v1.2.3 From 46ad1199deeaf6ba2db31fb3398d3eaa9abdbb2e Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Wed, 13 Dec 2017 12:07:12 +0100 Subject: Don't build EME-specific subroutines without EME. - Checks for restricted or encrypted content - Dispatching 'encrypted' events - Dispatching 'key needed' events - HTML Media Element media keys system - EME telemetry - HTML Media Element EME API This is the main bulk for #26, isolating EME-specific code. --- layout/base/nsLayoutUtils.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'layout') diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index ed34f39ce..789c91f50 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -7242,9 +7242,11 @@ nsLayoutUtils::SurfaceFromElement(HTMLVideoElement* aElement, (aSurfaceFlags & SFE_PREFER_NO_PREMULTIPLY_ALPHA) == 0, "We can't support non-premultiplied alpha for video!"); +#ifdef MOZ_EME if (aElement->ContainsRestrictedContent()) { return result; } +#endif uint16_t readyState; if (NS_SUCCEEDED(aElement->GetReadyState(&readyState)) && -- cgit v1.2.3 From 259e214960c23346628311d88427c7ca13bdb335 Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Wed, 28 Feb 2018 08:49:42 +0100 Subject: Basilisk - the cmd line - help (the columns alignment, error improvements) https://github.com/MoonchildProductions/moebius/pull/58 --- layout/tools/recording/recording-cmdline.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'layout') diff --git a/layout/tools/recording/recording-cmdline.js b/layout/tools/recording/recording-cmdline.js index e043aa29c..0f127bbd5 100644 --- a/layout/tools/recording/recording-cmdline.js +++ b/layout/tools/recording/recording-cmdline.js @@ -67,8 +67,8 @@ RecordingCmdLineHandler.prototype = cmdLine.preventDefault = true; }, - helpInfo : " --recording Record drawing for a given URL.\n" + - " --recording-output Specify destination file for a drawing recording.\n" + helpInfo : " --recording Record drawing for a given URL.\n" + + " --recording-output Specify destination file for a drawing recording.\n" }; this.NSGetFactory = XPCOMUtils.generateNSGetFactory([RecordingCmdLineHandler]); -- cgit v1.2.3 From b736f53a13af48de08026b7c7e64275122af66e2 Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Thu, 17 Aug 2017 20:27:14 +0200 Subject: SVG - support radialGradient fr attribute --- layout/reftests/svg/radialGradient-fr-01.svg | 27 +++++++++++++++++++++++ layout/reftests/svg/radialGradient-fr-02-ref.svg | 28 ++++++++++++++++++++++++ layout/reftests/svg/radialGradient-fr-02.svg | 27 +++++++++++++++++++++++ layout/reftests/svg/reftest.list | 2 ++ layout/svg/nsSVGGradientFrame.cpp | 5 +++-- 5 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 layout/reftests/svg/radialGradient-fr-01.svg create mode 100644 layout/reftests/svg/radialGradient-fr-02-ref.svg create mode 100644 layout/reftests/svg/radialGradient-fr-02.svg (limited to 'layout') diff --git a/layout/reftests/svg/radialGradient-fr-01.svg b/layout/reftests/svg/radialGradient-fr-01.svg new file mode 100644 index 000000000..2f28d3aba --- /dev/null +++ b/layout/reftests/svg/radialGradient-fr-01.svg @@ -0,0 +1,27 @@ + + + Test gradient fr attribute + + + + + + + + + + + + + + + diff --git a/layout/reftests/svg/radialGradient-fr-02-ref.svg b/layout/reftests/svg/radialGradient-fr-02-ref.svg new file mode 100644 index 000000000..c256f72a2 --- /dev/null +++ b/layout/reftests/svg/radialGradient-fr-02-ref.svg @@ -0,0 +1,28 @@ + + + Test gradient fr attribute + + + + + + + + + + + + + + diff --git a/layout/reftests/svg/radialGradient-fr-02.svg b/layout/reftests/svg/radialGradient-fr-02.svg new file mode 100644 index 000000000..1933203be --- /dev/null +++ b/layout/reftests/svg/radialGradient-fr-02.svg @@ -0,0 +1,27 @@ + + + Test gradient fr attribute + + + + + + + + + + + + + diff --git a/layout/reftests/svg/reftest.list b/layout/reftests/svg/reftest.list index e596feae8..520adc9e6 100644 --- a/layout/reftests/svg/reftest.list +++ b/layout/reftests/svg/reftest.list @@ -290,6 +290,8 @@ fuzzy-if(skiaContent,3,5) == pattern-scale-01c.svg pattern-scale-01-ref.svg == radialGradient-basic-02.svg pass.svg fuzzy-if(cocoaWidget,4,15982) fuzzy-if(winWidget,4,92) fuzzy-if(skiaContent,4,60) == radialGradient-basic-03.svg radialGradient-basic-03-ref.svg == radialGradient-basic-04.svg pass.svg +== radialGradient-fr-01.svg pass.svg +fuzzy(1,3235) fuzzy-if(winWidget,1,6704) == radialGradient-fr-02.svg radialGradient-fr-02-ref.svg fuzzy-if(skiaContent,1,3600) == rect-01.svg pass.svg == rect-02.svg pass.svg == rect-03.svg pass.svg diff --git a/layout/svg/nsSVGGradientFrame.cpp b/layout/svg/nsSVGGradientFrame.cpp index 217ab8c4a..2d7684f5a 100644 --- a/layout/svg/nsSVGGradientFrame.cpp +++ b/layout/svg/nsSVGGradientFrame.cpp @@ -623,7 +623,7 @@ nsSVGRadialGradientFrame::GradientVectorLengthIsZero() already_AddRefed nsSVGRadialGradientFrame::CreateGradient() { - float cx, cy, r, fx, fy; + float cx, cy, r, fx, fy, fr; cx = GetLengthValue(dom::SVGRadialGradientElement::ATTR_CX); cy = GetLengthValue(dom::SVGRadialGradientElement::ATTR_CY); @@ -631,6 +631,7 @@ nsSVGRadialGradientFrame::CreateGradient() // If fx or fy are not set, use cx/cy instead fx = GetLengthValue(dom::SVGRadialGradientElement::ATTR_FX, cx); fy = GetLengthValue(dom::SVGRadialGradientElement::ATTR_FY, cy); + fr = GetLengthValue(dom::SVGRadialGradientElement::ATTR_FR); if (fx != cx || fy != cy) { // The focal point (fFx and fFy) must be clamped to be *inside* - not on - @@ -651,7 +652,7 @@ nsSVGRadialGradientFrame::CreateGradient() } } - RefPtr pattern = new gfxPattern(fx, fy, 0, cx, cy, r); + RefPtr pattern = new gfxPattern(fx, fy, fr, cx, cy, r); return pattern.forget(); } -- cgit v1.2.3 From 017797de494cffd76e31e62dbec3234ecabfb75b Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Thu, 17 Aug 2017 20:30:45 +0200 Subject: CSS - Grid - fit-content unexpectedly reserves space for full clamp size in repeat() --- layout/style/nsCSSParser.cpp | 4 ++++ layout/style/test/property_database.js | 5 +++++ 2 files changed, 9 insertions(+) (limited to 'layout') diff --git a/layout/style/nsCSSParser.cpp b/layout/style/nsCSSParser.cpp index 1108ce5b5..cd996230e 100644 --- a/layout/style/nsCSSParser.cpp +++ b/layout/style/nsCSSParser.cpp @@ -8918,6 +8918,10 @@ CSSParserImpl::ParseGridTrackSize(nsCSSValue& aValue, return CSSParseResult::NotFound; } if (mToken.mIdent.LowerCaseEqualsLiteral("fit-content")) { + if (requireFixedSize) { + UngetToken(); + return CSSParseResult::Error; + } nsCSSValue::Array* func = aValue.InitFunction(eCSSKeyword_fit_content, 1); if (ParseGridTrackBreadth(func->Item(1)) == CSSParseResult::Ok && func->Item(1).IsLengthPercentCalcUnit() && diff --git a/layout/style/test/property_database.js b/layout/style/test/property_database.js index 9c69e7d10..4389d0cd0 100644 --- a/layout/style/test/property_database.js +++ b/layout/style/test/property_database.js @@ -6270,6 +6270,7 @@ if (IsCSSPropertyPrefEnabled("layout.css.grid.enabled")) { "repeat(auto-fill,minmax(1%,auto))", "repeat(auto-fill,minmax(1em,min-content)) minmax(min-content,0)", "repeat(auto-fill,minmax(max-content,1mm))", + "repeat(2, fit-content(1px))", "fit-content(1px) 1fr", "[a] fit-content(calc(1px - 99%)) [b]", "[a] fit-content(10%) [b c] fit-content(1em)", @@ -6314,6 +6315,8 @@ if (IsCSSPropertyPrefEnabled("layout.css.grid.enabled")) { "repeat(1, repeat(1, 20px))", "repeat(auto-fill, auto)", "repeat(auto-fit,auto)", + "repeat(auto-fill, fit-content(1px))", + "repeat(auto-fit, fit-content(1px))", "repeat(auto-fit,[])", "repeat(auto-fill, 0) repeat(auto-fit, 0) ", "repeat(auto-fit, 0) repeat(auto-fill, 0) ", @@ -6335,6 +6338,8 @@ if (IsCSSPropertyPrefEnabled("layout.css.grid.enabled")) { "fit-content(-1px)", "fit-content(auto)", "fit-content(min-content)", + "fit-content(1px) repeat(auto-fit, 1px)", + "fit-content(1px) repeat(auto-fill, 1px)", ], unbalanced_values: [ "(foo] 40px", -- cgit v1.2.3 From 505edf1ba4f6907c236b4876eefea606fa7b9cd0 Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Thu, 17 Aug 2017 20:34:01 +0200 Subject: [draft] CSS - linear-gradient - zero (0) angle value without degree unit is not correctly interpreted --- layout/style/nsCSSParser.cpp | 3 ++- layout/style/test/property_database.js | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'layout') diff --git a/layout/style/nsCSSParser.cpp b/layout/style/nsCSSParser.cpp index cd996230e..b361cf0c2 100644 --- a/layout/style/nsCSSParser.cpp +++ b/layout/style/nsCSSParser.cpp @@ -10404,7 +10404,8 @@ CSSParserImpl::ParseLinearGradient(nsCSSValue& aValue, UngetToken(); // , - if (ParseSingleTokenVariant(cssGradient->mAngle, VARIANT_ANGLE, nullptr) && + if (ParseSingleTokenVariant(cssGradient->mAngle, + VARIANT_ANGLE_OR_ZERO, nullptr) && !ExpectSymbol(',', true)) { SkipUntil(')'); return false; diff --git a/layout/style/test/property_database.js b/layout/style/test/property_database.js index 4389d0cd0..62d413d98 100644 --- a/layout/style/test/property_database.js +++ b/layout/style/test/property_database.js @@ -132,6 +132,9 @@ var validGradientAndElementValues = [ "linear-gradient(to right bottom, red, 50%, green 50%, 50%, blue)", "linear-gradient(to right bottom, red, 0%, green 50%, 100%, blue)", + /* Unitless 0 is valid as an */ + "linear-gradient(0, red, blue)", + "-moz-linear-gradient(red, blue)", "-moz-linear-gradient(red, yellow, blue)", "-moz-linear-gradient(red 1px, yellow 20%, blue 24em, green)", @@ -388,10 +391,8 @@ var invalidGradientAndElementValues = [ "-moz-linear-gradient(10 10px -45deg, red, blue) repeat", "-moz-linear-gradient(10px 10 -45deg, red, blue) repeat", "linear-gradient(red -99, yellow, green, blue 120%)", - /* Unitless 0 is invalid as an */ - "-moz-linear-gradient(top left 0, red, blue)", - "-moz-linear-gradient(5px 5px 0, red, blue)", - "linear-gradient(0, red, blue)", + /* Unitless nonzero numbers are valid as an */ + "linear-gradient(30, red, blue)", /* Invalid color, calc() or -moz-image-rect() function */ "linear-gradient(red, rgb(0, rubbish, 0) 50%, red)", "linear-gradient(red, red calc(50% + rubbish), red)", -- cgit v1.2.3 From 920519e7c56a08f743e5230e8db30f635f5f7cf5 Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Thu, 17 Aug 2017 20:46:41 +0200 Subject: CSS - Grid - intristic content with overflow:auto overlaps in grid --- layout/generic/ReflowInput.cpp | 12 +++ layout/generic/ReflowInput.h | 4 + layout/generic/nsFrame.cpp | 2 +- layout/generic/nsGridContainerFrame.cpp | 41 +++++++--- layout/generic/nsIFrame.h | 8 ++ .../grid-item-overflow-stretch-001-ref.html | 78 +++++++++++++++++++ .../css-grid/grid-item-overflow-stretch-001.html | 74 ++++++++++++++++++ .../grid-item-overflow-stretch-002-ref.html | 79 +++++++++++++++++++ .../css-grid/grid-item-overflow-stretch-002.html | 75 ++++++++++++++++++ .../grid-item-overflow-stretch-003-ref.html | 84 +++++++++++++++++++++ .../css-grid/grid-item-overflow-stretch-003.html | 75 ++++++++++++++++++ .../grid-item-overflow-stretch-004-ref.html | 88 ++++++++++++++++++++++ .../css-grid/grid-item-overflow-stretch-004.html | 82 ++++++++++++++++++++ .../grid-item-overflow-stretch-005-ref.html | 83 ++++++++++++++++++++ .../css-grid/grid-item-overflow-stretch-005.html | 77 +++++++++++++++++++ .../grid-item-overflow-stretch-006-ref.html | 54 +++++++++++++ .../css-grid/grid-item-overflow-stretch-006.html | 56 ++++++++++++++ layout/reftests/css-grid/reftest.list | 6 ++ 18 files changed, 965 insertions(+), 13 deletions(-) create mode 100644 layout/reftests/css-grid/grid-item-overflow-stretch-001-ref.html create mode 100644 layout/reftests/css-grid/grid-item-overflow-stretch-001.html create mode 100644 layout/reftests/css-grid/grid-item-overflow-stretch-002-ref.html create mode 100644 layout/reftests/css-grid/grid-item-overflow-stretch-002.html create mode 100644 layout/reftests/css-grid/grid-item-overflow-stretch-003-ref.html create mode 100644 layout/reftests/css-grid/grid-item-overflow-stretch-003.html create mode 100644 layout/reftests/css-grid/grid-item-overflow-stretch-004-ref.html create mode 100644 layout/reftests/css-grid/grid-item-overflow-stretch-004.html create mode 100644 layout/reftests/css-grid/grid-item-overflow-stretch-005-ref.html create mode 100644 layout/reftests/css-grid/grid-item-overflow-stretch-005.html create mode 100644 layout/reftests/css-grid/grid-item-overflow-stretch-006-ref.html create mode 100644 layout/reftests/css-grid/grid-item-overflow-stretch-006.html (limited to 'layout') diff --git a/layout/generic/ReflowInput.cpp b/layout/generic/ReflowInput.cpp index 42f4a24b5..a8756cea2 100644 --- a/layout/generic/ReflowInput.cpp +++ b/layout/generic/ReflowInput.cpp @@ -93,6 +93,9 @@ ReflowInput::ReflowInput(nsPresContext* aPresContext, if (aFlags & B_CLAMP_MARGIN_BOX_MIN_SIZE) { mFlags.mBClampMarginBoxMinSize = true; } + if (aFlags & I_APPLY_AUTO_MIN_SIZE) { + mFlags.mApplyAutoMinSize = true; + } if (!(aFlags & CALLER_WILL_INIT)) { Init(aPresContext); @@ -242,6 +245,7 @@ ReflowInput::ReflowInput( mFlags.mIOffsetsNeedCSSAlign = mFlags.mBOffsetsNeedCSSAlign = false; mFlags.mIClampMarginBoxMinSize = !!(aFlags & I_CLAMP_MARGIN_BOX_MIN_SIZE); mFlags.mBClampMarginBoxMinSize = !!(aFlags & B_CLAMP_MARGIN_BOX_MIN_SIZE); + mFlags.mApplyAutoMinSize = !!(aFlags & I_APPLY_AUTO_MIN_SIZE); mDiscoveredClearance = nullptr; mPercentBSizeObserver = (aParentReflowInput.mPercentBSizeObserver && @@ -1662,6 +1666,10 @@ ReflowInput::InitAbsoluteConstraints(nsPresContext* aPresContext, computeSizeFlags = ComputeSizeFlags(computeSizeFlags | ComputeSizeFlags::eBClampMarginBoxMinSize); } + if (mFlags.mApplyAutoMinSize) { + computeSizeFlags = ComputeSizeFlags(computeSizeFlags | + ComputeSizeFlags::eIApplyAutoMinSize); + } if (mFlags.mShrinkWrap) { computeSizeFlags = ComputeSizeFlags(computeSizeFlags | ComputeSizeFlags::eShrinkWrap); @@ -2375,6 +2383,10 @@ ReflowInput::InitConstraints(nsPresContext* aPresContext, computeSizeFlags = ComputeSizeFlags(computeSizeFlags | ComputeSizeFlags::eBClampMarginBoxMinSize); } + if (mFlags.mApplyAutoMinSize) { + computeSizeFlags = ComputeSizeFlags(computeSizeFlags | + ComputeSizeFlags::eIApplyAutoMinSize); + } if (mFlags.mShrinkWrap) { computeSizeFlags = ComputeSizeFlags(computeSizeFlags | ComputeSizeFlags::eShrinkWrap); diff --git a/layout/generic/ReflowInput.h b/layout/generic/ReflowInput.h index e42508646..09c980b72 100644 --- a/layout/generic/ReflowInput.h +++ b/layout/generic/ReflowInput.h @@ -220,6 +220,7 @@ public: uint32_t mStaticPosIsCBOrigin:1; // the STATIC_POS_IS_CB_ORIGIN ctor flag uint32_t mIClampMarginBoxMinSize:1; // the I_CLAMP_MARGIN_BOX_MIN_SIZE ctor flag uint32_t mBClampMarginBoxMinSize:1; // the B_CLAMP_MARGIN_BOX_MIN_SIZE ctor flag + uint32_t mApplyAutoMinSize : 1; // the I_APPLY_AUTO_MIN_SIZE ctor flag // If set, the following two flags indicate that: // (1) this frame is absolutely-positioned (or fixed-positioned). @@ -738,6 +739,9 @@ public: // Pass ComputeSizeFlags::eBClampMarginBoxMinSize to ComputeSize(). B_CLAMP_MARGIN_BOX_MIN_SIZE = (1<<6), + + // Pass ComputeSizeFlags::eIApplyAutoMinSize to ComputeSize(). + I_APPLY_AUTO_MIN_SIZE = (1<<7), }; // This method initializes various data members. It is automatically diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index 69791d5c5..418fa16b7 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -4781,7 +4781,7 @@ nsFrame::ComputeSize(nsRenderingContext* aRenderingContext, ComputeISizeValue(aRenderingContext, aCBSize.ISize(aWM), boxSizingAdjust.ISize(aWM), boxSizingToMarginEdgeISize, minISizeCoord, aFlags); - } else if (MOZ_UNLIKELY(isGridItem)) { + } else if (MOZ_UNLIKELY(aFlags & eIApplyAutoMinSize)) { // This implements "Implied Minimum Size of Grid Items". // https://drafts.csswg.org/css-grid/#min-size-auto minISize = std::min(maxISize, GetMinISize(aRenderingContext)); diff --git a/layout/generic/nsGridContainerFrame.cpp b/layout/generic/nsGridContainerFrame.cpp index 71d5bba21..f3e28acc4 100644 --- a/layout/generic/nsGridContainerFrame.cpp +++ b/layout/generic/nsGridContainerFrame.cpp @@ -818,8 +818,11 @@ struct nsGridContainerFrame::GridItemInfo // Ditto *-content:[last ]baseline. Mutually exclusive w. eSelfBaseline. eContentBaseline = 0x10, eAllBaselineBits = eIsBaselineAligned | eSelfBaseline | eContentBaseline, + // Should apply Automatic Minimum Size per: + // https://drafts.csswg.org/css-grid/#min-size-auto + eApplyAutoMinSize = 0x20, // Clamp per https://drafts.csswg.org/css-grid/#min-size-auto - eClampMarginBoxMinSize = 0x20, + eClampMarginBoxMinSize = 0x40, }; explicit GridItemInfo(nsIFrame* aFrame, @@ -851,11 +854,11 @@ struct nsGridContainerFrame::GridItemInfo return aAlign; } - // Return true if we should we clamp this item's Automatic Minimum Size. + // Return true if we should apply Automatic Minimum Size to this item. // https://drafts.csswg.org/css-grid/#min-size-auto - bool ShouldClampMinSize(WritingMode aContainerWM, - LogicalAxis aContainerAxis, - nscoord aPercentageBasis) const + bool ShouldApplyAutoMinSize(WritingMode aContainerWM, + LogicalAxis aContainerAxis, + nscoord aPercentageBasis) const { const auto pos = mFrame->StylePosition(); const auto& size = aContainerAxis == eLogicalAxisInline ? @@ -3977,9 +3980,9 @@ nsGridContainerFrame::Tracks::ResolveIntrinsicSizeStep1( WritingMode wm = aState.mWM; // Calculate data for "Automatic Minimum Size" clamping, if needed. bool needed = ((sz.mState & TrackSize::eIntrinsicMinSizing) || - aConstraint == SizingConstraint::eNoConstraint); - if (needed && TrackSize::IsDefiniteMaxSizing(sz.mState) && - aGridItem.ShouldClampMinSize(wm, mAxis, aPercentageBasis)) { + aConstraint == SizingConstraint::eNoConstraint) && + (aGridItem.mState[mAxis] & ItemState::eApplyAutoMinSize); + if (needed && TrackSize::IsDefiniteMaxSizing(sz.mState)) { if (sz.mState & TrackSize::eIntrinsicMinSizing) { auto maxCoord = aFunctions.MaxSizingFor(aRange.mStart); cache.mMinSizeClamp = @@ -4382,6 +4385,14 @@ nsGridContainerFrame::Tracks::ResolveIntrinsicSize( iter.Reset(); for (; !iter.AtEnd(); iter.Next()) { auto& gridItem = aGridItems[iter.GridItemIndex()]; + + // Check if we need to apply "Automatic Minimum Size" and cache it. + MOZ_ASSERT(!(gridItem.mState[mAxis] & ItemState::eApplyAutoMinSize), + "Why is eApplyAutoMinSize set already?"); + if (gridItem.ShouldApplyAutoMinSize(wm, mAxis, aPercentageBasis)) { + gridItem.mState[mAxis] |= ItemState::eApplyAutoMinSize; + } + const GridArea& area = gridItem.mArea; const LineRange& lineRange = area.*aRange; uint32_t span = lineRange.Extent(); @@ -4407,9 +4418,9 @@ nsGridContainerFrame::Tracks::ResolveIntrinsicSize( CachedIntrinsicSizes cache; // Calculate data for "Automatic Minimum Size" clamping, if needed. bool needed = ((state & TrackSize::eIntrinsicMinSizing) || - aConstraint == SizingConstraint::eNoConstraint); - if (needed && TrackSize::IsDefiniteMaxSizing(state) && - gridItem.ShouldClampMinSize(wm, mAxis, aPercentageBasis)) { + aConstraint == SizingConstraint::eNoConstraint) && + (gridItem.mState[mAxis] & ItemState::eApplyAutoMinSize); + if (needed && TrackSize::IsDefiniteMaxSizing(state)) { nscoord minSizeClamp = 0; for (auto i = lineRange.mStart, end = lineRange.mEnd; i < end; ++i) { auto maxCoord = aFunctions.MaxSizingFor(i); @@ -4445,11 +4456,14 @@ nsGridContainerFrame::Tracks::ResolveIntrinsicSize( gridItem.mState[mAxis] |= ItemState::eIsFlexing; } else if (aConstraint == SizingConstraint::eNoConstraint && TrackSize::IsDefiniteMaxSizing(state) && - gridItem.ShouldClampMinSize(wm, mAxis, aPercentageBasis)) { + (gridItem.mState[mAxis] & ItemState::eApplyAutoMinSize)) { gridItem.mState[mAxis] |= ItemState::eClampMarginBoxMinSize; } } } + MOZ_ASSERT(!(gridItem.mState[mAxis] & ItemState::eClampMarginBoxMinSize) || + (gridItem.mState[mAxis] & ItemState::eApplyAutoMinSize), + "clamping only applies to Automatic Minimum Size"); } // Step 2. @@ -5231,6 +5245,9 @@ nsGridContainerFrame::ReflowInFlowChild(nsIFrame* aChild, } else { aChild->Properties().Delete(BClampMarginBoxMinSizeProperty()); } + if ((aGridItemInfo->mState[childIAxis] & ItemState::eApplyAutoMinSize)) { + flags |= ReflowInput::I_APPLY_AUTO_MIN_SIZE; + } } if (!isConstrainedBSize) { diff --git a/layout/generic/nsIFrame.h b/layout/generic/nsIFrame.h index 50eb958e0..2acafa882 100644 --- a/layout/generic/nsIFrame.h +++ b/layout/generic/nsIFrame.h @@ -2105,6 +2105,14 @@ public: */ eIClampMarginBoxMinSize = 1 << 2, // clamp in our inline axis eBClampMarginBoxMinSize = 1 << 3, // clamp in our block axis + /** + * The frame is stretching (per CSS Box Alignment) and doesn't have an + * Automatic Minimum Size in the indicated axis. + * (may be used for both flex/grid items, but currently only used for Grid) + * https://drafts.csswg.org/css-grid/#min-size-auto + * https://drafts.csswg.org/css-align-3/#valdef-justify-self-stretch + */ + eIApplyAutoMinSize = 1 << 4, // only has an effect when eShrinkWrap is false }; /** diff --git a/layout/reftests/css-grid/grid-item-overflow-stretch-001-ref.html b/layout/reftests/css-grid/grid-item-overflow-stretch-001-ref.html new file mode 100644 index 000000000..463bbb4e6 --- /dev/null +++ b/layout/reftests/css-grid/grid-item-overflow-stretch-001-ref.html @@ -0,0 +1,78 @@ + + + + + CSS Grid Reference: stretching overflow!=visible items + + + + + +
+
+
+
+ +
+ +
+
+
+
+ +
+ +
+ +
+
+
+
+ +
+ +
+
+
+
+ +
+ +
+ + + diff --git a/layout/reftests/css-grid/grid-item-overflow-stretch-001.html b/layout/reftests/css-grid/grid-item-overflow-stretch-001.html new file mode 100644 index 000000000..4f6259abe --- /dev/null +++ b/layout/reftests/css-grid/grid-item-overflow-stretch-001.html @@ -0,0 +1,74 @@ + + + + + CSS Grid Test: stretching overflow!=visible items + + + + + + +
+
+
+
+ +
+ +
+
+
+
+ +
+ +
+ +
+
+
+
+ +
+ +
+
+
+
+ +
+ +
+ + + diff --git a/layout/reftests/css-grid/grid-item-overflow-stretch-002-ref.html b/layout/reftests/css-grid/grid-item-overflow-stretch-002-ref.html new file mode 100644 index 000000000..a9690a54e --- /dev/null +++ b/layout/reftests/css-grid/grid-item-overflow-stretch-002-ref.html @@ -0,0 +1,79 @@ + + + + + CSS Grid Reference: stretching overflow!=visible vertical-rl items + + + + + +
+
+
+
+ +
+ +
+
+
+
+ +
+ +
+ +
+
+
+
+ +
+ +
+
+
+
+ +
+ +
+ + + diff --git a/layout/reftests/css-grid/grid-item-overflow-stretch-002.html b/layout/reftests/css-grid/grid-item-overflow-stretch-002.html new file mode 100644 index 000000000..520eed911 --- /dev/null +++ b/layout/reftests/css-grid/grid-item-overflow-stretch-002.html @@ -0,0 +1,75 @@ + + + + + CSS Grid Test: stretching overflow!=visible vertical-rl items + + + + + + +
+
+
+
+ +
+ +
+
+
+
+ +
+ +
+ +
+
+
+
+ +
+ +
+
+
+
+ +
+ +
+ + + diff --git a/layout/reftests/css-grid/grid-item-overflow-stretch-003-ref.html b/layout/reftests/css-grid/grid-item-overflow-stretch-003-ref.html new file mode 100644 index 000000000..c082e6be4 --- /dev/null +++ b/layout/reftests/css-grid/grid-item-overflow-stretch-003-ref.html @@ -0,0 +1,84 @@ + + + + + CSS Grid Reference: margin:auto stretch items + + + + + +
+
+
+
+ +
+ +
+
+
+
+ +
+ +
+ +
+
+
+
+ +
+ +
+
+
+
+ +
+ +
+ + + diff --git a/layout/reftests/css-grid/grid-item-overflow-stretch-003.html b/layout/reftests/css-grid/grid-item-overflow-stretch-003.html new file mode 100644 index 000000000..8bcd79d9b --- /dev/null +++ b/layout/reftests/css-grid/grid-item-overflow-stretch-003.html @@ -0,0 +1,75 @@ + + + + + CSS Grid Test: margin:auto stretch items + + + + + + +
+
+
+
+ +
+ +
+
+
+
+ +
+ +
+ +
+
+
+
+ +
+ +
+
+
+
+ +
+ +
+ + + diff --git a/layout/reftests/css-grid/grid-item-overflow-stretch-004-ref.html b/layout/reftests/css-grid/grid-item-overflow-stretch-004-ref.html new file mode 100644 index 000000000..71ed28d7c --- /dev/null +++ b/layout/reftests/css-grid/grid-item-overflow-stretch-004-ref.html @@ -0,0 +1,88 @@ + + + + + CSS Grid Reference: stretching items + + + + + +
+
+
+
+ +
+ +
+
+
+
+ +
+ +
+ +
+
+
+
+ +
+ +
+
+
+
+ +
+ +
+ + + diff --git a/layout/reftests/css-grid/grid-item-overflow-stretch-004.html b/layout/reftests/css-grid/grid-item-overflow-stretch-004.html new file mode 100644 index 000000000..b983b5184 --- /dev/null +++ b/layout/reftests/css-grid/grid-item-overflow-stretch-004.html @@ -0,0 +1,82 @@ + + + + + CSS Grid Test: stretching items + + + + + + +
+
+
+
+ +
+ +
+
+
+
+ +
+ +
+ +
+
+
+
+ +
+ +
+
+
+
+ +
+ +
+ + + diff --git a/layout/reftests/css-grid/grid-item-overflow-stretch-005-ref.html b/layout/reftests/css-grid/grid-item-overflow-stretch-005-ref.html new file mode 100644 index 000000000..e7d353c8b --- /dev/null +++ b/layout/reftests/css-grid/grid-item-overflow-stretch-005-ref.html @@ -0,0 +1,83 @@ + + + + + CSS Grid Reference: stretching overflow!=visible items + + + + + +
+
+
+
+ +
+ +
+
+
+
+ +
+ +
+ +
+
+
+
+ +
+ +
+
+
+
+ +
+ +
+ + + diff --git a/layout/reftests/css-grid/grid-item-overflow-stretch-005.html b/layout/reftests/css-grid/grid-item-overflow-stretch-005.html new file mode 100644 index 000000000..33fe468d7 --- /dev/null +++ b/layout/reftests/css-grid/grid-item-overflow-stretch-005.html @@ -0,0 +1,77 @@ + + + + + CSS Grid Test: stretching overflow!=visible items + + + + + + +
+
+
+
+ +
+ +
+
+
+
+ +
+ +
+ +
+
+
+
+ +
+ +
+
+
+
+ +
+ +
+ + + diff --git a/layout/reftests/css-grid/grid-item-overflow-stretch-006-ref.html b/layout/reftests/css-grid/grid-item-overflow-stretch-006-ref.html new file mode 100644 index 000000000..71d4d4f54 --- /dev/null +++ b/layout/reftests/css-grid/grid-item-overflow-stretch-006-ref.html @@ -0,0 +1,54 @@ + + + + + CSS Grid Reference: stretching overflow visible items + + + + + +
+
+
+ +
+ +
+ +
+
+
+ +
+ +
+ + + diff --git a/layout/reftests/css-grid/grid-item-overflow-stretch-006.html b/layout/reftests/css-grid/grid-item-overflow-stretch-006.html new file mode 100644 index 000000000..015c50fcc --- /dev/null +++ b/layout/reftests/css-grid/grid-item-overflow-stretch-006.html @@ -0,0 +1,56 @@ + + + + + CSS Grid Test: stretching overflow visible items + + + + + + +
+
+
+ +
+ +
+ +
+
+
+ +
+ +
+ + + diff --git a/layout/reftests/css-grid/reftest.list b/layout/reftests/css-grid/reftest.list index d85eefbd0..093e2faee 100644 --- a/layout/reftests/css-grid/reftest.list +++ b/layout/reftests/css-grid/reftest.list @@ -116,6 +116,12 @@ skip-if(Android) == grid-auto-min-sizing-percent-001.html grid-auto-min-sizing-p == grid-item-auto-min-size-clamp-005.html grid-item-auto-min-size-clamp-005-ref.html == grid-item-auto-min-size-clamp-006.html grid-item-auto-min-size-clamp-006-ref.html == grid-item-auto-min-size-clamp-007.html grid-item-auto-min-size-clamp-007-ref.html +== grid-item-overflow-stretch-001.html grid-item-overflow-stretch-001-ref.html +== grid-item-overflow-stretch-002.html grid-item-overflow-stretch-002-ref.html +== grid-item-overflow-stretch-003.html grid-item-overflow-stretch-003-ref.html +== grid-item-overflow-stretch-004.html grid-item-overflow-stretch-004-ref.html +== grid-item-overflow-stretch-005.html grid-item-overflow-stretch-005-ref.html +== grid-item-overflow-stretch-006.html grid-item-overflow-stretch-006-ref.html == grid-item-canvas-001.html grid-item-canvas-001-ref.html skip-if(Android) == grid-item-button-001.html grid-item-button-001-ref.html == grid-item-table-stretch-001.html grid-item-table-stretch-001-ref.html -- cgit v1.2.3 From 76e1c016a32cb8cee6f5a0a0012fe512570da1eb Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Thu, 17 Aug 2017 20:56:20 +0200 Subject: CSS - Grid - transferred min-size contribution of percentage size grid item with an intrinsic ratio --- layout/base/nsLayoutUtils.cpp | 151 ++++++++++++++++++--- layout/base/nsLayoutUtils.h | 5 + layout/generic/nsGridContainerFrame.cpp | 68 ++++++++-- ...to-min-sizing-min-content-min-size-004-ref.html | 2 +- ...d-auto-min-sizing-transferred-size-004-ref.html | 2 +- ...ontent-min-sizing-transferred-size-004-ref.html | 2 +- 6 files changed, 199 insertions(+), 31 deletions(-) (limited to 'layout') diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 789c91f50..c8c91b251 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -4637,6 +4637,63 @@ GetPercentBSize(const nsStyleCoord& aStyle, return true; } +// Return true if aStyle can be resolved to a definite value and if so +// return that value in aResult. +static bool +GetDefiniteSize(const nsStyleCoord& aStyle, + nsIFrame* aFrame, + bool aIsInlineAxis, + const Maybe& aPercentageBasis, + nscoord* aResult) +{ + switch (aStyle.GetUnit()) { + case eStyleUnit_Coord: + *aResult = aStyle.GetCoordValue(); + return true; + case eStyleUnit_Percent: { + if (aPercentageBasis.isNothing()) { + return false; + } + auto wm = aFrame->GetWritingMode(); + nscoord pb = aIsInlineAxis ? aPercentageBasis.value().ISize(wm) + : aPercentageBasis.value().BSize(wm); + if (pb != NS_UNCONSTRAINEDSIZE) { + nscoord p = NSToCoordFloorClamped(pb * aStyle.GetPercentValue()); + *aResult = std::max(nscoord(0), p); + return true; + } + return false; + } + case eStyleUnit_Calc: { + nsStyleCoord::Calc* calc = aStyle.GetCalcValue(); + if (calc->mPercent != 0.0f) { + if (aPercentageBasis.isNothing()) { + return false; + } + auto wm = aFrame->GetWritingMode(); + nscoord pb = aIsInlineAxis ? aPercentageBasis.value().ISize(wm) + : aPercentageBasis.value().BSize(wm); + if (pb == NS_UNCONSTRAINEDSIZE) { + // XXXmats given that we're calculating an intrinsic size here, + // maybe we should back-compute the calc-size using AddPercents? + return false; + } + *aResult = std::max(0, calc->mLength + + NSToCoordFloorClamped(pb * calc->mPercent)); + } else { + *aResult = std::max(0, calc->mLength); + } + return true; + } + default: + return false; + } +} + +// +// NOTE: this function will be replaced by GetDefiniteSizeTakenByBoxSizing (bug 1363918). +// Please do not add new uses of this function. +// // Get the amount of vertical space taken out of aFrame's content area due to // its borders and paddings given the box-sizing value in aBoxSizing. We don't // get aBoxSizing from the frame because some callers want to compute this for @@ -4681,6 +4738,54 @@ GetBSizeTakenByBoxSizing(StyleBoxSizing aBoxSizing, return bSizeTakenByBoxSizing; } +// Get the amount of space taken out of aFrame's content area due to its +// borders and paddings given the box-sizing value in aBoxSizing. We don't +// get aBoxSizing from the frame because some callers want to compute this for +// specific box-sizing values. +// aIsInlineAxis is true if we're computing for aFrame's inline axis. +// aIgnorePadding is true if padding should be ignored. +static nscoord +GetDefiniteSizeTakenByBoxSizing(StyleBoxSizing aBoxSizing, + nsIFrame* aFrame, + bool aIsInlineAxis, + bool aIgnorePadding, + const Maybe& aPercentageBasis) +{ + nscoord sizeTakenByBoxSizing = 0; + if (MOZ_UNLIKELY(aBoxSizing == StyleBoxSizing::Border)) { + const bool isHorizontalAxis = + aIsInlineAxis == !aFrame->GetWritingMode().IsVertical(); + const nsStyleBorder* styleBorder = aFrame->StyleBorder(); + sizeTakenByBoxSizing = + isHorizontalAxis ? styleBorder->GetComputedBorder().LeftRight() + : styleBorder->GetComputedBorder().TopBottom(); + if (!aIgnorePadding) { + const nsStyleSides& stylePadding = aFrame->StylePadding()->mPadding; + const nsStyleCoord& pStart = + stylePadding.Get(isHorizontalAxis ? eSideLeft : eSideTop); + const nsStyleCoord& pEnd = + stylePadding.Get(isHorizontalAxis ? eSideRight : eSideBottom); + nscoord pad; + // XXXbz Calling GetPercentBSize on padding values looks bogus, since + // percent padding is always a percentage of the inline-size of the + // containing block. We should perhaps just treat non-absolute paddings + // here as 0 instead, except that in some cases the width may in fact be + // known. See bug 1231059. + if (GetDefiniteSize(pStart, aFrame, aIsInlineAxis, aPercentageBasis, &pad) || + (aPercentageBasis.isNothing() && + GetPercentBSize(pStart, aFrame, isHorizontalAxis, pad))) { + sizeTakenByBoxSizing += pad; + } + if (GetDefiniteSize(pEnd, aFrame, aIsInlineAxis, aPercentageBasis, &pad) || + (aPercentageBasis.isNothing() && + GetPercentBSize(pEnd, aFrame, isHorizontalAxis, pad))) { + sizeTakenByBoxSizing += pad; + } + } + } + return sizeTakenByBoxSizing; +} + // Handles only -moz-max-content and -moz-min-content, and // -moz-fit-content for min-width and max-width, since the others // (-moz-fit-content for width, and -moz-available) have no effect on @@ -4940,17 +5045,21 @@ AddStateBitToAncestors(nsIFrame* aFrame, nsFrameState aBit) } /* static */ nscoord -nsLayoutUtils::IntrinsicForAxis(PhysicalAxis aAxis, - nsRenderingContext* aRenderingContext, - nsIFrame* aFrame, - IntrinsicISizeType aType, - uint32_t aFlags, - nscoord aMarginBoxMinSizeClamp) +nsLayoutUtils::IntrinsicForAxis(PhysicalAxis aAxis, + nsRenderingContext* aRenderingContext, + nsIFrame* aFrame, + IntrinsicISizeType aType, + const Maybe& aPercentageBasis, + uint32_t aFlags, + nscoord aMarginBoxMinSizeClamp) { NS_PRECONDITION(aFrame, "null frame"); NS_PRECONDITION(aFrame->GetParent(), "IntrinsicForAxis called on frame not in tree"); NS_PRECONDITION(aType == MIN_ISIZE || aType == PREF_ISIZE, "bad type"); + MOZ_ASSERT(aFrame->GetParent()->Type() != LayoutFrameType::GridContainer || + aPercentageBasis.isSome(), + "grid layout should always pass a percentage basis"); const bool horizontalAxis = MOZ_LIKELY(aAxis == eAxisHorizontal); #ifdef DEBUG_INTRINSIC_WIDTH @@ -5014,6 +5123,7 @@ nsLayoutUtils::IntrinsicForAxis(PhysicalAxis aAxis, PhysicalAxis ourInlineAxis = aFrame->GetWritingMode().PhysicalAxis(eLogicalAxisInline); + const bool isInlineAxis = aAxis == ourInlineAxis; // If we have a specified width (or a specified 'min-width' greater // than the specified 'max-width', which works out to the same thing), // don't even bother getting the frame's intrinsic width, because in @@ -5043,7 +5153,7 @@ nsLayoutUtils::IntrinsicForAxis(PhysicalAxis aAxis, // constraint is the max-content contribution which we shouldn't clamp. aMarginBoxMinSizeClamp = NS_MAXSIZE; } - if (MOZ_UNLIKELY(aAxis != ourInlineAxis)) { + if (MOZ_UNLIKELY(!isInlineAxis)) { IntrinsicSize intrinsicSize = aFrame->GetIntrinsicSize(); const nsStyleCoord intrinsicBCoord = horizontalAxis ? intrinsicSize.width : intrinsicSize.height; @@ -5105,21 +5215,23 @@ nsLayoutUtils::IntrinsicForAxis(PhysicalAxis aAxis, NS_FRAME_DESCENDANT_INTRINSIC_ISIZE_DEPENDS_ON_BSIZE); nscoord bSizeTakenByBoxSizing = - GetBSizeTakenByBoxSizing(boxSizing, aFrame, horizontalAxis, - aFlags & IGNORE_PADDING); - + GetDefiniteSizeTakenByBoxSizing(boxSizing, aFrame, !isInlineAxis, + aFlags & IGNORE_PADDING, + aPercentageBasis); // NOTE: This is only the minContentSize if we've been passed MIN_INTRINSIC_ISIZE // (which is fine, because this should only be used inside a check for that flag). nscoord minContentSize = result; nscoord h; - if (GetAbsoluteCoord(styleBSize, h) || - GetPercentBSize(styleBSize, aFrame, horizontalAxis, h)) { + if (GetDefiniteSize(styleBSize, aFrame, !isInlineAxis, aPercentageBasis, &h) || + (aPercentageBasis.isNothing() && + GetPercentBSize(styleBSize, aFrame, horizontalAxis, h))) { h = std::max(0, h - bSizeTakenByBoxSizing); result = NSCoordMulDiv(h, ratioISize, ratioBSize); } - if (GetAbsoluteCoord(styleMaxBSize, h) || - GetPercentBSize(styleMaxBSize, aFrame, horizontalAxis, h)) { + if (GetDefiniteSize(styleMaxBSize, aFrame, !isInlineAxis, aPercentageBasis, &h) || + (aPercentageBasis.isNothing() && + GetPercentBSize(styleMaxBSize, aFrame, horizontalAxis, h))) { h = std::max(0, h - bSizeTakenByBoxSizing); nscoord maxISize = NSCoordMulDiv(h, ratioISize, ratioBSize); if (maxISize < result) { @@ -5130,8 +5242,9 @@ nsLayoutUtils::IntrinsicForAxis(PhysicalAxis aAxis, } } - if (GetAbsoluteCoord(styleMinBSize, h) || - GetPercentBSize(styleMinBSize, aFrame, horizontalAxis, h)) { + if (GetDefiniteSize(styleMinBSize, aFrame, !isInlineAxis, aPercentageBasis, &h) || + (aPercentageBasis.isNothing() && + GetPercentBSize(styleMinBSize, aFrame, horizontalAxis, h))) { h = std::max(0, h - bSizeTakenByBoxSizing); nscoord minISize = NSCoordMulDiv(h, ratioISize, ratioBSize); if (minISize > result) { @@ -5158,8 +5271,8 @@ nsLayoutUtils::IntrinsicForAxis(PhysicalAxis aAxis, } nsIFrame::IntrinsicISizeOffsetData offsets = - MOZ_LIKELY(aAxis == ourInlineAxis) ? aFrame->IntrinsicISizeOffsets() - : aFrame->IntrinsicBSizeOffsets(); + MOZ_LIKELY(isInlineAxis) ? aFrame->IntrinsicISizeOffsets() + : aFrame->IntrinsicBSizeOffsets(); nscoord contentBoxSize = result; result = AddIntrinsicSizeOffset(aRenderingContext, aFrame, offsets, aType, boxSizing, result, min, styleISize, @@ -5196,7 +5309,7 @@ nsLayoutUtils::IntrinsicForContainer(nsRenderingContext* aRenderingContext, // We want the size aFrame will contribute to its parent's inline-size. PhysicalAxis axis = aFrame->GetParent()->GetWritingMode().PhysicalAxis(eLogicalAxisInline); - return IntrinsicForAxis(axis, aRenderingContext, aFrame, aType, aFlags); + return IntrinsicForAxis(axis, aRenderingContext, aFrame, aType, Nothing(), aFlags); } /* static */ nscoord diff --git a/layout/base/nsLayoutUtils.h b/layout/base/nsLayoutUtils.h index d9580a3df..97fc410b0 100644 --- a/layout/base/nsLayoutUtils.h +++ b/layout/base/nsLayoutUtils.h @@ -1378,6 +1378,10 @@ public: * width, its 'width', 'min-width', and 'max-width' properties (or 'height' * variations if that's what matches aAxis) and its padding, border and margin * in the corresponding dimension. + * @param aPercentageBasis an optional percentage basis (in aFrame's WM). + * Pass NS_UNCONSTRAINEDSIZE if the basis is indefinite in either/both axes. + * If you pass Nothing() a percentage basis will be calculated from aFrame's + * ancestors' computed size in the relevant axis, if needed. * @param aMarginBoxMinSizeClamp make the result fit within this margin-box * size by reducing the *content size* (flooring at zero). This is used for: * https://drafts.csswg.org/css-grid/#min-size-auto @@ -1396,6 +1400,7 @@ public: nsRenderingContext* aRenderingContext, nsIFrame* aFrame, IntrinsicISizeType aType, + const mozilla::Maybe& aPercentageBasis = mozilla::Nothing(), uint32_t aFlags = 0, nscoord aMarginBoxMinSizeClamp = NS_MAXSIZE); /** diff --git a/layout/generic/nsGridContainerFrame.cpp b/layout/generic/nsGridContainerFrame.cpp index f3e28acc4..8f117b5ab 100644 --- a/layout/generic/nsGridContainerFrame.cpp +++ b/layout/generic/nsGridContainerFrame.cpp @@ -2092,6 +2092,18 @@ struct MOZ_STACK_CLASS nsGridContainerFrame::GridReflowInput LogicalSize& aContentBox, SizingConstraint aConstraint); + /** + * Return the percentage basis for a grid item in its writing-mode. + * If aAxis is eLogicalAxisInline then we return NS_UNCONSTRAINEDSIZE in + * both axes since we know all track sizes are indefinite at this point + * (we calculate column sizes before row sizes). Otherwise, assert that + * column sizes are known and calculate the size for aGridItem.mArea.mCols + * and use NS_UNCONSTRAINEDSIZE in the other axis. + * @param aAxis the axis we're currently calculating track sizes for + */ + LogicalSize PercentageBasisFor(LogicalAxis aAxis, + const GridItemInfo& aGridItem) const; + /** * Return the containing block for a grid item occupying aArea. */ @@ -3734,18 +3746,20 @@ MeasuringReflow(nsIFrame* aChild, * the child's margin-box) in aAxis. */ static nscoord -ContentContribution(const GridItemInfo& aGridItem, - const GridReflowInput& aState, - nsRenderingContext* aRC, - WritingMode aCBWM, - LogicalAxis aAxis, - IntrinsicISizeType aConstraint, - nscoord aMinSizeClamp = NS_MAXSIZE, - uint32_t aFlags = 0) +ContentContribution(const GridItemInfo& aGridItem, + const GridReflowInput& aState, + nsRenderingContext* aRC, + WritingMode aCBWM, + LogicalAxis aAxis, + const Maybe& aPercentageBasis, + IntrinsicISizeType aConstraint, + nscoord aMinSizeClamp = NS_MAXSIZE, + uint32_t aFlags = 0) { nsIFrame* child = aGridItem.mFrame; PhysicalAxis axis(aCBWM.PhysicalAxis(aAxis)); nscoord size = nsLayoutUtils::IntrinsicForAxis(axis, aRC, child, aConstraint, + aPercentageBasis, aFlags | nsLayoutUtils::BAIL_IF_REFLOW_NEEDED | nsLayoutUtils::ADD_PERCENTS, aMinSizeClamp); @@ -3815,6 +3829,10 @@ struct CachedIntrinsicSizes Maybe mMinSize; Maybe mMinContentContribution; Maybe mMaxContentContribution; + + // The item's percentage basis for intrinsic sizing purposes. + Maybe mPercentageBasis; + // "if the grid item spans only grid tracks that have a fixed max track // sizing function, its automatic minimum size in that dimension is // further clamped to less than or equal to the size necessary to fit its @@ -3835,7 +3853,11 @@ MinContentContribution(const GridItemInfo& aGridItem, if (aCache->mMinContentContribution.isSome()) { return aCache->mMinContentContribution.value(); } + if (aCache->mPercentageBasis.isNothing()) { + aCache->mPercentageBasis.emplace(aState.PercentageBasisFor(aAxis, aGridItem)); + } nscoord s = ContentContribution(aGridItem, aState, aRC, aCBWM, aAxis, + aCache->mPercentageBasis, nsLayoutUtils::MIN_ISIZE, aCache->mMinSizeClamp); aCache->mMinContentContribution.emplace(s); @@ -3853,7 +3875,11 @@ MaxContentContribution(const GridItemInfo& aGridItem, if (aCache->mMaxContentContribution.isSome()) { return aCache->mMaxContentContribution.value(); } + if (aCache->mPercentageBasis.isNothing()) { + aCache->mPercentageBasis.emplace(aState.PercentageBasisFor(aAxis, aGridItem)); + } nscoord s = ContentContribution(aGridItem, aState, aRC, aCBWM, aAxis, + aCache->mPercentageBasis, nsLayoutUtils::PREF_ISIZE, aCache->mMinSizeClamp); aCache->mMaxContentContribution.emplace(s); @@ -3907,7 +3933,11 @@ MinSize(const GridItemInfo& aGridItem, child->StyleDisplay()->mOverflowX == NS_STYLE_OVERFLOW_VISIBLE)) { // Now calculate the "content size" part and return whichever is smaller. MOZ_ASSERT(unit != eStyleUnit_Enumerated || sz == NS_UNCONSTRAINEDSIZE); + if (aCache->mPercentageBasis.isNothing()) { + aCache->mPercentageBasis.emplace(aState.PercentageBasisFor(aAxis, aGridItem)); + } sz = std::min(sz, ContentContribution(aGridItem, aState, aRC, aCBWM, aAxis, + aCache->mPercentageBasis, nsLayoutUtils::MIN_ISIZE, aCache->mMinSizeClamp, nsLayoutUtils::MIN_INTRINSIC_ISIZE)); @@ -4721,7 +4751,8 @@ nsGridContainerFrame::Tracks::FindUsedFlexFraction( const GridItemInfo& item = aGridItems[iter.GridItemIndex()]; if (item.mState[mAxis] & ItemState::eIsFlexing) { // XXX optimize: bug 1194446 - nscoord spaceToFill = ContentContribution(item, aState, rc, wm, mAxis, + auto pb = Some(aState.PercentageBasisFor(mAxis, item)); + nscoord spaceToFill = ContentContribution(item, aState, rc, wm, mAxis, pb, nsLayoutUtils::PREF_ISIZE); if (spaceToFill <= 0) { continue; @@ -5052,6 +5083,25 @@ nsGridContainerFrame::LineRange::ToPositionAndLengthForAbsPos( } } +LogicalSize +nsGridContainerFrame::GridReflowInput::PercentageBasisFor( + LogicalAxis aAxis, + const GridItemInfo& aGridItem) const +{ + auto wm = aGridItem.mFrame->GetWritingMode(); + if (aAxis == eLogicalAxisInline) { + return LogicalSize(wm, NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE); + } + // Note: for now, we only resolve transferred percentages to row sizing. + // We may need to adjust these assertions once we implement bug 1300366. + MOZ_ASSERT(mCols.mCanResolveLineRangeSize); + MOZ_ASSERT(!mRows.mCanResolveLineRangeSize); + nscoord colSize = aGridItem.mArea.mCols.ToLength(mCols.mSizes); + nscoord rowSize = NS_UNCONSTRAINEDSIZE; + return !wm.IsOrthogonalTo(mWM) ? + LogicalSize(wm, colSize, rowSize) : LogicalSize(wm, rowSize, colSize); +} + LogicalRect nsGridContainerFrame::GridReflowInput::ContainingBlockFor(const GridArea& aArea) const { diff --git a/layout/reftests/css-grid/grid-auto-min-sizing-min-content-min-size-004-ref.html b/layout/reftests/css-grid/grid-auto-min-sizing-min-content-min-size-004-ref.html index fc74cd214..caef8b031 100644 --- a/layout/reftests/css-grid/grid-auto-min-sizing-min-content-min-size-004-ref.html +++ b/layout/reftests/css-grid/grid-auto-min-sizing-min-content-min-size-004-ref.html @@ -36,7 +36,7 @@ var rowtest = [ "min-width:80%; max-height:20px", "min-width:50%", "margin-left: 50px; width:50%" ]; var results = [ -"0/2px", "0/2px", "0/4px", "0/2px", "0/2px", "0/2px", "24px/2px", "20px/2px", "20px/2px", "24px/2px", "24px/52px" +"0/2px", "0/2px", "0/4px", "0/2px", "0/2px", "0/2px", "12px/2px", "20px/2px", "20px/2px", "24px/2px", "24px/52px" ]; var item_height = [ "0", "0", "0", "0", "0", "0", "12px", "20px", "20px", "24px", "312px" diff --git a/layout/reftests/css-grid/grid-auto-min-sizing-transferred-size-004-ref.html b/layout/reftests/css-grid/grid-auto-min-sizing-transferred-size-004-ref.html index c5d8a68ff..36a2d4920 100644 --- a/layout/reftests/css-grid/grid-auto-min-sizing-transferred-size-004-ref.html +++ b/layout/reftests/css-grid/grid-auto-min-sizing-transferred-size-004-ref.html @@ -36,7 +36,7 @@ var rowtest = [ "min-width:80%; max-height:20px", "min-width:50%", "margin-left: 50px; width:50%" ]; var results = [ -"0/2px", "0/2px", "0/4px", "0/2px", "0/2px", "0/2px", "24px/2px", "20px/2px", "20px/2px", "24px/2px", "24px/52px" +"0/2px", "0/2px", "0/4px", "0/2px", "0/2px", "0/2px", "12px/2px", "20px/2px", "20px/2px", "24px/2px", "24px/52px" ]; var item_height = [ "0", "0", "0", "0", "0", "0", "12px", "20px", "20px", "24px", "312px" diff --git a/layout/reftests/css-grid/grid-min-content-min-sizing-transferred-size-004-ref.html b/layout/reftests/css-grid/grid-min-content-min-sizing-transferred-size-004-ref.html index 5fa60b3b5..04d047b83 100644 --- a/layout/reftests/css-grid/grid-min-content-min-sizing-transferred-size-004-ref.html +++ b/layout/reftests/css-grid/grid-min-content-min-sizing-transferred-size-004-ref.html @@ -36,7 +36,7 @@ var rowtest = [ "min-width:80%; max-height:20px", "min-width:50%", "margin-left: 50px; width:50%" ]; var results = [ -"0/2px", "0/2px", "0/4px", "0/2px", "0/2px", "0/2px", "24px/2px", "20px/2px", "20px/2px", "24px/2px", "24px/52px" +"0/2px", "0/2px", "0/4px", "0/2px", "0/2px", "0/2px", "12px/2px", "20px/2px", "20px/2px", "24px/2px", "312px/52px" ]; var item_height = [ "0", "0", "0", "0", "0", "0", "12px", "20px", "20px", "24px", "312px" -- cgit v1.2.3 From 092c61f6e68971a62822532e12dc45ba54c9a713 Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Thu, 17 Aug 2017 21:08:44 +0200 Subject: CSS: inline-block with a display:block child element has a wrong baseline (HTML forms) --- layout/forms/nsFieldSetFrame.cpp | 71 +++++++++++---- layout/forms/nsFieldSetFrame.h | 9 +- layout/forms/nsHTMLButtonControlFrame.cpp | 41 +++++++++ layout/forms/nsHTMLButtonControlFrame.h | 7 ++ layout/forms/nsLegendFrame.h | 5 +- layout/forms/nsTextControlFrame.cpp | 11 +-- layout/forms/nsTextControlFrame.h | 35 ++++++++ layout/reftests/bugs/315920-17.html | 15 +++- .../forms/display-block-baselines-1-ref.html | 91 +++++++++++++++++++ .../reftests/forms/display-block-baselines-1.html | 92 +++++++++++++++++++ .../forms/display-block-baselines-2-ref.html | 100 +++++++++++++++++++++ .../reftests/forms/display-block-baselines-2.html | 100 +++++++++++++++++++++ .../forms/display-block-baselines-3-ref.html | 72 +++++++++++++++ .../reftests/forms/display-block-baselines-3.html | 73 +++++++++++++++ .../forms/display-block-baselines-4-ref.html | 73 +++++++++++++++ .../reftests/forms/display-block-baselines-4.html | 74 +++++++++++++++ .../forms/display-block-baselines-5-ref.html | 72 +++++++++++++++ .../reftests/forms/display-block-baselines-5.html | 72 +++++++++++++++ layout/reftests/forms/reftest.list | 5 ++ 19 files changed, 989 insertions(+), 29 deletions(-) create mode 100644 layout/reftests/forms/display-block-baselines-1-ref.html create mode 100644 layout/reftests/forms/display-block-baselines-1.html create mode 100644 layout/reftests/forms/display-block-baselines-2-ref.html create mode 100644 layout/reftests/forms/display-block-baselines-2.html create mode 100644 layout/reftests/forms/display-block-baselines-3-ref.html create mode 100644 layout/reftests/forms/display-block-baselines-3.html create mode 100644 layout/reftests/forms/display-block-baselines-4-ref.html create mode 100644 layout/reftests/forms/display-block-baselines-4.html create mode 100644 layout/reftests/forms/display-block-baselines-5-ref.html create mode 100644 layout/reftests/forms/display-block-baselines-5.html (limited to 'layout') diff --git a/layout/forms/nsFieldSetFrame.cpp b/layout/forms/nsFieldSetFrame.cpp index befd41ee2..fc9f0571b 100644 --- a/layout/forms/nsFieldSetFrame.cpp +++ b/layout/forms/nsFieldSetFrame.cpp @@ -5,26 +5,22 @@ #include "nsFieldSetFrame.h" +#include #include "mozilla/gfx/2D.h" +#include "mozilla/Likely.h" +#include "mozilla/Maybe.h" #include "nsCSSAnonBoxes.h" -#include "nsLayoutUtils.h" -#include "nsLegendFrame.h" #include "nsCSSRendering.h" -#include -#include "nsIFrame.h" -#include "nsPresContext.h" -#include "mozilla/RestyleManager.h" -#include "nsGkAtoms.h" -#include "nsStyleConsts.h" #include "nsDisplayList.h" +#include "nsGkAtoms.h" +#include "nsIFrameInlines.h" +#include "nsLayoutUtils.h" +#include "nsLegendFrame.h" #include "nsRenderingContext.h" -#include "nsIScrollableFrame.h" -#include "mozilla/Likely.h" -#include "mozilla/Maybe.h" +#include "nsStyleConsts.h" using namespace mozilla; using namespace mozilla::gfx; -using namespace mozilla::image; using namespace mozilla::layout; nsContainerFrame* @@ -126,7 +122,7 @@ void nsDisplayFieldSetBorderBackground::Paint(nsDisplayListBuilder* aBuilder, nsRenderingContext* aCtx) { - DrawResult result = static_cast(mFrame)-> + image::DrawResult result = static_cast(mFrame)-> PaintBorder(aBuilder, *aCtx, ToReferenceFrame(), mVisibleRect); nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, result); @@ -210,7 +206,7 @@ nsFieldSetFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, contentDisplayItems.MoveTo(aLists); } -DrawResult +image::DrawResult nsFieldSetFrame::PaintBorder( nsDisplayListBuilder* aBuilder, nsRenderingContext& aRenderingContext, @@ -695,9 +691,50 @@ nsFieldSetFrame::AccessibleType() #endif nscoord -nsFieldSetFrame::GetLogicalBaseline(WritingMode aWritingMode) const +nsFieldSetFrame::GetLogicalBaseline(WritingMode aWM) const +{ + switch (StyleDisplay()->mDisplay) { + case mozilla::StyleDisplay::Grid: + case mozilla::StyleDisplay::InlineGrid: + case mozilla::StyleDisplay::Flex: + case mozilla::StyleDisplay::InlineFlex: + return BaselineBOffset(aWM, BaselineSharingGroup::eFirst, + AlignmentContext::eInline); + default: + return BSize(aWM) - BaselineBOffset(aWM, BaselineSharingGroup::eLast, + AlignmentContext::eInline); + } +} + +bool +nsFieldSetFrame::GetVerticalAlignBaseline(WritingMode aWM, + nscoord* aBaseline) const { nsIFrame* inner = GetInner(); - return inner->BStart(aWritingMode, GetParent()->GetSize()) + - inner->GetLogicalBaseline(aWritingMode); + MOZ_ASSERT(!inner->GetWritingMode().IsOrthogonalTo(aWM)); + if (!inner->GetVerticalAlignBaseline(aWM, aBaseline)) { + return false; + } + nscoord innerBStart = inner->BStart(aWM, GetSize()); + *aBaseline += innerBStart; + return true; +} + +bool +nsFieldSetFrame::GetNaturalBaselineBOffset(WritingMode aWM, + BaselineSharingGroup aBaselineGroup, + nscoord* aBaseline) const +{ + nsIFrame* inner = GetInner(); + MOZ_ASSERT(!inner->GetWritingMode().IsOrthogonalTo(aWM)); + if (!inner->GetNaturalBaselineBOffset(aWM, aBaselineGroup, aBaseline)) { + return false; + } + nscoord innerBStart = inner->BStart(aWM, GetSize()); + if (aBaselineGroup == BaselineSharingGroup::eFirst) { + *aBaseline += innerBStart; + } else { + *aBaseline += BSize(aWM) - (innerBStart + inner->BSize(aWM)); + } + return true; } diff --git a/layout/forms/nsFieldSetFrame.h b/layout/forms/nsFieldSetFrame.h index 54eaf678f..39d862278 100644 --- a/layout/forms/nsFieldSetFrame.h +++ b/layout/forms/nsFieldSetFrame.h @@ -7,7 +7,7 @@ #define nsFieldSetFrame_h___ #include "mozilla/Attributes.h" -#include "imgIContainer.h" +#include "DrawResult.h" #include "nsContainerFrame.h" class nsFieldSetFrame final : public nsContainerFrame @@ -46,6 +46,13 @@ public: const ReflowInput& aReflowInput, nsReflowStatus& aStatus) override; + nscoord GetLogicalBaseline(mozilla::WritingMode aWM) const override; + bool GetVerticalAlignBaseline(mozilla::WritingMode aWM, + nscoord* aBaseline) const override; + bool GetNaturalBaselineBOffset(mozilla::WritingMode aWM, + BaselineSharingGroup aBaselineGroup, + nscoord* aBaseline) const override; + virtual void BuildDisplayList(nsDisplayListBuilder* aBuilder, const nsRect& aDirtyRect, const nsDisplayListSet& aLists) override; diff --git a/layout/forms/nsHTMLButtonControlFrame.cpp b/layout/forms/nsHTMLButtonControlFrame.cpp index ef9459ef2..2e4fa9f67 100644 --- a/layout/forms/nsHTMLButtonControlFrame.cpp +++ b/layout/forms/nsHTMLButtonControlFrame.cpp @@ -418,6 +418,47 @@ nsHTMLButtonControlFrame::ReflowButtonContents(nsPresContext* aPresContext, aButtonDesiredSize.SetOverflowAreasToDesiredBounds(); } +bool +nsHTMLButtonControlFrame::GetVerticalAlignBaseline(mozilla::WritingMode aWM, + nscoord* aBaseline) const +{ + nsIFrame* inner = mFrames.FirstChild(); + if (MOZ_UNLIKELY(inner->GetWritingMode().IsOrthogonalTo(aWM))) { + return false; + } + if (!inner->GetVerticalAlignBaseline(aWM, aBaseline)) { + // has an empty block frame as inner frame + *aBaseline = inner-> + SynthesizeBaselineBOffsetFromBorderBox(aWM, BaselineSharingGroup::eFirst); + } + nscoord innerBStart = inner->BStart(aWM, GetSize()); + *aBaseline += innerBStart; + return true; +} + +bool +nsHTMLButtonControlFrame::GetNaturalBaselineBOffset(mozilla::WritingMode aWM, + BaselineSharingGroup aBaselineGroup, + nscoord* aBaseline) const +{ + nsIFrame* inner = mFrames.FirstChild(); + if (MOZ_UNLIKELY(inner->GetWritingMode().IsOrthogonalTo(aWM))) { + return false; + } + if (!inner->GetNaturalBaselineBOffset(aWM, aBaselineGroup, aBaseline)) { + // has an empty block frame as inner frame + *aBaseline = inner-> + SynthesizeBaselineBOffsetFromBorderBox(aWM, aBaselineGroup); + } + nscoord innerBStart = inner->BStart(aWM, GetSize()); + if (aBaselineGroup == BaselineSharingGroup::eFirst) { + *aBaseline += innerBStart; + } else { + *aBaseline += BSize(aWM) - (innerBStart + inner->BSize(aWM)); + } + return true; +} + nsresult nsHTMLButtonControlFrame::SetFormProperty(nsIAtom* aName, const nsAString& aValue) { if (nsGkAtoms::value == aName) { diff --git a/layout/forms/nsHTMLButtonControlFrame.h b/layout/forms/nsHTMLButtonControlFrame.h index 96ad0f366..432afa12c 100644 --- a/layout/forms/nsHTMLButtonControlFrame.h +++ b/layout/forms/nsHTMLButtonControlFrame.h @@ -39,6 +39,13 @@ public: const ReflowInput& aReflowInput, nsReflowStatus& aStatus) override; + bool GetVerticalAlignBaseline(mozilla::WritingMode aWM, + nscoord* aBaseline) const override; + + bool GetNaturalBaselineBOffset(mozilla::WritingMode aWM, + BaselineSharingGroup aBaselineGroup, + nscoord* aBaseline) const override; + virtual nsresult HandleEvent(nsPresContext* aPresContext, mozilla::WidgetGUIEvent* aEvent, nsEventStatus* aEventStatus) override; diff --git a/layout/forms/nsLegendFrame.h b/layout/forms/nsLegendFrame.h index 5f5e1e03e..a9e11cbbe 100644 --- a/layout/forms/nsLegendFrame.h +++ b/layout/forms/nsLegendFrame.h @@ -9,7 +9,8 @@ #include "mozilla/Attributes.h" #include "nsBlockFrame.h" -class nsLegendFrame : public nsBlockFrame { +class nsLegendFrame final : public nsBlockFrame +{ public: NS_DECL_QUERYFRAME_TARGET(nsLegendFrame) NS_DECL_QUERYFRAME @@ -30,7 +31,7 @@ public: virtual nsresult GetFrameName(nsAString& aResult) const override; #endif - int32_t GetLogicalAlign(WritingMode aCBWM); + int32_t GetLogicalAlign(mozilla::WritingMode aCBWM); }; diff --git a/layout/forms/nsTextControlFrame.cpp b/layout/forms/nsTextControlFrame.cpp index f85bc2a80..a7f7d40a8 100644 --- a/layout/forms/nsTextControlFrame.cpp +++ b/layout/forms/nsTextControlFrame.cpp @@ -106,6 +106,7 @@ private: nsTextControlFrame::nsTextControlFrame(nsStyleContext* aContext) : nsContainerFrame(aContext) + , mFirstBaseline(NS_INTRINSIC_WIDTH_UNKNOWN) , mEditorHasBeenInitialized(false) , mIsProcessing(false) #ifdef DEBUG @@ -538,20 +539,20 @@ nsTextControlFrame::Reflow(nsPresContext* aPresContext, aReflowInput.ComputedLogicalBorderPadding().BStartEnd(wm)); aDesiredSize.SetSize(wm, finalSize); - // computation of the ascent wrt the input height + // Calculate the baseline and store it in mFirstBaseline. nscoord lineHeight = aReflowInput.ComputedBSize(); float inflation = nsLayoutUtils::FontSizeInflationFor(this); if (!IsSingleLineTextControl()) { lineHeight = ReflowInput::CalcLineHeight(GetContent(), StyleContext(), - NS_AUTOHEIGHT, inflation); + NS_AUTOHEIGHT, inflation); } RefPtr fontMet = nsLayoutUtils::GetFontMetricsForFrame(this, inflation); - // now adjust for our borders and padding - aDesiredSize.SetBlockStartAscent( + mFirstBaseline = nsLayoutUtils::GetCenteredFontBaseline(fontMet, lineHeight, wm.IsLineInverted()) + - aReflowInput.ComputedLogicalBorderPadding().BStart(wm)); + aReflowInput.ComputedLogicalBorderPadding().BStart(wm); + aDesiredSize.SetBlockStartAscent(mFirstBaseline); // overflow handling aDesiredSize.SetOverflowAreasToDesiredBounds(); diff --git a/layout/forms/nsTextControlFrame.h b/layout/forms/nsTextControlFrame.h index a76cba514..9d4d0b77c 100644 --- a/layout/forms/nsTextControlFrame.h +++ b/layout/forms/nsTextControlFrame.h @@ -62,6 +62,29 @@ public: const ReflowInput& aReflowInput, nsReflowStatus& aStatus) override; + bool GetVerticalAlignBaseline(mozilla::WritingMode aWM, + nscoord* aBaseline) const override + { + return GetNaturalBaselineBOffset(aWM, BaselineSharingGroup::eFirst, aBaseline); + } + + bool GetNaturalBaselineBOffset(mozilla::WritingMode aWM, + BaselineSharingGroup aBaselineGroup, + nscoord* aBaseline) const override + { + if (!IsSingleLineTextControl()) { + return false; + } + NS_ASSERTION(mFirstBaseline != NS_INTRINSIC_WIDTH_UNKNOWN, + "please call Reflow before asking for the baseline"); + if (aBaselineGroup == BaselineSharingGroup::eFirst) { + *aBaseline = mFirstBaseline; + } else { + *aBaseline = BSize(aWM) - mFirstBaseline; + } + return true; + } + virtual nsSize GetXULMinSize(nsBoxLayoutState& aBoxLayoutState) override; virtual bool IsXULCollapsed() override; @@ -87,6 +110,14 @@ public: ~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock)); } +#ifdef DEBUG + void MarkIntrinsicISizesDirty() override + { + // Need another Reflow to have a correct baseline value again. + mFirstBaseline = NS_INTRINSIC_WIDTH_UNKNOWN; + } +#endif + // nsIAnonymousContentCreator virtual nsresult CreateAnonymousContent(nsTArray& aElements) override; virtual void AppendAnonymousContentTo(nsTArray& aElements, @@ -300,6 +331,10 @@ private: } private: + // Our first baseline, or NS_INTRINSIC_WIDTH_UNKNOWN if we have a pending + // Reflow. + nscoord mFirstBaseline; + // these packed bools could instead use the high order bits on mState, saving 4 bytes bool mEditorHasBeenInitialized; bool mIsProcessing; diff --git a/layout/reftests/bugs/315920-17.html b/layout/reftests/bugs/315920-17.html index 1681754a5..6d9180144 100644 --- a/layout/reftests/bugs/315920-17.html +++ b/layout/reftests/bugs/315920-17.html @@ -1,5 +1,5 @@ - + - +

@@ -19,5 +17,14 @@
+ diff --git a/layout/reftests/forms/display-block-baselines-1-ref.html b/layout/reftests/forms/display-block-baselines-1-ref.html new file mode 100644 index 000000000..d01c086b5 --- /dev/null +++ b/layout/reftests/forms/display-block-baselines-1-ref.html @@ -0,0 +1,91 @@ + + + + + Reference: Testcase #1 for bug 1330962 + + + + +
+
+ A +
+ B +
+ +
+
+ A + +
+ B +
+ +
+
+ A
+
+
+ B +
+ +
+
+ A
+
+
+ B +
+ +
+
+ A
+
+
+ B +
+ +
+
+ A
+
+
+ B +
+ + + diff --git a/layout/reftests/forms/display-block-baselines-1.html b/layout/reftests/forms/display-block-baselines-1.html new file mode 100644 index 000000000..96ebdad71 --- /dev/null +++ b/layout/reftests/forms/display-block-baselines-1.html @@ -0,0 +1,92 @@ + + + + + Testcase #1 for bug 1330962 + + + + +
+
+ A + +
+ B +
+ +
+
+ A + +
+ B +
+ +
+
+ A + +
+ B +
+ +
+
+ A + +
+ B +
+ +
+
+ A + +
+ B +
+ +
+
+ A + +
+ B +
+ + + diff --git a/layout/reftests/forms/display-block-baselines-2-ref.html b/layout/reftests/forms/display-block-baselines-2-ref.html new file mode 100644 index 000000000..441a927b4 --- /dev/null +++ b/layout/reftests/forms/display-block-baselines-2-ref.html @@ -0,0 +1,100 @@ + + + + + Reference: Testcase #2 for bug 1330962 + + + + +
+
+ A
+
+
+ B +
+ +
+
+ A
+
+
+ B +
+ +
+
+ A
+
+
+ B +
+ +
+
+ A
+ +
+ B +
button-first
button-last
+
+ +
+
+ A
+ +
+ B +
button-firstbutton-last
+
+ +
+
+ A + +
+ B +
+ +
+
+ A + +
+ B +
+ + + diff --git a/layout/reftests/forms/display-block-baselines-2.html b/layout/reftests/forms/display-block-baselines-2.html new file mode 100644 index 000000000..78253fe4c --- /dev/null +++ b/layout/reftests/forms/display-block-baselines-2.html @@ -0,0 +1,100 @@ + + + + + Testcase #2 for bug 1330962 + + + + +
+
+ A + +
+ B +
+ +
+
+ A + +
+ B +
+ +
+
+ A + +
+ B +
+ +
+
+ A + +
+ B + +
+ +
+
+ A + +
+ B + +
+ +
+
+ A + +
+ B +
+ +
+
+ A + +
+ B +
+ + + diff --git a/layout/reftests/forms/display-block-baselines-3-ref.html b/layout/reftests/forms/display-block-baselines-3-ref.html new file mode 100644 index 000000000..ce277b50c --- /dev/null +++ b/layout/reftests/forms/display-block-baselines-3-ref.html @@ -0,0 +1,72 @@ + + + + + Reference: Testcase #3 for bug 1330962 + + + + +
+
+ A + +
+ B +
+ +
+
+ A + +
+ B +
+ +
+
+ A + +
+ B +
+ +
+
+ A
+
fieldset-first
fieldset-last
+
+ B +
+ + + diff --git a/layout/reftests/forms/display-block-baselines-3.html b/layout/reftests/forms/display-block-baselines-3.html new file mode 100644 index 000000000..9f3c2b110 --- /dev/null +++ b/layout/reftests/forms/display-block-baselines-3.html @@ -0,0 +1,73 @@ + + + + + Testcase #3 for bug 1330962 + + + + +
+
+ A + +
+ B +
+ +
+
+ A + +
+ B +
+ +
+
+ A + +
+ B +
+ +
+
+ A +
fieldset-first
fieldset-last
+
+ B +
+ + + + diff --git a/layout/reftests/forms/display-block-baselines-4-ref.html b/layout/reftests/forms/display-block-baselines-4-ref.html new file mode 100644 index 000000000..5015d50c4 --- /dev/null +++ b/layout/reftests/forms/display-block-baselines-4-ref.html @@ -0,0 +1,73 @@ + + + + + Reference: Testcase #4 for bug 1330962 + + + + +
+
+ A
+
legend +fieldset-first
fieldset-last
+
+ B +
+ +
+
+ A
+
grid-fieldset-firstgrid-fieldset-last
+
+ B +
+ +
+
+ A
+
fieldset-first
fieldset-last
+
+ B +
+ +
+
+ A
+
fieldset-first
fieldset-last
+
+ B +
+ + + diff --git a/layout/reftests/forms/display-block-baselines-4.html b/layout/reftests/forms/display-block-baselines-4.html new file mode 100644 index 000000000..1bfd344b0 --- /dev/null +++ b/layout/reftests/forms/display-block-baselines-4.html @@ -0,0 +1,74 @@ + + + + + Testcase #4 for bug 1330962 + + + + +
+
+ A +
legend +fieldset-first
fieldset-last
+
+ B +
+ +
+
+ A +
grid-fieldset-lastgrid-fieldset-first
+
+ B +
+ +
+
+ A +
fieldset-first
fieldset-last
+
+ B +
+ +
+
+ A +
fieldset-first
fieldset-last
+
+ B +
+ + + + diff --git a/layout/reftests/forms/display-block-baselines-5-ref.html b/layout/reftests/forms/display-block-baselines-5-ref.html new file mode 100644 index 000000000..0dce47f59 --- /dev/null +++ b/layout/reftests/forms/display-block-baselines-5-ref.html @@ -0,0 +1,72 @@ + + + + + Reference: Testcase #5 for bug 1330962 + + + + +
+
+ A
+ +
+ B +
+ +
+
+ A
+ +
+ B +
+ +
+
+ A
+ +
+ B +
+ +
+
+ A
+ +
+ B +
+ + + diff --git a/layout/reftests/forms/display-block-baselines-5.html b/layout/reftests/forms/display-block-baselines-5.html new file mode 100644 index 000000000..0359c8a6f --- /dev/null +++ b/layout/reftests/forms/display-block-baselines-5.html @@ -0,0 +1,72 @@ + + + + + Testcase #5 for bug 1330962 + + + + +
+
+ A + +
+ B +
+ +
+
+ A + +
+ B +
+ +
+
+ A + +
+ B +
+ +
+
+ A + +
+ B +
+ + + diff --git a/layout/reftests/forms/reftest.list b/layout/reftests/forms/reftest.list index d45db276f..c7532077b 100644 --- a/layout/reftests/forms/reftest.list +++ b/layout/reftests/forms/reftest.list @@ -1,4 +1,9 @@ fuzzy-if(skiaContent,1,10) HTTP(..) == text-control-baseline-1.html text-control-baseline-1-ref.html +fuzzy-if(cocoaWidget,16,64) fuzzy-if(Android,52,64) fuzzy-if(/^Windows\x20NT\x206\.1/.test(http.oscpu),104,224) fuzzy-if(/^Windows\x20NT\x206\.2/.test(http.oscpu),57,400) == display-block-baselines-1.html display-block-baselines-1-ref.html # anti-aliasing issues +== display-block-baselines-2.html display-block-baselines-2-ref.html +== display-block-baselines-3.html display-block-baselines-3-ref.html +== display-block-baselines-4.html display-block-baselines-4-ref.html +fuzzy-if(Android,4,8) == display-block-baselines-5.html display-block-baselines-5-ref.html # button element include button/reftest.list -- cgit v1.2.3 From ea44e60b7ed5f674b6de65fad669ac43a45438cc Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Fri, 18 Aug 2017 13:39:37 +0200 Subject: HTML - implement the labels attribute (follow up) --- layout/base/nsLayoutDebugger.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'layout') diff --git a/layout/base/nsLayoutDebugger.cpp b/layout/base/nsLayoutDebugger.cpp index 22c313c72..6ce629bc9 100644 --- a/layout/base/nsLayoutDebugger.cpp +++ b/layout/base/nsLayoutDebugger.cpp @@ -126,8 +126,10 @@ PrintDisplayItemTo(nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem, contentData.AppendLiteral(" id:"); contentData.Append(tmp); } - if (content->GetClasses()) { - content->GetClasses()->ToString(tmp); + const nsAttrValue* classes = content->IsElement() ? + content->AsElement()->GetClasses() : nullptr; + if (classes) { + classes->ToString(tmp); contentData.AppendLiteral(" class:"); contentData.Append(tmp); } -- cgit v1.2.3 From 2fbd1794780f92d1e511f6314cc9af7b446a6338 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Mon, 12 Mar 2018 11:09:02 +0100 Subject: Bustage fix: remove duplicate function def --- layout/forms/nsFieldSetFrame.h | 1 - 1 file changed, 1 deletion(-) (limited to 'layout') diff --git a/layout/forms/nsFieldSetFrame.h b/layout/forms/nsFieldSetFrame.h index 39d862278..5eb67c320 100644 --- a/layout/forms/nsFieldSetFrame.h +++ b/layout/forms/nsFieldSetFrame.h @@ -33,7 +33,6 @@ public: const mozilla::LogicalSize& aBorder, const mozilla::LogicalSize& aPadding, ComputeSizeFlags aFlags) override; - virtual nscoord GetLogicalBaseline(mozilla::WritingMode aWritingMode) const override; /** * The area to paint box-shadows around. It's the border rect except -- cgit v1.2.3 From f13ea6af5be4ca04ec113f8c852d59d90993baa2 Mon Sep 17 00:00:00 2001 From: Bob Owen Date: Fri, 12 Jan 2018 10:17:36 +0000 Subject: Bug 1426087 - Decrement nsDocumentViewer::mDestroyRefCount in a separate function. r=jwatt, a=RyanVM --HG-- extra : source : 86d41b5efe074f6988085082df9ef537eee0813a extra : intermediate-source : ea406489f93a0a8fa05ff568acdff07ce6b118c4 --- layout/base/nsDocumentViewer.cpp | 7 ++++++- layout/base/nsIDocumentViewerPrint.h | 2 ++ layout/printing/nsPagePrintTimer.cpp | 10 ++-------- 3 files changed, 10 insertions(+), 9 deletions(-) (limited to 'layout') diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index 782ac332c..137efb3cd 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -1617,7 +1617,6 @@ nsDocumentViewer::Destroy() // We also keep the viewer from being cached in session history, since // we require all documents there to be sanitized. if (mDestroyRefCount != 0) { - --mDestroyRefCount; return NS_OK; } @@ -4426,6 +4425,12 @@ nsDocumentViewer::IncrementDestroyRefCount() ++mDestroyRefCount; } +void +nsDocumentViewer::DecrementDestroyRefCount() +{ + --mDestroyRefCount; +} + //------------------------------------------------------------ #if defined(NS_PRINTING) && defined(NS_PRINT_PREVIEW) diff --git a/layout/base/nsIDocumentViewerPrint.h b/layout/base/nsIDocumentViewerPrint.h index 8bc2465a1..e3c397f3a 100644 --- a/layout/base/nsIDocumentViewerPrint.h +++ b/layout/base/nsIDocumentViewerPrint.h @@ -41,6 +41,7 @@ public: virtual mozilla::StyleSetHandle CreateStyleSet(nsIDocument* aDocument) = 0; virtual void IncrementDestroyRefCount() = 0; + virtual void DecrementDestroyRefCount() = 0; virtual void ReturnToGalleyPresentation() = 0; @@ -75,6 +76,7 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIDocumentViewerPrint, bool GetIsPrintPreview() override; \ mozilla::StyleSetHandle CreateStyleSet(nsIDocument* aDocument) override; \ void IncrementDestroyRefCount() override; \ + void DecrementDestroyRefCount() override; \ void ReturnToGalleyPresentation() override; \ void OnDonePrinting() override; \ bool IsInitializedForPrintPreview() override; \ diff --git a/layout/printing/nsPagePrintTimer.cpp b/layout/printing/nsPagePrintTimer.cpp index b56569a9a..164b0469a 100644 --- a/layout/printing/nsPagePrintTimer.cpp +++ b/layout/printing/nsPagePrintTimer.cpp @@ -14,14 +14,8 @@ NS_IMPL_ISUPPORTS_INHERITED(nsPagePrintTimer, mozilla::Runnable, nsITimerCallbac nsPagePrintTimer::~nsPagePrintTimer() { - // "Destroy" the document viewer; this normally doesn't actually - // destroy it because of the IncrementDestroyRefCount call below - // XXX This is messy; the document viewer should use a single approach - // to keep itself alive during printing - nsCOMPtr cv(do_QueryInterface(mDocViewerPrint)); - if (cv) { - cv->Destroy(); - } + // This matches the IncrementDestroyRefCount call in the constructor. + mDocViewerPrint->DecrementDestroyRefCount(); } nsresult -- cgit v1.2.3 From 5babf7dc56e5d8fcd566845bbc991989a5b1c7b1 Mon Sep 17 00:00:00 2001 From: Daniel Holbert Date: Sat, 10 Feb 2018 08:46:49 -0800 Subject: Bug 1324042 - Fix trimmedOffsets arithmetic in GetRenderedText(). r=mats, a=RyanVM MozReview-Commit-ID: H4ngU8Juyln --HG-- extra : rebase_source : f4d6ab58ae70e485dfe72d5290cf6fae2c8397dd extra : intermediate-source : bec50ba1fb12aebde4e4065b2799bc730bc30010 extra : source : fbf54020043bd09c162530907b2a1091a10f4f92 --- layout/generic/nsTextFrame.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'layout') diff --git a/layout/generic/nsTextFrame.cpp b/layout/generic/nsTextFrame.cpp index b9848bcf1..00c0016fd 100644 --- a/layout/generic/nsTextFrame.cpp +++ b/layout/generic/nsTextFrame.cpp @@ -9751,9 +9751,13 @@ nsTextFrame::GetRenderedText(uint32_t aStartOffset, startOffset = aStartOffset; endOffset = std::min(INT32_MAX, aEndOffset); } + + // If startOffset and/or endOffset are inside of trimmedOffsets' range, + // then clamp the edges of trimmedOffsets accordingly. + int32_t origTrimmedOffsetsEnd = trimmedOffsets.GetEnd(); trimmedOffsets.mStart = std::max(trimmedOffsets.mStart, startOffset); - trimmedOffsets.mLength = std::min(trimmedOffsets.GetEnd(), + trimmedOffsets.mLength = std::min(origTrimmedOffsetsEnd, endOffset) - trimmedOffsets.mStart; if (trimmedOffsets.mLength <= 0) { offsetInRenderedString = nextOffsetInRenderedString; -- cgit v1.2.3