From 5d66838ba53399a537570bd99515f892f629e4bf Mon Sep 17 00:00:00 2001 From: K4sum1 Date: Thu, 21 Nov 2024 07:34:58 -0600 Subject: [PATCH] Stop browser chrome from forcing the non-native theme --- .../server/actors/animation-type-longhand.js | 1 - layout/reftests/native-theme/reftest.list | 1 + layout/style/ServoBindings.toml | 1 - layout/style/nsStyleStruct.cpp | 3 - layout/style/nsStyleStruct.h | 1 - layout/style/test/ListCSSProperties.cpp | 1 - servo/components/style/properties/data.py | 1 - .../properties/longhands/inherited_ui.mako.rs | 12 -- servo/components/style/values/computed/ui.rs | 6 +- servo/components/style/values/specified/ui.rs | 162 ------------------ servo/ports/geckolib/cbindgen.toml | 1 - widget/cocoa/nsNativeThemeCocoa.mm | 28 +-- widget/gtk/nsNativeThemeGTK.cpp | 12 +- widget/nsNativeTheme.cpp | 9 - widget/nsNativeTheme.h | 1 - widget/windows/nsNativeThemeWin.cpp | 22 +-- 16 files changed, 32 insertions(+), 230 deletions(-) diff --git a/devtools/server/actors/animation-type-longhand.js b/devtools/server/actors/animation-type-longhand.js index f4779402e21934..d222397c973973 100644 --- a/devtools/server/actors/animation-type-longhand.js +++ b/devtools/server/actors/animation-type-longhand.js @@ -236,7 +236,6 @@ exports.ANIMATION_TYPE_FOR_LONGHANDS = [ "-moz-context-properties", "-moz-control-character-visibility", "-moz-default-appearance", - "-moz-theme", "display", "font-optical-sizing", "inline-size", diff --git a/layout/reftests/native-theme/reftest.list b/layout/reftests/native-theme/reftest.list index d1cbd58cb297c8..805cf27cebb982 100644 --- a/layout/reftests/native-theme/reftest.list +++ b/layout/reftests/native-theme/reftest.list @@ -28,6 +28,7 @@ needs-focus == listbox-nonnative-when-styled.html listbox-nonnative-when-styled- != 427122-1.html 427122-1-ref.html == chrome://reftest/content/native-theme/470711-1.xhtml chrome://reftest/content/native-theme/470711-1-ref.xhtml + == chrome://reftest/content/native-theme/482955-1.xhtml chrome://reftest/content/native-theme/482955-1-ref.xhtml == 492155-1.html about:blank diff --git a/layout/style/ServoBindings.toml b/layout/style/ServoBindings.toml index c98db5563b56e1..697ed8d2bd6e21 100644 --- a/layout/style/ServoBindings.toml +++ b/layout/style/ServoBindings.toml @@ -383,7 +383,6 @@ cbindgen-types = [ { gecko = "StyleOffsetPathFunction", servo = "crate::values::computed::motion::OffsetPathFunction" }, { gecko = "StyleGenericOffsetPath", servo = "crate::values::generics::motion::OffsetPath" }, { gecko = "StyleGenericOffsetPathFunction", servo = "crate::values::generics::motion::OffsetPathFunction" }, - { gecko = "StyleMozTheme", servo = "crate::values::computed::ui::MozTheme" }, { gecko = "StyleOffsetPosition", servo = "crate::values::computed::motion::OffsetPosition" }, { gecko = "StyleOffsetRotate", servo = "crate::values::computed::motion::OffsetRotate" }, { gecko = "StylePathCommand", servo = "crate::values::specified::svg_path::PathCommand" }, diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp index e82825b8f08670..e001c7371bf03f 100644 --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -3002,7 +3002,6 @@ LogicalSide nsStyleText::TextEmphasisSide(WritingMode aWM, nsStyleUI::nsStyleUI() : mInert(StyleInert::None), - mMozTheme(StyleMozTheme::Auto), mUserInput(StyleUserInput::Auto), mUserModify(StyleUserModify::ReadOnly), mUserFocus(StyleUserFocus::Normal), @@ -3017,7 +3016,6 @@ nsStyleUI::nsStyleUI() nsStyleUI::nsStyleUI(const nsStyleUI& aSource) : mInert(aSource.mInert), - mMozTheme(aSource.mMozTheme), mUserInput(aSource.mUserInput), mUserModify(aSource.mUserModify), mUserFocus(aSource.mUserFocus), @@ -3083,7 +3081,6 @@ nsChangeHint nsStyleUI::CalcDifference(const nsStyleUI& aNewData) const { if (mCaretColor != aNewData.mCaretColor || mAccentColor != aNewData.mAccentColor || mScrollbarColor != aNewData.mScrollbarColor || - mMozTheme != aNewData.mMozTheme || mColorScheme != aNewData.mColorScheme) { hint |= nsChangeHint_RepaintFrame; } diff --git a/layout/style/nsStyleStruct.h b/layout/style/nsStyleStruct.h index 5962bbbb4d84ea..5967259c51530d 100644 --- a/layout/style/nsStyleStruct.h +++ b/layout/style/nsStyleStruct.h @@ -1849,7 +1849,6 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleUI { void TriggerImageLoads(mozilla::dom::Document&, const nsStyleUI*); mozilla::StyleInert mInert; - mozilla::StyleMozTheme mMozTheme; private: mozilla::StyleUserInput mUserInput; diff --git a/layout/style/test/ListCSSProperties.cpp b/layout/style/test/ListCSSProperties.cpp index 13ac6ae93db939..d78cfeaddc5159 100644 --- a/layout/style/test/ListCSSProperties.cpp +++ b/layout/style/test/ListCSSProperties.cpp @@ -94,7 +94,6 @@ const char* gInaccessibleProperties[] = { "-x-span", "-x-text-scale", "-moz-default-appearance", - "-moz-theme", "-moz-inert", "-moz-script-level", // parsed by UA sheets only "-moz-math-variant", diff --git a/servo/components/style/properties/data.py b/servo/components/style/properties/data.py index 46e9599ee45c82..1bcf0cadabe327 100644 --- a/servo/components/style/properties/data.py +++ b/servo/components/style/properties/data.py @@ -572,7 +572,6 @@ def specified_is_copy(self): "LineBreak", "LineClamp", "MasonryAutoFlow", - "MozTheme", "BoolInteger", "text::MozControlCharacterVisibility", "MathDepth", diff --git a/servo/components/style/properties/longhands/inherited_ui.mako.rs b/servo/components/style/properties/longhands/inherited_ui.mako.rs index 3cda78a8cb21f1..04e16324980d2e 100644 --- a/servo/components/style/properties/longhands/inherited_ui.mako.rs +++ b/servo/components/style/properties/longhands/inherited_ui.mako.rs @@ -117,16 +117,4 @@ ${helpers.predefined_type( spec="https://drafts.csswg.org/css-scrollbars-1/#scrollbar-color", boxed=True, ignored_when_colors_disabled=True, - affects="paint", -)} - -${helpers.predefined_type( - "-moz-theme", - "MozTheme", - "specified::MozTheme::Auto", - engines="gecko", - enabled_in="chrome", - animation_type="discrete", - spec="Internal", - affects="paint", )} diff --git a/servo/components/style/values/computed/ui.rs b/servo/components/style/values/computed/ui.rs index 511a57cbef28fe..6fa5137adf04ed 100644 --- a/servo/components/style/values/computed/ui.rs +++ b/servo/components/style/values/computed/ui.rs @@ -9,10 +9,8 @@ use crate::values::computed::image::Image; use crate::values::computed::Number; use crate::values::generics::ui as generics; -pub use crate::values::specified::ui::{ - BoolInteger, CursorKind, Inert, MozTheme, PointerEvents, UserFocus, UserInput, UserModify, - UserSelect, -}; +pub use crate::values::specified::ui::CursorKind; +pub use crate::values::specified::ui::{BoolInteger, UserSelect}; /// A computed value for the `cursor` property. pub type Cursor = generics::GenericCursor; diff --git a/servo/components/style/values/specified/ui.rs b/servo/components/style/values/specified/ui.rs index 2b387691de367c..0c656faab20dfc 100644 --- a/servo/components/style/values/specified/ui.rs +++ b/servo/components/style/values/specified/ui.rs @@ -230,165 +230,3 @@ pub enum CursorKind { ZoomOut, Auto, } - -/// The keywords allowed in the -moz-theme property. -#[derive( - Clone, - Copy, - Debug, - Eq, - FromPrimitive, - MallocSizeOf, - Parse, - PartialEq, - SpecifiedValueInfo, - ToComputedValue, - ToCss, - ToResolvedValue, - ToShmem, -)] -#[repr(u8)] -pub enum MozTheme { - /// Choose the default (maybe native) rendering. - Auto, - /// Choose the non-native rendering. - NonNative, -} - -/// The pointer-events property -/// https://svgwg.org/svg2-draft/interact.html#PointerEventsProperty -#[allow(missing_docs)] -#[derive( - Clone, - Copy, - Debug, - Eq, - FromPrimitive, - MallocSizeOf, - Parse, - PartialEq, - SpecifiedValueInfo, - ToComputedValue, - ToCss, - ToResolvedValue, - ToShmem, -)] -#[repr(u8)] -pub enum PointerEvents { - Auto, - None, - #[cfg(feature = "gecko")] - Visiblepainted, - #[cfg(feature = "gecko")] - Visiblefill, - #[cfg(feature = "gecko")] - Visiblestroke, - #[cfg(feature = "gecko")] - Visible, - #[cfg(feature = "gecko")] - Painted, - #[cfg(feature = "gecko")] - Fill, - #[cfg(feature = "gecko")] - Stroke, - #[cfg(feature = "gecko")] - All, -} - -/// Internal property to represent the inert attribute state: -/// https://html.spec.whatwg.org/multipage/#inert-subtrees -#[allow(missing_docs)] -#[derive( - Clone, - Copy, - Debug, - Eq, - FromPrimitive, - MallocSizeOf, - Parse, - PartialEq, - SpecifiedValueInfo, - ToComputedValue, - ToCss, - ToResolvedValue, - ToShmem, -)] -#[repr(u8)] -pub enum Inert { - None, - Inert, -} - -/// Non-standard user-input property. -/// https://developer.mozilla.org/en-US/docs/Web/CSS/-moz-user-input -#[allow(missing_docs)] -#[derive( - Clone, - Copy, - Debug, - Eq, - FromPrimitive, - MallocSizeOf, - Parse, - PartialEq, - SpecifiedValueInfo, - ToComputedValue, - ToCss, - ToResolvedValue, - ToShmem, -)] -#[repr(u8)] -pub enum UserInput { - Auto, - None, -} - -/// Non-standard -moz-user-modify property. -/// https://developer.mozilla.org/en-US/docs/Web/CSS/-moz-user-modify -#[allow(missing_docs)] -#[derive( - Clone, - Copy, - Debug, - Eq, - FromPrimitive, - MallocSizeOf, - Parse, - PartialEq, - SpecifiedValueInfo, - ToComputedValue, - ToCss, - ToResolvedValue, - ToShmem, -)] -#[repr(u8)] -pub enum UserModify { - ReadOnly, - ReadWrite, - WriteOnly, -} - -/// Internal -moz-user-focus property. -/// https://developer.mozilla.org/en-US/docs/Web/CSS/-moz-user-focus -#[allow(missing_docs)] -#[derive( - Clone, - Copy, - Debug, - Eq, - FromPrimitive, - MallocSizeOf, - Parse, - PartialEq, - SpecifiedValueInfo, - ToComputedValue, - ToCss, - ToResolvedValue, - ToShmem, -)] -#[repr(u8)] -pub enum UserFocus { - Normal, - None, - Ignore, -} diff --git a/servo/ports/geckolib/cbindgen.toml b/servo/ports/geckolib/cbindgen.toml index 19a346defb62cc..85b8a444acd073 100644 --- a/servo/ports/geckolib/cbindgen.toml +++ b/servo/ports/geckolib/cbindgen.toml @@ -143,7 +143,6 @@ include = [ "GenericFontFamily", "FontFamily", "FontFamilyNameSyntax", - "MozTheme", "OverflowWrap", "OffsetPath", "OffsetPathFunction", diff --git a/widget/cocoa/nsNativeThemeCocoa.mm b/widget/cocoa/nsNativeThemeCocoa.mm index 89558bef30ab50..6c79e356861ba5 100644 --- a/widget/cocoa/nsNativeThemeCocoa.mm +++ b/widget/cocoa/nsNativeThemeCocoa.mm @@ -2426,6 +2426,11 @@ static bool IsHiDPIContext(nsDeviceContext* aContext) { NS_OBJC_END_TRY_BLOCK_RETURN(Nothing()); } +static bool IsWidgetNonNative(StyleAppearance aAppearance) { + return nsNativeTheme::IsWidgetScrollbarPart(aAppearance) || + aAppearance == StyleAppearance::FocusOutline; +} + NS_IMETHODIMP nsNativeThemeCocoa::DrawWidgetBackground(gfxContext* aContext, nsIFrame* aFrame, StyleAppearance aAppearance, @@ -2434,9 +2439,9 @@ static bool IsHiDPIContext(nsDeviceContext* aContext) { DrawOverflow aDrawOverflow) { NS_OBJC_BEGIN_TRY_BLOCK_RETURN; - if (IsWidgetAlwaysNonNative(aFrame, aAppearance)) { - return ThemeCocoa::DrawWidgetBackground(aContext, aFrame, aAppearance, - aRect, aDirtyRect, aDrawOverflow); + if (IsWidgetNonNative(aAppearance)) { + return ThemeCocoa::DrawWidgetBackground(aContext, aFrame, aAppearance, aRect, aDirtyRect, + aDrawOverflow); } Maybe widgetInfo = ComputeWidgetInfo(aFrame, aAppearance, aRect); @@ -2650,8 +2655,8 @@ static bool IsHiDPIContext(nsDeviceContext* aContext) { mozilla::layers::RenderRootStateManager* aManager, nsIFrame* aFrame, StyleAppearance aAppearance, const nsRect& aRect) { if (IsWidgetAlwaysNonNative(aFrame, aAppearance)) { - return ThemeCocoa::CreateWebRenderCommandsForWidget( - aBuilder, aResources, aSc, aManager, aFrame, aAppearance, aRect); + return ThemeCocoa::CreateWebRenderCommandsForWidget(aBuilder, aResources, aSc, aManager, aFrame, + aAppearance, aRect); } // This list needs to stay consistent with the list in DrawWidgetBackground. @@ -2838,13 +2843,10 @@ static bool IsHiDPIContext(nsDeviceContext* aContext) { return false; } -bool nsNativeThemeCocoa::GetWidgetOverflow(nsDeviceContext* aContext, - nsIFrame* aFrame, - StyleAppearance aAppearance, - nsRect* aOverflowRect) { +bool nsNativeThemeCocoa::GetWidgetOverflow(nsDeviceContext* aContext, nsIFrame* aFrame, + StyleAppearance aAppearance, nsRect* aOverflowRect) { if (IsWidgetAlwaysNonNative(aFrame, aAppearance)) { - return ThemeCocoa::GetWidgetOverflow(aContext, aFrame, aAppearance, - aOverflowRect); + return ThemeCocoa::GetWidgetOverflow(aContext, aFrame, aAppearance, aOverflowRect); } nsIntMargin overflow; switch (aAppearance) { @@ -2908,7 +2910,7 @@ static bool IsHiDPIContext(nsDeviceContext* aContext) { StyleAppearance aAppearance) { NS_OBJC_BEGIN_TRY_BLOCK_RETURN; - if (IsWidgetAlwaysNonNative(aFrame, aAppearance)) { + if (IsWidgetNonNative(aAppearance)) { return ThemeCocoa::GetMinimumWidgetSize(aPresContext, aFrame, aAppearance); } @@ -3072,7 +3074,7 @@ static bool IsHiDPIContext(nsDeviceContext* aContext) { bool nsNativeThemeCocoa::ThemeSupportsWidget(nsPresContext* aPresContext, nsIFrame* aFrame, StyleAppearance aAppearance) { - if (IsWidgetAlwaysNonNative(aFrame, aAppearance)) { + if (IsWidgetNonNative(aAppearance)) { return ThemeCocoa::ThemeSupportsWidget(aPresContext, aFrame, aAppearance); } // if this is a dropdown button in a combobox the answer is always no diff --git a/widget/gtk/nsNativeThemeGTK.cpp b/widget/gtk/nsNativeThemeGTK.cpp index 8792e03a738523..18ba5b7b1b0718 100644 --- a/widget/gtk/nsNativeThemeGTK.cpp +++ b/widget/gtk/nsNativeThemeGTK.cpp @@ -945,9 +945,11 @@ bool nsNativeThemeGTK::GetWidgetOverflow(nsDeviceContext* aContext, return true; } -auto nsNativeThemeGTK::IsWidgetNonNative( - nsIFrame* aFrame, StyleAppearance aAppearance) -> NonNative { - if (IsWidgetAlwaysNonNative(aFrame, aAppearance)) { +auto nsNativeThemeGTK::IsWidgetNonNative(nsIFrame* aFrame, + StyleAppearance aAppearance) + -> NonNative { + if (IsWidgetScrollbarPart(aAppearance) || + aAppearance == StyleAppearance::FocusOutline) { return NonNative::Always; } @@ -990,7 +992,7 @@ bool nsNativeThemeGTK::IsWidgetAlwaysNonNative(nsIFrame* aFrame, LayoutDeviceIntSize nsNativeThemeGTK::GetMinimumWidgetSize( nsPresContext* aPresContext, nsIFrame* aFrame, StyleAppearance aAppearance) { - if (IsWidgetAlwaysNonNative(aFrame, aAppearance)) { + if (IsWidgetNonNative(aFrame, aAppearance) == NonNative::Always) { return Theme::GetMinimumWidgetSize(aPresContext, aFrame, aAppearance); } @@ -1155,7 +1157,7 @@ nsNativeThemeGTK::ThemeSupportsWidget(nsPresContext* aPresContext, return false; } - if (IsWidgetAlwaysNonNative(aFrame, aAppearance)) { + if (IsWidgetNonNative(aFrame, aAppearance) == NonNative::Always) { return Theme::ThemeSupportsWidget(aPresContext, aFrame, aAppearance); } diff --git a/widget/nsNativeTheme.cpp b/widget/nsNativeTheme.cpp index de69f5954cf909..f398e764864257 100644 --- a/widget/nsNativeTheme.cpp +++ b/widget/nsNativeTheme.cpp @@ -581,12 +581,3 @@ bool nsNativeTheme::IsWidgetScrollbarPart(StyleAppearance aAppearance) { return false; } } - -/*static*/ -bool nsNativeTheme::IsWidgetAlwaysNonNative(nsIFrame* aFrame, - StyleAppearance aAppearance) { - return IsWidgetScrollbarPart(aAppearance) || - aAppearance == StyleAppearance::FocusOutline || - aAppearance == StyleAppearance::Menuarrow || - (aFrame && aFrame->StyleUI()->mMozTheme == StyleMozTheme::NonNative); -} diff --git a/widget/nsNativeTheme.h b/widget/nsNativeTheme.h index 28a8c0cc3fad6c..1da764b82a30d4 100644 --- a/widget/nsNativeTheme.h +++ b/widget/nsNativeTheme.h @@ -159,7 +159,6 @@ class nsNativeTheme : public nsITimerCallback, public nsINamed { static bool IsDarkBackground(nsIFrame*); static bool IsWidgetScrollbarPart(mozilla::StyleAppearance); - static bool IsWidgetAlwaysNonNative(nsIFrame*, mozilla::StyleAppearance); private: uint32_t mAnimatedContentTimeout; diff --git a/widget/windows/nsNativeThemeWin.cpp b/widget/windows/nsNativeThemeWin.cpp index 6597581c201ce0..2020738916917c 100644 --- a/widget/windows/nsNativeThemeWin.cpp +++ b/widget/windows/nsNativeThemeWin.cpp @@ -65,19 +65,11 @@ nsNativeThemeWin::nsNativeThemeWin() nsNativeThemeWin::~nsNativeThemeWin() { nsUXThemeData::Invalidate(); } -bool nsNativeThemeWin::IsWidgetAlwaysNonNative(nsIFrame* aFrame, - StyleAppearance aAppearance) { - return Theme::IsWidgetAlwaysNonNative(aFrame, aAppearance) || - aAppearance == StyleAppearance::Checkbox || - aAppearance == StyleAppearance::Radio || - aAppearance == StyleAppearance::MozMenulistArrowButton || - aAppearance == StyleAppearance::SpinnerUpbutton || - aAppearance == StyleAppearance::SpinnerDownbutton; -} - -auto nsNativeThemeWin::IsWidgetNonNative( - nsIFrame* aFrame, StyleAppearance aAppearance) -> NonNative { - if (IsWidgetAlwaysNonNative(aFrame, aAppearance)) { +auto nsNativeThemeWin::IsWidgetNonNative(nsIFrame* aFrame, + StyleAppearance aAppearance) + -> NonNative { + if (IsWidgetScrollbarPart(aAppearance) || + aAppearance == StyleAppearance::FocusOutline) { return NonNative::Always; } @@ -1747,7 +1739,7 @@ bool nsNativeThemeWin::GetWidgetOverflow(nsDeviceContext* aContext, LayoutDeviceIntSize nsNativeThemeWin::GetMinimumWidgetSize( nsPresContext* aPresContext, nsIFrame* aFrame, StyleAppearance aAppearance) { - if (IsWidgetAlwaysNonNative(aFrame, aAppearance)) { + if (IsWidgetNonNative(aFrame, aAppearance) == NonNative::Always) { return Theme::GetMinimumWidgetSize(aPresContext, aFrame, aAppearance); } @@ -1935,7 +1927,7 @@ bool nsNativeThemeWin::ThemeSupportsWidget(nsPresContext* aPresContext, // XXXdwh We can go even further and call the API to ask if support exists for // specific widgets. - if (IsWidgetAlwaysNonNative(aFrame, aAppearance)) { + if (IsWidgetNonNative(aFrame, aAppearance) == NonNative::Always) { return Theme::ThemeSupportsWidget(aPresContext, aFrame, aAppearance); }