mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-27 01:27:30 +09:00
[GTK3] Introduce MOZ_GTK_TEXT_VIEW_TEXT and move MOZ_GTK_RESIZER to WidgetStyleCache
The style context for MOZ_GTK_TEXT_VIEW is now created by copying from the widget instead of caching a widget and using its context. No rendering changes are expected, unless themes are animating GtkTextView backgrounds.
This commit is contained in:
parent
f0e2977c10
commit
3951327f27
4 changed files with 49 additions and 32 deletions
|
|
@ -433,15 +433,6 @@ CreateScrolledWindowWidget()
|
||||||
return widget;
|
return widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GtkWidget*
|
|
||||||
CreateTextViewWidget()
|
|
||||||
{
|
|
||||||
GtkWidget* widget = gtk_text_view_new();
|
|
||||||
gtk_container_add(GTK_CONTAINER(GetWidget(MOZ_GTK_SCROLLED_WINDOW)),
|
|
||||||
widget);
|
|
||||||
return widget;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GtkWidget*
|
static GtkWidget*
|
||||||
CreateMenuSeparatorWidget()
|
CreateMenuSeparatorWidget()
|
||||||
{
|
{
|
||||||
|
|
@ -591,8 +582,6 @@ CreateWidget(WidgetNodeType aWidgetType)
|
||||||
return CreateEntryWidget();
|
return CreateEntryWidget();
|
||||||
case MOZ_GTK_SCROLLED_WINDOW:
|
case MOZ_GTK_SCROLLED_WINDOW:
|
||||||
return CreateScrolledWindowWidget();
|
return CreateScrolledWindowWidget();
|
||||||
case MOZ_GTK_TEXT_VIEW:
|
|
||||||
return CreateTextViewWidget();
|
|
||||||
case MOZ_GTK_TREEVIEW:
|
case MOZ_GTK_TREEVIEW:
|
||||||
return CreateTreeViewWidget();
|
return CreateTreeViewWidget();
|
||||||
case MOZ_GTK_TREE_HEADER_CELL:
|
case MOZ_GTK_TREE_HEADER_CELL:
|
||||||
|
|
@ -754,6 +743,10 @@ GetWidgetRootStyle(WidgetNodeType aNodeType)
|
||||||
style = CreateStyleForWidget(gtk_radio_menu_item_new(nullptr),
|
style = CreateStyleForWidget(gtk_radio_menu_item_new(nullptr),
|
||||||
MOZ_GTK_MENUPOPUP);
|
MOZ_GTK_MENUPOPUP);
|
||||||
break;
|
break;
|
||||||
|
case MOZ_GTK_TEXT_VIEW:
|
||||||
|
style = CreateStyleForWidget(gtk_text_view_new(),
|
||||||
|
MOZ_GTK_SCROLLED_WINDOW);
|
||||||
|
break;
|
||||||
case MOZ_GTK_TOOLTIP:
|
case MOZ_GTK_TOOLTIP:
|
||||||
if (gtk_check_version(3, 20, 0) != nullptr) {
|
if (gtk_check_version(3, 20, 0) != nullptr) {
|
||||||
// The tooltip style class is added first in CreateTooltipWidget()
|
// The tooltip style class is added first in CreateTooltipWidget()
|
||||||
|
|
@ -881,10 +874,21 @@ GetCssNodeStyleInternal(WidgetNodeType aNodeType)
|
||||||
// TODO - create from CSS node
|
// TODO - create from CSS node
|
||||||
return GetWidgetStyleWithClass(MOZ_GTK_SCROLLED_WINDOW,
|
return GetWidgetStyleWithClass(MOZ_GTK_SCROLLED_WINDOW,
|
||||||
GTK_STYLE_CLASS_FRAME);
|
GTK_STYLE_CLASS_FRAME);
|
||||||
case MOZ_GTK_TEXT_VIEW:
|
case MOZ_GTK_TEXT_VIEW_TEXT:
|
||||||
|
case MOZ_GTK_RESIZER:
|
||||||
// TODO - create from CSS node
|
// TODO - create from CSS node
|
||||||
return GetWidgetStyleWithClass(MOZ_GTK_TEXT_VIEW,
|
style = GetWidgetStyleWithClass(MOZ_GTK_TEXT_VIEW, GTK_STYLE_CLASS_VIEW);
|
||||||
GTK_STYLE_CLASS_VIEW);
|
if (aNodeType == MOZ_GTK_RESIZER) {
|
||||||
|
// The "grip" class provides the correct builtin icon from
|
||||||
|
// gtk_render_handle(). The icon is drawn with shaded variants of
|
||||||
|
// the background color, and so a transparent background would lead to
|
||||||
|
// a transparent resizer. gtk_render_handle() also uses the
|
||||||
|
// background color to draw a background, and so this style otherwise
|
||||||
|
// matches MOZ_GTK_TEXT_VIEW_TEXT to match the background with
|
||||||
|
// textarea elements.
|
||||||
|
gtk_style_context_add_class(style, GTK_STYLE_CLASS_GRIP);
|
||||||
|
}
|
||||||
|
return style;
|
||||||
case MOZ_GTK_FRAME_BORDER:
|
case MOZ_GTK_FRAME_BORDER:
|
||||||
style = CreateChildCSSNode("border", MOZ_GTK_FRAME);
|
style = CreateChildCSSNode("border", MOZ_GTK_FRAME);
|
||||||
break;
|
break;
|
||||||
|
|
@ -1008,9 +1012,25 @@ GetWidgetStyleInternal(WidgetNodeType aNodeType)
|
||||||
case MOZ_GTK_SCROLLED_WINDOW:
|
case MOZ_GTK_SCROLLED_WINDOW:
|
||||||
return GetWidgetStyleWithClass(MOZ_GTK_SCROLLED_WINDOW,
|
return GetWidgetStyleWithClass(MOZ_GTK_SCROLLED_WINDOW,
|
||||||
GTK_STYLE_CLASS_FRAME);
|
GTK_STYLE_CLASS_FRAME);
|
||||||
case MOZ_GTK_TEXT_VIEW:
|
case MOZ_GTK_TEXT_VIEW_TEXT:
|
||||||
return GetWidgetStyleWithClass(MOZ_GTK_TEXT_VIEW,
|
case MOZ_GTK_RESIZER: {
|
||||||
GTK_STYLE_CLASS_VIEW);
|
// GTK versions prior to 3.20 do not have the view class on the root
|
||||||
|
// node, but add this to determine the background for the text window.
|
||||||
|
GtkStyleContext* style =
|
||||||
|
GetWidgetStyleWithClass(MOZ_GTK_TEXT_VIEW, GTK_STYLE_CLASS_VIEW);
|
||||||
|
if (aNodeType == MOZ_GTK_RESIZER) {
|
||||||
|
// The "grip" class provides the correct builtin icon from
|
||||||
|
// gtk_render_handle(). The icon is drawn with shaded variants of
|
||||||
|
// the background color, and so a transparent background would lead to
|
||||||
|
// a transparent resizer. gtk_render_handle() also uses the
|
||||||
|
// background color to draw a background, and so this style otherwise
|
||||||
|
// matches MOZ_GTK_TEXT_VIEW_TEXT to match the background with
|
||||||
|
// textarea elements. GtkTextView creates a separate text window and
|
||||||
|
// so the background should not be transparent.
|
||||||
|
gtk_style_context_add_class(style, GTK_STYLE_CLASS_GRIP);
|
||||||
|
}
|
||||||
|
return style;
|
||||||
|
}
|
||||||
case MOZ_GTK_FRAME_BORDER:
|
case MOZ_GTK_FRAME_BORDER:
|
||||||
return GetWidgetRootStyle(MOZ_GTK_FRAME);
|
return GetWidgetRootStyle(MOZ_GTK_FRAME);
|
||||||
case MOZ_GTK_TREEVIEW_VIEW:
|
case MOZ_GTK_TREEVIEW_VIEW:
|
||||||
|
|
|
||||||
|
|
@ -897,8 +897,10 @@ moz_gtk_text_view_paint(cairo_t *cr, GdkRectangle* rect,
|
||||||
gtk_style_context_get_padding(style_frame, state_flags, &padding);
|
gtk_style_context_get_padding(style_frame, state_flags, &padding);
|
||||||
ReleaseStyleContext(style_frame);
|
ReleaseStyleContext(style_frame);
|
||||||
|
|
||||||
|
// There is a separate "text" window, which provides the background behind
|
||||||
|
// the text.
|
||||||
GtkStyleContext* style =
|
GtkStyleContext* style =
|
||||||
ClaimStyleContext(MOZ_GTK_TEXT_VIEW, direction, state_flags);
|
ClaimStyleContext(MOZ_GTK_TEXT_VIEW_TEXT, direction, state_flags);
|
||||||
|
|
||||||
gint xthickness = border.left + padding.left;
|
gint xthickness = border.left + padding.left;
|
||||||
gint ythickness = border.top + padding.top;
|
gint ythickness = border.top + padding.top;
|
||||||
|
|
@ -1337,17 +1339,9 @@ moz_gtk_resizer_paint(cairo_t *cr, GdkRectangle* rect,
|
||||||
GtkWidgetState* state,
|
GtkWidgetState* state,
|
||||||
GtkTextDirection direction)
|
GtkTextDirection direction)
|
||||||
{
|
{
|
||||||
GtkStyleContext* style;
|
GtkStyleContext* style =
|
||||||
|
ClaimStyleContext(MOZ_GTK_RESIZER, GTK_TEXT_DIR_LTR,
|
||||||
// gtk_render_handle() draws a background, so use GtkTextView and its
|
GetStateFlagsFromGtkWidgetState(state));
|
||||||
// GTK_STYLE_CLASS_VIEW to match the background with textarea elements.
|
|
||||||
// The resizer is drawn with shaded variants of the background color, and
|
|
||||||
// so a transparent background would lead to a transparent resizer.
|
|
||||||
style = ClaimStyleContext(MOZ_GTK_TEXT_VIEW, GTK_TEXT_DIR_LTR,
|
|
||||||
GetStateFlagsFromGtkWidgetState(state));
|
|
||||||
// TODO - we need to save/restore style when gtk 3.20 CSS node path
|
|
||||||
// is used
|
|
||||||
gtk_style_context_add_class(style, GTK_STYLE_CLASS_GRIP);
|
|
||||||
|
|
||||||
// Workaround unico not respecting the text direction for resizers.
|
// Workaround unico not respecting the text direction for resizers.
|
||||||
// See bug 1174248.
|
// See bug 1174248.
|
||||||
|
|
|
||||||
|
|
@ -145,8 +145,11 @@ typedef enum {
|
||||||
MOZ_GTK_ENTRY,
|
MOZ_GTK_ENTRY,
|
||||||
/* Paints a GtkExpander. */
|
/* Paints a GtkExpander. */
|
||||||
MOZ_GTK_EXPANDER,
|
MOZ_GTK_EXPANDER,
|
||||||
/* Paints a GtkTextView. */
|
/* Paints a GtkTextView or gets the style context corresponding to the
|
||||||
|
root node of a GtkTextView. */
|
||||||
MOZ_GTK_TEXT_VIEW,
|
MOZ_GTK_TEXT_VIEW,
|
||||||
|
/* The "text" window or node of a GtkTextView */
|
||||||
|
MOZ_GTK_TEXT_VIEW_TEXT,
|
||||||
/* Paints a GtkOptionMenu. */
|
/* Paints a GtkOptionMenu. */
|
||||||
MOZ_GTK_DROPDOWN,
|
MOZ_GTK_DROPDOWN,
|
||||||
/* Paints a dropdown arrow (a GtkButton containing a down GtkArrow). */
|
/* Paints a dropdown arrow (a GtkButton containing a down GtkArrow). */
|
||||||
|
|
@ -168,7 +171,7 @@ typedef enum {
|
||||||
MOZ_GTK_FRAME,
|
MOZ_GTK_FRAME,
|
||||||
/* Paints the border of a GtkFrame */
|
/* Paints the border of a GtkFrame */
|
||||||
MOZ_GTK_FRAME_BORDER,
|
MOZ_GTK_FRAME_BORDER,
|
||||||
/* Paints a resize grip for a GtkWindow */
|
/* Paints a resize grip for a GtkTextView */
|
||||||
MOZ_GTK_RESIZER,
|
MOZ_GTK_RESIZER,
|
||||||
/* Paints a GtkProgressBar. */
|
/* Paints a GtkProgressBar. */
|
||||||
MOZ_GTK_PROGRESSBAR,
|
MOZ_GTK_PROGRESSBAR,
|
||||||
|
|
|
||||||
|
|
@ -1291,7 +1291,7 @@ nsLookAndFeel::Init()
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
// Text colors
|
// Text colors
|
||||||
style = ClaimStyleContext(MOZ_GTK_TEXT_VIEW);
|
style = ClaimStyleContext(MOZ_GTK_TEXT_VIEW_TEXT);
|
||||||
gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color);
|
gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &color);
|
||||||
sMozFieldBackground = GDK_RGBA_TO_NS_RGBA(color);
|
sMozFieldBackground = GDK_RGBA_TO_NS_RGBA(color);
|
||||||
gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
|
gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &color);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue