From 1aa650b8acbe9e2e0ebddd255dd61532b5bb2086 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Fri, 22 Jul 2022 14:47:45 +0000 Subject: Issue #1970 - Part 1: Remove unused moz-focus-outer code for buttons. --- layout/forms/nsButtonFrameRenderer.cpp | 62 +--------------------- layout/forms/nsButtonFrameRenderer.h | 8 +-- .../button/focus-area-percent-units-1-ref.html | 11 ---- .../forms/button/focus-area-percent-units-1.html | 27 +--------- .../button/focus-area-percent-units-2-ref.html | 30 ----------- .../forms/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 @@
- - - - -
- - -
-- cgit v1.2.3