Skip to content

Commit

Permalink
Stop browser chrome from forcing the non-native theme
Browse files Browse the repository at this point in the history
  • Loading branch information
K4sum1 committed Nov 23, 2024
1 parent ba800f1 commit 5d66838
Show file tree
Hide file tree
Showing 16 changed files with 32 additions and 230 deletions.
1 change: 0 additions & 1 deletion devtools/server/actors/animation-type-longhand.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions layout/reftests/native-theme/reftest.list
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion layout/style/ServoBindings.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand Down
3 changes: 0 additions & 3 deletions layout/style/nsStyleStruct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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),
Expand Down Expand Up @@ -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;
}
Expand Down
1 change: 0 additions & 1 deletion layout/style/nsStyleStruct.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion layout/style/test/ListCSSProperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion servo/components/style/properties/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,6 @@ def specified_is_copy(self):
"LineBreak",
"LineClamp",
"MasonryAutoFlow",
"MozTheme",
"BoolInteger",
"text::MozControlCharacterVisibility",
"MathDepth",
Expand Down
12 changes: 0 additions & 12 deletions servo/components/style/properties/longhands/inherited_ui.mako.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)}
6 changes: 2 additions & 4 deletions servo/components/style/values/computed/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<CursorImage>;
Expand Down
162 changes: 0 additions & 162 deletions servo/components/style/values/specified/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
1 change: 0 additions & 1 deletion servo/ports/geckolib/cbindgen.toml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ include = [
"GenericFontFamily",
"FontFamily",
"FontFamilyNameSyntax",
"MozTheme",
"OverflowWrap",
"OffsetPath",
"OffsetPathFunction",
Expand Down
28 changes: 15 additions & 13 deletions widget/cocoa/nsNativeThemeCocoa.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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> widgetInfo = ComputeWidgetInfo(aFrame, aAppearance, aRect);
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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
Expand Down
12 changes: 7 additions & 5 deletions widget/gtk/nsNativeThemeGTK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand Down
9 changes: 0 additions & 9 deletions widget/nsNativeTheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Loading

0 comments on commit 5d66838

Please sign in to comment.