[gtk/deprecate-render: 31/36] scrolledwindow: Stop using gtk_style_context_save_to_node




commit 72f735c22597ecd07dd097654ff2e3baea18f6e7
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Oct 8 23:29:43 2022 -0400

    scrolledwindow: Stop using gtk_style_context_save_to_node

 gtk/gtkscrolledwindow.c | 69 +++++++++++++++----------------------------------
 1 file changed, 21 insertions(+), 48 deletions(-)
---
diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c
index b61068cbb4..8155e7676d 100644
--- a/gtk/gtkscrolledwindow.c
+++ b/gtk/gtkscrolledwindow.c
@@ -50,7 +50,6 @@
 #include "gtksnapshot.h"
 #include "gtkrenderbackgroundprivate.h"
 #include "gtkrenderborderprivate.h"
-#include "gtkstylecontextprivate.h"
 #include "gtktypebuiltins.h"
 #include "gtkviewport.h"
 #include "gtkwidgetprivate.h"
@@ -1871,9 +1870,8 @@ gtk_scrolled_window_snapshot_scrollbars_junction (GtkScrolledWindow *scrolled_wi
                                                   GtkSnapshot       *snapshot)
 {
   GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
-  GtkWidget *widget = GTK_WIDGET (scrolled_window);
   GtkAllocation hscr_allocation, vscr_allocation;
-  GtkStyleContext *context;
+  GtkCssStyle *style;
   GdkRectangle junction_rect;
   GtkCssBoxes boxes;
 
@@ -1885,17 +1883,13 @@ gtk_scrolled_window_snapshot_scrollbars_junction (GtkScrolledWindow *scrolled_wi
   junction_rect.width = vscr_allocation.width;
   junction_rect.height = hscr_allocation.height;
 
-  context = gtk_widget_get_style_context (widget);
-  gtk_style_context_save_to_node (context, priv->junction_node);
+  style = gtk_css_node_get_style (priv->junction_node);
 
-  gtk_css_boxes_init_border_box (&boxes,
-                                 gtk_style_context_lookup_style (context),
+  gtk_css_boxes_init_border_box (&boxes, style,
                                  junction_rect.x, junction_rect.y,
                                  junction_rect.width, junction_rect.height);
   gtk_css_style_snapshot_background (&boxes, snapshot);
   gtk_css_style_snapshot_border (&boxes, snapshot);
-
-  gtk_style_context_restore (context);
 }
 
 static void
@@ -1903,16 +1897,14 @@ gtk_scrolled_window_snapshot_overshoot (GtkScrolledWindow *scrolled_window,
                                         GtkSnapshot       *snapshot)
 {
   GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
-  GtkWidget *widget = GTK_WIDGET (scrolled_window);
   int overshoot_x, overshoot_y;
-  GtkStyleContext *context;
+  GtkCssStyle *style;
   GdkRectangle rect;
   GtkCssBoxes boxes;
 
   if (!_gtk_scrolled_window_get_overshoot (scrolled_window, &overshoot_x, &overshoot_y))
     return;
 
-  context = gtk_widget_get_style_context (widget);
   gtk_scrolled_window_inner_allocation (scrolled_window, &rect);
 
   overshoot_x = CLAMP (overshoot_x, - MAX_OVERSHOOT_DISTANCE, MAX_OVERSHOOT_DISTANCE);
@@ -1920,46 +1912,37 @@ gtk_scrolled_window_snapshot_overshoot (GtkScrolledWindow *scrolled_window,
 
   if (overshoot_x > 0)
     {
-      gtk_style_context_save_to_node (context, priv->overshoot_node[GTK_POS_RIGHT]);
-      gtk_css_boxes_init_border_box (&boxes,
-                                     gtk_style_context_lookup_style (context),
+      style = gtk_css_node_get_style (priv->overshoot_node[GTK_POS_RIGHT]);
+      gtk_css_boxes_init_border_box (&boxes, style,
                                      rect.x + rect.width - overshoot_x, rect.y, overshoot_x, rect.height);
       gtk_css_style_snapshot_background (&boxes, snapshot);
       gtk_css_style_snapshot_border (&boxes, snapshot);
-      gtk_style_context_restore (context);
     }
   else if (overshoot_x < 0)
     {
-      gtk_style_context_save_to_node (context, priv->overshoot_node[GTK_POS_LEFT]);
-      gtk_css_boxes_init_border_box (&boxes,
-                                     gtk_style_context_lookup_style (context),
+      style = gtk_css_node_get_style (priv->overshoot_node[GTK_POS_LEFT]);
+      gtk_css_boxes_init_border_box (&boxes, style,
                                      rect.x, rect.y, -overshoot_x, rect.height);
       gtk_css_style_snapshot_background (&boxes, snapshot);
       gtk_css_style_snapshot_border (&boxes, snapshot);
-      gtk_style_context_restore (context);
     }
 
   if (overshoot_y > 0)
     {
-      gtk_style_context_save_to_node (context, priv->overshoot_node[GTK_POS_BOTTOM]);
-      gtk_css_boxes_init_border_box (&boxes,
-                                     gtk_style_context_lookup_style (context),
+      style = gtk_css_node_get_style (priv->overshoot_node[GTK_POS_BOTTOM]);
+      gtk_css_boxes_init_border_box (&boxes, style,
                                      rect.x, rect.y + rect.height - overshoot_y, rect.width, overshoot_y);
       gtk_css_style_snapshot_background (&boxes, snapshot);
       gtk_css_style_snapshot_border (&boxes, snapshot);
-      gtk_style_context_restore (context);
     }
   else if (overshoot_y < 0)
     {
-      gtk_style_context_save_to_node (context, priv->overshoot_node[GTK_POS_TOP]);
-      gtk_css_boxes_init_border_box (&boxes,
-                                     gtk_style_context_lookup_style (context),
+      style = gtk_css_node_get_style (priv->overshoot_node[GTK_POS_TOP]);
+      gtk_css_boxes_init_border_box (&boxes, style,
                                      rect.x, rect.y, rect.width, -overshoot_y);
       gtk_css_style_snapshot_background (&boxes, snapshot);
       gtk_css_style_snapshot_border (&boxes, snapshot);
-      gtk_style_context_restore (context);
     }
-G_GNUC_END_IGNORE_DEPRECATIONS
 }
 
 static void
@@ -1967,57 +1950,47 @@ gtk_scrolled_window_snapshot_undershoot (GtkScrolledWindow *scrolled_window,
                                          GtkSnapshot       *snapshot)
 {
   GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window);
-  GtkWidget *widget = GTK_WIDGET (scrolled_window);
-  GtkStyleContext *context;
+  GtkCssStyle *style;
   GdkRectangle rect;
   GtkAdjustment *adj;
   GtkCssBoxes boxes;
 
-  context = gtk_widget_get_style_context (widget);
   gtk_scrolled_window_inner_allocation (scrolled_window, &rect);
 
   adj = gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (priv->hscrollbar));
   if (gtk_adjustment_get_value (adj) < gtk_adjustment_get_upper (adj) - gtk_adjustment_get_page_size (adj))
     {
-      gtk_style_context_save_to_node (context, priv->undershoot_node[GTK_POS_RIGHT]);
-      gtk_css_boxes_init_border_box (&boxes,
-                                     gtk_style_context_lookup_style (context),
+      style = gtk_css_node_get_style (priv->undershoot_node[GTK_POS_RIGHT]);
+      gtk_css_boxes_init_border_box (&boxes, style,
                                      rect.x + rect.width - UNDERSHOOT_SIZE, rect.y, UNDERSHOOT_SIZE, 
rect.height);
       gtk_css_style_snapshot_background (&boxes, snapshot);
       gtk_css_style_snapshot_border (&boxes, snapshot);
-      gtk_style_context_restore (context);
     }
   if (gtk_adjustment_get_value (adj) > gtk_adjustment_get_lower (adj))
     {
-      gtk_style_context_save_to_node (context, priv->undershoot_node[GTK_POS_LEFT]);
-      gtk_css_boxes_init_border_box (&boxes,
-                                     gtk_style_context_lookup_style (context),
+      style = gtk_css_node_get_style (priv->undershoot_node[GTK_POS_LEFT]);
+      gtk_css_boxes_init_border_box (&boxes, style,
                                      rect.x, rect.y, UNDERSHOOT_SIZE, rect.height);
       gtk_css_style_snapshot_background (&boxes, snapshot);
       gtk_css_style_snapshot_border (&boxes, snapshot);
-      gtk_style_context_restore (context);
     }
 
   adj = gtk_scrollbar_get_adjustment (GTK_SCROLLBAR (priv->vscrollbar));
   if (gtk_adjustment_get_value (adj) < gtk_adjustment_get_upper (adj) - gtk_adjustment_get_page_size (adj))
     {
-      gtk_style_context_save_to_node (context, priv->undershoot_node[GTK_POS_BOTTOM]);
-      gtk_css_boxes_init_border_box (&boxes,
-                                     gtk_style_context_lookup_style (context),
+      style = gtk_css_node_get_style (priv->undershoot_node[GTK_POS_BOTTOM]);
+      gtk_css_boxes_init_border_box (&boxes, style,
                                      rect.x, rect.y + rect.height - UNDERSHOOT_SIZE, rect.width, 
UNDERSHOOT_SIZE);
       gtk_css_style_snapshot_background (&boxes, snapshot);
       gtk_css_style_snapshot_border (&boxes, snapshot);
-      gtk_style_context_restore (context);
     }
   if (gtk_adjustment_get_value (adj) > gtk_adjustment_get_lower (adj))
     {
-      gtk_style_context_save_to_node (context, priv->undershoot_node[GTK_POS_TOP]);
-      gtk_css_boxes_init_border_box (&boxes,
-                                     gtk_style_context_lookup_style (context),
+      style = gtk_css_node_get_style (priv->undershoot_node[GTK_POS_TOP]);
+      gtk_css_boxes_init_border_box (&boxes, style,
                                      rect.x, rect.y, rect.width, UNDERSHOOT_SIZE);
       gtk_css_style_snapshot_background (&boxes, snapshot);
       gtk_css_style_snapshot_border (&boxes, snapshot);
-      gtk_style_context_restore (context);
     }
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]