forked from mirrors/gecko-dev
Bug 1852457 - Simplify nsITheme::ThemeWantsButtonInnerFocusRing(). r=jfkthame,layout-reviewers
In practice, this is only ever true on the native windows theme. All other themes return true for ThemeDrawsFocusForWidget for Button and Menulist, which are the relevant appearance values here. So make this more explicit. Differential Revision: https://phabricator.services.mozilla.com/D187856
This commit is contained in:
parent
38d7173959
commit
d12231ae7a
4 changed files with 8 additions and 28 deletions
|
|
@ -235,17 +235,8 @@ class nsITheme : public nsISupports {
|
||||||
*/
|
*/
|
||||||
virtual bool ThemeDrawsFocusForWidget(nsIFrame*, StyleAppearance) = 0;
|
virtual bool ThemeDrawsFocusForWidget(nsIFrame*, StyleAppearance) = 0;
|
||||||
|
|
||||||
/**
|
// Whether we want an inner focus ring for buttons and menulists.
|
||||||
* Whether we want an inner focus ring for buttons and such.
|
virtual bool ThemeWantsButtonInnerFocusRing() { return false; }
|
||||||
*
|
|
||||||
* Usually, we don't want it if we have our own focus indicators, but windows
|
|
||||||
* is special, because it wants it even though focus also alters the border
|
|
||||||
* color and such.
|
|
||||||
*/
|
|
||||||
virtual bool ThemeWantsButtonInnerFocusRing(nsIFrame* aFrame,
|
|
||||||
StyleAppearance aAppearance) {
|
|
||||||
return !ThemeDrawsFocusForWidget(aFrame, aAppearance);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Should we insert a dropmarker inside of combobox button?
|
* Should we insert a dropmarker inside of combobox button?
|
||||||
|
|
|
||||||
|
|
@ -81,12 +81,9 @@ nsresult nsButtonFrameRenderer::DisplayButton(nsDisplayListBuilder* aBuilder,
|
||||||
|
|
||||||
// Only display focus rings if we actually have them. Since at most one
|
// 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.
|
// button would normally display a focus ring, most buttons won't have them.
|
||||||
const auto* disp = mFrame->StyleDisplay();
|
|
||||||
nsPresContext* pc = mFrame->PresContext();
|
|
||||||
if (mInnerFocusStyle && mInnerFocusStyle->StyleBorder()->HasBorder() &&
|
if (mInnerFocusStyle && mInnerFocusStyle->StyleBorder()->HasBorder() &&
|
||||||
mFrame->IsThemed(disp) &&
|
mFrame->IsThemed() &&
|
||||||
pc->Theme()->ThemeWantsButtonInnerFocusRing(
|
mFrame->PresContext()->Theme()->ThemeWantsButtonInnerFocusRing()) {
|
||||||
mFrame, disp->EffectiveAppearance())) {
|
|
||||||
aForeground->AppendNewToTop<nsDisplayButtonForeground>(aBuilder, GetFrame(),
|
aForeground->AppendNewToTop<nsDisplayButtonForeground>(aBuilder, GetFrame(),
|
||||||
this);
|
this);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -916,15 +916,9 @@ void nsComboboxControlFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw a focus indicator only when focus rings should be drawn
|
// draw a focus indicator only when focus rings should be drawn
|
||||||
if (mContent->AsElement()->State().HasState(dom::ElementState::FOCUSRING)) {
|
if (Select().State().HasState(dom::ElementState::FOCUSRING) && IsThemed() &&
|
||||||
nsPresContext* pc = PresContext();
|
PresContext()->Theme()->ThemeWantsButtonInnerFocusRing()) {
|
||||||
const nsStyleDisplay* disp = StyleDisplay();
|
aLists.Content()->AppendNewToTop<nsDisplayComboboxFocus>(aBuilder, this);
|
||||||
if (IsThemed(disp) &&
|
|
||||||
pc->Theme()->ThemeWantsButtonInnerFocusRing(
|
|
||||||
this, disp->EffectiveAppearance()) &&
|
|
||||||
mDisplayFrame && IsVisibleForPainting()) {
|
|
||||||
aLists.Content()->AppendNewToTop<nsDisplayComboboxFocus>(aBuilder, this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DisplaySelectionOverlay(aBuilder, aLists.Content());
|
DisplaySelectionOverlay(aBuilder, aLists.Content());
|
||||||
|
|
|
||||||
|
|
@ -80,9 +80,7 @@ class nsNativeThemeWin : public Theme {
|
||||||
|
|
||||||
bool ThemeDrawsFocusForWidget(nsIFrame*, StyleAppearance) override;
|
bool ThemeDrawsFocusForWidget(nsIFrame*, StyleAppearance) override;
|
||||||
|
|
||||||
bool ThemeWantsButtonInnerFocusRing(nsIFrame*, StyleAppearance) override {
|
bool ThemeWantsButtonInnerFocusRing() override { return true; }
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ThemeNeedsComboboxDropmarker() override;
|
bool ThemeNeedsComboboxDropmarker() override;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue