зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1690043 - Remove requirement for root scrollbars to be opaque in the non-native theme. r=mstange
This seems to come from bug 1179780, but custom scrollbars shouldn't have this requirement, and it's kind of artificial anyway. Differential Revision: https://phabricator.services.mozilla.com/D103692
This commit is contained in:
Родитель
325953b00c
Коммит
e7cfc6d6f2
|
@ -0,0 +1,8 @@
|
|||
<!doctype html>
|
||||
<meta charset="utf-8">
|
||||
<title>CSS Test: non-opaque scrollbar-color should work on the root</title>
|
||||
<style>
|
||||
:root {
|
||||
background-color: black;
|
||||
}
|
||||
</style>
|
|
@ -0,0 +1,14 @@
|
|||
<!doctype html>
|
||||
<meta charset="utf-8">
|
||||
<title>CSS Test: non-opaque scrollbar-color should work on the root</title>
|
||||
<link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io">
|
||||
<link rel="author" title="Mozilla" href="https://www.mozilla.org">
|
||||
<link rel="help" href="https://drafts.csswg.org/css-scrollbars-1/#scrollbar-color-properties">
|
||||
<link rel="match" href="transparent-on-root-ref.html">
|
||||
<style>
|
||||
:root {
|
||||
overflow: scroll;
|
||||
scrollbar-color: transparent transparent;
|
||||
background-color: black;
|
||||
}
|
||||
</style>
|
|
@ -63,7 +63,7 @@ void nsNativeBasicThemeCocoa::PaintScrollbarThumb(
|
|||
void nsNativeBasicThemeCocoa::PaintScrollbarTrack(
|
||||
DrawTarget* aDrawTarget, const LayoutDeviceRect& aRect, bool aHorizontal,
|
||||
nsIFrame* aFrame, const ComputedStyle& aStyle,
|
||||
const EventStates& aDocumentState, DPIRatio aDpiRatio, bool aIsRoot) {
|
||||
const EventStates& aDocumentState, DPIRatio aDpiRatio) {
|
||||
ScrollbarParams params =
|
||||
ScrollbarDrawingMac::ComputeScrollbarParams(aFrame, aStyle, aHorizontal);
|
||||
auto rect = aRect.ToUnknownRect();
|
||||
|
@ -82,14 +82,14 @@ void nsNativeBasicThemeCocoa::PaintScrollbar(DrawTarget* aDrawTarget,
|
|||
bool aHorizontal, nsIFrame* aFrame,
|
||||
const ComputedStyle& aStyle,
|
||||
const EventStates& aDocumentState,
|
||||
DPIRatio aDpiRatio, bool aIsRoot) {
|
||||
DPIRatio aDpiRatio) {
|
||||
// Draw nothing; the scrollbar track is drawn in PaintScrollbarTrack.
|
||||
}
|
||||
|
||||
void nsNativeBasicThemeCocoa::PaintScrollCorner(
|
||||
DrawTarget* aDrawTarget, const LayoutDeviceRect& aRect, nsIFrame* aFrame,
|
||||
const ComputedStyle& aStyle, const EventStates& aDocumentState,
|
||||
DPIRatio aDpiRatio, bool aIsRoot) {
|
||||
DPIRatio aDpiRatio) {
|
||||
ScrollbarParams params =
|
||||
ScrollbarDrawingMac::ComputeScrollbarParams(aFrame, aStyle, false);
|
||||
if (aDpiRatio.scale >= 2.0f) {
|
||||
|
|
|
@ -36,16 +36,16 @@ class nsNativeBasicThemeCocoa : public nsNativeBasicTheme {
|
|||
const LayoutDeviceRect& aRect, bool aHorizontal,
|
||||
nsIFrame* aFrame, const ComputedStyle& aStyle,
|
||||
const EventStates& aDocumentState,
|
||||
DPIRatio aDpiRatio, bool aIsRoot) override;
|
||||
DPIRatio aDpiRatio) override;
|
||||
void PaintScrollbar(DrawTarget* aDrawTarget, const LayoutDeviceRect& aRect,
|
||||
bool aHorizontal, nsIFrame* aFrame,
|
||||
const ComputedStyle& aStyle,
|
||||
const EventStates& aDocumentState, DPIRatio aDpiRatio,
|
||||
bool aIsRoot) override;
|
||||
const EventStates& aDocumentState,
|
||||
DPIRatio aDpiRatio) override;
|
||||
void PaintScrollCorner(DrawTarget* aDrawTarget, const LayoutDeviceRect& aRect,
|
||||
nsIFrame* aFrame, const ComputedStyle& aStyle,
|
||||
const EventStates& aDocumentState, DPIRatio aDpiRatio,
|
||||
bool aIsRoot) override;
|
||||
const EventStates& aDocumentState,
|
||||
DPIRatio aDpiRatio) override;
|
||||
|
||||
protected:
|
||||
virtual ~nsNativeBasicThemeCocoa() = default;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "nsNativeBasicThemeGTK.h"
|
||||
|
||||
#include "nsLayoutUtils.h"
|
||||
#include "mozilla/dom/Document.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
|
@ -24,15 +25,15 @@ already_AddRefed<nsITheme> do_GetBasicNativeThemeDoNotUseDirectly() {
|
|||
|
||||
nsITheme::Transparency nsNativeBasicThemeGTK::GetWidgetTransparency(
|
||||
nsIFrame* aFrame, StyleAppearance aAppearance) {
|
||||
switch (aAppearance) {
|
||||
case StyleAppearance::ScrollbarVertical:
|
||||
case StyleAppearance::ScrollbarHorizontal:
|
||||
// Make scrollbar tracks opaque on the window's scroll frame to prevent
|
||||
// leaf layers from overlapping. See bug 1179780.
|
||||
return IsRootScrollbar(aFrame) ? eOpaque : eTransparent;
|
||||
default:
|
||||
return nsNativeBasicTheme::GetWidgetTransparency(aFrame, aAppearance);
|
||||
if (aAppearance == StyleAppearance::ScrollbarVertical ||
|
||||
aAppearance == StyleAppearance::ScrollbarHorizontal) {
|
||||
auto docState = aFrame->PresContext()->Document()->GetDocumentState();
|
||||
const auto* style = nsLayoutUtils::StyleForScrollbar(aFrame);
|
||||
auto [trackColor, borderColor] =
|
||||
ComputeScrollbarColors(aFrame, *style, docState);
|
||||
return trackColor.a == 1.0 ? eOpaque : eTransparent;
|
||||
}
|
||||
return nsNativeBasicTheme::GetWidgetTransparency(aFrame, aAppearance);
|
||||
}
|
||||
|
||||
auto nsNativeBasicThemeGTK::GetScrollbarSizes(nsPresContext* aPresContext,
|
||||
|
@ -101,9 +102,9 @@ void nsNativeBasicThemeGTK::PaintScrollbar(DrawTarget* aDrawTarget,
|
|||
bool aHorizontal, nsIFrame* aFrame,
|
||||
const ComputedStyle& aStyle,
|
||||
const EventStates& aDocumentState,
|
||||
DPIRatio aDpiRatio, bool aIsRoot) {
|
||||
DPIRatio aDpiRatio) {
|
||||
auto [trackColor, borderColor] =
|
||||
ComputeScrollbarColors(aFrame, aStyle, aDocumentState, aIsRoot);
|
||||
ComputeScrollbarColors(aFrame, aStyle, aDocumentState);
|
||||
Unused << borderColor;
|
||||
aDrawTarget->FillRect(aRect.ToUnknownRect(),
|
||||
gfx::ColorPattern(ToDeviceColor(trackColor)));
|
||||
|
@ -112,9 +113,9 @@ void nsNativeBasicThemeGTK::PaintScrollbar(DrawTarget* aDrawTarget,
|
|||
void nsNativeBasicThemeGTK::PaintScrollCorner(
|
||||
DrawTarget* aDrawTarget, const LayoutDeviceRect& aRect, nsIFrame* aFrame,
|
||||
const ComputedStyle& aStyle, const EventStates& aDocumentState,
|
||||
DPIRatio aDpiRatio, bool aIsRoot) {
|
||||
DPIRatio aDpiRatio) {
|
||||
auto [trackColor, borderColor] =
|
||||
ComputeScrollbarColors(aFrame, aStyle, aDocumentState, aIsRoot);
|
||||
ComputeScrollbarColors(aFrame, aStyle, aDocumentState);
|
||||
Unused << borderColor;
|
||||
aDrawTarget->FillRect(aRect.ToUnknownRect(),
|
||||
gfx::ColorPattern(ToDeviceColor(trackColor)));
|
||||
|
|
|
@ -29,12 +29,12 @@ class nsNativeBasicThemeGTK : public nsNativeBasicTheme {
|
|||
void PaintScrollbar(DrawTarget* aDrawTarget, const LayoutDeviceRect& aRect,
|
||||
bool aHorizontal, nsIFrame* aFrame,
|
||||
const ComputedStyle& aStyle,
|
||||
const EventStates& aDocumentState, DPIRatio aDpiRatio,
|
||||
bool aIsRoot) override;
|
||||
const EventStates& aDocumentState,
|
||||
DPIRatio aDpiRatio) override;
|
||||
void PaintScrollCorner(DrawTarget* aDrawTarget, const LayoutDeviceRect& aRect,
|
||||
nsIFrame* aFrame, const ComputedStyle& aStyle,
|
||||
const EventStates& aDocumentState, DPIRatio aDpiRatio,
|
||||
bool aIsRoot) override;
|
||||
const EventStates& aDocumentState,
|
||||
DPIRatio aDpiRatio) override;
|
||||
bool ThemeSupportsScrollbarButtons() override { return false; }
|
||||
ScrollbarSizes GetScrollbarSizes(nsPresContext*, StyleScrollbarWidth,
|
||||
Overlay) override;
|
||||
|
|
|
@ -343,7 +343,7 @@ std::array<sRGBColor, 3> nsNativeBasicTheme::ComputeFocusRectColors() {
|
|||
|
||||
std::pair<sRGBColor, sRGBColor> nsNativeBasicTheme::ComputeScrollbarColors(
|
||||
nsIFrame* aFrame, const ComputedStyle& aStyle,
|
||||
const EventStates& aDocumentState, bool aIsRoot) {
|
||||
const EventStates& aDocumentState) {
|
||||
const nsStyleUI* ui = aStyle.StyleUI();
|
||||
nscolor color;
|
||||
if (ui->mScrollbarColor.IsColors()) {
|
||||
|
@ -355,12 +355,6 @@ std::pair<sRGBColor, sRGBColor> nsNativeBasicTheme::ComputeScrollbarColors(
|
|||
color = LookAndFeel::GetColor(LookAndFeel::ColorID::ThemedScrollbar,
|
||||
sScrollbarColor.ToABGR());
|
||||
}
|
||||
if (aIsRoot) {
|
||||
// Root scrollbars must be opaque.
|
||||
nscolor bg = LookAndFeel::GetColor(LookAndFeel::ColorID::WindowBackground,
|
||||
NS_RGB(0xff, 0xff, 0xff));
|
||||
color = NS_ComposeColors(bg, color);
|
||||
}
|
||||
return std::make_pair(gfx::sRGBColor::FromABGR(color), sScrollbarBorderColor);
|
||||
}
|
||||
|
||||
|
@ -988,7 +982,7 @@ void nsNativeBasicTheme::PaintScrollbarTrack(DrawTarget* aDrawTarget,
|
|||
bool aHorizontal, nsIFrame* aFrame,
|
||||
const ComputedStyle& aStyle,
|
||||
const EventStates& aDocumentState,
|
||||
DPIRatio aDpiRatio, bool aIsRoot) {
|
||||
DPIRatio aDpiRatio) {
|
||||
// Draw nothing by default. Subclasses can override this.
|
||||
}
|
||||
|
||||
|
@ -997,9 +991,9 @@ void nsNativeBasicTheme::PaintScrollbar(DrawTarget* aDrawTarget,
|
|||
bool aHorizontal, nsIFrame* aFrame,
|
||||
const ComputedStyle& aStyle,
|
||||
const EventStates& aDocumentState,
|
||||
DPIRatio aDpiRatio, bool aIsRoot) {
|
||||
DPIRatio aDpiRatio) {
|
||||
auto [scrollbarColor, borderColor] =
|
||||
ComputeScrollbarColors(aFrame, aStyle, aDocumentState, aIsRoot);
|
||||
ComputeScrollbarColors(aFrame, aStyle, aDocumentState);
|
||||
aDrawTarget->FillRect(aRect.ToUnknownRect(),
|
||||
ColorPattern(ToDeviceColor(scrollbarColor)));
|
||||
// FIXME(heycam): We should probably derive the border color when custom
|
||||
|
@ -1024,9 +1018,9 @@ void nsNativeBasicTheme::PaintScrollCorner(DrawTarget* aDrawTarget,
|
|||
nsIFrame* aFrame,
|
||||
const ComputedStyle& aStyle,
|
||||
const EventStates& aDocumentState,
|
||||
DPIRatio aDpiRatio, bool aIsRoot) {
|
||||
DPIRatio aDpiRatio) {
|
||||
auto [scrollbarColor, borderColor] =
|
||||
ComputeScrollbarColors(aFrame, aStyle, aDocumentState, aIsRoot);
|
||||
ComputeScrollbarColors(aFrame, aStyle, aDocumentState);
|
||||
Unused << borderColor;
|
||||
aDrawTarget->FillRect(aRect.ToUnknownRect(),
|
||||
ColorPattern(ToDeviceColor(scrollbarColor)));
|
||||
|
@ -1095,15 +1089,6 @@ void nsNativeBasicTheme::PaintScrollbarButton(
|
|||
}
|
||||
}
|
||||
|
||||
// Checks whether the frame is for a root <scrollbar> or <scrollcorner>, which
|
||||
// influences some platforms' scrollbar rendering.
|
||||
bool nsNativeBasicTheme::IsRootScrollbar(nsIFrame* aFrame) {
|
||||
return CheckBooleanAttr(aFrame, nsGkAtoms::root_) &&
|
||||
aFrame->PresContext()->IsRootContentDocument() &&
|
||||
aFrame->GetContent() &&
|
||||
aFrame->GetContent()->IsInNamespace(kNameSpaceID_XUL);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNativeBasicTheme::DrawWidgetBackground(gfxContext* aContext, nsIFrame* aFrame,
|
||||
StyleAppearance aAppearance,
|
||||
|
@ -1112,7 +1097,7 @@ nsNativeBasicTheme::DrawWidgetBackground(gfxContext* aContext, nsIFrame* aFrame,
|
|||
DrawTarget* dt = aContext->GetDrawTarget();
|
||||
const nscoord twipsPerPixel = aFrame->PresContext()->AppUnitsPerDevPixel();
|
||||
EventStates eventState = GetContentState(aFrame, aAppearance);
|
||||
EventStates docState = aFrame->GetContent()->OwnerDoc()->GetDocumentState();
|
||||
EventStates docState = aFrame->PresContext()->Document()->GetDocumentState();
|
||||
auto devPxRect = LayoutDeviceRect::FromUnknownRect(
|
||||
NSRectToSnappedRect(aRect, twipsPerPixel, *dt));
|
||||
|
||||
|
@ -1220,7 +1205,7 @@ nsNativeBasicTheme::DrawWidgetBackground(gfxContext* aContext, nsIFrame* aFrame,
|
|||
aAppearance == StyleAppearance::ScrollbartrackHorizontal;
|
||||
PaintScrollbarTrack(dt, devPxRect, isHorizontal, aFrame,
|
||||
*nsLayoutUtils::StyleForScrollbar(aFrame), docState,
|
||||
dpiRatio, IsRootScrollbar(aFrame));
|
||||
dpiRatio);
|
||||
break;
|
||||
}
|
||||
case StyleAppearance::ScrollbarHorizontal:
|
||||
|
@ -1228,13 +1213,13 @@ nsNativeBasicTheme::DrawWidgetBackground(gfxContext* aContext, nsIFrame* aFrame,
|
|||
bool isHorizontal = aAppearance == StyleAppearance::ScrollbarHorizontal;
|
||||
PaintScrollbar(dt, devPxRect, isHorizontal, aFrame,
|
||||
*nsLayoutUtils::StyleForScrollbar(aFrame), docState,
|
||||
dpiRatio, IsRootScrollbar(aFrame));
|
||||
dpiRatio);
|
||||
break;
|
||||
}
|
||||
case StyleAppearance::Scrollcorner:
|
||||
PaintScrollCorner(dt, devPxRect, aFrame,
|
||||
*nsLayoutUtils::StyleForScrollbar(aFrame), docState,
|
||||
dpiRatio, IsRootScrollbar(aFrame));
|
||||
dpiRatio);
|
||||
break;
|
||||
case StyleAppearance::ScrollbarbuttonUp:
|
||||
case StyleAppearance::ScrollbarbuttonDown:
|
||||
|
|
|
@ -199,7 +199,6 @@ class nsNativeBasicTheme : protected nsNativeTheme, public nsITheme {
|
|||
static DPIRatio GetDPIRatio(nsIFrame* aFrame, StyleAppearance);
|
||||
static bool IsDateTimeResetButton(nsIFrame* aFrame);
|
||||
static bool IsColorPickerButton(nsIFrame* aFrame);
|
||||
static bool IsRootScrollbar(nsIFrame* aFrame);
|
||||
static LayoutDeviceRect FixAspectRatio(const LayoutDeviceRect& aRect);
|
||||
|
||||
virtual std::pair<sRGBColor, sRGBColor> ComputeCheckboxColors(
|
||||
|
@ -228,7 +227,7 @@ class nsNativeBasicTheme : protected nsNativeTheme, public nsITheme {
|
|||
virtual std::array<sRGBColor, 3> ComputeFocusRectColors();
|
||||
virtual std::pair<sRGBColor, sRGBColor> ComputeScrollbarColors(
|
||||
nsIFrame* aFrame, const ComputedStyle& aStyle,
|
||||
const EventStates& aDocumentState, bool aIsRoot);
|
||||
const EventStates& aDocumentState);
|
||||
virtual sRGBColor ComputeScrollbarThumbColor(
|
||||
nsIFrame* aFrame, const ComputedStyle& aStyle,
|
||||
const EventStates& aElementState, const EventStates& aDocumentState);
|
||||
|
@ -305,18 +304,18 @@ class nsNativeBasicTheme : protected nsNativeTheme, public nsITheme {
|
|||
const LayoutDeviceRect& aRect, bool aHorizontal,
|
||||
nsIFrame* aFrame, const ComputedStyle& aStyle,
|
||||
const EventStates& aDocumentState,
|
||||
DPIRatio aDpiRatio, bool aIsRoot);
|
||||
DPIRatio aDpiRatio);
|
||||
virtual void PaintScrollbarTrack(DrawTarget* aDrawTarget,
|
||||
const LayoutDeviceRect& aRect,
|
||||
bool aHorizontal, nsIFrame* aFrame,
|
||||
const ComputedStyle& aStyle,
|
||||
const EventStates& aDocumentState,
|
||||
DPIRatio aDpiRatio, bool aIsRoot);
|
||||
DPIRatio aDpiRatio);
|
||||
virtual void PaintScrollCorner(DrawTarget* aDrawTarget,
|
||||
const LayoutDeviceRect& aRect,
|
||||
nsIFrame* aFrame, const ComputedStyle& aStyle,
|
||||
const EventStates& aDocumentState,
|
||||
DPIRatio aDpiRatio, bool aIsRoot);
|
||||
DPIRatio aDpiRatio);
|
||||
virtual void PaintScrollbarButton(
|
||||
DrawTarget* aDrawTarget, StyleAppearance aAppearance,
|
||||
const LayoutDeviceRect& aRect, nsIFrame* aFrame,
|
||||
|
|
|
@ -221,7 +221,7 @@ std::array<sRGBColor, 3> nsNativeBasicThemeWin::ComputeFocusRectColors() {
|
|||
|
||||
std::pair<sRGBColor, sRGBColor> nsNativeBasicThemeWin::ComputeScrollbarColors(
|
||||
nsIFrame* aFrame, const ComputedStyle& aStyle,
|
||||
const EventStates& aDocumentState, bool aIsRoot) {
|
||||
const EventStates& aDocumentState) {
|
||||
if (!LookAndFeel::GetInt(LookAndFeel::IntID::UseAccessibilityTheme, 0)) {
|
||||
nscolor trackColor = ScrollbarUtil::GetScrollbarTrackColor(aFrame);
|
||||
sRGBColor color = sRGBColor::FromABGR(trackColor);
|
||||
|
|
|
@ -44,7 +44,7 @@ class nsNativeBasicThemeWin : public nsNativeBasicTheme {
|
|||
std::array<sRGBColor, 3> ComputeFocusRectColors() override;
|
||||
std::pair<sRGBColor, sRGBColor> ComputeScrollbarColors(
|
||||
nsIFrame* aFrame, const ComputedStyle& aStyle,
|
||||
const EventStates& aDocumentState, bool aIsRoot) override;
|
||||
const EventStates& aDocumentState) override;
|
||||
sRGBColor ComputeScrollbarThumbColor(
|
||||
nsIFrame* aFrame, const ComputedStyle& aStyle,
|
||||
const EventStates& aElementState,
|
||||
|
|
Загрузка…
Ссылка в новой задаче