gfx/cairo/on-edge.patch

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 commit a26655b3144ed273940486fc15ccdac12b0562ec
     2 Author: Jeff Muizelaar <jmuizelaar@mozilla.com>
     3 Date:   Tue Mar 17 15:08:50 2009 -0400
     5     Jeff Muizelaar noted that the treatment of edges differed with firefox's
     6     canvas definition, which considers a point on any edge as inside. The
     7     current implementation has a similar definition to that of flash, for
     8     which the top and right edges are outside. Arguably, firefox has the more
     9     intuitive definition here...
    11 diff --git a/src/cairo-path-in-fill.c b/src/cairo-path-in-fill.c
    12 index 21cd0bd..e641654 100644
    13 --- a/src/cairo-path-in-fill.c
    14 +++ b/src/cairo-path-in-fill.c
    15 @@ -41,6 +41,7 @@ typedef struct cairo_in_fill {
    16      int winding;
    18      cairo_fixed_t x, y;
    19 +    cairo_bool_t on_edge;
    21      cairo_bool_t has_current_point;
    22      cairo_point_t current_point;
    23 @@ -58,6 +59,7 @@ _cairo_in_fill_init (cairo_in_fill_t	*in_fill,
    25      in_fill->x = _cairo_fixed_from_double (x);
    26      in_fill->y = _cairo_fixed_from_double (y);
    27 +    in_fill->on_edge = FALSE;
    29      in_fill->has_current_point = FALSE;
    30      in_fill->current_point.x = 0;
    31 @@ -103,6 +105,9 @@ _cairo_in_fill_add_edge (cairo_in_fill_t *in_fill,
    32  {
    33      int dir;
    35 +    if (in_fill->on_edge)
    36 +	return;
    37 +
    38      /* count the number of edge crossing to -∞ */
    40      dir = 1;
    41 @@ -116,6 +121,18 @@ _cairo_in_fill_add_edge (cairo_in_fill_t *in_fill,
    42  	dir = -1;
    43      }
    45 +    /* First check whether the query is on an edge */
    46 +    if ((p1->x == in_fill->x && p1->x == in_fill->y) ||
    47 +	(p2->x == in_fill->x && p2->x == in_fill->y) ||
    48 +	(! (p2->y < in_fill->y || p1->y > in_fill->y) &&
    49 +	 ! (p1->x > in_fill->x && p2->x > in_fill->x) &&
    50 +	 ! (p1->x < in_fill->x && p2->x < in_fill->x) &&
    51 +	 edge_compare_for_y_against_x (p1, p2, in_fill->y, in_fill->x) == 0))
    52 +    {
    53 +	in_fill->on_edge = TRUE;
    54 +	return;
    55 +    }
    56 +
    57      /* edge is entirely above or below, note the shortening rule */
    58      if (p2->y <= in_fill->y || p1->y > in_fill->y)
    59  	return;
    60 @@ -246,7 +263,9 @@ _cairo_path_fixed_in_fill (cairo_path_fixed_t	*path,
    62      _cairo_in_fill_close_path (&in_fill);
    64 -    switch (fill_rule) {
    65 +    if (in_fill.on_edge) {
    66 +	*is_inside = TRUE;
    67 +    } else switch (fill_rule) {
    68      case CAIRO_FILL_RULE_EVEN_ODD:
    69  	*is_inside = in_fill.winding & 1;
    70  	break;

mercurial