Bug 1733339 - Remove NS_AUTHOR_SPECIFIED_PADDING. r=mstange

There's only one meaningful usage of it, which is to disable native
appearance of the <input type=range> (the windows native theme is no
longer exposed to content).

<input type=range> is inconsistent with every other native widget, which
only disables native appearance if the author specifies backgrounds or
borders. So make it match literally all other widgets and simplify a bit
the code.

We had no tests for this special behavior, let me know if you think it's
worth adding one (but I don't feel very strongly about it).

Differential Revision: https://phabricator.services.mozilla.com/D127082
This commit is contained in:
Emilio Cobos Álvarez 2021-10-01 06:31:09 +00:00
Родитель e58ba15e19
Коммит b53a78f446
11 изменённых файлов: 12 добавлений и 90 удалений

Просмотреть файл

@ -1888,24 +1888,6 @@ void nsPresContext::CountReflows(const char* aName, nsIFrame* aFrame) {
}
#endif
bool nsPresContext::HasAuthorSpecifiedRules(const nsIFrame* aFrame,
uint32_t aRuleTypeMask) const {
const bool padding = aRuleTypeMask & NS_AUTHOR_SPECIFIED_PADDING;
const bool borderBackground =
aRuleTypeMask & NS_AUTHOR_SPECIFIED_BORDER_OR_BACKGROUND;
const auto& style = *aFrame->Style();
if (padding && style.HasAuthorSpecifiedPadding()) {
return true;
}
if (borderBackground && style.HasAuthorSpecifiedBorderOrBackground()) {
return true;
}
return false;
}
gfxUserFontSet* nsPresContext::GetUserFontSet() {
return mDocument->GetUserFontSet();
}

Просмотреть файл

@ -119,10 +119,6 @@ enum class nsLayoutPhase : uint8_t {
};
#endif
/* Used by nsPresContext::HasAuthorSpecifiedRules */
#define NS_AUTHOR_SPECIFIED_BORDER_OR_BACKGROUND (1 << 0)
#define NS_AUTHOR_SPECIFIED_PADDING (1 << 1)
class nsRootPresContext;
// An interface for presentation contexts. Presentation contexts are
@ -890,10 +886,6 @@ class nsPresContext : public nsISupports, public mozilla::SupportsWeakPtr {
// Is this presentation in a chrome docshell?
bool IsChrome() const;
// Public API for native theme code to get style internals.
bool HasAuthorSpecifiedRules(const nsIFrame* aFrame,
uint32_t ruleTypeMask) const;
// Explicitly enable and disable paint flashing.
void SetPaintFlashing(bool aPaintFlashing) {
mPaintFlashing = aPaintFlashing;

Просмотреть файл

@ -11,6 +11,7 @@
#include "mozilla/dom/Element.h"
#include "mozilla/dom/HTMLMeterElement.h"
#include "nsIContent.h"
#include "nsLayoutUtils.h"
#include "nsPresContext.h"
#include "nsGkAtoms.h"
#include "nsNameSpaceManager.h"
@ -226,11 +227,8 @@ bool nsMeterFrame::ShouldUseNativeStyle() const {
// - neither frame has author specified rules setting the border or the
// background.
return StyleDisplay()->EffectiveAppearance() == StyleAppearance::Meter &&
!PresContext()->HasAuthorSpecifiedRules(
this, NS_AUTHOR_SPECIFIED_BORDER_OR_BACKGROUND) &&
barFrame &&
!Style()->HasAuthorSpecifiedBorderOrBackground() && barFrame &&
barFrame->StyleDisplay()->EffectiveAppearance() ==
StyleAppearance::Meterchunk &&
!PresContext()->HasAuthorSpecifiedRules(
barFrame, NS_AUTHOR_SPECIFIED_BORDER_OR_BACKGROUND);
!barFrame->Style()->HasAuthorSpecifiedBorderOrBackground();
}

Просмотреть файл

@ -11,6 +11,7 @@
#include "mozilla/dom/Element.h"
#include "mozilla/dom/HTMLProgressElement.h"
#include "nsIContent.h"
#include "nsLayoutUtils.h"
#include "nsPresContext.h"
#include "nsGkAtoms.h"
#include "nsNameSpaceManager.h"
@ -243,11 +244,9 @@ bool nsProgressFrame::ShouldUseNativeStyle() const {
// background.
return StyleDisplay()->EffectiveAppearance() ==
StyleAppearance::ProgressBar &&
!PresContext()->HasAuthorSpecifiedRules(
this, NS_AUTHOR_SPECIFIED_BORDER_OR_BACKGROUND) &&
!barFrame->Style()->HasAuthorSpecifiedBorderOrBackground() &&
barFrame &&
barFrame->StyleDisplay()->EffectiveAppearance() ==
StyleAppearance::Progresschunk &&
!PresContext()->HasAuthorSpecifiedRules(
barFrame, NS_AUTHOR_SPECIFIED_BORDER_OR_BACKGROUND);
!barFrame->Style()->HasAuthorSpecifiedBorderOrBackground();
}

Просмотреть файл

@ -670,9 +670,6 @@ double nsRangeFrame::GetValue() const {
.toDouble();
}
#define STYLES_DISABLING_NATIVE_THEMING \
NS_AUTHOR_SPECIFIED_BORDER_OR_BACKGROUND | NS_AUTHOR_SPECIFIED_PADDING
bool nsRangeFrame::ShouldUseNativeStyle() const {
nsIFrame* trackFrame = mTrackDiv->GetPrimaryFrame();
nsIFrame* progressFrame = mProgressDiv->GetPrimaryFrame();
@ -680,12 +677,9 @@ bool nsRangeFrame::ShouldUseNativeStyle() const {
return StyleDisplay()->EffectiveAppearance() == StyleAppearance::Range &&
trackFrame &&
!PresContext()->HasAuthorSpecifiedRules(
trackFrame, STYLES_DISABLING_NATIVE_THEMING) &&
!trackFrame->Style()->HasAuthorSpecifiedBorderOrBackground() &&
progressFrame &&
!PresContext()->HasAuthorSpecifiedRules(
progressFrame, STYLES_DISABLING_NATIVE_THEMING) &&
!progressFrame->Style()->HasAuthorSpecifiedBorderOrBackground() &&
thumbFrame &&
!PresContext()->HasAuthorSpecifiedRules(
thumbFrame, STYLES_DISABLING_NATIVE_THEMING);
!thumbFrame->Style()->HasAuthorSpecifiedBorderOrBackground();
}

Просмотреть файл

@ -116,12 +116,6 @@ class ComputedStyle {
return mPseudoType != PseudoStyleType::NotPseudo;
}
// Whether there are author-specified rules for padding properties.
// Only returns something meaningful if the appearance property is not `none`.
bool HasAuthorSpecifiedPadding() const {
return bool(Flags() & Flag::HAS_AUTHOR_SPECIFIED_PADDING);
}
// Whether there are author-specified rules for border or background
// properties.
// Only returns something meaningful if the appearance property is not `none`.

Просмотреть файл

@ -802,12 +802,6 @@ impl<'a, 'b: 'a> Cascade<'a, 'b> {
{
builder.add_flags(ComputedValueFlags::HAS_AUTHOR_SPECIFIED_BORDER_BACKGROUND);
}
if self
.author_specified
.contains_any(LonghandIdSet::padding_properties())
{
builder.add_flags(ComputedValueFlags::HAS_AUTHOR_SPECIFIED_PADDING);
}
if self
.author_specified
@ -870,8 +864,7 @@ impl<'a, 'b: 'a> Cascade<'a, 'b> {
//
// Note that all the properties involved are non-inherited, so we don't
// need to do anything else other than just copying the bits over.
let reset_props_bits = ComputedValueFlags::HAS_AUTHOR_SPECIFIED_BORDER_BACKGROUND |
ComputedValueFlags::HAS_AUTHOR_SPECIFIED_PADDING;
let reset_props_bits = ComputedValueFlags::HAS_AUTHOR_SPECIFIED_BORDER_BACKGROUND;
builder.add_flags(cached_style.flags & reset_props_bits);
true

Просмотреть файл

@ -84,12 +84,6 @@ bitflags! {
/// https://github.com/w3c/csswg-drafts/issues/4777#issuecomment-604424845
const HAS_AUTHOR_SPECIFIED_BORDER_BACKGROUND = 1 << 14;
/// Whether there are author-specified rules for padding-* properties.
///
/// FIXME(emilio): Try to merge this with BORDER_BACKGROUND, see
/// https://github.com/w3c/csswg-drafts/issues/4777
const HAS_AUTHOR_SPECIFIED_PADDING = 1 << 15;
/// Whether there are author-specified rules for `font-family`.
const HAS_AUTHOR_SPECIFIED_FONT_FAMILY = 1 << 16;

Просмотреть файл

@ -945,18 +945,6 @@ impl LonghandIdSet {
&HAS_NO_EFFECT_ON_SCROLLBARS
}
/// Returns the set of padding properties for the purpose of disabling
/// native appearance.
#[inline]
pub fn padding_properties() -> &'static Self {
<% assert "padding" in logical_groups %>
${static_longhand_id_set(
"PADDING_PROPERTIES",
lambda p: p.logical_group == "padding"
)}
&PADDING_PROPERTIES
}
/// Returns the set of border properties for the purpose of disabling native
/// appearance.
#[inline]

Просмотреть файл

@ -9,6 +9,7 @@
#include "nsIContent.h"
#include "nsIFrame.h"
#include "nsIScrollableFrame.h"
#include "nsLayoutUtils.h"
#include "nsNumberControlFrame.h"
#include "nsPresContext.h"
#include "nsString.h"
@ -272,8 +273,7 @@ bool nsNativeTheme::IsWidgetStyled(nsPresContext* aPresContext,
return nsLayoutUtils::AuthorSpecifiedBorderBackgroundDisablesTheming(
aAppearance) &&
aFrame->GetContent()->IsHTMLElement() &&
aPresContext->HasAuthorSpecifiedRules(
aFrame, NS_AUTHOR_SPECIFIED_BORDER_OR_BACKGROUND);
aFrame->Style()->HasAuthorSpecifiedBorderOrBackground();
}
bool nsNativeTheme::IsDisabled(nsIFrame* aFrame, EventStates aEventStates) {

Просмотреть файл

@ -2040,18 +2040,6 @@ bool nsNativeThemeWin::GetWidgetPadding(nsDeviceContext* aContext,
return ok;
}
if (aAppearance == StyleAppearance::NumberInput ||
aAppearance == StyleAppearance::Textfield ||
aAppearance == StyleAppearance::Textarea ||
aAppearance == StyleAppearance::MenulistButton ||
aAppearance == StyleAppearance::Menulist) {
// If we have author-specified padding for these elements, don't do the
// fixups below.
if (aFrame->PresContext()->HasAuthorSpecifiedRules(
aFrame, NS_AUTHOR_SPECIFIED_PADDING))
return false;
}
/* textfields need extra pixels on all sides, otherwise they wrap their
* content too tightly. The actual border is drawn 1px inside the specified
* rectangle, so Gecko will end up making the contents look too small.