From ab1118bc6594432473391593ebd8860fbe06ba2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Thu, 25 Mar 2021 11:28:08 +0000 Subject: [PATCH] Bug 1700802 - Add a small radius to the auto style outline. r=mstange (When not following the frame's border radius of course) This makes stuff like: data:text/html, More aesthetically pleasing when focused, and we still keep the square inside the outline (this is what Safari does). Differential Revision: https://phabricator.services.mozilla.com/D109680 --- .../outline/outline-auto-001-ref.html | 50 +++++++++++-------- .../outline/outline-auto-001-solid-ref.html | 1 - layout/reftests/outline/outline-auto-001.html | 38 +++++++------- widget/nsNativeBasicTheme.cpp | 9 +++- 4 files changed, 57 insertions(+), 41 deletions(-) diff --git a/layout/reftests/outline/outline-auto-001-ref.html b/layout/reftests/outline/outline-auto-001-ref.html index 2055880eb3ef..5520991b7493 100644 --- a/layout/reftests/outline/outline-auto-001-ref.html +++ b/layout/reftests/outline/outline-auto-001-ref.html @@ -1,26 +1,36 @@ - - Testcase for outline:auto - - - - +Testcase for outline:auto +
-
+
-
-
- - - +
diff --git a/layout/reftests/outline/outline-auto-001-solid-ref.html b/layout/reftests/outline/outline-auto-001-solid-ref.html index d9a0b851c374..6a46b4ed2c03 100644 --- a/layout/reftests/outline/outline-auto-001-solid-ref.html +++ b/layout/reftests/outline/outline-auto-001-solid-ref.html @@ -17,7 +17,6 @@
-
diff --git a/layout/reftests/outline/outline-auto-001.html b/layout/reftests/outline/outline-auto-001.html index 2f15008c0832..89758919ae22 100644 --- a/layout/reftests/outline/outline-auto-001.html +++ b/layout/reftests/outline/outline-auto-001.html @@ -1,26 +1,28 @@ - - Testcase for outline:auto - - - - +Testcase for outline:auto +
-
- - - diff --git a/widget/nsNativeBasicTheme.cpp b/widget/nsNativeBasicTheme.cpp index f3a8ba596806..e9727df9a7d7 100644 --- a/widget/nsNativeBasicTheme.cpp +++ b/widget/nsNativeBasicTheme.cpp @@ -1832,15 +1832,20 @@ void nsNativeBasicTheme::PaintAutoStyleOutline(nsIFrame* aFrame, LayoutDeviceCoord(SnapBorderWidth(kInnerFocusOutlineWidth, aDpiRatio)); rect.Inflate(width); + const nscoord offset = aFrame->StyleOutline()->mOutlineOffset.ToAppUnits(); nscoord cssRadii[8]; if (!aFrame->GetBorderRadii(cssRadii)) { + const CSSCoord cssOffset = CSSCoord::FromAppUnits(offset); + const CSSCoord radius = + cssOffset >= 0.0f + ? kInnerFocusOutlineWidth + : std::max(kInnerFocusOutlineWidth + cssOffset, CSSCoord(0.0f)); return PaintRoundedRectWithRadius(aPaintData, rect, sRGBColor::White(0.0f), innerColor, kInnerFocusOutlineWidth, - /* aRadius = */ 0.0f, aDpiRatio); + radius, aDpiRatio); } nsPresContext* pc = aFrame->PresContext(); - const nscoord offset = aFrame->StyleOutline()->mOutlineOffset.ToAppUnits(); const Float devPixelOffset = pc->AppUnitsToFloatDevPixels(offset); RectCornerRadii innerRadii;