mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-07 09:54:42 +00:00
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:
parent
c14411e54a
commit
390ddc27d6
@ -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) &&
|
||||
!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.
|
||||
|
Loading…
Reference in New Issue
Block a user