diff --git a/gfx/2d/BaseMargin.h b/gfx/2d/BaseMargin.h index 469541e6177b..de9c86c5af20 100644 --- a/gfx/2d/BaseMargin.h +++ b/gfx/2d/BaseMargin.h @@ -120,6 +120,10 @@ struct BaseMargin { left = std::min(left, aMargin.left); } + bool IsAllZero() const { + return left == 0 && top == 0 && right == 0 && bottom == 0; + } + // Overloaded operators. Note that '=' isn't defined so we'll get the // compiler generated default assignment operator bool operator==(const Sub& aMargin) const { diff --git a/layout/generic/WritingModes.h b/layout/generic/WritingModes.h index 087564c03b33..608f5afd897b 100644 --- a/layout/generic/WritingModes.h +++ b/layout/generic/WritingModes.h @@ -1423,10 +1423,7 @@ class LogicalMargin { return *this; } - bool IsAllZero() const { - return (mMargin.left == 0 && mMargin.top == 0 && mMargin.right == 0 && - mMargin.bottom == 0); - } + bool IsAllZero() const { return mMargin.IsAllZero(); } bool operator==(const LogicalMargin& aMargin) const { CHECK_WRITING_MODE(aMargin.GetWritingMode()); diff --git a/layout/mathml/nsMathMLTokenFrame.cpp b/layout/mathml/nsMathMLTokenFrame.cpp index 27522652ebab..29615327a479 100644 --- a/layout/mathml/nsMathMLTokenFrame.cpp +++ b/layout/mathml/nsMathMLTokenFrame.cpp @@ -155,10 +155,16 @@ nsresult nsMathMLTokenFrame::Place(DrawTarget* aDrawTarget, mBoundingMetrics = nsBoundingMetrics(); for (nsIFrame* childFrame : PrincipalChildList()) { ReflowOutput childSize(aDesiredSize.GetWritingMode()); - GetReflowAndBoundingMetricsFor(childFrame, childSize, - childSize.mBoundingMetrics, nullptr); + nsBoundingMetrics bmChild; + GetReflowAndBoundingMetricsFor(childFrame, childSize, bmChild, nullptr); + auto childMargin = GetMarginForPlace(aFlags, childFrame); + bmChild.ascent += childMargin.top; + bmChild.descent += childMargin.bottom; + bmChild.rightBearing += childMargin.LeftRight(); + bmChild.width += childMargin.LeftRight(); + // compute and cache the bounding metrics - mBoundingMetrics += childSize.mBoundingMetrics; + mBoundingMetrics += bmChild; } RefPtr fm = @@ -172,17 +178,24 @@ nsresult nsMathMLTokenFrame::Place(DrawTarget* aDrawTarget, aDesiredSize.Height() = aDesiredSize.BlockStartAscent() + std::max(mBoundingMetrics.descent, descent); + // Add padding+border. + auto borderPadding = GetBorderPaddingForPlace(aFlags); + InflateReflowAndBoundingMetrics(borderPadding, aDesiredSize, + mBoundingMetrics); + if (!aFlags.contains(PlaceFlag::MeasureOnly)) { - nscoord dy, dx = 0; + nscoord dx = borderPadding.left; for (nsIFrame* childFrame : PrincipalChildList()) { ReflowOutput childSize(aDesiredSize.GetWritingMode()); GetReflowAndBoundingMetricsFor(childFrame, childSize, childSize.mBoundingMetrics); + auto childMargin = GetMarginForPlace(aFlags, childFrame); // place and size the child; (dx,0) makes the caret happy - bug 188146 - dy = childSize.Height() == 0 - ? 0 - : aDesiredSize.BlockStartAscent() - childSize.BlockStartAscent(); + nscoord dy = childSize.Height() == 0 + ? 0 + : aDesiredSize.BlockStartAscent() - + childSize.BlockStartAscent() + childMargin.top; FinishReflowChild(childFrame, PresContext(), childSize, nullptr, dx, dy, ReflowChildFlags::Default); dx += childSize.Width(); diff --git a/layout/mathml/nsMathMLmoFrame.cpp b/layout/mathml/nsMathMLmoFrame.cpp index 62fba538b5d9..8410edc69fc9 100644 --- a/layout/mathml/nsMathMLmoFrame.cpp +++ b/layout/mathml/nsMathMLmoFrame.cpp @@ -839,17 +839,20 @@ nsMathMLmoFrame::Stretch(DrawTarget* aDrawTarget, // container and so we put the spacing, otherwise we don't include the // spacing, the outermost embellished container will take care of it. + nscoord leadingSpace = 0, trailingSpace = 0; if (!NS_MATHML_OPERATOR_HAS_EMBELLISH_ANCESTOR(mFlags)) { // Account the spacing if we are not an accent with explicit attributes - nscoord leadingSpace = mEmbellishData.leadingSpace; - if (isAccent && !NS_MATHML_OPERATOR_HAS_LSPACE_ATTR(mFlags)) { - leadingSpace = 0; + if (!isAccent || NS_MATHML_OPERATOR_HAS_LSPACE_ATTR(mFlags)) { + leadingSpace = mEmbellishData.leadingSpace; } - nscoord trailingSpace = mEmbellishData.trailingSpace; - if (isAccent && !NS_MATHML_OPERATOR_HAS_RSPACE_ATTR(mFlags)) { - trailingSpace = 0; + if (!isAccent || NS_MATHML_OPERATOR_HAS_RSPACE_ATTR(mFlags)) { + trailingSpace = mEmbellishData.trailingSpace; } + } + flags = PlaceFlags(); + auto borderPadding = GetBorderPaddingForPlace(flags); + if (leadingSpace || trailingSpace || !borderPadding.IsAllZero()) { mBoundingMetrics.width += leadingSpace + trailingSpace; aDesiredStretchSize.Width() = mBoundingMetrics.width; aDesiredStretchSize.mBoundingMetrics.width = mBoundingMetrics.width; @@ -857,22 +860,29 @@ nsMathMLmoFrame::Stretch(DrawTarget* aDrawTarget, nscoord dx = StyleVisibility()->mDirection == StyleDirection::Rtl ? trailingSpace : leadingSpace; - if (dx) { + mBoundingMetrics.leftBearing += dx; + mBoundingMetrics.rightBearing += dx; + aDesiredStretchSize.mBoundingMetrics.leftBearing += dx; + aDesiredStretchSize.mBoundingMetrics.rightBearing += dx; + + // Add border/padding. + InflateReflowAndBoundingMetrics(borderPadding, aDesiredStretchSize, + mBoundingMetrics); + dx += borderPadding.left; + nscoord dy = borderPadding.top; + + if (dx || dy) { // adjust the offsets - mBoundingMetrics.leftBearing += dx; - mBoundingMetrics.rightBearing += dx; - aDesiredStretchSize.mBoundingMetrics.leftBearing += dx; - aDesiredStretchSize.mBoundingMetrics.rightBearing += dx; if (useMathMLChar) { nsRect rect; mMathMLChar.GetRect(rect); mMathMLChar.SetRect( - nsRect(rect.x + dx, rect.y, rect.width, rect.height)); + nsRect(rect.x + dx, rect.y + dy, rect.width, rect.height)); } else { nsIFrame* childFrame = firstChild; while (childFrame) { - childFrame->SetPosition(childFrame->GetPosition() + nsPoint(dx, 0)); + childFrame->SetPosition(childFrame->GetPosition() + nsPoint(dx, dy)); childFrame = childFrame->GetNextSibling(); } } @@ -1016,6 +1026,7 @@ void nsMathMLmoFrame::GetIntrinsicISizeMetrics(gfxContext* aRenderingContext, aDesiredSize.Width() = mMathMLChar.GetMaxWidth( this, aRenderingContext->GetDrawTarget(), nsLayoutUtils::FontSizeInflationFor(this), stretchHint); + aDesiredSize.Width() += IntrinsicISizeOffsets().BorderPadding(); } else { nsMathMLTokenFrame::GetIntrinsicISizeMetrics(aRenderingContext, aDesiredSize); diff --git a/testing/web-platform/meta/mathml/relations/css-styling/padding-border-margin/border-002.html.ini b/testing/web-platform/meta/mathml/relations/css-styling/padding-border-margin/border-002.html.ini index 3a4fd838c689..036ae5110bc1 100644 --- a/testing/web-platform/meta/mathml/relations/css-styling/padding-border-margin/border-002.html.ini +++ b/testing/web-platform/meta/mathml/relations/css-styling/padding-border-margin/border-002.html.ini @@ -2,9 +2,6 @@ [Border properties on mmultiscripts] expected: FAIL - [Border properties on mn] - expected: FAIL - [Border properties on msup] expected: FAIL @@ -26,21 +23,9 @@ [Border properties on mroot] expected: FAIL - [Border properties on mi] - expected: FAIL - - [Border properties on mo] - expected: FAIL - - [Border properties on ms] - expected: FAIL - [Border properties on munderover] expected: FAIL - [Border properties on mtext] - expected: FAIL - [Border properties on mover] expected: FAIL @@ -65,26 +50,11 @@ [Border properties on msqrt (rtl)] expected: FAIL - [Border properties on ms (rtl)] - expected: FAIL - - [Border properties on mi (rtl)] - expected: FAIL - - [Border properties on mo (rtl)] - expected: FAIL - [Border properties on mroot (rtl)] expected: FAIL - [Border properties on mtext (rtl)] - expected: FAIL - [Border properties on menclose (rtl)] expected: FAIL [Border properties on msubsup (rtl)] expected: FAIL - - [Border properties on mn (rtl)] - expected: FAIL diff --git a/testing/web-platform/meta/mathml/relations/css-styling/padding-border-margin/padding-002.html.ini b/testing/web-platform/meta/mathml/relations/css-styling/padding-border-margin/padding-002.html.ini index 07cc70121cd8..4aa56d35de7c 100644 --- a/testing/web-platform/meta/mathml/relations/css-styling/padding-border-margin/padding-002.html.ini +++ b/testing/web-platform/meta/mathml/relations/css-styling/padding-border-margin/padding-002.html.ini @@ -1,25 +1,10 @@ [padding-002.html] - [Padding properties on mtext] - expected: FAIL - - [Padding properties on ms] - expected: FAIL - [Padding properties on msqrt] expected: FAIL [Padding properties on menclose] expected: FAIL - [Padding properties on mn] - expected: FAIL - - [Padding properties on mo] - expected: FAIL - - [Padding properties on mi] - expected: FAIL - [Padding properties on mroot] expected: FAIL @@ -44,21 +29,12 @@ [Padding properties on mover] expected: FAIL - [Padding properties on mtext (rtl)] - expected: FAIL - [Padding properties on munder (rtl)] expected: FAIL - [Padding properties on mo (rtl)] - expected: FAIL - [Padding properties on mroot (rtl)] expected: FAIL - [Padding properties on mn (rtl)] - expected: FAIL - [Padding properties on msub (rtl)] expected: FAIL @@ -77,12 +53,6 @@ [Padding properties on mover (rtl)] expected: FAIL - [Padding properties on mi (rtl)] - expected: FAIL - - [Padding properties on ms (rtl)] - expected: FAIL - [Padding properties on msqrt (rtl)] expected: FAIL diff --git a/testing/web-platform/meta/mathml/relations/css-styling/padding-border-margin/padding-border-margin-002.html.ini b/testing/web-platform/meta/mathml/relations/css-styling/padding-border-margin/padding-border-margin-002.html.ini deleted file mode 100644 index 75adb8d7e127..000000000000 --- a/testing/web-platform/meta/mathml/relations/css-styling/padding-border-margin/padding-border-margin-002.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[padding-border-margin-002.html] - expected: FAIL diff --git a/testing/web-platform/meta/mathml/relations/css-styling/padding-border-margin/padding-border-margin-003.html.ini b/testing/web-platform/meta/mathml/relations/css-styling/padding-border-margin/padding-border-margin-003.html.ini deleted file mode 100644 index 4c664eeecf2d..000000000000 --- a/testing/web-platform/meta/mathml/relations/css-styling/padding-border-margin/padding-border-margin-003.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[padding-border-margin-003.html] - expected: FAIL