mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-02 22:37:50 +00:00
Bug 1687868 - Prevent skia fuzziness in nsNativeBasicTheme. r=heycam
Differential Revision: https://phabricator.services.mozilla.com/D102773
This commit is contained in:
parent
3337733df4
commit
ed2fc6bdce
@ -21,6 +21,29 @@ using namespace mozilla::gfx;
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(nsNativeBasicTheme, nsNativeTheme, nsITheme)
|
||||
|
||||
namespace {
|
||||
|
||||
// This pushes and pops a clip rect to the draw target.
|
||||
//
|
||||
// This is done to reduce fuzz in places where we may have antialiasing,
|
||||
// because skia is not clip-invariant: given different clips, it does not
|
||||
// guarantee the same result, even if the painted content doesn't intersect
|
||||
// the clips.
|
||||
//
|
||||
// This is a bit sad, overall, but...
|
||||
struct MOZ_RAII AutoClipRect {
|
||||
AutoClipRect(DrawTarget& aDt, const LayoutDeviceRect& aRect) : mDt(aDt) {
|
||||
mDt.PushClipRect(aRect.ToUnknownRect());
|
||||
}
|
||||
|
||||
~AutoClipRect() { mDt.PopClip(); }
|
||||
|
||||
private:
|
||||
DrawTarget& mDt;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
static bool IsScrollbarWidthThin(nsIFrame* aFrame) {
|
||||
ComputedStyle* style = nsLayoutUtils::StyleForScrollbar(aFrame);
|
||||
auto scrollbarWidth = style->StyleUIReset()->mScrollbarWidth;
|
||||
@ -1177,6 +1200,15 @@ nsNativeBasicTheme::DrawWidgetBackground(gfxContext* aContext, nsIFrame* aFrame,
|
||||
}
|
||||
}
|
||||
|
||||
// Hack to avoid skia fuzziness: Add a dummy clip if the widget doesn't
|
||||
// overflow devPxRect.
|
||||
Maybe<AutoClipRect> maybeClipRect;
|
||||
if (aAppearance != StyleAppearance::FocusOutline &&
|
||||
aAppearance != StyleAppearance::Range &&
|
||||
!eventState.HasState(NS_EVENT_STATE_FOCUSRING)) {
|
||||
maybeClipRect.emplace(*dt, devPxRect);
|
||||
}
|
||||
|
||||
DPIRatio dpiRatio = GetDPIRatio(aFrame);
|
||||
|
||||
switch (aAppearance) {
|
||||
|
@ -199,25 +199,6 @@ class nsNativeBasicTheme : protected nsNativeTheme, public nsITheme {
|
||||
static bool IsRootScrollbar(nsIFrame* aFrame);
|
||||
static LayoutDeviceRect FixAspectRatio(const LayoutDeviceRect& aRect);
|
||||
|
||||
// This pushes and pops a clip rect to the draw target.
|
||||
//
|
||||
// This is done to reduce fuzz in places where we may have antialiasing,
|
||||
// because skia is not clip-invariant: given different clips, it does not
|
||||
// guarantee the same result, even if the painted content doesn't intersect
|
||||
// the clips.
|
||||
//
|
||||
// This is a bit sad, overall, but...
|
||||
struct MOZ_RAII AutoClipRect {
|
||||
AutoClipRect(DrawTarget& aDt, const LayoutDeviceRect& aRect) : mDt(aDt) {
|
||||
mDt.PushClipRect(aRect.ToUnknownRect());
|
||||
}
|
||||
|
||||
~AutoClipRect() { mDt.PopClip(); }
|
||||
|
||||
private:
|
||||
DrawTarget& mDt;
|
||||
};
|
||||
|
||||
virtual std::pair<sRGBColor, sRGBColor> ComputeCheckboxColors(
|
||||
const EventStates& aState, StyleAppearance aAppearance);
|
||||
virtual sRGBColor ComputeCheckmarkColor(const EventStates& aState);
|
||||
|
Loading…
x
Reference in New Issue
Block a user