Bug 1698821 - Simplify native-appearance-disabling for number spinners. r=dholbert

The root cause of this bug is that we're now accidentally using the
native theme for the spinners because GetNumberControlFrameForSpinButton
broke with my changes.

These pseudos are not exposed to content, and there's just one user of
this pseudo-class (the print.css one).

So just disable native appearance explicitly and remove that check.

Differential Revision: https://phabricator.services.mozilla.com/D108653
This commit is contained in:
Emilio Cobos Álvarez 2021-03-16 21:53:20 +00:00
parent 4e97659d91
commit e65533e909
3 changed files with 7 additions and 33 deletions

View File

@ -188,28 +188,6 @@ bool nsNumberControlFrame::SpinnerDownButtonIsDepressed() const {
->NumberSpinnerDownButtonIsDepressed(); ->NumberSpinnerDownButtonIsDepressed();
} }
#define STYLES_DISABLING_NATIVE_THEMING \
NS_AUTHOR_SPECIFIED_BORDER_OR_BACKGROUND | NS_AUTHOR_SPECIFIED_PADDING
bool nsNumberControlFrame::ShouldUseNativeStyleForSpinner() const {
MOZ_ASSERT(mSpinUp && mSpinDown,
"We should not be called when we have no spinner");
nsIFrame* spinUpFrame = mSpinUp->GetPrimaryFrame();
nsIFrame* spinDownFrame = mSpinDown->GetPrimaryFrame();
return spinUpFrame &&
spinUpFrame->StyleDisplay()->EffectiveAppearance() ==
StyleAppearance::SpinnerUpbutton &&
!PresContext()->HasAuthorSpecifiedRules(
spinUpFrame, STYLES_DISABLING_NATIVE_THEMING) &&
spinDownFrame &&
spinDownFrame->StyleDisplay()->EffectiveAppearance() ==
StyleAppearance::SpinnerDownbutton &&
!PresContext()->HasAuthorSpecifiedRules(
spinDownFrame, STYLES_DISABLING_NATIVE_THEMING);
}
void nsNumberControlFrame::AppendAnonymousContentTo( void nsNumberControlFrame::AppendAnonymousContentTo(
nsTArray<nsIContent*>& aElements, uint32_t aFilter) { nsTArray<nsIContent*>& aElements, uint32_t aFilter) {
if (mSpinBox) { if (mSpinBox) {

View File

@ -292,6 +292,7 @@ input[type="number"].photon-number::-moz-number-spin-down {
background-position: center; background-position: center;
-moz-context-properties: fill; -moz-context-properties: fill;
fill: currentColor; fill: currentColor;
appearance: none;
} }
input[type="number"].photon-number::-moz-number-spin-up { input[type="number"].photon-number::-moz-number-spin-up {

View File

@ -46,9 +46,13 @@ NS_IMPL_ISUPPORTS(nsNativeTheme, nsITimerCallback, nsINamed)
bool isXULCheckboxRadio = (aAppearance == StyleAppearance::Checkbox || bool isXULCheckboxRadio = (aAppearance == StyleAppearance::Checkbox ||
aAppearance == StyleAppearance::Radio) && aAppearance == StyleAppearance::Radio) &&
aFrame->GetContent()->IsXULElement(); aFrame->GetContent()->IsXULElement();
if (isXULCheckboxRadio) aFrame = aFrame->GetParent(); if (isXULCheckboxRadio) {
aFrame = aFrame->GetParent();
}
if (!aFrame->GetContent()) return EventStates(); if (!aFrame->GetContent()) {
return EventStates();
}
nsIContent* frameContent = aFrame->GetContent(); nsIContent* frameContent = aFrame->GetContent();
EventStates flags; EventStates flags;
@ -264,15 +268,6 @@ bool nsNativeTheme::IsWidgetStyled(nsPresContext* aPresContext,
} }
} }
if (aAppearance == StyleAppearance::SpinnerUpbutton ||
aAppearance == StyleAppearance::SpinnerDownbutton) {
nsNumberControlFrame* numberControlFrame =
nsNumberControlFrame::GetNumberControlFrameForSpinButton(aFrame);
if (numberControlFrame) {
return !numberControlFrame->ShouldUseNativeStyleForSpinner();
}
}
return nsLayoutUtils::AuthorSpecifiedBorderBackgroundDisablesTheming( return nsLayoutUtils::AuthorSpecifiedBorderBackgroundDisablesTheming(
aAppearance) && aAppearance) &&
aFrame->GetContent()->IsHTMLElement() && aFrame->GetContent()->IsHTMLElement() &&