Bug 1909074. Don't pass OFFSET_BY_ORIGIN to GetResultingTransformMatrix when it's...
[gecko.git] / gfx / cairo / 11-quartz-surface-tags.patch
blobb66efcc4962559dffbac2a5c78159ad275ec8a7c
1 # HG changeset patch
2 # User Jonathan Kew <jkew@mozilla.com>
3 # Date 1713889788 -3600
4 # Tue Apr 23 17:29:48 2024 +0100
5 # Node ID 0421354d816b993767e2409c425aaa95a5291a26
6 # Parent 2a04d0b05957b4db2cd9e97f29d28565badca201
7 Bug 1892913 - patch 13 - Apply 11-quartz-surface-tags.patch
9 diff --git a/gfx/cairo/cairo/src/cairo-quartz-surface.c b/gfx/cairo/cairo/src/cairo-quartz-surface.c
10 --- a/gfx/cairo/cairo/src/cairo-quartz-surface.c
11 +++ b/gfx/cairo/cairo/src/cairo-quartz-surface.c
12 @@ -48,6 +48,7 @@
13 #include "cairo-surface-backend-private.h"
14 #include "cairo-surface-clipper-private.h"
15 #include "cairo-recording-surface-private.h"
16 +#include "cairo-tag-attributes-private.h"
18 #include <dlfcn.h>
20 @@ -2190,6 +2191,70 @@ static cairo_status_t
21 return CAIRO_STATUS_SUCCESS;
24 +static cairo_int_status_t
25 +_cairo_quartz_surface_tag (void *abstract_surface,
26 + cairo_bool_t begin,
27 + const char *tag_name,
28 + const char *attributes,
29 + const cairo_pattern_t *source,
30 + const cairo_stroke_style_t *style,
31 + const cairo_matrix_t *ctm,
32 + const cairo_matrix_t *ctm_inverse,
33 + const cairo_clip_t *clip)
35 + cairo_link_attrs_t link_attrs;
36 + cairo_int_status_t status = CAIRO_STATUS_SUCCESS;
37 + int i, num_rects;
38 + cairo_quartz_surface_t *surface = (cairo_quartz_surface_t *) abstract_surface;
40 + /* Currently the only tag we support is "Link" */
41 + if (strcmp (tag_name, "Link"))
42 + return CAIRO_INT_STATUS_UNSUPPORTED;
44 + /* We only process the 'begin' tag, and expect a rect attribute;
45 + using the extents of the drawing operations enclosed by the begin/end
46 + link tags to define the clickable area is not implemented. */
47 + if (!begin)
48 + return status;
50 + status = _cairo_tag_parse_link_attributes (attributes, &link_attrs);
51 + if (unlikely (status))
52 + return status;
54 + num_rects = _cairo_array_num_elements (&link_attrs.rects);
55 + if (num_rects > 0) {
56 + CFURLRef url = CFURLCreateWithBytes (NULL,
57 + (const UInt8 *) link_attrs.uri,
58 + strlen (link_attrs.uri),
59 + kCFStringEncodingUTF8,
60 + NULL);
62 + for (i = 0; i < num_rects; i++) {
63 + CGRect link_rect;
64 + cairo_rectangle_t rectf;
66 + _cairo_array_copy_element (&link_attrs.rects, i, &rectf);
68 + link_rect =
69 + CGRectMake (rectf.x,
70 + surface->extents.height - rectf.y - rectf.height,
71 + rectf.width,
72 + rectf.height);
74 + CGPDFContextSetURLForRect (surface->cgContext, url, link_rect);
75 + }
77 + CFRelease (url);
78 + }
80 + _cairo_array_fini (&link_attrs.rects);
81 + free (link_attrs.dest);
82 + free (link_attrs.uri);
83 + free (link_attrs.file);
85 + return status;
88 // XXXtodo implement show_page; need to figure out how to handle begin/end
90 static const cairo_surface_backend_t cairo_quartz_surface_backend = {
91 @@ -2226,7 +2291,7 @@ static const cairo_surface_backend_t cai
92 NULL, /* has_show_text_glyphs */
93 NULL, /* show_text_glyphs */
94 NULL, /* get_supported_mime_types */
95 - NULL, /* tag */
96 + _cairo_quartz_surface_tag /* tag */
99 cairo_quartz_surface_t *