Bug 140562 - Part 1: Remove unused moz-focus-outer code for buttons. r=dbaron
authorThomas Wisniewski <wisniewskit@gmail.com>
Fri, 21 Oct 2016 12:19:03 -0400
changeset 325116 f8f0eba2dcbecd7bf12f59888fade012a59da4f2
parent 325091 9ff9b1aa382fb49983785d9831b80100a36ecb71
child 325117 f86ce2e2f6a51f351974e3781158bc0586ab71ed
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersdbaron
bugs140562
milestone53.0a1
Bug 140562 - Part 1: Remove unused moz-focus-outer code for buttons. r=dbaron
layout/forms/nsButtonFrameRenderer.cpp
layout/forms/nsButtonFrameRenderer.h
layout/reftests/forms/button/focus-area-percent-units-1-ref.html
layout/reftests/forms/button/focus-area-percent-units-1.html
layout/reftests/forms/button/focus-area-percent-units-2-ref.html
layout/reftests/forms/button/focus-area-percent-units-2.html
--- a/layout/forms/nsButtonFrameRenderer.cpp
+++ b/layout/forms/nsButtonFrameRenderer.cpp
@@ -31,19 +31,16 @@ nsButtonFrameRenderer::nsButtonFrameRend
 nsButtonFrameRenderer::~nsButtonFrameRenderer()
 {
   MOZ_COUNT_DTOR(nsButtonFrameRenderer);
 
 #ifdef DEBUG
   if (mInnerFocusStyle) {
     mInnerFocusStyle->FrameRelease();
   }
-  if (mOuterFocusStyle) {
-    mOuterFocusStyle->FrameRelease();
-  }
 #endif
 }
 
 void
 nsButtonFrameRenderer::SetFrame(nsFrame* aFrame, nsPresContext* aPresContext)
 {
   mFrame = aFrame;
   ReResolveStyles(aPresContext);
@@ -269,18 +266,17 @@ nsButtonFrameRenderer::DisplayButton(nsD
   nsDisplayBackgroundImage::AppendBackgroundItemsToTop(
     aBuilder, mFrame, buttonRect, aBackground);
 
   aBackground->AppendNewToTop(new (aBuilder)
     nsDisplayButtonBorder(aBuilder, this));
 
   // 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));
   }
   return NS_OK;
 }
 
 DrawResult
 nsButtonFrameRenderer::PaintOutlineAndFocusBorders(
@@ -300,29 +296,17 @@ nsButtonFrameRenderer::PaintOutlineAndFo
   nsRect rect;
 
   PaintBorderFlags flags = aBuilder->ShouldSyncDecodeImages()
                          ? PaintBorderFlags::SYNC_DECODE_IMAGES
                          : PaintBorderFlags();
 
   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 &=
       nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
                                   aDirtyRect, rect, mInnerFocusStyle, flags);
   }
 
   return result;
@@ -353,52 +337,32 @@ nsButtonFrameRenderer::PaintBorder(
     nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,
                                 aDirtyRect, buttonRect, context, borderFlags);
 
   return result;
 }
 
 
 void
-nsButtonFrameRenderer::GetButtonOuterFocusRect(const nsRect& aRect, nsRect& focusRect)
-{
-  focusRect = aRect;
-}
-
-void
 nsButtonFrameRenderer::GetButtonRect(const nsRect& aRect, nsRect& r)
 {
   r = aRect;
-  r.Deflate(GetButtonOuterFocusBorderAndPadding());
 }
 
 
 void
 nsButtonFrameRenderer::GetButtonInnerFocusRect(const nsRect& aRect, nsRect& focusRect)
 {
   GetButtonRect(aRect, focusRect);
   focusRect.Deflate(GetButtonBorderAndPadding());
   focusRect.Deflate(GetButtonInnerFocusMargin());
 }
 
 
 nsMargin
-nsButtonFrameRenderer::GetButtonOuterFocusBorderAndPadding()
-{
-  nsMargin result(0,0,0,0);
-
-  if (mOuterFocusStyle) {
-    mOuterFocusStyle->StylePadding()->GetPadding(result);
-    result += mOuterFocusStyle->StyleBorder()->GetComputedBorder();
-  }
-
-  return result;
-}
-
-nsMargin
 nsButtonFrameRenderer::GetButtonBorderAndPadding()
 {
   return mFrame->GetUsedBorderAndPadding();
 }
 
 /**
  * Gets the size of the buttons border this is the union of the normal and disabled borders.
  */
