Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 84c6a1a8cf | |||
| 57f3598b71 | |||
| 422fc3dda4 |
@@ -1,59 +1,6 @@
|
||||
Overview of Changes in 4.15.1, xx-xx-xxxx
|
||||
=========================================
|
||||
|
||||
* GtkGraphicsOffload:
|
||||
- Don't crash without a child
|
||||
|
||||
* CSS:
|
||||
- Support the :root selector
|
||||
- Support variables and custom properties
|
||||
|
||||
* Icontheme:
|
||||
- Make symbolic svg loading more efficient
|
||||
- Handle color-free symbolics more efficiently
|
||||
|
||||
* Accessibility:
|
||||
- Make the gtk-demo sidebar search more accessible
|
||||
- Stop emitting focus events
|
||||
- Realize child contexts when necessary
|
||||
|
||||
* GDK:
|
||||
- Support XDG_ACTIVATION_TOKEN
|
||||
- dmabuf: Be more defensive when importing unknown formats to GL
|
||||
- dmabuf: Use narrow range for YUV
|
||||
- vulkan: Recreate swapchains when necessary or beneficial
|
||||
|
||||
* GSK:
|
||||
- Improve logging for GDK_DEBUG=offload
|
||||
- Improve logging for GSK_DEBUG=renderer
|
||||
- gpu: Warn about inefficient texture import
|
||||
- gpu: Handle tiny offscreens correctly
|
||||
- vulkan: Add profiler marks in various places
|
||||
- vulkan: Fix a problem with imported dmabufs showing up black
|
||||
- cairo: Speed up mask nodes, since we use them for symbolic icons
|
||||
|
||||
* Wayland:
|
||||
- Use wl_compositor version 6
|
||||
|
||||
* X11:
|
||||
- Implement a missing method
|
||||
|
||||
* Build:
|
||||
- Fix many ubsan warnings
|
||||
|
||||
* Debugging:
|
||||
- Show more texture details in the recorder
|
||||
|
||||
* macOS:
|
||||
- Fix problems with events handed back to the OS
|
||||
- Respect GDK_DEBUG=default-settings
|
||||
|
||||
* Translation updates:
|
||||
Korean
|
||||
Portuguese
|
||||
Turkish
|
||||
|
||||
|
||||
Overview of Changes in 4.15.0, 21-04-2024
|
||||
=========================================
|
||||
|
||||
|
||||
@@ -363,9 +363,7 @@ insert_markup_idle (gpointer data)
|
||||
|
||||
if (g_get_monotonic_time () - begin > G_TIME_SPAN_MILLISECOND)
|
||||
{
|
||||
guint id;
|
||||
id = g_idle_add (insert_markup_idle, data);
|
||||
g_source_set_name_by_id (id, "[gtk-demo] insert_markup_idle");
|
||||
g_idle_add (insert_markup_idle, data);
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
@@ -400,9 +398,7 @@ parse_markup_idle (gpointer data)
|
||||
do {
|
||||
if (g_get_monotonic_time () - begin > G_TIME_SPAN_MILLISECOND)
|
||||
{
|
||||
guint id;
|
||||
id = g_idle_add (parse_markup_idle, data);
|
||||
g_source_set_name_by_id (id, "[gtk-demo] parse_markup_idle");
|
||||
g_idle_add (parse_markup_idle, data);
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ get_win32_all_locales_scripts (LPWSTR locale_w, DWORD flags, LPARAM param)
|
||||
{
|
||||
wchar_t *langname_w = NULL;
|
||||
wchar_t locale_abbrev_w[9];
|
||||
gchar *langname, *locale_abbrev, *locale;
|
||||
gchar *langname, *locale_abbrev, *locale, *p;
|
||||
gint i;
|
||||
const LCTYPE iso639_lctypes[] = { LOCALE_SISO639LANGNAME, LOCALE_SISO639LANGNAME2 };
|
||||
GHashTable *ht_scripts_langs = (GHashTable *) param;
|
||||
@@ -59,6 +59,7 @@ get_win32_all_locales_scripts (LPWSTR locale_w, DWORD flags, LPARAM param)
|
||||
GetLocaleInfoEx (locale_w, LOCALE_SLOCALIZEDDISPLAYNAME, langname_w, langname_size);
|
||||
langname = g_utf16_to_utf8 (langname_w, -1, NULL, NULL, NULL);
|
||||
locale = g_utf16_to_utf8 (locale_w, -1, NULL, NULL, NULL);
|
||||
p = strchr (locale, '-');
|
||||
lang = pango_language_from_string (locale);
|
||||
if (g_hash_table_lookup (ht_scripts_langs, lang) == NULL)
|
||||
g_hash_table_insert (ht_scripts_langs, lang, langname);
|
||||
|
||||
@@ -330,7 +330,6 @@ stroke bounds of the path.
|
||||
| offset | `<point>` | 0 0 | non-default |
|
||||
| hint-style | `<hint style>` | slight | non-default |
|
||||
| antialias | `<antialias>` | gray | non-default |
|
||||
| hint-metrics | `<hint metrics>` | off | non-default |
|
||||
|
||||
Creates a node like `gsk_text_node_new()` with the given properties.
|
||||
|
||||
@@ -347,7 +346,6 @@ font, an error node will be returned.
|
||||
|
||||
Possible values for hint-style are none, slight or full.
|
||||
Possible value for antialias are none or gray.
|
||||
Possible value for hint-metrics are on or off.
|
||||
|
||||
### texture
|
||||
|
||||
|
||||
@@ -56,30 +56,6 @@ follows:
|
||||
1 value:
|
||||
: all
|
||||
|
||||
## Custom Properties
|
||||
|
||||
GTK supports custom properties as defined in the
|
||||
[CSS Custom Properties for Cascading Variables](https://www.w3.org/TR/css-variables-1)
|
||||
spec.
|
||||
|
||||
Custom properties are defined as follows:
|
||||
|
||||
```css
|
||||
--prop: red;
|
||||
```
|
||||
|
||||
and used via the `var` keyword:
|
||||
|
||||
```css
|
||||
color: var(--prop);
|
||||
```
|
||||
|
||||
Custom properties can have a fallback for when the referred property is invalid:
|
||||
|
||||
```css
|
||||
color: var(--prop, green);
|
||||
```
|
||||
|
||||
## Colors
|
||||
|
||||
GTK extends the CSS syntax with several additional ways to specify colors.
|
||||
|
||||
@@ -155,7 +155,6 @@ Each property name is part of the `GtkAccessibleProperty` enumeration.
|
||||
| %GTK_ACCESSIBLE_PROPERTY_VALUE_MIN | “aria-valuemin” | double |
|
||||
| %GTK_ACCESSIBLE_PROPERTY_VALUE_NOW | “aria-valuenow” | double |
|
||||
| %GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT | “aria-valuetext” | translatable string |
|
||||
| %GTK_ACCESSIBLE_PROPERTY_HELP_TEXT | N/A | translatable string |
|
||||
|
||||
#### List of accessible relations
|
||||
|
||||
@@ -217,10 +216,6 @@ are accessible as part of the development process. The GTK Inspector shows
|
||||
the accessible attributes of each widget, and also provides an overlay that
|
||||
can highlight accessibility issues.
|
||||
|
||||
If you support some non-standard keyboard interactions for a widget, you
|
||||
**should** set an appropriate `GTK_ACCESSIBLE_PROPERTY_HELP_TEXT` to help
|
||||
discoverability of the behavior.
|
||||
|
||||
It is possible to set accessible attributes in UI files as well:
|
||||
```xml
|
||||
<object class="GtkButton" id="button1">
|
||||
|
||||
+8
-16
@@ -41,10 +41,8 @@ G_BEGIN_DECLS
|
||||
|
||||
#ifdef GDK_ARRAY_NULL_TERMINATED
|
||||
#define GDK_ARRAY_REAL_SIZE(_size) ((_size) + 1)
|
||||
#define GDK_ARRAY_MAX_SIZE (G_MAXSIZE / sizeof (_T_) - 1)
|
||||
#else
|
||||
#define GDK_ARRAY_REAL_SIZE(_size) (_size)
|
||||
#define GDK_ARRAY_MAX_SIZE (G_MAXSIZE / sizeof (_T_))
|
||||
#endif
|
||||
|
||||
/* make this readable */
|
||||
@@ -179,23 +177,18 @@ G_GNUC_UNUSED static inline void
|
||||
gdk_array(reserve) (GdkArray *self,
|
||||
gsize n)
|
||||
{
|
||||
gsize new_capacity, size, capacity;
|
||||
gsize new_size, size;
|
||||
|
||||
if (G_UNLIKELY (n > GDK_ARRAY_MAX_SIZE))
|
||||
g_error ("requesting array size of %zu, but maximum size is %zu", n, GDK_ARRAY_MAX_SIZE);
|
||||
|
||||
capacity = gdk_array(get_capacity) (self);
|
||||
if (n <= capacity)
|
||||
return;
|
||||
if (n <= gdk_array(get_capacity) (self))
|
||||
return;
|
||||
|
||||
size = gdk_array(get_size) (self);
|
||||
/* capacity * 2 can overflow, that's why we MAX() */
|
||||
new_capacity = MAX (GDK_ARRAY_REAL_SIZE (n), capacity * 2);
|
||||
new_size = ((gsize) 1) << g_bit_storage (MAX (GDK_ARRAY_REAL_SIZE (n), 16) - 1);
|
||||
|
||||
#ifdef GDK_ARRAY_PREALLOC
|
||||
if (self->start == self->preallocated)
|
||||
{
|
||||
self->start = g_new (_T_, new_capacity);
|
||||
self->start = g_new (_T_, new_size);
|
||||
memcpy (self->start, self->preallocated, sizeof (_T_) * GDK_ARRAY_REAL_SIZE (size));
|
||||
}
|
||||
else
|
||||
@@ -203,15 +196,15 @@ gdk_array(reserve) (GdkArray *self,
|
||||
#ifdef GDK_ARRAY_NULL_TERMINATED
|
||||
if (self->start == NULL)
|
||||
{
|
||||
self->start = g_new (_T_, new_capacity);
|
||||
self->start = g_new (_T_, new_size);
|
||||
*self->start = *(_T_[1]) { 0 };
|
||||
}
|
||||
else
|
||||
#endif
|
||||
self->start = g_renew (_T_, self->start, new_capacity);
|
||||
self->start = g_renew (_T_, self->start, new_size);
|
||||
|
||||
self->end = self->start + size;
|
||||
self->end_allocation = self->start + new_capacity;
|
||||
self->end_allocation = self->start + new_size;
|
||||
#ifdef GDK_ARRAY_NULL_TERMINATED
|
||||
self->end_allocation--;
|
||||
#endif
|
||||
@@ -319,7 +312,6 @@ gdk_array(get) (const GdkArray *self,
|
||||
#undef gdk_array_paste
|
||||
#undef gdk_array
|
||||
#undef GDK_ARRAY_REAL_SIZE
|
||||
#undef GDK_ARRAY_MAX_SIZE
|
||||
|
||||
#undef GDK_ARRAY_BY_VALUE
|
||||
#undef GDK_ARRAY_ELEMENT_TYPE
|
||||
|
||||
+1
-6
@@ -163,8 +163,6 @@ gdk_dmabuf_get_egl_downloader (GdkDisplay *display,
|
||||
return NULL;
|
||||
|
||||
previous = gdk_gl_context_get_current ();
|
||||
if (previous)
|
||||
g_object_ref (previous);
|
||||
formats = gdk_dmabuf_formats_builder_new ();
|
||||
external = gdk_dmabuf_formats_builder_new ();
|
||||
|
||||
@@ -196,10 +194,7 @@ gdk_dmabuf_get_egl_downloader (GdkDisplay *display,
|
||||
}
|
||||
|
||||
if (previous)
|
||||
{
|
||||
gdk_gl_context_make_current (previous);
|
||||
g_object_unref (previous);
|
||||
}
|
||||
gdk_gl_context_make_current (previous);
|
||||
|
||||
return GDK_DMABUF_DOWNLOADER (renderer);
|
||||
}
|
||||
|
||||
@@ -192,6 +192,13 @@ compute_smooth_frame_time (GdkFrameClock *clock,
|
||||
* and new_frame_time >= old_frame_time. */
|
||||
frames_passed = (new_frame_time - smoothed_frame_time_base + frame_interval / 2) / frame_interval;
|
||||
|
||||
if (frames_passed > 1)
|
||||
gdk_profiler_add_markf ((smoothed_frame_time_base - (frame_interval * (frames_passed-1))) * 1000L,
|
||||
frame_interval * (frames_passed-1) * 1000L,
|
||||
"Dropped Frames",
|
||||
"%u frames may have been dropped",
|
||||
frames_passed-1);
|
||||
|
||||
/* We use an approximately whole number of frames in the future from
|
||||
* last smoothed frame time. This way we avoid minor jitter in the
|
||||
* frame times making the animation speed uneven, but still animate
|
||||
|
||||
@@ -1956,6 +1956,8 @@ gdk_gl_context_get_glsl_version_string (GdkGLContext *self)
|
||||
return "#version 310 es";
|
||||
else if (gdk_gl_version_greater_equal (&priv->gl_version, &GDK_GL_VERSION_INIT (3, 0)))
|
||||
return "#version 300 es";
|
||||
else if (gdk_gl_version_greater_equal (&priv->gl_version, &GDK_GL_VERSION_INIT (3, 0)))
|
||||
return "#version 300 es";
|
||||
else
|
||||
return "#version 100";
|
||||
}
|
||||
|
||||
+19
-27
@@ -607,8 +607,7 @@ physical_device_check_features (VkPhysicalDevice device)
|
||||
features |= GDK_VULKAN_FEATURE_YCBCR;
|
||||
|
||||
if (physical_device_supports_extension (device, VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME) &&
|
||||
physical_device_supports_extension (device, VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME) &&
|
||||
physical_device_supports_extension (device, VK_EXT_EXTERNAL_MEMORY_DMA_BUF_EXTENSION_NAME))
|
||||
physical_device_supports_extension (device, VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME))
|
||||
features |= GDK_VULKAN_FEATURE_DMABUF;
|
||||
|
||||
if (physical_device_supports_extension (device, VK_KHR_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME))
|
||||
@@ -633,7 +632,6 @@ gdk_vulkan_context_begin_frame (GdkDrawContext *draw_context,
|
||||
{
|
||||
GdkVulkanContext *context = GDK_VULKAN_CONTEXT (draw_context);
|
||||
GdkVulkanContextPrivate *priv = gdk_vulkan_context_get_instance_private (context);
|
||||
VkResult acquire_result;
|
||||
guint i;
|
||||
|
||||
if (depth != priv->current_format)
|
||||
@@ -655,29 +653,12 @@ gdk_vulkan_context_begin_frame (GdkDrawContext *draw_context,
|
||||
cairo_region_union (priv->regions[i], region);
|
||||
}
|
||||
|
||||
acquire_next_image:
|
||||
acquire_result = GDK_VK_CHECK (vkAcquireNextImageKHR, gdk_vulkan_context_get_device (context),
|
||||
priv->swapchain,
|
||||
UINT64_MAX,
|
||||
priv->draw_semaphore,
|
||||
VK_NULL_HANDLE,
|
||||
&priv->draw_index);
|
||||
if ((acquire_result == VK_ERROR_OUT_OF_DATE_KHR) ||
|
||||
(acquire_result == VK_SUBOPTIMAL_KHR))
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
GDK_DEBUG (VULKAN, "Recreating the swapchain");
|
||||
|
||||
if (!gdk_vulkan_context_check_swapchain (context, &error))
|
||||
{
|
||||
g_warning ("%s", error->message);
|
||||
g_error_free (error);
|
||||
return;
|
||||
}
|
||||
|
||||
goto acquire_next_image;
|
||||
}
|
||||
GDK_VK_CHECK (vkAcquireNextImageKHR, gdk_vulkan_context_get_device (context),
|
||||
priv->swapchain,
|
||||
UINT64_MAX,
|
||||
priv->draw_semaphore,
|
||||
VK_NULL_HANDLE,
|
||||
&priv->draw_index);
|
||||
|
||||
cairo_region_union (region, priv->regions[priv->draw_index]);
|
||||
}
|
||||
@@ -1248,6 +1229,18 @@ gdk_display_vulkan_pipeline_cache_updated (GdkDisplay *display)
|
||||
NULL);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gdk_display_vulkan_pipeline_cache_save (GdkDisplay *display)
|
||||
{
|
||||
return gdk_vulkan_save_pipeline_cache (display);
|
||||
}
|
||||
|
||||
GFile *
|
||||
gdk_display_vulkan_pipeline_cache_file (GdkDisplay *display)
|
||||
{
|
||||
return gdk_vulkan_get_pipeline_cache_file (display);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_display_create_pipeline_cache (GdkDisplay *display)
|
||||
{
|
||||
@@ -1518,7 +1511,6 @@ gdk_display_create_vulkan_device (GdkDisplay *display,
|
||||
|
||||
g_ptr_array_add (device_extensions, (gpointer) VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME);
|
||||
g_ptr_array_add (device_extensions, (gpointer) VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME);
|
||||
g_ptr_array_add (device_extensions, (gpointer) VK_EXT_EXTERNAL_MEMORY_DMA_BUF_EXTENSION_NAME);
|
||||
|
||||
g_ptr_array_add (device_extensions, (gpointer) VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME);
|
||||
g_ptr_array_add (device_extensions, (gpointer) VK_KHR_IMAGE_FORMAT_LIST_EXTENSION_NAME);
|
||||
|
||||
@@ -87,6 +87,8 @@ VkShaderModule gdk_display_get_vk_shader_module (GdkDisp
|
||||
const char *resource_name);
|
||||
|
||||
void gdk_display_vulkan_pipeline_cache_updated (GdkDisplay *display);
|
||||
gboolean gdk_display_vulkan_pipeline_cache_save (GdkDisplay *display);
|
||||
GFile * gdk_display_vulkan_pipeline_cache_file (GdkDisplay *display);
|
||||
|
||||
VkInstance gdk_vulkan_context_get_instance (GdkVulkanContext *context);
|
||||
VkPhysicalDevice gdk_vulkan_context_get_physical_device (GdkVulkanContext *context);
|
||||
|
||||
@@ -165,29 +165,25 @@ _gdk_wayland_cursor_get_buffer (GdkWaylandDisplay *display,
|
||||
double *scale)
|
||||
{
|
||||
GdkTexture *texture;
|
||||
int desired_scale_factor;
|
||||
|
||||
desired_scale_factor = (int) ceil (desired_scale);
|
||||
|
||||
if (gdk_cursor_get_name (cursor))
|
||||
{
|
||||
struct wl_cursor *c;
|
||||
int scale_factor;
|
||||
|
||||
if (g_str_equal (gdk_cursor_get_name (cursor), "none"))
|
||||
{
|
||||
*hotspot_x = *hotspot_y = 0;
|
||||
*width = *height = 0;
|
||||
*scale = 1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
scale_factor = (int) ceil (desired_scale);
|
||||
goto none;
|
||||
|
||||
c = gdk_wayland_cursor_load_for_name (display,
|
||||
display->cursor_theme,
|
||||
scale_factor,
|
||||
_gdk_wayland_display_get_cursor_theme (display),
|
||||
desired_scale_factor,
|
||||
gdk_cursor_get_name (cursor));
|
||||
if (c && c->image_count > 0)
|
||||
{
|
||||
struct wl_cursor_image *image;
|
||||
int cursor_scale;
|
||||
|
||||
if (image_index >= c->image_count)
|
||||
{
|
||||
@@ -199,23 +195,23 @@ _gdk_wayland_cursor_get_buffer (GdkWaylandDisplay *display,
|
||||
|
||||
image = c->images[image_index];
|
||||
|
||||
*width = display->cursor_theme_size;
|
||||
*height = display->cursor_theme_size;
|
||||
*scale = image->width / (double) *width;
|
||||
*hotspot_x = image->hotspot_x / scale_factor;
|
||||
*hotspot_y = image->hotspot_y / scale_factor;
|
||||
|
||||
if (*scale != scale_factor && !use_viewporter)
|
||||
cursor_scale = desired_scale_factor;
|
||||
if ((image->width % cursor_scale != 0) ||
|
||||
(image->height % cursor_scale != 0))
|
||||
{
|
||||
g_warning (G_STRLOC " cursor image size (%d) not an integer "
|
||||
"multiple of theme size (%d)", image->width, *width);
|
||||
*width = image->width;
|
||||
*height = image->height;
|
||||
*hotspot_x = image->hotspot_x;
|
||||
*hotspot_y = image->hotspot_y;
|
||||
*scale = 1;
|
||||
g_warning (G_STRLOC " cursor image size (%dx%d) not an integer "
|
||||
"multiple of scale (%d)", image->width, image->height,
|
||||
cursor_scale);
|
||||
cursor_scale = 1;
|
||||
}
|
||||
|
||||
*hotspot_x = image->hotspot_x / cursor_scale;
|
||||
*hotspot_y = image->hotspot_y / cursor_scale;
|
||||
|
||||
*width = image->width / cursor_scale;
|
||||
*height = image->height / cursor_scale;
|
||||
*scale = cursor_scale;
|
||||
|
||||
return wl_cursor_image_get_buffer (image);
|
||||
}
|
||||
}
|
||||
@@ -261,7 +257,7 @@ from_texture:
|
||||
else
|
||||
{
|
||||
if (!use_viewporter)
|
||||
*scale = ceil (desired_scale);
|
||||
*scale = desired_scale_factor;
|
||||
else
|
||||
*scale = desired_scale;
|
||||
|
||||
@@ -298,23 +294,28 @@ from_texture:
|
||||
}
|
||||
|
||||
if (gdk_cursor_get_fallback (cursor))
|
||||
{
|
||||
return _gdk_wayland_cursor_get_buffer (display,
|
||||
gdk_cursor_get_fallback (cursor),
|
||||
desired_scale,
|
||||
use_viewporter,
|
||||
image_index,
|
||||
hotspot_x, hotspot_y,
|
||||
width, height,
|
||||
scale);
|
||||
}
|
||||
return _gdk_wayland_cursor_get_buffer (display,
|
||||
gdk_cursor_get_fallback (cursor),
|
||||
desired_scale,
|
||||
use_viewporter,
|
||||
image_index,
|
||||
hotspot_x, hotspot_y,
|
||||
width, height,
|
||||
scale);
|
||||
else
|
||||
{
|
||||
texture = gdk_texture_new_from_resource ("/org/gtk/libgdk/cursor/default");
|
||||
goto from_texture;
|
||||
}
|
||||
|
||||
g_assert_not_reached ();
|
||||
none:
|
||||
*hotspot_x = 0;
|
||||
*hotspot_y = 0;
|
||||
*width = 0;
|
||||
*height = 0;
|
||||
*scale = 1;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
guint
|
||||
|
||||
@@ -908,9 +908,7 @@ _gdk_win32_create_hicon_for_texture (GdkTexture *texture,
|
||||
width = cairo_image_surface_get_width (surface);
|
||||
height = cairo_image_surface_get_height (surface);
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0, width, height);
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
|
||||
icon = pixbuf_to_hicon (pixbuf, is_icon, x, y);
|
||||
|
||||
|
||||
@@ -267,7 +267,7 @@ create_dummy_gl_window (void)
|
||||
{
|
||||
WNDCLASS wclass = { 0, };
|
||||
ATOM klass;
|
||||
HWND hwnd = NULL;
|
||||
HWND hwnd;
|
||||
|
||||
wclass.lpszClassName = "GdkGLDummyWindow";
|
||||
wclass.lpfnWndProc = DefWindowProc;
|
||||
|
||||
@@ -38,6 +38,7 @@ gdk_win32_vulkan_context_create_surface (GdkVulkanContext *context,
|
||||
{
|
||||
GdkSurface *window = gdk_draw_context_get_surface (GDK_DRAW_CONTEXT (context));
|
||||
GdkDisplay *display = gdk_draw_context_get_display (GDK_DRAW_CONTEXT (context));
|
||||
GdkWin32Surface *win32_surface = GDK_WIN32_SURFACE (window);
|
||||
VkWin32SurfaceCreateInfoKHR info;
|
||||
VkResult result;
|
||||
|
||||
|
||||
@@ -1776,6 +1776,11 @@ _gdk_x11_display_is_root_window (GdkDisplay *display,
|
||||
return GDK_SCREEN_XROOTWIN (display_x11->screen) == xroot_window;
|
||||
}
|
||||
|
||||
struct XPointerUngrabInfo {
|
||||
GdkDisplay *display;
|
||||
guint32 time;
|
||||
};
|
||||
|
||||
static void
|
||||
device_grab_update_callback (GdkDisplay *display,
|
||||
gpointer data,
|
||||
|
||||
@@ -29,7 +29,7 @@ gsk_gpu_blend_mode_op_print_instance (GskGpuShaderOp *shader,
|
||||
gsk_gpu_print_image_descriptor (string, shader->desc, instance->top_id);
|
||||
}
|
||||
|
||||
static const GskGpuShaderOpClass GSK_GPU_BLEND_MODE_OP_CLASS = {
|
||||
const GskGpuShaderOpClass GSK_GPU_BLEND_MODE_OP_CLASS = {
|
||||
{
|
||||
GSK_GPU_OP_SIZE (GskGpuBlendModeOp),
|
||||
GSK_GPU_STAGE_SHADER,
|
||||
|
||||
@@ -31,7 +31,7 @@ gsk_gpu_blur_op_print_instance (GskGpuShaderOp *shader,
|
||||
gsk_gpu_print_image_descriptor (string, shader->desc, instance->tex_id);
|
||||
}
|
||||
|
||||
static const GskGpuShaderOpClass GSK_GPU_BLUR_OP_CLASS = {
|
||||
const GskGpuShaderOpClass GSK_GPU_BLUR_OP_CLASS = {
|
||||
{
|
||||
GSK_GPU_OP_SIZE (GskGpuBlurOp),
|
||||
GSK_GPU_STAGE_SHADER,
|
||||
|
||||
@@ -72,7 +72,7 @@ gsk_gpu_border_op_gl_command (GskGpuOp *op,
|
||||
return gsk_gpu_shader_op_gl_command_n (op, frame, state, 8);
|
||||
}
|
||||
|
||||
static const GskGpuShaderOpClass GSK_GPU_BORDER_OP_CLASS = {
|
||||
const GskGpuShaderOpClass GSK_GPU_BORDER_OP_CLASS = {
|
||||
{
|
||||
GSK_GPU_OP_SIZE (GskGpuBorderOp),
|
||||
GSK_GPU_STAGE_SHADER,
|
||||
|
||||
@@ -51,7 +51,7 @@ gsk_gpu_box_shadow_op_gl_command (GskGpuOp *op,
|
||||
return gsk_gpu_shader_op_gl_command_n (op, frame, state, 8);
|
||||
}
|
||||
|
||||
static const GskGpuShaderOpClass GSK_GPU_BOX_SHADOW_OP_CLASS = {
|
||||
const GskGpuShaderOpClass GSK_GPU_BOX_SHADOW_OP_CLASS = {
|
||||
{
|
||||
GSK_GPU_OP_SIZE (GskGpuBoxShadowOp),
|
||||
GSK_GPU_STAGE_SHADER,
|
||||
|
||||
@@ -27,7 +27,7 @@ gsk_gpu_colorize_op_print_instance (GskGpuShaderOp *shader,
|
||||
gsk_gpu_print_rgba (string, instance->color);
|
||||
}
|
||||
|
||||
static const GskGpuShaderOpClass GSK_GPU_COLORIZE_OP_CLASS = {
|
||||
const GskGpuShaderOpClass GSK_GPU_COLORIZE_OP_CLASS = {
|
||||
{
|
||||
GSK_GPU_OP_SIZE (GskGpuColorizeOp),
|
||||
GSK_GPU_STAGE_SHADER,
|
||||
|
||||
@@ -26,7 +26,7 @@ gsk_gpu_color_matrix_op_print_instance (GskGpuShaderOp *shader,
|
||||
gsk_gpu_print_image_descriptor (string, shader->desc, instance->tex_id);
|
||||
}
|
||||
|
||||
static const GskGpuShaderOpClass GSK_GPU_COLOR_MATRIX_OP_CLASS = {
|
||||
const GskGpuShaderOpClass GSK_GPU_COLOR_MATRIX_OP_CLASS = {
|
||||
{
|
||||
GSK_GPU_OP_SIZE (GskGpuColorMatrixOp),
|
||||
GSK_GPU_STAGE_SHADER,
|
||||
|
||||
@@ -27,7 +27,7 @@ gsk_gpu_color_op_print_instance (GskGpuShaderOp *shader,
|
||||
gsk_gpu_print_rgba (string, instance->color);
|
||||
}
|
||||
|
||||
static const GskGpuShaderOpClass GSK_GPU_COLOR_OP_CLASS = {
|
||||
const GskGpuShaderOpClass GSK_GPU_COLOR_OP_CLASS = {
|
||||
{
|
||||
GSK_GPU_OP_SIZE (GskGpuColorOp),
|
||||
GSK_GPU_STAGE_SHADER,
|
||||
|
||||
@@ -27,7 +27,7 @@ gsk_gpu_conic_gradient_op_print_instance (GskGpuShaderOp *shader,
|
||||
gsk_gpu_print_rect (string, instance->rect);
|
||||
}
|
||||
|
||||
static const GskGpuShaderOpClass GSK_GPU_CONIC_GRADIENT_OP_CLASS = {
|
||||
const GskGpuShaderOpClass GSK_GPU_CONIC_GRADIENT_OP_CLASS = {
|
||||
{
|
||||
GSK_GPU_OP_SIZE (GskGpuConicGradientOp),
|
||||
GSK_GPU_STAGE_SHADER,
|
||||
|
||||
@@ -28,7 +28,7 @@ gsk_gpu_cross_fade_op_print_instance (GskGpuShaderOp *shader,
|
||||
g_string_append_printf (string, "%g%%", 100 * instance->opacity_progress[1]);
|
||||
}
|
||||
|
||||
static const GskGpuShaderOpClass GSK_GPU_CROSS_FADE_OP_CLASS = {
|
||||
const GskGpuShaderOpClass GSK_GPU_CROSS_FADE_OP_CLASS = {
|
||||
{
|
||||
GSK_GPU_OP_SIZE (GskGpuCrossFadeOp),
|
||||
GSK_GPU_STAGE_SHADER,
|
||||
|
||||
@@ -546,7 +546,7 @@ gsk_gpu_device_maybe_gc (GskGpuDevice *self)
|
||||
|
||||
if (priv->cache_timeout == 0 || dead_texture_pixels > 1000000)
|
||||
{
|
||||
GSK_DEBUG (GLYPH_CACHE, "Pre-frame GC (%" G_GSIZE_FORMAT " dead pixels)", dead_texture_pixels);
|
||||
GSK_DEBUG (GLYPH_CACHE, "Pre-frame GC (%lu dead pixels)", dead_texture_pixels);
|
||||
gsk_gpu_device_gc (self, g_get_monotonic_time ());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ gsk_gpu_linear_gradient_op_print_instance (GskGpuShaderOp *shader,
|
||||
gsk_gpu_print_rect (string, instance->rect);
|
||||
}
|
||||
|
||||
static const GskGpuShaderOpClass GSK_GPU_LINEAR_GRADIENT_OP_CLASS = {
|
||||
const GskGpuShaderOpClass GSK_GPU_LINEAR_GRADIENT_OP_CLASS = {
|
||||
{
|
||||
GSK_GPU_OP_SIZE (GskGpuLinearGradientOp),
|
||||
GSK_GPU_STAGE_SHADER,
|
||||
|
||||
@@ -27,7 +27,7 @@ gsk_gpu_mask_op_print_instance (GskGpuShaderOp *shader,
|
||||
gsk_gpu_print_image_descriptor (string, shader->desc, instance->mask_id);
|
||||
}
|
||||
|
||||
static const GskGpuShaderOpClass GSK_GPU_MASK_OP_CLASS = {
|
||||
const GskGpuShaderOpClass GSK_GPU_MASK_OP_CLASS = {
|
||||
{
|
||||
GSK_GPU_OP_SIZE (GskGpuMaskOp),
|
||||
GSK_GPU_STAGE_SHADER,
|
||||
|
||||
@@ -30,7 +30,7 @@ gsk_gpu_radial_gradient_op_print_instance (GskGpuShaderOp *shader,
|
||||
gsk_gpu_print_rect (string, instance->rect);
|
||||
}
|
||||
|
||||
static const GskGpuShaderOpClass GSK_GPU_RADIAL_GRADIENT_OP_CLASS = {
|
||||
const GskGpuShaderOpClass GSK_GPU_RADIAL_GRADIENT_OP_CLASS = {
|
||||
{
|
||||
GSK_GPU_OP_SIZE (GskGpuRadialGradientOp),
|
||||
GSK_GPU_STAGE_SHADER,
|
||||
|
||||
@@ -27,7 +27,7 @@ gsk_gpu_rounded_color_op_print_instance (GskGpuShaderOp *shader,
|
||||
gsk_gpu_print_rgba (string, instance->color);
|
||||
}
|
||||
|
||||
static const GskGpuShaderOpClass GSK_GPU_ROUNDED_COLOR_OP_CLASS = {
|
||||
const GskGpuShaderOpClass GSK_GPU_ROUNDED_COLOR_OP_CLASS = {
|
||||
{
|
||||
GSK_GPU_OP_SIZE (GskGpuRoundedColorOp),
|
||||
GSK_GPU_STAGE_SHADER,
|
||||
|
||||
@@ -268,3 +268,45 @@ gsk_gpu_shader_op_alloc (GskGpuFrame *frame,
|
||||
*((gpointer *) out_vertex_data) = gsk_gpu_frame_get_vertex_data (frame, vertex_offset);
|
||||
}
|
||||
|
||||
extern const GskGpuShaderOpClass GSK_GPU_BLEND_MODE_OP_CLASS;
|
||||
extern const GskGpuShaderOpClass GSK_GPU_BLUR_OP_CLASS;
|
||||
extern const GskGpuShaderOpClass GSK_GPU_BORDER_OP_CLASS;
|
||||
extern const GskGpuShaderOpClass GSK_GPU_BOX_SHADOW_OP_CLASS;
|
||||
extern const GskGpuShaderOpClass GSK_GPU_COLORIZE_OP_CLASS;
|
||||
extern const GskGpuShaderOpClass GSK_GPU_COLOR_MATRIX_OP_CLASS;
|
||||
extern const GskGpuShaderOpClass GSK_GPU_COLOR_OP_CLASS;
|
||||
extern const GskGpuShaderOpClass GSK_GPU_CONIC_GRADIENT_OP_CLASS;
|
||||
extern const GskGpuShaderOpClass GSK_GPU_CROSS_FADE_OP_CLASS;
|
||||
extern const GskGpuShaderOpClass GSK_GPU_LINEAR_GRADIENT_OP_CLASS;
|
||||
extern const GskGpuShaderOpClass GSK_GPU_MASK_OP_CLASS;
|
||||
extern const GskGpuShaderOpClass GSK_GPU_RADIAL_GRADIENT_OP_CLASS;
|
||||
extern const GskGpuShaderOpClass GSK_GPU_ROUNDED_COLOR_OP_CLASS;
|
||||
extern const GskGpuShaderOpClass GSK_GPU_STRAIGHT_ALPHA_OP_CLASS;
|
||||
extern const GskGpuShaderOpClass GSK_GPU_TEXTURE_OP_CLASS;
|
||||
extern const GskGpuShaderOpClass GSK_GPU_UBER_OP_CLASS;
|
||||
|
||||
#define CHECK_CLASS(class) if (strcmp (name, class.shader_name) == 0) return &class
|
||||
|
||||
const GskGpuShaderOpClass *
|
||||
gsk_gpu_shader_op_class_from_name (const char *name)
|
||||
{
|
||||
CHECK_CLASS (GSK_GPU_BLEND_MODE_OP_CLASS);
|
||||
else CHECK_CLASS (GSK_GPU_BLUR_OP_CLASS);
|
||||
else CHECK_CLASS (GSK_GPU_BORDER_OP_CLASS);
|
||||
else CHECK_CLASS (GSK_GPU_BOX_SHADOW_OP_CLASS);
|
||||
else CHECK_CLASS (GSK_GPU_COLORIZE_OP_CLASS);
|
||||
else CHECK_CLASS (GSK_GPU_COLOR_MATRIX_OP_CLASS);
|
||||
else CHECK_CLASS (GSK_GPU_COLOR_OP_CLASS);
|
||||
else CHECK_CLASS (GSK_GPU_CROSS_FADE_OP_CLASS);
|
||||
else CHECK_CLASS (GSK_GPU_LINEAR_GRADIENT_OP_CLASS);
|
||||
else CHECK_CLASS (GSK_GPU_MASK_OP_CLASS);
|
||||
else CHECK_CLASS (GSK_GPU_RADIAL_GRADIENT_OP_CLASS);
|
||||
else CHECK_CLASS (GSK_GPU_ROUNDED_COLOR_OP_CLASS);
|
||||
else CHECK_CLASS (GSK_GPU_STRAIGHT_ALPHA_OP_CLASS);
|
||||
else CHECK_CLASS (GSK_GPU_TEXTURE_OP_CLASS);
|
||||
else CHECK_CLASS (GSK_GPU_UBER_OP_CLASS);
|
||||
|
||||
g_warning ("No such shader op: %s\n", name);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -84,5 +84,7 @@ gsk_gpu_point_to_float (const graphene_point_t *point,
|
||||
values[1] = point->y + offset->y;
|
||||
}
|
||||
|
||||
const GskGpuShaderOpClass * gsk_gpu_shader_op_class_from_name (const char *name);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ gsk_gpu_straight_alpha_op_print_instance (GskGpuShaderOp *shader,
|
||||
gsk_gpu_print_image_descriptor (string, shader->desc, instance->tex_id);
|
||||
}
|
||||
|
||||
static const GskGpuShaderOpClass GSK_GPU_STRAIGHT_ALPHA_OP_CLASS = {
|
||||
const GskGpuShaderOpClass GSK_GPU_STRAIGHT_ALPHA_OP_CLASS = {
|
||||
{
|
||||
GSK_GPU_OP_SIZE (GskGpuStraightAlphaOp),
|
||||
GSK_GPU_STAGE_SHADER,
|
||||
|
||||
@@ -26,7 +26,7 @@ gsk_gpu_texture_op_print_instance (GskGpuShaderOp *shader,
|
||||
gsk_gpu_print_image_descriptor (string, shader->desc, instance->tex_id);
|
||||
}
|
||||
|
||||
static const GskGpuShaderOpClass GSK_GPU_TEXTURE_OP_CLASS = {
|
||||
const GskGpuShaderOpClass GSK_GPU_TEXTURE_OP_CLASS = {
|
||||
{
|
||||
GSK_GPU_OP_SIZE (GskGpuTextureOp),
|
||||
GSK_GPU_STAGE_SHADER,
|
||||
|
||||
@@ -26,7 +26,7 @@ gsk_gpu_uber_op_print_instance (GskGpuShaderOp *shader,
|
||||
gsk_gpu_print_rect (string, instance->rect);
|
||||
}
|
||||
|
||||
static const GskGpuShaderOpClass GSK_GPU_UBER_OP_CLASS = {
|
||||
const GskGpuShaderOpClass GSK_GPU_UBER_OP_CLASS = {
|
||||
{
|
||||
GSK_GPU_OP_SIZE (GskGpuUberOp),
|
||||
GSK_GPU_STAGE_SHADER,
|
||||
|
||||
@@ -1139,7 +1139,7 @@ gsk_vulkan_device_get_vk_pipeline (GskVulkanDevice *self,
|
||||
format);
|
||||
|
||||
GSK_DEBUG (SHADERS,
|
||||
"Create Vulkan pipeline (%s %s, %u/%s/%s/%u) for layout (%" G_GSIZE_FORMAT "/%" G_GSIZE_FORMAT "/%" G_GSIZE_FORMAT ")",
|
||||
"Create Vulkan pipeline (%s %s, %u/%s/%s/%u) for layout (%lu/%lu/%lu)",
|
||||
op_class->shader_name,
|
||||
version_string + 1,
|
||||
variation,
|
||||
|
||||
@@ -6397,10 +6397,6 @@ gsk_mask_node_draw (GskRenderNode *node,
|
||||
graphene_matrix_t color_matrix;
|
||||
graphene_vec4_t color_offset;
|
||||
|
||||
/* clip so the push_group() creates a smaller surface */
|
||||
gsk_cairo_rectangle (cr, &node->bounds);
|
||||
cairo_clip (cr);
|
||||
|
||||
if (has_empty_clip (cr))
|
||||
return;
|
||||
|
||||
|
||||
@@ -2312,25 +2312,6 @@ parse_antialias (GtkCssParser *parser,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
parse_hint_metrics (GtkCssParser *parser,
|
||||
Context *context,
|
||||
gpointer out)
|
||||
{
|
||||
if (!parse_enum (parser, CAIRO_GOBJECT_TYPE_HINT_METRICS, out))
|
||||
return FALSE;
|
||||
|
||||
if (*(cairo_hint_metrics_t *) out != CAIRO_HINT_METRICS_OFF &&
|
||||
*(cairo_hint_metrics_t *) out != CAIRO_HINT_METRICS_ON)
|
||||
{
|
||||
gtk_css_parser_error_value (parser, "Unsupported value for enum \"%s\"",
|
||||
g_type_name (CAIRO_GOBJECT_TYPE_HINT_METRICS));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GskRenderNode *
|
||||
parse_text_node (GtkCssParser *parser,
|
||||
Context *context)
|
||||
@@ -2341,7 +2322,6 @@ parse_text_node (GtkCssParser *parser,
|
||||
PangoGlyphString *glyphs = NULL;
|
||||
cairo_hint_style_t hint_style = CAIRO_HINT_STYLE_SLIGHT;
|
||||
cairo_antialias_t antialias = CAIRO_ANTIALIAS_GRAY;
|
||||
cairo_hint_metrics_t hint_metrics = CAIRO_HINT_METRICS_OFF;
|
||||
PangoFont *hinted;
|
||||
const Declaration declarations[] = {
|
||||
{ "font", parse_font, clear_font, &font },
|
||||
@@ -2350,7 +2330,6 @@ parse_text_node (GtkCssParser *parser,
|
||||
{ "glyphs", parse_glyphs, clear_glyphs, &glyphs },
|
||||
{ "hint-style", parse_hint_style, NULL, &hint_style },
|
||||
{ "antialias", parse_antialias, NULL, &antialias },
|
||||
{ "hint-metrics", parse_hint_metrics, NULL, &hint_metrics },
|
||||
};
|
||||
GskRenderNode *result;
|
||||
|
||||
@@ -2362,7 +2341,7 @@ parse_text_node (GtkCssParser *parser,
|
||||
g_assert (font);
|
||||
}
|
||||
|
||||
hinted = gsk_reload_font (font, 1.0, hint_metrics, hint_style, antialias);
|
||||
hinted = gsk_reload_font (font, 1.0, CAIRO_HINT_METRICS_OFF, hint_style, antialias);
|
||||
g_object_unref (font);
|
||||
font = hinted;
|
||||
|
||||
@@ -3560,13 +3539,13 @@ append_texture_param (Printer *p,
|
||||
case GDK_MEMORY_U8:
|
||||
case GDK_MEMORY_U16:
|
||||
bytes = gdk_texture_save_to_png_bytes (texture);
|
||||
g_string_append (p->str, "url(\"data:image/png;base64,\\\n");
|
||||
g_string_append (p->str, "url(\"data:image/png;base64,");
|
||||
break;
|
||||
|
||||
case GDK_MEMORY_FLOAT16:
|
||||
case GDK_MEMORY_FLOAT32:
|
||||
bytes = gdk_texture_save_to_tiff_bytes (texture);
|
||||
g_string_append (p->str, "url(\"data:image/tiff;base64,\\\n");
|
||||
g_string_append (p->str, "url(\"data:image/tiff;base64,");
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -3625,7 +3604,7 @@ gsk_text_node_serialize_font (GskRenderNode *node,
|
||||
|
||||
b64 = base64_encode_with_linebreaks ((const guchar *) data, len);
|
||||
|
||||
g_string_append (p->str, " url(\"data:font/ttf;base64,\\\n");
|
||||
g_string_append (p->str, " url(\"data:font/ttf;base64,");
|
||||
append_escaping_newlines (p->str, b64);
|
||||
g_string_append (p->str, "\")");
|
||||
|
||||
@@ -3644,13 +3623,11 @@ gsk_text_node_serialize_font_options (GskRenderNode *node,
|
||||
cairo_font_options_t *options;
|
||||
cairo_hint_style_t hint_style;
|
||||
cairo_antialias_t antialias;
|
||||
cairo_hint_metrics_t hint_metrics;
|
||||
|
||||
options = cairo_font_options_create ();
|
||||
cairo_scaled_font_get_font_options (sf, options);
|
||||
hint_style = cairo_font_options_get_hint_style (options);
|
||||
antialias = cairo_font_options_get_antialias (options);
|
||||
hint_metrics = cairo_font_options_get_hint_metrics (options);
|
||||
cairo_font_options_destroy (options);
|
||||
|
||||
/* medium and full are identical in the absence of subpixel modes */
|
||||
@@ -3666,12 +3643,6 @@ gsk_text_node_serialize_font_options (GskRenderNode *node,
|
||||
*/
|
||||
if (antialias == CAIRO_ANTIALIAS_NONE)
|
||||
append_enum_param (p, "antialias", CAIRO_GOBJECT_TYPE_ANTIALIAS, antialias);
|
||||
|
||||
/* CAIRO_HINT_METRICS_ON is the only value we ever emit here, since off is the default,
|
||||
* and we don't accept any other values.
|
||||
*/
|
||||
if (hint_metrics == CAIRO_HINT_METRICS_ON)
|
||||
append_enum_param (p, "hint-metrics", CAIRO_GOBJECT_TYPE_HINT_METRICS, CAIRO_HINT_METRICS_ON);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -4443,7 +4414,7 @@ render_node_print (Printer *p,
|
||||
cairo_surface_write_to_png_stream (surface, cairo_write_array, array);
|
||||
|
||||
_indent (p);
|
||||
g_string_append (p->str, "pixels: url(\"data:image/png;base64,\\\n");
|
||||
g_string_append (p->str, "pixels: url(\"data:image/png;base64,");
|
||||
b64 = base64_encode_with_linebreaks (array->data, array->len);
|
||||
append_escaping_newlines (p->str, b64);
|
||||
g_free (b64);
|
||||
@@ -4463,7 +4434,7 @@ render_node_print (Printer *p,
|
||||
if (cairo_script_from_recording_surface (script, surface) == CAIRO_STATUS_SUCCESS)
|
||||
{
|
||||
_indent (p);
|
||||
g_string_append (p->str, "script: url(\"data:;base64,\\\n");
|
||||
g_string_append (p->str, "script: url(\"data:;base64,");
|
||||
b64 = base64_encode_with_linebreaks (array->data, array->len);
|
||||
append_escaping_newlines (p->str, b64);
|
||||
g_free (b64);
|
||||
|
||||
@@ -184,4 +184,10 @@
|
||||
</signal>
|
||||
</interface>
|
||||
|
||||
<interface name="org.a11y.atspi.Event.Focus">
|
||||
<signal name="Focus"><arg direction="in" type="(suuv)"/>
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QSpiEvent"/>
|
||||
</signal>
|
||||
</interface>
|
||||
|
||||
</node>
|
||||
|
||||
+20
-31
@@ -530,15 +530,6 @@ handle_accessible_method (GDBusConnection *connection,
|
||||
g_variant_builder_open (&builder, G_VARIANT_TYPE ("a{ss}"));
|
||||
g_variant_builder_add (&builder, "{ss}", "toolkit", "GTK");
|
||||
|
||||
if (gtk_at_context_has_accessible_property (GTK_AT_CONTEXT (self), GTK_ACCESSIBLE_PROPERTY_LEVEL))
|
||||
{
|
||||
GtkAccessibleValue *value = gtk_at_context_get_accessible_property (GTK_AT_CONTEXT (self),
|
||||
GTK_ACCESSIBLE_PROPERTY_LEVEL);
|
||||
char *level = g_strdup_printf ("%d", gtk_int_accessible_value_get (value));
|
||||
g_variant_builder_add (&builder, "{ss}", "level", level);
|
||||
g_free (level);
|
||||
}
|
||||
|
||||
if (gtk_at_context_has_accessible_property (GTK_AT_CONTEXT (self), GTK_ACCESSIBLE_PROPERTY_PLACEHOLDER))
|
||||
{
|
||||
GtkAccessibleValue *value;
|
||||
@@ -729,16 +720,6 @@ handle_accessible_get_property (GDBusConnection *connection,
|
||||
res = get_parent_context_ref (accessible);
|
||||
else if (g_strcmp0 (property_name, "ChildCount") == 0)
|
||||
res = g_variant_new_int32 (gtk_at_spi_context_get_child_count (self));
|
||||
else if (g_strcmp0 (property_name, "HelpText"))
|
||||
{
|
||||
if (gtk_at_context_has_accessible_property (GTK_AT_CONTEXT (self), GTK_ACCESSIBLE_PROPERTY_HELP_TEXT))
|
||||
{
|
||||
GtkAccessibleValue *value = gtk_at_context_get_accessible_property (GTK_AT_CONTEXT (self), GTK_ACCESSIBLE_PROPERTY_HELP_TEXT);
|
||||
res = g_variant_new_string (gtk_string_accessible_value_get (value));
|
||||
}
|
||||
else
|
||||
res = g_variant_new_string ("");
|
||||
}
|
||||
else
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
"Unknown property '%s'", property_name);
|
||||
@@ -918,6 +899,24 @@ emit_children_changed (GtkAtSpiContext *self,
|
||||
context_ref);
|
||||
}
|
||||
|
||||
static void
|
||||
emit_focus (GtkAtSpiContext *self,
|
||||
gboolean focus_in)
|
||||
{
|
||||
if (self->connection == NULL)
|
||||
return;
|
||||
|
||||
if (focus_in)
|
||||
g_dbus_connection_emit_signal (self->connection,
|
||||
NULL,
|
||||
self->context_path,
|
||||
"org.a11y.atspi.Event.Focus",
|
||||
"Focus",
|
||||
g_variant_new ("(siiva{sv})",
|
||||
"", 0, 0, g_variant_new_string ("0"), NULL),
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
emit_window_event (GtkAtSpiContext *self,
|
||||
const char *event_type)
|
||||
@@ -1155,7 +1154,7 @@ gtk_at_spi_context_state_change (GtkATContext *ctx,
|
||||
}
|
||||
|
||||
if (changed_properties & GTK_ACCESSIBLE_PROPERTY_CHANGE_DESCRIPTION)
|
||||
{
|
||||
{
|
||||
char *label = gtk_at_context_get_description (GTK_AT_CONTEXT (self));
|
||||
GVariant *v = g_variant_new_take_string (label);
|
||||
emit_property_changed (self, "accessible-description", v);
|
||||
@@ -1168,14 +1167,6 @@ gtk_at_spi_context_state_change (GtkATContext *ctx,
|
||||
"accessible-value",
|
||||
g_variant_new_double (gtk_number_accessible_value_get (value)));
|
||||
}
|
||||
|
||||
if (changed_properties & GTK_ACCESSIBLE_PROPERTY_CHANGE_HELP_TEXT)
|
||||
{
|
||||
value = gtk_accessible_attribute_set_get_value (properties, GTK_ACCESSIBLE_PROPERTY_HELP_TEXT);
|
||||
emit_property_changed (self,
|
||||
"accessible-help-text",
|
||||
g_variant_new_string (gtk_string_accessible_value_get (value)));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1205,6 +1196,7 @@ gtk_at_spi_context_platform_change (GtkATContext *ctx,
|
||||
gboolean state = gtk_accessible_get_platform_state (GTK_ACCESSIBLE (widget),
|
||||
GTK_ACCESSIBLE_PLATFORM_STATE_FOCUSED);
|
||||
emit_state_changed (self, "focused", state);
|
||||
emit_focus (self, state);
|
||||
}
|
||||
|
||||
if (changed_platform & GTK_ACCESSIBLE_PLATFORM_CHANGE_ACTIVE)
|
||||
@@ -1266,13 +1258,10 @@ gtk_at_spi_context_child_change (GtkATContext *ctx,
|
||||
}
|
||||
|
||||
if (change & GTK_ACCESSIBLE_CHILD_CHANGE_ADDED)
|
||||
{
|
||||
gtk_at_context_realize (child_context);
|
||||
emit_children_changed (self,
|
||||
GTK_AT_SPI_CONTEXT (child_context),
|
||||
idx,
|
||||
GTK_ACCESSIBLE_CHILD_STATE_ADDED);
|
||||
}
|
||||
else if (change & GTK_ACCESSIBLE_CHILD_CHANGE_REMOVED)
|
||||
emit_children_changed (self,
|
||||
GTK_AT_SPI_CONTEXT (child_context),
|
||||
|
||||
@@ -97,7 +97,7 @@ gtk_accessible_role_to_atspi_role (GtkAccessibleRole role)
|
||||
return ATSPI_ROLE_FORM;
|
||||
|
||||
case GTK_ACCESSIBLE_ROLE_GENERIC:
|
||||
return ATSPI_ROLE_PANEL;
|
||||
return ATSPI_ROLE_FILLER;
|
||||
|
||||
case GTK_ACCESSIBLE_ROLE_GRID:
|
||||
return ATSPI_ROLE_TABLE;
|
||||
@@ -106,7 +106,7 @@ gtk_accessible_role_to_atspi_role (GtkAccessibleRole role)
|
||||
return ATSPI_ROLE_TABLE_CELL;
|
||||
|
||||
case GTK_ACCESSIBLE_ROLE_GROUP:
|
||||
return ATSPI_ROLE_GROUPING;
|
||||
return ATSPI_ROLE_PANEL;
|
||||
|
||||
case GTK_ACCESSIBLE_ROLE_HEADING:
|
||||
return ATSPI_ROLE_HEADING;
|
||||
|
||||
+47
-549
@@ -26,18 +26,24 @@
|
||||
#include "gtkcsserror.h"
|
||||
#include "gtkcsslocationprivate.h"
|
||||
|
||||
static void clear_ref (GtkCssVariableValueReference *ref);
|
||||
|
||||
#define GDK_ARRAY_NAME gtk_css_parser_references
|
||||
#define GDK_ARRAY_TYPE_NAME GtkCssParserReferences
|
||||
#define GDK_ARRAY_ELEMENT_TYPE GtkCssVariableValueReference
|
||||
#define GDK_ARRAY_BY_VALUE 1
|
||||
#define GDK_ARRAY_NO_MEMSET 1
|
||||
#define GDK_ARRAY_FREE_FUNC clear_ref
|
||||
#include "gdk/gdkarrayimpl.c"
|
||||
|
||||
typedef struct _GtkCssParserBlock GtkCssParserBlock;
|
||||
|
||||
struct _GtkCssParser
|
||||
{
|
||||
volatile int ref_count;
|
||||
|
||||
GtkCssTokenizer *tokenizer;
|
||||
GFile *file;
|
||||
GFile *directory;
|
||||
GtkCssParserErrorFunc error_func;
|
||||
gpointer user_data;
|
||||
GDestroyNotify user_destroy;
|
||||
|
||||
GArray *blocks;
|
||||
GtkCssLocation location;
|
||||
GtkCssToken token;
|
||||
};
|
||||
|
||||
struct _GtkCssParserBlock
|
||||
{
|
||||
GtkCssLocation start_location;
|
||||
@@ -46,97 +52,8 @@ struct _GtkCssParserBlock
|
||||
GtkCssTokenType alternative_token;
|
||||
};
|
||||
|
||||
#define GDK_ARRAY_NAME gtk_css_parser_blocks
|
||||
#define GDK_ARRAY_TYPE_NAME GtkCssParserBlocks
|
||||
#define GDK_ARRAY_ELEMENT_TYPE GtkCssParserBlock
|
||||
#define GDK_ARRAY_PREALLOC 12
|
||||
#define GDK_ARRAY_NO_MEMSET 1
|
||||
#include "gdk/gdkarrayimpl.c"
|
||||
|
||||
static inline GtkCssParserBlock *
|
||||
gtk_css_parser_blocks_get_last (GtkCssParserBlocks *blocks)
|
||||
{
|
||||
return gtk_css_parser_blocks_index (blocks, gtk_css_parser_blocks_get_size (blocks) - 1);
|
||||
}
|
||||
|
||||
static inline void
|
||||
gtk_css_parser_blocks_drop_last (GtkCssParserBlocks *blocks)
|
||||
{
|
||||
gtk_css_parser_blocks_set_size (blocks, gtk_css_parser_blocks_get_size (blocks) - 1);
|
||||
}
|
||||
|
||||
typedef struct _GtkCssTokenizerData GtkCssTokenizerData;
|
||||
|
||||
struct _GtkCssTokenizerData
|
||||
{
|
||||
GtkCssTokenizer *tokenizer;
|
||||
char *var_name;
|
||||
GtkCssVariableValue *variable;
|
||||
};
|
||||
|
||||
static void
|
||||
gtk_css_tokenizer_data_clear (gpointer data)
|
||||
{
|
||||
GtkCssTokenizerData *td = data;
|
||||
|
||||
gtk_css_tokenizer_unref (td->tokenizer);
|
||||
if (td->var_name)
|
||||
g_free (td->var_name);
|
||||
if (td->variable)
|
||||
gtk_css_variable_value_unref (td->variable);
|
||||
}
|
||||
|
||||
#define GDK_ARRAY_NAME gtk_css_tokenizers
|
||||
#define GDK_ARRAY_TYPE_NAME GtkCssTokenizers
|
||||
#define GDK_ARRAY_ELEMENT_TYPE GtkCssTokenizerData
|
||||
#define GDK_ARRAY_FREE_FUNC gtk_css_tokenizer_data_clear
|
||||
#define GDK_ARRAY_BY_VALUE 1
|
||||
#define GDK_ARRAY_PREALLOC 16
|
||||
#define GDK_ARRAY_NO_MEMSET 1
|
||||
#include "gdk/gdkarrayimpl.c"
|
||||
|
||||
static inline GtkCssTokenizerData *
|
||||
gtk_css_tokenizers_get_last (GtkCssTokenizers *tokenizers)
|
||||
{
|
||||
return gtk_css_tokenizers_index (tokenizers, gtk_css_tokenizers_get_size (tokenizers) - 1);
|
||||
}
|
||||
|
||||
static inline void
|
||||
gtk_css_tokenizers_drop_last (GtkCssTokenizers *tokenizers)
|
||||
{
|
||||
gtk_css_tokenizers_set_size (tokenizers, gtk_css_tokenizers_get_size (tokenizers) - 1);
|
||||
}
|
||||
|
||||
struct _GtkCssParser
|
||||
{
|
||||
volatile int ref_count;
|
||||
|
||||
GtkCssTokenizers tokenizers;
|
||||
GFile *file;
|
||||
GFile *directory;
|
||||
GtkCssParserErrorFunc error_func;
|
||||
gpointer user_data;
|
||||
GDestroyNotify user_destroy;
|
||||
|
||||
GtkCssParserBlocks blocks;
|
||||
GtkCssLocation location;
|
||||
GtkCssToken token;
|
||||
|
||||
GtkCssVariableValue **refs;
|
||||
gsize n_refs;
|
||||
gsize next_ref;
|
||||
gboolean var_fallback;
|
||||
};
|
||||
|
||||
static inline GtkCssTokenizer *
|
||||
get_tokenizer (GtkCssParser *self)
|
||||
{
|
||||
return gtk_css_tokenizers_get_last (&self->tokenizers)->tokenizer;
|
||||
}
|
||||
|
||||
static GtkCssParser *
|
||||
gtk_css_parser_new (GtkCssTokenizer *tokenizer,
|
||||
GtkCssVariableValue *value,
|
||||
GFile *file,
|
||||
GtkCssParserErrorFunc error_func,
|
||||
gpointer user_data,
|
||||
@@ -147,21 +64,17 @@ gtk_css_parser_new (GtkCssTokenizer *tokenizer,
|
||||
self = g_new0 (GtkCssParser, 1);
|
||||
|
||||
self->ref_count = 1;
|
||||
|
||||
gtk_css_tokenizers_init (&self->tokenizers);
|
||||
gtk_css_tokenizers_append (&self->tokenizers,
|
||||
&(GtkCssTokenizerData) {
|
||||
gtk_css_tokenizer_ref (tokenizer),
|
||||
NULL,
|
||||
value ? gtk_css_variable_value_ref (value) : NULL });
|
||||
|
||||
self->tokenizer = gtk_css_tokenizer_ref (tokenizer);
|
||||
if (file)
|
||||
self->file = g_object_ref (file);
|
||||
{
|
||||
self->file = g_object_ref (file);
|
||||
self->directory = g_file_get_parent (file);
|
||||
}
|
||||
|
||||
self->error_func = error_func;
|
||||
self->user_data = user_data;
|
||||
self->user_destroy = user_destroy;
|
||||
gtk_css_parser_blocks_init (&self->blocks);
|
||||
self->blocks = g_array_new (FALSE, FALSE, sizeof (GtkCssParserBlock));
|
||||
|
||||
return self;
|
||||
}
|
||||
@@ -196,50 +109,26 @@ gtk_css_parser_new_for_bytes (GBytes *bytes,
|
||||
{
|
||||
GtkCssTokenizer *tokenizer;
|
||||
GtkCssParser *result;
|
||||
|
||||
|
||||
tokenizer = gtk_css_tokenizer_new (bytes);
|
||||
result = gtk_css_parser_new (tokenizer, NULL, file, error_func, user_data, user_destroy);
|
||||
result = gtk_css_parser_new (tokenizer, file, error_func, user_data, user_destroy);
|
||||
gtk_css_tokenizer_unref (tokenizer);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
GtkCssParser *
|
||||
gtk_css_parser_new_for_token_stream (GtkCssVariableValue *value,
|
||||
GFile *file,
|
||||
GtkCssVariableValue **refs,
|
||||
gsize n_refs,
|
||||
GtkCssParserErrorFunc error_func,
|
||||
gpointer user_data,
|
||||
GDestroyNotify user_destroy)
|
||||
{
|
||||
GtkCssTokenizer *tokenizer;
|
||||
GtkCssParser *result;
|
||||
|
||||
tokenizer = gtk_css_tokenizer_new_for_range (value->bytes, value->offset,
|
||||
value->end_offset - value->offset);
|
||||
result = gtk_css_parser_new (tokenizer, value, file, error_func, user_data, user_destroy);
|
||||
gtk_css_tokenizer_unref (tokenizer);
|
||||
|
||||
result->refs = refs;
|
||||
result->n_refs = n_refs;
|
||||
result->next_ref = 0;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_parser_finalize (GtkCssParser *self)
|
||||
{
|
||||
if (self->user_destroy)
|
||||
self->user_destroy (self->user_data);
|
||||
|
||||
gtk_css_tokenizers_clear (&self->tokenizers);
|
||||
g_clear_pointer (&self->tokenizer, gtk_css_tokenizer_unref);
|
||||
g_clear_object (&self->file);
|
||||
g_clear_object (&self->directory);
|
||||
if (gtk_css_parser_blocks_get_size (&self->blocks) > 0)
|
||||
g_critical ("Finalizing CSS parser with %lu remaining blocks", gtk_css_parser_blocks_get_size (&self->blocks));
|
||||
gtk_css_parser_blocks_clear (&self->blocks);
|
||||
if (self->blocks->len)
|
||||
g_critical ("Finalizing CSS parser with %u remaining blocks", self->blocks->len);
|
||||
g_array_free (self->blocks, TRUE);
|
||||
|
||||
g_free (self);
|
||||
}
|
||||
@@ -274,12 +163,6 @@ gtk_css_parser_get_file (GtkCssParser *self)
|
||||
return self->file;
|
||||
}
|
||||
|
||||
GBytes *
|
||||
gtk_css_parser_get_bytes (GtkCssParser *self)
|
||||
{
|
||||
return gtk_css_tokenizer_get_bytes (gtk_css_tokenizers_get (&self->tokenizers, 0)->tokenizer);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_css_parser_resolve_url:
|
||||
* @self: a `GtkCssParser`
|
||||
@@ -305,12 +188,7 @@ gtk_css_parser_resolve_url (GtkCssParser *self,
|
||||
}
|
||||
|
||||
if (self->directory == NULL)
|
||||
{
|
||||
if (self->file)
|
||||
self->directory = g_file_get_parent (self->file);
|
||||
if (self->directory == NULL)
|
||||
return NULL;
|
||||
}
|
||||
return NULL;
|
||||
|
||||
return g_file_resolve_relative_path (self->directory, url);
|
||||
}
|
||||
@@ -361,7 +239,7 @@ gtk_css_parser_get_start_location (GtkCssParser *self)
|
||||
const GtkCssLocation *
|
||||
gtk_css_parser_get_end_location (GtkCssParser *self)
|
||||
{
|
||||
return gtk_css_tokenizer_get_location (get_tokenizer (self));
|
||||
return gtk_css_tokenizer_get_location (self->tokenizer);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -381,13 +259,13 @@ gtk_css_parser_get_block_location (GtkCssParser *self)
|
||||
{
|
||||
const GtkCssParserBlock *block;
|
||||
|
||||
if (gtk_css_parser_blocks_get_size (&self->blocks) == 0)
|
||||
if (self->blocks->len == 0)
|
||||
{
|
||||
static const GtkCssLocation start_of_document = { 0, };
|
||||
return &start_of_document;
|
||||
}
|
||||
|
||||
block = gtk_css_parser_blocks_get_last (&self->blocks);
|
||||
block = &g_array_index (self->blocks, GtkCssParserBlock, self->blocks->len - 1);
|
||||
return &block->start_location;
|
||||
}
|
||||
|
||||
@@ -395,14 +273,12 @@ static void
|
||||
gtk_css_parser_ensure_token (GtkCssParser *self)
|
||||
{
|
||||
GError *error = NULL;
|
||||
GtkCssTokenizer *tokenizer;
|
||||
|
||||
if (!gtk_css_token_is (&self->token, GTK_CSS_TOKEN_EOF))
|
||||
return;
|
||||
|
||||
tokenizer = get_tokenizer (self);
|
||||
self->location = *gtk_css_tokenizer_get_location (tokenizer);
|
||||
if (!gtk_css_tokenizer_read_token (tokenizer, &self->token, &error))
|
||||
self->location = *gtk_css_tokenizer_get_location (self->tokenizer);
|
||||
if (!gtk_css_tokenizer_read_token (self->tokenizer, &self->token, &error))
|
||||
{
|
||||
/* We ignore the error here, because the resulting token will
|
||||
* likely already trigger an error in the parsing code and
|
||||
@@ -410,49 +286,6 @@ gtk_css_parser_ensure_token (GtkCssParser *self)
|
||||
*/
|
||||
g_clear_error (&error);
|
||||
}
|
||||
|
||||
if (gtk_css_tokenizers_get_size (&self->tokenizers) > 1 && gtk_css_token_is (&self->token, GTK_CSS_TOKEN_EOF))
|
||||
{
|
||||
gtk_css_tokenizers_drop_last (&self->tokenizers);
|
||||
gtk_css_parser_ensure_token (self);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Resolve var(--name): skip it and insert the resolved reference instead */
|
||||
if (self->n_refs > 0 && gtk_css_token_is_function (&self->token, "var") && self->var_fallback == 0)
|
||||
{
|
||||
GtkCssVariableValue *ref;
|
||||
GtkCssTokenizer *ref_tokenizer;
|
||||
|
||||
gtk_css_parser_start_block (self);
|
||||
|
||||
g_assert (gtk_css_parser_has_token (self, GTK_CSS_TOKEN_IDENT));
|
||||
|
||||
char *var_name = gtk_css_parser_consume_ident (self);
|
||||
g_assert (var_name[0] == '-' && var_name[1] == '-');
|
||||
|
||||
/* If we encounter var() in a fallback when we can already resolve the
|
||||
* actual variable, skip it */
|
||||
self->var_fallback++;
|
||||
gtk_css_parser_skip (self);
|
||||
gtk_css_parser_end_block (self);
|
||||
self->var_fallback--;
|
||||
|
||||
g_assert (self->next_ref < self->n_refs);
|
||||
|
||||
ref = self->refs[self->next_ref++];
|
||||
ref_tokenizer = gtk_css_tokenizer_new_for_range (ref->bytes, ref->offset,
|
||||
ref->end_offset - ref->offset);
|
||||
gtk_css_tokenizers_append (&self->tokenizers,
|
||||
&(GtkCssTokenizerData) {
|
||||
ref_tokenizer,
|
||||
g_strdup (var_name),
|
||||
gtk_css_variable_value_ref (ref)
|
||||
});
|
||||
|
||||
gtk_css_parser_ensure_token (self);
|
||||
g_free (var_name);
|
||||
}
|
||||
}
|
||||
|
||||
const GtkCssToken *
|
||||
@@ -462,9 +295,9 @@ gtk_css_parser_peek_token (GtkCssParser *self)
|
||||
|
||||
gtk_css_parser_ensure_token (self);
|
||||
|
||||
if (gtk_css_parser_blocks_get_size (&self->blocks) > 0)
|
||||
if (self->blocks->len)
|
||||
{
|
||||
const GtkCssParserBlock *block = gtk_css_parser_blocks_get_last (&self->blocks);
|
||||
const GtkCssParserBlock *block = &g_array_index (self->blocks, GtkCssParserBlock, self->blocks->len - 1);
|
||||
if (gtk_css_token_is (&self->token, block->end_token) ||
|
||||
gtk_css_token_is (&self->token, block->inherited_end_token) ||
|
||||
gtk_css_token_is (&self->token, block->alternative_token))
|
||||
@@ -519,7 +352,7 @@ gtk_css_parser_start_block (GtkCssParser *self)
|
||||
block.inherited_end_token = GTK_CSS_TOKEN_EOF;
|
||||
block.alternative_token = GTK_CSS_TOKEN_EOF;
|
||||
block.start_location = self->location;
|
||||
gtk_css_parser_blocks_append (&self->blocks, block);
|
||||
g_array_append_val (self->blocks, block);
|
||||
|
||||
gtk_css_token_clear (&self->token);
|
||||
}
|
||||
@@ -531,13 +364,13 @@ gtk_css_parser_start_semicolon_block (GtkCssParser *self,
|
||||
GtkCssParserBlock block;
|
||||
|
||||
block.end_token = GTK_CSS_TOKEN_SEMICOLON;
|
||||
if (gtk_css_parser_blocks_get_size (&self->blocks) > 0)
|
||||
block.inherited_end_token = gtk_css_parser_blocks_get_last (&self->blocks)->end_token;
|
||||
if (self->blocks->len)
|
||||
block.inherited_end_token = g_array_index (self->blocks, GtkCssParserBlock, self->blocks->len - 1).end_token;
|
||||
else
|
||||
block.inherited_end_token = GTK_CSS_TOKEN_EOF;
|
||||
block.alternative_token = alternative_token;
|
||||
block.start_location = self->location;
|
||||
gtk_css_parser_blocks_append (&self->blocks, block);
|
||||
g_array_append_val (self->blocks, block);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -545,9 +378,9 @@ gtk_css_parser_end_block_prelude (GtkCssParser *self)
|
||||
{
|
||||
GtkCssParserBlock *block;
|
||||
|
||||
g_return_if_fail (gtk_css_parser_blocks_get_size (&self->blocks) > 0);
|
||||
g_return_if_fail (self->blocks->len > 0);
|
||||
|
||||
block = gtk_css_parser_blocks_get_last (&self->blocks);
|
||||
block = &g_array_index (self->blocks, GtkCssParserBlock, self->blocks->len - 1);
|
||||
|
||||
if (block->alternative_token == GTK_CSS_TOKEN_EOF)
|
||||
return;
|
||||
@@ -572,11 +405,11 @@ gtk_css_parser_end_block (GtkCssParser *self)
|
||||
{
|
||||
GtkCssParserBlock *block;
|
||||
|
||||
g_return_if_fail (gtk_css_parser_blocks_get_size (&self->blocks) > 0);
|
||||
g_return_if_fail (self->blocks->len > 0);
|
||||
|
||||
gtk_css_parser_skip_until (self, GTK_CSS_TOKEN_EOF);
|
||||
|
||||
block = gtk_css_parser_blocks_get_last (&self->blocks);
|
||||
block = &g_array_index (self->blocks, GtkCssParserBlock, self->blocks->len - 1);
|
||||
|
||||
if (gtk_css_token_is (&self->token, GTK_CSS_TOKEN_EOF))
|
||||
{
|
||||
@@ -585,7 +418,7 @@ gtk_css_parser_end_block (GtkCssParser *self)
|
||||
gtk_css_parser_get_block_location (self),
|
||||
gtk_css_parser_get_start_location (self),
|
||||
"Unterminated block at end of document");
|
||||
gtk_css_parser_blocks_drop_last (&self->blocks);
|
||||
g_array_set_size (self->blocks, self->blocks->len - 1);
|
||||
}
|
||||
else if (gtk_css_token_is (&self->token, block->inherited_end_token))
|
||||
{
|
||||
@@ -595,11 +428,11 @@ gtk_css_parser_end_block (GtkCssParser *self)
|
||||
gtk_css_parser_get_block_location (self),
|
||||
gtk_css_parser_get_start_location (self),
|
||||
"Expected ';' at end of block");
|
||||
gtk_css_parser_blocks_drop_last (&self->blocks);
|
||||
g_array_set_size (self->blocks, self->blocks->len - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_css_parser_blocks_drop_last (&self->blocks);
|
||||
g_array_set_size (self->blocks, self->blocks->len - 1);
|
||||
if (gtk_css_token_is_preserved (&self->token, NULL))
|
||||
{
|
||||
gtk_css_token_clear (&self->token);
|
||||
@@ -669,19 +502,6 @@ gtk_css_parser_skip_until (GtkCssParser *self,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gtk_css_parser_skip_whitespace (GtkCssParser *self)
|
||||
{
|
||||
const GtkCssToken *token;
|
||||
|
||||
for (token = gtk_css_parser_peek_token (self);
|
||||
gtk_css_token_is (token, GTK_CSS_TOKEN_WHITESPACE);
|
||||
token = gtk_css_parser_peek_token (self))
|
||||
{
|
||||
gtk_css_parser_consume_token (self);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gtk_css_parser_emit_error (GtkCssParser *self,
|
||||
const GtkCssLocation *start,
|
||||
@@ -1292,325 +1112,3 @@ gtk_css_parser_consume_any (GtkCssParser *parser,
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_css_parser_has_references (GtkCssParser *self)
|
||||
{
|
||||
GtkCssTokenizer *tokenizer = get_tokenizer (self);
|
||||
gboolean ret = FALSE;
|
||||
int inner_blocks = 0, i;
|
||||
|
||||
/* We don't want gtk_css_parser_ensure_token to expand references on us here */
|
||||
g_assert (self->n_refs == 0);
|
||||
|
||||
gtk_css_tokenizer_save (tokenizer);
|
||||
|
||||
do {
|
||||
const GtkCssToken *token;
|
||||
|
||||
token = gtk_css_parser_get_token (self);
|
||||
|
||||
if (inner_blocks == 0)
|
||||
{
|
||||
if (gtk_css_token_is (token, GTK_CSS_TOKEN_EOF))
|
||||
break;
|
||||
|
||||
if (gtk_css_token_is (token, GTK_CSS_TOKEN_CLOSE_PARENS) ||
|
||||
gtk_css_token_is (token, GTK_CSS_TOKEN_CLOSE_SQUARE))
|
||||
{
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
if (gtk_css_token_is_preserved (token, NULL))
|
||||
{
|
||||
if (inner_blocks > 0 && gtk_css_token_is (token, GTK_CSS_TOKEN_EOF))
|
||||
{
|
||||
gtk_css_parser_end_block (self);
|
||||
inner_blocks--;
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_css_parser_consume_token (self);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gboolean is_var = gtk_css_token_is_function (token, "var");
|
||||
|
||||
inner_blocks++;
|
||||
gtk_css_parser_start_block (self);
|
||||
|
||||
if (is_var)
|
||||
{
|
||||
token = gtk_css_parser_get_token (self);
|
||||
|
||||
if (gtk_css_token_is (token, GTK_CSS_TOKEN_IDENT))
|
||||
{
|
||||
const char *var_name = gtk_css_token_get_string (token);
|
||||
|
||||
if (strlen (var_name) < 3 || var_name[0] != '-' || var_name[1] != '-')
|
||||
goto done;
|
||||
|
||||
gtk_css_parser_consume_token (self);
|
||||
|
||||
if (!gtk_css_parser_has_token (self, GTK_CSS_TOKEN_EOF) &&
|
||||
!gtk_css_parser_has_token (self, GTK_CSS_TOKEN_COMMA))
|
||||
goto done;
|
||||
|
||||
ret = TRUE;
|
||||
/* We got our answer. Now get it out as fast as possible! */
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
while (!gtk_css_parser_has_token (self, GTK_CSS_TOKEN_SEMICOLON) &&
|
||||
!gtk_css_parser_has_token (self, GTK_CSS_TOKEN_CLOSE_CURLY));
|
||||
|
||||
done:
|
||||
for (i = 0; i < inner_blocks; i++)
|
||||
gtk_css_parser_end_block (self);
|
||||
|
||||
g_assert (tokenizer == get_tokenizer (self));
|
||||
|
||||
gtk_css_tokenizer_restore (tokenizer);
|
||||
self->location = *gtk_css_tokenizer_get_location (tokenizer);
|
||||
gtk_css_tokenizer_read_token (tokenizer, &self->token, NULL);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
clear_ref (GtkCssVariableValueReference *ref)
|
||||
{
|
||||
g_free (ref->name);
|
||||
if (ref->fallback)
|
||||
gtk_css_variable_value_unref (ref->fallback);
|
||||
}
|
||||
|
||||
#define GDK_ARRAY_NAME gtk_css_parser_references
|
||||
#define GDK_ARRAY_TYPE_NAME GtkCssParserReferences
|
||||
#define GDK_ARRAY_ELEMENT_TYPE GtkCssVariableValueReference
|
||||
|
||||
GtkCssVariableValue *
|
||||
gtk_css_parser_parse_value_into_token_stream (GtkCssParser *self)
|
||||
{
|
||||
GBytes *bytes = gtk_css_tokenizer_get_bytes (get_tokenizer (self));
|
||||
const GtkCssToken *token;
|
||||
gsize offset;
|
||||
gsize length = 0;
|
||||
GtkCssParserReferences refs;
|
||||
int inner_blocks = 0, i;
|
||||
gboolean is_initial = FALSE;
|
||||
|
||||
for (token = gtk_css_parser_peek_token (self);
|
||||
gtk_css_token_is (token, GTK_CSS_TOKEN_WHITESPACE);
|
||||
token = gtk_css_parser_peek_token (self))
|
||||
{
|
||||
gtk_css_parser_consume_token (self);
|
||||
}
|
||||
|
||||
gtk_css_parser_references_init (&refs);
|
||||
|
||||
offset = self->location.bytes;
|
||||
|
||||
do {
|
||||
token = gtk_css_parser_get_token (self);
|
||||
|
||||
if (length == 0 && gtk_css_token_is_ident (token, "initial"))
|
||||
is_initial = TRUE;
|
||||
|
||||
if (gtk_css_token_is (token, GTK_CSS_TOKEN_BAD_STRING) ||
|
||||
gtk_css_token_is (token, GTK_CSS_TOKEN_BAD_URL))
|
||||
{
|
||||
gtk_css_parser_error_syntax (self, "Invalid property value");
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (inner_blocks == 0)
|
||||
{
|
||||
if (gtk_css_token_is (token, GTK_CSS_TOKEN_EOF))
|
||||
break;
|
||||
|
||||
if (gtk_css_token_is (token, GTK_CSS_TOKEN_CLOSE_PARENS) ||
|
||||
gtk_css_token_is (token, GTK_CSS_TOKEN_CLOSE_SQUARE))
|
||||
{
|
||||
gtk_css_parser_error_syntax (self, "Invalid property value");
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
if (gtk_css_token_is_preserved (token, NULL))
|
||||
{
|
||||
if (inner_blocks > 0 && gtk_css_token_is (token, GTK_CSS_TOKEN_EOF))
|
||||
{
|
||||
length++;
|
||||
gtk_css_parser_end_block (self);
|
||||
|
||||
inner_blocks--;
|
||||
}
|
||||
else
|
||||
{
|
||||
length++;
|
||||
gtk_css_parser_consume_token (self);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gboolean is_var = gtk_css_token_is_function (token, "var");
|
||||
|
||||
length++;
|
||||
inner_blocks++;
|
||||
|
||||
gtk_css_parser_start_block (self);
|
||||
|
||||
if (is_var)
|
||||
{
|
||||
token = gtk_css_parser_get_token (self);
|
||||
|
||||
if (gtk_css_token_is (token, GTK_CSS_TOKEN_IDENT))
|
||||
{
|
||||
GtkCssVariableValueReference ref;
|
||||
char *var_name = g_strdup (gtk_css_token_get_string (token));
|
||||
|
||||
if (strlen (var_name) < 3 || var_name[0] != '-' || var_name[1] != '-')
|
||||
{
|
||||
gtk_css_parser_error_syntax (self, "Invalid variable name: %s", var_name);
|
||||
g_free (var_name);
|
||||
goto error;
|
||||
}
|
||||
|
||||
length++;
|
||||
gtk_css_parser_consume_token (self);
|
||||
|
||||
if (!gtk_css_parser_has_token (self, GTK_CSS_TOKEN_EOF) &&
|
||||
!gtk_css_parser_has_token (self, GTK_CSS_TOKEN_COMMA))
|
||||
{
|
||||
gtk_css_parser_error_syntax (self, "Invalid property value");
|
||||
g_free (var_name);
|
||||
goto error;
|
||||
}
|
||||
|
||||
ref.name = var_name;
|
||||
|
||||
if (gtk_css_parser_has_token (self, GTK_CSS_TOKEN_EOF))
|
||||
{
|
||||
ref.length = 3;
|
||||
ref.fallback = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
length++;
|
||||
gtk_css_parser_consume_token (self);
|
||||
|
||||
ref.fallback = gtk_css_parser_parse_value_into_token_stream (self);
|
||||
|
||||
if (ref.fallback == NULL)
|
||||
{
|
||||
gtk_css_parser_error_value (self, "Invalid fallback for: %s", var_name);
|
||||
g_free (var_name);
|
||||
goto error;
|
||||
}
|
||||
|
||||
ref.length = 4 + ref.fallback->length;
|
||||
length += ref.fallback->length;
|
||||
}
|
||||
|
||||
gtk_css_parser_references_append (&refs, &ref);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gtk_css_token_is (token, GTK_CSS_TOKEN_EOF))
|
||||
{
|
||||
gtk_css_parser_error_syntax (self, "Missing variable name");
|
||||
}
|
||||
else
|
||||
{
|
||||
char *s = gtk_css_token_to_string (token);
|
||||
gtk_css_parser_error_syntax (self, "Expected a variable name, not %s", s);
|
||||
g_free (s);
|
||||
}
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
while (!gtk_css_parser_has_token (self, GTK_CSS_TOKEN_SEMICOLON) &&
|
||||
!gtk_css_parser_has_token (self, GTK_CSS_TOKEN_CLOSE_CURLY));
|
||||
|
||||
if (inner_blocks > 0)
|
||||
{
|
||||
gtk_css_parser_error_syntax (self, "Invalid property value");
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (is_initial && length == 1)
|
||||
{
|
||||
gtk_css_parser_references_clear (&refs);
|
||||
|
||||
return gtk_css_variable_value_new_initial (bytes,
|
||||
offset,
|
||||
self->location.bytes);
|
||||
}
|
||||
else
|
||||
{
|
||||
GtkCssVariableValueReference *out_refs;
|
||||
gsize n_refs;
|
||||
|
||||
n_refs = gtk_css_parser_references_get_size (&refs);
|
||||
out_refs = gtk_css_parser_references_steal (&refs);
|
||||
|
||||
return gtk_css_variable_value_new (bytes,
|
||||
offset,
|
||||
self->location.bytes,
|
||||
length,
|
||||
out_refs,
|
||||
n_refs);
|
||||
}
|
||||
|
||||
error:
|
||||
for (i = 0; i < inner_blocks; i++)
|
||||
gtk_css_parser_end_block (self);
|
||||
|
||||
gtk_css_parser_references_clear (&refs);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_css_parser_get_expanding_variables (GtkCssParser *self,
|
||||
GtkCssVariableValue ***variables,
|
||||
char ***variable_names,
|
||||
gsize *n_variables)
|
||||
{
|
||||
gsize len = gtk_css_tokenizers_get_size (&self->tokenizers);
|
||||
GtkCssVariableValue **vars = NULL;
|
||||
char **names = NULL;
|
||||
gsize n;
|
||||
|
||||
if (variables)
|
||||
vars = g_new0 (GtkCssVariableValue *, len + 1);
|
||||
if (variable_names)
|
||||
names = g_new0 (char *, len + 1);
|
||||
|
||||
n = 0;
|
||||
for (gsize i = 0; i < gtk_css_tokenizers_get_size (&self->tokenizers); i++)
|
||||
{
|
||||
GtkCssTokenizerData *data = gtk_css_tokenizers_index (&self->tokenizers, i);
|
||||
if (variables && data->variable)
|
||||
vars[n] = gtk_css_variable_value_ref (data->variable);
|
||||
if (variable_names)
|
||||
names[n] = g_strdup (data->var_name);
|
||||
n++;
|
||||
}
|
||||
|
||||
if (variables)
|
||||
*variables = vars;
|
||||
|
||||
if (variable_names)
|
||||
*variable_names = names;
|
||||
|
||||
if (n_variables)
|
||||
*n_variables = n;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
#include "gtkcssenums.h"
|
||||
#include "gtkcsstokenizerprivate.h"
|
||||
#include "gtkcssvariablevalueprivate.h"
|
||||
|
||||
#include <gio/gio.h>
|
||||
|
||||
@@ -59,18 +58,10 @@ GtkCssParser * gtk_css_parser_new_for_bytes (GBytes
|
||||
GtkCssParserErrorFunc error_func,
|
||||
gpointer user_data,
|
||||
GDestroyNotify user_destroy);
|
||||
GtkCssParser * gtk_css_parser_new_for_token_stream (GtkCssVariableValue *value,
|
||||
GFile *file,
|
||||
GtkCssVariableValue **refs,
|
||||
gsize n_refs,
|
||||
GtkCssParserErrorFunc error_func,
|
||||
gpointer user_data,
|
||||
GDestroyNotify user_destroy);
|
||||
GtkCssParser * gtk_css_parser_ref (GtkCssParser *self);
|
||||
void gtk_css_parser_unref (GtkCssParser *self);
|
||||
|
||||
GFile * gtk_css_parser_get_file (GtkCssParser *self) G_GNUC_PURE;
|
||||
GBytes * gtk_css_parser_get_bytes (GtkCssParser *self) G_GNUC_PURE;
|
||||
GFile * gtk_css_parser_resolve_url (GtkCssParser *self,
|
||||
const char *url);
|
||||
|
||||
@@ -90,7 +81,6 @@ void gtk_css_parser_end_block (GtkCssParser
|
||||
void gtk_css_parser_skip (GtkCssParser *self);
|
||||
void gtk_css_parser_skip_until (GtkCssParser *self,
|
||||
GtkCssTokenType token_type);
|
||||
void gtk_css_parser_skip_whitespace (GtkCssParser *self);
|
||||
|
||||
void gtk_css_parser_emit_error (GtkCssParser *self,
|
||||
const GtkCssLocation *start,
|
||||
@@ -160,14 +150,5 @@ gsize gtk_css_parser_consume_any (GtkCssParser
|
||||
gsize n_options,
|
||||
gpointer user_data);
|
||||
|
||||
gboolean gtk_css_parser_has_references (GtkCssParser *parser);
|
||||
|
||||
GtkCssVariableValue * gtk_css_parser_parse_value_into_token_stream (GtkCssParser *parser);
|
||||
|
||||
void gtk_css_parser_get_expanding_variables (GtkCssParser *parser,
|
||||
GtkCssVariableValue ***variables,
|
||||
char ***names,
|
||||
gsize *n_variables);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ struct _GtkCssSection
|
||||
int ref_count;
|
||||
GtkCssSection *parent;
|
||||
GFile *file;
|
||||
GBytes *bytes;
|
||||
GtkCssLocation start_location;
|
||||
GtkCssLocation end_location; /* end location if parser is %NULL */
|
||||
};
|
||||
@@ -49,15 +48,6 @@ GtkCssSection *
|
||||
gtk_css_section_new (GFile *file,
|
||||
const GtkCssLocation *start,
|
||||
const GtkCssLocation *end)
|
||||
{
|
||||
return gtk_css_section_new_with_bytes (file, NULL,start, end);
|
||||
}
|
||||
|
||||
GtkCssSection *
|
||||
gtk_css_section_new_with_bytes (GFile *file,
|
||||
GBytes *bytes,
|
||||
const GtkCssLocation *start,
|
||||
const GtkCssLocation *end)
|
||||
{
|
||||
GtkCssSection *result;
|
||||
|
||||
@@ -70,8 +60,6 @@ gtk_css_section_new_with_bytes (GFile *file,
|
||||
result->ref_count = 1;
|
||||
if (file)
|
||||
result->file = g_object_ref (file);
|
||||
if (bytes)
|
||||
result->bytes = g_bytes_ref (bytes);
|
||||
result->start_location = *start;
|
||||
result->end_location = *end;
|
||||
|
||||
@@ -116,8 +104,6 @@ gtk_css_section_unref (GtkCssSection *section)
|
||||
gtk_css_section_unref (section->parent);
|
||||
if (section->file)
|
||||
g_object_unref (section->file);
|
||||
if (section->bytes)
|
||||
g_bytes_unref (section->bytes);
|
||||
|
||||
g_free (section);
|
||||
}
|
||||
@@ -165,14 +151,6 @@ gtk_css_section_get_file (const GtkCssSection *section)
|
||||
return section->file;
|
||||
}
|
||||
|
||||
GBytes *
|
||||
gtk_css_section_get_bytes (const GtkCssSection *section)
|
||||
{
|
||||
g_return_val_if_fail (section != NULL, NULL);
|
||||
|
||||
return section->bytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_css_section_get_start_location:
|
||||
* @section: the section
|
||||
|
||||
@@ -46,11 +46,6 @@ GDK_AVAILABLE_IN_ALL
|
||||
GtkCssSection * gtk_css_section_new (GFile *file,
|
||||
const GtkCssLocation *start,
|
||||
const GtkCssLocation *end);
|
||||
GDK_AVAILABLE_IN_4_16
|
||||
GtkCssSection * gtk_css_section_new_with_bytes (GFile *file,
|
||||
GBytes *bytes,
|
||||
const GtkCssLocation *start,
|
||||
const GtkCssLocation *end);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkCssSection * gtk_css_section_ref (GtkCssSection *section);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
@@ -66,8 +61,6 @@ GDK_AVAILABLE_IN_ALL
|
||||
GtkCssSection * gtk_css_section_get_parent (const GtkCssSection *section);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GFile * gtk_css_section_get_file (const GtkCssSection *section);
|
||||
GDK_AVAILABLE_IN_4_16
|
||||
GBytes * gtk_css_section_get_bytes (const GtkCssSection *section);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const GtkCssLocation *
|
||||
gtk_css_section_get_start_location (const GtkCssSection *section);
|
||||
|
||||
@@ -36,9 +36,6 @@ struct _GtkCssTokenizer
|
||||
const char *end;
|
||||
|
||||
GtkCssLocation position;
|
||||
|
||||
GtkCssLocation saved_position;
|
||||
const char *saved_data;
|
||||
};
|
||||
|
||||
void
|
||||
@@ -571,14 +568,6 @@ gtk_css_token_init_dimension (GtkCssToken *token,
|
||||
|
||||
GtkCssTokenizer *
|
||||
gtk_css_tokenizer_new (GBytes *bytes)
|
||||
{
|
||||
return gtk_css_tokenizer_new_for_range (bytes, 0, g_bytes_get_size (bytes));
|
||||
}
|
||||
|
||||
GtkCssTokenizer *
|
||||
gtk_css_tokenizer_new_for_range (GBytes *bytes,
|
||||
gsize offset,
|
||||
gsize length)
|
||||
{
|
||||
GtkCssTokenizer *tokenizer;
|
||||
|
||||
@@ -587,8 +576,8 @@ gtk_css_tokenizer_new_for_range (GBytes *bytes,
|
||||
tokenizer->bytes = g_bytes_ref (bytes);
|
||||
tokenizer->name_buffer = g_string_new (NULL);
|
||||
|
||||
tokenizer->data = g_bytes_get_region (bytes, 1, offset, length);
|
||||
tokenizer->end = tokenizer->data + length;
|
||||
tokenizer->data = g_bytes_get_data (bytes, NULL);
|
||||
tokenizer->end = tokenizer->data + g_bytes_get_size (bytes);
|
||||
|
||||
gtk_css_location_init (&tokenizer->position);
|
||||
|
||||
@@ -615,12 +604,6 @@ gtk_css_tokenizer_unref (GtkCssTokenizer *tokenizer)
|
||||
g_free (tokenizer);
|
||||
}
|
||||
|
||||
GBytes *
|
||||
gtk_css_tokenizer_get_bytes (GtkCssTokenizer *tokenizer)
|
||||
{
|
||||
return tokenizer->bytes;
|
||||
}
|
||||
|
||||
const GtkCssLocation *
|
||||
gtk_css_tokenizer_get_location (GtkCssTokenizer *tokenizer)
|
||||
{
|
||||
@@ -1501,23 +1484,3 @@ gtk_css_tokenizer_read_token (GtkCssTokenizer *tokenizer,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gtk_css_tokenizer_save (GtkCssTokenizer *tokenizer)
|
||||
{
|
||||
g_assert (!tokenizer->saved_data);
|
||||
|
||||
tokenizer->saved_position = tokenizer->position;
|
||||
tokenizer->saved_data = tokenizer->data;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_css_tokenizer_restore (GtkCssTokenizer *tokenizer)
|
||||
{
|
||||
g_assert (tokenizer->saved_data);
|
||||
|
||||
tokenizer->position = tokenizer->saved_position;
|
||||
tokenizer->data = tokenizer->saved_data;
|
||||
|
||||
gtk_css_location_init (&tokenizer->saved_position);
|
||||
tokenizer->saved_data = NULL;
|
||||
}
|
||||
|
||||
@@ -138,22 +138,15 @@ void gtk_css_token_print (const GtkCssTok
|
||||
char * gtk_css_token_to_string (const GtkCssToken *token);
|
||||
|
||||
GtkCssTokenizer * gtk_css_tokenizer_new (GBytes *bytes);
|
||||
GtkCssTokenizer * gtk_css_tokenizer_new_for_range (GBytes *bytes,
|
||||
gsize offset,
|
||||
gsize length);
|
||||
|
||||
GtkCssTokenizer * gtk_css_tokenizer_ref (GtkCssTokenizer *tokenizer);
|
||||
void gtk_css_tokenizer_unref (GtkCssTokenizer *tokenizer);
|
||||
|
||||
GBytes * gtk_css_tokenizer_get_bytes (GtkCssTokenizer *tokenizer);
|
||||
const GtkCssLocation * gtk_css_tokenizer_get_location (GtkCssTokenizer *tokenizer) G_GNUC_CONST;
|
||||
|
||||
gboolean gtk_css_tokenizer_read_token (GtkCssTokenizer *tokenizer,
|
||||
GtkCssToken *token,
|
||||
GError **error);
|
||||
|
||||
void gtk_css_tokenizer_save (GtkCssTokenizer *tokenizer);
|
||||
void gtk_css_tokenizer_restore (GtkCssTokenizer *tokenizer);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
@@ -1,158 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2023 GNOME Foundation Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Alice Mikhaylenko <alicem@gnome.org>
|
||||
*/
|
||||
|
||||
#include "gtkcssvariablevalueprivate.h"
|
||||
|
||||
GtkCssVariableValue *
|
||||
gtk_css_variable_value_new (GBytes *bytes,
|
||||
gsize offset,
|
||||
gsize end_offset,
|
||||
gsize length,
|
||||
GtkCssVariableValueReference *references,
|
||||
gsize n_references)
|
||||
{
|
||||
GtkCssVariableValue *self = g_new0 (GtkCssVariableValue, 1);
|
||||
|
||||
self->ref_count = 1;
|
||||
|
||||
self->bytes = g_bytes_ref (bytes);
|
||||
self->offset = offset;
|
||||
self->end_offset = end_offset;
|
||||
self->length = length;
|
||||
|
||||
self->references = references;
|
||||
self->n_references = n_references;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
GtkCssVariableValue *
|
||||
gtk_css_variable_value_new_initial (GBytes *bytes,
|
||||
gsize offset,
|
||||
gsize end_offset)
|
||||
{
|
||||
GtkCssVariableValue *self = gtk_css_variable_value_new (bytes, offset, end_offset, 1, NULL, 0);
|
||||
|
||||
self->is_invalid = TRUE;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
GtkCssVariableValue *
|
||||
gtk_css_variable_value_ref (GtkCssVariableValue *self)
|
||||
{
|
||||
self->ref_count++;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_css_variable_value_unref (GtkCssVariableValue *self)
|
||||
{
|
||||
gsize i;
|
||||
|
||||
self->ref_count--;
|
||||
if (self->ref_count > 0)
|
||||
return;
|
||||
|
||||
g_bytes_unref (self->bytes);
|
||||
|
||||
for (i = 0; i < self->n_references; i++)
|
||||
{
|
||||
GtkCssVariableValueReference *ref = &self->references[i];
|
||||
|
||||
g_free (ref->name);
|
||||
if (ref->fallback)
|
||||
gtk_css_variable_value_unref (ref->fallback);
|
||||
}
|
||||
|
||||
if (self->section)
|
||||
gtk_css_section_unref (self->section);
|
||||
|
||||
g_free (self->references);
|
||||
g_free (self);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_css_variable_value_print (GtkCssVariableValue *self,
|
||||
GString *string)
|
||||
{
|
||||
gsize len = self->end_offset - self->offset;
|
||||
gconstpointer data = g_bytes_get_region (self->bytes, 1, self->offset, len);
|
||||
|
||||
g_assert (data != NULL);
|
||||
|
||||
g_string_append_len (string, (const char *) data, len);
|
||||
}
|
||||
|
||||
char *
|
||||
gtk_css_variable_value_to_string (GtkCssVariableValue *self)
|
||||
{
|
||||
GString *string = g_string_new (NULL);
|
||||
gtk_css_variable_value_print (self, string);
|
||||
return g_string_free (string, FALSE);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gtk_css_variable_value_equal (const GtkCssVariableValue *value1,
|
||||
const GtkCssVariableValue *value2)
|
||||
{
|
||||
if (value1 == value2)
|
||||
return TRUE;
|
||||
|
||||
if (value1 == NULL || value2 == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (value1->bytes != value2->bytes)
|
||||
return FALSE;
|
||||
|
||||
if (value1->offset != value2->offset)
|
||||
return FALSE;
|
||||
|
||||
if (value1->end_offset != value2->end_offset)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GtkCssVariableValue *
|
||||
gtk_css_variable_value_transition (GtkCssVariableValue *start,
|
||||
GtkCssVariableValue *end,
|
||||
double progress)
|
||||
{
|
||||
GtkCssVariableValue *ret = progress < 0.5 ? start : end;
|
||||
|
||||
if (ret == NULL)
|
||||
return NULL;
|
||||
|
||||
return gtk_css_variable_value_ref (ret);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_css_variable_value_set_section (GtkCssVariableValue *self,
|
||||
GtkCssSection *section)
|
||||
{
|
||||
self->section = gtk_css_section_ref (section);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_css_variable_value_taint (GtkCssVariableValue *self)
|
||||
{
|
||||
self->is_animation_tainted = TRUE;
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2023 GNOME Foundation Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Alice Mikhaylenko <alicem@gnome.org>
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "gtkcss.h"
|
||||
#include "gtkcsstokenizerprivate.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GtkCssVariableValueReference GtkCssVariableValueReference;
|
||||
typedef struct _GtkCssVariableValue GtkCssVariableValue;
|
||||
|
||||
struct _GtkCssVariableValueReference
|
||||
{
|
||||
char *name;
|
||||
gsize length;
|
||||
GtkCssVariableValue *fallback;
|
||||
};
|
||||
|
||||
struct _GtkCssVariableValue
|
||||
{
|
||||
int ref_count;
|
||||
|
||||
GBytes *bytes;
|
||||
gsize offset;
|
||||
gsize end_offset;
|
||||
gsize length;
|
||||
|
||||
GtkCssVariableValueReference *references;
|
||||
gsize n_references;
|
||||
|
||||
GtkCssSection *section;
|
||||
gboolean is_invalid;
|
||||
gboolean is_animation_tainted;
|
||||
};
|
||||
|
||||
GtkCssVariableValue *gtk_css_variable_value_new (GBytes *bytes,
|
||||
gsize offset,
|
||||
gsize end_offset,
|
||||
gsize length,
|
||||
GtkCssVariableValueReference *references,
|
||||
gsize n_references);
|
||||
GtkCssVariableValue *gtk_css_variable_value_new_initial (GBytes *bytes,
|
||||
gsize offset,
|
||||
gsize end_offset);
|
||||
GtkCssVariableValue *gtk_css_variable_value_ref (GtkCssVariableValue *self);
|
||||
void gtk_css_variable_value_unref (GtkCssVariableValue *self);
|
||||
void gtk_css_variable_value_print (GtkCssVariableValue *self,
|
||||
GString *string);
|
||||
char * gtk_css_variable_value_to_string (GtkCssVariableValue *self);
|
||||
gboolean gtk_css_variable_value_equal (const GtkCssVariableValue *value1,
|
||||
const GtkCssVariableValue *value2) G_GNUC_PURE;
|
||||
GtkCssVariableValue *gtk_css_variable_value_transition (GtkCssVariableValue *start,
|
||||
GtkCssVariableValue *end,
|
||||
double progress);
|
||||
void gtk_css_variable_value_set_section (GtkCssVariableValue *self,
|
||||
GtkCssSection *section);
|
||||
void gtk_css_variable_value_taint (GtkCssVariableValue *self);
|
||||
|
||||
G_END_DECLS
|
||||
+1
-2
@@ -6,9 +6,8 @@ gtk_css_public_sources = files([
|
||||
gtk_css_private_sources = files([
|
||||
'gtkcssdataurl.c',
|
||||
'gtkcssparser.c',
|
||||
'gtkcssserializer.c',
|
||||
'gtkcsstokenizer.c',
|
||||
'gtkcssvariablevalue.c',
|
||||
'gtkcssserializer.c',
|
||||
])
|
||||
|
||||
gtk_css_public_headers = files([
|
||||
|
||||
@@ -253,7 +253,7 @@ gtk_cell_renderer_spinner_update_size (GtkCellRendererSpinner *cell,
|
||||
node = gtk_style_context_get_node (context);
|
||||
gtk_icon_size_set_style_classes (node, priv->icon_size);
|
||||
style = gtk_css_node_get_style (node);
|
||||
priv->size = gtk_css_number_value_get (style->icon->icon_size, 100);
|
||||
priv->size = _gtk_css_number_value_get (style->icon->icon_size, 100);
|
||||
|
||||
gtk_style_context_restore (context);
|
||||
}
|
||||
|
||||
@@ -370,7 +370,7 @@ static int
|
||||
calc_indicator_size (GtkStyleContext *context)
|
||||
{
|
||||
GtkCssStyle *style = gtk_style_context_lookup_style (context);
|
||||
return gtk_css_number_value_get (style->icon->icon_size, 100);
|
||||
return _gtk_css_number_value_get (style->icon->icon_size, 100);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -778,15 +778,15 @@ gtk_style_context_resolve_color (GtkStyleContext *context,
|
||||
g_return_val_if_fail (color != NULL, FALSE);
|
||||
g_return_val_if_fail (result != NULL, FALSE);
|
||||
|
||||
val = gtk_css_color_value_resolve (color,
|
||||
GTK_STYLE_PROVIDER (priv->cascade),
|
||||
_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_COLOR));
|
||||
|
||||
val = _gtk_css_color_value_resolve (color,
|
||||
GTK_STYLE_PROVIDER (priv->cascade),
|
||||
_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_COLOR),
|
||||
NULL);
|
||||
if (val == NULL)
|
||||
return FALSE;
|
||||
|
||||
*result = *gtk_css_color_value_get_rgba (val);
|
||||
gtk_css_value_unref (val);
|
||||
_gtk_css_value_unref (val);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -860,10 +860,10 @@ gtk_style_context_get_border (GtkStyleContext *context,
|
||||
|
||||
style = gtk_style_context_lookup_style (context);
|
||||
|
||||
border->top = round (gtk_css_number_value_get (style->border->border_top_width, 100));
|
||||
border->right = round (gtk_css_number_value_get (style->border->border_right_width, 100));
|
||||
border->bottom = round (gtk_css_number_value_get (style->border->border_bottom_width, 100));
|
||||
border->left = round (gtk_css_number_value_get (style->border->border_left_width, 100));
|
||||
border->top = round (_gtk_css_number_value_get (style->border->border_top_width, 100));
|
||||
border->right = round (_gtk_css_number_value_get (style->border->border_right_width, 100));
|
||||
border->bottom = round (_gtk_css_number_value_get (style->border->border_bottom_width, 100));
|
||||
border->left = round (_gtk_css_number_value_get (style->border->border_left_width, 100));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -886,10 +886,10 @@ gtk_style_context_get_padding (GtkStyleContext *context,
|
||||
|
||||
style = gtk_style_context_lookup_style (context);
|
||||
|
||||
padding->top = round (gtk_css_number_value_get (style->size->padding_top, 100));
|
||||
padding->right = round (gtk_css_number_value_get (style->size->padding_right, 100));
|
||||
padding->bottom = round (gtk_css_number_value_get (style->size->padding_bottom, 100));
|
||||
padding->left = round (gtk_css_number_value_get (style->size->padding_left, 100));
|
||||
padding->top = round (_gtk_css_number_value_get (style->size->padding_top, 100));
|
||||
padding->right = round (_gtk_css_number_value_get (style->size->padding_right, 100));
|
||||
padding->bottom = round (_gtk_css_number_value_get (style->size->padding_bottom, 100));
|
||||
padding->left = round (_gtk_css_number_value_get (style->size->padding_left, 100));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -912,10 +912,10 @@ gtk_style_context_get_margin (GtkStyleContext *context,
|
||||
|
||||
style = gtk_style_context_lookup_style (context);
|
||||
|
||||
margin->top = round (gtk_css_number_value_get (style->size->margin_top, 100));
|
||||
margin->right = round (gtk_css_number_value_get (style->size->margin_right, 100));
|
||||
margin->bottom = round (gtk_css_number_value_get (style->size->margin_bottom, 100));
|
||||
margin->left = round (gtk_css_number_value_get (style->size->margin_left, 100));
|
||||
margin->top = round (_gtk_css_number_value_get (style->size->margin_top, 100));
|
||||
margin->right = round (_gtk_css_number_value_get (style->size->margin_right, 100));
|
||||
margin->bottom = round (_gtk_css_number_value_get (style->size->margin_bottom, 100));
|
||||
margin->left = round (_gtk_css_number_value_get (style->size->margin_left, 100));
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -2691,8 +2691,8 @@ gtk_tree_view_get_expander_size (GtkTreeView *tree_view)
|
||||
gtk_style_context_add_class (context, "expander");
|
||||
|
||||
style = gtk_style_context_lookup_style (context);
|
||||
min_width = gtk_css_number_value_get (style->size->min_width, 100);
|
||||
min_height = gtk_css_number_value_get (style->size->min_height, 100);
|
||||
min_width = _gtk_css_number_value_get (style->size->min_width, 100);
|
||||
min_height = _gtk_css_number_value_get (style->size->min_height, 100);
|
||||
|
||||
gtk_style_context_restore (context);
|
||||
|
||||
@@ -5521,7 +5521,7 @@ get_separator_height (GtkTreeView *tree_view)
|
||||
gtk_style_context_add_class (context, "separator");
|
||||
|
||||
style = gtk_style_context_lookup_style (context);
|
||||
d = gtk_css_number_value_get (style->size->min_height, 100);
|
||||
d = _gtk_css_number_value_get (style->size->min_height, 100);
|
||||
|
||||
if (d < 1)
|
||||
min_size = ceil (d);
|
||||
|
||||
@@ -808,11 +808,6 @@ static const GtkAccessibleCollect collect_props[] = {
|
||||
.ctype = GTK_ACCESSIBLE_COLLECT_STRING,
|
||||
.name = "valuetext"
|
||||
},
|
||||
[GTK_ACCESSIBLE_PROPERTY_HELP_TEXT] = {
|
||||
.value = GTK_ACCESSIBLE_PROPERTY_HELP_TEXT,
|
||||
.ctype = GTK_ACCESSIBLE_COLLECT_STRING,
|
||||
.name = "helptext"
|
||||
},
|
||||
};
|
||||
|
||||
/* § 6.6.4 Relationship Attributes */
|
||||
@@ -1667,7 +1662,7 @@ gtk_accessible_value_get_default_for_property (GtkAccessibleProperty property)
|
||||
{
|
||||
const GtkAccessibleCollect *cstate = &collect_props[property];
|
||||
|
||||
g_return_val_if_fail (property <= GTK_ACCESSIBLE_PROPERTY_HELP_TEXT, NULL);
|
||||
g_return_val_if_fail (property <= GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT, NULL);
|
||||
|
||||
switch (cstate->value)
|
||||
{
|
||||
@@ -1697,7 +1692,6 @@ gtk_accessible_value_get_default_for_property (GtkAccessibleProperty property)
|
||||
case GTK_ACCESSIBLE_PROPERTY_PLACEHOLDER:
|
||||
case GTK_ACCESSIBLE_PROPERTY_ROLE_DESCRIPTION:
|
||||
case GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT:
|
||||
case GTK_ACCESSIBLE_PROPERTY_HELP_TEXT:
|
||||
return gtk_undefined_accessible_value_new ();
|
||||
|
||||
/* Token properties */
|
||||
@@ -1738,7 +1732,7 @@ gtk_accessible_value_collect_for_property (GtkAccessibleProperty property,
|
||||
{
|
||||
const GtkAccessibleCollect *cstate = &collect_props[property];
|
||||
|
||||
g_return_val_if_fail (property <= GTK_ACCESSIBLE_PROPERTY_HELP_TEXT, NULL);
|
||||
g_return_val_if_fail (property <= GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT, NULL);
|
||||
|
||||
return gtk_accessible_value_collect_valist (cstate, error, args);
|
||||
}
|
||||
@@ -1766,7 +1760,7 @@ gtk_accessible_value_collect_for_property_value (GtkAccessibleProperty propert
|
||||
{
|
||||
const GtkAccessibleCollect *cstate = &collect_props[property];
|
||||
|
||||
g_return_val_if_fail (property <= GTK_ACCESSIBLE_PROPERTY_HELP_TEXT, NULL);
|
||||
g_return_val_if_fail (property <= GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT, NULL);
|
||||
|
||||
return gtk_accessible_value_collect_value (cstate, value, error);
|
||||
}
|
||||
@@ -1779,7 +1773,7 @@ gtk_accessible_value_parse_for_property (GtkAccessibleProperty property,
|
||||
{
|
||||
const GtkAccessibleCollect *cstate = &collect_props[property];
|
||||
|
||||
g_return_val_if_fail (property <= GTK_ACCESSIBLE_PROPERTY_HELP_TEXT, NULL);
|
||||
g_return_val_if_fail (property <= GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT, NULL);
|
||||
|
||||
return gtk_accessible_value_parse (cstate, str, len, error);
|
||||
}
|
||||
@@ -1800,7 +1794,7 @@ gtk_accessible_property_init_value (GtkAccessibleProperty property,
|
||||
{
|
||||
const GtkAccessibleCollect *cstate = &collect_props[property];
|
||||
|
||||
g_return_if_fail (property <= GTK_ACCESSIBLE_PROPERTY_HELP_TEXT);
|
||||
g_return_if_fail (property <= GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT);
|
||||
|
||||
gtk_accessible_attribute_init_value (cstate, value);
|
||||
}
|
||||
|
||||
@@ -76,19 +76,13 @@ G_DEFINE_TYPE (GtkApplicationImplQuartz, gtk_application_impl_quartz, GTK_TYPE_A
|
||||
|
||||
-(NSApplicationTerminateReply) applicationShouldTerminate:(NSApplication *)sender
|
||||
{
|
||||
const gchar *quit_action_name = "quit";
|
||||
GActionGroup *action_group = G_ACTION_GROUP (quartz->impl.application);
|
||||
|
||||
if (quartz->quit_inhibit != 0)
|
||||
return NSTerminateCancel;
|
||||
|
||||
if (g_action_group_has_action (action_group, quit_action_name))
|
||||
{
|
||||
g_action_group_activate_action (action_group, quit_action_name, NULL);
|
||||
return NSTerminateCancel;
|
||||
}
|
||||
|
||||
return NSTerminateNow;
|
||||
/* We have no way to give our message other than to pop up a dialog
|
||||
* ourselves, which we should not do since the OS will already show
|
||||
* one when we return NSTerminateNow.
|
||||
*
|
||||
* Just let the OS show the generic message...
|
||||
*/
|
||||
return quartz->quit_inhibit == 0 ? NSTerminateNow : NSTerminateCancel;
|
||||
}
|
||||
|
||||
-(void)application:(NSApplication *)theApplication openFiles:(NSArray *)filenames
|
||||
|
||||
+1
-2
@@ -328,7 +328,6 @@ static const char *property_attrs[] = {
|
||||
[GTK_ACCESSIBLE_PROPERTY_VALUE_MIN] = "valuemin",
|
||||
[GTK_ACCESSIBLE_PROPERTY_VALUE_NOW] = "valuenow",
|
||||
[GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT] = "valuetext",
|
||||
[GTK_ACCESSIBLE_PROPERTY_HELP_TEXT] = "helptext",
|
||||
};
|
||||
|
||||
/*< private >
|
||||
@@ -343,7 +342,7 @@ const char *
|
||||
gtk_accessible_property_get_attribute_name (GtkAccessibleProperty property)
|
||||
{
|
||||
g_return_val_if_fail (property >= GTK_ACCESSIBLE_PROPERTY_AUTOCOMPLETE &&
|
||||
property <= GTK_ACCESSIBLE_PROPERTY_HELP_TEXT,
|
||||
property <= GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT,
|
||||
"<none>");
|
||||
|
||||
return property_attrs[property];
|
||||
|
||||
@@ -47,8 +47,7 @@ typedef enum {
|
||||
GTK_ACCESSIBLE_PROPERTY_CHANGE_VALUE_MAX = 1 << GTK_ACCESSIBLE_PROPERTY_VALUE_MAX,
|
||||
GTK_ACCESSIBLE_PROPERTY_CHANGE_VALUE_MIN = 1 << GTK_ACCESSIBLE_PROPERTY_VALUE_MIN,
|
||||
GTK_ACCESSIBLE_PROPERTY_CHANGE_VALUE_NOW = 1 << GTK_ACCESSIBLE_PROPERTY_VALUE_NOW,
|
||||
GTK_ACCESSIBLE_PROPERTY_CHANGE_VALUE_TEXT = 1 << GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT,
|
||||
GTK_ACCESSIBLE_PROPERTY_CHANGE_HELP_TEXT = 1 << GTK_ACCESSIBLE_PROPERTY_HELP_TEXT,
|
||||
GTK_ACCESSIBLE_PROPERTY_CHANGE_VALUE_TEXT = 1 << GTK_ACCESSIBLE_PROPERTY_VALUE_TEXT
|
||||
} GtkAccessiblePropertyChange;
|
||||
|
||||
typedef enum {
|
||||
|
||||
@@ -32,12 +32,8 @@
|
||||
* `GtkBuilderListItemFactory` is a `GtkListItemFactory` that creates
|
||||
* widgets by instantiating `GtkBuilder` UI templates.
|
||||
*
|
||||
* The templates must extend the class that the parent widget expects.
|
||||
* For example, a factory provided to [property@Gtk.ListView:factory] must have
|
||||
* a template that extends [class@Gtk.ListItem].
|
||||
*
|
||||
* Templates typically use `GtkExpression`s to obtain data from the items
|
||||
* in the model.
|
||||
* The templates must be extending `GtkListItem`, and typically use
|
||||
* `GtkExpression`s to obtain data from the items in the model.
|
||||
*
|
||||
* Example:
|
||||
* ```xml
|
||||
@@ -207,7 +203,7 @@ gtk_builder_list_item_factory_set_property (GObject *object,
|
||||
case PROP_RESOURCE:
|
||||
{
|
||||
GError *error = NULL;
|
||||
GBytes *bytes;
|
||||
GBytes *bytes;
|
||||
const char *resource;
|
||||
|
||||
resource = g_value_get_string (value);
|
||||
|
||||
@@ -84,7 +84,7 @@ gtk_builtin_icon_measure (GtkWidget *widget,
|
||||
|
||||
style = gtk_css_node_get_style (gtk_widget_get_css_node (widget));
|
||||
|
||||
*minimum = *natural = gtk_css_number_value_get (style->icon->icon_size, 100);
|
||||
*minimum = *natural = _gtk_css_number_value_get (style->icon->icon_size, 100);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
+1
-7
@@ -861,8 +861,6 @@ gtk_column_view_class_init (GtkColumnViewClass *klass)
|
||||
*
|
||||
* The factory used for configuring rows.
|
||||
*
|
||||
* The factory must be for configuring [class@Gtk.ColumnViewRow] objects.
|
||||
*
|
||||
* Since: 4.12
|
||||
*/
|
||||
properties[PROP_ROW_FACTORY] =
|
||||
@@ -928,8 +926,6 @@ gtk_column_view_class_init (GtkColumnViewClass *klass)
|
||||
*
|
||||
* Factory for creating header widgets.
|
||||
*
|
||||
* The factory must be for configuring [class@Gtk.ListHeader] objects.
|
||||
*
|
||||
* Since: 4.12
|
||||
*/
|
||||
properties[PROP_HEADER_FACTORY] =
|
||||
@@ -2188,8 +2184,7 @@ gtk_column_view_set_header_factory (GtkColumnView *self,
|
||||
/**
|
||||
* gtk_column_view_scroll_to:
|
||||
* @self: The columnview to scroll in
|
||||
* @pos: position of the item. Must be less than the number of
|
||||
* items in the view.
|
||||
* @pos: position of the item
|
||||
* @column: (nullable) (transfer none): The column to scroll to
|
||||
* or %NULL to not scroll columns.
|
||||
* @flags: actions to perform
|
||||
@@ -2212,7 +2207,6 @@ gtk_column_view_scroll_to (GtkColumnView *self,
|
||||
GtkScrollInfo *scroll)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_COLUMN_VIEW (self));
|
||||
g_return_if_fail (pos < gtk_list_base_get_n_items (GTK_LIST_BASE (self->listview)));
|
||||
g_return_if_fail (column == NULL || GTK_IS_COLUMN_VIEW_COLUMN (column));
|
||||
if (column)
|
||||
{
|
||||
|
||||
@@ -255,8 +255,6 @@ gtk_column_view_column_class_init (GtkColumnViewColumnClass *klass)
|
||||
* GtkColumnViewColumn:factory: (attributes org.gtk.Property.get=gtk_column_view_column_get_factory org.gtk.Property.set=gtk_column_view_column_set_factory)
|
||||
*
|
||||
* Factory for populating list items.
|
||||
*
|
||||
* The factory must be for configuring [class@Gtk.ColumnViewCell] objects.
|
||||
*/
|
||||
properties[PROP_FACTORY] =
|
||||
g_param_spec_object ("factory", NULL, NULL,
|
||||
@@ -763,7 +761,7 @@ gtk_column_view_column_remove_from_sorter (GtkColumnViewColumn *self)
|
||||
{
|
||||
if (self->view == NULL)
|
||||
return;
|
||||
|
||||
|
||||
gtk_column_view_sorter_remove_column (GTK_COLUMN_VIEW_SORTER (gtk_column_view_get_sorter (self->view)), self);
|
||||
}
|
||||
|
||||
|
||||
+16
-213
@@ -33,99 +33,13 @@
|
||||
#include "gtkcssstringvalueprivate.h"
|
||||
#include "gtkcssstylepropertyprivate.h"
|
||||
#include "gtkcsstransitionprivate.h"
|
||||
#include "gtkcssvaluesprivate.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkstyleanimationprivate.h"
|
||||
#include "gtkstylepropertyprivate.h"
|
||||
#include "gtkstyleproviderprivate.h"
|
||||
#include "gtkcsscustompropertypoolprivate.h"
|
||||
|
||||
G_DEFINE_TYPE (GtkCssAnimatedStyle, gtk_css_animated_style, GTK_TYPE_CSS_STYLE)
|
||||
|
||||
static inline gboolean
|
||||
property_has_color (guint id)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case GTK_CSS_PROPERTY_COLOR:
|
||||
case GTK_CSS_PROPERTY_ICON_PALETTE:
|
||||
case GTK_CSS_PROPERTY_TEXT_DECORATION_COLOR:
|
||||
case GTK_CSS_PROPERTY_TEXT_SHADOW:
|
||||
case GTK_CSS_PROPERTY_BOX_SHADOW:
|
||||
case GTK_CSS_PROPERTY_BORDER_TOP_COLOR:
|
||||
case GTK_CSS_PROPERTY_BORDER_RIGHT_COLOR:
|
||||
case GTK_CSS_PROPERTY_BORDER_BOTTOM_COLOR:
|
||||
case GTK_CSS_PROPERTY_BORDER_LEFT_COLOR:
|
||||
case GTK_CSS_PROPERTY_OUTLINE_COLOR:
|
||||
case GTK_CSS_PROPERTY_BACKGROUND_IMAGE:
|
||||
case GTK_CSS_PROPERTY_ICON_SOURCE:
|
||||
case GTK_CSS_PROPERTY_ICON_SHADOW:
|
||||
case GTK_CSS_PROPERTY_CARET_COLOR:
|
||||
case GTK_CSS_PROPERTY_SECONDARY_CARET_COLOR:
|
||||
return TRUE;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
#define DEFINE_VALUES(ENUM, TYPE, NAME) \
|
||||
static inline void \
|
||||
gtk_css_ ## NAME ## _values_recompute (GtkCssAnimatedStyle *animated, \
|
||||
GtkCssComputeContext *context, \
|
||||
GtkCssAnimationChange change) \
|
||||
{ \
|
||||
GtkCssStyle *style = (GtkCssStyle *)animated; \
|
||||
GtkCssValue **values = (GtkCssValue **)((guint8*)(animated->style->NAME) + sizeof (GtkCssValues)); \
|
||||
int i; \
|
||||
\
|
||||
for (i = 0; i < G_N_ELEMENTS (NAME ## _props); i++) \
|
||||
{ \
|
||||
guint id = NAME ## _props[i]; \
|
||||
GtkCssValue *original, *computed; \
|
||||
gboolean needs_recompute = FALSE; \
|
||||
\
|
||||
if (values[i] == NULL) \
|
||||
continue; \
|
||||
\
|
||||
original = gtk_css_style_get_original_value (style, id); \
|
||||
if (original == NULL) \
|
||||
continue; \
|
||||
\
|
||||
if ((change & GTK_CSS_ANIMATION_CHANGE_VARIABLES) && \
|
||||
gtk_css_value_contains_variables (original)) \
|
||||
needs_recompute = TRUE; \
|
||||
\
|
||||
if ((change & GTK_CSS_ANIMATION_CHANGE_COLOR) && \
|
||||
property_has_color (id)) \
|
||||
needs_recompute = TRUE; \
|
||||
\
|
||||
if (!needs_recompute) \
|
||||
continue; \
|
||||
\
|
||||
computed = gtk_css_value_compute (original, \
|
||||
id, \
|
||||
context); \
|
||||
if (computed == NULL) \
|
||||
continue; \
|
||||
\
|
||||
gtk_css_animated_style_set_animated_value (animated, id, computed); \
|
||||
\
|
||||
if (id == GTK_CSS_PROPERTY_COLOR) \
|
||||
change |= GTK_CSS_ANIMATION_CHANGE_COLOR; \
|
||||
} \
|
||||
}
|
||||
|
||||
DEFINE_VALUES (CORE, Core, core)
|
||||
DEFINE_VALUES (BACKGROUND, Background, background)
|
||||
DEFINE_VALUES (BORDER, Border, border)
|
||||
DEFINE_VALUES (ICON, Icon, icon)
|
||||
DEFINE_VALUES (OUTLINE, Outline, outline)
|
||||
DEFINE_VALUES (FONT, Font, font)
|
||||
DEFINE_VALUES (FONT_VARIANT, FontVariant, font_variant)
|
||||
DEFINE_VALUES (ANIMATION, Animation, animation)
|
||||
DEFINE_VALUES (TRANSITION, Transition, transition)
|
||||
DEFINE_VALUES (SIZE, Size, size)
|
||||
DEFINE_VALUES (OTHER, Other, other)
|
||||
|
||||
static GtkCssSection *
|
||||
gtk_css_animated_style_get_section (GtkCssStyle *style,
|
||||
@@ -160,15 +74,6 @@ gtk_css_animated_style_get_static_style (GtkCssStyle *style)
|
||||
return (GtkCssStaticStyle *)animated->style;
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
gtk_css_animated_style_get_original_value (GtkCssStyle *style,
|
||||
guint id)
|
||||
{
|
||||
GtkCssAnimatedStyle *animated = GTK_CSS_ANIMATED_STYLE (style);
|
||||
|
||||
return gtk_css_style_get_original_value (animated->style, id);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_animated_style_dispose (GObject *object)
|
||||
{
|
||||
@@ -191,9 +96,6 @@ gtk_css_animated_style_finalize (GObject *object)
|
||||
GtkCssAnimatedStyle *style = GTK_CSS_ANIMATED_STYLE (object);
|
||||
|
||||
g_object_unref (style->style);
|
||||
if (style->parent_style)
|
||||
g_object_unref (style->parent_style);
|
||||
g_object_unref (style->provider);
|
||||
|
||||
G_OBJECT_CLASS (gtk_css_animated_style_parent_class)->finalize (object);
|
||||
}
|
||||
@@ -210,7 +112,6 @@ gtk_css_animated_style_class_init (GtkCssAnimatedStyleClass *klass)
|
||||
style_class->get_section = gtk_css_animated_style_get_section;
|
||||
style_class->is_static = gtk_css_animated_style_is_static;
|
||||
style_class->get_static_style = gtk_css_animated_style_get_static_style;
|
||||
style_class->get_original_value = gtk_css_animated_style_get_original_value;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -645,70 +546,6 @@ gtk_css_animated_style_get_intrinsic_value (GtkCssAnimatedStyle *style,
|
||||
return gtk_css_style_get_value (style->style, id);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_css_animated_style_set_animated_custom_value (GtkCssAnimatedStyle *animated,
|
||||
int id,
|
||||
GtkCssVariableValue *value)
|
||||
{
|
||||
GtkCssStyle *style = (GtkCssStyle *)animated;
|
||||
|
||||
gtk_internal_return_if_fail (GTK_IS_CSS_ANIMATED_STYLE (style));
|
||||
gtk_internal_return_if_fail (value != NULL);
|
||||
|
||||
if (style->variables == NULL)
|
||||
{
|
||||
style->variables = gtk_css_variable_set_new ();
|
||||
if (animated->parent_style)
|
||||
gtk_css_variable_set_set_parent (style->variables,
|
||||
animated->parent_style->variables);
|
||||
}
|
||||
else if (style->variables == animated->style->variables)
|
||||
{
|
||||
gtk_css_variable_set_unref (style->variables);
|
||||
style->variables = gtk_css_variable_set_copy (animated->style->variables);
|
||||
}
|
||||
|
||||
gtk_css_variable_set_add (style->variables, id, value);
|
||||
}
|
||||
|
||||
void
|
||||
gtk_css_animated_style_recompute (GtkCssAnimatedStyle *style,
|
||||
GtkCssAnimationChange change)
|
||||
{
|
||||
GtkCssComputeContext context = { NULL, };
|
||||
GtkCssValue *shorthands[GTK_CSS_SHORTHAND_PROPERTY_N_PROPERTIES] = { NULL, };
|
||||
|
||||
context.provider = style->provider;
|
||||
context.style = style->style;
|
||||
context.parent_style = style->parent_style;
|
||||
context.shorthands = shorthands;
|
||||
|
||||
gtk_css_core_values_recompute (style, &context, change);
|
||||
gtk_css_background_values_recompute (style, &context, change);
|
||||
gtk_css_border_values_recompute (style, &context, change);
|
||||
gtk_css_icon_values_recompute (style, &context, change);
|
||||
gtk_css_outline_values_recompute (style, &context, change);
|
||||
gtk_css_font_values_recompute (style, &context, change);
|
||||
gtk_css_font_variant_values_recompute (style, &context, change);
|
||||
gtk_css_animation_values_recompute (style, &context, change);
|
||||
gtk_css_transition_values_recompute (style, &context, change);
|
||||
gtk_css_size_values_recompute (style, &context, change);
|
||||
gtk_css_other_values_recompute (style, &context, change);
|
||||
|
||||
for (unsigned int i = 0; i < GTK_CSS_SHORTHAND_PROPERTY_N_PROPERTIES; i++)
|
||||
{
|
||||
if (shorthands[i])
|
||||
gtk_css_value_unref (shorthands[i]);
|
||||
}
|
||||
}
|
||||
|
||||
GtkCssVariableValue *
|
||||
gtk_css_animated_style_get_intrinsic_custom_value (GtkCssAnimatedStyle *style,
|
||||
int id)
|
||||
{
|
||||
return gtk_css_style_get_custom_property (style->style, id);
|
||||
}
|
||||
|
||||
static GPtrArray *
|
||||
gtk_css_animated_style_create_dynamic (GPtrArray *animations,
|
||||
GtkCssStyle *style,
|
||||
@@ -848,8 +685,8 @@ gtk_css_animated_style_create_css_transitions (GPtrArray *animations,
|
||||
|
||||
if (_gtk_css_array_value_get_n_values (durations) == 1 &&
|
||||
_gtk_css_array_value_get_n_values (delays) == 1 &&
|
||||
gtk_css_number_value_get (_gtk_css_array_value_get_nth (durations, 0), 100) +
|
||||
gtk_css_number_value_get (_gtk_css_array_value_get_nth (delays, 0), 100) == 0)
|
||||
_gtk_css_number_value_get (_gtk_css_array_value_get_nth (durations, 0), 100) +
|
||||
_gtk_css_number_value_get (_gtk_css_array_value_get_nth (delays, 0), 100) == 0)
|
||||
return animations;
|
||||
|
||||
transition_infos_set (transitions, base_style->transition->transition_property);
|
||||
@@ -864,8 +701,8 @@ gtk_css_animated_style_create_css_transitions (GPtrArray *animations,
|
||||
if (!transitions[i].pending)
|
||||
continue;
|
||||
|
||||
duration = gtk_css_number_value_get (_gtk_css_array_value_get_nth (durations, transitions[i].index), 100);
|
||||
delay = gtk_css_number_value_get (_gtk_css_array_value_get_nth (delays, transitions[i].index), 100);
|
||||
duration = _gtk_css_number_value_get (_gtk_css_array_value_get_nth (durations, transitions[i].index), 100);
|
||||
delay = _gtk_css_number_value_get (_gtk_css_array_value_get_nth (delays, transitions[i].index), 100);
|
||||
if (duration + delay == 0.0)
|
||||
continue;
|
||||
|
||||
@@ -874,7 +711,7 @@ gtk_css_animated_style_create_css_transitions (GPtrArray *animations,
|
||||
start = gtk_css_animated_style_get_intrinsic_value ((GtkCssAnimatedStyle *)source, i);
|
||||
end = gtk_css_style_get_value (base_style, i);
|
||||
|
||||
if (gtk_css_value_equal (start, end))
|
||||
if (_gtk_css_value_equal (start, end))
|
||||
{
|
||||
animation = gtk_css_animated_style_find_transition ((GtkCssAnimatedStyle *)source, i);
|
||||
if (animation)
|
||||
@@ -890,8 +727,8 @@ gtk_css_animated_style_create_css_transitions (GPtrArray *animations,
|
||||
}
|
||||
}
|
||||
|
||||
if (gtk_css_value_equal (gtk_css_style_get_value (source, i),
|
||||
gtk_css_style_get_value (base_style, i)))
|
||||
if (_gtk_css_value_equal (gtk_css_style_get_value (source, i),
|
||||
gtk_css_style_get_value (base_style, i)))
|
||||
continue;
|
||||
|
||||
animation = _gtk_css_transition_new (i,
|
||||
@@ -933,6 +770,7 @@ gtk_css_animated_style_find_animation (GtkStyleAnimation **animations,
|
||||
static GPtrArray *
|
||||
gtk_css_animated_style_create_css_animations (GPtrArray *animations,
|
||||
GtkCssStyle *base_style,
|
||||
GtkCssStyle *parent_style,
|
||||
gint64 timestamp,
|
||||
GtkStyleProvider *provider,
|
||||
GtkCssStyle *source)
|
||||
@@ -994,16 +832,19 @@ gtk_css_animated_style_create_css_animations (GPtrArray *animations,
|
||||
if (keyframes == NULL)
|
||||
continue;
|
||||
|
||||
keyframes = _gtk_css_keyframes_compute (keyframes, provider, base_style, parent_style);
|
||||
|
||||
animation = _gtk_css_animation_new (name,
|
||||
keyframes,
|
||||
timestamp,
|
||||
gtk_css_number_value_get (_gtk_css_array_value_get_nth (delays, i), 100) * G_USEC_PER_SEC,
|
||||
gtk_css_number_value_get (_gtk_css_array_value_get_nth (durations, i), 100) * G_USEC_PER_SEC,
|
||||
_gtk_css_number_value_get (_gtk_css_array_value_get_nth (delays, i), 100) * G_USEC_PER_SEC,
|
||||
_gtk_css_number_value_get (_gtk_css_array_value_get_nth (durations, i), 100) * G_USEC_PER_SEC,
|
||||
_gtk_css_array_value_get_nth (timing_functions, i),
|
||||
_gtk_css_direction_value_get (_gtk_css_array_value_get_nth (directions, i)),
|
||||
_gtk_css_play_state_value_get (_gtk_css_array_value_get_nth (play_states, i)),
|
||||
_gtk_css_fill_mode_value_get (_gtk_css_array_value_get_nth (fill_modes, i)),
|
||||
gtk_css_number_value_get (_gtk_css_array_value_get_nth (iteration_counts, i), 100));
|
||||
_gtk_css_number_value_get (_gtk_css_array_value_get_nth (iteration_counts, i), 100));
|
||||
_gtk_css_keyframes_unref (keyframes);
|
||||
}
|
||||
|
||||
if (!animations)
|
||||
@@ -1052,7 +893,7 @@ gtk_css_animated_style_new (GtkCssStyle *base_style,
|
||||
if (previous_style != NULL)
|
||||
animations = gtk_css_animated_style_create_css_transitions (animations, base_style, timestamp, previous_style);
|
||||
|
||||
animations = gtk_css_animated_style_create_css_animations (animations, base_style, timestamp, provider, previous_style);
|
||||
animations = gtk_css_animated_style_create_css_animations (animations, base_style, parent_style, timestamp, provider, previous_style);
|
||||
animations = gtk_css_animated_style_create_dynamic (animations, base_style, timestamp);
|
||||
|
||||
if (animations == NULL)
|
||||
@@ -1061,9 +902,6 @@ gtk_css_animated_style_new (GtkCssStyle *base_style,
|
||||
result = g_object_new (GTK_TYPE_CSS_ANIMATED_STYLE, NULL);
|
||||
|
||||
result->style = g_object_ref (base_style);
|
||||
if (parent_style)
|
||||
result->parent_style = g_object_ref (parent_style);
|
||||
result->provider = g_object_ref (provider);
|
||||
result->current_time = timestamp;
|
||||
result->n_animations = animations->len;
|
||||
result->animations = g_ptr_array_free (animations, FALSE);
|
||||
@@ -1080,8 +918,6 @@ gtk_css_animated_style_new (GtkCssStyle *base_style,
|
||||
style->transition = (GtkCssTransitionValues *)gtk_css_values_ref ((GtkCssValues *)base_style->transition);
|
||||
style->size = (GtkCssSizeValues *)gtk_css_values_ref ((GtkCssValues *)base_style->size);
|
||||
style->other = (GtkCssOtherValues *)gtk_css_values_ref ((GtkCssValues *)base_style->other);
|
||||
if (base_style->variables)
|
||||
style->variables = gtk_css_variable_set_ref (base_style->variables);
|
||||
|
||||
gtk_css_animated_style_apply_animations (result);
|
||||
|
||||
@@ -1091,9 +927,7 @@ gtk_css_animated_style_new (GtkCssStyle *base_style,
|
||||
GtkCssStyle *
|
||||
gtk_css_animated_style_new_advance (GtkCssAnimatedStyle *source,
|
||||
GtkCssStyle *base_style,
|
||||
GtkCssStyle *parent_style,
|
||||
gint64 timestamp,
|
||||
GtkStyleProvider *provider)
|
||||
gint64 timestamp)
|
||||
{
|
||||
GtkCssAnimatedStyle *result;
|
||||
GtkCssStyle *style;
|
||||
@@ -1102,8 +936,6 @@ gtk_css_animated_style_new_advance (GtkCssAnimatedStyle *source,
|
||||
|
||||
gtk_internal_return_val_if_fail (GTK_IS_CSS_ANIMATED_STYLE (source), NULL);
|
||||
gtk_internal_return_val_if_fail (GTK_IS_CSS_STYLE (base_style), NULL);
|
||||
gtk_internal_return_val_if_fail (parent_style == NULL || GTK_IS_CSS_STYLE (parent_style), NULL);
|
||||
gtk_internal_return_val_if_fail (GTK_IS_STYLE_PROVIDER (provider), NULL);
|
||||
|
||||
if (timestamp == 0)
|
||||
return g_object_ref (source->style);
|
||||
@@ -1134,9 +966,6 @@ gtk_css_animated_style_new_advance (GtkCssAnimatedStyle *source,
|
||||
result = g_object_new (GTK_TYPE_CSS_ANIMATED_STYLE, NULL);
|
||||
|
||||
result->style = g_object_ref (base_style);
|
||||
if (parent_style)
|
||||
result->parent_style = g_object_ref (parent_style);
|
||||
result->provider = g_object_ref (provider);
|
||||
result->current_time = timestamp;
|
||||
result->n_animations = animations->len;
|
||||
result->animations = g_ptr_array_free (animations, FALSE);
|
||||
@@ -1153,34 +982,8 @@ gtk_css_animated_style_new_advance (GtkCssAnimatedStyle *source,
|
||||
style->transition = (GtkCssTransitionValues *)gtk_css_values_ref ((GtkCssValues *)base_style->transition);
|
||||
style->size = (GtkCssSizeValues *)gtk_css_values_ref ((GtkCssValues *)base_style->size);
|
||||
style->other = (GtkCssOtherValues *)gtk_css_values_ref ((GtkCssValues *)base_style->other);
|
||||
if (base_style->variables)
|
||||
style->variables = gtk_css_variable_set_ref (base_style->variables);
|
||||
|
||||
gtk_css_animated_style_apply_animations (result);
|
||||
|
||||
return GTK_CSS_STYLE (result);
|
||||
}
|
||||
|
||||
GtkCssStyle *
|
||||
gtk_css_animated_style_get_base_style (GtkCssAnimatedStyle *style)
|
||||
{
|
||||
gtk_internal_return_val_if_fail (GTK_IS_CSS_ANIMATED_STYLE (style), NULL);
|
||||
|
||||
return style->style;
|
||||
}
|
||||
|
||||
GtkCssStyle *
|
||||
gtk_css_animated_style_get_parent_style (GtkCssAnimatedStyle *style)
|
||||
{
|
||||
gtk_internal_return_val_if_fail (GTK_IS_CSS_ANIMATED_STYLE (style), NULL);
|
||||
|
||||
return style->parent_style;
|
||||
}
|
||||
|
||||
GtkStyleProvider *
|
||||
gtk_css_animated_style_get_provider (GtkCssAnimatedStyle *style)
|
||||
{
|
||||
gtk_internal_return_val_if_fail (GTK_IS_CSS_ANIMATED_STYLE (style), NULL);
|
||||
|
||||
return style->provider;
|
||||
}
|
||||
|
||||
@@ -38,8 +38,6 @@ struct _GtkCssAnimatedStyle
|
||||
GtkCssStyle parent;
|
||||
|
||||
GtkCssStyle *style; /* the style if we weren't animating */
|
||||
GtkCssStyle *parent_style;
|
||||
GtkStyleProvider *provider;
|
||||
|
||||
gint64 current_time; /* the current time in our world */
|
||||
gpointer *animations; /* GtkStyleAnimation**, least important one first */
|
||||
@@ -59,34 +57,15 @@ GtkCssStyle * gtk_css_animated_style_new (GtkCssStyle
|
||||
GtkStyleProvider *provider,
|
||||
GtkCssStyle *previous_style);
|
||||
GtkCssStyle * gtk_css_animated_style_new_advance (GtkCssAnimatedStyle *source,
|
||||
GtkCssStyle *base_style,
|
||||
GtkCssStyle *parent_style,
|
||||
gint64 timestamp,
|
||||
GtkStyleProvider *provider);
|
||||
GtkCssStyle *base,
|
||||
gint64 timestamp);
|
||||
|
||||
void gtk_css_animated_style_set_animated_value(GtkCssAnimatedStyle *style,
|
||||
guint id,
|
||||
GtkCssValue *value);
|
||||
|
||||
GtkCssValue * gtk_css_animated_style_get_intrinsic_value (GtkCssAnimatedStyle *style,
|
||||
guint id);
|
||||
|
||||
void gtk_css_animated_style_set_animated_custom_value (GtkCssAnimatedStyle *animated,
|
||||
int id,
|
||||
GtkCssVariableValue *value);
|
||||
|
||||
typedef enum {
|
||||
GTK_CSS_ANIMATION_CHANGE_VARIABLES = 1 << 0,
|
||||
GTK_CSS_ANIMATION_CHANGE_COLOR = 1 << 1,
|
||||
} GtkCssAnimationChange;
|
||||
|
||||
void gtk_css_animated_style_recompute (GtkCssAnimatedStyle *style,
|
||||
GtkCssAnimationChange change);
|
||||
GtkCssVariableValue * gtk_css_animated_style_get_intrinsic_custom_value (GtkCssAnimatedStyle *style,
|
||||
int id);
|
||||
|
||||
GtkCssStyle * gtk_css_animated_style_get_base_style (GtkCssAnimatedStyle *style);
|
||||
GtkCssStyle * gtk_css_animated_style_get_parent_style (GtkCssAnimatedStyle *style);
|
||||
GtkStyleProvider * gtk_css_animated_style_get_provider (GtkCssAnimatedStyle *style);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
+7
-49
@@ -90,12 +90,8 @@ gtk_css_animation_apply_values (GtkStyleAnimation *style_animation,
|
||||
GtkCssAnimatedStyle *style)
|
||||
{
|
||||
GtkCssAnimation *animation = (GtkCssAnimation *)style_animation;
|
||||
GtkCssStyle *base_style, *parent_style;
|
||||
GtkStyleProvider *provider;
|
||||
GtkCssKeyframes *resolved_keyframes;
|
||||
double progress;
|
||||
guint i;
|
||||
GtkCssAnimationChange change = 0;
|
||||
|
||||
if (!gtk_css_animation_is_executing (animation))
|
||||
return;
|
||||
@@ -103,57 +99,19 @@ gtk_css_animation_apply_values (GtkStyleAnimation *style_animation,
|
||||
progress = gtk_css_animation_get_progress (animation);
|
||||
progress = _gtk_css_ease_value_transform (animation->ease, progress);
|
||||
|
||||
base_style = gtk_css_animated_style_get_base_style (style);
|
||||
parent_style = gtk_css_animated_style_get_parent_style (style);
|
||||
provider = gtk_css_animated_style_get_provider (style);
|
||||
resolved_keyframes = _gtk_css_keyframes_compute (animation->keyframes,
|
||||
provider,
|
||||
base_style,
|
||||
parent_style);
|
||||
|
||||
for (i = 0; i < _gtk_css_keyframes_get_n_variables (resolved_keyframes); i++)
|
||||
{
|
||||
GtkCssVariableValue *value;
|
||||
int variable_id;
|
||||
|
||||
variable_id = _gtk_css_keyframes_get_variable_id (resolved_keyframes, i);
|
||||
|
||||
value = _gtk_css_keyframes_get_variable (resolved_keyframes,
|
||||
i,
|
||||
progress,
|
||||
gtk_css_animated_style_get_intrinsic_custom_value (style, variable_id));
|
||||
|
||||
if (!value)
|
||||
continue;
|
||||
|
||||
gtk_css_animated_style_set_animated_custom_value (style, variable_id, value);
|
||||
|
||||
gtk_css_variable_value_unref (value);
|
||||
|
||||
change |= GTK_CSS_ANIMATION_CHANGE_VARIABLES;
|
||||
}
|
||||
|
||||
for (i = 0; i < _gtk_css_keyframes_get_n_properties (resolved_keyframes); i++)
|
||||
for (i = 0; i < _gtk_css_keyframes_get_n_properties (animation->keyframes); i++)
|
||||
{
|
||||
GtkCssValue *value;
|
||||
guint property_id;
|
||||
|
||||
property_id = _gtk_css_keyframes_get_property_id (animation->keyframes, i);
|
||||
|
||||
property_id = _gtk_css_keyframes_get_property_id (resolved_keyframes, i);
|
||||
|
||||
value = _gtk_css_keyframes_get_value (resolved_keyframes,
|
||||
value = _gtk_css_keyframes_get_value (animation->keyframes,
|
||||
i,
|
||||
progress,
|
||||
gtk_css_animated_style_get_intrinsic_value (style, property_id));
|
||||
gtk_css_animated_style_set_animated_value (style, property_id, value);
|
||||
|
||||
if (property_id == GTK_CSS_PROPERTY_COLOR)
|
||||
change |= GTK_CSS_ANIMATION_CHANGE_COLOR;
|
||||
}
|
||||
|
||||
if (change != 0)
|
||||
gtk_css_animated_style_recompute (style, change);
|
||||
|
||||
_gtk_css_keyframes_unref (resolved_keyframes);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -180,7 +138,7 @@ gtk_css_animation_free (GtkStyleAnimation *animation)
|
||||
|
||||
g_free (self->name);
|
||||
_gtk_css_keyframes_unref (self->keyframes);
|
||||
gtk_css_value_unref (self->ease);
|
||||
_gtk_css_value_unref (self->ease);
|
||||
|
||||
g_free (self);
|
||||
}
|
||||
@@ -220,7 +178,7 @@ _gtk_css_animation_new (const char *name,
|
||||
|
||||
animation->name = g_strdup (name);
|
||||
animation->keyframes = _gtk_css_keyframes_ref (keyframes);
|
||||
animation->ease = gtk_css_value_ref (ease);
|
||||
animation->ease = _gtk_css_value_ref (ease);
|
||||
animation->direction = direction;
|
||||
animation->play_state = play_state;
|
||||
animation->fill_mode = fill_mode;
|
||||
@@ -251,7 +209,7 @@ _gtk_css_animation_advance_with_play_state (GtkCssAnimation *source,
|
||||
|
||||
animation->name = g_strdup (source->name);
|
||||
animation->keyframes = _gtk_css_keyframes_ref (source->keyframes);
|
||||
animation->ease = gtk_css_value_ref (source->ease);
|
||||
animation->ease = _gtk_css_value_ref (source->ease);
|
||||
animation->direction = source->direction;
|
||||
animation->play_state = play_state;
|
||||
animation->fill_mode = source->fill_mode;
|
||||
|
||||
+42
-45
@@ -35,15 +35,17 @@ gtk_css_value_array_free (GtkCssValue *value)
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < value->n_values; i++)
|
||||
gtk_css_value_unref (value->values[i]);
|
||||
_gtk_css_value_unref (value->values[i]);
|
||||
|
||||
g_free (value);
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
gtk_css_value_array_compute (GtkCssValue *value,
|
||||
guint property_id,
|
||||
GtkCssComputeContext *context)
|
||||
gtk_css_value_array_compute (GtkCssValue *value,
|
||||
guint property_id,
|
||||
GtkStyleProvider *provider,
|
||||
GtkCssStyle *style,
|
||||
GtkCssStyle *parent_style)
|
||||
{
|
||||
GtkCssValue *result;
|
||||
GtkCssValue *i_value;
|
||||
@@ -52,24 +54,24 @@ gtk_css_value_array_compute (GtkCssValue *value,
|
||||
result = NULL;
|
||||
for (i = 0; i < value->n_values; i++)
|
||||
{
|
||||
i_value = gtk_css_value_compute (value->values[i], property_id, context);
|
||||
i_value = _gtk_css_value_compute (value->values[i], property_id, provider, style, parent_style);
|
||||
|
||||
if (result == NULL &&
|
||||
i_value != value->values[i])
|
||||
{
|
||||
result = _gtk_css_array_value_new_from_array (value->values, value->n_values);
|
||||
for (j = 0; j < i; j++)
|
||||
gtk_css_value_ref (result->values[j]);
|
||||
_gtk_css_value_ref (result->values[j]);
|
||||
}
|
||||
|
||||
if (result != NULL)
|
||||
result->values[i] = i_value;
|
||||
else
|
||||
gtk_css_value_unref (i_value);
|
||||
_gtk_css_value_unref (i_value);
|
||||
}
|
||||
|
||||
if (result == NULL)
|
||||
return gtk_css_value_ref (value);
|
||||
return _gtk_css_value_ref (value);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -85,8 +87,8 @@ gtk_css_value_array_equal (const GtkCssValue *value1,
|
||||
|
||||
for (i = 0; i < value1->n_values; i++)
|
||||
{
|
||||
if (!gtk_css_value_equal (value1->values[i],
|
||||
value2->values[i]))
|
||||
if (!_gtk_css_value_equal (value1->values[i],
|
||||
value2->values[i]))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -125,14 +127,14 @@ gtk_css_value_array_transition_repeat (GtkCssValue *start,
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
transitions[i] = gtk_css_value_transition (start->values[i % start->n_values],
|
||||
end->values[i % end->n_values],
|
||||
property_id,
|
||||
progress);
|
||||
transitions[i] = _gtk_css_value_transition (start->values[i % start->n_values],
|
||||
end->values[i % end->n_values],
|
||||
property_id,
|
||||
progress);
|
||||
if (transitions[i] == NULL)
|
||||
{
|
||||
while (i--)
|
||||
gtk_css_value_unref (transitions[i]);
|
||||
_gtk_css_value_unref (transitions[i]);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -166,14 +168,14 @@ gtk_css_value_array_transition_extend (GtkCssValue *start,
|
||||
|
||||
for (i = 0; i < MIN (start->n_values, end->n_values); i++)
|
||||
{
|
||||
transitions[i] = gtk_css_value_transition (start->values[i],
|
||||
end->values[i],
|
||||
property_id,
|
||||
progress);
|
||||
transitions[i] = _gtk_css_value_transition (start->values[i],
|
||||
end->values[i],
|
||||
property_id,
|
||||
progress);
|
||||
if (transitions[i] == NULL)
|
||||
{
|
||||
while (i--)
|
||||
gtk_css_value_unref (transitions[i]);
|
||||
_gtk_css_value_unref (transitions[i]);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -186,28 +188,28 @@ gtk_css_value_array_transition_extend (GtkCssValue *start,
|
||||
|
||||
for (; i < start->n_values; i++)
|
||||
{
|
||||
transitions[i] = gtk_css_value_transition (start->values[i],
|
||||
default_value,
|
||||
property_id,
|
||||
progress);
|
||||
transitions[i] = _gtk_css_value_transition (start->values[i],
|
||||
default_value,
|
||||
property_id,
|
||||
progress);
|
||||
if (transitions[i] == NULL)
|
||||
{
|
||||
while (i--)
|
||||
gtk_css_value_unref (transitions[i]);
|
||||
_gtk_css_value_unref (transitions[i]);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
for (; i < end->n_values; i++)
|
||||
{
|
||||
transitions[i] = gtk_css_value_transition (default_value,
|
||||
end->values[i],
|
||||
property_id,
|
||||
progress);
|
||||
transitions[i] = _gtk_css_value_transition (default_value,
|
||||
end->values[i],
|
||||
property_id,
|
||||
progress);
|
||||
if (transitions[i] == NULL)
|
||||
{
|
||||
while (i--)
|
||||
gtk_css_value_unref (transitions[i]);
|
||||
_gtk_css_value_unref (transitions[i]);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -325,17 +327,17 @@ gtk_css_value_array_get_dynamic_value (GtkCssValue *value,
|
||||
{
|
||||
result = _gtk_css_array_value_new_from_array (value->values, value->n_values);
|
||||
for (j = 0; j < i; j++)
|
||||
gtk_css_value_ref (result->values[j]);
|
||||
_gtk_css_value_ref (result->values[j]);
|
||||
}
|
||||
|
||||
if (result != NULL)
|
||||
result->values[i] = i_value;
|
||||
else
|
||||
gtk_css_value_unref (i_value);
|
||||
_gtk_css_value_unref (i_value);
|
||||
}
|
||||
|
||||
if (result == NULL)
|
||||
return gtk_css_value_ref (value);
|
||||
return _gtk_css_value_ref (value);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -356,7 +358,7 @@ gtk_css_value_array_print (const GtkCssValue *value,
|
||||
{
|
||||
if (i > 0)
|
||||
g_string_append (string, ", ");
|
||||
gtk_css_value_print (value->values[i], string);
|
||||
_gtk_css_value_print (value->values[i], string);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -392,22 +394,18 @@ _gtk_css_array_value_new_from_array (GtkCssValue **values,
|
||||
if (n_values == 1)
|
||||
return values[0];
|
||||
|
||||
result = gtk_css_value_alloc (>K_CSS_VALUE_ARRAY, sizeof (GtkCssValue) + sizeof (GtkCssValue *) * (n_values - 1));
|
||||
result = _gtk_css_value_alloc (>K_CSS_VALUE_ARRAY, sizeof (GtkCssValue) + sizeof (GtkCssValue *) * (n_values - 1));
|
||||
result->n_values = n_values;
|
||||
memcpy (&result->values[0], values, sizeof (GtkCssValue *) * n_values);
|
||||
|
||||
result->is_computed = TRUE;
|
||||
result->contains_variables = FALSE;
|
||||
for (i = 0; i < n_values; i ++)
|
||||
{
|
||||
if (!gtk_css_value_is_computed (values[i]))
|
||||
result->is_computed = FALSE;
|
||||
|
||||
if (gtk_css_value_contains_variables (values[i]))
|
||||
result->contains_variables = TRUE;
|
||||
|
||||
if (!result->is_computed && result->contains_variables)
|
||||
break;
|
||||
{
|
||||
result->is_computed = FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -428,7 +426,7 @@ _gtk_css_array_value_parse (GtkCssParser *parser,
|
||||
if (value == NULL)
|
||||
{
|
||||
for (i = 0; i < n_values; i ++)
|
||||
gtk_css_value_unref (values[i]);
|
||||
_gtk_css_value_unref (values[i]);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -469,4 +467,3 @@ _gtk_css_array_value_get_n_values (const GtkCssValue *value)
|
||||
return value->n_values;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+40
-38
@@ -33,39 +33,41 @@ static void
|
||||
gtk_css_value_bg_size_free (GtkCssValue *value)
|
||||
{
|
||||
if (value->x)
|
||||
gtk_css_value_unref (value->x);
|
||||
_gtk_css_value_unref (value->x);
|
||||
if (value->y)
|
||||
gtk_css_value_unref (value->y);
|
||||
_gtk_css_value_unref (value->y);
|
||||
|
||||
g_free (value);
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
gtk_css_value_bg_size_compute (GtkCssValue *value,
|
||||
guint property_id,
|
||||
GtkCssComputeContext *context)
|
||||
gtk_css_value_bg_size_compute (GtkCssValue *value,
|
||||
guint property_id,
|
||||
GtkStyleProvider *provider,
|
||||
GtkCssStyle *style,
|
||||
GtkCssStyle *parent_style)
|
||||
{
|
||||
GtkCssValue *x, *y;
|
||||
|
||||
if (value->x == NULL && value->y == NULL)
|
||||
return gtk_css_value_ref (value);
|
||||
return _gtk_css_value_ref (value);
|
||||
|
||||
x = y = NULL;
|
||||
|
||||
if (value->x)
|
||||
x = gtk_css_value_compute (value->x, property_id, context);
|
||||
x = _gtk_css_value_compute (value->x, property_id, provider, style, parent_style);
|
||||
|
||||
if (value->y)
|
||||
y = gtk_css_value_compute (value->y, property_id, context);
|
||||
y = _gtk_css_value_compute (value->y, property_id, provider, style, parent_style);
|
||||
|
||||
if (x == value->x && y == value->y)
|
||||
{
|
||||
if (x)
|
||||
gtk_css_value_unref (x);
|
||||
_gtk_css_value_unref (x);
|
||||
if (y)
|
||||
gtk_css_value_unref (y);
|
||||
_gtk_css_value_unref (y);
|
||||
|
||||
return gtk_css_value_ref (value);
|
||||
return _gtk_css_value_ref (value);
|
||||
}
|
||||
|
||||
return _gtk_css_bg_size_value_new (value->x ? x : NULL,
|
||||
@@ -80,10 +82,10 @@ gtk_css_value_bg_size_equal (const GtkCssValue *value1,
|
||||
value1->contain == value2->contain &&
|
||||
(value1->x == value2->x ||
|
||||
(value1->x != NULL && value2->x != NULL &&
|
||||
gtk_css_value_equal (value1->x, value2->x))) &&
|
||||
_gtk_css_value_equal (value1->x, value2->x))) &&
|
||||
(value1->y == value2->y ||
|
||||
(value1->y != NULL && value2->y != NULL &&
|
||||
gtk_css_value_equal (value1->y, value2->y)));
|
||||
_gtk_css_value_equal (value1->y, value2->y)));
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
@@ -95,9 +97,9 @@ gtk_css_value_bg_size_transition (GtkCssValue *start,
|
||||
GtkCssValue *x, *y;
|
||||
|
||||
if (start->cover)
|
||||
return end->cover ? gtk_css_value_ref (end) : NULL;
|
||||
return end->cover ? _gtk_css_value_ref (end) : NULL;
|
||||
if (start->contain)
|
||||
return end->contain ? gtk_css_value_ref (end) : NULL;
|
||||
return end->contain ? _gtk_css_value_ref (end) : NULL;
|
||||
|
||||
if ((start->x != NULL) ^ (end->x != NULL) ||
|
||||
(start->y != NULL) ^ (end->y != NULL))
|
||||
@@ -105,7 +107,7 @@ gtk_css_value_bg_size_transition (GtkCssValue *start,
|
||||
|
||||
if (start->x)
|
||||
{
|
||||
x = gtk_css_value_transition (start->x, end->x, property_id, progress);
|
||||
x = _gtk_css_value_transition (start->x, end->x, property_id, progress);
|
||||
if (x == NULL)
|
||||
return NULL;
|
||||
}
|
||||
@@ -114,10 +116,10 @@ gtk_css_value_bg_size_transition (GtkCssValue *start,
|
||||
|
||||
if (start->y)
|
||||
{
|
||||
y = gtk_css_value_transition (start->y, end->y, property_id, progress);
|
||||
y = _gtk_css_value_transition (start->y, end->y, property_id, progress);
|
||||
if (y == NULL)
|
||||
{
|
||||
gtk_css_value_unref (x);
|
||||
_gtk_css_value_unref (x);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -140,12 +142,12 @@ gtk_css_value_bg_size_print (const GtkCssValue *value,
|
||||
if (value->x == NULL)
|
||||
g_string_append (string, "auto");
|
||||
else
|
||||
gtk_css_value_print (value->x, string);
|
||||
_gtk_css_value_print (value->x, string);
|
||||
|
||||
if (value->y)
|
||||
{
|
||||
g_string_append_c (string, ' ');
|
||||
gtk_css_value_print (value->y, string);
|
||||
_gtk_css_value_print (value->y, string);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -161,9 +163,9 @@ static const GtkCssValueClass GTK_CSS_VALUE_BG_SIZE = {
|
||||
gtk_css_value_bg_size_print
|
||||
};
|
||||
|
||||
static GtkCssValue auto_singleton = { >K_CSS_VALUE_BG_SIZE, 1, TRUE, FALSE, FALSE, FALSE, NULL, NULL };
|
||||
static GtkCssValue cover_singleton = { >K_CSS_VALUE_BG_SIZE, 1, TRUE, FALSE, TRUE, FALSE, NULL, NULL };
|
||||
static GtkCssValue contain_singleton = { >K_CSS_VALUE_BG_SIZE, 1, TRUE, FALSE, FALSE, TRUE, NULL, NULL };
|
||||
static GtkCssValue auto_singleton = { >K_CSS_VALUE_BG_SIZE, 1, TRUE, FALSE, FALSE, NULL, NULL };
|
||||
static GtkCssValue cover_singleton = { >K_CSS_VALUE_BG_SIZE, 1, TRUE, TRUE, FALSE, NULL, NULL };
|
||||
static GtkCssValue contain_singleton = { >K_CSS_VALUE_BG_SIZE, 1, TRUE, FALSE, TRUE, NULL, NULL };
|
||||
|
||||
GtkCssValue *
|
||||
_gtk_css_bg_size_value_new (GtkCssValue *x,
|
||||
@@ -172,9 +174,9 @@ _gtk_css_bg_size_value_new (GtkCssValue *x,
|
||||
GtkCssValue *result;
|
||||
|
||||
if (x == NULL && y == NULL)
|
||||
return gtk_css_value_ref (&auto_singleton);
|
||||
return _gtk_css_value_ref (&auto_singleton);
|
||||
|
||||
result = gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_BG_SIZE);
|
||||
result = _gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_BG_SIZE);
|
||||
result->x = x;
|
||||
result->y = y;
|
||||
result->is_computed = (!x || gtk_css_value_is_computed (x)) &&
|
||||
@@ -189,18 +191,18 @@ _gtk_css_bg_size_value_parse (GtkCssParser *parser)
|
||||
GtkCssValue *x, *y;
|
||||
|
||||
if (gtk_css_parser_try_ident (parser, "cover"))
|
||||
return gtk_css_value_ref (&cover_singleton);
|
||||
return _gtk_css_value_ref (&cover_singleton);
|
||||
else if (gtk_css_parser_try_ident (parser, "contain"))
|
||||
return gtk_css_value_ref (&contain_singleton);
|
||||
return _gtk_css_value_ref (&contain_singleton);
|
||||
|
||||
if (gtk_css_parser_try_ident (parser, "auto"))
|
||||
x = NULL;
|
||||
else
|
||||
{
|
||||
x = gtk_css_number_value_parse (parser,
|
||||
GTK_CSS_POSITIVE_ONLY
|
||||
| GTK_CSS_PARSE_PERCENT
|
||||
| GTK_CSS_PARSE_LENGTH);
|
||||
x = _gtk_css_number_value_parse (parser,
|
||||
GTK_CSS_POSITIVE_ONLY
|
||||
| GTK_CSS_PARSE_PERCENT
|
||||
| GTK_CSS_PARSE_LENGTH);
|
||||
if (x == NULL)
|
||||
return NULL;
|
||||
}
|
||||
@@ -211,13 +213,13 @@ _gtk_css_bg_size_value_parse (GtkCssParser *parser)
|
||||
y = NULL;
|
||||
else
|
||||
{
|
||||
y = gtk_css_number_value_parse (parser,
|
||||
GTK_CSS_POSITIVE_ONLY
|
||||
| GTK_CSS_PARSE_PERCENT
|
||||
| GTK_CSS_PARSE_LENGTH);
|
||||
y = _gtk_css_number_value_parse (parser,
|
||||
GTK_CSS_POSITIVE_ONLY
|
||||
| GTK_CSS_PARSE_PERCENT
|
||||
| GTK_CSS_PARSE_LENGTH);
|
||||
if (y == NULL)
|
||||
{
|
||||
gtk_css_value_unref (x);
|
||||
_gtk_css_value_unref (x);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -280,8 +282,8 @@ _gtk_css_bg_size_value_compute_size (const GtkCssValue *value,
|
||||
double x, y;
|
||||
|
||||
/* note: 0 does the right thing later for 'auto' */
|
||||
x = value->x ? gtk_css_number_value_get (value->x, area_width) : 0;
|
||||
y = value->y ? gtk_css_number_value_get (value->y, area_height) : 0;
|
||||
x = value->x ? _gtk_css_number_value_get (value->x, area_width) : 0;
|
||||
y = value->y ? _gtk_css_number_value_get (value->y, area_height) : 0;
|
||||
|
||||
if ((x <= 0 && value->x) ||
|
||||
(y <= 0 && value->y))
|
||||
|
||||
+19
-18
@@ -35,16 +35,18 @@ gtk_css_value_border_free (GtkCssValue *value)
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if (value->values[i])
|
||||
gtk_css_value_unref (value->values[i]);
|
||||
_gtk_css_value_unref (value->values[i]);
|
||||
}
|
||||
|
||||
g_free (value);
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
gtk_css_value_border_compute (GtkCssValue *value,
|
||||
guint property_id,
|
||||
GtkCssComputeContext *context)
|
||||
gtk_css_value_border_compute (GtkCssValue *value,
|
||||
guint property_id,
|
||||
GtkStyleProvider *provider,
|
||||
GtkCssStyle *style,
|
||||
GtkCssStyle *parent_style)
|
||||
{
|
||||
GtkCssValue *values[4];
|
||||
GtkCssValue *computed;
|
||||
@@ -55,7 +57,7 @@ gtk_css_value_border_compute (GtkCssValue *value,
|
||||
{
|
||||
if (value->values[i])
|
||||
{
|
||||
values[i] = gtk_css_value_compute (value->values[i], property_id, context);
|
||||
values[i] = _gtk_css_value_compute (value->values[i], property_id, provider, style, parent_style);
|
||||
changed |= (values[i] != value->values[i]);
|
||||
}
|
||||
else
|
||||
@@ -69,9 +71,9 @@ gtk_css_value_border_compute (GtkCssValue *value,
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if (values[i] != NULL)
|
||||
gtk_css_value_unref (values[i]);
|
||||
_gtk_css_value_unref (values[i]);
|
||||
}
|
||||
return gtk_css_value_ref (value);
|
||||
return _gtk_css_value_ref (value);
|
||||
}
|
||||
|
||||
computed = _gtk_css_border_value_new (values[0], values[1], values[2], values[3]);
|
||||
@@ -91,7 +93,7 @@ gtk_css_value_border_equal (const GtkCssValue *value1,
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if (!gtk_css_value_equal0 (value1->values[i], value2->values[i]))
|
||||
if (!_gtk_css_value_equal0 (value1->values[i], value2->values[i]))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -113,11 +115,11 @@ gtk_css_value_border_print (const GtkCssValue *value,
|
||||
{
|
||||
guint i, n;
|
||||
|
||||
if (!gtk_css_value_equal0 (value->values[GTK_CSS_RIGHT], value->values[GTK_CSS_LEFT]))
|
||||
if (!_gtk_css_value_equal0 (value->values[GTK_CSS_RIGHT], value->values[GTK_CSS_LEFT]))
|
||||
n = 4;
|
||||
else if (!gtk_css_value_equal0 (value->values[GTK_CSS_TOP], value->values[GTK_CSS_BOTTOM]))
|
||||
else if (!_gtk_css_value_equal0 (value->values[GTK_CSS_TOP], value->values[GTK_CSS_BOTTOM]))
|
||||
n = 3;
|
||||
else if (!gtk_css_value_equal0 (value->values[GTK_CSS_TOP], value->values[GTK_CSS_RIGHT]))
|
||||
else if (!_gtk_css_value_equal0 (value->values[GTK_CSS_TOP], value->values[GTK_CSS_RIGHT]))
|
||||
n = 2;
|
||||
else
|
||||
n = 1;
|
||||
@@ -130,7 +132,7 @@ gtk_css_value_border_print (const GtkCssValue *value,
|
||||
if (value->values[i] == NULL)
|
||||
g_string_append (string, "auto");
|
||||
else
|
||||
gtk_css_value_print (value->values[i], string);
|
||||
_gtk_css_value_print (value->values[i], string);
|
||||
}
|
||||
|
||||
if (value->fill)
|
||||
@@ -156,7 +158,7 @@ _gtk_css_border_value_new (GtkCssValue *top,
|
||||
{
|
||||
GtkCssValue *result;
|
||||
|
||||
result = gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_BORDER);
|
||||
result = _gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_BORDER);
|
||||
result->values[GTK_CSS_TOP] = top;
|
||||
result->values[GTK_CSS_RIGHT] = right;
|
||||
result->values[GTK_CSS_BOTTOM] = bottom;
|
||||
@@ -191,10 +193,10 @@ _gtk_css_border_value_parse (GtkCssParser *parser,
|
||||
if (!gtk_css_number_value_can_parse (parser))
|
||||
break;
|
||||
|
||||
result->values[i] = gtk_css_number_value_parse (parser, flags);
|
||||
result->values[i] = _gtk_css_number_value_parse (parser, flags);
|
||||
if (result->values[i] == NULL)
|
||||
{
|
||||
gtk_css_value_unref (result);
|
||||
_gtk_css_value_unref (result);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -202,7 +204,7 @@ _gtk_css_border_value_parse (GtkCssParser *parser,
|
||||
if (i == 0)
|
||||
{
|
||||
gtk_css_parser_error_syntax (parser, "Expected a number");
|
||||
gtk_css_value_unref (result);
|
||||
_gtk_css_value_unref (result);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -212,7 +214,7 @@ _gtk_css_border_value_parse (GtkCssParser *parser,
|
||||
for (; i < 4; i++)
|
||||
{
|
||||
if (result->values[(i - 1) >> 1])
|
||||
result->values[i] = gtk_css_value_ref (result->values[(i - 1) >> 1]);
|
||||
result->values[i] = _gtk_css_value_ref (result->values[(i - 1) >> 1]);
|
||||
}
|
||||
|
||||
result->is_computed = TRUE;
|
||||
@@ -258,4 +260,3 @@ _gtk_css_border_value_get_left (const GtkCssValue *value)
|
||||
return value->values[GTK_CSS_LEFT];
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -84,17 +84,17 @@ gtk_css_boxes_rect_grow (GskRoundedRect *dest,
|
||||
if (gtk_css_dimension_value_is_zero (right))
|
||||
dest->bounds.size.width = src->bounds.size.width;
|
||||
else
|
||||
dest->bounds.size.width = src->bounds.size.width + gtk_css_number_value_get (right, 100);
|
||||
dest->bounds.size.width = src->bounds.size.width + _gtk_css_number_value_get (right, 100);
|
||||
}
|
||||
else
|
||||
{
|
||||
const double left_value = gtk_css_number_value_get (left, 100);
|
||||
const double left_value = _gtk_css_number_value_get (left, 100);
|
||||
|
||||
dest->bounds.origin.x = src->bounds.origin.x - left_value;
|
||||
if (gtk_css_dimension_value_is_zero (right))
|
||||
dest->bounds.size.width = src->bounds.size.width + left_value;
|
||||
else
|
||||
dest->bounds.size.width = src->bounds.size.width + left_value + gtk_css_number_value_get (right, 100);
|
||||
dest->bounds.size.width = src->bounds.size.width + left_value + _gtk_css_number_value_get (right, 100);
|
||||
|
||||
}
|
||||
|
||||
@@ -105,17 +105,17 @@ gtk_css_boxes_rect_grow (GskRoundedRect *dest,
|
||||
if (gtk_css_dimension_value_is_zero (bottom))
|
||||
dest->bounds.size.height = src->bounds.size.height;
|
||||
else
|
||||
dest->bounds.size.height = src->bounds.size.height + gtk_css_number_value_get (bottom, 100);
|
||||
dest->bounds.size.height = src->bounds.size.height + _gtk_css_number_value_get (bottom, 100);
|
||||
}
|
||||
else
|
||||
{
|
||||
const double top_value = gtk_css_number_value_get (top, 100);
|
||||
const double top_value = _gtk_css_number_value_get (top, 100);
|
||||
|
||||
dest->bounds.origin.y = src->bounds.origin.y - top_value;
|
||||
if (gtk_css_dimension_value_is_zero (bottom))
|
||||
dest->bounds.size.height = src->bounds.size.height + top_value;
|
||||
else
|
||||
dest->bounds.size.height = src->bounds.size.height + top_value + gtk_css_number_value_get (bottom, 100);
|
||||
dest->bounds.size.height = src->bounds.size.height + top_value + _gtk_css_number_value_get (bottom, 100);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,10 +127,10 @@ gtk_css_boxes_rect_shrink (GskRoundedRect *dest,
|
||||
GtkCssValue *bottom_value,
|
||||
GtkCssValue *left_value)
|
||||
{
|
||||
double top = gtk_css_number_value_get (top_value, 100);
|
||||
double right = gtk_css_number_value_get (right_value, 100);
|
||||
double bottom = gtk_css_number_value_get (bottom_value, 100);
|
||||
double left = gtk_css_number_value_get (left_value, 100);
|
||||
double top = _gtk_css_number_value_get (top_value, 100);
|
||||
double right = _gtk_css_number_value_get (right_value, 100);
|
||||
double bottom = _gtk_css_number_value_get (bottom_value, 100);
|
||||
double left = _gtk_css_number_value_get (left_value, 100);
|
||||
|
||||
/* FIXME: Do we need underflow checks here? */
|
||||
dest->bounds.origin.x = src->bounds.origin.x + left;
|
||||
@@ -255,8 +255,8 @@ gtk_css_boxes_compute_outline_rect (GtkCssBoxes *boxes)
|
||||
dest = &boxes->box[GTK_CSS_AREA_OUTLINE_BOX].bounds;
|
||||
src = &boxes->box[GTK_CSS_AREA_BORDER_BOX].bounds;
|
||||
|
||||
d = gtk_css_number_value_get (boxes->style->outline->outline_offset, 100) +
|
||||
gtk_css_number_value_get (boxes->style->outline->outline_width, 100);
|
||||
d = _gtk_css_number_value_get (boxes->style->outline->outline_offset, 100) +
|
||||
_gtk_css_number_value_get (boxes->style->outline->outline_width, 100);
|
||||
|
||||
dest->origin.x = src->origin.x - d;
|
||||
dest->origin.y = src->origin.y - d;
|
||||
@@ -483,8 +483,8 @@ gtk_css_boxes_compute_outline_box (GtkCssBoxes *boxes)
|
||||
src = &boxes->box[GTK_CSS_AREA_BORDER_BOX];
|
||||
dest = &boxes->box[GTK_CSS_AREA_OUTLINE_BOX];
|
||||
|
||||
d = gtk_css_number_value_get (boxes->style->outline->outline_offset, 100) +
|
||||
gtk_css_number_value_get (boxes->style->outline->outline_width, 100);
|
||||
d = _gtk_css_number_value_get (boxes->style->outline->outline_offset, 100) +
|
||||
_gtk_css_number_value_get (boxes->style->outline->outline_width, 100);
|
||||
|
||||
/* Grow border rect into outline rect */
|
||||
dest->bounds.origin.x = src->bounds.origin.x - d;
|
||||
|
||||
+13
-317
@@ -60,7 +60,7 @@ gtk_css_calc_value_parse_value (GtkCssParser *parser,
|
||||
return result;
|
||||
}
|
||||
|
||||
return gtk_css_number_value_parse (parser, flags);
|
||||
return _gtk_css_number_value_parse (parser, flags);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -96,11 +96,11 @@ gtk_css_calc_value_parse_product (GtkCssParser *parser,
|
||||
if (value == NULL)
|
||||
goto fail;
|
||||
if (is_number (value))
|
||||
temp = gtk_css_number_value_multiply (result, gtk_css_number_value_get (value, 100));
|
||||
temp = gtk_css_number_value_multiply (result, _gtk_css_number_value_get (value, 100));
|
||||
else
|
||||
temp = gtk_css_number_value_multiply (value, gtk_css_number_value_get (result, 100));
|
||||
gtk_css_value_unref (value);
|
||||
gtk_css_value_unref (result);
|
||||
temp = gtk_css_number_value_multiply (value, _gtk_css_number_value_get (result, 100));
|
||||
_gtk_css_value_unref (value);
|
||||
_gtk_css_value_unref (result);
|
||||
result = temp;
|
||||
}
|
||||
else if (gtk_css_parser_try_delim (parser, '/'))
|
||||
@@ -108,9 +108,9 @@ gtk_css_calc_value_parse_product (GtkCssParser *parser,
|
||||
value = gtk_css_calc_value_parse_product (parser, GTK_CSS_PARSE_NUMBER);
|
||||
if (value == NULL)
|
||||
goto fail;
|
||||
temp = gtk_css_number_value_multiply (result, 1.0 / gtk_css_number_value_get (value, 100));
|
||||
gtk_css_value_unref (value);
|
||||
gtk_css_value_unref (result);
|
||||
temp = gtk_css_number_value_multiply (result, 1.0 / _gtk_css_number_value_get (value, 100));
|
||||
_gtk_css_value_unref (value);
|
||||
_gtk_css_value_unref (result);
|
||||
result = temp;
|
||||
}
|
||||
else
|
||||
@@ -132,7 +132,7 @@ gtk_css_calc_value_parse_product (GtkCssParser *parser,
|
||||
return result;
|
||||
|
||||
fail:
|
||||
gtk_css_value_unref (result);
|
||||
_gtk_css_value_unref (result);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ gtk_css_calc_value_parse_sum (GtkCssParser *parser,
|
||||
if (temp == NULL)
|
||||
goto fail;
|
||||
next = gtk_css_number_value_multiply (temp, -1);
|
||||
gtk_css_value_unref (temp);
|
||||
_gtk_css_value_unref (temp);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -178,15 +178,15 @@ gtk_css_calc_value_parse_sum (GtkCssParser *parser,
|
||||
}
|
||||
|
||||
temp = gtk_css_number_value_add (result, next);
|
||||
gtk_css_value_unref (result);
|
||||
gtk_css_value_unref (next);
|
||||
_gtk_css_value_unref (result);
|
||||
_gtk_css_value_unref (next);
|
||||
result = temp;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
fail:
|
||||
gtk_css_value_unref (result);
|
||||
_gtk_css_value_unref (result);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -232,307 +232,3 @@ gtk_css_calc_value_parse (GtkCssParser *parser,
|
||||
return data.value;
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GtkCssNumberParseFlags flags;
|
||||
GPtrArray *values;
|
||||
} ParseArgnData;
|
||||
|
||||
static guint
|
||||
gtk_css_argn_value_parse_arg (GtkCssParser *parser,
|
||||
guint arg,
|
||||
gpointer data_)
|
||||
{
|
||||
ParseArgnData *data = data_;
|
||||
GtkCssValue *value;
|
||||
|
||||
value = gtk_css_calc_value_parse_sum (parser, data->flags);
|
||||
if (value == NULL)
|
||||
return 0;
|
||||
|
||||
g_ptr_array_add (data->values, value);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GtkCssNumberParseFlags flags;
|
||||
GtkCssValue *values[3];
|
||||
} ParseClampData;
|
||||
|
||||
static guint
|
||||
gtk_css_clamp_value_parse_arg (GtkCssParser *parser,
|
||||
guint arg,
|
||||
gpointer data_)
|
||||
{
|
||||
ParseClampData *data = data_;
|
||||
|
||||
if ((arg == 0 || arg == 2))
|
||||
{
|
||||
if (gtk_css_parser_try_ident (parser, "none"))
|
||||
{
|
||||
data->values[arg] = NULL;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
data->values[arg] = gtk_css_calc_value_parse_sum (parser, data->flags);
|
||||
if (data->values[arg] == NULL)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
gtk_css_clamp_value_parse (GtkCssParser *parser,
|
||||
GtkCssNumberParseFlags flags,
|
||||
guint type)
|
||||
{
|
||||
ParseClampData data;
|
||||
GtkCssValue *result = NULL;
|
||||
|
||||
if (!gtk_css_parser_has_function (parser, "clamp"))
|
||||
{
|
||||
gtk_css_parser_error_syntax (parser, "Expected 'clamp('");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* This can only be handled at compute time, we allow '-' after all */
|
||||
data.flags = flags & ~GTK_CSS_POSITIVE_ONLY;
|
||||
data.values[0] = NULL;
|
||||
data.values[1] = NULL;
|
||||
data.values[2] = NULL;
|
||||
|
||||
if (gtk_css_parser_consume_function (parser, 3, 3, gtk_css_clamp_value_parse_arg, &data))
|
||||
{
|
||||
GtkCssDimension dim = gtk_css_number_value_get_dimension (data.values[1]);
|
||||
if ((data.values[0] && gtk_css_number_value_get_dimension (data.values[0]) != dim) ||
|
||||
(data.values[2] && gtk_css_number_value_get_dimension (data.values[2]) != dim))
|
||||
gtk_css_parser_error_syntax (parser, "Inconsistent types in 'clamp('");
|
||||
else
|
||||
result = gtk_css_math_value_new (type, 0, data.values, 3);
|
||||
}
|
||||
|
||||
if (result == NULL)
|
||||
{
|
||||
g_clear_pointer (&data.values[0], gtk_css_value_unref);
|
||||
g_clear_pointer (&data.values[1], gtk_css_value_unref);
|
||||
g_clear_pointer (&data.values[2], gtk_css_value_unref);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
GtkCssNumberParseFlags flags;
|
||||
guint mode;
|
||||
gboolean has_mode;
|
||||
GtkCssValue *values[2];
|
||||
} ParseRoundData;
|
||||
|
||||
static guint
|
||||
gtk_css_round_value_parse_arg (GtkCssParser *parser,
|
||||
guint arg,
|
||||
gpointer data_)
|
||||
{
|
||||
ParseRoundData *data = data_;
|
||||
|
||||
if (arg == 0)
|
||||
{
|
||||
const char *modes[] = { "nearest", "up", "down", "to-zero" };
|
||||
|
||||
for (guint i = 0; i < G_N_ELEMENTS (modes); i++)
|
||||
{
|
||||
if (gtk_css_parser_try_ident (parser, modes[i]))
|
||||
{
|
||||
data->mode = i;
|
||||
data->has_mode = TRUE;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
data->values[0] = gtk_css_calc_value_parse_sum (parser, data->flags);
|
||||
if (data->values[0] == NULL)
|
||||
return 0;
|
||||
}
|
||||
else if (arg == 1)
|
||||
{
|
||||
GtkCssValue *value = gtk_css_calc_value_parse_sum (parser, data->flags);
|
||||
|
||||
if (value == NULL)
|
||||
return 0;
|
||||
|
||||
if (data->has_mode)
|
||||
data->values[0] = value;
|
||||
else
|
||||
data->values[1] = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!data->has_mode)
|
||||
{
|
||||
gtk_css_parser_error_syntax (parser, "Too many argument for 'round'");
|
||||
return 0;
|
||||
}
|
||||
|
||||
data->values[1] = gtk_css_calc_value_parse_sum (parser, data->flags);
|
||||
|
||||
if (data->values[1] == NULL)
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
gtk_css_round_value_parse (GtkCssParser *parser,
|
||||
GtkCssNumberParseFlags flags,
|
||||
guint type)
|
||||
{
|
||||
ParseRoundData data;
|
||||
GtkCssValue *result = NULL;
|
||||
|
||||
if (!gtk_css_parser_has_function (parser, "round"))
|
||||
{
|
||||
gtk_css_parser_error_syntax (parser, "Expected 'round('");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data.flags = flags & ~GTK_CSS_POSITIVE_ONLY;
|
||||
data.mode = ROUND_NEAREST;
|
||||
data.has_mode = FALSE;
|
||||
data.values[0] = NULL;
|
||||
data.values[1] = NULL;
|
||||
|
||||
if (gtk_css_parser_consume_function (parser, 1, 3, gtk_css_round_value_parse_arg, &data) &&
|
||||
data.values[0] != NULL)
|
||||
{
|
||||
if (data.values[1] != NULL &&
|
||||
gtk_css_number_value_get_dimension (data.values[0]) !=
|
||||
gtk_css_number_value_get_dimension (data.values[1]))
|
||||
gtk_css_parser_error_syntax (parser, "Inconsistent types in 'round('");
|
||||
else if (data.values[1] == NULL &&
|
||||
gtk_css_number_value_get_dimension (data.values[0]) != GTK_CSS_DIMENSION_NUMBER)
|
||||
gtk_css_parser_error_syntax (parser, "Can't omit second argument to 'round(' here");
|
||||
else
|
||||
result = gtk_css_math_value_new (type, data.mode, data.values, data.values[1] != NULL ? 2 : 1);
|
||||
}
|
||||
|
||||
if (result == NULL)
|
||||
{
|
||||
g_clear_pointer (&data.values[0], gtk_css_value_unref);
|
||||
g_clear_pointer (&data.values[1], gtk_css_value_unref);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
GtkCssNumberParseFlags flags;
|
||||
GtkCssValue *values[2];
|
||||
} ParseArg2Data;
|
||||
|
||||
static guint
|
||||
gtk_css_arg2_value_parse_arg (GtkCssParser *parser,
|
||||
guint arg,
|
||||
gpointer data_)
|
||||
{
|
||||
ParseArg2Data *data = data_;
|
||||
|
||||
data->values[arg] = gtk_css_calc_value_parse_sum (parser, data->flags);
|
||||
if (data->values[arg] == NULL)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
gtk_css_arg2_value_parse (GtkCssParser *parser,
|
||||
GtkCssNumberParseFlags flags,
|
||||
guint min_args,
|
||||
guint max_args,
|
||||
const char *function,
|
||||
guint type)
|
||||
{
|
||||
ParseArg2Data data;
|
||||
GtkCssValue *result = NULL;
|
||||
|
||||
g_assert (1 <= min_args && min_args <= max_args && max_args <= 2);
|
||||
|
||||
if (!gtk_css_parser_has_function (parser, function))
|
||||
{
|
||||
gtk_css_parser_error_syntax (parser, "Expected '%s('", function);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data.flags = flags & ~GTK_CSS_POSITIVE_ONLY;
|
||||
data.values[0] = NULL;
|
||||
data.values[1] = NULL;
|
||||
|
||||
if (gtk_css_parser_consume_function (parser, min_args, max_args, gtk_css_arg2_value_parse_arg, &data))
|
||||
{
|
||||
if (data.values[1] != NULL &&
|
||||
gtk_css_number_value_get_dimension (data.values[0]) !=
|
||||
gtk_css_number_value_get_dimension (data.values[1]))
|
||||
gtk_css_parser_error_syntax (parser, "Inconsistent types in '%s('", function);
|
||||
else
|
||||
result = gtk_css_math_value_new (type, 0, data.values, data.values[1] != NULL ? 2 : 1);
|
||||
}
|
||||
|
||||
if (result == NULL)
|
||||
{
|
||||
g_clear_pointer (&data.values[0], gtk_css_value_unref);
|
||||
g_clear_pointer (&data.values[1], gtk_css_value_unref);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
gtk_css_argn_value_parse (GtkCssParser *parser,
|
||||
GtkCssNumberParseFlags flags,
|
||||
const char *function,
|
||||
guint type)
|
||||
{
|
||||
ParseArgnData data;
|
||||
GtkCssValue *result = NULL;
|
||||
|
||||
if (!gtk_css_parser_has_function (parser, function))
|
||||
{
|
||||
gtk_css_parser_error_syntax (parser, "Expected '%s('", function);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* This can only be handled at compute time, we allow '-' after all */
|
||||
data.flags = flags & ~GTK_CSS_POSITIVE_ONLY;
|
||||
data.values = g_ptr_array_new ();
|
||||
|
||||
if (gtk_css_parser_consume_function (parser, 1, G_MAXUINT, gtk_css_argn_value_parse_arg, &data))
|
||||
{
|
||||
GtkCssValue *val = (GtkCssValue *) g_ptr_array_index (data.values, 0);
|
||||
GtkCssDimension dim = gtk_css_number_value_get_dimension (val);
|
||||
guint i;
|
||||
for (i = 1; i < data.values->len; i++)
|
||||
{
|
||||
val = (GtkCssValue *) g_ptr_array_index (data.values, i);
|
||||
if (gtk_css_number_value_get_dimension (val) != dim)
|
||||
break;
|
||||
}
|
||||
if (i < data.values->len)
|
||||
gtk_css_parser_error_syntax (parser, "Inconsistent types in '%s('", function);
|
||||
else
|
||||
result = gtk_css_math_value_new (type, 0, (GtkCssValue **)data.values->pdata, data.values->len);
|
||||
}
|
||||
|
||||
if (result == NULL)
|
||||
{
|
||||
for (guint i = 0; i < data.values->len; i++)
|
||||
gtk_css_value_unref ((GtkCssValue *)g_ptr_array_index (data.values, i));
|
||||
}
|
||||
|
||||
g_ptr_array_unref (data.values);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,21 +23,6 @@ G_BEGIN_DECLS
|
||||
|
||||
GtkCssValue * gtk_css_calc_value_parse (GtkCssParser *parser,
|
||||
GtkCssNumberParseFlags flags);
|
||||
GtkCssValue * gtk_css_clamp_value_parse (GtkCssParser *parser,
|
||||
GtkCssNumberParseFlags flags,
|
||||
guint type);
|
||||
GtkCssValue * gtk_css_round_value_parse (GtkCssParser *parser,
|
||||
GtkCssNumberParseFlags flags,
|
||||
guint type);
|
||||
GtkCssValue * gtk_css_arg2_value_parse (GtkCssParser *parser,
|
||||
GtkCssNumberParseFlags flags,
|
||||
guint min_args,
|
||||
guint max_args,
|
||||
const char *function,
|
||||
guint type);
|
||||
GtkCssValue * gtk_css_argn_value_parse (GtkCssParser *parser,
|
||||
GtkCssNumberParseFlags flags,
|
||||
const char *function,
|
||||
guint type);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
+164
-153
@@ -60,29 +60,29 @@ struct _GtkCssValue
|
||||
GtkCssValue *color2;
|
||||
double factor;
|
||||
} mix;
|
||||
};
|
||||
} sym_col;
|
||||
};
|
||||
|
||||
static void
|
||||
gtk_css_value_color_free (GtkCssValue *color)
|
||||
{
|
||||
if (color->last_value)
|
||||
gtk_css_value_unref (color->last_value);
|
||||
_gtk_css_value_unref (color->last_value);
|
||||
|
||||
switch (color->type)
|
||||
{
|
||||
case COLOR_TYPE_NAME:
|
||||
g_free (color->name);
|
||||
g_free (color->sym_col.name);
|
||||
break;
|
||||
case COLOR_TYPE_SHADE:
|
||||
gtk_css_value_unref (color->shade.color);
|
||||
_gtk_css_value_unref (color->sym_col.shade.color);
|
||||
break;
|
||||
case COLOR_TYPE_ALPHA:
|
||||
gtk_css_value_unref (color->alpha.color);
|
||||
_gtk_css_value_unref (color->sym_col.alpha.color);
|
||||
break;
|
||||
case COLOR_TYPE_MIX:
|
||||
gtk_css_value_unref (color->mix.color1);
|
||||
gtk_css_value_unref (color->mix.color2);
|
||||
_gtk_css_value_unref (color->sym_col.mix.color1);
|
||||
_gtk_css_value_unref (color->sym_col.mix.color2);
|
||||
break;
|
||||
case COLOR_TYPE_LITERAL:
|
||||
case COLOR_TYPE_CURRENT_COLOR:
|
||||
@@ -94,8 +94,10 @@ gtk_css_value_color_free (GtkCssValue *color)
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
gtk_css_value_color_get_fallback (guint property_id,
|
||||
GtkCssComputeContext *context)
|
||||
gtk_css_value_color_get_fallback (guint property_id,
|
||||
GtkStyleProvider *provider,
|
||||
GtkCssStyle *style,
|
||||
GtkCssStyle *parent_style)
|
||||
{
|
||||
switch (property_id)
|
||||
{
|
||||
@@ -114,58 +116,64 @@ gtk_css_value_color_get_fallback (guint property_id,
|
||||
case GTK_CSS_PROPERTY_OUTLINE_COLOR:
|
||||
case GTK_CSS_PROPERTY_CARET_COLOR:
|
||||
case GTK_CSS_PROPERTY_SECONDARY_CARET_COLOR:
|
||||
return gtk_css_value_compute (_gtk_css_style_property_get_initial_value (_gtk_css_style_property_lookup_by_id (property_id)),
|
||||
return _gtk_css_value_compute (_gtk_css_style_property_get_initial_value (_gtk_css_style_property_lookup_by_id (property_id)),
|
||||
property_id,
|
||||
context);
|
||||
provider,
|
||||
style,
|
||||
parent_style);
|
||||
case GTK_CSS_PROPERTY_ICON_PALETTE:
|
||||
return gtk_css_value_ref (context->style->core->color);
|
||||
return _gtk_css_value_ref (style->core->color);
|
||||
default:
|
||||
if (property_id < GTK_CSS_PROPERTY_N_PROPERTIES)
|
||||
g_warning ("No fallback color defined for property '%s'",
|
||||
g_warning ("No fallback color defined for property '%s'",
|
||||
_gtk_style_property_get_name (GTK_STYLE_PROPERTY (_gtk_css_style_property_lookup_by_id (property_id))));
|
||||
return gtk_css_color_value_new_transparent ();
|
||||
}
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
gtk_css_value_color_compute (GtkCssValue *value,
|
||||
guint property_id,
|
||||
GtkCssComputeContext *context)
|
||||
gtk_css_value_color_compute (GtkCssValue *value,
|
||||
guint property_id,
|
||||
GtkStyleProvider *provider,
|
||||
GtkCssStyle *style,
|
||||
GtkCssStyle *parent_style)
|
||||
{
|
||||
GtkCssValue *resolved;
|
||||
|
||||
/* The computed value of the ‘currentColor’ keyword is the computed
|
||||
* value of the ‘color’ property. If the ‘currentColor’ keyword is
|
||||
* set on the ‘color’ property itself, it is treated as ‘color: inherit’.
|
||||
* set on the ‘color’ property itself, it is treated as ‘color: inherit’.
|
||||
*/
|
||||
if (property_id == GTK_CSS_PROPERTY_COLOR)
|
||||
{
|
||||
GtkCssValue *current;
|
||||
|
||||
if (context->parent_style)
|
||||
current = context->parent_style->core->color;
|
||||
if (parent_style)
|
||||
current = parent_style->core->color;
|
||||
else
|
||||
current = NULL;
|
||||
|
||||
resolved = gtk_css_color_value_resolve (value,
|
||||
context->provider,
|
||||
current);
|
||||
resolved = _gtk_css_color_value_resolve (value,
|
||||
provider,
|
||||
current,
|
||||
NULL);
|
||||
}
|
||||
else if (value->type == COLOR_TYPE_LITERAL)
|
||||
{
|
||||
resolved = gtk_css_value_ref (value);
|
||||
resolved = _gtk_css_value_ref (value);
|
||||
}
|
||||
else
|
||||
{
|
||||
GtkCssValue *current = context->style->core->color;
|
||||
GtkCssValue *current = style->core->color;
|
||||
|
||||
resolved = gtk_css_color_value_resolve (value,
|
||||
context->provider,
|
||||
current);
|
||||
resolved = _gtk_css_color_value_resolve (value,
|
||||
provider,
|
||||
current,
|
||||
NULL);
|
||||
}
|
||||
|
||||
if (resolved == NULL)
|
||||
return gtk_css_value_color_get_fallback (property_id, context);
|
||||
return gtk_css_value_color_get_fallback (property_id, provider, style, parent_style);
|
||||
|
||||
return resolved;
|
||||
}
|
||||
@@ -180,23 +188,23 @@ gtk_css_value_color_equal (const GtkCssValue *value1,
|
||||
switch (value1->type)
|
||||
{
|
||||
case COLOR_TYPE_LITERAL:
|
||||
return gdk_rgba_equal (&value1->rgba, &value2->rgba);
|
||||
return gdk_rgba_equal (&value1->sym_col.rgba, &value2->sym_col.rgba);
|
||||
case COLOR_TYPE_NAME:
|
||||
return g_str_equal (value1->name, value2->name);
|
||||
return g_str_equal (value1->sym_col.name, value2->sym_col.name);
|
||||
case COLOR_TYPE_SHADE:
|
||||
return value1->shade.factor == value2->shade.factor &&
|
||||
gtk_css_value_equal (value1->shade.color,
|
||||
value2->shade.color);
|
||||
return value1->sym_col.shade.factor == value2->sym_col.shade.factor &&
|
||||
_gtk_css_value_equal (value1->sym_col.shade.color,
|
||||
value2->sym_col.shade.color);
|
||||
case COLOR_TYPE_ALPHA:
|
||||
return value1->alpha.factor == value2->alpha.factor &&
|
||||
gtk_css_value_equal (value1->alpha.color,
|
||||
value2->alpha.color);
|
||||
return value1->sym_col.alpha.factor == value2->sym_col.alpha.factor &&
|
||||
_gtk_css_value_equal (value1->sym_col.alpha.color,
|
||||
value2->sym_col.alpha.color);
|
||||
case COLOR_TYPE_MIX:
|
||||
return value1->mix.factor == value2->mix.factor &&
|
||||
gtk_css_value_equal (value1->mix.color1,
|
||||
value2->mix.color1) &&
|
||||
gtk_css_value_equal (value1->mix.color2,
|
||||
value2->mix.color2);
|
||||
return value1->sym_col.mix.factor == value2->sym_col.mix.factor &&
|
||||
_gtk_css_value_equal (value1->sym_col.mix.color1,
|
||||
value2->sym_col.mix.color1) &&
|
||||
_gtk_css_value_equal (value1->sym_col.mix.color2,
|
||||
value2->sym_col.mix.color2);
|
||||
case COLOR_TYPE_CURRENT_COLOR:
|
||||
return TRUE;
|
||||
default:
|
||||
@@ -211,7 +219,7 @@ gtk_css_value_color_transition (GtkCssValue *start,
|
||||
guint property_id,
|
||||
double progress)
|
||||
{
|
||||
return gtk_css_color_value_new_mix (start, end, progress);
|
||||
return _gtk_css_color_value_new_mix (start, end, progress);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -222,23 +230,23 @@ gtk_css_value_color_print (const GtkCssValue *value,
|
||||
{
|
||||
case COLOR_TYPE_LITERAL:
|
||||
{
|
||||
char *s = gdk_rgba_to_string (&value->rgba);
|
||||
char *s = gdk_rgba_to_string (&value->sym_col.rgba);
|
||||
g_string_append (string, s);
|
||||
g_free (s);
|
||||
}
|
||||
break;
|
||||
case COLOR_TYPE_NAME:
|
||||
g_string_append (string, "@");
|
||||
g_string_append (string, value->name);
|
||||
g_string_append (string, value->sym_col.name);
|
||||
break;
|
||||
case COLOR_TYPE_SHADE:
|
||||
{
|
||||
char factor[G_ASCII_DTOSTR_BUF_SIZE];
|
||||
|
||||
g_string_append (string, "shade(");
|
||||
gtk_css_value_print (value->shade.color, string);
|
||||
_gtk_css_value_print (value->sym_col.shade.color, string);
|
||||
g_string_append (string, ", ");
|
||||
g_ascii_dtostr (factor, sizeof (factor), value->shade.factor);
|
||||
g_ascii_dtostr (factor, sizeof (factor), value->sym_col.shade.factor);
|
||||
g_string_append (string, factor);
|
||||
g_string_append (string, ")");
|
||||
}
|
||||
@@ -248,9 +256,9 @@ gtk_css_value_color_print (const GtkCssValue *value,
|
||||
char factor[G_ASCII_DTOSTR_BUF_SIZE];
|
||||
|
||||
g_string_append (string, "alpha(");
|
||||
gtk_css_value_print (value->alpha.color, string);
|
||||
_gtk_css_value_print (value->sym_col.alpha.color, string);
|
||||
g_string_append (string, ", ");
|
||||
g_ascii_dtostr (factor, sizeof (factor), value->alpha.factor);
|
||||
g_ascii_dtostr (factor, sizeof (factor), value->sym_col.alpha.factor);
|
||||
g_string_append (string, factor);
|
||||
g_string_append (string, ")");
|
||||
}
|
||||
@@ -260,11 +268,11 @@ gtk_css_value_color_print (const GtkCssValue *value,
|
||||
char factor[G_ASCII_DTOSTR_BUF_SIZE];
|
||||
|
||||
g_string_append (string, "mix(");
|
||||
gtk_css_value_print (value->mix.color1, string);
|
||||
_gtk_css_value_print (value->sym_col.mix.color1, string);
|
||||
g_string_append (string, ", ");
|
||||
gtk_css_value_print (value->mix.color2, string);
|
||||
_gtk_css_value_print (value->sym_col.mix.color2, string);
|
||||
g_string_append (string, ", ");
|
||||
g_ascii_dtostr (factor, sizeof (factor), value->mix.factor);
|
||||
g_ascii_dtostr (factor, sizeof (factor), value->sym_col.mix.factor);
|
||||
g_string_append (string, factor);
|
||||
g_string_append (string, ")");
|
||||
}
|
||||
@@ -339,11 +347,11 @@ apply_mix (const GdkRGBA *in1,
|
||||
}
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
gtk_css_color_value_do_resolve (GtkCssValue *color,
|
||||
GtkStyleProvider *provider,
|
||||
GtkCssValue *current,
|
||||
GSList *cycle_list)
|
||||
GtkCssValue *
|
||||
_gtk_css_color_value_resolve (GtkCssValue *color,
|
||||
GtkStyleProvider *provider,
|
||||
GtkCssValue *current,
|
||||
GSList *cycle_list)
|
||||
{
|
||||
GtkCssValue *value;
|
||||
|
||||
@@ -352,10 +360,10 @@ gtk_css_color_value_do_resolve (GtkCssValue *color,
|
||||
switch (color->type)
|
||||
{
|
||||
case COLOR_TYPE_LITERAL:
|
||||
return gtk_css_value_ref (color);
|
||||
return _gtk_css_value_ref (color);
|
||||
case COLOR_TYPE_NAME:
|
||||
{
|
||||
GtkCssValue *named;
|
||||
GtkCssValue *named;
|
||||
GSList cycle = { color, cycle_list };
|
||||
|
||||
/* If color exists in cycle_list, we're currently resolving it.
|
||||
@@ -363,13 +371,13 @@ gtk_css_color_value_do_resolve (GtkCssValue *color,
|
||||
if (g_slist_find (cycle_list, color))
|
||||
return NULL;
|
||||
|
||||
named = gtk_style_provider_get_color (provider, color->name);
|
||||
if (named == NULL)
|
||||
return NULL;
|
||||
named = gtk_style_provider_get_color (provider, color->sym_col.name);
|
||||
if (named == NULL)
|
||||
return NULL;
|
||||
|
||||
value = gtk_css_color_value_do_resolve (named, provider, current, &cycle);
|
||||
if (value == NULL)
|
||||
return NULL;
|
||||
value = _gtk_css_color_value_resolve (named, provider, current, &cycle);
|
||||
if (value == NULL)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -379,15 +387,15 @@ gtk_css_color_value_do_resolve (GtkCssValue *color,
|
||||
GtkCssValue *val;
|
||||
GdkRGBA shade;
|
||||
|
||||
val = gtk_css_color_value_do_resolve (color->shade.color, provider, current, cycle_list);
|
||||
val = _gtk_css_color_value_resolve (color->sym_col.shade.color, provider, current, cycle_list);
|
||||
if (val == NULL)
|
||||
return NULL;
|
||||
c = gtk_css_color_value_get_rgba (val);
|
||||
|
||||
apply_shade (c, &shade, color->shade.factor);
|
||||
apply_shade (c, &shade, color->sym_col.shade.factor);
|
||||
|
||||
value = gtk_css_color_value_new_literal (&shade);
|
||||
gtk_css_value_unref (val);
|
||||
value = _gtk_css_color_value_new_literal (&shade);
|
||||
_gtk_css_value_unref (val);
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -397,15 +405,15 @@ gtk_css_color_value_do_resolve (GtkCssValue *color,
|
||||
GtkCssValue *val;
|
||||
GdkRGBA alpha;
|
||||
|
||||
val = gtk_css_color_value_do_resolve (color->alpha.color, provider, current, cycle_list);
|
||||
val = _gtk_css_color_value_resolve (color->sym_col.alpha.color, provider, current, cycle_list);
|
||||
if (val == NULL)
|
||||
return NULL;
|
||||
c = gtk_css_color_value_get_rgba (val);
|
||||
|
||||
apply_alpha (c, &alpha, color->alpha.factor);
|
||||
apply_alpha (c, &alpha, color->sym_col.alpha.factor);
|
||||
|
||||
value = gtk_css_color_value_new_literal (&alpha);
|
||||
gtk_css_value_unref (val);
|
||||
value = _gtk_css_color_value_new_literal (&alpha);
|
||||
_gtk_css_value_unref (val);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -415,34 +423,45 @@ gtk_css_color_value_do_resolve (GtkCssValue *color,
|
||||
GtkCssValue *val1, *val2;
|
||||
GdkRGBA res;
|
||||
|
||||
val1 = gtk_css_color_value_do_resolve (color->mix.color1, provider, current, cycle_list);
|
||||
val1 = _gtk_css_color_value_resolve (color->sym_col.mix.color1, provider, current, cycle_list);
|
||||
if (val1 == NULL)
|
||||
return NULL;
|
||||
color1 = gtk_css_color_value_get_rgba (val1);
|
||||
|
||||
val2 = gtk_css_color_value_do_resolve (color->mix.color2, provider, current, cycle_list);
|
||||
val2 = _gtk_css_color_value_resolve (color->sym_col.mix.color2, provider, current, cycle_list);
|
||||
if (val2 == NULL)
|
||||
return NULL;
|
||||
color2 = gtk_css_color_value_get_rgba (val2);
|
||||
|
||||
apply_mix (color1, color2, &res, color->mix.factor);
|
||||
apply_mix (color1, color2, &res, color->sym_col.mix.factor);
|
||||
|
||||
value = gtk_css_color_value_new_literal (&res);
|
||||
gtk_css_value_unref (val1);
|
||||
gtk_css_value_unref (val2);
|
||||
value = _gtk_css_color_value_new_literal (&res);
|
||||
_gtk_css_value_unref (val1);
|
||||
_gtk_css_value_unref (val2);
|
||||
}
|
||||
|
||||
break;
|
||||
case COLOR_TYPE_CURRENT_COLOR:
|
||||
if (current == NULL)
|
||||
if (current)
|
||||
{
|
||||
current = _gtk_css_style_property_get_initial_value (_gtk_css_style_property_lookup_by_id (GTK_CSS_PROPERTY_COLOR));
|
||||
|
||||
g_assert (current->class == >K_CSS_VALUE_COLOR);
|
||||
g_assert (current->type == COLOR_TYPE_LITERAL);
|
||||
return _gtk_css_value_ref (current);
|
||||
}
|
||||
else
|
||||
{
|
||||
GtkCssValue *initial = _gtk_css_style_property_get_initial_value (_gtk_css_style_property_lookup_by_id (GTK_CSS_PROPERTY_COLOR));
|
||||
|
||||
value = gtk_css_value_ref (current);
|
||||
if (initial->class == >K_CSS_VALUE_COLOR)
|
||||
{
|
||||
return _gtk_css_color_value_resolve (initial,
|
||||
provider,
|
||||
NULL,
|
||||
cycle_list);
|
||||
}
|
||||
else
|
||||
{
|
||||
return _gtk_css_value_ref (initial);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
value = NULL;
|
||||
@@ -450,85 +469,77 @@ gtk_css_color_value_do_resolve (GtkCssValue *color,
|
||||
}
|
||||
|
||||
if (color->last_value != NULL &&
|
||||
gtk_css_value_equal (color->last_value, value))
|
||||
_gtk_css_value_equal (color->last_value, value))
|
||||
{
|
||||
gtk_css_value_unref (value);
|
||||
value = gtk_css_value_ref (color->last_value);
|
||||
_gtk_css_value_unref (value);
|
||||
value = _gtk_css_value_ref (color->last_value);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (color->last_value != NULL)
|
||||
gtk_css_value_unref (color->last_value);
|
||||
color->last_value = gtk_css_value_ref (value);
|
||||
_gtk_css_value_unref (color->last_value);
|
||||
color->last_value = _gtk_css_value_ref (value);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
gtk_css_color_value_resolve (GtkCssValue *color,
|
||||
GtkStyleProvider *provider,
|
||||
GtkCssValue *current)
|
||||
{
|
||||
return gtk_css_color_value_do_resolve (color, provider, current, NULL);
|
||||
}
|
||||
|
||||
static GtkCssValue transparent_black_singleton = { >K_CSS_VALUE_COLOR, 1, TRUE, FALSE, COLOR_TYPE_LITERAL, NULL,
|
||||
.rgba = {0, 0, 0, 0} };
|
||||
static GtkCssValue white_singleton = { >K_CSS_VALUE_COLOR, 1, TRUE, FALSE, COLOR_TYPE_LITERAL, NULL,
|
||||
.rgba = {1, 1, 1, 1} };
|
||||
static GtkCssValue transparent_black_singleton = { >K_CSS_VALUE_COLOR, 1, TRUE, COLOR_TYPE_LITERAL, NULL,
|
||||
.sym_col.rgba = {0, 0, 0, 0} };
|
||||
static GtkCssValue white_singleton = { >K_CSS_VALUE_COLOR, 1, TRUE, COLOR_TYPE_LITERAL, NULL,
|
||||
.sym_col.rgba = {1, 1, 1, 1} };
|
||||
|
||||
|
||||
GtkCssValue *
|
||||
gtk_css_color_value_new_transparent (void)
|
||||
{
|
||||
return gtk_css_value_ref (&transparent_black_singleton);
|
||||
return _gtk_css_value_ref (&transparent_black_singleton);
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
gtk_css_color_value_new_white (void)
|
||||
{
|
||||
return gtk_css_value_ref (&white_singleton);
|
||||
return _gtk_css_value_ref (&white_singleton);
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
gtk_css_color_value_new_literal (const GdkRGBA *color)
|
||||
_gtk_css_color_value_new_literal (const GdkRGBA *color)
|
||||
{
|
||||
GtkCssValue *value;
|
||||
|
||||
g_return_val_if_fail (color != NULL, NULL);
|
||||
|
||||
if (gdk_rgba_equal (color, &white_singleton.rgba))
|
||||
return gtk_css_value_ref (&white_singleton);
|
||||
if (gdk_rgba_equal (color, &white_singleton.sym_col.rgba))
|
||||
return _gtk_css_value_ref (&white_singleton);
|
||||
|
||||
if (gdk_rgba_equal (color, &transparent_black_singleton.rgba))
|
||||
return gtk_css_value_ref (&transparent_black_singleton);
|
||||
if (gdk_rgba_equal (color, &transparent_black_singleton.sym_col.rgba))
|
||||
return _gtk_css_value_ref (&transparent_black_singleton);
|
||||
|
||||
value = gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_COLOR);
|
||||
value = _gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_COLOR);
|
||||
value->type = COLOR_TYPE_LITERAL;
|
||||
value->is_computed = TRUE;
|
||||
value->rgba = *color;
|
||||
value->sym_col.rgba = *color;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
gtk_css_color_value_new_name (const char *name)
|
||||
_gtk_css_color_value_new_name (const char *name)
|
||||
{
|
||||
GtkCssValue *value;
|
||||
|
||||
gtk_internal_return_val_if_fail (name != NULL, NULL);
|
||||
|
||||
value = gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_COLOR);
|
||||
value = _gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_COLOR);
|
||||
value->type = COLOR_TYPE_NAME;
|
||||
value->name = g_strdup (name);
|
||||
value->sym_col.name = g_strdup (name);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
gtk_css_color_value_new_shade (GtkCssValue *color,
|
||||
double factor)
|
||||
_gtk_css_color_value_new_shade (GtkCssValue *color,
|
||||
double factor)
|
||||
{
|
||||
GtkCssValue *value;
|
||||
|
||||
@@ -538,22 +549,22 @@ gtk_css_color_value_new_shade (GtkCssValue *color,
|
||||
{
|
||||
GdkRGBA c;
|
||||
|
||||
apply_shade (&color->rgba, &c, factor);
|
||||
apply_shade (&color->sym_col.rgba, &c, factor);
|
||||
|
||||
return gtk_css_color_value_new_literal (&c);
|
||||
return _gtk_css_color_value_new_literal (&c);
|
||||
}
|
||||
|
||||
value = gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_COLOR);
|
||||
value = _gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_COLOR);
|
||||
value->type = COLOR_TYPE_SHADE;
|
||||
value->shade.color = gtk_css_value_ref (color);
|
||||
value->shade.factor = factor;
|
||||
value->sym_col.shade.color = _gtk_css_value_ref (color);
|
||||
value->sym_col.shade.factor = factor;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
gtk_css_color_value_new_alpha (GtkCssValue *color,
|
||||
double factor)
|
||||
_gtk_css_color_value_new_alpha (GtkCssValue *color,
|
||||
double factor)
|
||||
{
|
||||
GtkCssValue *value;
|
||||
|
||||
@@ -563,23 +574,23 @@ gtk_css_color_value_new_alpha (GtkCssValue *color,
|
||||
{
|
||||
GdkRGBA c;
|
||||
|
||||
apply_alpha (&color->rgba, &c, factor);
|
||||
apply_alpha (&color->sym_col.rgba, &c, factor);
|
||||
|
||||
return gtk_css_color_value_new_literal (&c);
|
||||
return _gtk_css_color_value_new_literal (&c);
|
||||
}
|
||||
|
||||
value = gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_COLOR);
|
||||
value = _gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_COLOR);
|
||||
value->type = COLOR_TYPE_ALPHA;
|
||||
value->alpha.color = gtk_css_value_ref (color);
|
||||
value->alpha.factor = factor;
|
||||
value->sym_col.alpha.color = _gtk_css_value_ref (color);
|
||||
value->sym_col.alpha.factor = factor;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
gtk_css_color_value_new_mix (GtkCssValue *color1,
|
||||
GtkCssValue *color2,
|
||||
double factor)
|
||||
_gtk_css_color_value_new_mix (GtkCssValue *color1,
|
||||
GtkCssValue *color2,
|
||||
double factor)
|
||||
{
|
||||
GtkCssValue *value;
|
||||
|
||||
@@ -591,30 +602,30 @@ gtk_css_color_value_new_mix (GtkCssValue *color1,
|
||||
{
|
||||
GdkRGBA result;
|
||||
|
||||
apply_mix (&color1->rgba, &color2->rgba, &result, factor);
|
||||
apply_mix (&color1->sym_col.rgba, &color2->sym_col.rgba, &result, factor);
|
||||
|
||||
return gtk_css_color_value_new_literal (&result);
|
||||
return _gtk_css_color_value_new_literal (&result);
|
||||
|
||||
}
|
||||
|
||||
value = gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_COLOR);
|
||||
value = _gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_COLOR);
|
||||
value->type = COLOR_TYPE_MIX;
|
||||
value->mix.color1 = gtk_css_value_ref (color1);
|
||||
value->mix.color2 = gtk_css_value_ref (color2);
|
||||
value->mix.factor = factor;
|
||||
value->sym_col.mix.color1 = _gtk_css_value_ref (color1);
|
||||
value->sym_col.mix.color2 = _gtk_css_value_ref (color2);
|
||||
value->sym_col.mix.factor = factor;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
gtk_css_color_value_new_current_color (void)
|
||||
_gtk_css_color_value_new_current_color (void)
|
||||
{
|
||||
static GtkCssValue current_color = { >K_CSS_VALUE_COLOR, 1, FALSE, FALSE, COLOR_TYPE_CURRENT_COLOR, NULL, };
|
||||
static GtkCssValue current_color = { >K_CSS_VALUE_COLOR, 1, FALSE, COLOR_TYPE_CURRENT_COLOR, NULL, };
|
||||
|
||||
return gtk_css_value_ref (¤t_color);
|
||||
return _gtk_css_value_ref (¤t_color);
|
||||
}
|
||||
|
||||
typedef struct
|
||||
typedef struct
|
||||
{
|
||||
GtkCssValue *color;
|
||||
GtkCssValue *color2;
|
||||
@@ -631,13 +642,13 @@ parse_color_mix (GtkCssParser *parser,
|
||||
switch (arg)
|
||||
{
|
||||
case 0:
|
||||
data->color = gtk_css_color_value_parse (parser);
|
||||
data->color = _gtk_css_color_value_parse (parser);
|
||||
if (data->color == NULL)
|
||||
return 0;
|
||||
return 1;
|
||||
|
||||
case 1:
|
||||
data->color2 = gtk_css_color_value_parse (parser);
|
||||
data->color2 = _gtk_css_color_value_parse (parser);
|
||||
if (data->color2 == NULL)
|
||||
return 0;
|
||||
return 1;
|
||||
@@ -662,7 +673,7 @@ parse_color_number (GtkCssParser *parser,
|
||||
switch (arg)
|
||||
{
|
||||
case 0:
|
||||
data->color = gtk_css_color_value_parse (parser);
|
||||
data->color = _gtk_css_color_value_parse (parser);
|
||||
if (data->color == NULL)
|
||||
return 0;
|
||||
return 1;
|
||||
@@ -697,7 +708,7 @@ gtk_css_color_value_can_parse (GtkCssParser *parser)
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
gtk_css_color_value_parse (GtkCssParser *parser)
|
||||
_gtk_css_color_value_parse (GtkCssParser *parser)
|
||||
{
|
||||
ColorFunctionData data = { NULL, };
|
||||
GtkCssValue *value;
|
||||
@@ -705,13 +716,13 @@ gtk_css_color_value_parse (GtkCssParser *parser)
|
||||
|
||||
if (gtk_css_parser_try_ident (parser, "currentColor"))
|
||||
{
|
||||
return gtk_css_color_value_new_current_color ();
|
||||
return _gtk_css_color_value_new_current_color ();
|
||||
}
|
||||
else if (gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_AT_KEYWORD))
|
||||
{
|
||||
const GtkCssToken *token = gtk_css_parser_get_token (parser);
|
||||
|
||||
value = gtk_css_color_value_new_name (gtk_css_token_get_string (token));
|
||||
value = _gtk_css_color_value_new_name (gtk_css_token_get_string (token));
|
||||
gtk_css_parser_consume_token (parser);
|
||||
|
||||
return value;
|
||||
@@ -719,7 +730,7 @@ gtk_css_color_value_parse (GtkCssParser *parser)
|
||||
else if (gtk_css_parser_has_function (parser, "lighter"))
|
||||
{
|
||||
if (gtk_css_parser_consume_function (parser, 1, 1, parse_color_number, &data))
|
||||
value = gtk_css_color_value_new_shade (data.color, 1.3);
|
||||
value = _gtk_css_color_value_new_shade (data.color, 1.3);
|
||||
else
|
||||
value = NULL;
|
||||
|
||||
@@ -729,7 +740,7 @@ gtk_css_color_value_parse (GtkCssParser *parser)
|
||||
else if (gtk_css_parser_has_function (parser, "darker"))
|
||||
{
|
||||
if (gtk_css_parser_consume_function (parser, 1, 1, parse_color_number, &data))
|
||||
value = gtk_css_color_value_new_shade (data.color, 0.7);
|
||||
value = _gtk_css_color_value_new_shade (data.color, 0.7);
|
||||
else
|
||||
value = NULL;
|
||||
|
||||
@@ -739,7 +750,7 @@ gtk_css_color_value_parse (GtkCssParser *parser)
|
||||
else if (gtk_css_parser_has_function (parser, "shade"))
|
||||
{
|
||||
if (gtk_css_parser_consume_function (parser, 2, 2, parse_color_number, &data))
|
||||
value = gtk_css_color_value_new_shade (data.color, data.value);
|
||||
value = _gtk_css_color_value_new_shade (data.color, data.value);
|
||||
else
|
||||
value = NULL;
|
||||
|
||||
@@ -749,7 +760,7 @@ gtk_css_color_value_parse (GtkCssParser *parser)
|
||||
else if (gtk_css_parser_has_function (parser, "alpha"))
|
||||
{
|
||||
if (gtk_css_parser_consume_function (parser, 2, 2, parse_color_number, &data))
|
||||
value = gtk_css_color_value_new_alpha (data.color, data.value);
|
||||
value = _gtk_css_color_value_new_alpha (data.color, data.value);
|
||||
else
|
||||
value = NULL;
|
||||
|
||||
@@ -759,7 +770,7 @@ gtk_css_color_value_parse (GtkCssParser *parser)
|
||||
else if (gtk_css_parser_has_function (parser, "mix"))
|
||||
{
|
||||
if (gtk_css_parser_consume_function (parser, 3, 3, parse_color_mix, &data))
|
||||
value = gtk_css_color_value_new_mix (data.color, data.color2, data.value);
|
||||
value = _gtk_css_color_value_new_mix (data.color, data.color2, data.value);
|
||||
else
|
||||
value = NULL;
|
||||
|
||||
@@ -769,7 +780,7 @@ gtk_css_color_value_parse (GtkCssParser *parser)
|
||||
}
|
||||
|
||||
if (gdk_rgba_parser_parse (parser, &rgba))
|
||||
return gtk_css_color_value_new_literal (&rgba);
|
||||
return _gtk_css_color_value_new_literal (&rgba);
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
@@ -780,5 +791,5 @@ gtk_css_color_value_get_rgba (const GtkCssValue *color)
|
||||
g_assert (color->class == >K_CSS_VALUE_COLOR);
|
||||
g_assert (color->type == COLOR_TYPE_LITERAL);
|
||||
|
||||
return &color->rgba;
|
||||
return &color->sym_col.rgba;
|
||||
}
|
||||
|
||||
@@ -27,23 +27,24 @@ G_BEGIN_DECLS
|
||||
|
||||
GtkCssValue * gtk_css_color_value_new_transparent (void) G_GNUC_PURE;
|
||||
GtkCssValue * gtk_css_color_value_new_white (void) G_GNUC_PURE;
|
||||
GtkCssValue * gtk_css_color_value_new_literal (const GdkRGBA *color) G_GNUC_PURE;
|
||||
GtkCssValue * gtk_css_color_value_new_name (const char *name) G_GNUC_PURE;
|
||||
GtkCssValue * gtk_css_color_value_new_shade (GtkCssValue *color,
|
||||
GtkCssValue * _gtk_css_color_value_new_literal (const GdkRGBA *color) G_GNUC_PURE;
|
||||
GtkCssValue * _gtk_css_color_value_new_name (const char *name) G_GNUC_PURE;
|
||||
GtkCssValue * _gtk_css_color_value_new_shade (GtkCssValue *color,
|
||||
double factor) G_GNUC_PURE;
|
||||
GtkCssValue * gtk_css_color_value_new_alpha (GtkCssValue *color,
|
||||
GtkCssValue * _gtk_css_color_value_new_alpha (GtkCssValue *color,
|
||||
double factor) G_GNUC_PURE;
|
||||
GtkCssValue * gtk_css_color_value_new_mix (GtkCssValue *color1,
|
||||
GtkCssValue * _gtk_css_color_value_new_mix (GtkCssValue *color1,
|
||||
GtkCssValue *color2,
|
||||
double factor) G_GNUC_PURE;
|
||||
GtkCssValue * gtk_css_color_value_new_current_color (void) G_GNUC_PURE;
|
||||
GtkCssValue * _gtk_css_color_value_new_current_color (void) G_GNUC_PURE;
|
||||
|
||||
gboolean gtk_css_color_value_can_parse (GtkCssParser *parser);
|
||||
GtkCssValue * gtk_css_color_value_parse (GtkCssParser *parser);
|
||||
GtkCssValue * _gtk_css_color_value_parse (GtkCssParser *parser);
|
||||
|
||||
GtkCssValue * gtk_css_color_value_resolve (GtkCssValue *color,
|
||||
GtkCssValue * _gtk_css_color_value_resolve (GtkCssValue *color,
|
||||
GtkStyleProvider *provider,
|
||||
GtkCssValue *current);
|
||||
GtkCssValue *current,
|
||||
GSList *cycle_list);
|
||||
const GdkRGBA * gtk_css_color_value_get_rgba (const GtkCssValue *color) G_GNUC_CONST;
|
||||
|
||||
|
||||
|
||||
+41
-40
@@ -30,26 +30,28 @@ struct _GtkCssValue {
|
||||
static void
|
||||
gtk_css_value_corner_free (GtkCssValue *value)
|
||||
{
|
||||
gtk_css_value_unref (value->x);
|
||||
gtk_css_value_unref (value->y);
|
||||
_gtk_css_value_unref (value->x);
|
||||
_gtk_css_value_unref (value->y);
|
||||
|
||||
g_free (value);
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
gtk_css_value_corner_compute (GtkCssValue *corner,
|
||||
guint property_id,
|
||||
GtkCssComputeContext *context)
|
||||
gtk_css_value_corner_compute (GtkCssValue *corner,
|
||||
guint property_id,
|
||||
GtkStyleProvider *provider,
|
||||
GtkCssStyle *style,
|
||||
GtkCssStyle *parent_style)
|
||||
{
|
||||
GtkCssValue *x, *y;
|
||||
|
||||
x = gtk_css_value_compute (corner->x, property_id, context);
|
||||
y = gtk_css_value_compute (corner->y, property_id, context);
|
||||
x = _gtk_css_value_compute (corner->x, property_id, provider, style, parent_style);
|
||||
y = _gtk_css_value_compute (corner->y, property_id, provider, style, parent_style);
|
||||
if (x == corner->x && y == corner->y)
|
||||
{
|
||||
gtk_css_value_unref (x);
|
||||
gtk_css_value_unref (y);
|
||||
return gtk_css_value_ref (corner);
|
||||
_gtk_css_value_unref (x);
|
||||
_gtk_css_value_unref (y);
|
||||
return _gtk_css_value_ref (corner);
|
||||
}
|
||||
|
||||
return _gtk_css_corner_value_new (x, y);
|
||||
@@ -59,8 +61,8 @@ static gboolean
|
||||
gtk_css_value_corner_equal (const GtkCssValue *corner1,
|
||||
const GtkCssValue *corner2)
|
||||
{
|
||||
return gtk_css_value_equal (corner1->x, corner2->x)
|
||||
&& gtk_css_value_equal (corner1->y, corner2->y);
|
||||
return _gtk_css_value_equal (corner1->x, corner2->x)
|
||||
&& _gtk_css_value_equal (corner1->y, corner2->y);
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
@@ -71,13 +73,13 @@ gtk_css_value_corner_transition (GtkCssValue *start,
|
||||
{
|
||||
GtkCssValue *x, *y;
|
||||
|
||||
x = gtk_css_value_transition (start->x, end->x, property_id, progress);
|
||||
x = _gtk_css_value_transition (start->x, end->x, property_id, progress);
|
||||
if (x == NULL)
|
||||
return NULL;
|
||||
y = gtk_css_value_transition (start->y, end->y, property_id, progress);
|
||||
y = _gtk_css_value_transition (start->y, end->y, property_id, progress);
|
||||
if (y == NULL)
|
||||
{
|
||||
gtk_css_value_unref (x);
|
||||
_gtk_css_value_unref (x);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -88,11 +90,11 @@ static void
|
||||
gtk_css_value_corner_print (const GtkCssValue *corner,
|
||||
GString *string)
|
||||
{
|
||||
gtk_css_value_print (corner->x, string);
|
||||
if (!gtk_css_value_equal (corner->x, corner->y))
|
||||
_gtk_css_value_print (corner->x, string);
|
||||
if (!_gtk_css_value_equal (corner->x, corner->y))
|
||||
{
|
||||
g_string_append_c (string, ' ');
|
||||
gtk_css_value_print (corner->y, string);
|
||||
_gtk_css_value_print (corner->y, string);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,14 +110,14 @@ static const GtkCssValueClass GTK_CSS_VALUE_CORNER = {
|
||||
};
|
||||
|
||||
static GtkCssValue corner_singletons[] = {
|
||||
{ >K_CSS_VALUE_CORNER, 1, TRUE, FALSE, NULL, NULL },
|
||||
{ >K_CSS_VALUE_CORNER, 1, TRUE, FALSE, NULL, NULL },
|
||||
{ >K_CSS_VALUE_CORNER, 1, TRUE, FALSE, NULL, NULL },
|
||||
{ >K_CSS_VALUE_CORNER, 1, TRUE, FALSE, NULL, NULL },
|
||||
{ >K_CSS_VALUE_CORNER, 1, TRUE, FALSE, NULL, NULL },
|
||||
{ >K_CSS_VALUE_CORNER, 1, TRUE, FALSE, NULL, NULL },
|
||||
{ >K_CSS_VALUE_CORNER, 1, TRUE, FALSE, NULL, NULL },
|
||||
{ >K_CSS_VALUE_CORNER, 1, TRUE, FALSE, NULL, NULL },
|
||||
{ >K_CSS_VALUE_CORNER, 1, TRUE, NULL, NULL },
|
||||
{ >K_CSS_VALUE_CORNER, 1, TRUE, NULL, NULL },
|
||||
{ >K_CSS_VALUE_CORNER, 1, TRUE, NULL, NULL },
|
||||
{ >K_CSS_VALUE_CORNER, 1, TRUE, NULL, NULL },
|
||||
{ >K_CSS_VALUE_CORNER, 1, TRUE, NULL, NULL },
|
||||
{ >K_CSS_VALUE_CORNER, 1, TRUE, NULL, NULL },
|
||||
{ >K_CSS_VALUE_CORNER, 1, TRUE, NULL, NULL },
|
||||
{ >K_CSS_VALUE_CORNER, 1, TRUE, NULL, NULL },
|
||||
};
|
||||
|
||||
static inline void
|
||||
@@ -158,7 +160,7 @@ _gtk_css_corner_value_new (GtkCssValue *x,
|
||||
}
|
||||
}
|
||||
|
||||
result = gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_CORNER);
|
||||
result = _gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_CORNER);
|
||||
result->x = x;
|
||||
result->y = y;
|
||||
|
||||
@@ -170,24 +172,24 @@ _gtk_css_corner_value_parse (GtkCssParser *parser)
|
||||
{
|
||||
GtkCssValue *x, *y;
|
||||
|
||||
x = gtk_css_number_value_parse (parser,
|
||||
GTK_CSS_POSITIVE_ONLY
|
||||
| GTK_CSS_PARSE_PERCENT
|
||||
| GTK_CSS_PARSE_LENGTH);
|
||||
x = _gtk_css_number_value_parse (parser,
|
||||
GTK_CSS_POSITIVE_ONLY
|
||||
| GTK_CSS_PARSE_PERCENT
|
||||
| GTK_CSS_PARSE_LENGTH);
|
||||
if (x == NULL)
|
||||
return NULL;
|
||||
|
||||
if (!gtk_css_number_value_can_parse (parser))
|
||||
y = gtk_css_value_ref (x);
|
||||
y = _gtk_css_value_ref (x);
|
||||
else
|
||||
{
|
||||
y = gtk_css_number_value_parse (parser,
|
||||
GTK_CSS_POSITIVE_ONLY
|
||||
| GTK_CSS_PARSE_PERCENT
|
||||
| GTK_CSS_PARSE_LENGTH);
|
||||
y = _gtk_css_number_value_parse (parser,
|
||||
GTK_CSS_POSITIVE_ONLY
|
||||
| GTK_CSS_PARSE_PERCENT
|
||||
| GTK_CSS_PARSE_LENGTH);
|
||||
if (y == NULL)
|
||||
{
|
||||
gtk_css_value_unref (x);
|
||||
_gtk_css_value_unref (x);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@@ -202,7 +204,7 @@ _gtk_css_corner_value_get_x (const GtkCssValue *corner,
|
||||
g_return_val_if_fail (corner != NULL, 0.0);
|
||||
g_return_val_if_fail (corner->class == >K_CSS_VALUE_CORNER, 0.0);
|
||||
|
||||
return gtk_css_number_value_get (corner->x, one_hundred_percent);
|
||||
return _gtk_css_number_value_get (corner->x, one_hundred_percent);
|
||||
}
|
||||
|
||||
double
|
||||
@@ -212,7 +214,7 @@ _gtk_css_corner_value_get_y (const GtkCssValue *corner,
|
||||
g_return_val_if_fail (corner != NULL, 0.0);
|
||||
g_return_val_if_fail (corner->class == >K_CSS_VALUE_CORNER, 0.0);
|
||||
|
||||
return gtk_css_number_value_get (corner->y, one_hundred_percent);
|
||||
return _gtk_css_number_value_get (corner->y, one_hundred_percent);
|
||||
}
|
||||
|
||||
gboolean
|
||||
@@ -224,4 +226,3 @@ gtk_css_corner_value_is_zero (const GtkCssValue *corner)
|
||||
return gtk_css_dimension_value_is_zero (corner->x) &&
|
||||
gtk_css_dimension_value_is_zero (corner->y);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,161 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2023 GNOME Foundation Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Alice Mikhaylenko <alicem@gnome.org>
|
||||
*/
|
||||
|
||||
#include "gtkcsscustompropertypoolprivate.h"
|
||||
|
||||
struct _GtkCssCustomPropertyPool
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
GArray *names;
|
||||
GHashTable *name_mappings;
|
||||
};
|
||||
|
||||
struct _GtkCssCustomPropertyName
|
||||
{
|
||||
int ref_count;
|
||||
char *name;
|
||||
};
|
||||
|
||||
typedef struct _GtkCssCustomPropertyName GtkCssCustomPropertyName;
|
||||
|
||||
static GtkCssCustomPropertyPool *instance = NULL;
|
||||
|
||||
G_DEFINE_FINAL_TYPE (GtkCssCustomPropertyPool, gtk_css_custom_property_pool, G_TYPE_OBJECT)
|
||||
|
||||
static void
|
||||
clear_custom_property_name (GtkCssCustomPropertyName *name)
|
||||
{
|
||||
g_clear_pointer (&name->name, g_free);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_custom_property_pool_finalize (GObject *object)
|
||||
{
|
||||
GtkCssCustomPropertyPool *self = (GtkCssCustomPropertyPool *)object;
|
||||
|
||||
g_hash_table_unref (self->name_mappings);
|
||||
g_array_unref (self->names);
|
||||
|
||||
G_OBJECT_CLASS (gtk_css_custom_property_pool_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_custom_property_pool_class_init (GtkCssCustomPropertyPoolClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->finalize = gtk_css_custom_property_pool_finalize;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_custom_property_pool_init (GtkCssCustomPropertyPool *self)
|
||||
{
|
||||
self->name_mappings = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
self->names = g_array_new (FALSE, FALSE, sizeof (GtkCssCustomPropertyName));
|
||||
|
||||
g_array_set_clear_func (self->names, (GDestroyNotify) clear_custom_property_name);
|
||||
}
|
||||
|
||||
GtkCssCustomPropertyPool *
|
||||
gtk_css_custom_property_pool_get (void)
|
||||
{
|
||||
if (instance == NULL)
|
||||
instance = g_object_new (GTK_TYPE_CSS_CUSTOM_PROPERTY_POOL, NULL);
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
int
|
||||
gtk_css_custom_property_pool_add (GtkCssCustomPropertyPool *self,
|
||||
const char *str)
|
||||
{
|
||||
GtkCssCustomPropertyName name;
|
||||
int id;
|
||||
|
||||
id = gtk_css_custom_property_pool_lookup (self, str);
|
||||
if (id > 0)
|
||||
return gtk_css_custom_property_pool_ref (self, id);
|
||||
|
||||
name.ref_count = 1;
|
||||
name.name = g_strdup (str);
|
||||
|
||||
// TODO reuse slots after they're gone
|
||||
g_array_append_val (self->names, name);
|
||||
|
||||
id = self->names->len;
|
||||
|
||||
g_hash_table_insert (self->name_mappings, (char *) name.name, GINT_TO_POINTER (id));
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
int
|
||||
gtk_css_custom_property_pool_lookup (GtkCssCustomPropertyPool *self,
|
||||
const char *str)
|
||||
{
|
||||
gpointer id;
|
||||
|
||||
id = g_hash_table_lookup (self->name_mappings, str);
|
||||
|
||||
return GPOINTER_TO_INT (id);
|
||||
}
|
||||
|
||||
int
|
||||
gtk_css_custom_property_pool_ref (GtkCssCustomPropertyPool *self,
|
||||
int id)
|
||||
{
|
||||
GtkCssCustomPropertyName *name;
|
||||
|
||||
name = &g_array_index (self->names, GtkCssCustomPropertyName, id - 1);
|
||||
|
||||
name->ref_count++;
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
void
|
||||
gtk_css_custom_property_pool_unref (GtkCssCustomPropertyPool *self,
|
||||
int id)
|
||||
{
|
||||
GtkCssCustomPropertyName *name;
|
||||
|
||||
name = &g_array_index (self->names, GtkCssCustomPropertyName, id - 1);
|
||||
|
||||
g_assert (name->ref_count > 0);
|
||||
|
||||
name->ref_count--;
|
||||
|
||||
if (name->ref_count == 0)
|
||||
{
|
||||
g_hash_table_remove (self->name_mappings, name->name);
|
||||
clear_custom_property_name (name);
|
||||
}
|
||||
}
|
||||
|
||||
const char *
|
||||
gtk_css_custom_property_pool_get_name (GtkCssCustomPropertyPool *self,
|
||||
int id)
|
||||
{
|
||||
GtkCssCustomPropertyName *name;
|
||||
|
||||
name = &g_array_index (self->names, GtkCssCustomPropertyName, id - 1);
|
||||
|
||||
return name->name;
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2023 GNOME Foundation Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Authors: Alice Mikhaylenko <alicem@gnome.org>
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GTK_TYPE_CSS_CUSTOM_PROPERTY_POOL (gtk_css_custom_property_pool_get_type())
|
||||
|
||||
G_DECLARE_FINAL_TYPE (GtkCssCustomPropertyPool, gtk_css_custom_property_pool, GTK, CSS_CUSTOM_PROPERTY_POOL, GObject)
|
||||
|
||||
GtkCssCustomPropertyPool *gtk_css_custom_property_pool_get (void);
|
||||
|
||||
int gtk_css_custom_property_pool_add (GtkCssCustomPropertyPool *self,
|
||||
const char *str);
|
||||
int gtk_css_custom_property_pool_lookup (GtkCssCustomPropertyPool *self,
|
||||
const char *str);
|
||||
const char * gtk_css_custom_property_pool_get_name (GtkCssCustomPropertyPool *self,
|
||||
int id);
|
||||
int gtk_css_custom_property_pool_ref (GtkCssCustomPropertyPool *self,
|
||||
int id);
|
||||
void gtk_css_custom_property_pool_unref (GtkCssCustomPropertyPool *self,
|
||||
int id);
|
||||
|
||||
G_END_DECLS
|
||||
@@ -50,11 +50,13 @@ gtk_css_value_ease_free (GtkCssValue *value)
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
gtk_css_value_ease_compute (GtkCssValue *value,
|
||||
guint property_id,
|
||||
GtkCssComputeContext *context)
|
||||
gtk_css_value_ease_compute (GtkCssValue *value,
|
||||
guint property_id,
|
||||
GtkStyleProvider *provider,
|
||||
GtkCssStyle *style,
|
||||
GtkCssStyle *parent_style)
|
||||
{
|
||||
return gtk_css_value_ref (value);
|
||||
return _gtk_css_value_ref (value);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -156,7 +158,7 @@ _gtk_css_ease_value_new_cubic_bezier (double x1,
|
||||
g_return_val_if_fail (x2 >= 0.0, NULL);
|
||||
g_return_val_if_fail (x2 <= 1.0, NULL);
|
||||
|
||||
value = gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_EASE);
|
||||
value = _gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_EASE);
|
||||
|
||||
value->type = GTK_CSS_EASE_CUBIC_BEZIER;
|
||||
value->u.cubic.x1 = x1;
|
||||
@@ -176,7 +178,7 @@ _gtk_css_ease_value_new_steps (guint n_steps,
|
||||
|
||||
g_return_val_if_fail (n_steps > 0, NULL);
|
||||
|
||||
value = gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_EASE);
|
||||
value = _gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_EASE);
|
||||
|
||||
value->type = GTK_CSS_EASE_STEPS;
|
||||
value->u.steps.steps = n_steps;
|
||||
@@ -405,4 +407,3 @@ _gtk_css_ease_value_transform (const GtkCssValue *ease,
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
+150
-148
@@ -41,11 +41,13 @@ gtk_css_value_enum_free (GtkCssValue *value)
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
gtk_css_value_enum_compute (GtkCssValue *value,
|
||||
guint property_id,
|
||||
GtkCssComputeContext *context)
|
||||
gtk_css_value_enum_compute (GtkCssValue *value,
|
||||
guint property_id,
|
||||
GtkStyleProvider *provider,
|
||||
GtkCssStyle *style,
|
||||
GtkCssStyle *parent_style)
|
||||
{
|
||||
return gtk_css_value_ref (value);
|
||||
return _gtk_css_value_ref (value);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -85,16 +87,16 @@ static const GtkCssValueClass GTK_CSS_VALUE_BORDER_STYLE = {
|
||||
};
|
||||
|
||||
static GtkCssValue border_style_values[] = {
|
||||
{ >K_CSS_VALUE_BORDER_STYLE, 1, TRUE, FALSE, GTK_BORDER_STYLE_NONE, "none" },
|
||||
{ >K_CSS_VALUE_BORDER_STYLE, 1, TRUE, FALSE, GTK_BORDER_STYLE_SOLID, "solid" },
|
||||
{ >K_CSS_VALUE_BORDER_STYLE, 1, TRUE, FALSE, GTK_BORDER_STYLE_INSET, "inset" },
|
||||
{ >K_CSS_VALUE_BORDER_STYLE, 1, TRUE, FALSE, GTK_BORDER_STYLE_OUTSET, "outset" },
|
||||
{ >K_CSS_VALUE_BORDER_STYLE, 1, TRUE, FALSE, GTK_BORDER_STYLE_HIDDEN, "hidden" },
|
||||
{ >K_CSS_VALUE_BORDER_STYLE, 1, TRUE, FALSE, GTK_BORDER_STYLE_DOTTED, "dotted" },
|
||||
{ >K_CSS_VALUE_BORDER_STYLE, 1, TRUE, FALSE, GTK_BORDER_STYLE_DASHED, "dashed" },
|
||||
{ >K_CSS_VALUE_BORDER_STYLE, 1, TRUE, FALSE, GTK_BORDER_STYLE_DOUBLE, "double" },
|
||||
{ >K_CSS_VALUE_BORDER_STYLE, 1, TRUE, FALSE, GTK_BORDER_STYLE_GROOVE, "groove" },
|
||||
{ >K_CSS_VALUE_BORDER_STYLE, 1, TRUE, FALSE, GTK_BORDER_STYLE_RIDGE, "ridge" }
|
||||
{ >K_CSS_VALUE_BORDER_STYLE, 1, TRUE, GTK_BORDER_STYLE_NONE, "none" },
|
||||
{ >K_CSS_VALUE_BORDER_STYLE, 1, TRUE, GTK_BORDER_STYLE_SOLID, "solid" },
|
||||
{ >K_CSS_VALUE_BORDER_STYLE, 1, TRUE, GTK_BORDER_STYLE_INSET, "inset" },
|
||||
{ >K_CSS_VALUE_BORDER_STYLE, 1, TRUE, GTK_BORDER_STYLE_OUTSET, "outset" },
|
||||
{ >K_CSS_VALUE_BORDER_STYLE, 1, TRUE, GTK_BORDER_STYLE_HIDDEN, "hidden" },
|
||||
{ >K_CSS_VALUE_BORDER_STYLE, 1, TRUE, GTK_BORDER_STYLE_DOTTED, "dotted" },
|
||||
{ >K_CSS_VALUE_BORDER_STYLE, 1, TRUE, GTK_BORDER_STYLE_DASHED, "dashed" },
|
||||
{ >K_CSS_VALUE_BORDER_STYLE, 1, TRUE, GTK_BORDER_STYLE_DOUBLE, "double" },
|
||||
{ >K_CSS_VALUE_BORDER_STYLE, 1, TRUE, GTK_BORDER_STYLE_GROOVE, "groove" },
|
||||
{ >K_CSS_VALUE_BORDER_STYLE, 1, TRUE, GTK_BORDER_STYLE_RIDGE, "ridge" }
|
||||
};
|
||||
|
||||
GtkCssValue *
|
||||
@@ -102,7 +104,7 @@ _gtk_css_border_style_value_new (GtkBorderStyle border_style)
|
||||
{
|
||||
g_return_val_if_fail (border_style < G_N_ELEMENTS (border_style_values), NULL);
|
||||
|
||||
return gtk_css_value_ref (&border_style_values[border_style]);
|
||||
return _gtk_css_value_ref (&border_style_values[border_style]);
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
@@ -115,7 +117,7 @@ _gtk_css_border_style_value_try_parse (GtkCssParser *parser)
|
||||
for (i = 0; i < G_N_ELEMENTS (border_style_values); i++)
|
||||
{
|
||||
if (gtk_css_parser_try_ident (parser, border_style_values[i].name))
|
||||
return gtk_css_value_ref (&border_style_values[i]);
|
||||
return _gtk_css_value_ref (&border_style_values[i]);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -143,22 +145,22 @@ static const GtkCssValueClass GTK_CSS_VALUE_BLEND_MODE = {
|
||||
};
|
||||
|
||||
static GtkCssValue blend_mode_values[] = {
|
||||
{ >K_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_DEFAULT, "normal" },
|
||||
{ >K_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_MULTIPLY, "multiply" },
|
||||
{ >K_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_SCREEN, "screen" },
|
||||
{ >K_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_OVERLAY, "overlay" },
|
||||
{ >K_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_DARKEN, "darken" },
|
||||
{ >K_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_LIGHTEN, "lighten" },
|
||||
{ >K_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_COLOR_DODGE, "color-dodge" },
|
||||
{ >K_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_COLOR_BURN, "color-burn" },
|
||||
{ >K_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_HARD_LIGHT, "hard-light" },
|
||||
{ >K_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_SOFT_LIGHT, "soft-light" },
|
||||
{ >K_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_DIFFERENCE, "difference" },
|
||||
{ >K_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_EXCLUSION, "exclusion" },
|
||||
{ >K_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_COLOR, "color" },
|
||||
{ >K_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_HUE, "hue" },
|
||||
{ >K_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_SATURATION, "saturation" },
|
||||
{ >K_CSS_VALUE_BLEND_MODE, 1, TRUE, FALSE, GSK_BLEND_MODE_LUMINOSITY, "luminosity" }
|
||||
{ >K_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_DEFAULT, "normal" },
|
||||
{ >K_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_MULTIPLY, "multiply" },
|
||||
{ >K_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_SCREEN, "screen" },
|
||||
{ >K_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_OVERLAY, "overlay" },
|
||||
{ >K_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_DARKEN, "darken" },
|
||||
{ >K_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_LIGHTEN, "lighten" },
|
||||
{ >K_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_COLOR_DODGE, "color-dodge" },
|
||||
{ >K_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_COLOR_BURN, "color-burn" },
|
||||
{ >K_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_HARD_LIGHT, "hard-light" },
|
||||
{ >K_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_SOFT_LIGHT, "soft-light" },
|
||||
{ >K_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_DIFFERENCE, "difference" },
|
||||
{ >K_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_EXCLUSION, "exclusion" },
|
||||
{ >K_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_COLOR, "color" },
|
||||
{ >K_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_HUE, "hue" },
|
||||
{ >K_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_SATURATION, "saturation" },
|
||||
{ >K_CSS_VALUE_BLEND_MODE, 1, TRUE, GSK_BLEND_MODE_LUMINOSITY, "luminosity" }
|
||||
};
|
||||
|
||||
GtkCssValue *
|
||||
@@ -166,7 +168,7 @@ _gtk_css_blend_mode_value_new (GskBlendMode blend_mode)
|
||||
{
|
||||
g_return_val_if_fail (blend_mode < G_N_ELEMENTS (blend_mode_values), NULL);
|
||||
|
||||
return gtk_css_value_ref (&blend_mode_values[blend_mode]);
|
||||
return _gtk_css_value_ref (&blend_mode_values[blend_mode]);
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
@@ -179,7 +181,7 @@ _gtk_css_blend_mode_value_try_parse (GtkCssParser *parser)
|
||||
for (i = 0; i < G_N_ELEMENTS (blend_mode_values); i++)
|
||||
{
|
||||
if (gtk_css_parser_try_ident (parser, blend_mode_values[i].name))
|
||||
return gtk_css_value_ref (&blend_mode_values[i]);
|
||||
return _gtk_css_value_ref (&blend_mode_values[i]);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -198,7 +200,7 @@ _gtk_css_blend_mode_value_get (const GtkCssValue *value)
|
||||
static double
|
||||
get_dpi (GtkCssStyle *style)
|
||||
{
|
||||
return gtk_css_number_value_get (style->core->dpi, 96);
|
||||
return _gtk_css_number_value_get (style->core->dpi, 96);
|
||||
}
|
||||
|
||||
/* XXX: Kinda bad to have that machinery here, nobody expects vital font
|
||||
@@ -227,14 +229,12 @@ gtk_css_font_size_get_default_px (GtkStyleProvider *provider,
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
gtk_css_value_font_size_compute (GtkCssValue *value,
|
||||
guint property_id,
|
||||
GtkCssComputeContext *context)
|
||||
gtk_css_value_font_size_compute (GtkCssValue *value,
|
||||
guint property_id,
|
||||
GtkStyleProvider *provider,
|
||||
GtkCssStyle *style,
|
||||
GtkCssStyle *parent_style)
|
||||
{
|
||||
GtkStyleProvider *provider = context->provider;
|
||||
GtkCssStyle *style = context->style;
|
||||
GtkCssStyle *parent_style = context->parent_style;
|
||||
|
||||
double font_size;
|
||||
|
||||
switch (value->value)
|
||||
@@ -265,7 +265,7 @@ gtk_css_value_font_size_compute (GtkCssValue *value,
|
||||
break;
|
||||
case GTK_CSS_FONT_SIZE_SMALLER:
|
||||
if (parent_style)
|
||||
font_size = gtk_css_number_value_get (parent_style->core->font_size, 100);
|
||||
font_size = _gtk_css_number_value_get (parent_style->core->font_size, 100);
|
||||
else
|
||||
font_size = gtk_css_font_size_get_default_px (provider, style);
|
||||
/* This is what WebKit does... */
|
||||
@@ -273,7 +273,7 @@ gtk_css_value_font_size_compute (GtkCssValue *value,
|
||||
break;
|
||||
case GTK_CSS_FONT_SIZE_LARGER:
|
||||
if (parent_style)
|
||||
font_size = gtk_css_number_value_get (parent_style->core->font_size, 100);
|
||||
font_size = _gtk_css_number_value_get (parent_style->core->font_size, 100);
|
||||
else
|
||||
font_size = gtk_css_font_size_get_default_px (provider, style);
|
||||
/* This is what WebKit does... */
|
||||
@@ -281,7 +281,7 @@ gtk_css_value_font_size_compute (GtkCssValue *value,
|
||||
break;
|
||||
}
|
||||
|
||||
return gtk_css_number_value_new (font_size, GTK_CSS_PX);
|
||||
return _gtk_css_number_value_new (font_size, GTK_CSS_PX);
|
||||
}
|
||||
|
||||
static const GtkCssValueClass GTK_CSS_VALUE_FONT_SIZE = {
|
||||
@@ -296,15 +296,15 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_SIZE = {
|
||||
};
|
||||
|
||||
static GtkCssValue font_size_values[] = {
|
||||
{ >K_CSS_VALUE_FONT_SIZE, 1, FALSE, FALSE, GTK_CSS_FONT_SIZE_SMALLER, "smaller" },
|
||||
{ >K_CSS_VALUE_FONT_SIZE, 1, FALSE, FALSE, GTK_CSS_FONT_SIZE_LARGER, "larger" },
|
||||
{ >K_CSS_VALUE_FONT_SIZE, 1, FALSE, FALSE, GTK_CSS_FONT_SIZE_XX_SMALL, "xx-small" },
|
||||
{ >K_CSS_VALUE_FONT_SIZE, 1, FALSE, FALSE, GTK_CSS_FONT_SIZE_X_SMALL, "x-small" },
|
||||
{ >K_CSS_VALUE_FONT_SIZE, 1, FALSE, FALSE, GTK_CSS_FONT_SIZE_SMALL, "small" },
|
||||
{ >K_CSS_VALUE_FONT_SIZE, 1, FALSE, FALSE, GTK_CSS_FONT_SIZE_MEDIUM, "medium" },
|
||||
{ >K_CSS_VALUE_FONT_SIZE, 1, FALSE, FALSE, GTK_CSS_FONT_SIZE_LARGE, "large" },
|
||||
{ >K_CSS_VALUE_FONT_SIZE, 1, FALSE, FALSE, GTK_CSS_FONT_SIZE_X_LARGE, "x-large" },
|
||||
{ >K_CSS_VALUE_FONT_SIZE, 1, FALSE, FALSE, GTK_CSS_FONT_SIZE_XX_LARGE, "xx-large" }
|
||||
{ >K_CSS_VALUE_FONT_SIZE, 1, FALSE, GTK_CSS_FONT_SIZE_SMALLER, "smaller" },
|
||||
{ >K_CSS_VALUE_FONT_SIZE, 1, FALSE, GTK_CSS_FONT_SIZE_LARGER, "larger" },
|
||||
{ >K_CSS_VALUE_FONT_SIZE, 1, FALSE, GTK_CSS_FONT_SIZE_XX_SMALL, "xx-small" },
|
||||
{ >K_CSS_VALUE_FONT_SIZE, 1, FALSE, GTK_CSS_FONT_SIZE_X_SMALL, "x-small" },
|
||||
{ >K_CSS_VALUE_FONT_SIZE, 1, FALSE, GTK_CSS_FONT_SIZE_SMALL, "small" },
|
||||
{ >K_CSS_VALUE_FONT_SIZE, 1, FALSE, GTK_CSS_FONT_SIZE_MEDIUM, "medium" },
|
||||
{ >K_CSS_VALUE_FONT_SIZE, 1, FALSE, GTK_CSS_FONT_SIZE_LARGE, "large" },
|
||||
{ >K_CSS_VALUE_FONT_SIZE, 1, FALSE, GTK_CSS_FONT_SIZE_X_LARGE, "x-large" },
|
||||
{ >K_CSS_VALUE_FONT_SIZE, 1, FALSE, GTK_CSS_FONT_SIZE_XX_LARGE, "xx-large" }
|
||||
};
|
||||
|
||||
GtkCssValue *
|
||||
@@ -312,7 +312,7 @@ _gtk_css_font_size_value_new (GtkCssFontSize font_size)
|
||||
{
|
||||
g_return_val_if_fail (font_size < G_N_ELEMENTS (font_size_values), NULL);
|
||||
|
||||
return gtk_css_value_ref (&font_size_values[font_size]);
|
||||
return _gtk_css_value_ref (&font_size_values[font_size]);
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
@@ -325,7 +325,7 @@ _gtk_css_font_size_value_try_parse (GtkCssParser *parser)
|
||||
for (i = 0; i < G_N_ELEMENTS (font_size_values); i++)
|
||||
{
|
||||
if (gtk_css_parser_try_ident (parser, font_size_values[i].name))
|
||||
return gtk_css_value_ref (&font_size_values[i]);
|
||||
return _gtk_css_value_ref (&font_size_values[i]);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -353,9 +353,9 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_STYLE = {
|
||||
};
|
||||
|
||||
static GtkCssValue font_style_values[] = {
|
||||
{ >K_CSS_VALUE_FONT_STYLE, 1, TRUE, FALSE, PANGO_STYLE_NORMAL, "normal" },
|
||||
{ >K_CSS_VALUE_FONT_STYLE, 1, TRUE, FALSE, PANGO_STYLE_OBLIQUE, "oblique" },
|
||||
{ >K_CSS_VALUE_FONT_STYLE, 1, TRUE, FALSE, PANGO_STYLE_ITALIC, "italic" }
|
||||
{ >K_CSS_VALUE_FONT_STYLE, 1, TRUE, PANGO_STYLE_NORMAL, "normal" },
|
||||
{ >K_CSS_VALUE_FONT_STYLE, 1, TRUE, PANGO_STYLE_OBLIQUE, "oblique" },
|
||||
{ >K_CSS_VALUE_FONT_STYLE, 1, TRUE, PANGO_STYLE_ITALIC, "italic" }
|
||||
};
|
||||
|
||||
GtkCssValue *
|
||||
@@ -363,7 +363,7 @@ _gtk_css_font_style_value_new (PangoStyle font_style)
|
||||
{
|
||||
g_return_val_if_fail (font_style < G_N_ELEMENTS (font_style_values), NULL);
|
||||
|
||||
return gtk_css_value_ref (&font_style_values[font_style]);
|
||||
return _gtk_css_value_ref (&font_style_values[font_style]);
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
@@ -376,7 +376,7 @@ _gtk_css_font_style_value_try_parse (GtkCssParser *parser)
|
||||
for (i = 0; i < G_N_ELEMENTS (font_style_values); i++)
|
||||
{
|
||||
if (gtk_css_parser_try_ident (parser, font_style_values[i].name))
|
||||
return gtk_css_value_ref (&font_style_values[i]);
|
||||
return _gtk_css_value_ref (&font_style_values[i]);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -396,18 +396,20 @@ _gtk_css_font_style_value_get (const GtkCssValue *value)
|
||||
#define LIGHTER -2
|
||||
|
||||
static GtkCssValue *
|
||||
gtk_css_value_font_weight_compute (GtkCssValue *value,
|
||||
guint property_id,
|
||||
GtkCssComputeContext *context)
|
||||
gtk_css_value_font_weight_compute (GtkCssValue *value,
|
||||
guint property_id,
|
||||
GtkStyleProvider *provider,
|
||||
GtkCssStyle *style,
|
||||
GtkCssStyle *parent_style)
|
||||
{
|
||||
PangoWeight new_weight;
|
||||
int parent_value;
|
||||
|
||||
if (value->value >= 0)
|
||||
return gtk_css_value_ref (value);
|
||||
return _gtk_css_value_ref (value);
|
||||
|
||||
if (context->parent_style)
|
||||
parent_value = gtk_css_number_value_get (context->parent_style->font->font_weight, 100);
|
||||
if (parent_style)
|
||||
parent_value = _gtk_css_number_value_get (parent_style->font->font_weight, 100);
|
||||
else
|
||||
parent_value = 400;
|
||||
|
||||
@@ -435,7 +437,7 @@ gtk_css_value_font_weight_compute (GtkCssValue *value,
|
||||
new_weight = PANGO_WEIGHT_NORMAL;
|
||||
}
|
||||
|
||||
return gtk_css_number_value_new (new_weight, GTK_CSS_NUMBER);
|
||||
return _gtk_css_number_value_new (new_weight, GTK_CSS_NUMBER);
|
||||
}
|
||||
|
||||
static const GtkCssValueClass GTK_CSS_VALUE_FONT_WEIGHT = {
|
||||
@@ -450,8 +452,8 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_WEIGHT = {
|
||||
};
|
||||
|
||||
static GtkCssValue font_weight_values[] = {
|
||||
{ >K_CSS_VALUE_FONT_WEIGHT, 1, FALSE, FALSE, BOLDER, "bolder" },
|
||||
{ >K_CSS_VALUE_FONT_WEIGHT, 1, FALSE, FALSE, LIGHTER, "lighter" },
|
||||
{ >K_CSS_VALUE_FONT_WEIGHT, 1, FALSE, BOLDER, "bolder" },
|
||||
{ >K_CSS_VALUE_FONT_WEIGHT, 1, FALSE, LIGHTER, "lighter" },
|
||||
};
|
||||
|
||||
GtkCssValue *
|
||||
@@ -464,13 +466,13 @@ gtk_css_font_weight_value_try_parse (GtkCssParser *parser)
|
||||
for (i = 0; i < G_N_ELEMENTS (font_weight_values); i++)
|
||||
{
|
||||
if (gtk_css_parser_try_ident (parser, font_weight_values[i].name))
|
||||
return gtk_css_value_ref (&font_weight_values[i]);
|
||||
return _gtk_css_value_ref (&font_weight_values[i]);
|
||||
}
|
||||
|
||||
if (gtk_css_parser_try_ident (parser, "normal"))
|
||||
return gtk_css_number_value_new (PANGO_WEIGHT_NORMAL, GTK_CSS_NUMBER);
|
||||
return _gtk_css_number_value_new (PANGO_WEIGHT_NORMAL, GTK_CSS_NUMBER);
|
||||
if (gtk_css_parser_try_ident (parser, "bold"))
|
||||
return gtk_css_number_value_new (PANGO_WEIGHT_BOLD, GTK_CSS_NUMBER);
|
||||
return _gtk_css_number_value_new (PANGO_WEIGHT_BOLD, GTK_CSS_NUMBER);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -500,15 +502,15 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_STRETCH = {
|
||||
};
|
||||
|
||||
static GtkCssValue font_stretch_values[] = {
|
||||
{ >K_CSS_VALUE_FONT_STRETCH, 1, TRUE, FALSE, PANGO_STRETCH_ULTRA_CONDENSED, "ultra-condensed" },
|
||||
{ >K_CSS_VALUE_FONT_STRETCH, 1, TRUE, FALSE, PANGO_STRETCH_EXTRA_CONDENSED, "extra-condensed" },
|
||||
{ >K_CSS_VALUE_FONT_STRETCH, 1, TRUE, FALSE, PANGO_STRETCH_CONDENSED, "condensed" },
|
||||
{ >K_CSS_VALUE_FONT_STRETCH, 1, TRUE, FALSE, PANGO_STRETCH_SEMI_CONDENSED, "semi-condensed" },
|
||||
{ >K_CSS_VALUE_FONT_STRETCH, 1, TRUE, FALSE, PANGO_STRETCH_NORMAL, "normal" },
|
||||
{ >K_CSS_VALUE_FONT_STRETCH, 1, TRUE, FALSE, PANGO_STRETCH_SEMI_EXPANDED, "semi-expanded" },
|
||||
{ >K_CSS_VALUE_FONT_STRETCH, 1, TRUE, FALSE, PANGO_STRETCH_EXPANDED, "expanded" },
|
||||
{ >K_CSS_VALUE_FONT_STRETCH, 1, TRUE, FALSE, PANGO_STRETCH_EXTRA_EXPANDED, "extra-expanded" },
|
||||
{ >K_CSS_VALUE_FONT_STRETCH, 1, TRUE, FALSE, PANGO_STRETCH_ULTRA_EXPANDED, "ultra-expanded" },
|
||||
{ >K_CSS_VALUE_FONT_STRETCH, 1, TRUE, PANGO_STRETCH_ULTRA_CONDENSED, "ultra-condensed" },
|
||||
{ >K_CSS_VALUE_FONT_STRETCH, 1, TRUE, PANGO_STRETCH_EXTRA_CONDENSED, "extra-condensed" },
|
||||
{ >K_CSS_VALUE_FONT_STRETCH, 1, TRUE, PANGO_STRETCH_CONDENSED, "condensed" },
|
||||
{ >K_CSS_VALUE_FONT_STRETCH, 1, TRUE, PANGO_STRETCH_SEMI_CONDENSED, "semi-condensed" },
|
||||
{ >K_CSS_VALUE_FONT_STRETCH, 1, TRUE, PANGO_STRETCH_NORMAL, "normal" },
|
||||
{ >K_CSS_VALUE_FONT_STRETCH, 1, TRUE, PANGO_STRETCH_SEMI_EXPANDED, "semi-expanded" },
|
||||
{ >K_CSS_VALUE_FONT_STRETCH, 1, TRUE, PANGO_STRETCH_EXPANDED, "expanded" },
|
||||
{ >K_CSS_VALUE_FONT_STRETCH, 1, TRUE, PANGO_STRETCH_EXTRA_EXPANDED, "extra-expanded" },
|
||||
{ >K_CSS_VALUE_FONT_STRETCH, 1, TRUE, PANGO_STRETCH_ULTRA_EXPANDED, "ultra-expanded" },
|
||||
};
|
||||
|
||||
GtkCssValue *
|
||||
@@ -516,7 +518,7 @@ _gtk_css_font_stretch_value_new (PangoStretch font_stretch)
|
||||
{
|
||||
g_return_val_if_fail (font_stretch < G_N_ELEMENTS (font_stretch_values), NULL);
|
||||
|
||||
return gtk_css_value_ref (&font_stretch_values[font_stretch]);
|
||||
return _gtk_css_value_ref (&font_stretch_values[font_stretch]);
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
@@ -529,7 +531,7 @@ _gtk_css_font_stretch_value_try_parse (GtkCssParser *parser)
|
||||
for (i = 0; i < G_N_ELEMENTS (font_stretch_values); i++)
|
||||
{
|
||||
if (gtk_css_parser_try_ident (parser, font_stretch_values[i].name))
|
||||
return gtk_css_value_ref (&font_stretch_values[i]);
|
||||
return _gtk_css_value_ref (&font_stretch_values[i]);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -557,9 +559,9 @@ static const GtkCssValueClass GTK_CSS_VALUE_TEXT_DECORATION_STYLE = {
|
||||
};
|
||||
|
||||
static GtkCssValue text_decoration_style_values[] = {
|
||||
{ >K_CSS_VALUE_TEXT_DECORATION_STYLE, 1, TRUE, FALSE, GTK_CSS_TEXT_DECORATION_STYLE_SOLID, "solid" },
|
||||
{ >K_CSS_VALUE_TEXT_DECORATION_STYLE, 1, TRUE, FALSE, GTK_CSS_TEXT_DECORATION_STYLE_DOUBLE, "double" },
|
||||
{ >K_CSS_VALUE_TEXT_DECORATION_STYLE, 1, TRUE, FALSE, GTK_CSS_TEXT_DECORATION_STYLE_WAVY, "wavy" },
|
||||
{ >K_CSS_VALUE_TEXT_DECORATION_STYLE, 1, TRUE, GTK_CSS_TEXT_DECORATION_STYLE_SOLID, "solid" },
|
||||
{ >K_CSS_VALUE_TEXT_DECORATION_STYLE, 1, TRUE, GTK_CSS_TEXT_DECORATION_STYLE_DOUBLE, "double" },
|
||||
{ >K_CSS_VALUE_TEXT_DECORATION_STYLE, 1, TRUE, GTK_CSS_TEXT_DECORATION_STYLE_WAVY, "wavy" },
|
||||
};
|
||||
|
||||
GtkCssValue *
|
||||
@@ -567,7 +569,7 @@ _gtk_css_text_decoration_style_value_new (GtkTextDecorationStyle style)
|
||||
{
|
||||
g_return_val_if_fail (style < G_N_ELEMENTS (text_decoration_style_values), NULL);
|
||||
|
||||
return gtk_css_value_ref (&text_decoration_style_values[style]);
|
||||
return _gtk_css_value_ref (&text_decoration_style_values[style]);
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
@@ -580,7 +582,7 @@ _gtk_css_text_decoration_style_value_try_parse (GtkCssParser *parser)
|
||||
for (i = 0; i < G_N_ELEMENTS (text_decoration_style_values); i++)
|
||||
{
|
||||
if (gtk_css_parser_try_ident (parser, text_decoration_style_values[i].name))
|
||||
return gtk_css_value_ref (&text_decoration_style_values[i]);
|
||||
return _gtk_css_value_ref (&text_decoration_style_values[i]);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -608,9 +610,9 @@ static const GtkCssValueClass GTK_CSS_VALUE_AREA = {
|
||||
};
|
||||
|
||||
static GtkCssValue area_values[] = {
|
||||
{ >K_CSS_VALUE_AREA, 1, TRUE, FALSE, GTK_CSS_AREA_BORDER_BOX, "border-box" },
|
||||
{ >K_CSS_VALUE_AREA, 1, TRUE, FALSE, GTK_CSS_AREA_PADDING_BOX, "padding-box" },
|
||||
{ >K_CSS_VALUE_AREA, 1, TRUE, FALSE, GTK_CSS_AREA_CONTENT_BOX, "content-box" }
|
||||
{ >K_CSS_VALUE_AREA, 1, TRUE, GTK_CSS_AREA_BORDER_BOX, "border-box" },
|
||||
{ >K_CSS_VALUE_AREA, 1, TRUE, GTK_CSS_AREA_PADDING_BOX, "padding-box" },
|
||||
{ >K_CSS_VALUE_AREA, 1, TRUE, GTK_CSS_AREA_CONTENT_BOX, "content-box" }
|
||||
};
|
||||
|
||||
GtkCssValue *
|
||||
@@ -621,7 +623,7 @@ _gtk_css_area_value_new (GtkCssArea area)
|
||||
for (i = 0; i < G_N_ELEMENTS (area_values); i++)
|
||||
{
|
||||
if (area_values[i].value == area)
|
||||
return gtk_css_value_ref (&area_values[i]);
|
||||
return _gtk_css_value_ref (&area_values[i]);
|
||||
}
|
||||
|
||||
g_return_val_if_reached (NULL);
|
||||
@@ -637,7 +639,7 @@ _gtk_css_area_value_try_parse (GtkCssParser *parser)
|
||||
for (i = 0; i < G_N_ELEMENTS (area_values); i++)
|
||||
{
|
||||
if (gtk_css_parser_try_ident (parser, area_values[i].name))
|
||||
return gtk_css_value_ref (&area_values[i]);
|
||||
return _gtk_css_value_ref (&area_values[i]);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -665,10 +667,10 @@ static const GtkCssValueClass GTK_CSS_VALUE_DIRECTION = {
|
||||
};
|
||||
|
||||
static GtkCssValue direction_values[] = {
|
||||
{ >K_CSS_VALUE_DIRECTION, 1, TRUE, FALSE, GTK_CSS_DIRECTION_NORMAL, "normal" },
|
||||
{ >K_CSS_VALUE_DIRECTION, 1, TRUE, FALSE, GTK_CSS_DIRECTION_REVERSE, "reverse" },
|
||||
{ >K_CSS_VALUE_DIRECTION, 1, TRUE, FALSE, GTK_CSS_DIRECTION_ALTERNATE, "alternate" },
|
||||
{ >K_CSS_VALUE_DIRECTION, 1, TRUE, FALSE, GTK_CSS_DIRECTION_ALTERNATE_REVERSE, "alternate-reverse" }
|
||||
{ >K_CSS_VALUE_DIRECTION, 1, TRUE, GTK_CSS_DIRECTION_NORMAL, "normal" },
|
||||
{ >K_CSS_VALUE_DIRECTION, 1, TRUE, GTK_CSS_DIRECTION_REVERSE, "reverse" },
|
||||
{ >K_CSS_VALUE_DIRECTION, 1, TRUE, GTK_CSS_DIRECTION_ALTERNATE, "alternate" },
|
||||
{ >K_CSS_VALUE_DIRECTION, 1, TRUE, GTK_CSS_DIRECTION_ALTERNATE_REVERSE, "alternate-reverse" }
|
||||
};
|
||||
|
||||
GtkCssValue *
|
||||
@@ -679,7 +681,7 @@ _gtk_css_direction_value_new (GtkCssDirection direction)
|
||||
for (i = 0; i < G_N_ELEMENTS (direction_values); i++)
|
||||
{
|
||||
if (direction_values[i].value == direction)
|
||||
return gtk_css_value_ref (&direction_values[i]);
|
||||
return _gtk_css_value_ref (&direction_values[i]);
|
||||
}
|
||||
|
||||
g_return_val_if_reached (NULL);
|
||||
@@ -698,7 +700,7 @@ _gtk_css_direction_value_try_parse (GtkCssParser *parser)
|
||||
for (i = G_N_ELEMENTS (direction_values) - 1; i >= 0; i--)
|
||||
{
|
||||
if (gtk_css_parser_try_ident (parser, direction_values[i].name))
|
||||
return gtk_css_value_ref (&direction_values[i]);
|
||||
return _gtk_css_value_ref (&direction_values[i]);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -726,8 +728,8 @@ static const GtkCssValueClass GTK_CSS_VALUE_PLAY_STATE = {
|
||||
};
|
||||
|
||||
static GtkCssValue play_state_values[] = {
|
||||
{ >K_CSS_VALUE_PLAY_STATE, 1, TRUE, FALSE, GTK_CSS_PLAY_STATE_RUNNING, "running" },
|
||||
{ >K_CSS_VALUE_PLAY_STATE, 1, TRUE, FALSE, GTK_CSS_PLAY_STATE_PAUSED, "paused" }
|
||||
{ >K_CSS_VALUE_PLAY_STATE, 1, TRUE, GTK_CSS_PLAY_STATE_RUNNING, "running" },
|
||||
{ >K_CSS_VALUE_PLAY_STATE, 1, TRUE, GTK_CSS_PLAY_STATE_PAUSED, "paused" }
|
||||
};
|
||||
|
||||
GtkCssValue *
|
||||
@@ -738,7 +740,7 @@ _gtk_css_play_state_value_new (GtkCssPlayState play_state)
|
||||
for (i = 0; i < G_N_ELEMENTS (play_state_values); i++)
|
||||
{
|
||||
if (play_state_values[i].value == play_state)
|
||||
return gtk_css_value_ref (&play_state_values[i]);
|
||||
return _gtk_css_value_ref (&play_state_values[i]);
|
||||
}
|
||||
|
||||
g_return_val_if_reached (NULL);
|
||||
@@ -754,7 +756,7 @@ _gtk_css_play_state_value_try_parse (GtkCssParser *parser)
|
||||
for (i = 0; i < G_N_ELEMENTS (play_state_values); i++)
|
||||
{
|
||||
if (gtk_css_parser_try_ident (parser, play_state_values[i].name))
|
||||
return gtk_css_value_ref (&play_state_values[i]);
|
||||
return _gtk_css_value_ref (&play_state_values[i]);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -782,10 +784,10 @@ static const GtkCssValueClass GTK_CSS_VALUE_FILL_MODE = {
|
||||
};
|
||||
|
||||
static GtkCssValue fill_mode_values[] = {
|
||||
{ >K_CSS_VALUE_FILL_MODE, 1, TRUE, FALSE, GTK_CSS_FILL_NONE, "none" },
|
||||
{ >K_CSS_VALUE_FILL_MODE, 1, TRUE, FALSE, GTK_CSS_FILL_FORWARDS, "forwards" },
|
||||
{ >K_CSS_VALUE_FILL_MODE, 1, TRUE, FALSE, GTK_CSS_FILL_BACKWARDS, "backwards" },
|
||||
{ >K_CSS_VALUE_FILL_MODE, 1, TRUE, FALSE, GTK_CSS_FILL_BOTH, "both" }
|
||||
{ >K_CSS_VALUE_FILL_MODE, 1, TRUE, GTK_CSS_FILL_NONE, "none" },
|
||||
{ >K_CSS_VALUE_FILL_MODE, 1, TRUE, GTK_CSS_FILL_FORWARDS, "forwards" },
|
||||
{ >K_CSS_VALUE_FILL_MODE, 1, TRUE, GTK_CSS_FILL_BACKWARDS, "backwards" },
|
||||
{ >K_CSS_VALUE_FILL_MODE, 1, TRUE, GTK_CSS_FILL_BOTH, "both" }
|
||||
};
|
||||
|
||||
GtkCssValue *
|
||||
@@ -796,7 +798,7 @@ _gtk_css_fill_mode_value_new (GtkCssFillMode fill_mode)
|
||||
for (i = 0; i < G_N_ELEMENTS (fill_mode_values); i++)
|
||||
{
|
||||
if (fill_mode_values[i].value == fill_mode)
|
||||
return gtk_css_value_ref (&fill_mode_values[i]);
|
||||
return _gtk_css_value_ref (&fill_mode_values[i]);
|
||||
}
|
||||
|
||||
g_return_val_if_reached (NULL);
|
||||
@@ -812,7 +814,7 @@ _gtk_css_fill_mode_value_try_parse (GtkCssParser *parser)
|
||||
for (i = 0; i < G_N_ELEMENTS (fill_mode_values); i++)
|
||||
{
|
||||
if (gtk_css_parser_try_ident (parser, fill_mode_values[i].name))
|
||||
return gtk_css_value_ref (&fill_mode_values[i]);
|
||||
return _gtk_css_value_ref (&fill_mode_values[i]);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -840,9 +842,9 @@ static const GtkCssValueClass GTK_CSS_VALUE_ICON_STYLE = {
|
||||
};
|
||||
|
||||
static GtkCssValue icon_style_values[] = {
|
||||
{ >K_CSS_VALUE_ICON_STYLE, 1, TRUE, FALSE, GTK_CSS_ICON_STYLE_REQUESTED, "requested" },
|
||||
{ >K_CSS_VALUE_ICON_STYLE, 1, TRUE, FALSE, GTK_CSS_ICON_STYLE_REGULAR, "regular" },
|
||||
{ >K_CSS_VALUE_ICON_STYLE, 1, TRUE, FALSE, GTK_CSS_ICON_STYLE_SYMBOLIC, "symbolic" }
|
||||
{ >K_CSS_VALUE_ICON_STYLE, 1, TRUE, GTK_CSS_ICON_STYLE_REQUESTED, "requested" },
|
||||
{ >K_CSS_VALUE_ICON_STYLE, 1, TRUE, GTK_CSS_ICON_STYLE_REGULAR, "regular" },
|
||||
{ >K_CSS_VALUE_ICON_STYLE, 1, TRUE, GTK_CSS_ICON_STYLE_SYMBOLIC, "symbolic" }
|
||||
};
|
||||
|
||||
GtkCssValue *
|
||||
@@ -853,7 +855,7 @@ _gtk_css_icon_style_value_new (GtkCssIconStyle icon_style)
|
||||
for (i = 0; i < G_N_ELEMENTS (icon_style_values); i++)
|
||||
{
|
||||
if (icon_style_values[i].value == icon_style)
|
||||
return gtk_css_value_ref (&icon_style_values[i]);
|
||||
return _gtk_css_value_ref (&icon_style_values[i]);
|
||||
}
|
||||
|
||||
g_return_val_if_reached (NULL);
|
||||
@@ -869,7 +871,7 @@ _gtk_css_icon_style_value_try_parse (GtkCssParser *parser)
|
||||
for (i = 0; i < G_N_ELEMENTS (icon_style_values); i++)
|
||||
{
|
||||
if (gtk_css_parser_try_ident (parser, icon_style_values[i].name))
|
||||
return gtk_css_value_ref (&icon_style_values[i]);
|
||||
return _gtk_css_value_ref (&icon_style_values[i]);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -897,9 +899,9 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_KERNING = {
|
||||
};
|
||||
|
||||
static GtkCssValue font_kerning_values[] = {
|
||||
{ >K_CSS_VALUE_FONT_KERNING, 1, TRUE, FALSE, GTK_CSS_FONT_KERNING_AUTO, "auto" },
|
||||
{ >K_CSS_VALUE_FONT_KERNING, 1, TRUE, FALSE, GTK_CSS_FONT_KERNING_NORMAL, "normal" },
|
||||
{ >K_CSS_VALUE_FONT_KERNING, 1, TRUE, FALSE, GTK_CSS_FONT_KERNING_NONE, "none" }
|
||||
{ >K_CSS_VALUE_FONT_KERNING, 1, TRUE, GTK_CSS_FONT_KERNING_AUTO, "auto" },
|
||||
{ >K_CSS_VALUE_FONT_KERNING, 1, TRUE, GTK_CSS_FONT_KERNING_NORMAL, "normal" },
|
||||
{ >K_CSS_VALUE_FONT_KERNING, 1, TRUE, GTK_CSS_FONT_KERNING_NONE, "none" }
|
||||
};
|
||||
|
||||
GtkCssValue *
|
||||
@@ -910,7 +912,7 @@ _gtk_css_font_kerning_value_new (GtkCssFontKerning kerning)
|
||||
for (i = 0; i < G_N_ELEMENTS (font_kerning_values); i++)
|
||||
{
|
||||
if (font_kerning_values[i].value == kerning)
|
||||
return gtk_css_value_ref (&font_kerning_values[i]);
|
||||
return _gtk_css_value_ref (&font_kerning_values[i]);
|
||||
}
|
||||
|
||||
g_return_val_if_reached (NULL);
|
||||
@@ -926,7 +928,7 @@ _gtk_css_font_kerning_value_try_parse (GtkCssParser *parser)
|
||||
for (i = 0; i < G_N_ELEMENTS (font_kerning_values); i++)
|
||||
{
|
||||
if (gtk_css_parser_try_ident (parser, font_kerning_values[i].name))
|
||||
return gtk_css_value_ref (&font_kerning_values[i]);
|
||||
return _gtk_css_value_ref (&font_kerning_values[i]);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -954,9 +956,9 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_VARIANT_POSITION = {
|
||||
};
|
||||
|
||||
static GtkCssValue font_variant_position_values[] = {
|
||||
{ >K_CSS_VALUE_FONT_VARIANT_POSITION, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_POSITION_NORMAL, "normal" },
|
||||
{ >K_CSS_VALUE_FONT_VARIANT_POSITION, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_POSITION_SUB, "sub" },
|
||||
{ >K_CSS_VALUE_FONT_VARIANT_POSITION, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_POSITION_SUPER, "super" }
|
||||
{ >K_CSS_VALUE_FONT_VARIANT_POSITION, 1, TRUE, GTK_CSS_FONT_VARIANT_POSITION_NORMAL, "normal" },
|
||||
{ >K_CSS_VALUE_FONT_VARIANT_POSITION, 1, TRUE, GTK_CSS_FONT_VARIANT_POSITION_SUB, "sub" },
|
||||
{ >K_CSS_VALUE_FONT_VARIANT_POSITION, 1, TRUE, GTK_CSS_FONT_VARIANT_POSITION_SUPER, "super" }
|
||||
};
|
||||
|
||||
GtkCssValue *
|
||||
@@ -967,7 +969,7 @@ _gtk_css_font_variant_position_value_new (GtkCssFontVariantPosition position)
|
||||
for (i = 0; i < G_N_ELEMENTS (font_variant_position_values); i++)
|
||||
{
|
||||
if (font_variant_position_values[i].value == position)
|
||||
return gtk_css_value_ref (&font_variant_position_values[i]);
|
||||
return _gtk_css_value_ref (&font_variant_position_values[i]);
|
||||
}
|
||||
|
||||
g_return_val_if_reached (NULL);
|
||||
@@ -983,7 +985,7 @@ _gtk_css_font_variant_position_value_try_parse (GtkCssParser *parser)
|
||||
for (i = 0; i < G_N_ELEMENTS (font_variant_position_values); i++)
|
||||
{
|
||||
if (gtk_css_parser_try_ident (parser, font_variant_position_values[i].name))
|
||||
return gtk_css_value_ref (&font_variant_position_values[i]);
|
||||
return _gtk_css_value_ref (&font_variant_position_values[i]);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -1011,13 +1013,13 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_VARIANT_CAPS = {
|
||||
};
|
||||
|
||||
static GtkCssValue font_variant_caps_values[] = {
|
||||
{ >K_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_CAPS_NORMAL, "normal" },
|
||||
{ >K_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_CAPS_SMALL_CAPS, "small-caps" },
|
||||
{ >K_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_CAPS_ALL_SMALL_CAPS, "all-small-caps" },
|
||||
{ >K_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_CAPS_PETITE_CAPS, "petite-caps" },
|
||||
{ >K_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_CAPS_ALL_PETITE_CAPS, "all-petite-caps" },
|
||||
{ >K_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_CAPS_UNICASE, "unicase" },
|
||||
{ >K_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_CAPS_TITLING_CAPS, "titling-caps" }
|
||||
{ >K_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, GTK_CSS_FONT_VARIANT_CAPS_NORMAL, "normal" },
|
||||
{ >K_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, GTK_CSS_FONT_VARIANT_CAPS_SMALL_CAPS, "small-caps" },
|
||||
{ >K_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, GTK_CSS_FONT_VARIANT_CAPS_ALL_SMALL_CAPS, "all-small-caps" },
|
||||
{ >K_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, GTK_CSS_FONT_VARIANT_CAPS_PETITE_CAPS, "petite-caps" },
|
||||
{ >K_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, GTK_CSS_FONT_VARIANT_CAPS_ALL_PETITE_CAPS, "all-petite-caps" },
|
||||
{ >K_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, GTK_CSS_FONT_VARIANT_CAPS_UNICASE, "unicase" },
|
||||
{ >K_CSS_VALUE_FONT_VARIANT_CAPS, 1, TRUE, GTK_CSS_FONT_VARIANT_CAPS_TITLING_CAPS, "titling-caps" }
|
||||
};
|
||||
|
||||
GtkCssValue *
|
||||
@@ -1028,7 +1030,7 @@ _gtk_css_font_variant_caps_value_new (GtkCssFontVariantCaps caps)
|
||||
for (i = 0; i < G_N_ELEMENTS (font_variant_caps_values); i++)
|
||||
{
|
||||
if (font_variant_caps_values[i].value == caps)
|
||||
return gtk_css_value_ref (&font_variant_caps_values[i]);
|
||||
return _gtk_css_value_ref (&font_variant_caps_values[i]);
|
||||
}
|
||||
|
||||
g_return_val_if_reached (NULL);
|
||||
@@ -1044,7 +1046,7 @@ _gtk_css_font_variant_caps_value_try_parse (GtkCssParser *parser)
|
||||
for (i = 0; i < G_N_ELEMENTS (font_variant_caps_values); i++)
|
||||
{
|
||||
if (gtk_css_parser_try_ident (parser, font_variant_caps_values[i].name))
|
||||
return gtk_css_value_ref (&font_variant_caps_values[i]);
|
||||
return _gtk_css_value_ref (&font_variant_caps_values[i]);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -1072,8 +1074,8 @@ static const GtkCssValueClass GTK_CSS_VALUE_FONT_VARIANT_ALTERNATE = {
|
||||
};
|
||||
|
||||
static GtkCssValue font_variant_alternate_values[] = {
|
||||
{ >K_CSS_VALUE_FONT_VARIANT_ALTERNATE, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_ALTERNATE_NORMAL, "normal" },
|
||||
{ >K_CSS_VALUE_FONT_VARIANT_ALTERNATE, 1, TRUE, FALSE, GTK_CSS_FONT_VARIANT_ALTERNATE_HISTORICAL_FORMS, "historical-forms" }
|
||||
{ >K_CSS_VALUE_FONT_VARIANT_ALTERNATE, 1, TRUE, GTK_CSS_FONT_VARIANT_ALTERNATE_NORMAL, "normal" },
|
||||
{ >K_CSS_VALUE_FONT_VARIANT_ALTERNATE, 1, TRUE, GTK_CSS_FONT_VARIANT_ALTERNATE_HISTORICAL_FORMS, "historical-forms" }
|
||||
};
|
||||
|
||||
GtkCssValue *
|
||||
@@ -1084,7 +1086,7 @@ _gtk_css_font_variant_alternate_value_new (GtkCssFontVariantAlternate alternate)
|
||||
for (i = 0; i < G_N_ELEMENTS (font_variant_alternate_values); i++)
|
||||
{
|
||||
if (font_variant_alternate_values[i].value == alternate)
|
||||
return gtk_css_value_ref (&font_variant_alternate_values[i]);
|
||||
return _gtk_css_value_ref (&font_variant_alternate_values[i]);
|
||||
}
|
||||
|
||||
g_return_val_if_reached (NULL);
|
||||
@@ -1100,7 +1102,7 @@ _gtk_css_font_variant_alternate_value_try_parse (GtkCssParser *parser)
|
||||
for (i = 0; i < G_N_ELEMENTS (font_variant_alternate_values); i++)
|
||||
{
|
||||
if (gtk_css_parser_try_ident (parser, font_variant_alternate_values[i].name))
|
||||
return gtk_css_value_ref (&font_variant_alternate_values[i]);
|
||||
return _gtk_css_value_ref (&font_variant_alternate_values[i]);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -1197,7 +1199,7 @@ _gtk_css_text_decoration_line_value_new (GtkTextDecorationLine line)
|
||||
if (!text_decoration_line_is_valid (line))
|
||||
return NULL;
|
||||
|
||||
value = gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_TEXT_DECORATION_LINE);
|
||||
value = _gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_TEXT_DECORATION_LINE);
|
||||
value->value = line;
|
||||
value->name = NULL;
|
||||
value->is_computed = TRUE;
|
||||
@@ -1306,7 +1308,7 @@ _gtk_css_font_variant_ligature_value_new (GtkCssFontVariantLigature ligatures)
|
||||
if (!ligature_value_is_valid (ligatures))
|
||||
return NULL;
|
||||
|
||||
value = gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_FONT_VARIANT_LIGATURE);
|
||||
value = _gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_FONT_VARIANT_LIGATURE);
|
||||
value->value = ligatures;
|
||||
value->name = NULL;
|
||||
value->is_computed = TRUE;
|
||||
@@ -1410,7 +1412,7 @@ _gtk_css_font_variant_numeric_value_new (GtkCssFontVariantNumeric numeric)
|
||||
if (!numeric_value_is_valid (numeric))
|
||||
return NULL;
|
||||
|
||||
value = gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_FONT_VARIANT_NUMERIC);
|
||||
value = _gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_FONT_VARIANT_NUMERIC);
|
||||
value->value = numeric;
|
||||
value->name = NULL;
|
||||
value->is_computed = TRUE;
|
||||
@@ -1521,7 +1523,7 @@ _gtk_css_font_variant_east_asian_value_new (GtkCssFontVariantEastAsian east_asia
|
||||
if (!east_asian_value_is_valid (east_asian))
|
||||
return NULL;
|
||||
|
||||
value = gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_FONT_VARIANT_EAST_ASIAN);
|
||||
value = _gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_FONT_VARIANT_EAST_ASIAN);
|
||||
value->value = east_asian;
|
||||
value->name = NULL;
|
||||
value->is_computed = TRUE;
|
||||
@@ -1581,10 +1583,10 @@ static const GtkCssValueClass GTK_CSS_VALUE_TEXT_TRANSFORM = {
|
||||
};
|
||||
|
||||
static GtkCssValue text_transform_values[] = {
|
||||
{ >K_CSS_VALUE_TEXT_TRANSFORM, 1, TRUE, FALSE, GTK_CSS_TEXT_TRANSFORM_NONE, "none" },
|
||||
{ >K_CSS_VALUE_TEXT_TRANSFORM, 1, TRUE, FALSE, GTK_CSS_TEXT_TRANSFORM_LOWERCASE, "lowercase" },
|
||||
{ >K_CSS_VALUE_TEXT_TRANSFORM, 1, TRUE, FALSE, GTK_CSS_TEXT_TRANSFORM_UPPERCASE, "uppercase" },
|
||||
{ >K_CSS_VALUE_TEXT_TRANSFORM, 1, TRUE, FALSE, GTK_CSS_TEXT_TRANSFORM_CAPITALIZE, "capitalize" },
|
||||
{ >K_CSS_VALUE_TEXT_TRANSFORM, 1, TRUE, GTK_CSS_TEXT_TRANSFORM_NONE, "none" },
|
||||
{ >K_CSS_VALUE_TEXT_TRANSFORM, 1, TRUE, GTK_CSS_TEXT_TRANSFORM_LOWERCASE, "lowercase" },
|
||||
{ >K_CSS_VALUE_TEXT_TRANSFORM, 1, TRUE, GTK_CSS_TEXT_TRANSFORM_UPPERCASE, "uppercase" },
|
||||
{ >K_CSS_VALUE_TEXT_TRANSFORM, 1, TRUE, GTK_CSS_TEXT_TRANSFORM_CAPITALIZE, "capitalize" },
|
||||
};
|
||||
|
||||
GtkCssValue *
|
||||
@@ -1592,7 +1594,7 @@ _gtk_css_text_transform_value_new (GtkTextTransform transform)
|
||||
{
|
||||
g_return_val_if_fail (transform < G_N_ELEMENTS (text_transform_values), NULL);
|
||||
|
||||
return gtk_css_value_ref (&text_transform_values[transform]);
|
||||
return _gtk_css_value_ref (&text_transform_values[transform]);
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
@@ -1605,7 +1607,7 @@ _gtk_css_text_transform_value_try_parse (GtkCssParser *parser)
|
||||
for (i = 0; i < G_N_ELEMENTS (text_transform_values); i++)
|
||||
{
|
||||
if (gtk_css_parser_try_ident (parser, text_transform_values[i].name))
|
||||
return gtk_css_value_ref (&text_transform_values[i]);
|
||||
return _gtk_css_value_ref (&text_transform_values[i]);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
+92
-86
@@ -65,34 +65,34 @@ gtk_css_filter_clear (GtkCssFilter *filter)
|
||||
switch (filter->type)
|
||||
{
|
||||
case GTK_CSS_FILTER_BRIGHTNESS:
|
||||
gtk_css_value_unref (filter->brightness.value);
|
||||
_gtk_css_value_unref (filter->brightness.value);
|
||||
break;
|
||||
case GTK_CSS_FILTER_CONTRAST:
|
||||
gtk_css_value_unref (filter->contrast.value);
|
||||
_gtk_css_value_unref (filter->contrast.value);
|
||||
break;
|
||||
case GTK_CSS_FILTER_GRAYSCALE:
|
||||
gtk_css_value_unref (filter->grayscale.value);
|
||||
_gtk_css_value_unref (filter->grayscale.value);
|
||||
break;
|
||||
case GTK_CSS_FILTER_HUE_ROTATE:
|
||||
gtk_css_value_unref (filter->hue_rotate.value);
|
||||
_gtk_css_value_unref (filter->hue_rotate.value);
|
||||
break;
|
||||
case GTK_CSS_FILTER_INVERT:
|
||||
gtk_css_value_unref (filter->invert.value);
|
||||
_gtk_css_value_unref (filter->invert.value);
|
||||
break;
|
||||
case GTK_CSS_FILTER_OPACITY:
|
||||
gtk_css_value_unref (filter->opacity.value);
|
||||
_gtk_css_value_unref (filter->opacity.value);
|
||||
break;
|
||||
case GTK_CSS_FILTER_SATURATE:
|
||||
gtk_css_value_unref (filter->saturate.value);
|
||||
_gtk_css_value_unref (filter->saturate.value);
|
||||
break;
|
||||
case GTK_CSS_FILTER_SEPIA:
|
||||
gtk_css_value_unref (filter->sepia.value);
|
||||
_gtk_css_value_unref (filter->sepia.value);
|
||||
break;
|
||||
case GTK_CSS_FILTER_BLUR:
|
||||
gtk_css_value_unref (filter->blur.value);
|
||||
_gtk_css_value_unref (filter->blur.value);
|
||||
break;
|
||||
case GTK_CSS_FILTER_DROP_SHADOW:
|
||||
gtk_css_value_unref (filter->drop_shadow.value);
|
||||
_gtk_css_value_unref (filter->drop_shadow.value);
|
||||
break;
|
||||
case GTK_CSS_FILTER_NONE:
|
||||
default:
|
||||
@@ -108,31 +108,31 @@ gtk_css_filter_init_identity (GtkCssFilter *filter,
|
||||
switch (other->type)
|
||||
{
|
||||
case GTK_CSS_FILTER_BRIGHTNESS:
|
||||
filter->brightness.value = gtk_css_number_value_new (1, GTK_CSS_NUMBER);
|
||||
filter->brightness.value = _gtk_css_number_value_new (1, GTK_CSS_NUMBER);
|
||||
break;
|
||||
case GTK_CSS_FILTER_CONTRAST:
|
||||
filter->contrast.value = gtk_css_number_value_new (1, GTK_CSS_NUMBER);
|
||||
filter->contrast.value = _gtk_css_number_value_new (1, GTK_CSS_NUMBER);
|
||||
break;
|
||||
case GTK_CSS_FILTER_GRAYSCALE:
|
||||
filter->grayscale.value = gtk_css_number_value_new (0, GTK_CSS_NUMBER);
|
||||
filter->grayscale.value = _gtk_css_number_value_new (0, GTK_CSS_NUMBER);
|
||||
break;
|
||||
case GTK_CSS_FILTER_HUE_ROTATE:
|
||||
filter->hue_rotate.value = gtk_css_number_value_new (0, GTK_CSS_DEG);
|
||||
filter->hue_rotate.value = _gtk_css_number_value_new (0, GTK_CSS_DEG);
|
||||
break;
|
||||
case GTK_CSS_FILTER_INVERT:
|
||||
filter->invert.value = gtk_css_number_value_new (0, GTK_CSS_NUMBER);
|
||||
filter->invert.value = _gtk_css_number_value_new (0, GTK_CSS_NUMBER);
|
||||
break;
|
||||
case GTK_CSS_FILTER_OPACITY:
|
||||
filter->opacity.value = gtk_css_number_value_new (1, GTK_CSS_NUMBER);
|
||||
filter->opacity.value = _gtk_css_number_value_new (1, GTK_CSS_NUMBER);
|
||||
break;
|
||||
case GTK_CSS_FILTER_SATURATE:
|
||||
filter->saturate.value = gtk_css_number_value_new (1, GTK_CSS_NUMBER);
|
||||
filter->saturate.value = _gtk_css_number_value_new (1, GTK_CSS_NUMBER);
|
||||
break;
|
||||
case GTK_CSS_FILTER_SEPIA:
|
||||
filter->sepia.value = gtk_css_number_value_new (0, GTK_CSS_NUMBER);
|
||||
filter->sepia.value = _gtk_css_number_value_new (0, GTK_CSS_NUMBER);
|
||||
break;
|
||||
case GTK_CSS_FILTER_BLUR:
|
||||
filter->blur.value = gtk_css_number_value_new (0, GTK_CSS_PX);
|
||||
filter->blur.value = _gtk_css_number_value_new (0, GTK_CSS_PX);
|
||||
break;
|
||||
case GTK_CSS_FILTER_DROP_SHADOW:
|
||||
filter->drop_shadow.value = gtk_css_shadow_value_new_filter (other->drop_shadow.value);
|
||||
@@ -160,19 +160,19 @@ gtk_css_filter_get_matrix (const GtkCssFilter *filter,
|
||||
switch (filter->type)
|
||||
{
|
||||
case GTK_CSS_FILTER_BRIGHTNESS:
|
||||
value = gtk_css_number_value_get (filter->brightness.value, 1.0);
|
||||
value = _gtk_css_number_value_get (filter->brightness.value, 1.0);
|
||||
graphene_matrix_init_scale (matrix, value, value, value);
|
||||
graphene_vec4_init (offset, 0.0, 0.0, 0.0, 0.0);
|
||||
break;
|
||||
|
||||
case GTK_CSS_FILTER_CONTRAST:
|
||||
value = gtk_css_number_value_get (filter->contrast.value, 1.0);
|
||||
value = _gtk_css_number_value_get (filter->contrast.value, 1.0);
|
||||
graphene_matrix_init_scale (matrix, value, value, value);
|
||||
graphene_vec4_init (offset, 0.5 - 0.5 * value, 0.5 - 0.5 * value, 0.5 - 0.5 * value, 0.0);
|
||||
break;
|
||||
|
||||
case GTK_CSS_FILTER_GRAYSCALE:
|
||||
value = gtk_css_number_value_get (filter->grayscale.value, 1.0);
|
||||
value = _gtk_css_number_value_get (filter->grayscale.value, 1.0);
|
||||
graphene_matrix_init_from_float (matrix, (float[16]) {
|
||||
1.0 - (1.0 - R) * value, R * value, R * value, 0.0,
|
||||
G * value, 1.0 - (1.0 - G) * value, G * value, 0.0,
|
||||
@@ -185,7 +185,7 @@ gtk_css_filter_get_matrix (const GtkCssFilter *filter,
|
||||
case GTK_CSS_FILTER_HUE_ROTATE:
|
||||
{
|
||||
double c, s;
|
||||
value = gtk_css_number_value_get (filter->grayscale.value, 1.0) * G_PI / 180.0;
|
||||
value = _gtk_css_number_value_get (filter->grayscale.value, 1.0) * G_PI / 180.0;
|
||||
c = cos (value);
|
||||
s = sin (value);
|
||||
graphene_matrix_init_from_float (matrix, (float[16]) {
|
||||
@@ -208,13 +208,13 @@ gtk_css_filter_get_matrix (const GtkCssFilter *filter,
|
||||
break;
|
||||
|
||||
case GTK_CSS_FILTER_INVERT:
|
||||
value = gtk_css_number_value_get (filter->invert.value, 1.0);
|
||||
value = _gtk_css_number_value_get (filter->invert.value, 1.0);
|
||||
graphene_matrix_init_scale (matrix, 1.0 - 2 * value, 1.0 - 2 * value, 1.0 - 2 * value);
|
||||
graphene_vec4_init (offset, value, value, value, 0.0);
|
||||
break;
|
||||
|
||||
case GTK_CSS_FILTER_OPACITY:
|
||||
value = gtk_css_number_value_get (filter->opacity.value, 1.0);
|
||||
value = _gtk_css_number_value_get (filter->opacity.value, 1.0);
|
||||
graphene_matrix_init_from_float (matrix, (float[16]) {
|
||||
1.0, 0.0, 0.0, 0.0,
|
||||
0.0, 1.0, 0.0, 0.0,
|
||||
@@ -225,7 +225,7 @@ gtk_css_filter_get_matrix (const GtkCssFilter *filter,
|
||||
break;
|
||||
|
||||
case GTK_CSS_FILTER_SATURATE:
|
||||
value = gtk_css_number_value_get (filter->saturate.value, 1.0);
|
||||
value = _gtk_css_number_value_get (filter->saturate.value, 1.0);
|
||||
graphene_matrix_init_from_float (matrix, (float[16]) {
|
||||
R + (1.0 - R) * value, R - R * value, R - R * value, 0.0,
|
||||
G - G * value, G + (1.0 - G) * value, G - G * value, 0.0,
|
||||
@@ -236,7 +236,7 @@ gtk_css_filter_get_matrix (const GtkCssFilter *filter,
|
||||
break;
|
||||
|
||||
case GTK_CSS_FILTER_SEPIA:
|
||||
value = gtk_css_number_value_get (filter->sepia.value, 1.0);
|
||||
value = _gtk_css_number_value_get (filter->sepia.value, 1.0);
|
||||
graphene_matrix_init_from_float (matrix, (float[16]) {
|
||||
1.0 - 0.607 * value, 0.349 * value, 0.272 * value, 0.0,
|
||||
0.769 * value, 1.0 - 0.314 * value, 0.534 * value, 0.0,
|
||||
@@ -307,53 +307,55 @@ gtk_css_value_filter_free (GtkCssValue *value)
|
||||
|
||||
/* returns TRUE if dest == src */
|
||||
static gboolean
|
||||
gtk_css_filter_compute (GtkCssFilter *dest,
|
||||
GtkCssFilter *src,
|
||||
guint property_id,
|
||||
GtkCssComputeContext *context)
|
||||
gtk_css_filter_compute (GtkCssFilter *dest,
|
||||
GtkCssFilter *src,
|
||||
guint property_id,
|
||||
GtkStyleProvider *provider,
|
||||
GtkCssStyle *style,
|
||||
GtkCssStyle *parent_style)
|
||||
{
|
||||
dest->type = src->type;
|
||||
|
||||
switch (src->type)
|
||||
{
|
||||
case GTK_CSS_FILTER_BRIGHTNESS:
|
||||
dest->brightness.value = gtk_css_value_compute (src->brightness.value, property_id, context);
|
||||
dest->brightness.value = _gtk_css_value_compute (src->brightness.value, property_id, provider, style, parent_style);
|
||||
return dest->brightness.value == src->brightness.value;
|
||||
|
||||
case GTK_CSS_FILTER_CONTRAST:
|
||||
dest->contrast.value = gtk_css_value_compute (src->contrast.value, property_id, context);
|
||||
dest->contrast.value = _gtk_css_value_compute (src->contrast.value, property_id, provider, style, parent_style);
|
||||
return dest->contrast.value == src->contrast.value;
|
||||
|
||||
case GTK_CSS_FILTER_GRAYSCALE:
|
||||
dest->grayscale.value = gtk_css_value_compute (src->grayscale.value, property_id, context);
|
||||
dest->grayscale.value = _gtk_css_value_compute (src->grayscale.value, property_id, provider, style, parent_style);
|
||||
return dest->grayscale.value == src->grayscale.value;
|
||||
|
||||
case GTK_CSS_FILTER_HUE_ROTATE:
|
||||
dest->hue_rotate.value = gtk_css_value_compute (src->hue_rotate.value, property_id, context);
|
||||
dest->hue_rotate.value = _gtk_css_value_compute (src->hue_rotate.value, property_id, provider, style, parent_style);
|
||||
return dest->hue_rotate.value == src->hue_rotate.value;
|
||||
|
||||
case GTK_CSS_FILTER_INVERT:
|
||||
dest->invert.value = gtk_css_value_compute (src->invert.value, property_id, context);
|
||||
dest->invert.value = _gtk_css_value_compute (src->invert.value, property_id, provider, style, parent_style);
|
||||
return dest->invert.value == src->invert.value;
|
||||
|
||||
case GTK_CSS_FILTER_OPACITY:
|
||||
dest->opacity.value = gtk_css_value_compute (src->opacity.value, property_id, context);
|
||||
dest->opacity.value = _gtk_css_value_compute (src->opacity.value, property_id, provider, style, parent_style);
|
||||
return dest->opacity.value == src->opacity.value;
|
||||
|
||||
case GTK_CSS_FILTER_SATURATE:
|
||||
dest->saturate.value = gtk_css_value_compute (src->saturate.value, property_id, context);
|
||||
dest->saturate.value = _gtk_css_value_compute (src->saturate.value, property_id, provider, style, parent_style);
|
||||
return dest->saturate.value == src->saturate.value;
|
||||
|
||||
case GTK_CSS_FILTER_SEPIA:
|
||||
dest->sepia.value = gtk_css_value_compute (src->sepia.value, property_id, context);
|
||||
dest->sepia.value = _gtk_css_value_compute (src->sepia.value, property_id, provider, style, parent_style);
|
||||
return dest->sepia.value == src->sepia.value;
|
||||
|
||||
case GTK_CSS_FILTER_BLUR:
|
||||
dest->blur.value = gtk_css_value_compute (src->blur.value, property_id, context);
|
||||
dest->blur.value = _gtk_css_value_compute (src->blur.value, property_id, provider, style, parent_style);
|
||||
return dest->blur.value == src->blur.value;
|
||||
|
||||
case GTK_CSS_FILTER_DROP_SHADOW:
|
||||
dest->drop_shadow.value = gtk_css_value_compute (src->drop_shadow.value, property_id, context);
|
||||
dest->drop_shadow.value = _gtk_css_value_compute (src->drop_shadow.value, property_id, provider, style, parent_style);
|
||||
return dest->drop_shadow.value == src->drop_shadow.value;
|
||||
|
||||
case GTK_CSS_FILTER_NONE:
|
||||
@@ -364,9 +366,11 @@ gtk_css_filter_compute (GtkCssFilter *dest,
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
gtk_css_value_filter_compute (GtkCssValue *value,
|
||||
guint property_id,
|
||||
GtkCssComputeContext *context)
|
||||
gtk_css_value_filter_compute (GtkCssValue *value,
|
||||
guint property_id,
|
||||
GtkStyleProvider *provider,
|
||||
GtkCssStyle *style,
|
||||
GtkCssStyle *parent_style)
|
||||
{
|
||||
GtkCssValue *result;
|
||||
gboolean changes;
|
||||
@@ -374,7 +378,7 @@ gtk_css_value_filter_compute (GtkCssValue *value,
|
||||
|
||||
/* Special case the 99% case of "none" */
|
||||
if (gtk_css_filter_value_is_none (value))
|
||||
return gtk_css_value_ref (value);
|
||||
return _gtk_css_value_ref (value);
|
||||
|
||||
changes = FALSE;
|
||||
result = gtk_css_filter_value_alloc (value->n_filters);
|
||||
@@ -384,13 +388,15 @@ gtk_css_value_filter_compute (GtkCssValue *value,
|
||||
changes |= !gtk_css_filter_compute (&result->filters[i],
|
||||
&value->filters[i],
|
||||
property_id,
|
||||
context);
|
||||
provider,
|
||||
style,
|
||||
parent_style);
|
||||
}
|
||||
|
||||
if (!changes)
|
||||
{
|
||||
gtk_css_value_unref (result);
|
||||
result = gtk_css_value_ref (value);
|
||||
_gtk_css_value_unref (result);
|
||||
result = _gtk_css_value_ref (value);
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -406,34 +412,34 @@ gtk_css_filter_equal (const GtkCssFilter *filter1,
|
||||
switch (filter1->type)
|
||||
{
|
||||
case GTK_CSS_FILTER_BRIGHTNESS:
|
||||
return gtk_css_value_equal (filter1->brightness.value, filter2->brightness.value);
|
||||
return _gtk_css_value_equal (filter1->brightness.value, filter2->brightness.value);
|
||||
|
||||
case GTK_CSS_FILTER_CONTRAST:
|
||||
return gtk_css_value_equal (filter1->contrast.value, filter2->contrast.value);
|
||||
return _gtk_css_value_equal (filter1->contrast.value, filter2->contrast.value);
|
||||
|
||||
case GTK_CSS_FILTER_GRAYSCALE:
|
||||
return gtk_css_value_equal (filter1->grayscale.value, filter2->grayscale.value);
|
||||
return _gtk_css_value_equal (filter1->grayscale.value, filter2->grayscale.value);
|
||||
|
||||
case GTK_CSS_FILTER_HUE_ROTATE:
|
||||
return gtk_css_value_equal (filter1->hue_rotate.value, filter2->hue_rotate.value);
|
||||
return _gtk_css_value_equal (filter1->hue_rotate.value, filter2->hue_rotate.value);
|
||||
|
||||
case GTK_CSS_FILTER_INVERT:
|
||||
return gtk_css_value_equal (filter1->invert.value, filter2->invert.value);
|
||||
return _gtk_css_value_equal (filter1->invert.value, filter2->invert.value);
|
||||
|
||||
case GTK_CSS_FILTER_OPACITY:
|
||||
return gtk_css_value_equal (filter1->opacity.value, filter2->opacity.value);
|
||||
return _gtk_css_value_equal (filter1->opacity.value, filter2->opacity.value);
|
||||
|
||||
case GTK_CSS_FILTER_SATURATE:
|
||||
return gtk_css_value_equal (filter1->saturate.value, filter2->saturate.value);
|
||||
return _gtk_css_value_equal (filter1->saturate.value, filter2->saturate.value);
|
||||
|
||||
case GTK_CSS_FILTER_SEPIA:
|
||||
return gtk_css_value_equal (filter1->sepia.value, filter2->sepia.value);
|
||||
return _gtk_css_value_equal (filter1->sepia.value, filter2->sepia.value);
|
||||
|
||||
case GTK_CSS_FILTER_BLUR:
|
||||
return gtk_css_value_equal (filter1->blur.value, filter2->blur.value);
|
||||
return _gtk_css_value_equal (filter1->blur.value, filter2->blur.value);
|
||||
|
||||
case GTK_CSS_FILTER_DROP_SHADOW:
|
||||
return gtk_css_value_equal (filter1->drop_shadow.value, filter2->drop_shadow.value);
|
||||
return _gtk_css_value_equal (filter1->drop_shadow.value, filter2->drop_shadow.value);
|
||||
|
||||
case GTK_CSS_FILTER_NONE:
|
||||
default:
|
||||
@@ -488,43 +494,43 @@ gtk_css_filter_transition (GtkCssFilter *result,
|
||||
switch (start->type)
|
||||
{
|
||||
case GTK_CSS_FILTER_BRIGHTNESS:
|
||||
result->brightness.value = gtk_css_value_transition (start->brightness.value, end->brightness.value, property_id, progress);
|
||||
result->brightness.value = _gtk_css_value_transition (start->brightness.value, end->brightness.value, property_id, progress);
|
||||
break;
|
||||
|
||||
case GTK_CSS_FILTER_CONTRAST:
|
||||
result->contrast.value = gtk_css_value_transition (start->contrast.value, end->contrast.value, property_id, progress);
|
||||
result->contrast.value = _gtk_css_value_transition (start->contrast.value, end->contrast.value, property_id, progress);
|
||||
break;
|
||||
|
||||
case GTK_CSS_FILTER_GRAYSCALE:
|
||||
result->grayscale.value = gtk_css_value_transition (start->grayscale.value, end->grayscale.value, property_id, progress);
|
||||
result->grayscale.value = _gtk_css_value_transition (start->grayscale.value, end->grayscale.value, property_id, progress);
|
||||
break;
|
||||
|
||||
case GTK_CSS_FILTER_HUE_ROTATE:
|
||||
result->hue_rotate.value = gtk_css_value_transition (start->hue_rotate.value, end->hue_rotate.value, property_id, progress);
|
||||
result->hue_rotate.value = _gtk_css_value_transition (start->hue_rotate.value, end->hue_rotate.value, property_id, progress);
|
||||
break;
|
||||
|
||||
case GTK_CSS_FILTER_INVERT:
|
||||
result->invert.value = gtk_css_value_transition (start->invert.value, end->invert.value, property_id, progress);
|
||||
result->invert.value = _gtk_css_value_transition (start->invert.value, end->invert.value, property_id, progress);
|
||||
break;
|
||||
|
||||
case GTK_CSS_FILTER_OPACITY:
|
||||
result->opacity.value = gtk_css_value_transition (start->opacity.value, end->opacity.value, property_id, progress);
|
||||
result->opacity.value = _gtk_css_value_transition (start->opacity.value, end->opacity.value, property_id, progress);
|
||||
break;
|
||||
|
||||
case GTK_CSS_FILTER_SATURATE:
|
||||
result->saturate.value = gtk_css_value_transition (start->saturate.value, end->saturate.value, property_id, progress);
|
||||
result->saturate.value = _gtk_css_value_transition (start->saturate.value, end->saturate.value, property_id, progress);
|
||||
break;
|
||||
|
||||
case GTK_CSS_FILTER_SEPIA:
|
||||
result->sepia.value = gtk_css_value_transition (start->sepia.value, end->sepia.value, property_id, progress);
|
||||
result->sepia.value = _gtk_css_value_transition (start->sepia.value, end->sepia.value, property_id, progress);
|
||||
break;
|
||||
|
||||
case GTK_CSS_FILTER_BLUR:
|
||||
result->blur.value = gtk_css_value_transition (start->blur.value, end->blur.value, property_id, progress);
|
||||
result->blur.value = _gtk_css_value_transition (start->blur.value, end->blur.value, property_id, progress);
|
||||
break;
|
||||
|
||||
case GTK_CSS_FILTER_DROP_SHADOW:
|
||||
result->drop_shadow.value = gtk_css_value_transition (start->drop_shadow.value, end->drop_shadow.value, property_id, progress);
|
||||
result->drop_shadow.value = _gtk_css_value_transition (start->drop_shadow.value, end->drop_shadow.value, property_id, progress);
|
||||
break;
|
||||
|
||||
case GTK_CSS_FILTER_NONE:
|
||||
@@ -546,7 +552,7 @@ gtk_css_value_filter_transition (GtkCssValue *start,
|
||||
if (gtk_css_filter_value_is_none (start))
|
||||
{
|
||||
if (gtk_css_filter_value_is_none (end))
|
||||
return gtk_css_value_ref (start);
|
||||
return _gtk_css_value_ref (start);
|
||||
|
||||
n = 0;
|
||||
}
|
||||
@@ -620,61 +626,61 @@ gtk_css_filter_print (const GtkCssFilter *filter,
|
||||
{
|
||||
case GTK_CSS_FILTER_BRIGHTNESS:
|
||||
g_string_append (string, "brightness(");
|
||||
gtk_css_value_print (filter->brightness.value, string);
|
||||
_gtk_css_value_print (filter->brightness.value, string);
|
||||
g_string_append (string, ")");
|
||||
break;
|
||||
|
||||
case GTK_CSS_FILTER_CONTRAST:
|
||||
g_string_append (string, "contrast(");
|
||||
gtk_css_value_print (filter->contrast.value, string);
|
||||
_gtk_css_value_print (filter->contrast.value, string);
|
||||
g_string_append (string, ")");
|
||||
break;
|
||||
|
||||
case GTK_CSS_FILTER_GRAYSCALE:
|
||||
g_string_append (string, "grayscale(");
|
||||
gtk_css_value_print (filter->grayscale.value, string);
|
||||
_gtk_css_value_print (filter->grayscale.value, string);
|
||||
g_string_append (string, ")");
|
||||
break;
|
||||
|
||||
case GTK_CSS_FILTER_HUE_ROTATE:
|
||||
g_string_append (string, "hue-rotate(");
|
||||
gtk_css_value_print (filter->hue_rotate.value, string);
|
||||
_gtk_css_value_print (filter->hue_rotate.value, string);
|
||||
g_string_append (string, ")");
|
||||
break;
|
||||
|
||||
case GTK_CSS_FILTER_INVERT:
|
||||
g_string_append (string, "invert(");
|
||||
gtk_css_value_print (filter->invert.value, string);
|
||||
_gtk_css_value_print (filter->invert.value, string);
|
||||
g_string_append (string, ")");
|
||||
break;
|
||||
|
||||
case GTK_CSS_FILTER_OPACITY:
|
||||
g_string_append (string, "opacity(");
|
||||
gtk_css_value_print (filter->opacity.value, string);
|
||||
_gtk_css_value_print (filter->opacity.value, string);
|
||||
g_string_append (string, ")");
|
||||
break;
|
||||
|
||||
case GTK_CSS_FILTER_SATURATE:
|
||||
g_string_append (string, "saturate(");
|
||||
gtk_css_value_print (filter->saturate.value, string);
|
||||
_gtk_css_value_print (filter->saturate.value, string);
|
||||
g_string_append (string, ")");
|
||||
break;
|
||||
|
||||
case GTK_CSS_FILTER_SEPIA:
|
||||
g_string_append (string, "sepia(");
|
||||
gtk_css_value_print (filter->sepia.value, string);
|
||||
_gtk_css_value_print (filter->sepia.value, string);
|
||||
g_string_append (string, ")");
|
||||
break;
|
||||
|
||||
case GTK_CSS_FILTER_BLUR:
|
||||
g_string_append (string, "blur(");
|
||||
gtk_css_value_print (filter->blur.value, string);
|
||||
_gtk_css_value_print (filter->blur.value, string);
|
||||
g_string_append (string, ")");
|
||||
break;
|
||||
|
||||
case GTK_CSS_FILTER_DROP_SHADOW:
|
||||
g_string_append (string, "drop-shadow(");
|
||||
gtk_css_value_print (filter->drop_shadow.value, string);
|
||||
_gtk_css_value_print (filter->drop_shadow.value, string);
|
||||
g_string_append (string, ")");
|
||||
break;
|
||||
|
||||
@@ -717,7 +723,7 @@ static const GtkCssValueClass GTK_CSS_VALUE_FILTER = {
|
||||
gtk_css_value_filter_print
|
||||
};
|
||||
|
||||
static GtkCssValue filter_none_singleton = { >K_CSS_VALUE_FILTER, 1, TRUE, FALSE, 0, { { GTK_CSS_FILTER_NONE } } };
|
||||
static GtkCssValue filter_none_singleton = { >K_CSS_VALUE_FILTER, 1, TRUE, 0, { { GTK_CSS_FILTER_NONE } } };
|
||||
|
||||
static GtkCssValue *
|
||||
gtk_css_filter_value_alloc (guint n_filters)
|
||||
@@ -726,7 +732,7 @@ gtk_css_filter_value_alloc (guint n_filters)
|
||||
|
||||
g_return_val_if_fail (n_filters > 0, NULL);
|
||||
|
||||
result = gtk_css_value_alloc (>K_CSS_VALUE_FILTER, sizeof (GtkCssValue) + sizeof (GtkCssFilter) * (n_filters - 1));
|
||||
result = _gtk_css_value_alloc (>K_CSS_VALUE_FILTER, sizeof (GtkCssValue) + sizeof (GtkCssFilter) * (n_filters - 1));
|
||||
result->n_filters = n_filters;
|
||||
|
||||
return result;
|
||||
@@ -735,7 +741,7 @@ gtk_css_filter_value_alloc (guint n_filters)
|
||||
GtkCssValue *
|
||||
gtk_css_filter_value_new_none (void)
|
||||
{
|
||||
return gtk_css_value_ref (&filter_none_singleton);
|
||||
return _gtk_css_value_ref (&filter_none_singleton);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -751,7 +757,7 @@ gtk_css_filter_parse_number (GtkCssParser *parser,
|
||||
{
|
||||
GtkCssValue **values = data;
|
||||
|
||||
values[n] = gtk_css_number_value_parse (parser, GTK_CSS_PARSE_NUMBER | GTK_CSS_PARSE_PERCENT | GTK_CSS_POSITIVE_ONLY);
|
||||
values[n] = _gtk_css_number_value_parse (parser, GTK_CSS_PARSE_NUMBER | GTK_CSS_PARSE_PERCENT | GTK_CSS_POSITIVE_ONLY);
|
||||
if (values[n] == NULL)
|
||||
return 0;
|
||||
|
||||
@@ -765,7 +771,7 @@ gtk_css_filter_parse_length (GtkCssParser *parser,
|
||||
{
|
||||
GtkCssValue **values = data;
|
||||
|
||||
values[n] = gtk_css_number_value_parse (parser, GTK_CSS_PARSE_LENGTH | GTK_CSS_POSITIVE_ONLY);
|
||||
values[n] = _gtk_css_number_value_parse (parser, GTK_CSS_PARSE_LENGTH | GTK_CSS_POSITIVE_ONLY);
|
||||
if (values[n] == NULL)
|
||||
return 0;
|
||||
|
||||
@@ -779,7 +785,7 @@ gtk_css_filter_parse_angle (GtkCssParser *parser,
|
||||
{
|
||||
GtkCssValue **values = data;
|
||||
|
||||
values[n] = gtk_css_number_value_parse (parser, GTK_CSS_PARSE_ANGLE);
|
||||
values[n] = _gtk_css_number_value_parse (parser, GTK_CSS_PARSE_ANGLE);
|
||||
if (values[n] == NULL)
|
||||
return 0;
|
||||
|
||||
@@ -957,7 +963,7 @@ gtk_css_filter_value_push_snapshot (const GtkCssValue *filter,
|
||||
{
|
||||
if (filter->filters[j].type == GTK_CSS_FILTER_BLUR)
|
||||
{
|
||||
double std_dev = gtk_css_number_value_get (filter->filters[j].blur.value, 100.0);
|
||||
double std_dev = _gtk_css_number_value_get (filter->filters[j].blur.value, 100.0);
|
||||
gtk_snapshot_push_blur (snapshot, 2 * std_dev);
|
||||
}
|
||||
else if (filter->filters[j].type == GTK_CSS_FILTER_DROP_SHADOW)
|
||||
|
||||
@@ -53,11 +53,13 @@ gtk_css_value_font_features_free (GtkCssValue *value)
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
gtk_css_value_font_features_compute (GtkCssValue *specified,
|
||||
guint property_id,
|
||||
GtkCssComputeContext *context)
|
||||
gtk_css_value_font_features_compute (GtkCssValue *specified,
|
||||
guint property_id,
|
||||
GtkStyleProvider *provider,
|
||||
GtkCssStyle *style,
|
||||
GtkCssStyle *parent_style)
|
||||
{
|
||||
return gtk_css_value_ref (specified);
|
||||
return _gtk_css_value_ref (specified);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -168,7 +170,7 @@ gtk_css_font_features_value_new_empty (void)
|
||||
{
|
||||
GtkCssValue *result;
|
||||
|
||||
result = gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_FONT_FEATURES);
|
||||
result = _gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_FONT_FEATURES);
|
||||
result->features = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
|
||||
result->is_computed = TRUE;
|
||||
|
||||
@@ -181,7 +183,7 @@ gtk_css_font_features_value_new_default (void)
|
||||
if (default_font_features == NULL)
|
||||
default_font_features = gtk_css_font_features_value_new_empty ();
|
||||
|
||||
return gtk_css_value_ref (default_font_features);
|
||||
return _gtk_css_value_ref (default_font_features);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -215,7 +217,7 @@ gtk_css_font_features_value_parse (GtkCssParser *parser)
|
||||
name = gtk_css_parser_consume_string (parser);
|
||||
if (name == NULL)
|
||||
{
|
||||
gtk_css_value_unref (result);
|
||||
_gtk_css_value_unref (result);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -223,7 +225,7 @@ gtk_css_font_features_value_parse (GtkCssParser *parser)
|
||||
{
|
||||
gtk_css_parser_error_value (parser, "Not a valid OpenType tag.");
|
||||
g_free (name);
|
||||
gtk_css_value_unref (result);
|
||||
_gtk_css_value_unref (result);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -236,7 +238,7 @@ gtk_css_font_features_value_parse (GtkCssParser *parser)
|
||||
if (!gtk_css_parser_consume_integer (parser, &num))
|
||||
{
|
||||
g_free (name);
|
||||
gtk_css_value_unref (result);
|
||||
_gtk_css_value_unref (result);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,11 +52,13 @@ gtk_css_value_font_variations_free (GtkCssValue *value)
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
gtk_css_value_font_variations_compute (GtkCssValue *specified,
|
||||
guint property_id,
|
||||
GtkCssComputeContext *context)
|
||||
gtk_css_value_font_variations_compute (GtkCssValue *specified,
|
||||
guint property_id,
|
||||
GtkStyleProvider *provider,
|
||||
GtkCssStyle *style,
|
||||
GtkCssStyle *parent_style)
|
||||
{
|
||||
return gtk_css_value_ref (specified);
|
||||
return _gtk_css_value_ref (specified);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -76,7 +78,7 @@ gtk_css_value_font_variations_equal (const GtkCssValue *value1,
|
||||
if (coord2 == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (!gtk_css_value_equal (coord1, coord2))
|
||||
if (!_gtk_css_value_equal (coord1, coord2))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -106,9 +108,9 @@ gtk_css_value_font_variations_transition (GtkCssValue *start,
|
||||
{
|
||||
end_coord = g_hash_table_lookup (end->axes, name);
|
||||
if (end_coord == NULL)
|
||||
transition = gtk_css_value_ref (start_coord);
|
||||
transition = _gtk_css_value_ref (start_coord);
|
||||
else
|
||||
transition = gtk_css_value_transition (start_coord, end_coord, property_id, progress);
|
||||
transition = _gtk_css_value_transition (start_coord, end_coord, property_id, progress);
|
||||
|
||||
gtk_css_font_variations_value_add_axis (result, name, transition);
|
||||
}
|
||||
@@ -120,7 +122,7 @@ gtk_css_value_font_variations_transition (GtkCssValue *start,
|
||||
if (start_coord != NULL)
|
||||
continue;
|
||||
|
||||
gtk_css_font_variations_value_add_axis (result, name, gtk_css_value_ref (end_coord));
|
||||
gtk_css_font_variations_value_add_axis (result, name, _gtk_css_value_ref (end_coord));
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -149,7 +151,7 @@ gtk_css_value_font_variations_print (const GtkCssValue *value,
|
||||
else
|
||||
g_string_append (string, ", ");
|
||||
g_string_append_printf (string, "\"%s\" ", name);
|
||||
gtk_css_value_print (coord, string);
|
||||
_gtk_css_value_print (coord, string);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,10 +171,10 @@ gtk_css_font_variations_value_new_empty (void)
|
||||
{
|
||||
GtkCssValue *result;
|
||||
|
||||
result = gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_FONT_VARIATIONS);
|
||||
result = _gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_FONT_VARIATIONS);
|
||||
result->axes = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
g_free,
|
||||
(GDestroyNotify) gtk_css_value_unref);
|
||||
(GDestroyNotify) _gtk_css_value_unref);
|
||||
result->is_computed = TRUE;
|
||||
|
||||
return result;
|
||||
@@ -184,7 +186,7 @@ gtk_css_font_variations_value_new_default (void)
|
||||
if (default_font_variations == NULL)
|
||||
default_font_variations = gtk_css_font_variations_value_new_empty ();
|
||||
|
||||
return gtk_css_value_ref (default_font_variations);
|
||||
return _gtk_css_value_ref (default_font_variations);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -217,7 +219,7 @@ gtk_css_font_variations_value_parse (GtkCssParser *parser)
|
||||
name = gtk_css_parser_consume_string (parser);
|
||||
if (name == NULL)
|
||||
{
|
||||
gtk_css_value_unref (result);
|
||||
_gtk_css_value_unref (result);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -225,15 +227,15 @@ gtk_css_font_variations_value_parse (GtkCssParser *parser)
|
||||
{
|
||||
gtk_css_parser_error_value (parser, "Not a valid OpenType tag.");
|
||||
g_free (name);
|
||||
gtk_css_value_unref (result);
|
||||
_gtk_css_value_unref (result);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
coord = gtk_css_number_value_parse (parser, GTK_CSS_PARSE_NUMBER);
|
||||
coord = _gtk_css_number_value_parse (parser, GTK_CSS_PARSE_NUMBER);
|
||||
if (coord == NULL)
|
||||
{
|
||||
g_free (name);
|
||||
gtk_css_value_unref (result);
|
||||
_gtk_css_value_unref (result);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -268,7 +270,7 @@ gtk_css_font_variations_value_get_variations (GtkCssValue *value)
|
||||
else
|
||||
g_string_append (string, ",");
|
||||
g_string_append_printf (string, "%s=%g", name,
|
||||
gtk_css_number_value_get (coord, 100));
|
||||
_gtk_css_number_value_get (coord, 100));
|
||||
}
|
||||
|
||||
return g_string_free (string, FALSE);
|
||||
|
||||
+13
-9
@@ -65,9 +65,11 @@ gtk_css_image_real_get_aspect_ratio (GtkCssImage *image)
|
||||
}
|
||||
|
||||
static GtkCssImage *
|
||||
gtk_css_image_real_compute (GtkCssImage *image,
|
||||
guint property_id,
|
||||
GtkCssComputeContext *context)
|
||||
gtk_css_image_real_compute (GtkCssImage *image,
|
||||
guint property_id,
|
||||
GtkStyleProvider *provider,
|
||||
GtkCssStyle *style,
|
||||
GtkCssStyle *parent_style)
|
||||
{
|
||||
return g_object_ref (image);
|
||||
}
|
||||
@@ -171,19 +173,21 @@ _gtk_css_image_get_aspect_ratio (GtkCssImage *image)
|
||||
}
|
||||
|
||||
GtkCssImage *
|
||||
_gtk_css_image_compute (GtkCssImage *image,
|
||||
guint property_id,
|
||||
GtkCssComputeContext *context)
|
||||
_gtk_css_image_compute (GtkCssImage *image,
|
||||
guint property_id,
|
||||
GtkStyleProvider *provider,
|
||||
GtkCssStyle *style,
|
||||
GtkCssStyle *parent_style)
|
||||
{
|
||||
GtkCssImageClass *klass;
|
||||
|
||||
gtk_internal_return_val_if_fail (GTK_IS_CSS_IMAGE (image), NULL);
|
||||
gtk_internal_return_val_if_fail (GTK_IS_CSS_STYLE (context->style), NULL);
|
||||
gtk_internal_return_val_if_fail (context->parent_style == NULL || GTK_IS_CSS_STYLE (context->parent_style), NULL);
|
||||
gtk_internal_return_val_if_fail (GTK_IS_CSS_STYLE (style), NULL);
|
||||
gtk_internal_return_val_if_fail (parent_style == NULL || GTK_IS_CSS_STYLE (parent_style), NULL);
|
||||
|
||||
klass = GTK_CSS_IMAGE_GET_CLASS (image);
|
||||
|
||||
return klass->compute (image, property_id, context);
|
||||
return klass->compute (image, property_id, provider, style, parent_style);
|
||||
}
|
||||
|
||||
GtkCssImage *
|
||||
|
||||
+43
-41
@@ -61,7 +61,7 @@ gtk_css_image_conic_snapshot (GtkCssImage *image,
|
||||
}
|
||||
else
|
||||
{
|
||||
pos = gtk_css_number_value_get (stop->offset, 360) / 360;
|
||||
pos = _gtk_css_number_value_get (stop->offset, 360) / 360;
|
||||
pos = CLAMP (pos, 0.0, 1.0);
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ gtk_css_image_conic_snapshot (GtkCssImage *image,
|
||||
&GRAPHENE_RECT_INIT (0, 0, width, height),
|
||||
&GRAPHENE_POINT_INIT (_gtk_css_position_value_get_x (self->center, width),
|
||||
_gtk_css_position_value_get_y (self->center, height)),
|
||||
gtk_css_number_value_get (self->rotation, 360),
|
||||
_gtk_css_number_value_get (self->rotation, 360),
|
||||
stops,
|
||||
self->n_stops);
|
||||
}
|
||||
@@ -98,13 +98,13 @@ parse_angles (GtkCssParser *parser,
|
||||
{
|
||||
GtkCssValue **angles = option_data;
|
||||
|
||||
angles[0] = gtk_css_number_value_parse (parser, GTK_CSS_PARSE_ANGLE | GTK_CSS_PARSE_PERCENT);
|
||||
angles[0] = _gtk_css_number_value_parse (parser, GTK_CSS_PARSE_ANGLE | GTK_CSS_PARSE_PERCENT);
|
||||
if (angles[0] == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (gtk_css_number_value_can_parse (parser))
|
||||
{
|
||||
angles[1] = gtk_css_number_value_parse (parser, GTK_CSS_PARSE_ANGLE | GTK_CSS_PARSE_PERCENT);
|
||||
angles[1] = _gtk_css_number_value_parse (parser, GTK_CSS_PARSE_ANGLE | GTK_CSS_PARSE_PERCENT);
|
||||
if (angles[1] == NULL)
|
||||
return FALSE;
|
||||
}
|
||||
@@ -119,7 +119,7 @@ parse_color (GtkCssParser *parser,
|
||||
{
|
||||
GtkCssValue **color = option_data;
|
||||
|
||||
*color = gtk_css_color_value_parse (parser);
|
||||
*color = _gtk_css_color_value_parse (parser);
|
||||
if (*color == NULL)
|
||||
return FALSE;
|
||||
|
||||
@@ -176,14 +176,14 @@ gtk_css_image_conic_parse_first_arg (GtkCssImageConic *self,
|
||||
|
||||
if (gtk_css_parser_try_ident (parser, "from"))
|
||||
{
|
||||
self->rotation = gtk_css_number_value_parse (parser, GTK_CSS_PARSE_ANGLE);
|
||||
self->rotation = _gtk_css_number_value_parse (parser, GTK_CSS_PARSE_ANGLE);
|
||||
if (self->rotation == NULL)
|
||||
return 0;
|
||||
nothing_parsed = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
self->rotation = gtk_css_number_value_new (0, GTK_CSS_DEG);
|
||||
self->rotation = _gtk_css_number_value_new (0, GTK_CSS_DEG);
|
||||
}
|
||||
|
||||
if (gtk_css_parser_try_ident (parser, "at"))
|
||||
@@ -195,8 +195,8 @@ gtk_css_image_conic_parse_first_arg (GtkCssImageConic *self,
|
||||
}
|
||||
else
|
||||
{
|
||||
self->center = _gtk_css_position_value_new (gtk_css_number_value_new (50, GTK_CSS_PERCENT),
|
||||
gtk_css_number_value_new (50, GTK_CSS_PERCENT));
|
||||
self->center = _gtk_css_position_value_new (_gtk_css_number_value_new (50, GTK_CSS_PERCENT),
|
||||
_gtk_css_number_value_new (50, GTK_CSS_PERCENT));
|
||||
}
|
||||
|
||||
if (!nothing_parsed)
|
||||
@@ -269,25 +269,25 @@ gtk_css_image_conic_print (GtkCssImage *image,
|
||||
|
||||
if (self->center)
|
||||
{
|
||||
GtkCssValue *compare = _gtk_css_position_value_new (gtk_css_number_value_new (50, GTK_CSS_PERCENT),
|
||||
gtk_css_number_value_new (50, GTK_CSS_PERCENT));
|
||||
GtkCssValue *compare = _gtk_css_position_value_new (_gtk_css_number_value_new (50, GTK_CSS_PERCENT),
|
||||
_gtk_css_number_value_new (50, GTK_CSS_PERCENT));
|
||||
|
||||
if (!gtk_css_value_equal (self->center, compare))
|
||||
if (!_gtk_css_value_equal (self->center, compare))
|
||||
{
|
||||
g_string_append (string, "from ");
|
||||
gtk_css_value_print (self->center, string);
|
||||
_gtk_css_value_print (self->center, string);
|
||||
written = TRUE;
|
||||
}
|
||||
|
||||
gtk_css_value_unref (compare);
|
||||
}
|
||||
|
||||
if (self->rotation && gtk_css_number_value_get (self->rotation, 360) != 0)
|
||||
if (self->rotation && _gtk_css_number_value_get (self->rotation, 360) != 0)
|
||||
{
|
||||
if (written)
|
||||
g_string_append_c (string, ' ');
|
||||
g_string_append (string, "at ");
|
||||
gtk_css_value_print (self->rotation, string);
|
||||
_gtk_css_value_print (self->rotation, string);
|
||||
}
|
||||
|
||||
if (written)
|
||||
@@ -300,12 +300,12 @@ gtk_css_image_conic_print (GtkCssImage *image,
|
||||
if (i > 0)
|
||||
g_string_append (string, ", ");
|
||||
|
||||
gtk_css_value_print (stop->color, string);
|
||||
_gtk_css_value_print (stop->color, string);
|
||||
|
||||
if (stop->offset)
|
||||
{
|
||||
g_string_append (string, " ");
|
||||
gtk_css_value_print (stop->offset, string);
|
||||
_gtk_css_value_print (stop->offset, string);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -313,9 +313,11 @@ gtk_css_image_conic_print (GtkCssImage *image,
|
||||
}
|
||||
|
||||
static GtkCssImage *
|
||||
gtk_css_image_conic_compute (GtkCssImage *image,
|
||||
guint property_id,
|
||||
GtkCssComputeContext *context)
|
||||
gtk_css_image_conic_compute (GtkCssImage *image,
|
||||
guint property_id,
|
||||
GtkStyleProvider *provider,
|
||||
GtkCssStyle *style,
|
||||
GtkCssStyle *parent_style)
|
||||
{
|
||||
GtkCssImageConic *self = GTK_CSS_IMAGE_CONIC (image);
|
||||
GtkCssImageConic *copy;
|
||||
@@ -323,8 +325,8 @@ gtk_css_image_conic_compute (GtkCssImage *image,
|
||||
|
||||
copy = g_object_new (GTK_TYPE_CSS_IMAGE_CONIC, NULL);
|
||||
|
||||
copy->center = gtk_css_value_compute (self->center, property_id, context);
|
||||
copy->rotation = gtk_css_value_compute (self->rotation, property_id, context);
|
||||
copy->center = _gtk_css_value_compute (self->center, property_id, provider, style, parent_style);
|
||||
copy->rotation = _gtk_css_value_compute (self->rotation, property_id, provider, style, parent_style);
|
||||
|
||||
copy->n_stops = self->n_stops;
|
||||
copy->color_stops = g_malloc (sizeof (GtkCssImageConicColorStop) * copy->n_stops);
|
||||
@@ -333,11 +335,11 @@ gtk_css_image_conic_compute (GtkCssImage *image,
|
||||
const GtkCssImageConicColorStop *stop = &self->color_stops[i];
|
||||
GtkCssImageConicColorStop *scopy = ©->color_stops[i];
|
||||
|
||||
scopy->color = gtk_css_value_compute (stop->color, property_id, context);
|
||||
scopy->color = _gtk_css_value_compute (stop->color, property_id, provider, style, parent_style);
|
||||
|
||||
if (stop->offset)
|
||||
{
|
||||
scopy->offset = gtk_css_value_compute (stop->offset, property_id, context);
|
||||
scopy->offset = _gtk_css_value_compute (stop->offset, property_id, provider, style, parent_style);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -372,11 +374,11 @@ gtk_css_image_conic_transition (GtkCssImage *start_image,
|
||||
|
||||
result = g_object_new (GTK_TYPE_CSS_IMAGE_CONIC, NULL);
|
||||
|
||||
result->center = gtk_css_value_transition (start->center, end->center, property_id, progress);
|
||||
result->center = _gtk_css_value_transition (start->center, end->center, property_id, progress);
|
||||
if (result->center == NULL)
|
||||
goto fail;
|
||||
|
||||
result->rotation = gtk_css_value_transition (start->rotation, end->rotation, property_id, progress);
|
||||
result->rotation = _gtk_css_value_transition (start->rotation, end->rotation, property_id, progress);
|
||||
if (result->rotation == NULL)
|
||||
goto fail;
|
||||
|
||||
@@ -397,22 +399,22 @@ gtk_css_image_conic_transition (GtkCssImage *start_image,
|
||||
}
|
||||
else
|
||||
{
|
||||
stop->offset = gtk_css_value_transition (start_stop->offset,
|
||||
end_stop->offset,
|
||||
property_id,
|
||||
progress);
|
||||
stop->offset = _gtk_css_value_transition (start_stop->offset,
|
||||
end_stop->offset,
|
||||
property_id,
|
||||
progress);
|
||||
if (stop->offset == NULL)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
stop->color = gtk_css_value_transition (start_stop->color,
|
||||
end_stop->color,
|
||||
property_id,
|
||||
progress);
|
||||
stop->color = _gtk_css_value_transition (start_stop->color,
|
||||
end_stop->color,
|
||||
property_id,
|
||||
progress);
|
||||
if (stop->color == NULL)
|
||||
{
|
||||
if (stop->offset)
|
||||
gtk_css_value_unref (stop->offset);
|
||||
_gtk_css_value_unref (stop->offset);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@@ -434,8 +436,8 @@ gtk_css_image_conic_equal (GtkCssImage *image1,
|
||||
GtkCssImageConic *conic2 = (GtkCssImageConic *) image2;
|
||||
guint i;
|
||||
|
||||
if (!gtk_css_value_equal (conic1->center, conic2->center) ||
|
||||
!gtk_css_value_equal (conic1->rotation, conic2->rotation))
|
||||
if (!_gtk_css_value_equal (conic1->center, conic2->center) ||
|
||||
!_gtk_css_value_equal (conic1->rotation, conic2->rotation))
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; i < conic1->n_stops; i++)
|
||||
@@ -443,8 +445,8 @@ gtk_css_image_conic_equal (GtkCssImage *image1,
|
||||
const GtkCssImageConicColorStop *stop1 = &conic1->color_stops[i];
|
||||
const GtkCssImageConicColorStop *stop2 = &conic2->color_stops[i];
|
||||
|
||||
if (!gtk_css_value_equal0 (stop1->offset, stop2->offset) ||
|
||||
!gtk_css_value_equal (stop1->color, stop2->color))
|
||||
if (!_gtk_css_value_equal0 (stop1->offset, stop2->offset) ||
|
||||
!_gtk_css_value_equal (stop1->color, stop2->color))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -461,9 +463,9 @@ gtk_css_image_conic_dispose (GObject *object)
|
||||
{
|
||||
GtkCssImageConicColorStop *stop = &self->color_stops[i];
|
||||
|
||||
gtk_css_value_unref (stop->color);
|
||||
_gtk_css_value_unref (stop->color);
|
||||
if (stop->offset)
|
||||
gtk_css_value_unref (stop->offset);
|
||||
_gtk_css_value_unref (stop->offset);
|
||||
}
|
||||
g_free (self->color_stops);
|
||||
|
||||
|
||||
@@ -289,11 +289,11 @@ parse_progress (GtkCssParser *parser,
|
||||
double *progress = option_data;
|
||||
GtkCssValue *number;
|
||||
|
||||
number = gtk_css_number_value_parse (parser, GTK_CSS_PARSE_PERCENT | GTK_CSS_POSITIVE_ONLY);
|
||||
number = _gtk_css_number_value_parse (parser, GTK_CSS_PARSE_PERCENT | GTK_CSS_POSITIVE_ONLY);
|
||||
if (number == NULL)
|
||||
return FALSE;
|
||||
*progress = gtk_css_number_value_get (number, 1);
|
||||
gtk_css_value_unref (number);
|
||||
*progress = _gtk_css_number_value_get (number, 1);
|
||||
_gtk_css_value_unref (number);
|
||||
|
||||
if (*progress > 1.0)
|
||||
{
|
||||
@@ -323,7 +323,7 @@ parse_image (GtkCssParser *parser,
|
||||
{
|
||||
GtkCssValue *color;
|
||||
|
||||
color = gtk_css_color_value_parse (parser);
|
||||
color = _gtk_css_color_value_parse (parser);
|
||||
if (color == NULL)
|
||||
return FALSE;
|
||||
|
||||
@@ -399,9 +399,11 @@ gtk_css_image_cross_fade_print (GtkCssImage *image,
|
||||
}
|
||||
|
||||
static GtkCssImage *
|
||||
gtk_css_image_cross_fade_compute (GtkCssImage *image,
|
||||
guint property_id,
|
||||
GtkCssComputeContext *context)
|
||||
gtk_css_image_cross_fade_compute (GtkCssImage *image,
|
||||
guint property_id,
|
||||
GtkStyleProvider *provider,
|
||||
GtkCssStyle *style,
|
||||
GtkCssStyle *parent_style)
|
||||
{
|
||||
GtkCssImageCrossFade *self = GTK_CSS_IMAGE_CROSS_FADE (image);
|
||||
GtkCssImageCrossFade *result;
|
||||
@@ -416,7 +418,7 @@ gtk_css_image_cross_fade_compute (GtkCssImage *image,
|
||||
gtk_css_image_cross_fade_add (result,
|
||||
entry->has_progress,
|
||||
entry->progress,
|
||||
_gtk_css_image_compute (entry->image, property_id, context));
|
||||
_gtk_css_image_compute (entry->image, property_id, provider, style, parent_style));
|
||||
}
|
||||
|
||||
return GTK_CSS_IMAGE (result);
|
||||
|
||||
+18
-12
@@ -105,7 +105,7 @@ gtk_css_image_fallback_print (GtkCssImage *image,
|
||||
{
|
||||
if (fallback->n_images > 0)
|
||||
g_string_append (string, ",");
|
||||
gtk_css_value_print (fallback->color, string);
|
||||
_gtk_css_value_print (fallback->color, string);
|
||||
}
|
||||
|
||||
g_string_append (string, ")");
|
||||
@@ -124,7 +124,7 @@ gtk_css_image_fallback_dispose (GObject *object)
|
||||
|
||||
if (fallback->color)
|
||||
{
|
||||
gtk_css_value_unref (fallback->color);
|
||||
_gtk_css_value_unref (fallback->color);
|
||||
fallback->color = NULL;
|
||||
}
|
||||
|
||||
@@ -133,9 +133,11 @@ gtk_css_image_fallback_dispose (GObject *object)
|
||||
|
||||
|
||||
static GtkCssImage *
|
||||
gtk_css_image_fallback_compute (GtkCssImage *image,
|
||||
guint property_id,
|
||||
GtkCssComputeContext *context)
|
||||
gtk_css_image_fallback_compute (GtkCssImage *image,
|
||||
guint property_id,
|
||||
GtkStyleProvider *provider,
|
||||
GtkCssStyle *style,
|
||||
GtkCssStyle *parent_style)
|
||||
{
|
||||
GtkCssImageFallback *fallback = GTK_CSS_IMAGE_FALLBACK (image);
|
||||
GtkCssImageFallback *copy;
|
||||
@@ -146,9 +148,11 @@ gtk_css_image_fallback_compute (GtkCssImage *image,
|
||||
GtkCssValue *computed_color = NULL;
|
||||
|
||||
if (fallback->color)
|
||||
computed_color = gtk_css_value_compute (fallback->color,
|
||||
property_id,
|
||||
context);
|
||||
computed_color = _gtk_css_value_compute (fallback->color,
|
||||
property_id,
|
||||
provider,
|
||||
style,
|
||||
parent_style);
|
||||
|
||||
/* image($color) that didn't change */
|
||||
if (computed_color && !fallback->images &&
|
||||
@@ -162,7 +166,9 @@ gtk_css_image_fallback_compute (GtkCssImage *image,
|
||||
{
|
||||
copy->images[i] = _gtk_css_image_compute (fallback->images[i],
|
||||
property_id,
|
||||
context);
|
||||
provider,
|
||||
style,
|
||||
parent_style);
|
||||
|
||||
if (gtk_css_image_is_invalid (copy->images[i]))
|
||||
continue;
|
||||
@@ -211,7 +217,7 @@ gtk_css_image_fallback_parse_arg (GtkCssParser *parser,
|
||||
}
|
||||
else
|
||||
{
|
||||
data->color = gtk_css_color_value_parse (parser);
|
||||
data->color = _gtk_css_color_value_parse (parser);
|
||||
if (data->color == NULL)
|
||||
return 0;
|
||||
|
||||
@@ -234,7 +240,7 @@ gtk_css_image_fallback_parse (GtkCssImage *image,
|
||||
|
||||
if (!gtk_css_parser_consume_function (parser, 1, G_MAXUINT, gtk_css_image_fallback_parse_arg, &data))
|
||||
{
|
||||
g_clear_pointer (&data.color, gtk_css_value_unref);
|
||||
g_clear_pointer (&data.color, _gtk_css_value_unref);
|
||||
if (data.images)
|
||||
g_ptr_array_free (data.images, TRUE);
|
||||
return FALSE;
|
||||
@@ -267,7 +273,7 @@ gtk_css_image_fallback_equal (GtkCssImage *image1,
|
||||
if (fallback2->used >= 0)
|
||||
return FALSE;
|
||||
|
||||
return gtk_css_value_equal (fallback1->color, fallback2->color);
|
||||
return _gtk_css_value_equal (fallback1->color, fallback2->color);
|
||||
}
|
||||
|
||||
if (fallback2->used < 0)
|
||||
|
||||
@@ -138,9 +138,11 @@ gtk_css_image_icon_theme_print (GtkCssImage *image,
|
||||
}
|
||||
|
||||
static GtkCssImage *
|
||||
gtk_css_image_icon_theme_compute (GtkCssImage *image,
|
||||
guint property_id,
|
||||
GtkCssComputeContext *context)
|
||||
gtk_css_image_icon_theme_compute (GtkCssImage *image,
|
||||
guint property_id,
|
||||
GtkStyleProvider *provider,
|
||||
GtkCssStyle *style,
|
||||
GtkCssStyle *parent_style)
|
||||
{
|
||||
GtkCssImageIconTheme *icon_theme = GTK_CSS_IMAGE_ICON_THEME (image);
|
||||
GtkCssImageIconTheme *copy;
|
||||
@@ -149,12 +151,12 @@ gtk_css_image_icon_theme_compute (GtkCssImage *image,
|
||||
|
||||
copy = g_object_new (GTK_TYPE_CSS_IMAGE_ICON_THEME, NULL);
|
||||
copy->name = g_strdup (icon_theme->name);
|
||||
settings = gtk_style_provider_get_settings (context->provider);
|
||||
settings = gtk_style_provider_get_settings (provider);
|
||||
display = _gtk_settings_get_display (settings);
|
||||
copy->icon_theme = gtk_icon_theme_get_for_display (display);
|
||||
copy->serial = gtk_icon_theme_get_serial (copy->icon_theme);
|
||||
copy->scale = gtk_style_provider_get_scale (context->provider);
|
||||
gtk_css_style_lookup_symbolic_colors (context->style, copy->colors);
|
||||
copy->scale = gtk_style_provider_get_scale (provider);
|
||||
gtk_icon_theme_lookup_symbolic_colors (style, copy->colors);
|
||||
|
||||
return GTK_CSS_IMAGE (copy);
|
||||
}
|
||||
|
||||
+37
-35
@@ -46,7 +46,7 @@ gtk_css_image_linear_get_repeating_start_end (GtkCssImageLinear *linear,
|
||||
if (stop->offset == NULL)
|
||||
*start = 0;
|
||||
else
|
||||
*start = gtk_css_number_value_get (stop->offset, length) / length;
|
||||
*start = _gtk_css_number_value_get (stop->offset, length) / length;
|
||||
|
||||
*end = *start;
|
||||
|
||||
@@ -57,7 +57,7 @@ gtk_css_image_linear_get_repeating_start_end (GtkCssImageLinear *linear,
|
||||
if (stop->offset == NULL)
|
||||
continue;
|
||||
|
||||
pos = gtk_css_number_value_get (stop->offset, length) / length;
|
||||
pos = _gtk_css_number_value_get (stop->offset, length) / length;
|
||||
|
||||
*end = MAX (pos, *end);
|
||||
}
|
||||
@@ -174,7 +174,7 @@ gtk_css_image_linear_snapshot (GtkCssImage *image,
|
||||
}
|
||||
else
|
||||
{
|
||||
angle = gtk_css_number_value_get (linear->angle, 100);
|
||||
angle = _gtk_css_number_value_get (linear->angle, 100);
|
||||
}
|
||||
|
||||
gtk_css_image_linear_compute_start_point (angle,
|
||||
@@ -224,7 +224,7 @@ gtk_css_image_linear_snapshot (GtkCssImage *image,
|
||||
}
|
||||
else
|
||||
{
|
||||
pos = gtk_css_number_value_get (stop->offset, length) / length;
|
||||
pos = _gtk_css_number_value_get (stop->offset, length) / length;
|
||||
pos = CLAMP (pos, 0.0, 1.0);
|
||||
}
|
||||
|
||||
@@ -273,18 +273,18 @@ gtk_css_image_linear_parse_color_stop (GtkCssImageLinear *self,
|
||||
{
|
||||
GtkCssImageLinearColorStop stop;
|
||||
|
||||
stop.color = gtk_css_color_value_parse (parser);
|
||||
stop.color = _gtk_css_color_value_parse (parser);
|
||||
if (stop.color == NULL)
|
||||
return 0;
|
||||
|
||||
if (gtk_css_number_value_can_parse (parser))
|
||||
{
|
||||
stop.offset = gtk_css_number_value_parse (parser,
|
||||
GTK_CSS_PARSE_PERCENT
|
||||
| GTK_CSS_PARSE_LENGTH);
|
||||
stop.offset = _gtk_css_number_value_parse (parser,
|
||||
GTK_CSS_PARSE_PERCENT
|
||||
| GTK_CSS_PARSE_LENGTH);
|
||||
if (stop.offset == NULL)
|
||||
{
|
||||
gtk_css_value_unref (stop.color);
|
||||
_gtk_css_value_unref (stop.color);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -359,7 +359,7 @@ gtk_css_image_linear_parse_first_arg (GtkCssImageLinear *linear,
|
||||
}
|
||||
else if (gtk_css_number_value_can_parse (parser))
|
||||
{
|
||||
linear->angle = gtk_css_number_value_parse (parser, GTK_CSS_PARSE_ANGLE);
|
||||
linear->angle = _gtk_css_number_value_parse (parser, GTK_CSS_PARSE_ANGLE);
|
||||
if (linear->angle == NULL)
|
||||
return 0;
|
||||
|
||||
@@ -464,7 +464,7 @@ gtk_css_image_linear_print (GtkCssImage *image,
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_css_value_print (linear->angle, string);
|
||||
_gtk_css_value_print (linear->angle, string);
|
||||
g_string_append (string, ", ");
|
||||
}
|
||||
|
||||
@@ -475,12 +475,12 @@ gtk_css_image_linear_print (GtkCssImage *image,
|
||||
if (i > 0)
|
||||
g_string_append (string, ", ");
|
||||
|
||||
gtk_css_value_print (stop->color, string);
|
||||
_gtk_css_value_print (stop->color, string);
|
||||
|
||||
if (stop->offset)
|
||||
{
|
||||
g_string_append (string, " ");
|
||||
gtk_css_value_print (stop->offset, string);
|
||||
_gtk_css_value_print (stop->offset, string);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -488,9 +488,11 @@ gtk_css_image_linear_print (GtkCssImage *image,
|
||||
}
|
||||
|
||||
static GtkCssImage *
|
||||
gtk_css_image_linear_compute (GtkCssImage *image,
|
||||
guint property_id,
|
||||
GtkCssComputeContext *context)
|
||||
gtk_css_image_linear_compute (GtkCssImage *image,
|
||||
guint property_id,
|
||||
GtkStyleProvider *provider,
|
||||
GtkCssStyle *style,
|
||||
GtkCssStyle *parent_style)
|
||||
{
|
||||
GtkCssImageLinear *linear = GTK_CSS_IMAGE_LINEAR (image);
|
||||
GtkCssImageLinear *copy;
|
||||
@@ -501,7 +503,7 @@ gtk_css_image_linear_compute (GtkCssImage *image,
|
||||
copy->side = linear->side;
|
||||
|
||||
if (linear->angle)
|
||||
copy->angle = gtk_css_value_compute (linear->angle, property_id, context);
|
||||
copy->angle = _gtk_css_value_compute (linear->angle, property_id, provider, style, parent_style);
|
||||
|
||||
copy->n_stops = linear->n_stops;
|
||||
copy->color_stops = g_malloc (sizeof (GtkCssImageLinearColorStop) * copy->n_stops);
|
||||
@@ -510,11 +512,11 @@ gtk_css_image_linear_compute (GtkCssImage *image,
|
||||
const GtkCssImageLinearColorStop *stop = &linear->color_stops[i];
|
||||
GtkCssImageLinearColorStop *scopy = ©->color_stops[i];
|
||||
|
||||
scopy->color = gtk_css_value_compute (stop->color, property_id, context);
|
||||
scopy->color = _gtk_css_value_compute (stop->color, property_id, provider, style, parent_style);
|
||||
|
||||
if (stop->offset)
|
||||
{
|
||||
scopy->offset = gtk_css_value_compute (stop->offset, property_id, context);
|
||||
scopy->offset = _gtk_css_value_compute (stop->offset, property_id, provider, style, parent_style);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -556,7 +558,7 @@ gtk_css_image_linear_transition (GtkCssImage *start_image,
|
||||
|
||||
result->side = start->side;
|
||||
if (result->side == 0)
|
||||
result->angle = gtk_css_value_transition (start->angle, end->angle, property_id, progress);
|
||||
result->angle = _gtk_css_value_transition (start->angle, end->angle, property_id, progress);
|
||||
if (result->angle == NULL)
|
||||
goto fail;
|
||||
|
||||
@@ -578,22 +580,22 @@ gtk_css_image_linear_transition (GtkCssImage *start_image,
|
||||
}
|
||||
else
|
||||
{
|
||||
stop->offset = gtk_css_value_transition (start_stop->offset,
|
||||
end_stop->offset,
|
||||
property_id,
|
||||
progress);
|
||||
stop->offset = _gtk_css_value_transition (start_stop->offset,
|
||||
end_stop->offset,
|
||||
property_id,
|
||||
progress);
|
||||
if (stop->offset == NULL)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
stop->color = gtk_css_value_transition (start_stop->color,
|
||||
end_stop->color,
|
||||
property_id,
|
||||
progress);
|
||||
stop->color = _gtk_css_value_transition (start_stop->color,
|
||||
end_stop->color,
|
||||
property_id,
|
||||
progress);
|
||||
if (stop->color == NULL)
|
||||
{
|
||||
if (stop->offset)
|
||||
gtk_css_value_unref (stop->offset);
|
||||
_gtk_css_value_unref (stop->offset);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@@ -617,7 +619,7 @@ gtk_css_image_linear_equal (GtkCssImage *image1,
|
||||
|
||||
if (linear1->repeating != linear2->repeating ||
|
||||
linear1->side != linear2->side ||
|
||||
(linear1->side == 0 && !gtk_css_value_equal (linear1->angle, linear2->angle)) ||
|
||||
(linear1->side == 0 && !_gtk_css_value_equal (linear1->angle, linear2->angle)) ||
|
||||
linear1->n_stops != linear2->n_stops)
|
||||
return FALSE;
|
||||
|
||||
@@ -626,8 +628,8 @@ gtk_css_image_linear_equal (GtkCssImage *image1,
|
||||
const GtkCssImageLinearColorStop *stop1 = &linear1->color_stops[i];
|
||||
const GtkCssImageLinearColorStop *stop2 = &linear2->color_stops[i];
|
||||
|
||||
if (!gtk_css_value_equal0 (stop1->offset, stop2->offset) ||
|
||||
!gtk_css_value_equal (stop1->color, stop2->color))
|
||||
if (!_gtk_css_value_equal0 (stop1->offset, stop2->offset) ||
|
||||
!_gtk_css_value_equal (stop1->color, stop2->color))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -644,16 +646,16 @@ gtk_css_image_linear_dispose (GObject *object)
|
||||
{
|
||||
GtkCssImageLinearColorStop *stop = &linear->color_stops[i];
|
||||
|
||||
gtk_css_value_unref (stop->color);
|
||||
_gtk_css_value_unref (stop->color);
|
||||
if (stop->offset)
|
||||
gtk_css_value_unref (stop->offset);
|
||||
_gtk_css_value_unref (stop->offset);
|
||||
}
|
||||
g_free (linear->color_stops);
|
||||
|
||||
linear->side = 0;
|
||||
if (linear->angle)
|
||||
{
|
||||
gtk_css_value_unref (linear->angle);
|
||||
_gtk_css_value_unref (linear->angle);
|
||||
linear->angle = NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkcssimagepaintableprivate.h"
|
||||
#include "gtkcssvalueprivate.h"
|
||||
|
||||
#include "gtkprivate.h"
|
||||
|
||||
@@ -97,9 +96,11 @@ gtk_css_image_paintable_get_static_image (GtkCssImage *image)
|
||||
}
|
||||
|
||||
static GtkCssImage *
|
||||
gtk_css_image_paintable_compute (GtkCssImage *image,
|
||||
guint property_id,
|
||||
GtkCssComputeContext *context)
|
||||
gtk_css_image_paintable_compute (GtkCssImage *image,
|
||||
guint property_id,
|
||||
GtkStyleProvider *provider,
|
||||
GtkCssStyle *style,
|
||||
GtkCssStyle *parent_style)
|
||||
{
|
||||
return gtk_css_image_paintable_get_static_image (image);
|
||||
}
|
||||
|
||||
@@ -26,8 +26,6 @@
|
||||
#include "gtk/css/gtkcsstokenizerprivate.h"
|
||||
#include "gtk/css/gtkcssparserprivate.h"
|
||||
#include "gtk/gtkcsstypesprivate.h"
|
||||
#include "gtk/gtkcssvariablesetprivate.h"
|
||||
#include "gtk/gtkcssvalueprivate.h"
|
||||
#include "gtk/gtksnapshot.h"
|
||||
#include "gtk/gtkstyleprovider.h"
|
||||
|
||||
@@ -62,7 +60,9 @@ struct _GtkCssImageClass
|
||||
/* create "computed value" in CSS terms, returns a new reference */
|
||||
GtkCssImage *(* compute) (GtkCssImage *image,
|
||||
guint property_id,
|
||||
GtkCssComputeContext *context);
|
||||
GtkStyleProvider *provider,
|
||||
GtkCssStyle *style,
|
||||
GtkCssStyle *parent_style);
|
||||
/* compare two images for equality */
|
||||
gboolean (* equal) (GtkCssImage *image1,
|
||||
GtkCssImage *image2);
|
||||
@@ -104,7 +104,9 @@ double _gtk_css_image_get_aspect_ratio (GtkCssImage *
|
||||
|
||||
GtkCssImage * _gtk_css_image_compute (GtkCssImage *image,
|
||||
guint property_id,
|
||||
GtkCssComputeContext *context);
|
||||
GtkStyleProvider *provider,
|
||||
GtkCssStyle *style,
|
||||
GtkCssStyle *parent_style);
|
||||
gboolean _gtk_css_image_equal (GtkCssImage *image1,
|
||||
GtkCssImage *image2) G_GNUC_PURE;
|
||||
GtkCssImage * _gtk_css_image_transition (GtkCssImage *start,
|
||||
|
||||
+52
-50
@@ -47,7 +47,7 @@ gtk_css_image_radial_get_start_end (GtkCssImageRadial *radial,
|
||||
if (stop->offset == NULL)
|
||||
*start = 0;
|
||||
else
|
||||
*start = gtk_css_number_value_get (stop->offset, radius) / radius;
|
||||
*start = _gtk_css_number_value_get (stop->offset, radius) / radius;
|
||||
|
||||
*end = *start;
|
||||
|
||||
@@ -58,7 +58,7 @@ gtk_css_image_radial_get_start_end (GtkCssImageRadial *radial,
|
||||
if (stop->offset == NULL)
|
||||
continue;
|
||||
|
||||
pos = gtk_css_number_value_get (stop->offset, radius) / radius;
|
||||
pos = _gtk_css_number_value_get (stop->offset, radius) / radius;
|
||||
|
||||
*end = MAX (pos, *end);
|
||||
}
|
||||
@@ -96,7 +96,7 @@ gtk_css_image_radial_snapshot (GtkCssImage *image,
|
||||
switch (radial->size)
|
||||
{
|
||||
case GTK_CSS_EXPLICIT_SIZE:
|
||||
hradius = gtk_css_number_value_get (radial->sizes[0], width);
|
||||
hradius = _gtk_css_number_value_get (radial->sizes[0], width);
|
||||
break;
|
||||
case GTK_CSS_CLOSEST_SIDE:
|
||||
hradius = MIN (MIN (x, width - x), MIN (y, height - y));
|
||||
@@ -128,8 +128,8 @@ gtk_css_image_radial_snapshot (GtkCssImage *image,
|
||||
switch (radial->size)
|
||||
{
|
||||
case GTK_CSS_EXPLICIT_SIZE:
|
||||
hradius = gtk_css_number_value_get (radial->sizes[0], width);
|
||||
vradius = gtk_css_number_value_get (radial->sizes[1], height);
|
||||
hradius = _gtk_css_number_value_get (radial->sizes[0], width);
|
||||
vradius = _gtk_css_number_value_get (radial->sizes[1], height);
|
||||
break;
|
||||
case GTK_CSS_CLOSEST_SIDE:
|
||||
hradius = MIN (x, width - x);
|
||||
@@ -176,7 +176,7 @@ gtk_css_image_radial_snapshot (GtkCssImage *image,
|
||||
continue;
|
||||
}
|
||||
else
|
||||
pos = MIN (1.0, gtk_css_number_value_get (stop->offset, hradius) / hradius);
|
||||
pos = MIN (1.0, _gtk_css_number_value_get (stop->offset, hradius) / hradius);
|
||||
|
||||
pos = MAX (pos, offset);
|
||||
step = (pos - offset) / (i - last);
|
||||
@@ -223,18 +223,18 @@ gtk_css_image_radial_parse_color_stop (GtkCssImageRadial *radial,
|
||||
{
|
||||
GtkCssImageRadialColorStop stop;
|
||||
|
||||
stop.color = gtk_css_color_value_parse (parser);
|
||||
stop.color = _gtk_css_color_value_parse (parser);
|
||||
if (stop.color == NULL)
|
||||
return 0;
|
||||
|
||||
if (gtk_css_number_value_can_parse (parser))
|
||||
{
|
||||
stop.offset = gtk_css_number_value_parse (parser,
|
||||
GTK_CSS_PARSE_PERCENT
|
||||
| GTK_CSS_PARSE_LENGTH);
|
||||
stop.offset = _gtk_css_number_value_parse (parser,
|
||||
GTK_CSS_PARSE_PERCENT
|
||||
| GTK_CSS_PARSE_LENGTH);
|
||||
if (stop.offset == NULL)
|
||||
{
|
||||
gtk_css_value_unref (stop.color);
|
||||
_gtk_css_value_unref (stop.color);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -294,12 +294,12 @@ gtk_css_image_radial_parse_first_arg (GtkCssImageRadial *radial,
|
||||
|
||||
if (!has_size && gtk_css_number_value_can_parse (parser))
|
||||
{
|
||||
radial->sizes[0] = gtk_css_number_value_parse (parser, GTK_CSS_PARSE_LENGTH | GTK_CSS_PARSE_PERCENT);
|
||||
radial->sizes[0] = _gtk_css_number_value_parse (parser, GTK_CSS_PARSE_LENGTH | GTK_CSS_PARSE_PERCENT);
|
||||
if (radial->sizes[0] == NULL)
|
||||
return 0;
|
||||
if (gtk_css_number_value_can_parse (parser))
|
||||
{
|
||||
radial->sizes[1] = gtk_css_number_value_parse (parser, GTK_CSS_PARSE_LENGTH | GTK_CSS_PARSE_PERCENT);
|
||||
radial->sizes[1] = _gtk_css_number_value_parse (parser, GTK_CSS_PARSE_LENGTH | GTK_CSS_PARSE_PERCENT);
|
||||
if (radial->sizes[1] == NULL)
|
||||
return 0;
|
||||
}
|
||||
@@ -323,8 +323,8 @@ gtk_css_image_radial_parse_first_arg (GtkCssImageRadial *radial,
|
||||
}
|
||||
else
|
||||
{
|
||||
radial->position = _gtk_css_position_value_new (gtk_css_number_value_new (50, GTK_CSS_PERCENT),
|
||||
gtk_css_number_value_new (50, GTK_CSS_PERCENT));
|
||||
radial->position = _gtk_css_position_value_new (_gtk_css_number_value_new (50, GTK_CSS_PERCENT),
|
||||
_gtk_css_number_value_new (50, GTK_CSS_PERCENT));
|
||||
}
|
||||
|
||||
if (!has_size)
|
||||
@@ -358,7 +358,7 @@ gtk_css_image_radial_parse_first_arg (GtkCssImageRadial *radial,
|
||||
if (has_size && !radial->circle)
|
||||
{
|
||||
if (radial->sizes[0] && !radial->sizes[1])
|
||||
radial->sizes[1] = gtk_css_value_ref (radial->sizes[0]);
|
||||
radial->sizes[1] = _gtk_css_value_ref (radial->sizes[0]);
|
||||
}
|
||||
|
||||
if (found_one)
|
||||
@@ -456,16 +456,16 @@ gtk_css_image_radial_print (GtkCssImage *image,
|
||||
else
|
||||
{
|
||||
if (radial->sizes[0])
|
||||
gtk_css_value_print (radial->sizes[0], string);
|
||||
_gtk_css_value_print (radial->sizes[0], string);
|
||||
if (radial->sizes[1])
|
||||
{
|
||||
g_string_append (string, " ");
|
||||
gtk_css_value_print (radial->sizes[1], string);
|
||||
_gtk_css_value_print (radial->sizes[1], string);
|
||||
}
|
||||
}
|
||||
|
||||
g_string_append (string, " at ");
|
||||
gtk_css_value_print (radial->position, string);
|
||||
_gtk_css_value_print (radial->position, string);
|
||||
|
||||
g_string_append (string, ", ");
|
||||
|
||||
@@ -476,12 +476,12 @@ gtk_css_image_radial_print (GtkCssImage *image,
|
||||
if (i > 0)
|
||||
g_string_append (string, ", ");
|
||||
|
||||
gtk_css_value_print (stop->color, string);
|
||||
_gtk_css_value_print (stop->color, string);
|
||||
|
||||
if (stop->offset)
|
||||
{
|
||||
g_string_append (string, " ");
|
||||
gtk_css_value_print (stop->offset, string);
|
||||
_gtk_css_value_print (stop->offset, string);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -489,9 +489,11 @@ gtk_css_image_radial_print (GtkCssImage *image,
|
||||
}
|
||||
|
||||
static GtkCssImage *
|
||||
gtk_css_image_radial_compute (GtkCssImage *image,
|
||||
guint property_id,
|
||||
GtkCssComputeContext *context)
|
||||
gtk_css_image_radial_compute (GtkCssImage *image,
|
||||
guint property_id,
|
||||
GtkStyleProvider *provider,
|
||||
GtkCssStyle *style,
|
||||
GtkCssStyle *parent_style)
|
||||
{
|
||||
GtkCssImageRadial *radial = GTK_CSS_IMAGE_RADIAL (image);
|
||||
GtkCssImageRadial *copy;
|
||||
@@ -502,13 +504,13 @@ gtk_css_image_radial_compute (GtkCssImage *image,
|
||||
copy->circle = radial->circle;
|
||||
copy->size = radial->size;
|
||||
|
||||
copy->position = gtk_css_value_compute (radial->position, property_id, context);
|
||||
copy->position = _gtk_css_value_compute (radial->position, property_id, provider, style, parent_style);
|
||||
|
||||
if (radial->sizes[0])
|
||||
copy->sizes[0] = gtk_css_value_compute (radial->sizes[0], property_id, context);
|
||||
copy->sizes[0] = _gtk_css_value_compute (radial->sizes[0], property_id, provider, style, parent_style);
|
||||
|
||||
if (radial->sizes[1])
|
||||
copy->sizes[1] = gtk_css_value_compute (radial->sizes[1], property_id, context);
|
||||
copy->sizes[1] = _gtk_css_value_compute (radial->sizes[1], property_id, provider, style, parent_style);
|
||||
|
||||
copy->n_stops = radial->n_stops;
|
||||
copy->color_stops = g_malloc (sizeof (GtkCssImageRadialColorStop) * copy->n_stops);
|
||||
@@ -517,11 +519,11 @@ gtk_css_image_radial_compute (GtkCssImage *image,
|
||||
const GtkCssImageRadialColorStop *stop = &radial->color_stops[i];
|
||||
GtkCssImageRadialColorStop *scopy = ©->color_stops[i];
|
||||
|
||||
scopy->color = gtk_css_value_compute (stop->color, property_id, context);
|
||||
scopy->color = _gtk_css_value_compute (stop->color, property_id, provider, style, parent_style);
|
||||
|
||||
if (stop->offset)
|
||||
{
|
||||
scopy->offset = gtk_css_value_compute (stop->offset, property_id, context);
|
||||
scopy->offset = _gtk_css_value_compute (stop->offset, property_id, provider, style, parent_style);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -562,13 +564,13 @@ gtk_css_image_radial_transition (GtkCssImage *start_image,
|
||||
result->circle = start->circle;
|
||||
result->size = start->size;
|
||||
|
||||
result->position = gtk_css_value_transition (start->position, end->position, property_id, progress);
|
||||
result->position = _gtk_css_value_transition (start->position, end->position, property_id, progress);
|
||||
if (result->position == NULL)
|
||||
goto fail;
|
||||
|
||||
if (start->sizes[0] && end->sizes[0])
|
||||
{
|
||||
result->sizes[0] = gtk_css_value_transition (start->sizes[0], end->sizes[0], property_id, progress);
|
||||
result->sizes[0] = _gtk_css_value_transition (start->sizes[0], end->sizes[0], property_id, progress);
|
||||
if (result->sizes[0] == NULL)
|
||||
goto fail;
|
||||
}
|
||||
@@ -577,7 +579,7 @@ gtk_css_image_radial_transition (GtkCssImage *start_image,
|
||||
|
||||
if (start->sizes[1] && end->sizes[1])
|
||||
{
|
||||
result->sizes[1] = gtk_css_value_transition (start->sizes[1], end->sizes[1], property_id, progress);
|
||||
result->sizes[1] = _gtk_css_value_transition (start->sizes[1], end->sizes[1], property_id, progress);
|
||||
if (result->sizes[1] == NULL)
|
||||
goto fail;
|
||||
}
|
||||
@@ -601,22 +603,22 @@ gtk_css_image_radial_transition (GtkCssImage *start_image,
|
||||
}
|
||||
else
|
||||
{
|
||||
stop->offset = gtk_css_value_transition (start_stop->offset,
|
||||
end_stop->offset,
|
||||
property_id,
|
||||
progress);
|
||||
stop->offset = _gtk_css_value_transition (start_stop->offset,
|
||||
end_stop->offset,
|
||||
property_id,
|
||||
progress);
|
||||
if (stop->offset == NULL)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
stop->color = gtk_css_value_transition (start_stop->color,
|
||||
end_stop->color,
|
||||
property_id,
|
||||
progress);
|
||||
stop->color = _gtk_css_value_transition (start_stop->color,
|
||||
end_stop->color,
|
||||
property_id,
|
||||
progress);
|
||||
if (stop->color == NULL)
|
||||
{
|
||||
if (stop->offset)
|
||||
gtk_css_value_unref (stop->offset);
|
||||
_gtk_css_value_unref (stop->offset);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@@ -640,11 +642,11 @@ gtk_css_image_radial_equal (GtkCssImage *image1,
|
||||
|
||||
if (radial1->repeating != radial2->repeating ||
|
||||
radial1->size != radial2->size ||
|
||||
!gtk_css_value_equal (radial1->position, radial2->position) ||
|
||||
!_gtk_css_value_equal (radial1->position, radial2->position) ||
|
||||
((radial1->sizes[0] == NULL) != (radial2->sizes[0] == NULL)) ||
|
||||
(radial1->sizes[0] && radial2->sizes[0] && !gtk_css_value_equal (radial1->sizes[0], radial2->sizes[0])) ||
|
||||
(radial1->sizes[0] && radial2->sizes[0] && !_gtk_css_value_equal (radial1->sizes[0], radial2->sizes[0])) ||
|
||||
((radial1->sizes[1] == NULL) != (radial2->sizes[1] == NULL)) ||
|
||||
(radial1->sizes[1] && radial2->sizes[1] && !gtk_css_value_equal (radial1->sizes[1], radial2->sizes[1])) ||
|
||||
(radial1->sizes[1] && radial2->sizes[1] && !_gtk_css_value_equal (radial1->sizes[1], radial2->sizes[1])) ||
|
||||
radial1->n_stops != radial2->n_stops)
|
||||
return FALSE;
|
||||
|
||||
@@ -653,8 +655,8 @@ gtk_css_image_radial_equal (GtkCssImage *image1,
|
||||
const GtkCssImageRadialColorStop *stop1 = &radial1->color_stops[i];
|
||||
const GtkCssImageRadialColorStop *stop2 = &radial2->color_stops[i];
|
||||
|
||||
if (!gtk_css_value_equal0 (stop1->offset, stop2->offset) ||
|
||||
!gtk_css_value_equal (stop1->color, stop2->color))
|
||||
if (!_gtk_css_value_equal0 (stop1->offset, stop2->offset) ||
|
||||
!_gtk_css_value_equal (stop1->color, stop2->color))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -671,22 +673,22 @@ gtk_css_image_radial_dispose (GObject *object)
|
||||
{
|
||||
GtkCssImageRadialColorStop *stop = &radial->color_stops[i];
|
||||
|
||||
gtk_css_value_unref (stop->color);
|
||||
_gtk_css_value_unref (stop->color);
|
||||
if (stop->offset)
|
||||
gtk_css_value_unref (stop->offset);
|
||||
_gtk_css_value_unref (stop->offset);
|
||||
}
|
||||
g_free (radial->color_stops);
|
||||
|
||||
if (radial->position)
|
||||
{
|
||||
gtk_css_value_unref (radial->position);
|
||||
_gtk_css_value_unref (radial->position);
|
||||
radial->position = NULL;
|
||||
}
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
if (radial->sizes[i])
|
||||
{
|
||||
gtk_css_value_unref (radial->sizes[i]);
|
||||
_gtk_css_value_unref (radial->sizes[i]);
|
||||
radial->sizes[i] = NULL;
|
||||
}
|
||||
|
||||
|
||||
+14
-12
@@ -44,7 +44,7 @@ gtk_css_image_recolor_print (GtkCssImage *image,
|
||||
if (recolor->palette)
|
||||
{
|
||||
g_string_append (string, ",");
|
||||
gtk_css_value_print (recolor->palette, string);
|
||||
_gtk_css_value_print (recolor->palette, string);
|
||||
}
|
||||
g_string_append (string, ")");
|
||||
}
|
||||
@@ -54,7 +54,7 @@ gtk_css_image_recolor_dispose (GObject *object)
|
||||
{
|
||||
GtkCssImageRecolor *recolor = GTK_CSS_IMAGE_RECOLOR (object);
|
||||
|
||||
g_clear_pointer (&recolor->palette, gtk_css_value_unref);
|
||||
g_clear_pointer (&recolor->palette, _gtk_css_value_unref);
|
||||
g_clear_object (&recolor->file);
|
||||
g_clear_object (&recolor->texture);
|
||||
|
||||
@@ -201,9 +201,11 @@ gtk_css_image_recolor_snapshot (GtkCssImage *image,
|
||||
}
|
||||
|
||||
static GtkCssImage *
|
||||
gtk_css_image_recolor_compute (GtkCssImage *image,
|
||||
guint property_id,
|
||||
GtkCssComputeContext *context)
|
||||
gtk_css_image_recolor_compute (GtkCssImage *image,
|
||||
guint property_id,
|
||||
GtkStyleProvider *provider,
|
||||
GtkCssStyle *style,
|
||||
GtkCssStyle *parent_style)
|
||||
{
|
||||
GtkCssImageRecolor *recolor = GTK_CSS_IMAGE_RECOLOR (image);
|
||||
GtkCssValue *palette;
|
||||
@@ -211,23 +213,23 @@ gtk_css_image_recolor_compute (GtkCssImage *image,
|
||||
int scale;
|
||||
GError *error = NULL;
|
||||
|
||||
scale = gtk_style_provider_get_scale (context->provider);
|
||||
scale = gtk_style_provider_get_scale (provider);
|
||||
|
||||
if (recolor->palette)
|
||||
palette = gtk_css_value_compute (recolor->palette, property_id, context);
|
||||
palette = _gtk_css_value_compute (recolor->palette, property_id, provider, style, parent_style);
|
||||
else
|
||||
palette = gtk_css_value_ref (context->style->core->icon_palette);
|
||||
palette = _gtk_css_value_ref (style->core->icon_palette);
|
||||
|
||||
img = gtk_css_image_recolor_load (recolor, context->style, palette, scale, &error);
|
||||
img = gtk_css_image_recolor_load (recolor, style, palette, scale, &error);
|
||||
|
||||
if (error)
|
||||
{
|
||||
GtkCssSection *section = gtk_css_style_get_section (context->style, property_id);
|
||||
gtk_style_provider_emit_error (context->provider, section, error);
|
||||
GtkCssSection *section = gtk_css_style_get_section (style, property_id);
|
||||
gtk_style_provider_emit_error (provider, section, error);
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
gtk_css_value_unref (palette);
|
||||
_gtk_css_value_unref (palette);
|
||||
|
||||
return img;
|
||||
}
|
||||
|
||||
@@ -97,9 +97,11 @@ gtk_css_image_scaled_dispose (GObject *object)
|
||||
|
||||
|
||||
static GtkCssImage *
|
||||
gtk_css_image_scaled_compute (GtkCssImage *image,
|
||||
guint property_id,
|
||||
GtkCssComputeContext *context)
|
||||
gtk_css_image_scaled_compute (GtkCssImage *image,
|
||||
guint property_id,
|
||||
GtkStyleProvider *provider,
|
||||
GtkCssStyle *style,
|
||||
GtkCssStyle *parent_style)
|
||||
{
|
||||
GtkCssImageScaled *scaled = GTK_CSS_IMAGE_SCALED (image);
|
||||
int scale;
|
||||
@@ -107,7 +109,7 @@ gtk_css_image_scaled_compute (GtkCssImage *image,
|
||||
int i;
|
||||
int best;
|
||||
|
||||
scale = gtk_style_provider_get_scale (context->provider);
|
||||
scale = gtk_style_provider_get_scale (provider);
|
||||
scale = MAX(scale, 1);
|
||||
|
||||
best = 0;
|
||||
@@ -133,7 +135,9 @@ gtk_css_image_scaled_compute (GtkCssImage *image,
|
||||
|
||||
res->images[0] = _gtk_css_image_compute (scaled->images[best],
|
||||
property_id,
|
||||
context);
|
||||
provider,
|
||||
style,
|
||||
parent_style);
|
||||
res->scales[0] = scaled->scales[best];
|
||||
|
||||
return GTK_CSS_IMAGE (res);
|
||||
|
||||
@@ -112,9 +112,11 @@ gtk_css_image_url_snapshot (GtkCssImage *image,
|
||||
}
|
||||
|
||||
static GtkCssImage *
|
||||
gtk_css_image_url_compute (GtkCssImage *image,
|
||||
guint property_id,
|
||||
GtkCssComputeContext *context)
|
||||
gtk_css_image_url_compute (GtkCssImage *image,
|
||||
guint property_id,
|
||||
GtkStyleProvider *provider,
|
||||
GtkCssStyle *style,
|
||||
GtkCssStyle *parent_style)
|
||||
{
|
||||
GtkCssImageUrl *url = GTK_CSS_IMAGE_URL (image);
|
||||
GtkCssImage *copy;
|
||||
@@ -123,8 +125,8 @@ gtk_css_image_url_compute (GtkCssImage *image,
|
||||
copy = gtk_css_image_url_load_image (url, &error);
|
||||
if (error)
|
||||
{
|
||||
GtkCssSection *section = gtk_css_style_get_section (context->style, property_id);
|
||||
gtk_style_provider_emit_error (context->provider, section, error);
|
||||
GtkCssSection *section = gtk_css_style_get_section (style, property_id);
|
||||
gtk_style_provider_emit_error (provider, section, error);
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
|
||||
+11
-9
@@ -34,23 +34,25 @@ gtk_css_value_image_free (GtkCssValue *value)
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
gtk_css_value_image_compute (GtkCssValue *value,
|
||||
guint property_id,
|
||||
GtkCssComputeContext *context)
|
||||
gtk_css_value_image_compute (GtkCssValue *value,
|
||||
guint property_id,
|
||||
GtkStyleProvider *provider,
|
||||
GtkCssStyle *style,
|
||||
GtkCssStyle *parent_style)
|
||||
{
|
||||
GtkCssImage *image, *computed;
|
||||
|
||||
image = _gtk_css_image_value_get_image (value);
|
||||
|
||||
if (image == NULL)
|
||||
return gtk_css_value_ref (value);
|
||||
return _gtk_css_value_ref (value);
|
||||
|
||||
computed = _gtk_css_image_compute (image, property_id, context);
|
||||
computed = _gtk_css_image_compute (image, property_id, provider, style, parent_style);
|
||||
|
||||
if (computed == image)
|
||||
{
|
||||
g_object_unref (computed);
|
||||
return gtk_css_value_ref (value);
|
||||
return _gtk_css_value_ref (value);
|
||||
}
|
||||
|
||||
return _gtk_css_image_value_new (computed);
|
||||
@@ -134,13 +136,13 @@ static const GtkCssValueClass GTK_CSS_VALUE_IMAGE = {
|
||||
GtkCssValue *
|
||||
_gtk_css_image_value_new (GtkCssImage *image)
|
||||
{
|
||||
static GtkCssValue image_none_singleton = { >K_CSS_VALUE_IMAGE, 1, TRUE, FALSE, NULL };
|
||||
static GtkCssValue image_none_singleton = { >K_CSS_VALUE_IMAGE, 1, TRUE, NULL };
|
||||
GtkCssValue *value;
|
||||
|
||||
if (image == NULL)
|
||||
return gtk_css_value_ref (&image_none_singleton);
|
||||
return _gtk_css_value_ref (&image_none_singleton);
|
||||
|
||||
value = gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_IMAGE);
|
||||
value = _gtk_css_value_new (GtkCssValue, >K_CSS_VALUE_IMAGE);
|
||||
value->image = image;
|
||||
value->is_computed = gtk_css_image_is_computed (image);
|
||||
|
||||
|
||||
@@ -34,19 +34,23 @@ gtk_css_value_inherit_free (GtkCssValue *value)
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
gtk_css_value_inherit_compute (GtkCssValue *value,
|
||||
guint property_id,
|
||||
GtkCssComputeContext *context)
|
||||
gtk_css_value_inherit_compute (GtkCssValue *value,
|
||||
guint property_id,
|
||||
GtkStyleProvider *provider,
|
||||
GtkCssStyle *style,
|
||||
GtkCssStyle *parent_style)
|
||||
{
|
||||
if (context->parent_style)
|
||||
if (parent_style)
|
||||
{
|
||||
return gtk_css_value_ref (gtk_css_style_get_value (context->parent_style, property_id));
|
||||
return _gtk_css_value_ref (gtk_css_style_get_value (parent_style, property_id));
|
||||
}
|
||||
else
|
||||
{
|
||||
return gtk_css_value_compute (_gtk_css_initial_value_get (),
|
||||
property_id,
|
||||
context);
|
||||
return _gtk_css_value_compute (_gtk_css_initial_value_get (),
|
||||
property_id,
|
||||
provider,
|
||||
style,
|
||||
parent_style);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +93,7 @@ static GtkCssValue inherit = { >K_CSS_VALUE_INHERIT, 1 };
|
||||
GtkCssValue *
|
||||
_gtk_css_inherit_value_new (void)
|
||||
{
|
||||
return gtk_css_value_ref (&inherit);
|
||||
return _gtk_css_value_ref (&inherit);
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
|
||||
+20
-12
@@ -38,16 +38,18 @@ gtk_css_value_initial_free (GtkCssValue *value)
|
||||
}
|
||||
|
||||
static GtkCssValue *
|
||||
gtk_css_value_initial_compute (GtkCssValue *value,
|
||||
guint property_id,
|
||||
GtkCssComputeContext *context)
|
||||
gtk_css_value_initial_compute (GtkCssValue *value,
|
||||
guint property_id,
|
||||
GtkStyleProvider *provider,
|
||||
GtkCssStyle *style,
|
||||
GtkCssStyle *parent_style)
|
||||
{
|
||||
GtkSettings *settings;
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case GTK_CSS_PROPERTY_DPI:
|
||||
settings = gtk_style_provider_get_settings (context->provider);
|
||||
settings = gtk_style_provider_get_settings (provider);
|
||||
if (settings)
|
||||
{
|
||||
int dpi_int;
|
||||
@@ -55,12 +57,12 @@ gtk_css_value_initial_compute (GtkCssValue *value,
|
||||
g_object_get (settings, "gtk-xft-dpi", &dpi_int, NULL);
|
||||
|
||||
if (dpi_int > 0.0)
|
||||
return gtk_css_number_value_new (dpi_int / 1024., GTK_CSS_NUMBER);
|
||||
return _gtk_css_number_value_new (dpi_int / 1024., GTK_CSS_NUMBER);
|
||||
}
|
||||
break;
|
||||
|
||||
case GTK_CSS_PROPERTY_FONT_FAMILY:
|
||||
settings = gtk_style_provider_get_settings (context->provider);
|
||||
settings = gtk_style_provider_get_settings (provider);
|
||||
if (settings && gtk_settings_get_font_family (settings) != NULL)
|
||||
return _gtk_css_array_value_new (_gtk_css_string_value_new (gtk_settings_get_font_family (settings)));
|
||||
break;
|
||||
@@ -69,9 +71,11 @@ gtk_css_value_initial_compute (GtkCssValue *value,
|
||||
break;
|
||||
}
|
||||
|
||||
return gtk_css_value_compute (_gtk_css_style_property_get_initial_value (_gtk_css_style_property_lookup_by_id (property_id)),
|
||||
return _gtk_css_value_compute (_gtk_css_style_property_get_initial_value (_gtk_css_style_property_lookup_by_id (property_id)),
|
||||
property_id,
|
||||
context);
|
||||
provider,
|
||||
style,
|
||||
parent_style);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -113,7 +117,7 @@ static GtkCssValue initial = { >K_CSS_VALUE_INITIAL, 1 };
|
||||
GtkCssValue *
|
||||
_gtk_css_initial_value_new (void)
|
||||
{
|
||||
return gtk_css_value_ref (&initial);
|
||||
return _gtk_css_value_ref (&initial);
|
||||
}
|
||||
|
||||
GtkCssValue *
|
||||
@@ -122,10 +126,14 @@ _gtk_css_initial_value_get (void)
|
||||
return &initial;
|
||||
}
|
||||
GtkCssValue *
|
||||
_gtk_css_initial_value_new_compute (guint property_id,
|
||||
GtkCssComputeContext *context)
|
||||
_gtk_css_initial_value_new_compute (guint property_id,
|
||||
GtkStyleProvider *provider,
|
||||
GtkCssStyle *style,
|
||||
GtkCssStyle *parent_style)
|
||||
{
|
||||
return gtk_css_value_initial_compute (NULL,
|
||||
property_id,
|
||||
context);
|
||||
provider,
|
||||
style,
|
||||
parent_style);
|
||||
}
|
||||
|
||||
@@ -25,8 +25,10 @@ G_BEGIN_DECLS
|
||||
|
||||
GtkCssValue * _gtk_css_initial_value_new (void);
|
||||
GtkCssValue * _gtk_css_initial_value_get (void);
|
||||
GtkCssValue * _gtk_css_initial_value_new_compute (guint property_id,
|
||||
GtkCssComputeContext *context);
|
||||
GtkCssValue * _gtk_css_initial_value_new_compute (guint property_id,
|
||||
GtkStyleProvider *provider,
|
||||
GtkCssStyle *style,
|
||||
GtkCssStyle *parent_style);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
+28
-309
@@ -21,8 +21,6 @@
|
||||
|
||||
#include "gtkcssstyleprivate.h"
|
||||
#include "gtkcssarrayvalueprivate.h"
|
||||
#include "gtkcsscustompropertypoolprivate.h"
|
||||
#include "gtkcssreferencevalueprivate.h"
|
||||
#include "gtkcssshorthandpropertyprivate.h"
|
||||
#include "gtkcssstylepropertyprivate.h"
|
||||
#include "gtkstylepropertyprivate.h"
|
||||
@@ -33,15 +31,12 @@
|
||||
#include <string.h>
|
||||
|
||||
struct _GtkCssKeyframes {
|
||||
int ref_count; /* ref count */
|
||||
int n_keyframes; /* number of keyframes (at least 2 for 0% and 100% */
|
||||
double *keyframe_progress; /* ordered array of n_keyframes of [0..1] */
|
||||
int n_properties; /* number of properties used by keyframes */
|
||||
guint *property_ids; /* ordered array of n_properties property ids */
|
||||
GtkCssValue **values; /* 2D array: n_keyframes * n_properties of (value or NULL) for all the keyframes */
|
||||
GtkCssVariableSet **variables; /* array of variable sets for each keyframe */
|
||||
int *variable_ids; /* ordered array of variable ids */
|
||||
int n_variables; /* number of variable used by keyframes */
|
||||
int ref_count; /* ref count */
|
||||
int n_keyframes; /* number of keyframes (at least 2 for 0% and 100% */
|
||||
double *keyframe_progress; /* ordered array of n_keyframes of [0..1] */
|
||||
int n_properties; /* number of properties used by keyframes */
|
||||
guint *property_ids; /* ordered array of n_properties property ids */
|
||||
GtkCssValue **values; /* 2D array: n_keyframes * n_properties of (value or NULL) for all the keyframes */
|
||||
};
|
||||
|
||||
#define KEYFRAMES_VALUE(keyframes, k, p) ((keyframes)->values[(k) * (keyframes)->n_properties + (p)])
|
||||
@@ -74,16 +69,11 @@ _gtk_css_keyframes_unref (GtkCssKeyframes *keyframes)
|
||||
{
|
||||
for (p = 0; p < keyframes->n_properties; p++)
|
||||
{
|
||||
gtk_css_value_unref (KEYFRAMES_VALUE (keyframes, k, p));
|
||||
_gtk_css_value_unref (KEYFRAMES_VALUE (keyframes, k, p));
|
||||
KEYFRAMES_VALUE (keyframes, k, p) = NULL;
|
||||
}
|
||||
|
||||
if (keyframes->variables && keyframes->variables[k])
|
||||
gtk_css_variable_set_unref (keyframes->variables[k]);
|
||||
}
|
||||
g_free (keyframes->values);
|
||||
g_free (keyframes->variables);
|
||||
g_free (keyframes->variable_ids);
|
||||
|
||||
g_free (keyframes);
|
||||
}
|
||||
@@ -103,7 +93,7 @@ gtk_css_keyframes_add_keyframe (GtkCssKeyframes *keyframes,
|
||||
if (KEYFRAMES_VALUE (keyframes, k, p) == NULL)
|
||||
continue;
|
||||
|
||||
gtk_css_value_unref (KEYFRAMES_VALUE (keyframes, k, p));
|
||||
_gtk_css_value_unref (KEYFRAMES_VALUE (keyframes, k, p));
|
||||
KEYFRAMES_VALUE (keyframes, k, p) = NULL;
|
||||
|
||||
/* XXX: GC properties that are now unset
|
||||
@@ -130,9 +120,6 @@ gtk_css_keyframes_add_keyframe (GtkCssKeyframes *keyframes,
|
||||
memset (&KEYFRAMES_VALUE (keyframes, k, 0), 0, size);
|
||||
}
|
||||
|
||||
if (keyframes->variables)
|
||||
keyframes->variables = g_realloc (keyframes->variables, sizeof (GtkCssVariableSet *) * keyframes->n_keyframes);
|
||||
|
||||
return k;
|
||||
}
|
||||
|
||||
@@ -186,26 +173,6 @@ gtk_css_keyframes_lookup_property (GtkCssKeyframes *keyframes,
|
||||
return p;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_keyframes_register_variable (GtkCssKeyframes *keyframes,
|
||||
int variable_id)
|
||||
{
|
||||
guint p;
|
||||
|
||||
for (p = 0; p < keyframes->n_variables; p++)
|
||||
{
|
||||
if (keyframes->variable_ids[p] == variable_id)
|
||||
return;
|
||||
else if (keyframes->variable_ids[p] > variable_id)
|
||||
break;
|
||||
}
|
||||
|
||||
keyframes->n_variables++;
|
||||
keyframes->variable_ids = g_realloc (keyframes->variable_ids, sizeof (int) * keyframes->n_variables);
|
||||
memmove (keyframes->variable_ids + p + 1, keyframes->variable_ids + p, sizeof (int) * (keyframes->n_variables - p - 1));
|
||||
keyframes->variable_ids[p] = variable_id;
|
||||
}
|
||||
|
||||
static GtkCssKeyframes *
|
||||
gtk_css_keyframes_alloc (void)
|
||||
{
|
||||
@@ -244,9 +211,9 @@ keyframes_set_value (GtkCssKeyframes *keyframes,
|
||||
p = gtk_css_keyframes_lookup_property (keyframes, _gtk_css_style_property_get_id (property));
|
||||
|
||||
if (KEYFRAMES_VALUE (keyframes, k, p))
|
||||
gtk_css_value_unref (KEYFRAMES_VALUE (keyframes, k, p));
|
||||
_gtk_css_value_unref (KEYFRAMES_VALUE (keyframes, k, p));
|
||||
|
||||
KEYFRAMES_VALUE (keyframes, k, p) = gtk_css_value_ref (value);
|
||||
KEYFRAMES_VALUE (keyframes, k, p) = _gtk_css_value_ref (value);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -268,47 +235,6 @@ gtk_css_keyframes_parse_declaration (GtkCssKeyframes *keyframes,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* This is a custom property */
|
||||
if (name[0] == '-' && name[1] == '-')
|
||||
{
|
||||
GtkCssVariableValue *var_value;
|
||||
GtkCssCustomPropertyPool *pool;
|
||||
int id;
|
||||
|
||||
if (!gtk_css_parser_try_token (parser, GTK_CSS_TOKEN_COLON))
|
||||
{
|
||||
gtk_css_parser_error_syntax (parser, "Expected a ':'");
|
||||
g_free (name);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
var_value = gtk_css_parser_parse_value_into_token_stream (parser);
|
||||
if (var_value == NULL)
|
||||
{
|
||||
g_free (name);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!keyframes->variables)
|
||||
keyframes->variables = g_new0 (GtkCssVariableSet *, keyframes->n_keyframes);
|
||||
|
||||
if (!keyframes->variables[k])
|
||||
keyframes->variables[k] = gtk_css_variable_set_new ();
|
||||
|
||||
pool = gtk_css_custom_property_pool_get ();
|
||||
id = gtk_css_custom_property_pool_add (pool, name);
|
||||
gtk_css_keyframes_register_variable (keyframes, id);
|
||||
|
||||
gtk_css_variable_value_taint (var_value);
|
||||
|
||||
gtk_css_variable_set_add (keyframes->variables[k], id, var_value);
|
||||
|
||||
gtk_css_custom_property_pool_unref (pool, id);
|
||||
|
||||
g_free (name);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
property = _gtk_style_property_lookup (name);
|
||||
if (property == NULL)
|
||||
{
|
||||
@@ -325,58 +251,14 @@ gtk_css_keyframes_parse_declaration (GtkCssKeyframes *keyframes,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (gtk_css_parser_has_references (parser))
|
||||
{
|
||||
GtkCssVariableValue *var_value;
|
||||
|
||||
var_value = gtk_css_parser_parse_value_into_token_stream (parser);
|
||||
if (var_value == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (GTK_IS_CSS_SHORTHAND_PROPERTY (property))
|
||||
{
|
||||
GtkCssShorthandProperty *shorthand = GTK_CSS_SHORTHAND_PROPERTY (property);
|
||||
guint i, n;
|
||||
GtkCssValue **values;
|
||||
|
||||
n = _gtk_css_shorthand_property_get_n_subproperties (shorthand);
|
||||
|
||||
values = g_new (GtkCssValue *, n);
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
GtkCssValue *child =
|
||||
_gtk_css_reference_value_new (property,
|
||||
var_value,
|
||||
gtk_css_parser_get_file (parser));
|
||||
_gtk_css_reference_value_set_subproperty (child, i);
|
||||
|
||||
values[i] = _gtk_css_array_value_get_nth (child, i);
|
||||
}
|
||||
|
||||
value = _gtk_css_array_value_new_from_array (values, n);
|
||||
g_free (values);
|
||||
}
|
||||
else
|
||||
{
|
||||
value = _gtk_css_reference_value_new (property,
|
||||
var_value,
|
||||
gtk_css_parser_get_file (parser));
|
||||
}
|
||||
|
||||
gtk_css_variable_value_unref (var_value);
|
||||
}
|
||||
else
|
||||
{
|
||||
value = _gtk_style_property_parse_value (property, parser);
|
||||
if (value == NULL)
|
||||
return FALSE;
|
||||
}
|
||||
value = _gtk_style_property_parse_value (property, parser);
|
||||
if (value == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (!gtk_css_parser_has_token (parser, GTK_CSS_TOKEN_EOF))
|
||||
{
|
||||
gtk_css_parser_error_syntax (parser, "Junk at end of value");
|
||||
gtk_css_value_unref (value);
|
||||
_gtk_css_value_unref (value);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -407,7 +289,7 @@ gtk_css_keyframes_parse_declaration (GtkCssKeyframes *keyframes,
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
gtk_css_value_unref (value);
|
||||
_gtk_css_value_unref (value);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -432,9 +314,6 @@ gtk_css_keyframes_parse_block (GtkCssKeyframes *keyframes,
|
||||
gtk_css_parser_end_block (parser);
|
||||
}
|
||||
|
||||
if (keyframes->variables && keyframes->variables[k])
|
||||
gtk_css_variable_set_resolve_cycles (keyframes->variables[k]);
|
||||
|
||||
gtk_css_parser_end_block (parser);
|
||||
|
||||
return TRUE;
|
||||
@@ -499,27 +378,12 @@ compare_property_by_name (gconstpointer a,
|
||||
_gtk_css_style_property_lookup_by_id (keyframes->property_ids[*(const guint *) b]))));
|
||||
}
|
||||
|
||||
static int
|
||||
compare_custom_property_ids (gconstpointer a, gconstpointer b, gpointer user_data)
|
||||
{
|
||||
GtkCssCustomPropertyPool *pool = user_data;
|
||||
int id1 = GPOINTER_TO_INT (*((const int *) a));
|
||||
int id2 = GPOINTER_TO_INT (*((const int *) b));
|
||||
const char *name1, *name2;
|
||||
|
||||
name1 = gtk_css_custom_property_pool_get_name (pool, id1);
|
||||
name2 = gtk_css_custom_property_pool_get_name (pool, id2);
|
||||
|
||||
return strcmp (name1, name2);
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_css_keyframes_print (GtkCssKeyframes *keyframes,
|
||||
GString *string)
|
||||
{
|
||||
GtkCssCustomPropertyPool *pool = gtk_css_custom_property_pool_get ();
|
||||
guint k, p;
|
||||
guint *sorted, *sorted_variable_ids = NULL;
|
||||
guint *sorted;
|
||||
|
||||
g_return_if_fail (keyframes != NULL);
|
||||
g_return_if_fail (string != NULL);
|
||||
@@ -529,18 +393,6 @@ _gtk_css_keyframes_print (GtkCssKeyframes *keyframes,
|
||||
sorted[p] = p;
|
||||
g_qsort_with_data (sorted, keyframes->n_properties, sizeof (guint), compare_property_by_name, keyframes);
|
||||
|
||||
if (keyframes->variable_ids)
|
||||
{
|
||||
sorted_variable_ids = g_memdup2 (keyframes->variable_ids,
|
||||
sizeof (int) * keyframes->n_variables);
|
||||
|
||||
g_qsort_with_data (sorted_variable_ids,
|
||||
keyframes->n_variables,
|
||||
sizeof (int),
|
||||
compare_custom_property_ids,
|
||||
pool);
|
||||
}
|
||||
|
||||
for (k = 0; k < keyframes->n_keyframes; k++)
|
||||
{
|
||||
/* useful for 0% and 100% which might be empty */
|
||||
@@ -566,47 +418,15 @@ _gtk_css_keyframes_print (GtkCssKeyframes *keyframes,
|
||||
GTK_STYLE_PROPERTY (
|
||||
_gtk_css_style_property_lookup_by_id (
|
||||
keyframes->property_ids[sorted[p]]))));
|
||||
gtk_css_value_print (KEYFRAMES_VALUE (keyframes, k, sorted[p]), string);
|
||||
_gtk_css_value_print (KEYFRAMES_VALUE (keyframes, k, sorted[p]), string);
|
||||
g_string_append (string, ";\n");
|
||||
}
|
||||
|
||||
if (keyframes->variables && keyframes->variables[k])
|
||||
{
|
||||
for (p = 0; p < keyframes->n_variables; p++)
|
||||
{
|
||||
int variable_id = sorted_variable_ids[p];
|
||||
GtkCssVariableValue *value =
|
||||
gtk_css_variable_set_lookup (keyframes->variables[k], variable_id, NULL);
|
||||
const char *name;
|
||||
|
||||
if (value == NULL)
|
||||
continue;
|
||||
|
||||
if (!opened)
|
||||
{
|
||||
if (keyframes->keyframe_progress[k] == 0.0)
|
||||
g_string_append (string, " from {\n");
|
||||
else if (keyframes->keyframe_progress[k] == 1.0)
|
||||
g_string_append (string, " to {\n");
|
||||
else
|
||||
g_string_append_printf (string, " %g%% {\n", keyframes->keyframe_progress[k] * 100);
|
||||
opened = TRUE;
|
||||
}
|
||||
|
||||
name = gtk_css_custom_property_pool_get_name (pool, variable_id);
|
||||
|
||||
g_string_append_printf (string, " %s: ", name);
|
||||
gtk_css_variable_value_print (value, string);
|
||||
g_string_append (string, ";\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (opened)
|
||||
g_string_append (string, " }\n");
|
||||
}
|
||||
|
||||
g_free (sorted);
|
||||
g_free (sorted_variable_ids);
|
||||
}
|
||||
|
||||
GtkCssKeyframes *
|
||||
@@ -615,7 +435,6 @@ _gtk_css_keyframes_compute (GtkCssKeyframes *keyframes,
|
||||
GtkCssStyle *style,
|
||||
GtkCssStyle *parent_style)
|
||||
{
|
||||
GtkCssComputeContext context = { NULL, };
|
||||
GtkCssKeyframes *resolved;
|
||||
guint k, p;
|
||||
|
||||
@@ -631,10 +450,6 @@ _gtk_css_keyframes_compute (GtkCssKeyframes *keyframes,
|
||||
resolved->property_ids = g_memdup2 (keyframes->property_ids, keyframes->n_properties * sizeof (guint));
|
||||
resolved->values = g_new0 (GtkCssValue *, resolved->n_keyframes * resolved->n_properties);
|
||||
|
||||
context.provider = provider;
|
||||
context.style = style;
|
||||
context.parent_style = parent_style;
|
||||
|
||||
for (p = 0; p < resolved->n_properties; p++)
|
||||
{
|
||||
for (k = 0; k < resolved->n_keyframes; k++)
|
||||
@@ -642,30 +457,14 @@ _gtk_css_keyframes_compute (GtkCssKeyframes *keyframes,
|
||||
if (KEYFRAMES_VALUE (keyframes, k, p) == NULL)
|
||||
continue;
|
||||
|
||||
context.variables = keyframes->variables ? keyframes->variables[k] : NULL;
|
||||
|
||||
KEYFRAMES_VALUE (resolved, k, p) = gtk_css_value_compute (KEYFRAMES_VALUE (keyframes, k, p),
|
||||
resolved->property_ids[p],
|
||||
&context);
|
||||
KEYFRAMES_VALUE (resolved, k, p) = _gtk_css_value_compute (KEYFRAMES_VALUE (keyframes, k, p),
|
||||
resolved->property_ids[p],
|
||||
provider,
|
||||
style,
|
||||
parent_style);
|
||||
}
|
||||
}
|
||||
|
||||
if (keyframes->variables)
|
||||
{
|
||||
resolved->variables = g_new0 (GtkCssVariableSet *, resolved->n_keyframes);
|
||||
|
||||
for (k = 0; k < resolved->n_keyframes; k++)
|
||||
{
|
||||
if (keyframes->variables[k])
|
||||
resolved->variables[k] = gtk_css_variable_set_ref (keyframes->variables[k]);
|
||||
}
|
||||
}
|
||||
else
|
||||
resolved->variables = NULL;
|
||||
|
||||
resolved->variable_ids = g_memdup2 (keyframes->variable_ids, keyframes->n_variables * sizeof (int));
|
||||
resolved->n_variables = keyframes->n_variables;
|
||||
|
||||
return resolved;
|
||||
}
|
||||
|
||||
@@ -712,7 +511,7 @@ _gtk_css_keyframes_get_value (GtkCssKeyframes *keyframes,
|
||||
|
||||
if (keyframes->keyframe_progress[k] == progress)
|
||||
{
|
||||
return gtk_css_value_ref (KEYFRAMES_VALUE (keyframes, k, id));
|
||||
return _gtk_css_value_ref (KEYFRAMES_VALUE (keyframes, k, id));
|
||||
}
|
||||
else if (keyframes->keyframe_progress[k] < progress)
|
||||
{
|
||||
@@ -729,95 +528,15 @@ _gtk_css_keyframes_get_value (GtkCssKeyframes *keyframes,
|
||||
|
||||
progress = (progress - start_progress) / (end_progress - start_progress);
|
||||
|
||||
result = gtk_css_value_transition (start_value,
|
||||
end_value,
|
||||
keyframes->property_ids[id],
|
||||
progress);
|
||||
result = _gtk_css_value_transition (start_value,
|
||||
end_value,
|
||||
keyframes->property_ids[id],
|
||||
progress);
|
||||
|
||||
/* XXX: Dear spec, what's the correct thing to do here? */
|
||||
if (result == NULL)
|
||||
return gtk_css_value_ref (start_value);
|
||||
return _gtk_css_value_ref (start_value);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
guint
|
||||
_gtk_css_keyframes_get_n_variables (GtkCssKeyframes *keyframes)
|
||||
{
|
||||
g_return_val_if_fail (keyframes != NULL, 0);
|
||||
|
||||
return keyframes->n_variables;
|
||||
}
|
||||
|
||||
int
|
||||
_gtk_css_keyframes_get_variable_id (GtkCssKeyframes *keyframes,
|
||||
guint id)
|
||||
{
|
||||
g_return_val_if_fail (keyframes != NULL, 0);
|
||||
g_return_val_if_fail (id < keyframes->n_variables, 0);
|
||||
|
||||
return keyframes->variable_ids[id];
|
||||
}
|
||||
|
||||
GtkCssVariableValue *
|
||||
_gtk_css_keyframes_get_variable (GtkCssKeyframes *keyframes,
|
||||
guint id,
|
||||
double progress,
|
||||
GtkCssVariableValue *default_value)
|
||||
{
|
||||
GtkCssVariableValue *start_value, *end_value, *result;
|
||||
double start_progress, end_progress;
|
||||
int variable_id;
|
||||
guint k;
|
||||
|
||||
g_return_val_if_fail (keyframes != NULL, 0);
|
||||
g_return_val_if_fail (id < keyframes->n_variables, 0);
|
||||
|
||||
start_value = default_value;
|
||||
start_progress = 0.0;
|
||||
end_value = default_value;
|
||||
end_progress = 1.0;
|
||||
|
||||
variable_id = keyframes->variable_ids[id];
|
||||
|
||||
for (k = 0; k < keyframes->n_keyframes; k++)
|
||||
{
|
||||
GtkCssVariableValue *value;
|
||||
|
||||
if (keyframes->variables[k] == NULL)
|
||||
continue;
|
||||
|
||||
value = gtk_css_variable_set_lookup (keyframes->variables[k], variable_id, NULL);
|
||||
|
||||
if (value == NULL)
|
||||
continue;
|
||||
|
||||
if (keyframes->keyframe_progress[k] == progress)
|
||||
{
|
||||
return gtk_css_variable_value_ref (value);
|
||||
}
|
||||
else if (keyframes->keyframe_progress[k] < progress)
|
||||
{
|
||||
start_value = value;
|
||||
start_progress = keyframes->keyframe_progress[k];
|
||||
}
|
||||
else
|
||||
{
|
||||
end_value = value;
|
||||
end_progress = keyframes->keyframe_progress[k];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
progress = (progress - start_progress) / (end_progress - start_progress);
|
||||
|
||||
result = gtk_css_variable_value_transition (start_value,
|
||||
end_value,
|
||||
progress);
|
||||
|
||||
/* XXX: Dear spec, what's the correct thing to do here? */
|
||||
if (result == NULL)
|
||||
return start_value ? gtk_css_variable_value_ref (start_value) : NULL;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -50,13 +50,5 @@ GtkCssValue * _gtk_css_keyframes_get_value (GtkCssKeyframes
|
||||
double progress,
|
||||
GtkCssValue *default_value);
|
||||
|
||||
guint _gtk_css_keyframes_get_n_variables (GtkCssKeyframes *keyframes);
|
||||
int _gtk_css_keyframes_get_variable_id (GtkCssKeyframes *keyframes,
|
||||
guint id);
|
||||
GtkCssVariableValue *_gtk_css_keyframes_get_variable (GtkCssKeyframes *keyframes,
|
||||
guint id,
|
||||
double progress,
|
||||
GtkCssVariableValue *default_value);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user