Bug 1756210 - Let native theme focus outline be controlled only by CSS. r=mstange

This might be a bit more controversial, but matches Chromium at least,
and it makes sense to me... Would've also fixed this particular bug,
though I think the previous patch is also desirable if devtools ever
wants to add `:disabled` locked states or so.

Depends on D140529

Differential Revision: https://phabricator.services.mozilla.com/D140530
This commit is contained in:
Emilio Cobos Álvarez 2022-03-09 11:45:10 +00:00
parent 340de6fd0f
commit a819845751
5 changed files with 19 additions and 6 deletions

View file

@ -9,8 +9,8 @@
<html:style xmlns:html="http://www.w3.org/1999/xhtml" type="text/css"> <html:style xmlns:html="http://www.w3.org/1999/xhtml" type="text/css">
* { outline: none; } * { outline: none; }
#b3 { outline: auto } #b3:focus-visible { outline: auto }
#l1:-moz-focusring, #l3:-moz-focusring, #b1:-moz-focusring { outline: 2px solid red; } #l1:focus-visible, #l3:focus-visible, #b1:focus-visible { outline: 2px solid red; }
#l2:focus, #b2:focus { outline: 2px solid red; } #l2:focus, #b2:focus { outline: 2px solid red; }
</html:style> </html:style>

View file

@ -0,0 +1,5 @@
<!doctype html>
<style>
input { caret-color: transparent }
</style>
<input autofocus>

View file

@ -0,0 +1,5 @@
<!doctype html>
<style>
input { outline-style: auto }
</style>
<input>

View file

@ -14,6 +14,7 @@ pref(layout.css.outline-style-auto.enabled,false) == outline-auto-001.html outli
skip-if(nativeThemePref) != outline-auto-follows-border-radius-non-native.html outline-auto-follows-border-radius-non-native-notref.html skip-if(nativeThemePref) != outline-auto-follows-border-radius-non-native.html outline-auto-follows-border-radius-non-native-notref.html
skip-if(nativeThemePref) == outline-auto-follows-border-radius-non-native-02.html outline-auto-follows-border-radius-non-native.html skip-if(nativeThemePref) == outline-auto-follows-border-radius-non-native-02.html outline-auto-follows-border-radius-non-native.html
needs-focus skip-if(nativeThemePref) == outline-auto-suppressed-native-widget.html outline-auto-suppressed-native-widget-ref.html needs-focus skip-if(nativeThemePref) == outline-auto-suppressed-native-widget.html outline-auto-suppressed-native-widget-ref.html
needs-focus skip-if(nativeThemePref) == outline-auto-explicit-native-widget.html outline-auto-explicit-native-widget-ref.html
== outline-initial-1a.html outline-initial-1-ref.html == outline-initial-1a.html outline-initial-1-ref.html
== outline-initial-1b.html outline-initial-1-ref.html == outline-initial-1b.html outline-initial-1-ref.html
== outline-on-table.html outline-on-table-ref.html == outline-on-table.html outline-on-table-ref.html

View file

@ -1065,10 +1065,12 @@ bool Theme::DoDrawWidgetBackground(PaintBackendData& aPaintData,
} }
} }
// Don't paint the outline if we're asked not to draw overflow, or if the // Paint the outline iff we're asked to draw overflow and we have
// author has specified another kind of outline on focus. // outline-style: auto.
if (aDrawOverflow == DrawOverflow::No || if (aDrawOverflow == DrawOverflow::Yes &&
!aFrame->StyleOutline()->mOutlineStyle.IsAuto()) { aFrame->StyleOutline()->mOutlineStyle.IsAuto()) {
eventState |= NS_EVENT_STATE_FOCUSRING;
} else {
eventState &= ~NS_EVENT_STATE_FOCUSRING; eventState &= ~NS_EVENT_STATE_FOCUSRING;
} }