From 8de47d99c431f67af8690ed8045570a3cc809bf5 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Fri, 22 Jul 2022 14:47:45 +0000 Subject: [PATCH 01/10] Issue #1970 - Part 1: Remove unused moz-focus-outer code for buttons. --- layout/forms/nsButtonFrameRenderer.cpp | 62 +------------------ layout/forms/nsButtonFrameRenderer.h | 8 +-- .../focus-area-percent-units-1-ref.html | 11 ---- .../button/focus-area-percent-units-1.html | 27 +------- .../focus-area-percent-units-2-ref.html | 30 --------- .../button/focus-area-percent-units-2.html | 19 +----- 6 files changed, 8 insertions(+), 149 deletions(-) diff --git a/layout/forms/nsButtonFrameRenderer.cpp b/layout/forms/nsButtonFrameRenderer.cpp index 5372acb7fb..bf513374a0 100644 --- a/layout/forms/nsButtonFrameRenderer.cpp +++ b/layout/forms/nsButtonFrameRenderer.cpp @@ -36,9 +36,6 @@ nsButtonFrameRenderer::~nsButtonFrameRenderer() if (mInnerFocusStyle) { mInnerFocusStyle->FrameRelease(); } - if (mOuterFocusStyle) { - mOuterFocusStyle->FrameRelease(); - } #endif } @@ -274,8 +271,7 @@ nsButtonFrameRenderer::DisplayButton(nsDisplayListBuilder* aBuilder, // Only display focus rings if we actually have them. Since at most one // button would normally display a focus ring, most buttons won't have them. - if ((mOuterFocusStyle && mOuterFocusStyle->StyleBorder()->HasBorder()) || - (mInnerFocusStyle && mInnerFocusStyle->StyleBorder()->HasBorder())) { + if (mInnerFocusStyle && mInnerFocusStyle->StyleBorder()->HasBorder()) { aForeground->AppendNewToTop(new (aBuilder) nsDisplayButtonForeground(aBuilder, this)); } @@ -305,19 +301,7 @@ nsButtonFrameRenderer::PaintOutlineAndFocusBorders( DrawResult result = DrawResult::SUCCESS; - if (mOuterFocusStyle) { - // ---------- paint the outer focus border ------------- - - GetButtonOuterFocusRect(aRect, rect); - - result &= - nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame, - aDirtyRect, rect, mOuterFocusStyle, flags); - } - if (mInnerFocusStyle) { - // ---------- paint the inner focus border ------------- - GetButtonInnerFocusRect(aRect, rect); result &= @@ -357,17 +341,10 @@ nsButtonFrameRenderer::PaintBorder( } -void -nsButtonFrameRenderer::GetButtonOuterFocusRect(const nsRect& aRect, nsRect& focusRect) -{ - focusRect = aRect; -} - void nsButtonFrameRenderer::GetButtonRect(const nsRect& aRect, nsRect& r) { r = aRect; - r.Deflate(GetButtonOuterFocusBorderAndPadding()); } @@ -380,19 +357,6 @@ nsButtonFrameRenderer::GetButtonInnerFocusRect(const nsRect& aRect, nsRect& focu } -nsMargin -nsButtonFrameRenderer::GetButtonOuterFocusBorderAndPadding() -{ - nsMargin result(0,0,0,0); - - if (mOuterFocusStyle) { - mOuterFocusStyle->StylePadding()->GetPadding(result); - result += mOuterFocusStyle->StyleBorder()->GetComputedBorder(); - } - - return result; -} - nsMargin nsButtonFrameRenderer::GetButtonBorderAndPadding() { @@ -432,7 +396,7 @@ nsButtonFrameRenderer::GetButtonInnerFocusBorderAndPadding() nsMargin nsButtonFrameRenderer::GetAddedButtonBorderAndPadding() { - return GetButtonOuterFocusBorderAndPadding() + GetButtonInnerFocusMargin() + GetButtonInnerFocusBorderAndPadding(); + return GetButtonInnerFocusMargin() + GetButtonInnerFocusBorderAndPadding(); } /** @@ -449,9 +413,6 @@ nsButtonFrameRenderer::ReResolveStyles(nsPresContext* aPresContext) if (mInnerFocusStyle) { mInnerFocusStyle->FrameRelease(); } - if (mOuterFocusStyle) { - mOuterFocusStyle->FrameRelease(); - } #endif // style for the inner such as a dotted line (Windows) @@ -460,19 +421,10 @@ nsButtonFrameRenderer::ReResolveStyles(nsPresContext* aPresContext) CSSPseudoElementType::mozFocusInner, context); - // style for outer focus like a ridged border (MAC). - mOuterFocusStyle = - styleSet->ProbePseudoElementStyle(mFrame->GetContent()->AsElement(), - CSSPseudoElementType::mozFocusOuter, - context); - #ifdef DEBUG if (mInnerFocusStyle) { mInnerFocusStyle->FrameAddRef(); } - if (mOuterFocusStyle) { - mOuterFocusStyle->FrameAddRef(); - } #endif } @@ -482,8 +434,6 @@ nsButtonFrameRenderer::GetStyleContext(int32_t aIndex) const switch (aIndex) { case NS_BUTTON_RENDERER_FOCUS_INNER_CONTEXT_INDEX: return mInnerFocusStyle; - case NS_BUTTON_RENDERER_FOCUS_OUTER_CONTEXT_INDEX: - return mOuterFocusStyle; default: return nullptr; } @@ -501,14 +451,6 @@ nsButtonFrameRenderer::SetStyleContext(int32_t aIndex, nsStyleContext* aStyleCon #endif mInnerFocusStyle = aStyleContext; break; - case NS_BUTTON_RENDERER_FOCUS_OUTER_CONTEXT_INDEX: -#ifdef DEBUG - if (mOuterFocusStyle) { - mOuterFocusStyle->FrameRelease(); - } -#endif - mOuterFocusStyle = aStyleContext; - break; } #ifdef DEBUG aStyleContext->FrameAddRef(); diff --git a/layout/forms/nsButtonFrameRenderer.h b/layout/forms/nsButtonFrameRenderer.h index 8662c52e05..6557bc0927 100644 --- a/layout/forms/nsButtonFrameRenderer.h +++ b/layout/forms/nsButtonFrameRenderer.h @@ -20,8 +20,7 @@ class nsStyleContext; #define NS_BUTTON_RENDERER_FOCUS_INNER_CONTEXT_INDEX 0 -#define NS_BUTTON_RENDERER_FOCUS_OUTER_CONTEXT_INDEX 1 -#define NS_BUTTON_RENDERER_LAST_CONTEXT_INDEX NS_BUTTON_RENDERER_FOCUS_OUTER_CONTEXT_INDEX +#define NS_BUTTON_RENDERER_LAST_CONTEXT_INDEX NS_BUTTON_RENDERER_FOCUS_INNER_CONTEXT_INDEX class nsButtonFrameRenderer { typedef mozilla::image::DrawResult DrawResult; @@ -57,10 +56,8 @@ public: bool isActive(); bool isDisabled(); - void GetButtonOuterFocusRect(const nsRect& aRect, nsRect& aResult); void GetButtonRect(const nsRect& aRect, nsRect& aResult); void GetButtonInnerFocusRect(const nsRect& aRect, nsRect& aResult); - nsMargin GetButtonOuterFocusBorderAndPadding(); nsMargin GetButtonBorderAndPadding(); nsMargin GetButtonInnerFocusMargin(); nsMargin GetButtonInnerFocusBorderAndPadding(); @@ -76,9 +73,8 @@ protected: private: - // cached styles for focus and outline. + // cached style for focus and outline (used on Windows). RefPtr mInnerFocusStyle; - RefPtr mOuterFocusStyle; nsFrame* mFrame; }; diff --git a/layout/reftests/forms/button/focus-area-percent-units-1-ref.html b/layout/reftests/forms/button/focus-area-percent-units-1-ref.html index 6c66d5f178..a5c4c95f51 100644 --- a/layout/reftests/forms/button/focus-area-percent-units-1-ref.html +++ b/layout/reftests/forms/button/focus-area-percent-units-1-ref.html @@ -37,16 +37,5 @@
- - - - - -
- - - - -
diff --git a/layout/reftests/forms/button/focus-area-percent-units-1.html b/layout/reftests/forms/button/focus-area-percent-units-1.html index 17d65b3b02..23c97ab713 100644 --- a/layout/reftests/forms/button/focus-area-percent-units-1.html +++ b/layout/reftests/forms/button/focus-area-percent-units-1.html @@ -2,8 +2,8 @@ - @@ -22,18 +22,6 @@ button.mfi6::-moz-focus-inner { margin: 10px auto; } button.mfi7::-moz-focus-inner { margin: 10px; } button.mfi8::-moz-focus-inner { margin: 2em; } - - /* Testing percent and auto margin values on "-moz-focus-outer": - (just for completeness -- really, 'margin' has no effect on - the behavior of -moz-focus-outer) */ - button.mfo1::-moz-focus-outer { margin: 50%; } - button.mfo2::-moz-focus-outer { margin: 50% 10px; } - button.mfo3::-moz-focus-outer { margin: 10px 50%; } - button.mfo4::-moz-focus-outer { margin: auto; } - button.mfo5::-moz-focus-outer { margin: auto 10px; } - button.mfo6::-moz-focus-outer { margin: 10px auto; } - button.mfo7::-moz-focus-outer { margin: 10px; } - button.mfo8::-moz-focus-outer { margin: 2em; } @@ -47,16 +35,5 @@
- - - - - -
- - - - -
diff --git a/layout/reftests/forms/button/focus-area-percent-units-2-ref.html b/layout/reftests/forms/button/focus-area-percent-units-2-ref.html index 6b6a6056d4..b17db2753e 100644 --- a/layout/reftests/forms/button/focus-area-percent-units-2-ref.html +++ b/layout/reftests/forms/button/focus-area-percent-units-2-ref.html @@ -24,24 +24,6 @@ version of padding values that we actually expect to take effect: */ button.mfi4 > div { padding: 10px; } button.mfi5 > div { padding: 2em; } - - /* As above, set padding to 0 for all cases: */ - button.mfo1::-moz-focus-outer, - button.mfo2::-moz-focus-outer, - button.mfo3::-moz-focus-outer, - button.mfo4::-moz-focus-outer, - button.mfo5::-moz-focus-outer { padding: 0; } - - /* To make reference for -moz-focus-outer padding that we expect to - take effect, we'll put the padding on a wrapper-div (and bump the - button's outline to that div). */ - div.mfo4-wrapper { padding: 10px; } - div.mfo5-wrapper { padding: 20px; /* = 2em * 10px/em */ } - - button.mfo4, - button.mfo5 { outline: none; } - div.mfo4-wrapper, - div.mfo5-wrapper { display: inline-block; outline: 1px solid black; } @@ -52,17 +34,5 @@
- - - - -
-
- -
-
- -
-
diff --git a/layout/reftests/forms/button/focus-area-percent-units-2.html b/layout/reftests/forms/button/focus-area-percent-units-2.html index 3c0cb8612f..8ebf30343c 100644 --- a/layout/reftests/forms/button/focus-area-percent-units-2.html +++ b/layout/reftests/forms/button/focus-area-percent-units-2.html @@ -2,8 +2,8 @@ - @@ -22,13 +22,6 @@ button.mfi3::-moz-focus-inner { padding: 10px 50%; } button.mfi4::-moz-focus-inner { padding: 10px; } button.mfi5::-moz-focus-inner { padding: 2em; } - - /* Testing percent and auto padding values on "-moz-focus-outer": */ - button.mfo1::-moz-focus-outer { padding: 50%; } - button.mfo2::-moz-focus-outer { padding: 50% 10px; } - button.mfo3::-moz-focus-outer { padding: 10px 50%; } - button.mfo4::-moz-focus-outer { padding: 10px; } - button.mfo5::-moz-focus-outer { padding: 2em; } @@ -39,13 +32,5 @@
- - - - -
- - -
From e54e8f61bb9d35d7cb836c9b41e78233b720b1a1 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Fri, 22 Jul 2022 15:06:19 +0000 Subject: [PATCH 02/10] Issue #1970 - Part 2: Remove the extra padding on buttons Extra padding was created for a prospective -moz-focus-inner ring. We now just size that ring the same as the content frame, inflated by its CSS padding. --- layout/forms/nsButtonFrameRenderer.cpp | 81 ++++------------- layout/forms/nsButtonFrameRenderer.h | 16 ++-- layout/forms/nsHTMLButtonControlFrame.cpp | 101 +++------------------- layout/style/nsLayoutStylesheetCache.cpp | 1 - layout/style/res/forms.css | 17 ++-- widget/gtk/gtk3drawing.cpp | 3 - 6 files changed, 44 insertions(+), 175 deletions(-) diff --git a/layout/forms/nsButtonFrameRenderer.cpp b/layout/forms/nsButtonFrameRenderer.cpp index bf513374a0..eaf1f82c14 100644 --- a/layout/forms/nsButtonFrameRenderer.cpp +++ b/layout/forms/nsButtonFrameRenderer.cpp @@ -241,10 +241,9 @@ void nsDisplayButtonForeground::Paint(nsDisplayListBuilder* aBuilder, !presContext->GetTheme()->ThemeDrawsFocusForWidget(disp->mAppearance)) { nsRect r = nsRect(ToReferenceFrame(), mFrame->GetSize()); - // Draw the focus and outline borders. + // Draw the -moz-focus-inner border DrawResult result = - mBFR->PaintOutlineAndFocusBorders(aBuilder, presContext, *aCtx, - mVisibleRect, r); + mBFR->PaintInnerFocusBorder(aBuilder, presContext, *aCtx, mVisibleRect, r); nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, result); } @@ -278,20 +277,29 @@ nsButtonFrameRenderer::DisplayButton(nsDisplayListBuilder* aBuilder, return NS_OK; } +void +nsButtonFrameRenderer::GetButtonInnerFocusRect(const nsRect& aRect, nsRect& aResult) +{ + GetButtonRect(aRect, aResult); + aResult.Deflate(mFrame->GetUsedBorderAndPadding()); + + nsMargin innerFocusPadding(0,0,0,0); + if (mInnerFocusStyle) { + mInnerFocusStyle->StylePadding()->GetPadding(innerFocusPadding); + } + aResult.Inflate(innerFocusPadding); +} + DrawResult -nsButtonFrameRenderer::PaintOutlineAndFocusBorders( +nsButtonFrameRenderer::PaintInnerFocusBorder( nsDisplayListBuilder* aBuilder, nsPresContext* aPresContext, nsRenderingContext& aRenderingContext, const nsRect& aDirtyRect, const nsRect& aRect) { - // once we have all that we'll draw the focus if we have it. We will - // need to draw 2 focuses, the inner and the outer. This is so we - // can do any kind of look and feel. Some buttons have focus on the - // outside like mac and motif. While others like windows have it - // inside (dotted line). Usually only one will be specifed. But I - // guess you could have both if you wanted to. + // we draw the -moz-focus-inner border just inside the button's + // normal border and padding, to match Windows themes. nsRect rect; @@ -348,57 +356,6 @@ nsButtonFrameRenderer::GetButtonRect(const nsRect& aRect, nsRect& r) } -void -nsButtonFrameRenderer::GetButtonInnerFocusRect(const nsRect& aRect, nsRect& focusRect) -{ - GetButtonRect(aRect, focusRect); - focusRect.Deflate(GetButtonBorderAndPadding()); - focusRect.Deflate(GetButtonInnerFocusMargin()); -} - - -nsMargin -nsButtonFrameRenderer::GetButtonBorderAndPadding() -{ - return mFrame->GetUsedBorderAndPadding(); -} - -/** - * Gets the size of the buttons border this is the union of the normal and disabled borders. - */ -nsMargin -nsButtonFrameRenderer::GetButtonInnerFocusMargin() -{ - nsMargin innerFocusMargin(0,0,0,0); - - if (mInnerFocusStyle) { - const nsStyleMargin* margin = mInnerFocusStyle->StyleMargin(); - margin->GetMargin(innerFocusMargin); - } - - return innerFocusMargin; -} - -nsMargin -nsButtonFrameRenderer::GetButtonInnerFocusBorderAndPadding() -{ - nsMargin result(0,0,0,0); - - if (mInnerFocusStyle) { - mInnerFocusStyle->StylePadding()->GetPadding(result); - result += mInnerFocusStyle->StyleBorder()->GetComputedBorder(); - } - - return result; -} - -// gets all the focus borders and padding that will be added to the regular border -nsMargin -nsButtonFrameRenderer::GetAddedButtonBorderAndPadding() -{ - return GetButtonInnerFocusMargin() + GetButtonInnerFocusBorderAndPadding(); -} - /** * Call this when styles change */ @@ -415,7 +372,7 @@ nsButtonFrameRenderer::ReResolveStyles(nsPresContext* aPresContext) } #endif - // style for the inner such as a dotted line (Windows) + // get styles assigned to -moz-inner-focus (ie dotted border on Windows) mInnerFocusStyle = styleSet->ProbePseudoElementStyle(mFrame->GetContent()->AsElement(), CSSPseudoElementType::mozFocusInner, diff --git a/layout/forms/nsButtonFrameRenderer.h b/layout/forms/nsButtonFrameRenderer.h index 6557bc0927..d21303efaf 100644 --- a/layout/forms/nsButtonFrameRenderer.h +++ b/layout/forms/nsButtonFrameRenderer.h @@ -37,11 +37,11 @@ public: nsDisplayList* aBackground, nsDisplayList* aForeground); - DrawResult PaintOutlineAndFocusBorders(nsDisplayListBuilder* aBuilder, - nsPresContext* aPresContext, - nsRenderingContext& aRenderingContext, - const nsRect& aDirtyRect, - const nsRect& aRect); + DrawResult PaintInnerFocusBorder(nsDisplayListBuilder* aBuilder, + nsPresContext* aPresContext, + nsRenderingContext& aRenderingContext, + const nsRect& aDirtyRect, + const nsRect& aRect); DrawResult PaintBorder(nsDisplayListBuilder* aBuilder, nsPresContext* aPresContext, @@ -58,10 +58,6 @@ public: void GetButtonRect(const nsRect& aRect, nsRect& aResult); void GetButtonInnerFocusRect(const nsRect& aRect, nsRect& aResult); - nsMargin GetButtonBorderAndPadding(); - nsMargin GetButtonInnerFocusMargin(); - nsMargin GetButtonInnerFocusBorderAndPadding(); - nsMargin GetAddedButtonBorderAndPadding(); nsStyleContext* GetStyleContext(int32_t aIndex) const; void SetStyleContext(int32_t aIndex, nsStyleContext* aStyleContext); @@ -73,7 +69,7 @@ protected: private: - // cached style for focus and outline (used on Windows). + // cached style for optional inner focus outline (used on Windows). RefPtr mInnerFocusStyle; nsFrame* mFrame; diff --git a/layout/forms/nsHTMLButtonControlFrame.cpp b/layout/forms/nsHTMLButtonControlFrame.cpp index afedfa7748..1ec0ec6c94 100644 --- a/layout/forms/nsHTMLButtonControlFrame.cpp +++ b/layout/forms/nsHTMLButtonControlFrame.cpp @@ -157,10 +157,6 @@ nsHTMLButtonControlFrame::GetMinISize(nsRenderingContext* aRenderingContext) kid, nsLayoutUtils::MIN_ISIZE); - result += GetWritingMode().IsVertical() - ? mRenderer.GetAddedButtonBorderAndPadding().TopBottom() - : mRenderer.GetAddedButtonBorderAndPadding().LeftRight(); - return result; } @@ -175,10 +171,6 @@ nsHTMLButtonControlFrame::GetPrefISize(nsRenderingContext* aRenderingContext) kid, nsLayoutUtils::PREF_ISIZE); - result += GetWritingMode().IsVertical() - ? mRenderer.GetAddedButtonBorderAndPadding().TopBottom() - : mRenderer.GetAddedButtonBorderAndPadding().LeftRight(); - return result; } @@ -192,9 +184,6 @@ nsHTMLButtonControlFrame::Reflow(nsPresContext* aPresContext, DO_GLOBAL_REFLOW_COUNT("nsHTMLButtonControlFrame"); DISPLAY_REFLOW(aPresContext, this, aReflowInput, aDesiredSize, aStatus); - NS_PRECONDITION(aReflowInput.ComputedISize() != NS_INTRINSICSIZE, - "Should have real computed inline-size by now"); - if (mState & NS_FRAME_FIRST_REFLOW) { nsFormControlFrame::RegUnRegAccessKey(static_cast(this), true); } @@ -237,34 +226,6 @@ nsHTMLButtonControlFrame::Reflow(nsPresContext* aPresContext, NS_FRAME_SET_TRUNCATION(aStatus, aReflowInput, aDesiredSize); } -// Helper-function that lets us clone the button's reflow state, but with its -// ComputedWidth and ComputedHeight reduced by the amount of renderer-specific -// focus border and padding that we're using. (This lets us provide a more -// appropriate content-box size for descendents' percent sizes to resolve -// against.) -static ReflowInput -CloneReflowInputWithReducedContentBox( - const ReflowInput& aButtonReflowInput, - const nsMargin& aFocusPadding) -{ - nscoord adjustedWidth = - aButtonReflowInput.ComputedWidth() - aFocusPadding.LeftRight(); - adjustedWidth = std::max(0, adjustedWidth); - - // (Only adjust height if it's an actual length.) - nscoord adjustedHeight = aButtonReflowInput.ComputedHeight(); - if (adjustedHeight != NS_INTRINSICSIZE) { - adjustedHeight -= aFocusPadding.TopBottom(); - adjustedHeight = std::max(0, adjustedHeight); - } - - ReflowInput clone(aButtonReflowInput); - clone.SetComputedWidth(adjustedWidth); - clone.SetComputedHeight(adjustedHeight); - - return clone; -} - void nsHTMLButtonControlFrame::ReflowButtonContents(nsPresContext* aPresContext, ReflowOutput& aButtonDesiredSize, @@ -275,53 +236,17 @@ nsHTMLButtonControlFrame::ReflowButtonContents(nsPresContext* aPresContext, LogicalSize availSize = aButtonReflowInput.ComputedSize(wm); availSize.BSize(wm) = NS_INTRINSICSIZE; - // Buttons have some bonus renderer-determined border/padding, - // which occupies part of the button's content-box area: - LogicalMargin focusPadding = - LogicalMargin(wm, mRenderer.GetAddedButtonBorderAndPadding()); - - // See whether out availSize's inline-size is big enough. If it's - // smaller than our intrinsic min iSize, that means that the kid - // wouldn't really fit. In that case, we overflow into our internal - // focuspadding (which other browsers don't have) so that there's a - // little more space for it. - // Note that GetMinISize includes the focusPadding. - nscoord IOverflow = GetMinISize(aButtonReflowInput.mRenderingContext) - - aButtonReflowInput.ComputedISize(); - nscoord IFocusPadding = focusPadding.IStartEnd(wm); - nscoord focusPaddingReduction = std::min(IFocusPadding, - std::max(IOverflow, 0)); - if (focusPaddingReduction > 0) { - nscoord startReduction = focusPadding.IStart(wm); - if (focusPaddingReduction != IFocusPadding) { - startReduction = NSToCoordRound(startReduction * - (float(focusPaddingReduction) / - float(IFocusPadding))); - } - focusPadding.IStart(wm) -= startReduction; - focusPadding.IEnd(wm) -= focusPaddingReduction - startReduction; - } - // shorthand for a value we need to use in a bunch of places const LogicalMargin& clbp = aButtonReflowInput.ComputedLogicalBorderPadding(); - // Indent the child inside us by the focus border. We must do this separate - // from the regular border. - availSize.ISize(wm) -= focusPadding.IStartEnd(wm); - LogicalPoint childPos(wm); - childPos.I(wm) = focusPadding.IStart(wm) + clbp.IStart(wm); + childPos.I(wm) = clbp.IStart(wm); availSize.ISize(wm) = std::max(availSize.ISize(wm), 0); - // Give child a clone of the button's reflow state, with height/width reduced - // by focusPadding, so that descendants with height:100% don't protrude. - ReflowInput adjustedButtonReflowInput = - CloneReflowInputWithReducedContentBox(aButtonReflowInput, - focusPadding.GetPhysicalMargin(wm)); - ReflowInput contentsReflowInput(aPresContext, - adjustedButtonReflowInput, - aFirstKid, availSize); + aButtonReflowInput, + aFirstKid, + availSize); nsReflowStatus contentsReflowStatus; ReflowOutput contentsDesiredSize(aButtonReflowInput); @@ -346,9 +271,8 @@ nsHTMLButtonControlFrame::ReflowButtonContents(nsPresContext* aPresContext, buttonContentBox.BSize(wm) = aButtonReflowInput.ComputedBSize(); } else { // Button is intrinsically sized -- it should shrinkwrap the - // button-contents' bSize, plus any focus-padding space: - buttonContentBox.BSize(wm) = - contentsDesiredSize.BSize(wm) + focusPadding.BStartEnd(wm); + // button-contents' bSize: + buttonContentBox.BSize(wm) = contentsDesiredSize.BSize(wm); // Make sure we obey min/max-bSize in the case when we're doing intrinsic // sizing (we get it for free when we have a non-intrinsic @@ -363,8 +287,7 @@ nsHTMLButtonControlFrame::ReflowButtonContents(nsPresContext* aPresContext, if (aButtonReflowInput.ComputedISize() != NS_INTRINSICSIZE) { buttonContentBox.ISize(wm) = aButtonReflowInput.ComputedISize(); } else { - buttonContentBox.ISize(wm) = - contentsDesiredSize.ISize(wm) + focusPadding.IStartEnd(wm); + buttonContentBox.ISize(wm) = contentsDesiredSize.ISize(wm); buttonContentBox.ISize(wm) = NS_CSS_MINMAX(buttonContentBox.ISize(wm), aButtonReflowInput.ComputedMinISize(), @@ -372,16 +295,12 @@ nsHTMLButtonControlFrame::ReflowButtonContents(nsPresContext* aPresContext, } // Center child in the block-direction in the button - // (technically, inside of the button's focus-padding area) - nscoord extraSpace = - buttonContentBox.BSize(wm) - focusPadding.BStartEnd(wm) - - contentsDesiredSize.BSize(wm); + nscoord extraSpace = buttonContentBox.BSize(wm) - contentsDesiredSize.BSize(wm); childPos.B(wm) = std::max(0, extraSpace / 2); - // Adjust childPos.B() to be in terms of the button's frame-rect, instead of - // its focus-padding rect: - childPos.B(wm) += focusPadding.BStart(wm) + clbp.BStart(wm); + // Adjust childPos.B() to be in terms of the button's frame-rect: + childPos.B(wm) += clbp.BStart(wm); nsSize containerSize = (buttonContentBox + clbp.Size(wm)).GetPhysicalSize(wm); diff --git a/layout/style/nsLayoutStylesheetCache.cpp b/layout/style/nsLayoutStylesheetCache.cpp index 7c09202e6a..9591ad4f4a 100644 --- a/layout/style/nsLayoutStylesheetCache.cpp +++ b/layout/style/nsLayoutStylesheetCache.cpp @@ -637,7 +637,6 @@ nsLayoutStylesheetCache::BuildPreferenceSheet(RefPtr* aSheet, "button::-moz-focus-inner, input[type=\"reset\"]::-moz-focus-inner, " "input[type=\"button\"]::-moz-focus-inner, " "input[type=\"submit\"]::-moz-focus-inner { " - "padding: 1px 2px 1px 2px; " "border: %dpx %s transparent !important; }\n", focusRingWidth, focusRingStyle == 0 ? "solid" : "dotted"); diff --git a/layout/style/res/forms.css b/layout/style/res/forms.css index db75151d48..b0b171a892 100644 --- a/layout/style/res/forms.css +++ b/layout/style/res/forms.css @@ -627,12 +627,12 @@ input[type="button"], input[type="submit"] { -moz-appearance: button; /* The sum of border and padding on block-start and block-end - must be the same here, for text inputs, and for . + Note -moz-focus-inner padding does not affect button size. */ padding-block-start: 0px; - padding-inline-end: 6px; + padding-inline-end: 8px; padding-block-end: 0px; - padding-inline-start: 6px; + padding-inline-start: 8px; border: 2px outset ThreeDLightShadow; background-color: ButtonFace; cursor: default; @@ -725,9 +725,9 @@ input[type="button"]:active:hover, input[type="submit"]:active:hover { %ifndef XP_MACOSX padding-block-start: 0px; - padding-inline-end: 5px; + padding-inline-end: 7px; padding-block-end: 0px; - padding-inline-start: 7px; + padding-inline-start: 9px; %endif border-style: inset; background-color: ButtonFace; @@ -746,6 +746,7 @@ input[type="reset"]::-moz-focus-inner, input[type="button"]::-moz-focus-inner, input[type="submit"]::-moz-focus-inner, input[type="file"] > button[type="button"]::-moz-focus-inner { + /* Note this padding only affects the -moz-focus-inner ring, not the button itself */ padding-block-start: 0px; padding-inline-end: 2px; padding-block-end: 0px; @@ -776,9 +777,9 @@ input[type="submit"]:disabled { /* The sum of border and padding on block-start and block-end must be the same here and for text inputs */ padding-block-start: 0px; - padding-inline-end: 6px; + padding-inline-end: 8px; padding-block-end: 0px; - padding-inline-start: 6px; + padding-inline-start: 8px; border: 2px outset ThreeDLightShadow; cursor: inherit; } diff --git a/widget/gtk/gtk3drawing.cpp b/widget/gtk/gtk3drawing.cpp index c592fa51c9..c3216fbf34 100644 --- a/widget/gtk/gtk3drawing.cpp +++ b/widget/gtk/gtk3drawing.cpp @@ -2036,9 +2036,6 @@ moz_gtk_get_widget_border(WidgetNodeType widget, gint* left, gint* top, if (widget == MOZ_GTK_TOOLBAR_BUTTON) gtk_style_context_restore(style); - // XXX: Subtract 1 pixel from the border to account for the added - // -moz-focus-inner border (Bug 1228281). - *left -= 1; *top -= 1; *right -= 1; *bottom -= 1; moz_gtk_add_style_border(style, left, top, right, bottom); ReleaseStyleContext(style); From 4712b75d5cc810a183d967b457b0ec5a92346971 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Fri, 22 Jul 2022 16:38:07 +0000 Subject: [PATCH 03/10] Issue #1970 - Part 3: Update reftests. --- layout/reftests/bugs/491180-1-ref.html | 2 +- layout/reftests/bugs/491180-2-ref.html | 2 +- ...id-item-intrinsic-size-normal-001-ref.html | 82 +++++++++---------- ...sic-with-percents-across-elements-ref.html | 8 +- .../focus-area-percent-units-1-ref.html | 41 ---------- .../button/focus-area-percent-units-1.html | 39 --------- .../focus-area-percent-units-2-ref.html | 38 --------- .../button/focus-area-percent-units-2.html | 36 -------- .../button/percent-height-child-2-ref.html | 54 ------------ .../forms/button/percent-height-child-2.html | 63 -------------- .../button/percent-width-child-2-ref.html | 55 ------------- .../forms/button/percent-width-child-2.html | 62 -------------- layout/reftests/forms/button/reftest.list | 9 -- .../button/width-auto-size-em-ltr-ref.html | 1 - .../button/width-auto-size-em-rtl-ref.html | 1 - .../forms/button/width-auto-size-ltr-ref.html | 1 - .../forms/button/width-auto-size-rtl-ref.html | 1 - .../width-erode-all-focuspadding-ltr-ref.html | 20 ----- .../width-erode-all-focuspadding-ltr.html | 21 ----- ...h-erode-overflow-focuspadding-ltr-ref.html | 20 ----- ...width-erode-overflow-focuspadding-ltr.html | 21 ----- ...h-erode-overflow-focuspadding-rtl-ref.html | 21 ----- ...width-erode-overflow-focuspadding-rtl.html | 22 ----- ...width-erode-part-focuspadding-ltr-ref.html | 20 ----- .../width-erode-part-focuspadding-ltr.html | 21 ----- ...width-erode-part-focuspadding-rtl-ref.html | 21 ----- .../width-erode-part-focuspadding-rtl.html | 22 ----- .../forms/button/width-exact-fit-ltr.html | 2 +- .../forms/button/width-exact-fit-rtl.html | 2 +- .../ua-style-sheet-button-1a-ref.html | 4 +- .../ua-style-sheet-input-color-1-ref.html | 4 +- 31 files changed, 53 insertions(+), 663 deletions(-) delete mode 100644 layout/reftests/forms/button/focus-area-percent-units-1-ref.html delete mode 100644 layout/reftests/forms/button/focus-area-percent-units-1.html delete mode 100644 layout/reftests/forms/button/focus-area-percent-units-2-ref.html delete mode 100644 layout/reftests/forms/button/focus-area-percent-units-2.html delete mode 100644 layout/reftests/forms/button/percent-height-child-2-ref.html delete mode 100644 layout/reftests/forms/button/percent-height-child-2.html delete mode 100644 layout/reftests/forms/button/percent-width-child-2-ref.html delete mode 100644 layout/reftests/forms/button/percent-width-child-2.html delete mode 100644 layout/reftests/forms/button/width-erode-all-focuspadding-ltr-ref.html delete mode 100644 layout/reftests/forms/button/width-erode-all-focuspadding-ltr.html delete mode 100644 layout/reftests/forms/button/width-erode-overflow-focuspadding-ltr-ref.html delete mode 100644 layout/reftests/forms/button/width-erode-overflow-focuspadding-ltr.html delete mode 100644 layout/reftests/forms/button/width-erode-overflow-focuspadding-rtl-ref.html delete mode 100644 layout/reftests/forms/button/width-erode-overflow-focuspadding-rtl.html delete mode 100644 layout/reftests/forms/button/width-erode-part-focuspadding-ltr-ref.html delete mode 100644 layout/reftests/forms/button/width-erode-part-focuspadding-ltr.html delete mode 100644 layout/reftests/forms/button/width-erode-part-focuspadding-rtl-ref.html delete mode 100644 layout/reftests/forms/button/width-erode-part-focuspadding-rtl.html diff --git a/layout/reftests/bugs/491180-1-ref.html b/layout/reftests/bugs/491180-1-ref.html index 2cf61ad165..e9dcf7cc56 100644 --- a/layout/reftests/bugs/491180-1-ref.html +++ b/layout/reftests/bugs/491180-1-ref.html @@ -1,5 +1,5 @@ -
+
Some text
diff --git a/layout/reftests/bugs/491180-2-ref.html b/layout/reftests/bugs/491180-2-ref.html index 2b7a85630d..7ab4aa58c5 100644 --- a/layout/reftests/bugs/491180-2-ref.html +++ b/layout/reftests/bugs/491180-2-ref.html @@ -1,4 +1,4 @@ -
Some text
+
Some text
diff --git a/layout/reftests/css-grid/grid-item-intrinsic-size-normal-001-ref.html b/layout/reftests/css-grid/grid-item-intrinsic-size-normal-001-ref.html index 98cd026d6d..c0dbcbac03 100644 --- a/layout/reftests/css-grid/grid-item-intrinsic-size-normal-001-ref.html +++ b/layout/reftests/css-grid/grid-item-intrinsic-size-normal-001-ref.html @@ -147,79 +147,79 @@ button { var buttonSizes = [ ['32px', '4px'], - ['8px', '4px'], - ['8px', '4px'], - ['8px', '4px'], - ['8px', '4px'], - ['2px', '4px'], + ['0px', '0px'], + ['0px', '4px'], + ['0px', '4px'], + ['0px', '4px'], + ['0px', '4px'], ['32px', '20px'], ['10px', '20px'], - ['8px', '20px'], - ['8px', '20px'], - ['8px', '20px'], - ['8px', '20px'], - ['8px', '20px'], - ['8px', '20px'], + ['0px', '20px'], + ['0px', '20px'], + ['0px', '20px'], + ['0px', '20px'], + ['0px', '20px'], + ['0px', '20px'], ['32px', '4px'], ['10px', '4px'], - ['8px', '4px'], - ['8px', '4px'], - ['8px', '4px'], - ['8px', '4px'], - ['8px', '4px'], - ['2px', '4px'], - ['4px', '32px'], - ['2px', '32px'], - ['4px', '4px'], - ['2px', '4px'], - ['4px', '32px'], - ['2px', '32px'], + ['0px', '0px'], + ['0px', '0px'], + ['0px', '4px'], + ['0px', '4px'], + ['0px', '4px'], + ['0px', '4px'], ['4px', '32px'], ['2px', '32px'], + ['0px', '0px'], + ['2px', '0px'], + ['0px', '32px'], + ['0px', '32px'], + ['0px', '32px'], + ['0px', '32px'], ['20px', '32px'], ['20px', '10px'], - ['20px', '4px'], - ['20px', '4px'], + ['20px', '0px'], + ['20px', '0px'], ['20px', '32px'], ['20px', '10px'], ['20px', '32px'], ['20px', '10px'], ['4px', '32px'], ['4px', '10px'], - ['8px', '4px'], - ['8px', '4px'], - ['8px', '32px'], - ['8px', '10px'], - ['8px', '32px'], - ['8px', '10px'], - ['20px', '4px'], - ['20px', '4px'], + ['0px', '0px'], + ['0px', '0px'], + ['0px', '32px'], + ['0px', '10px'], + ['0px', '32px'], + ['0px', '10px'], ['20px', '4px'], ['20px', '4px'], + ['20px', '0px'], + ['20px', '0px'], ['20px', '4px'], ['20px', '2px'], ['20px', '4px'], ['20px', '2px'], - ['20px', '4px'], - ['20px', '4px'], - ['20px', '4px'], - ['20px', '4px'], + ['20px', '0px'], + ['20px', '0px'], + ['20px', '0px'], + ['20px', '0px'], ['20px', '32px'], ['20px', '10px'], ['20px', '32px'], ['20px', '10px'], ['32px', '20px'], ['10px', '20px'], - ['8px', '20px'], - ['8px', '20px'], + ['0px', '20px'], + ['0px', '20px'], ['32px', '20px'], ['10px', '20px'], ['32px', '20px'], ['10px', '20px'], ['4px', '20px'], ['2px', '20px'], - ['4px', '20px'], - ['4px', '20px'], + ['0px', '20px'], + ['0px', '20px'], ['4px', '20px'], ['2px', '20px'], ['4px', '20px'], diff --git a/layout/reftests/css-sizing/min-intrinsic-with-percents-across-elements-ref.html b/layout/reftests/css-sizing/min-intrinsic-with-percents-across-elements-ref.html index dbd50f8f4b..57dd5ac56c 100644 --- a/layout/reftests/css-sizing/min-intrinsic-with-percents-across-elements-ref.html +++ b/layout/reftests/css-sizing/min-intrinsic-with-percents-across-elements-ref.html @@ -89,14 +89,14 @@ canvas { - - + +
empty input type="button", width: 50%
- - + +
empty input type="button", max-width: 50%
diff --git a/layout/reftests/forms/button/focus-area-percent-units-1-ref.html b/layout/reftests/forms/button/focus-area-percent-units-1-ref.html deleted file mode 100644 index a5c4c95f51..0000000000 --- a/layout/reftests/forms/button/focus-area-percent-units-1-ref.html +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Reference case for bug 1272983 - - - - - - - -
- - - - -
- - diff --git a/layout/reftests/forms/button/focus-area-percent-units-1.html b/layout/reftests/forms/button/focus-area-percent-units-1.html deleted file mode 100644 index 23c97ab713..0000000000 --- a/layout/reftests/forms/button/focus-area-percent-units-1.html +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - Testcase for bug 1272983 - - - - - - - -
- - - - -
- - diff --git a/layout/reftests/forms/button/focus-area-percent-units-2-ref.html b/layout/reftests/forms/button/focus-area-percent-units-2-ref.html deleted file mode 100644 index b17db2753e..0000000000 --- a/layout/reftests/forms/button/focus-area-percent-units-2-ref.html +++ /dev/null @@ -1,38 +0,0 @@ - - - - - Reference case for bug 1272983 - - - - - - -
- - -
- - diff --git a/layout/reftests/forms/button/focus-area-percent-units-2.html b/layout/reftests/forms/button/focus-area-percent-units-2.html deleted file mode 100644 index 8ebf30343c..0000000000 --- a/layout/reftests/forms/button/focus-area-percent-units-2.html +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - Testcase for bug 1272983 - - - - - - -
- - -
- - diff --git a/layout/reftests/forms/button/percent-height-child-2-ref.html b/layout/reftests/forms/button/percent-height-child-2-ref.html deleted file mode 100644 index 7491ed71e4..0000000000 --- a/layout/reftests/forms/button/percent-height-child-2-ref.html +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - - - -
-
abc
-
- -
-
abc
-
- - -
-
abc
-
- -
-
abc
-
- - - diff --git a/layout/reftests/forms/button/percent-height-child-2.html b/layout/reftests/forms/button/percent-height-child-2.html deleted file mode 100644 index 7eecea1ad4..0000000000 --- a/layout/reftests/forms/button/percent-height-child-2.html +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/layout/reftests/forms/button/percent-width-child-2-ref.html b/layout/reftests/forms/button/percent-width-child-2-ref.html deleted file mode 100644 index 19a24a7375..0000000000 --- a/layout/reftests/forms/button/percent-width-child-2-ref.html +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - -
-
abc
-
- -
-
abc
-
- - -
-
abc
-
- -
-
abc
-
- - - diff --git a/layout/reftests/forms/button/percent-width-child-2.html b/layout/reftests/forms/button/percent-width-child-2.html deleted file mode 100644 index d46ff62af5..0000000000 --- a/layout/reftests/forms/button/percent-width-child-2.html +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/layout/reftests/forms/button/reftest.list b/layout/reftests/forms/button/reftest.list index db314516df..7492c8f08c 100644 --- a/layout/reftests/forms/button/reftest.list +++ b/layout/reftests/forms/button/reftest.list @@ -1,9 +1,6 @@ == first-letter-1.html first-letter-1-ref.html != first-letter-1.html first-letter-1-noref.html -== focus-area-percent-units-1.html focus-area-percent-units-1-ref.html -== focus-area-percent-units-2.html focus-area-percent-units-2-ref.html - == max-height.html max-height-ref.html == min-height.html min-height-ref.html == overflow-areas-1.html overflow-areas-1-ref.html @@ -31,13 +28,7 @@ pref(browser.display.focus_ring_width,1) == percent-width-child-2.html percent- == width-auto-size-em-ltr.html width-auto-size-em-ltr-ref.html == width-auto-size-ltr.html width-auto-size-ltr-ref.html == width-exact-fit-ltr.html width-auto-size-ltr-ref.html -== width-erode-part-focuspadding-ltr.html width-erode-part-focuspadding-ltr-ref.html -== width-erode-all-focuspadding-ltr.html width-erode-all-focuspadding-ltr-ref.html -== width-erode-overflow-focuspadding-ltr.html width-erode-overflow-focuspadding-ltr-ref.html == width-auto-size-em-rtl.html width-auto-size-em-rtl-ref.html == width-auto-size-rtl.html width-auto-size-rtl-ref.html == width-exact-fit-rtl.html width-auto-size-rtl-ref.html -== width-erode-part-focuspadding-rtl.html width-erode-part-focuspadding-rtl-ref.html -== width-erode-all-focuspadding-rtl.html width-erode-all-focuspadding-rtl-ref.html -== width-erode-overflow-focuspadding-rtl.html width-erode-overflow-focuspadding-rtl-ref.html == display-grid-flex-columnset.html display-grid-flex-columnset-ref.html diff --git a/layout/reftests/forms/button/width-auto-size-em-ltr-ref.html b/layout/reftests/forms/button/width-auto-size-em-ltr-ref.html index 1e7ab40bba..4a998c3435 100644 --- a/layout/reftests/forms/button/width-auto-size-em-ltr-ref.html +++ b/layout/reftests/forms/button/width-auto-size-em-ltr-ref.html @@ -11,7 +11,6 @@ div.button { span { display: inline-block; vertical-align: middle; height: 2em; width: 5em; border: 2px solid blue; - margin: 1px 3px; /* for implicit focuspadding */ } diff --git a/layout/reftests/forms/button/width-auto-size-em-rtl-ref.html b/layout/reftests/forms/button/width-auto-size-em-rtl-ref.html index 1214714744..59f3ba424b 100644 --- a/layout/reftests/forms/button/width-auto-size-em-rtl-ref.html +++ b/layout/reftests/forms/button/width-auto-size-em-rtl-ref.html @@ -12,7 +12,6 @@ div.button { span { display: inline-block; vertical-align: middle; height: 2em; width: 5em; border: 2px solid blue; - margin: 1px 3px; /* for implicit focuspadding */ } diff --git a/layout/reftests/forms/button/width-auto-size-ltr-ref.html b/layout/reftests/forms/button/width-auto-size-ltr-ref.html index c1ba89860e..48372131ea 100644 --- a/layout/reftests/forms/button/width-auto-size-ltr-ref.html +++ b/layout/reftests/forms/button/width-auto-size-ltr-ref.html @@ -12,7 +12,6 @@ div.button { span { display: inline-block; vertical-align: middle; height: 20px; width: 50px; border: 2px solid blue; - margin: 1px 3px; /* for implicit focuspadding */ } diff --git a/layout/reftests/forms/button/width-auto-size-rtl-ref.html b/layout/reftests/forms/button/width-auto-size-rtl-ref.html index 3e09016dc3..f644a196f2 100644 --- a/layout/reftests/forms/button/width-auto-size-rtl-ref.html +++ b/layout/reftests/forms/button/width-auto-size-rtl-ref.html @@ -13,7 +13,6 @@ div.button { span { display: inline-block; vertical-align: middle; height: 20px; width: 50px; border: 2px solid blue; - margin: 1px 3px; /* for implicit focuspadding */ } diff --git a/layout/reftests/forms/button/width-erode-all-focuspadding-ltr-ref.html b/layout/reftests/forms/button/width-erode-all-focuspadding-ltr-ref.html deleted file mode 100644 index c85da00e3c..0000000000 --- a/layout/reftests/forms/button/width-erode-all-focuspadding-ltr-ref.html +++ /dev/null @@ -1,20 +0,0 @@ - - - -
diff --git a/layout/reftests/forms/button/width-erode-all-focuspadding-ltr.html b/layout/reftests/forms/button/width-erode-all-focuspadding-ltr.html deleted file mode 100644 index 4978a57e4e..0000000000 --- a/layout/reftests/forms/button/width-erode-all-focuspadding-ltr.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - diff --git a/layout/reftests/forms/button/width-erode-overflow-focuspadding-ltr-ref.html b/layout/reftests/forms/button/width-erode-overflow-focuspadding-ltr-ref.html deleted file mode 100644 index 6f7047cce3..0000000000 --- a/layout/reftests/forms/button/width-erode-overflow-focuspadding-ltr-ref.html +++ /dev/null @@ -1,20 +0,0 @@ - - - -
diff --git a/layout/reftests/forms/button/width-erode-overflow-focuspadding-ltr.html b/layout/reftests/forms/button/width-erode-overflow-focuspadding-ltr.html deleted file mode 100644 index daecef56e4..0000000000 --- a/layout/reftests/forms/button/width-erode-overflow-focuspadding-ltr.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - diff --git a/layout/reftests/forms/button/width-erode-overflow-focuspadding-rtl-ref.html b/layout/reftests/forms/button/width-erode-overflow-focuspadding-rtl-ref.html deleted file mode 100644 index 1b36154cfc..0000000000 --- a/layout/reftests/forms/button/width-erode-overflow-focuspadding-rtl-ref.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - -
diff --git a/layout/reftests/forms/button/width-erode-overflow-focuspadding-rtl.html b/layout/reftests/forms/button/width-erode-overflow-focuspadding-rtl.html deleted file mode 100644 index b76a3957a5..0000000000 --- a/layout/reftests/forms/button/width-erode-overflow-focuspadding-rtl.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - - diff --git a/layout/reftests/forms/button/width-erode-part-focuspadding-ltr-ref.html b/layout/reftests/forms/button/width-erode-part-focuspadding-ltr-ref.html deleted file mode 100644 index 59cbd02086..0000000000 --- a/layout/reftests/forms/button/width-erode-part-focuspadding-ltr-ref.html +++ /dev/null @@ -1,20 +0,0 @@ - - - -
diff --git a/layout/reftests/forms/button/width-erode-part-focuspadding-ltr.html b/layout/reftests/forms/button/width-erode-part-focuspadding-ltr.html deleted file mode 100644 index c0d64b2797..0000000000 --- a/layout/reftests/forms/button/width-erode-part-focuspadding-ltr.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - diff --git a/layout/reftests/forms/button/width-erode-part-focuspadding-rtl-ref.html b/layout/reftests/forms/button/width-erode-part-focuspadding-rtl-ref.html deleted file mode 100644 index 0765a673df..0000000000 --- a/layout/reftests/forms/button/width-erode-part-focuspadding-rtl-ref.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - -
diff --git a/layout/reftests/forms/button/width-erode-part-focuspadding-rtl.html b/layout/reftests/forms/button/width-erode-part-focuspadding-rtl.html deleted file mode 100644 index 9b88269385..0000000000 --- a/layout/reftests/forms/button/width-erode-part-focuspadding-rtl.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - - diff --git a/layout/reftests/forms/button/width-exact-fit-ltr.html b/layout/reftests/forms/button/width-exact-fit-ltr.html index 58db0aa70c..4978a57e4e 100644 --- a/layout/reftests/forms/button/width-exact-fit-ltr.html +++ b/layout/reftests/forms/button/width-exact-fit-ltr.html @@ -7,7 +7,7 @@ button { border: 2px solid fuchsia; padding: 2px; font-size: 10px; - width: 68px; + width: 62px; border-radius: 0; /* override mobile/android/themes/core/content.css */ } diff --git a/layout/reftests/forms/button/width-exact-fit-rtl.html b/layout/reftests/forms/button/width-exact-fit-rtl.html index 996a69d831..d4b028b48e 100644 --- a/layout/reftests/forms/button/width-exact-fit-rtl.html +++ b/layout/reftests/forms/button/width-exact-fit-rtl.html @@ -8,7 +8,7 @@ button { border: 2px solid fuchsia; padding: 2px; font-size: 10px; - width: 68px; + width: 62px; border-radius: 0; /* override mobile/android/themes/core/content.css */ } diff --git a/layout/reftests/writing-mode/ua-style-sheet-button-1a-ref.html b/layout/reftests/writing-mode/ua-style-sheet-button-1a-ref.html index 1c3bc73906..7567da08a6 100644 --- a/layout/reftests/writing-mode/ua-style-sheet-button-1a-ref.html +++ b/layout/reftests/writing-mode/ua-style-sheet-button-1a-ref.html @@ -10,12 +10,12 @@ .rtl button, .ltr input[type="button"], .rtl input[type="button"] { - padding: 0px 6px; + padding: 0px 8px; } .v-rl button, .v-rl input[type="button"] { - padding: 6px 0px; + padding: 8px 0px; }
diff --git a/layout/reftests/writing-mode/ua-style-sheet-input-color-1-ref.html b/layout/reftests/writing-mode/ua-style-sheet-input-color-1-ref.html index ddd3c7ec43..9b6bfe1a87 100644 --- a/layout/reftests/writing-mode/ua-style-sheet-input-color-1-ref.html +++ b/layout/reftests/writing-mode/ua-style-sheet-input-color-1-ref.html @@ -10,13 +10,13 @@ .rtl input[type="color"]:-moz-system-metric(color-picker-available) { width: 64px; height: 23px; - padding: 0px 6px; + padding: 0px 8px; } .v-rl input[type="color"]:-moz-system-metric(color-picker-available) { height: 64px; width: 23px; - padding: 6px 0px; + padding: 8px 0px; }
From 8101720ca8beebc19b8a0bb0947843565dae0c0c Mon Sep 17 00:00:00 2001 From: Moonchild Date: Fri, 22 Jul 2022 18:25:57 +0000 Subject: [PATCH 04/10] Issue #1970 - Part 4: Don't overflow -moz-focus-inner border. --- layout/forms/nsButtonFrameRenderer.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/layout/forms/nsButtonFrameRenderer.cpp b/layout/forms/nsButtonFrameRenderer.cpp index eaf1f82c14..5113572995 100644 --- a/layout/forms/nsButtonFrameRenderer.cpp +++ b/layout/forms/nsButtonFrameRenderer.cpp @@ -283,11 +283,23 @@ nsButtonFrameRenderer::GetButtonInnerFocusRect(const nsRect& aRect, nsRect& aRes GetButtonRect(aRect, aResult); aResult.Deflate(mFrame->GetUsedBorderAndPadding()); - nsMargin innerFocusPadding(0,0,0,0); if (mInnerFocusStyle) { + nsMargin innerFocusPadding(0,0,0,0); mInnerFocusStyle->StylePadding()->GetPadding(innerFocusPadding); + + nsMargin framePadding = mFrame->GetUsedPadding(); + + innerFocusPadding.top = std::min(innerFocusPadding.top, + framePadding.top); + innerFocusPadding.right = std::min(innerFocusPadding.right, + framePadding.right); + innerFocusPadding.bottom = std::min(innerFocusPadding.bottom, + framePadding.bottom); + innerFocusPadding.left = std::min(innerFocusPadding.left, + framePadding.left); + + aResult.Inflate(innerFocusPadding); } - aResult.Inflate(innerFocusPadding); } DrawResult @@ -372,7 +384,7 @@ nsButtonFrameRenderer::ReResolveStyles(nsPresContext* aPresContext) } #endif - // get styles assigned to -moz-inner-focus (ie dotted border on Windows) + // get styles assigned to -moz-focus-inner (ie dotted border on Windows) mInnerFocusStyle = styleSet->ProbePseudoElementStyle(mFrame->GetContent()->AsElement(), CSSPseudoElementType::mozFocusInner, From bbbfa54ee443eb3f64ff5f9ef4d2f0ad198f9844 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Sat, 23 Jul 2022 17:36:23 +0000 Subject: [PATCH 05/10] Issue #1970 - Part 5: Move combobox/select padding to the select rule. This doesn't change behavior by default but allows authors to remove the padding previously enforced to align with focus ring padding, if they wish to. --- .../forms/select/vertical-centering-ref.html | 13 +++++-------- .../reftests/forms/select/vertical-centering.html | 5 ++--- layout/style/res/forms.css | 8 ++------ 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/layout/reftests/forms/select/vertical-centering-ref.html b/layout/reftests/forms/select/vertical-centering-ref.html index f5d8554563..82bbb7d3d0 100644 --- a/layout/reftests/forms/select/vertical-centering-ref.html +++ b/layout/reftests/forms/select/vertical-centering-ref.html @@ -7,15 +7,12 @@ select { -moz-appearance: none; border: none; - font-family: Ahem; - font-size: 20px; + font: 20px/1 Ahem; box-sizing: content-box; - /* - * Why are these top/bottom paddings 7px rather than 10px? 1px each is - * eaten up by padding on the combobox display area, but I have no idea - * where the extra 4px somewhere else are coming from... - */ - padding: 7px 0 7px 0; + /* The testcase has 20px-tall text, which should be centered in a 40px-tall + content-box (with 10px of extra space above and below). We emulate that + by having explicit 10px of padding on top and bottom. */ + padding: 10px 0 10px 0; } diff --git a/layout/style/res/forms.css b/layout/style/res/forms.css index b0b171a892..a808822c89 100644 --- a/layout/style/res/forms.css +++ b/layout/style/res/forms.css @@ -251,6 +251,8 @@ select { display: inline-block; page-break-inside: avoid; overflow-clip-box: padding-box !important; /* bug 992447 */ + padding-block-start: 1px; + padding-block-end: 1px; } /* Need the "select[size][multiple]" selector to override the settings on @@ -263,8 +265,6 @@ select[size][multiple] { background-color: -moz-Field; color: -moz-FieldText; vertical-align: text-bottom; - padding-block-start: 1px; - padding-block-end: 1px; padding-inline-start: 0; padding-inline-end: 0; -moz-appearance: listbox; @@ -327,10 +327,6 @@ select:empty { *|*::-moz-display-comboboxcontrol-frame { overflow: -moz-hidden-unscrollable; - /* This block-start/end padding plus the combobox block-start/end border need to - add up to the block-start/end borderpadding of text inputs and buttons */ - padding-block-start: 1px; - padding-block-end: 1px; padding-inline-start: 4px; padding-inline-end: 0; color: inherit; From 7203916733b75bd337daa9f58661619052237419 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Sat, 23 Jul 2022 23:35:18 +0000 Subject: [PATCH 06/10] Issue #1970 - Part 6: Rename CalcLineHeight(), and cache used line height To better distinguish the calculation of line height (still present with args) and simply getting the line height without args, it's now called GetLineHeight() This also introduces `mLineHeight` to cache specifically calculated line heights that aren't "auto" (which is a magic value), and it opens up the possibility to override it in Part 7. --- layout/generic/BlockReflowInput.cpp | 3 +-- layout/generic/ReflowInput.cpp | 14 +++++++++----- layout/generic/ReflowInput.h | 18 +++++++++++------- layout/generic/nsBRFrame.cpp | 2 +- layout/generic/nsRubyBaseContainerFrame.cpp | 2 +- 5 files changed, 23 insertions(+), 16 deletions(-) diff --git a/layout/generic/BlockReflowInput.cpp b/layout/generic/BlockReflowInput.cpp index 86248ac141..e73ae6331c 100644 --- a/layout/generic/BlockReflowInput.cpp +++ b/layout/generic/BlockReflowInput.cpp @@ -43,6 +43,7 @@ BlockReflowInput::BlockReflowInput(const ReflowInput& aReflowInput, mOverflowTracker(nullptr), mBorderPadding(mReflowInput.ComputedLogicalBorderPadding()), mPrevBEndMargin(), + mMinLineHeight(aReflowInput.GetLineHeight()), mLineNumber(0), mFloatBreakType(StyleClear::None), mConsumedBSize(aConsumedBSize) @@ -141,8 +142,6 @@ BlockReflowInput::BlockReflowInput(const ReflowInput& aReflowInput, mPrevChild = nullptr; mCurrentLine = aFrame->LinesEnd(); - - mMinLineHeight = aReflowInput.CalcLineHeight(); } nscoord diff --git a/layout/generic/ReflowInput.cpp b/layout/generic/ReflowInput.cpp index 077c68b5be..8a295f4958 100644 --- a/layout/generic/ReflowInput.cpp +++ b/layout/generic/ReflowInput.cpp @@ -2802,15 +2802,19 @@ ComputeLineHeight(nsStyleContext* aStyleContext, return GetNormalLineHeight(fm); } -nscoord -ReflowInput::CalcLineHeight() const -{ +nscoord ReflowInput::GetLineHeight() const { + if (mLineHeight != NS_AUTOHEIGHT) { + return mLineHeight; + } + nscoord blockBSize = nsLayoutUtils::IsNonWrapperBlock(mFrame) ? ComputedBSize() : (mCBReflowInput ? mCBReflowInput->ComputedBSize() : NS_AUTOHEIGHT); - return CalcLineHeight(mFrame->GetContent(), mFrame->StyleContext(), blockBSize, - nsLayoutUtils::FontSizeInflationFor(mFrame)); + mLineHeight = CalcLineHeight(mFrame->GetContent(), + mFrame->StyleContext(), + blockBSize, + nsLayoutUtils::FontSizeInflationFor(mFrame)); } /* static */ nscoord diff --git a/layout/generic/ReflowInput.h b/layout/generic/ReflowInput.h index 1d2df6af68..d8e0518399 100644 --- a/layout/generic/ReflowInput.h +++ b/layout/generic/ReflowInput.h @@ -744,18 +744,19 @@ public: nscoord GetContainingBlockContentISize(mozilla::WritingMode aWritingMode) const; /** - * Calculate the used line-height property. The return value will be >= 0. + * Get the used line-height property. The return value will be >= 0. */ - nscoord CalcLineHeight() const; + nscoord GetLineHeight() const; /** - * Same as CalcLineHeight() above, but doesn't need a reflow state. + * Calculate the used line-height property without a reflow input instance. + * The return value will be >= 0. * * @param aBlockBSize The computed block size of the content rect of the block - * that the line should fill. - * Only used with line-height:-moz-block-height. - * NS_AUTOHEIGHT results in a normal line-height for - * line-height:-moz-block-height. + * that the line should fill. + * Only used with line-height:-moz-block-height. + * NS_AUTOHEIGHT results in a normal line-height for + * line-height:-moz-block-height. * @param aFontSizeInflation The result of the appropriate * nsLayoutUtils::FontSizeInflationFor call, * or 1.0 if during intrinsic size @@ -1000,6 +1001,9 @@ protected: nscoord* aOutsideBoxSizing) const; void CalculateBlockSideMargins(nsIAtom* aFrameType); + + // Cache the used line-height property. + mutable nscoord mLineHeight = NS_AUTOHEIGHT; }; } // namespace mozilla diff --git a/layout/generic/nsBRFrame.cpp b/layout/generic/nsBRFrame.cpp index 08c0fe3dda..e02711353a 100644 --- a/layout/generic/nsBRFrame.cpp +++ b/layout/generic/nsBRFrame.cpp @@ -125,7 +125,7 @@ BRFrame::Reflow(nsPresContext* aPresContext, RefPtr fm = nsLayoutUtils::GetInflatedFontMetricsForFrame(this); if (fm) { - nscoord logicalHeight = aReflowInput.CalcLineHeight(); + nscoord logicalHeight = aReflowInput.GetLineHeight(); finalSize.BSize(wm) = logicalHeight; aMetrics.SetBlockStartAscent(nsLayoutUtils::GetCenteredFontBaseline( fm, logicalHeight, wm.IsLineInverted())); diff --git a/layout/generic/nsRubyBaseContainerFrame.cpp b/layout/generic/nsRubyBaseContainerFrame.cpp index 91bbf5de85..ed2a35b417 100644 --- a/layout/generic/nsRubyBaseContainerFrame.cpp +++ b/layout/generic/nsRubyBaseContainerFrame.cpp @@ -363,7 +363,7 @@ nsRubyBaseContainerFrame::Reflow(nsPresContext* aPresContext, // Line number is useless for ruby text // XXX nullptr here may cause problem, see comments for // nsLineLayout::mBlockRI and nsLineLayout::AddFloat - lineLayout->Init(nullptr, reflowInput->CalcLineHeight(), -1); + lineLayout->Init(nullptr, reflowInput->GetLineHeight(), -1); reflowInput->mLineLayout = lineLayout; // Border and padding are suppressed on ruby text containers. From b18a680d4fc31ab0af5cb75520efaabc443aa8e0 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Sun, 24 Jul 2022 12:31:32 +0000 Subject: [PATCH 07/10] Issue #1970 - Part 7: Restore proper spacing in select for CJK/asian The issue is that select elements may contain some non-Latin characters that need extra block-size to display than the one line-height calculated by using a Latin font spec in the style. Before this patch, when a control has an unconstrained block-size, we set the element's block-size to one line-height in Reflow(), which is intended to properly initialize `BlockReflowInput::mMinLineHeight` since it uses `line-height:-moz-block-height`. However, this simply prevents the display from choosing a larger block-size after the reflow occurs. Previously, this discrepancy was absorbed by the extra padding present to make select elements the same intrinsic size as buttons, but since we did away with that, we're losing the extra space and the font glyphs get clipped. This patch fixes the issue by carrying the computed line height over to the element's display so that its computed block-size is still unconstrained. This way it can accommodate taller characters in the display text. After this patch, a + + + + + + + + \ No newline at end of file diff --git a/layout/generic/ReflowInput.cpp b/layout/generic/ReflowInput.cpp index 8a295f4958..d76287de57 100644 --- a/layout/generic/ReflowInput.cpp +++ b/layout/generic/ReflowInput.cpp @@ -2817,6 +2817,17 @@ nscoord ReflowInput::GetLineHeight() const { nsLayoutUtils::FontSizeInflationFor(mFrame)); } +void ReflowInput::SetLineHeight(nscoord aLineHeight) { + MOZ_ASSERT(aLineHeight >= 0, "aLineHeight must be >= 0!"); + + if (mLineHeight != aLineHeight) { + mLineHeight = aLineHeight; + // Setting used line height can change a frame's block-size if mFrame's + // block-size behaves as auto. + InitResizeFlags(mFrame->PresContext(), mFrame->GetType()); + } +} + /* static */ nscoord ReflowInput::CalcLineHeight(nsIContent* aContent, nsStyleContext* aStyleContext, diff --git a/layout/generic/ReflowInput.h b/layout/generic/ReflowInput.h index d8e0518399..a70549d8eb 100644 --- a/layout/generic/ReflowInput.h +++ b/layout/generic/ReflowInput.h @@ -747,6 +747,11 @@ public: * Get the used line-height property. The return value will be >= 0. */ nscoord GetLineHeight() const; + + /** + * Set the used line-height. aLineHeight must be >= 0. + */ + void SetLineHeight(nscoord aLineHeight); /** * Calculate the used line-height property without a reflow input instance. From 707d74421937e75e0c0581d6ac9facbd83dd20ea Mon Sep 17 00:00:00 2001 From: Job Bautista Date: Wed, 27 Jul 2022 12:26:29 +0800 Subject: [PATCH 08/10] Issue #1977 - Allow WAV into media document. Based on https://hg.mozilla.org/integration/mozilla-inbound/rev/b3f7abd15aeb --- dom/media/DecoderTraits.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/dom/media/DecoderTraits.cpp b/dom/media/DecoderTraits.cpp index 6aa44f3e57..19596572a0 100644 --- a/dom/media/DecoderTraits.cpp +++ b/dom/media/DecoderTraits.cpp @@ -278,15 +278,6 @@ DecoderTraits::CanHandleContentType(const MediaContentType& aContentType, bool DecoderTraits::ShouldHandleMediaType(const char* aMIMEType, DecoderDoctorDiagnostics* aDiagnostics) { - if (IsWaveSupportedType(nsDependentCString(aMIMEType))) { - // We should not return true for Wave types, since there are some - // Wave codecs actually in use in the wild that we don't support, and - // we should allow those to be handled by plugins or helper apps. - // Furthermore people can play Wave files on most platforms by other - // means. - return false; - } - // If an external plugin which can handle quicktime video is available // (and not disabled), prefer it over native playback as there several // codecs found in the wild that we do not handle. @@ -414,6 +405,7 @@ bool DecoderTraits::IsSupportedInVideoDocument(const nsACString& aType) #endif IsMP3SupportedType(aType) || IsAACSupportedType(aType) || + IsWaveSupportedType(aType) || IsFlacSupportedType(aType) || false; } From 0c5c349ca688b879c587a7509eea88de46fcc1d1 Mon Sep 17 00:00:00 2001 From: Job Bautista Date: Fri, 29 Jul 2022 20:14:27 +0800 Subject: [PATCH 09/10] Issue #1977 - Bring back old behavior behind a pref. I've thought about this before creating the issue, and Moonchild wanted this as well. --- dom/media/DecoderTraits.cpp | 15 +++++++++++++-- modules/libpref/init/all.js | 4 ++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/dom/media/DecoderTraits.cpp b/dom/media/DecoderTraits.cpp index 19596572a0..d4968c0b4e 100644 --- a/dom/media/DecoderTraits.cpp +++ b/dom/media/DecoderTraits.cpp @@ -278,9 +278,20 @@ DecoderTraits::CanHandleContentType(const MediaContentType& aContentType, bool DecoderTraits::ShouldHandleMediaType(const char* aMIMEType, DecoderDoctorDiagnostics* aDiagnostics) { + // Prior to Issue #1977, we always pop-up the download prompt when + // wave files are opened directly. This was considered inconsistent + // since we play wave files when they're inside an HTML5 audio tag + // anyway. However, there may be users who depended on this old + // behavior, where they use their helper apps to open WAV audio + // instead. We should allow this old behavior behind a pref for + // those who want it. + if (!Preferences::GetBool("media.wave.play-stand-alone", true)) { + return false; + } + // If an external plugin which can handle quicktime video is available - // (and not disabled), prefer it over native playback as there several - // codecs found in the wild that we do not handle. + // (and not disabled), prefer it over native playback as there are + // several codecs found in the wild that we do not handle. if (nsDependentCString(aMIMEType).EqualsASCII("video/quicktime")) { RefPtr pluginHost = nsPluginHost::GetInst(); if (pluginHost && diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index e0709a477e..c3a995814f 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -373,6 +373,10 @@ pref("media.wakelock_timeout", 2000); // opened as top-level documents, as opposed to inside a media element. pref("media.play-stand-alone", true); +// Whether we should play wave files opened in a "media document", i.e. wave +// audio opened as top-level documents, as opposed to inside a media element. +pref("media.wave.play-stand-alone", false); + pref("media.hardware-video-decoding.enabled", true); pref("media.hardware-video-decoding.force-enabled", false); From b3e43f41a8e73dea01326f114a2d18dd0e62f8e4 Mon Sep 17 00:00:00 2001 From: Job Bautista Date: Sat, 30 Jul 2022 13:24:40 +0800 Subject: [PATCH 10/10] Issue #1980 - Fix build bustage for applications where WebRTC building is enabled. Turns out we have a duplicate VoidFunction callback in the WebIDLs. Per Mozilla bug 1324169, we should remove this callback from RTCPeerConnection.webidl and let Function.webidl handle it instead. The AttributeError faced by the new Basilisk dev wasn't helpful at all; and turns out Mozilla had this exact same issue on bug 1505504. We're also backporting that just in case we encounter another case of callback duplication. Also doing a minor fix in the MicroTaskRunnable class which Moonchild forgot to do while working on Issue #1895. --- dom/bindings/parser/WebIDL.py | 10 ++++++++-- xpcom/base/CycleCollectedJSContext.h | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/dom/bindings/parser/WebIDL.py b/dom/bindings/parser/WebIDL.py index ce8862c02b..59db43f6bd 100644 --- a/dom/bindings/parser/WebIDL.py +++ b/dom/bindings/parser/WebIDL.py @@ -248,8 +248,14 @@ class IDLScope(IDLObject): return self.QName() def QName(self): - if self._name: - return self._name.QName() + "::" + # It's possible for us to be called before __init__ has been called, for + # the IDLObjectWithScope case. In that case, self._name won't be set yet. + if hasattr(self, "_name"): + name = self._name + else: + name = None + if name: + return name.QName() + "::" return "::" def ensureUnique(self, identifier, object): diff --git a/xpcom/base/CycleCollectedJSContext.h b/xpcom/base/CycleCollectedJSContext.h index 914bb95d30..366a1ea3bb 100644 --- a/xpcom/base/CycleCollectedJSContext.h +++ b/xpcom/base/CycleCollectedJSContext.h @@ -142,7 +142,7 @@ public: virtual void Run(AutoSlowOperation& aAso) = 0; virtual bool Suppressed() { return false; } protected: - virtual ~MicroTaskRunnable() {} + virtual ~MicroTaskRunnable() = default; }; class CycleCollectedJSContext