Bug 1349646 - Don't overflow -moz-inner-focus border. r=wisniewskit+471096
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Sat, 07 Apr 2018 08:38:26 +0900
changeset 469011 1b149844d7002807a684131b3b381b853b3a263f
parent 469010 ee12eb319b24369ecc956afacad532c56b44808b
child 469012 09928d75cfec04a499aa886e629382003a221d07
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswisniewskit
bugs1349646, 471096
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1349646 - Don't overflow -moz-inner-focus border. r=wisniewskit+471096 MozReview-Commit-ID: FFSI6cKZBha
layout/forms/nsButtonFrameRenderer.cpp
layout/reftests/forms/button/1349646-ref.html
layout/reftests/forms/button/1349646.html
layout/reftests/forms/button/reftest.list
--- a/layout/forms/nsButtonFrameRenderer.cpp
+++ b/layout/forms/nsButtonFrameRenderer.cpp
@@ -456,21 +456,33 @@ nsButtonFrameRenderer::DisplayButton(nsD
 }
 
 void
 nsButtonFrameRenderer::GetButtonInnerFocusRect(const nsRect& aRect, nsRect& aResult)
 {
   aResult = aRect;
   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);
 }
 
 ImgDrawResult
 nsButtonFrameRenderer::PaintInnerFocusBorder(
   nsDisplayListBuilder* aBuilder,
   nsPresContext* aPresContext,
   gfxContext& aRenderingContext,
   const nsRect& aDirtyRect,
new file mode 100644
--- /dev/null
+++ b/layout/reftests/forms/button/1349646-ref.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+<style>
+button {
+  padding: 0px;
+  border:none;
+  font-size: 64px;
+  background-color: green;
+}
+button::-moz-focus-inner {
+  padding-inline-start: 0px;
+  padding-inline-end: 0px;
+}
+button:-moz-focusring::-moz-focus-inner {
+  border: 4px solid;
+}
+</style>
+<div>
+  <button id="button1"><span>Menu1</span></button>
+</div>
+<script>
+window.onload = () => {
+  button1.focus();
+  document.documentElement.classList.remove('reftest-wait');
+}
+</script>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/forms/button/1349646.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+<style>
+button {
+  padding: 0px;
+  border:none;
+  font-size: 64px;
+  background-color: green;
+}
+button::-moz-focus-inner {
+  padding-inline-start: 20px;
+  padding-inline-end: 20px;
+}
+button:-moz-focusring::-moz-focus-inner {
+  border: 4px solid;
+}
+</style>
+<div>
+  <button id="button1"><span>Menu1</span></button>
+</div>
+<script>
+window.onload = () => {
+  button1.focus();
+  document.documentElement.classList.remove('reftest-wait');
+}
+</script>
+</html>
--- a/layout/reftests/forms/button/reftest.list
+++ b/layout/reftests/forms/button/reftest.list
@@ -36,8 +36,10 @@ fails-if(Android) == disabled-1.html dis
 == width-exact-fit-ltr.html width-auto-size-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
 == display-grid-flex-columnset.html display-grid-flex-columnset-ref.html
 == 1317351.html 1317351-ref.html
 
 == dynamic-text-indent.html dynamic-text-indent-ref.html
+
+== 1349646.html 1349646-ref.html