@@ -427,68 +391,54 @@ nsButtonFrameRenderer::GetButtonInnerFoc
 
   return result;
 }
 
 // gets all the focus borders and padding that will be added to the regular border
 nsMargin
 nsButtonFrameRenderer::GetAddedButtonBorderAndPadding()
 {
-  return GetButtonOuterFocusBorderAndPadding() + GetButtonInnerFocusMargin() + GetButtonInnerFocusBorderAndPadding();
+  return GetButtonInnerFocusMargin() + GetButtonInnerFocusBorderAndPadding();
 }
 
 /**
  * Call this when styles change
  */
 void
 nsButtonFrameRenderer::ReResolveStyles(nsPresContext* aPresContext)
 {
   // get all the styles
   nsStyleContext* context = mFrame->StyleContext();
   StyleSetHandle styleSet = aPresContext->StyleSet();
 
 #ifdef DEBUG
   if (mInnerFocusStyle) {
     mInnerFocusStyle->FrameRelease();
   }
-  if (mOuterFocusStyle) {
-    mOuterFocusStyle->FrameRelease();
-  }
 #endif
 
   // style for the inner such as a dotted line (Windows)
   mInnerFocusStyle =
     styleSet->ProbePseudoElementStyle(mFrame->GetContent()->AsElement(),
                                       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
 }
 
 nsStyleContext*
 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;
   }
 }
 
 void 
 nsButtonFrameRenderer::SetStyleContext(int32_t aIndex, nsStyleContext* aStyleContext)
 {
@@ -496,21 +446,13 @@ nsButtonFrameRenderer::SetStyleContext(i
   case NS_BUTTON_RENDERER_FOCUS_INNER_CONTEXT_INDEX:
 #ifdef DEBUG
     if (mInnerFocusStyle) {
       mInnerFocusStyle->FrameRelease();
     }
 #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();
 #endif
 }
--- a/layout/forms/nsButtonFrameRenderer.h
+++ b/layout/forms/nsButtonFrameRenderer.h
@@ -15,18 +15,17 @@ class nsDisplayList;
 class nsDisplayListBuilder;
 class nsPresContext;
 class nsRenderingContext;
 struct nsRect;
 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;
 
 public:
 
   nsButtonFrameRenderer();
   ~nsButtonFrameRenderer();
@@ -52,37 +51,34 @@ public:
 
   void SetFrame(nsFrame* aFrame, nsPresContext* aPresContext);
  
   void SetDisabled(bool aDisabled, bool notify);
 
   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();
   nsMargin GetAddedButtonBorderAndPadding();
 
   nsStyleContext* GetStyleContext(int32_t aIndex) const;
   void SetStyleContext(int32_t aIndex, nsStyleContext* aStyleContext);
   void ReResolveStyles(nsPresContext* aPresContext);
 
   nsIFrame* GetFrame();
 
 protected:
 
 private:
 
-  // cached styles for focus and outline.
+  // cached style for focus and outline (used on Windows).
   RefPtr<nsStyleContext> mInnerFocusStyle;
-  RefPtr<nsStyleContext> mOuterFocusStyle;
 
   nsFrame* mFrame;
 };
 
 
 #endif
 
--- a/layout/reftests/forms/button/focus-area-percent-units-1-ref.html
+++ b/layout/reftests/forms/button/focus-area-percent-units-1-ref.html
@@ -32,21 +32,10 @@
   <button class="mfi3">mfi3</button>
   <button class="mfi4">mfi4</button>
   <br>
   <button class="mfi5">mfi5</button>
   <button class="mfi6">mfi6</button>
   <button class="mfi7"><div>mfi7</div></button>
   <button class="mfi8"><div>mfi8</div></button>
   <br>
-
-  <button class="mfo1">mfo1</button>
-  <button class="mfo2">mfo2</button>
-  <button class="mfo3">mfo3</button>
-  <button class="mfo4">mfo4</button>
-  <br>
-  <button class="mfo5">mfo5</button>
-  <button class="mfo6">mfo6</button>
-  <button class="mfo7">mfo7</button>
-  <button class="mfo8">mfo8</button>
-  <br>
 </body>
 </html>
--- a/layout/reftests/forms/button/focus-area-percent-units-1.html
+++ b/layout/reftests/forms/button/focus-area-percent-units-1.html
@@ -1,14 +1,14 @@
 <!DOCTYPE html>
 <!-- Any copyright is dedicated to the Public Domain.
    - http://creativecommons.org/publicdomain/zero/1.0/ -->
 <html>
