gfx/cairo/cairo-clamp-boundary.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.

michael@0 1 # HG changeset patch
michael@0 2 # User Milan Sreckovic <msreckovic@mozilla.com>
michael@0 3 # Date 1362078121 18000
michael@0 4 # Node ID e9e6d97b153d8ec17ee03bb1deef1dec24c7a17c
michael@0 5 # Parent c65d59d33aa86b7e75bc420ea3beda6201e0aceb
michael@0 6 Bug 825721: clamp negative box starts and disallow negative sizes. r=jmuizelaar
michael@0 7
michael@0 8 diff --git a/gfx/cairo/cairo/src/cairo-image-surface.c b/gfx/cairo/cairo/src/cairo-image-surface.c
michael@0 9 --- a/gfx/cairo/cairo/src/cairo-image-surface.c
michael@0 10 +++ b/gfx/cairo/cairo/src/cairo-image-surface.c
michael@0 11 @@ -1846,16 +1846,20 @@ static cairo_status_t
michael@0 12 if (likely (status == CAIRO_STATUS_SUCCESS)) {
michael@0 13 for (chunk = &clear.chunks; chunk != NULL; chunk = chunk->next) {
michael@0 14 for (i = 0; i < chunk->count; i++) {
michael@0 15 int x1 = _cairo_fixed_integer_part (chunk->base[i].p1.x);
michael@0 16 int y1 = _cairo_fixed_integer_part (chunk->base[i].p1.y);
michael@0 17 int x2 = _cairo_fixed_integer_part (chunk->base[i].p2.x);
michael@0 18 int y2 = _cairo_fixed_integer_part (chunk->base[i].p2.y);
michael@0 19
michael@0 20 + x1 = (x1 < 0 ? 0 : x1);
michael@0 21 + y1 = (y1 < 0 ? 0 : y1);
michael@0 22 + if (x2 <= x1 || y2 <= y1)
michael@0 23 + continue;
michael@0 24 pixman_fill ((uint32_t *) dst->data, dst->stride / sizeof (uint32_t),
michael@0 25 PIXMAN_FORMAT_BPP (dst->pixman_format),
michael@0 26 x1, y1, x2 - x1, y2 - y1,
michael@0 27 0);
michael@0 28 }
michael@0 29 }
michael@0 30 }
michael@0 31
michael@0 32 @@ -2669,16 +2673,18 @@ static cairo_status_t
michael@0 33 const cairo_box_t *box = chunk->base;
michael@0 34
michael@0 35 for (i = 0; i < chunk->count; i++) {
michael@0 36 int x1 = _cairo_fixed_integer_ceil (box[i].p1.x);
michael@0 37 int y1 = _cairo_fixed_integer_ceil (box[i].p1.y);
michael@0 38 int x2 = _cairo_fixed_integer_floor (box[i].p2.x);
michael@0 39 int y2 = _cairo_fixed_integer_floor (box[i].p2.y);
michael@0 40
michael@0 41 + x1 = (x1 < 0 ? 0 : x1);
michael@0 42 + y1 = (y1 < 0 ? 0 : y1);
michael@0 43 if (x2 > x1 && y2 > y1) {
michael@0 44 cairo_box_t b;
michael@0 45
michael@0 46 pixman_fill ((uint32_t *) dst->data,
michael@0 47 dst->stride / sizeof (uint32_t),
michael@0 48 PIXMAN_FORMAT_BPP (dst->pixman_format),
michael@0 49 x1, y1, x2 - x1, y2 - y1,
michael@0 50 pixel);
michael@0 51 @@ -2929,17 +2935,19 @@ static cairo_status_t
michael@0 52 cairo_box_t *box = chunk->base;
michael@0 53
michael@0 54 for (i = 0; i < chunk->count; i++) {
michael@0 55 int x1 = _cairo_fixed_integer_round_down (box[i].p1.x);
michael@0 56 int y1 = _cairo_fixed_integer_round_down (box[i].p1.y);
michael@0 57 int x2 = _cairo_fixed_integer_round_down (box[i].p2.x);
michael@0 58 int y2 = _cairo_fixed_integer_round_down (box[i].p2.y);
michael@0 59
michael@0 60 - if (x2 == x1 || y2 == y1)
michael@0 61 + x1 = (x1 < 0 ? 0 : x1);
michael@0 62 + y1 = (y1 < 0 ? 0 : y1);
michael@0 63 + if (x2 <= x1 || y2 <= y1)
michael@0 64 continue;
michael@0 65
michael@0 66 pixman_fill ((uint32_t *) dst->data, dst->stride / sizeof (uint32_t),
michael@0 67 PIXMAN_FORMAT_BPP (dst->pixman_format),
michael@0 68 x1, y1, x2 - x1, y2 - y1,
michael@0 69 pixel);
michael@0 70 }
michael@0 71 }

mercurial