Bug 1962978 - Use non-native listboxes on GTK. r=stransky,geckoview-reviewers,nika
Gtk4 doesn't use different background colors for GtkColumnView (the replacement for the treeview), so avoid computing one. Our computation didn't have any guarantee of matching the fieldtext foreground color. This matches windows too. Remove unused -moz-eventreerow while at it. Differential Revision: https://phabricator.services.mozilla.com/D249237
This commit is contained in:
committed by
ealvarez@mozilla.com
parent
52cff163d1
commit
5bf95f9046
@@ -46,7 +46,6 @@ function runTest(testCanvasColors) {
|
||||
[ "-moz-ComboboxText", 0x00, 0x00, 0x00 ],
|
||||
[ "-moz-Dialog", 0xF0, 0xF0, 0xF0 ],
|
||||
[ "-moz-DialogText", 0x00, 0x00, 0x00 ],
|
||||
[ "-moz-EvenTreeRow", 0xFF, 0xFF, 0xFF ],
|
||||
[ "-moz-Field", 0xFF, 0xFF, 0xFF ],
|
||||
[ "-moz-FieldText", 0x00, 0x00, 0x00 ],
|
||||
[ "-moz-MenuHover", 0x33, 0x99, 0xFF ],
|
||||
|
||||
@@ -270,9 +270,8 @@ pub enum SystemColor {
|
||||
/// Used for menubar item text when hovered.
|
||||
MozMenubarhovertext,
|
||||
|
||||
/// On platforms where these colors are the same as -moz-field, use
|
||||
/// -moz-fieldtext as foreground color
|
||||
MozEventreerow,
|
||||
/// On platforms where this color is the same as field, or transparent, use fieldtext as
|
||||
/// foreground color.
|
||||
MozOddtreerow,
|
||||
|
||||
/// Used for button text when pressed.
|
||||
|
||||
@@ -223,7 +223,6 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, ColorScheme aColorScheme,
|
||||
case ColorID::Field:
|
||||
case ColorID::Threedhighlight:
|
||||
case ColorID::MozCombobox:
|
||||
case ColorID::MozEventreerow:
|
||||
aColor = NS_RGB(0xff, 0xff, 0xff);
|
||||
break;
|
||||
|
||||
|
||||
@@ -326,7 +326,6 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, ColorScheme aScheme,
|
||||
break;
|
||||
case ColorID::MozColheader:
|
||||
case ColorID::MozColheaderhover:
|
||||
case ColorID::MozEventreerow:
|
||||
// Background color of even list rows.
|
||||
aColor =
|
||||
GetColorFromNSColor(NSColor.controlAlternatingRowBackgroundColors[0]);
|
||||
|
||||
@@ -779,10 +779,6 @@ static GtkStyleContext* GetCssNodeStyleInternal(WidgetNodeType aNodeType) {
|
||||
case MOZ_GTK_FRAME_BORDER:
|
||||
style = CreateChildCSSNode("border", MOZ_GTK_FRAME);
|
||||
break;
|
||||
case MOZ_GTK_TREEVIEW_VIEW:
|
||||
// TODO - create from CSS node
|
||||
style = CreateSubStyleWithClass(MOZ_GTK_TREEVIEW, GTK_STYLE_CLASS_VIEW);
|
||||
break;
|
||||
case MOZ_GTK_SPLITTER_SEPARATOR_HORIZONTAL:
|
||||
style = CreateChildCSSNode("separator", MOZ_GTK_SPLITTER_HORIZONTAL);
|
||||
break;
|
||||
@@ -870,9 +866,6 @@ static GtkStyleContext* GetWidgetStyleInternal(WidgetNodeType aNodeType) {
|
||||
break;
|
||||
case MOZ_GTK_FRAME_BORDER:
|
||||
return GetWidgetRootStyle(MOZ_GTK_FRAME);
|
||||
case MOZ_GTK_TREEVIEW_VIEW:
|
||||
style = CreateSubStyleWithClass(MOZ_GTK_TREEVIEW, GTK_STYLE_CLASS_VIEW);
|
||||
break;
|
||||
case MOZ_GTK_SPLITTER_SEPARATOR_HORIZONTAL:
|
||||
style = CreateSubStyleWithClass(MOZ_GTK_SPLITTER_HORIZONTAL,
|
||||
GTK_STYLE_CLASS_PANE_SEPARATOR);
|
||||
|
||||
@@ -344,38 +344,6 @@ static gint moz_gtk_vpaned_paint(cairo_t* cr, GdkRectangle* rect,
|
||||
return MOZ_GTK_SUCCESS;
|
||||
}
|
||||
|
||||
static gint moz_gtk_treeview_paint(cairo_t* cr, GdkRectangle* rect,
|
||||
GtkWidgetState* state,
|
||||
GtkTextDirection direction) {
|
||||
gint xthickness, ythickness;
|
||||
GtkStyleContext* style;
|
||||
GtkStyleContext* style_tree;
|
||||
GtkStateFlags state_flags;
|
||||
GtkBorder border;
|
||||
|
||||
/* only handle disabled and normal states, otherwise the whole background
|
||||
* area will be painted differently with other states */
|
||||
state_flags =
|
||||
state->disabled ? GTK_STATE_FLAG_INSENSITIVE : GTK_STATE_FLAG_NORMAL;
|
||||
|
||||
style =
|
||||
GetStyleContext(MOZ_GTK_SCROLLED_WINDOW, state->image_scale, direction);
|
||||
gtk_style_context_get_border(style, state_flags, &border);
|
||||
xthickness = border.left;
|
||||
ythickness = border.top;
|
||||
|
||||
style_tree =
|
||||
GetStyleContext(MOZ_GTK_TREEVIEW_VIEW, state->image_scale, direction);
|
||||
gtk_render_background(style_tree, cr, rect->x + xthickness,
|
||||
rect->y + ythickness, rect->width - 2 * xthickness,
|
||||
rect->height - 2 * ythickness);
|
||||
|
||||
style =
|
||||
GetStyleContext(MOZ_GTK_SCROLLED_WINDOW, state->image_scale, direction);
|
||||
gtk_render_frame(style, cr, rect->x, rect->y, rect->width, rect->height);
|
||||
return MOZ_GTK_SUCCESS;
|
||||
}
|
||||
|
||||
static gint moz_gtk_resizer_paint(cairo_t* cr, GdkRectangle* rect,
|
||||
GtkWidgetState* state,
|
||||
GtkTextDirection direction) {
|
||||
@@ -644,16 +612,10 @@ gint moz_gtk_get_widget_border(WidgetNodeType widget, gint* left, gint* top,
|
||||
// NOTE: callers depend on direction being used
|
||||
// only for MOZ_GTK_DROPDOWN widgets.
|
||||
GtkTextDirection direction) {
|
||||
GtkWidget* w;
|
||||
GtkStyleContext* style;
|
||||
GtkWidget* w = nullptr;
|
||||
*left = *top = *right = *bottom = 0;
|
||||
|
||||
switch (widget) {
|
||||
case MOZ_GTK_TREEVIEW: {
|
||||
style = GetStyleContext(MOZ_GTK_SCROLLED_WINDOW);
|
||||
moz_gtk_add_style_border(style, left, top, right, bottom);
|
||||
return MOZ_GTK_SUCCESS;
|
||||
}
|
||||
case MOZ_GTK_TABPANELS:
|
||||
w = GetWidget(MOZ_GTK_TABPANELS);
|
||||
break;
|
||||
@@ -748,8 +710,6 @@ gint moz_gtk_widget_paint(WidgetNodeType widget, cairo_t* cr,
|
||||
cairo_new_path(cr);
|
||||
|
||||
switch (widget) {
|
||||
case MOZ_GTK_TREEVIEW:
|
||||
return moz_gtk_treeview_paint(cr, rect, state, direction);
|
||||
case MOZ_GTK_FRAME:
|
||||
return moz_gtk_frame_paint(cr, rect, state, direction);
|
||||
case MOZ_GTK_RESIZER:
|
||||
|
||||
@@ -152,8 +152,6 @@ enum WidgetNodeType : int {
|
||||
MOZ_GTK_TABPANELS,
|
||||
/* Paints the expander and border of a GtkTreeView */
|
||||
MOZ_GTK_TREEVIEW,
|
||||
/* Paints the border of a GtkTreeView */
|
||||
MOZ_GTK_TREEVIEW_VIEW,
|
||||
/* Paints treeheader cells */
|
||||
MOZ_GTK_TREE_HEADER_CELL,
|
||||
/* Paints the background of menus, context menus. */
|
||||
|
||||
@@ -880,7 +880,6 @@ nsresult nsLookAndFeel::PerThemeData::GetColor(ColorID aID,
|
||||
aColor = mIsDark ? *GenericDarkColor(aID) : NS_RGB(0xDC, 0xDC, 0xDC);
|
||||
break;
|
||||
|
||||
case ColorID::MozEventreerow:
|
||||
case ColorID::Field:
|
||||
aColor = mField.mBg;
|
||||
break;
|
||||
@@ -914,12 +913,10 @@ nsresult nsLookAndFeel::PerThemeData::GetColor(ColorID aID,
|
||||
case ColorID::MozMenuhovertext:
|
||||
aColor = mMenuHover.mFg;
|
||||
break;
|
||||
case ColorID::MozOddtreerow:
|
||||
case ColorID::MozMenuhoverdisabled:
|
||||
aColor = NS_TRANSPARENT;
|
||||
break;
|
||||
case ColorID::MozOddtreerow:
|
||||
aColor = mOddCellBackground;
|
||||
break;
|
||||
case ColorID::Linktext:
|
||||
aColor = mNativeHyperLinkText;
|
||||
break;
|
||||
@@ -2367,21 +2364,6 @@ void nsLookAndFeel::PerThemeData::Init() {
|
||||
mButtonActive.mBg = mWindow.mBg;
|
||||
}
|
||||
|
||||
// GTK's guide to fancy odd row background colors:
|
||||
// 1) Check if a theme explicitly defines an odd row color
|
||||
// 2) If not, check if it defines an even row color, and darken it
|
||||
// slightly by a hardcoded value (gtkstyle.c)
|
||||
// 3) If neither are defined, take the base background color and
|
||||
// darken that by a hardcoded value
|
||||
style = GetStyleContext(MOZ_GTK_TREEVIEW);
|
||||
|
||||
// Get odd row background color
|
||||
gtk_style_context_save(style);
|
||||
gtk_style_context_add_region(style, GTK_STYLE_REGION_ROW, GTK_REGION_ODD);
|
||||
gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color);
|
||||
mOddCellBackground = GDK_RGBA_TO_NS_RGBA(color);
|
||||
gtk_style_context_restore(style);
|
||||
|
||||
// Column header colors
|
||||
style = GetStyleContext(MOZ_GTK_TREE_HEADER_CELL);
|
||||
mMozColHeader = GetColorPair(style, GTK_STATE_FLAG_NORMAL);
|
||||
|
||||
@@ -137,7 +137,6 @@ class nsLookAndFeel final : public nsXPLookAndFeel {
|
||||
nscolor mButtonBorder = kBlack;
|
||||
nscolor mThreeDHighlight = kBlack;
|
||||
nscolor mThreeDShadow = kBlack;
|
||||
nscolor mOddCellBackground = kWhite;
|
||||
nscolor mNativeHyperLinkText = kBlack;
|
||||
nscolor mNativeVisitedHyperLinkText = kBlack;
|
||||
ColorPair mField;
|
||||
|
||||
@@ -199,9 +199,6 @@ bool nsNativeThemeGTK::GetGtkWidgetAndState(StyleAppearance aAppearance,
|
||||
}
|
||||
|
||||
switch (aAppearance) {
|
||||
case StyleAppearance::Listbox:
|
||||
aGtkWidgetType = MOZ_GTK_TREEVIEW;
|
||||
break;
|
||||
case StyleAppearance::Tabpanels:
|
||||
aGtkWidgetType = MOZ_GTK_TABPANELS;
|
||||
break;
|
||||
@@ -761,6 +758,7 @@ bool nsNativeThemeGTK::IsWidgetAlwaysNonNative(nsIFrame* aFrame,
|
||||
aAppearance == StyleAppearance::Radio ||
|
||||
aAppearance == StyleAppearance::Button ||
|
||||
aAppearance == StyleAppearance::Toolbarbutton ||
|
||||
aAppearance == StyleAppearance::Listbox ||
|
||||
aAppearance == StyleAppearance::Menulist ||
|
||||
aAppearance == StyleAppearance::ProgressBar ||
|
||||
aAppearance == StyleAppearance::Progresschunk ||
|
||||
@@ -824,7 +822,6 @@ nsNativeThemeGTK::ThemeSupportsWidget(nsPresContext* aPresContext,
|
||||
}
|
||||
|
||||
switch (aAppearance) {
|
||||
case StyleAppearance::Listbox:
|
||||
case StyleAppearance::Tab:
|
||||
// case StyleAppearance::Tabpanel:
|
||||
case StyleAppearance::Tabpanels:
|
||||
|
||||
@@ -239,7 +239,6 @@ static const char sColorPrefs[][41] = {
|
||||
"ui.-moz_menuhoverdisabled",
|
||||
"ui.-moz_menuhovertext",
|
||||
"ui.-moz_menubarhovertext",
|
||||
"ui.-moz_eventreerow",
|
||||
"ui.-moz_oddtreerow",
|
||||
"ui.-moz-buttonactivetext",
|
||||
"ui.-moz-buttonactiveface",
|
||||
@@ -703,7 +702,6 @@ nscolor nsXPLookAndFeel::GetStandinForNativeColor(ColorID aID,
|
||||
COLOR(MozMenuhovertext, 0x00, 0x00, 0x00)
|
||||
COLOR(MozMenubarhovertext, 0x00, 0x00, 0x00)
|
||||
COLOR(MozMenuhoverdisabled, 0xF0, 0xF0, 0xF0)
|
||||
COLOR(MozEventreerow, 0xFF, 0xFF, 0xFF)
|
||||
COLOR(MozOddtreerow, 0xFF, 0xFF, 0xFF)
|
||||
COLOR(MozMacFocusring, 0x60, 0x9D, 0xD7)
|
||||
COLOR(MozMacDisabledtoolbartext, 0x3F, 0x3F, 0x3F)
|
||||
@@ -754,7 +752,6 @@ Maybe<nscolor> nsXPLookAndFeel::GenericDarkColor(ColorID aID) {
|
||||
color = NS_RGB(0x3a, 0x39, 0x44);
|
||||
break;
|
||||
|
||||
case ColorID::MozEventreerow:
|
||||
case ColorID::MozOddtreerow:
|
||||
case ColorID::MozDialog: // --background-color-box
|
||||
color = NS_RGB(35, 34, 43);
|
||||
|
||||
@@ -55,7 +55,6 @@ var colors = {
|
||||
"-moz-buttonhovertext": ["rgb(0, 0, 0)"],
|
||||
"-moz-cellhighlight": ["rgb(212, 212, 212)", "rgb(220, 220, 220)"],
|
||||
"-moz-cellhighlighttext": ["rgb(0, 0, 0)"],
|
||||
"-moz-eventreerow": ["rgb(255, 255, 255)"],
|
||||
"-moz-field": ["rgb(255, 255, 255)"],
|
||||
"-moz-fieldtext": ["rgb(0, 0, 0)"],
|
||||
"-moz-dialog": ["rgb(232, 232, 232)"],
|
||||
|
||||
@@ -186,10 +186,6 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, ColorScheme aColorScheme,
|
||||
// For inactive list selection
|
||||
aResult = NS_RGB(0xaa, 0xaa, 0xaa);
|
||||
break;
|
||||
case ColorID::MozEventreerow:
|
||||
// Background color of even list rows.
|
||||
aResult = NS_RGB(0xff, 0xff, 0xff);
|
||||
break;
|
||||
case ColorID::MozOddtreerow:
|
||||
// Background color of odd list rows.
|
||||
aResult = NS_TRANSPARENT;
|
||||
|
||||
@@ -402,7 +402,6 @@ nsresult nsLookAndFeel::NativeGetColor(ColorID aID, ColorScheme aScheme,
|
||||
case ColorID::Fieldtext:
|
||||
idx = mHighContrastOn ? COLOR_BTNTEXT : COLOR_WINDOWTEXT;
|
||||
break;
|
||||
case ColorID::MozEventreerow:
|
||||
case ColorID::MozOddtreerow:
|
||||
case ColorID::MozSidebar:
|
||||
case ColorID::MozCombobox:
|
||||
|
||||
Reference in New Issue
Block a user