-<!-- The ::-moz-focus-inner & ::-moz-focus-outer button pseudo-elements only
-     support CSS "margin" values that contain absolute lengths.  Any percent or
+<!-- The ::-moz-focus-inner button pseudo-element only supports
+     CSS "margin" values that contain absolute lengths.  Any percent or
      "auto" margin values will simply make the margin collapse to zero.
      This test verifies that this is indeed what happens (not anything worse).
 -->
 <head>
   <title>Testcase for bug 1272983</title>
   <style>
     /* Set explicit font size so that em units are predictable: */
     body, button { font: 10px sans-serif; }
@@ -17,46 +17,23 @@
     button.mfi1::-moz-focus-inner { margin: 50%; }
     button.mfi2::-moz-focus-inner { margin: 50% 10px; }
     button.mfi3::-moz-focus-inner { margin: 10px 50%; }
     button.mfi4::-moz-focus-inner { margin: auto; }
     button.mfi5::-moz-focus-inner { margin: auto 10px; }
     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; }
   </style>
 </head>
 <body>
   <button class="mfi1">mfi1</button>
   <button class="mfi2">mfi2</button>
   <button class="mfi3">mfi3</button>
   <button class="mfi4">mfi4</button>
   <br>
   <button class="mfi5">mfi5</button>
   <button class="mfi6">mfi6</button>
   <button class="mfi7">mfi7</button>
   <button class="mfi8">mfi8</button>
   <br>
-
-  <button class="mfo1">mfo1</button>
-  <button class="mfo2">mfo2</button>
-  <button class="mfo3">mfo3</button>
-  <button class="mfo4">mfo4</button>
-  <br>
-  <button class="mfo5">mfo5</button>
-  <button class="mfo6">mfo6</button>
-  <button class="mfo7">mfo7</button>
-  <button class="mfo8">mfo8</button>
-  <br>
 </body>
 </html>
--- a/layout/reftests/forms/button/focus-area-percent-units-2-ref.html
+++ b/layout/reftests/forms/button/focus-area-percent-units-2-ref.html
@@ -19,50 +19,20 @@
     button.mfi3::-moz-focus-inner,
     button.mfi4::-moz-focus-inner,
     button.mfi5::-moz-focus-inner { padding: 0; }
 
     /* Use an explicit div instead of pseudo-element, for reference case's
        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; }
   </style>
 </head>
 <body>
   <button class="mfi1">mfi1</button>
   <button class="mfi2">mfi2</button>
   <button class="mfi3">mfi3</button>
   <br>
   <button class="mfi4"><div>mfi4</div></button>
   <button class="mfi5"><div>mfi5</div></button>
   <br>
-
-  <button class="mfo1">mfo1</button>
-  <button class="mfo2">mfo2</button>
-  <button class="mfo3">mfo3</button>
-  <br>
-  <div class="mfo4-wrapper">
-    <button class="mfo4">mfo4</button>
-  </div>
-  <div class="mfo5-wrapper">
-    <button class="mfo5">mfo5</button>
-  </div>
-  <br>
 </body>
 </html>
--- a/layout/reftests/forms/button/focus-area-percent-units-2.html
+++ b/layout/reftests/forms/button/focus-area-percent-units-2.html
@@ -1,14 +1,14 @@
 <!DOCTYPE html>
 <!-- Any copyright is dedicated to the Public Domain.
    - http://creativecommons.org/publicdomain/zero/1.0/ -->
 <html>
-<!-- The ::-moz-focus-inner & ::-moz-focus-outer button pseudo-elements only
-     support CSS "padding" values that contain absolute lengths.  Any percent
+<!-- The ::-moz-focus-inner button pseudo-element only supports
+     CSS "padding" values that contain absolute lengths.  Any percent
      padding values will simply make the padding collapse to zero.
      This test verifies that this is indeed what happens (not anything worse).
 -->
 <head>
   <title>Testcase for bug 1272983</title>
   <style>
     /* Set explicit font size so that em units are predictable: */
     body, button { font: 10px sans-serif; }
@@ -17,35 +17,20 @@
     button { outline: 1px solid black; }
 
     /* Testing percent and auto padding values on "-moz-focus-inner": */
     button.mfi1::-moz-focus-inner { padding: 50%; }
     button.mfi2::-moz-focus-inner { padding: 50% 10px; }
     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; }
   </style>
 </head>
 <body>
   <button class="mfi1">mfi1</button>
   <button class="mfi2">mfi2</button>
   <button class="mfi3">mfi3</button>
   <br>
   <button class="mfi4">mfi4</button>
   <button class="mfi5">mfi5</button>
   <br>
-
-  <button class="mfo1">mfo1</button>
-  <button class="mfo2">mfo2</button>
-  <button class="mfo3">mfo3</button>
-  <br>
-  <button class="mfo4">mfo4</button>
-  <button class="mfo5">mfo5</button>
-  <br>
 </body>
 </html>