Skip to content

Commit

Permalink
Bug 1620467 - Part 3: Defer to -moz-default-appearance when appearanc…
Browse files Browse the repository at this point in the history
…e is auto. r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D83429
  • Loading branch information
heycam committed Jul 16, 2020
1 parent 1739610 commit 1fe732d
Show file tree
Hide file tree
Showing 35 changed files with 180 additions and 174 deletions.
5 changes: 3 additions & 2 deletions layout/base/PresShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5289,9 +5289,10 @@ void PresShell::UpdateCanvasBackground() {
bool drawBackgroundImage = false;
bool drawBackgroundColor = false;
const nsStyleDisplay* disp = rootStyleFrame->StyleDisplay();
StyleAppearance appearance = disp->EffectiveAppearance();
if (rootStyleFrame->IsThemed(disp) &&
disp->mAppearance != StyleAppearance::MozWinGlass &&
disp->mAppearance != StyleAppearance::MozWinBorderlessGlass) {
appearance != StyleAppearance::MozWinGlass &&
appearance != StyleAppearance::MozWinBorderlessGlass) {
// Ignore the CSS background-color if -moz-appearance is used and it is
// not one of the glass values. (Windows 7 Glass has traditionally not
// overridden background colors, so we preserve that behavior for now.)
Expand Down
21 changes: 11 additions & 10 deletions layout/base/RestyleManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,14 +506,15 @@ static nsChangeHint ChangeForContentStateChange(const Element& aElement,
return nsChangeHint_ReconstructFrame;
}

auto* disp = primaryFrame->StyleDisplay();
if (disp->HasAppearance()) {
StyleAppearance appearance =
primaryFrame->StyleDisplay()->EffectiveAppearance();
if (appearance != StyleAppearance::None) {
nsPresContext* pc = primaryFrame->PresContext();
nsITheme* theme = pc->Theme();
if (theme->ThemeSupportsWidget(pc, primaryFrame, disp->mAppearance)) {
if (theme->ThemeSupportsWidget(pc, primaryFrame, appearance)) {
bool repaint = false;
theme->WidgetStateChanged(primaryFrame, disp->mAppearance, nullptr,
&repaint, nullptr);
theme->WidgetStateChanged(primaryFrame, appearance, nullptr, &repaint,
nullptr);
if (repaint) {
changeHint |= nsChangeHint_RepaintFrame;
}
Expand Down Expand Up @@ -3343,13 +3344,13 @@ void RestyleManager::AttributeChanged(Element* aElement, int32_t aNameSpaceID,

if (nsIFrame* primaryFrame = aElement->GetPrimaryFrame()) {
// See if we have appearance information for a theme.
const nsStyleDisplay* disp = primaryFrame->StyleDisplay();
if (disp->HasAppearance()) {
StyleAppearance appearance =
primaryFrame->StyleDisplay()->EffectiveAppearance();
if (appearance != StyleAppearance::None) {
nsITheme* theme = PresContext()->Theme();
if (theme->ThemeSupportsWidget(PresContext(), primaryFrame,
disp->mAppearance)) {
if (theme->ThemeSupportsWidget(PresContext(), primaryFrame, appearance)) {
bool repaint = false;
theme->WidgetStateChanged(primaryFrame, disp->mAppearance, aAttribute,
theme->WidgetStateChanged(primaryFrame, appearance, aAttribute,
&repaint, aOldValue);
if (repaint) {
changeHint |= nsChangeHint_RepaintFrame;
Expand Down
20 changes: 10 additions & 10 deletions layout/base/nsLayoutUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5524,8 +5524,8 @@ static nscoord AddIntrinsicSizeOffset(
LayoutDeviceIntSize devSize;
bool canOverride = true;
nsPresContext* pc = aFrame->PresContext();
pc->Theme()->GetMinimumWidgetSize(pc, aFrame, disp->mAppearance, &devSize,
&canOverride);
pc->Theme()->GetMinimumWidgetSize(pc, aFrame, disp->EffectiveAppearance(),
&devSize, &canOverride);
nscoord themeSize = pc->DevPixelsToAppUnits(
aAxis == eAxisVertical ? devSize.height : devSize.width);
// GetMinimumWidgetSize() returns a border-box width.
Expand Down Expand Up @@ -7451,12 +7451,12 @@ nsTransparencyMode nsLayoutUtils::GetFrameTransparency(
if (HasNonZeroCorner(aCSSRootFrame->StyleBorder()->mBorderRadius))
return eTransparencyTransparent;

if (aCSSRootFrame->StyleDisplay()->mAppearance ==
StyleAppearance::MozWinGlass)
return eTransparencyGlass;
StyleAppearance appearance =
aCSSRootFrame->StyleDisplay()->EffectiveAppearance();

if (aCSSRootFrame->StyleDisplay()->mAppearance ==
StyleAppearance::MozWinBorderlessGlass)
if (appearance == StyleAppearance::MozWinGlass) return eTransparencyGlass;

if (appearance == StyleAppearance::MozWinBorderlessGlass)
return eTransparencyBorderlessGlass;

nsITheme::Transparency transparency;
Expand Down Expand Up @@ -8642,9 +8642,9 @@ nsRect nsLayoutUtils::GetBoxShadowRectForFrame(nsIFrame* aFrame,
// border-box path with border-radius disabled.
if (transparency != nsITheme::eOpaque) {
nsPresContext* presContext = aFrame->PresContext();
presContext->Theme()->GetWidgetOverflow(presContext->DeviceContext(),
aFrame, styleDisplay->mAppearance,
&inputRect);
presContext->Theme()->GetWidgetOverflow(
presContext->DeviceContext(), aFrame,
styleDisplay->EffectiveAppearance(), &inputRect);
}
}

Expand Down
3 changes: 2 additions & 1 deletion layout/forms/nsButtonFrameRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,8 @@ nsresult nsButtonFrameRenderer::DisplayButton(nsDisplayListBuilder* aBuilder,
nsPresContext* pc = mFrame->PresContext();
if (mInnerFocusStyle && mInnerFocusStyle->StyleBorder()->HasBorder() &&
mFrame->IsThemed(disp) &&
pc->Theme()->ThemeWantsButtonInnerFocusRing(disp->mAppearance)) {
pc->Theme()->ThemeWantsButtonInnerFocusRing(
disp->EffectiveAppearance())) {
aForeground->AppendNewToTop<nsDisplayButtonForeground>(aBuilder, GetFrame(),
this);
}
Expand Down
8 changes: 5 additions & 3 deletions layout/forms/nsComboboxControlFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ bool nsComboboxControlFrame::HasDropDownButton() const {
const nsStyleDisplay* disp = StyleDisplay();
// FIXME(emilio): Blink also shows this for menulist-button and such... Seems
// more similar to our mac / linux implementation.
return disp->mAppearance == StyleAppearance::Menulist &&
return disp->EffectiveAppearance() == StyleAppearance::Menulist &&
(!IsThemed(disp) ||
PresContext()->Theme()->ThemeNeedsComboboxDropmarker());
}
Expand Down Expand Up @@ -1282,7 +1282,8 @@ void nsComboboxDisplayFrame::Reflow(nsPresContext* aPresContext,
// clipping the display text, by enforcing the display text minimum size in
// that situation.
const bool shouldHonorMinISize =
mComboBox->StyleDisplay()->mAppearance == StyleAppearance::Menulist;
mComboBox->StyleDisplay()->EffectiveAppearance() ==
StyleAppearance::Menulist;
if (shouldHonorMinISize) {
computedISize = std::max(state.ComputedMinISize(), computedISize);
// Don't let this size go over mMaxDisplayISize, since that'd be
Expand Down Expand Up @@ -1502,7 +1503,8 @@ void nsComboboxControlFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
nsPresContext* pc = PresContext();
const nsStyleDisplay* disp = StyleDisplay();
if (IsThemed(disp) &&
pc->Theme()->ThemeWantsButtonInnerFocusRing(disp->mAppearance) &&
pc->Theme()->ThemeWantsButtonInnerFocusRing(
disp->EffectiveAppearance()) &&
mDisplayFrame && IsVisibleForPainting()) {
aLists.Content()->AppendNewToTop<nsDisplayComboboxFocus>(aBuilder, this);
}
Expand Down
5 changes: 3 additions & 2 deletions layout/forms/nsMeterFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,12 @@ bool nsMeterFrame::ShouldUseNativeStyle() const {
// - both frames use the native appearance;
// - neither frame has author specified rules setting the border or the
// background.
return StyleDisplay()->mAppearance == StyleAppearance::Meter &&
return StyleDisplay()->EffectiveAppearance() == StyleAppearance::Meter &&
!PresContext()->HasAuthorSpecifiedRules(
this, NS_AUTHOR_SPECIFIED_BORDER_OR_BACKGROUND) &&
barFrame &&
barFrame->StyleDisplay()->mAppearance == StyleAppearance::Meterchunk &&
barFrame->StyleDisplay()->EffectiveAppearance() ==
StyleAppearance::Meterchunk &&
!PresContext()->HasAuthorSpecifiedRules(
barFrame, NS_AUTHOR_SPECIFIED_BORDER_OR_BACKGROUND);
}
6 changes: 3 additions & 3 deletions layout/forms/nsNumberControlFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ nsresult nsNumberControlFrame::CreateAnonymousContent(
}
}

if (StyleDisplay()->mAppearance == StyleAppearance::Textfield) {
if (StyleDisplay()->EffectiveAppearance() == StyleAppearance::Textfield) {
// The author has elected to hide the spinner by setting this
// -moz-appearance. We will reframe if it changes.
return NS_OK;
Expand Down Expand Up @@ -242,12 +242,12 @@ bool nsNumberControlFrame::ShouldUseNativeStyleForSpinner() const {
nsIFrame* spinDownFrame = mSpinDown->GetPrimaryFrame();

return spinUpFrame &&
spinUpFrame->StyleDisplay()->mAppearance ==
spinUpFrame->StyleDisplay()->EffectiveAppearance() ==
StyleAppearance::SpinnerUpbutton &&
!PresContext()->HasAuthorSpecifiedRules(
spinUpFrame, STYLES_DISABLING_NATIVE_THEMING) &&
spinDownFrame &&
spinDownFrame->StyleDisplay()->mAppearance ==
spinDownFrame->StyleDisplay()->EffectiveAppearance() ==
StyleAppearance::SpinnerDownbutton &&
!PresContext()->HasAuthorSpecifiedRules(
spinDownFrame, STYLES_DISABLING_NATIVE_THEMING);
Expand Down
5 changes: 3 additions & 2 deletions layout/forms/nsProgressFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,12 @@ bool nsProgressFrame::ShouldUseNativeStyle() const {
// - both frames use the native appearance;
// - neither frame has author specified rules setting the border or the
// background.
return StyleDisplay()->mAppearance == StyleAppearance::ProgressBar &&
return StyleDisplay()->EffectiveAppearance() ==
StyleAppearance::ProgressBar &&
!PresContext()->HasAuthorSpecifiedRules(
this, NS_AUTHOR_SPECIFIED_BORDER_OR_BACKGROUND) &&
barFrame &&
barFrame->StyleDisplay()->mAppearance ==
barFrame->StyleDisplay()->EffectiveAppearance() ==
StyleAppearance::Progresschunk &&
!PresContext()->HasAuthorSpecifiedRules(
barFrame, NS_AUTHOR_SPECIFIED_BORDER_OR_BACKGROUND);
Expand Down
3 changes: 2 additions & 1 deletion layout/forms/nsRangeFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,8 @@ bool nsRangeFrame::ShouldUseNativeStyle() const {
nsIFrame* progressFrame = mProgressDiv->GetPrimaryFrame();
nsIFrame* thumbFrame = mThumbDiv->GetPrimaryFrame();

return StyleDisplay()->mAppearance == StyleAppearance::Range && trackFrame &&
return StyleDisplay()->EffectiveAppearance() == StyleAppearance::Range &&
trackFrame &&
!PresContext()->HasAuthorSpecifiedRules(
trackFrame, STYLES_DISABLING_NATIVE_THEMING) &&
progressFrame &&
Expand Down
6 changes: 3 additions & 3 deletions layout/generic/ReflowInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2498,8 +2498,8 @@ void SizeComputationInput::InitOffsets(WritingMode aWM, nscoord aPercentBasis,
bool needPaddingProp;
LayoutDeviceIntMargin widgetPadding;
if (isThemed && presContext->Theme()->GetWidgetPadding(
presContext->DeviceContext(), mFrame, disp->mAppearance,
&widgetPadding)) {
presContext->DeviceContext(), mFrame,
disp->EffectiveAppearance(), &widgetPadding)) {
ComputedPhysicalPadding() = LayoutDevicePixel::ToAppUnits(
widgetPadding, presContext->AppUnitsPerDevPixel());
needPaddingProp = false;
Expand Down Expand Up @@ -2549,7 +2549,7 @@ void SizeComputationInput::InitOffsets(WritingMode aWM, nscoord aPercentBasis,

if (isThemed) {
LayoutDeviceIntMargin border = presContext->Theme()->GetWidgetBorder(
presContext->DeviceContext(), mFrame, disp->mAppearance);
presContext->DeviceContext(), mFrame, disp->EffectiveAppearance());
ComputedPhysicalBorderPadding() = LayoutDevicePixel::ToAppUnits(
border, presContext->AppUnitsPerDevPixel());
} else if (SVGUtils::IsInSVGTextSubtree(mFrame)) {
Expand Down
2 changes: 1 addition & 1 deletion layout/generic/nsFlexContainerFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1341,7 +1341,7 @@ FlexItem* nsFlexContainerFrame::GenerateFlexItemForChild(
LayoutDeviceIntSize widgetMinSize;
bool canOverride = true;
PresContext()->Theme()->GetMinimumWidgetSize(PresContext(), aChildFrame,
disp->mAppearance,
disp->EffectiveAppearance(),
&widgetMinSize, &canOverride);

nscoord widgetMainMinSize = PresContext()->DevPixelsToAppUnits(
Expand Down
28 changes: 15 additions & 13 deletions layout/generic/nsIFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1574,7 +1574,7 @@ nsMargin nsIFrame::GetUsedBorder() const {
if (mutable_this->IsThemed(disp)) {
nsPresContext* pc = PresContext();
LayoutDeviceIntMargin widgetBorder = pc->Theme()->GetWidgetBorder(
pc->DeviceContext(), mutable_this, disp->mAppearance);
pc->DeviceContext(), mutable_this, disp->EffectiveAppearance());
border =
LayoutDevicePixel::ToAppUnits(widgetBorder, pc->AppUnitsPerDevPixel());
return border;
Expand Down Expand Up @@ -1604,7 +1604,8 @@ nsMargin nsIFrame::GetUsedPadding() const {
nsPresContext* pc = PresContext();
LayoutDeviceIntMargin widgetPadding;
if (pc->Theme()->GetWidgetPadding(pc->DeviceContext(), mutable_this,
disp->mAppearance, &widgetPadding)) {
disp->EffectiveAppearance(),
&widgetPadding)) {
return LayoutDevicePixel::ToAppUnits(widgetPadding,
pc->AppUnitsPerDevPixel());
}
Expand Down Expand Up @@ -2457,8 +2458,8 @@ void nsIFrame::DisplayOutlineUnconditional(nsDisplayListBuilder* aBuilder,
// focus indicators.
if (outline.mOutlineStyle.IsAuto()) {
auto* disp = StyleDisplay();
if (IsThemed(disp) &&
PresContext()->Theme()->ThemeDrawsFocusForWidget(disp->mAppearance)) {
if (IsThemed(disp) && PresContext()->Theme()->ThemeDrawsFocusForWidget(
disp->EffectiveAppearance())) {
return;
}
}
Expand Down Expand Up @@ -4091,8 +4092,8 @@ void nsIFrame::BuildDisplayListForChild(nsDisplayListBuilder* aBuilder,
const nsStyleDisplay* ourDisp = StyleDisplay();
// REVIEW: Taken from nsBoxFrame::Paint
// Don't paint our children if the theme object is a leaf.
if (IsThemed(ourDisp) &&
!PresContext()->Theme()->WidgetIsContainer(ourDisp->mAppearance))
if (IsThemed(ourDisp) && !PresContext()->Theme()->WidgetIsContainer(
ourDisp->EffectiveAppearance()))
return;

// Since we're now sure that we're adding this frame to the display list
Expand Down Expand Up @@ -5884,14 +5885,14 @@ static nsIFrame::IntrinsicSizeOffsetData IntrinsicSizeOffsets(
nsPresContext* presContext = aFrame->PresContext();

LayoutDeviceIntMargin border = presContext->Theme()->GetWidgetBorder(
presContext->DeviceContext(), aFrame, disp->mAppearance);
presContext->DeviceContext(), aFrame, disp->EffectiveAppearance());
result.border = presContext->DevPixelsToAppUnits(
verticalAxis ? border.TopBottom() : border.LeftRight());

LayoutDeviceIntMargin padding;
if (presContext->Theme()->GetWidgetPadding(presContext->DeviceContext(),
aFrame, disp->mAppearance,
&padding)) {
if (presContext->Theme()->GetWidgetPadding(
presContext->DeviceContext(), aFrame, disp->EffectiveAppearance(),
&padding)) {
result.padding = presContext->DevPixelsToAppUnits(
verticalAxis ? padding.TopBottom() : padding.LeftRight());
}
Expand Down Expand Up @@ -6151,7 +6152,7 @@ LogicalSize nsIFrame::ComputeSize(gfxContext* aRenderingContext,
bool canOverride = true;
nsPresContext* presContext = PresContext();
presContext->Theme()->GetMinimumWidgetSize(
presContext, this, disp->mAppearance, &widget, &canOverride);
presContext, this, disp->EffectiveAppearance(), &widget, &canOverride);

// Convert themed widget's physical dimensions to logical coords
LogicalSize size(aWM,
Expand Down Expand Up @@ -9269,8 +9270,9 @@ bool nsIFrame::FinishAndStoreOverflow(nsOverflowAreas& aOverflowAreas,
if (!::IsXULBoxWrapped(this) && IsThemed(disp)) {
nsRect r(bounds);
nsPresContext* presContext = PresContext();
if (presContext->Theme()->GetWidgetOverflow(presContext->DeviceContext(),
this, disp->mAppearance, &r)) {
if (presContext->Theme()->GetWidgetOverflow(
presContext->DeviceContext(), this, disp->EffectiveAppearance(),
&r)) {
nsRect& vo = aOverflowAreas.VisualOverflow();
vo.UnionRectEdges(vo, r);
}
Expand Down
7 changes: 4 additions & 3 deletions layout/generic/nsIFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -1848,12 +1848,13 @@ class nsIFrame : public nsQueryFrame {
nsIFrame* mutable_this = const_cast<nsIFrame*>(this);
nsPresContext* pc = PresContext();
nsITheme* theme = pc->Theme();
if (!theme->ThemeSupportsWidget(pc, mutable_this, aDisp->mAppearance)) {
if (!theme->ThemeSupportsWidget(pc, mutable_this,
aDisp->EffectiveAppearance())) {
return false;
}
if (aTransparencyState) {
*aTransparencyState =
theme->GetWidgetTransparency(mutable_this, aDisp->mAppearance);
*aTransparencyState = theme->GetWidgetTransparency(
mutable_this, aDisp->EffectiveAppearance());
}
return true;
}
Expand Down
Loading

0 comments on commit 1fe732d

Please sign in to comment.