Commit 390ddc27 authored by Emilio Cobos Álvarez's avatar Emilio Cobos Álvarez
Browse files

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
parent c14411e5
Loading
Loading
Loading
Loading
+0 −18
Original line number Diff line number Diff line
@@ -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();
}
+0 −8
Original line number Diff line number Diff line
@@ -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;
+3 −5
Original line number Diff line number Diff line
@@ -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();
}
+3 −4
Original line number Diff line number Diff line
@@ -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();
}
+3 −9
Original line number Diff line number Diff line
@@ -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();
}
Loading