Bug 475092. Fix incorrect positioning on Windows when glyph run includes vertically-offset glyphs is drawn to canvas. r=vlad
☠☠ backed out by f6d6fcef81fc ☠ ☠
authorJonathan Kew <jfkthame@gmail.com>
Wed, 28 Jan 2009 22:41:34 +1300
changeset 24334 360b4a2d0aa8fa46670fd304276cfab140bbdabf
parent 24333 a6690fa2baba68d4accbbc3a36779c7dc145c398
child 24335 42b8e2c66c5b8ac67baa3cb7e1654292d2d38b7f
child 24338 f6d6fcef81fc1c7cfa438d5901f94820130db960
push idunknown
push userunknown
push dateunknown
reviewersvlad
bugs475092
milestone1.9.2a1pre
Bug 475092. Fix incorrect positioning on Windows when glyph run includes vertically-offset glyphs is drawn to canvas. r=vlad
gfx/cairo/README
gfx/cairo/cairo/src/cairo-win32-font.c
gfx/cairo/win32-canvas-glyph-position.patch
layout/reftests/bidi/475092-glyph-vertical-delta-ref.xhtml
layout/reftests/bidi/475092-glyph-vertical-delta.xhtml
layout/reftests/bidi/reftest.list
--- a/gfx/cairo/README
+++ b/gfx/cairo/README
@@ -39,15 +39,17 @@ wince-fixes.patch: stubs out win32 funct
 ft-done-face.patch: bug 467874; only destroy FT_Faces created by cairo
 
 wince-fontconfig.patch: bug 462908; fixes required to compile for windows ce.  Also allows for building without fontconfig
 
 glyph-safety-margin.patch: Change the glyph dropping safety margin from 2em to 10em for bug 460023.  Upstream commit: 28a72648ba7abe02ebd4df7234424e333b85dc9c.
 
 win32-vertically-offset-glyph.patch: bug 454098; vertical positioning errors when drawing glyph runs including delta-y offsets on screen via GDI
 
+win32-canvas-glyph-position.patch: bug 475092; horizontal positioning errors when drawing glyph runs with delta-y offsets to canvas through win32-font
+
 ==== pixman patches ====
 
 endian.patch: include cairo-platform.h for endian macros
 
 ==== disable printing patch ====
 
 disable-printing.patch:  allows us to use NS_PRINTING to disable printing.
--- a/gfx/cairo/cairo/src/cairo-win32-font.c
+++ b/gfx/cairo/cairo/src/cairo-win32-font.c
@@ -1182,22 +1182,22 @@ static cairo_status_t
     if (state->glyphs.num_elements > 0) {
 	int dx;
 
 	if (logical_y != state->last_y) {
 	    status = _flush_glyphs (state);
 	    if (status)
 		return status;
 	    state->start_x = logical_x;
+	} else {
+	    dx = logical_x - state->last_x;
+	    status = _cairo_array_append (&state->dx, &dx);
+	    if (status)
+		return status;
 	}
-
-	dx = logical_x - state->last_x;
-	status = _cairo_array_append (&state->dx, &dx);
-	if (status)
-	    return status;
     } else {
 	state->start_x = logical_x;
     }
 
     state->last_x = logical_x;
     state->last_y = logical_y;
 
     status = _cairo_array_append (&state->glyphs, &glyph_index);
new file mode 100644
--- /dev/null
+++ b/gfx/cairo/win32-canvas-glyph-position.patch
@@ -0,0 +1,31 @@
+diff --git a/gfx/cairo/cairo/src/cairo-win32-font.c b/gfx/cairo/cairo/src/cairo-win32-font.c
+--- a/gfx/cairo/cairo/src/cairo-win32-font.c
++++ b/gfx/cairo/cairo/src/cairo-win32-font.c
+@@ -1182,22 +1182,22 @@ _add_glyph (cairo_glyph_state_t *state,
+     if (state->glyphs.num_elements > 0) {
+ 	int dx;
+ 
+ 	if (logical_y != state->last_y) {
+ 	    status = _flush_glyphs (state);
+ 	    if (status)
+ 		return status;
+ 	    state->start_x = logical_x;
++	} else {
++	    dx = logical_x - state->last_x;
++	    status = _cairo_array_append (&state->dx, &dx);
++	    if (status)
++		return status;
+ 	}
+-
+-	dx = logical_x - state->last_x;
+-	status = _cairo_array_append (&state->dx, &dx);
+-	if (status)
+-	    return status;
+     } else {
+ 	state->start_x = logical_x;
+     }
+ 
+     state->last_x = logical_x;
+     state->last_y = logical_y;
+ 
+     status = _cairo_array_append (&state->glyphs, &glyph_index);
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bidi/475092-glyph-vertical-delta-ref.xhtml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg"
+     xmlns:xlink="http://www.w3.org/1999/xlink"
+     version="1.1">
+  <!-- use an empty g to force filters.svg to load before onload -->
+  <use xlink:href="../filters.svg#empty"/>
+  <foreignObject filter="url(../filters.svg#NonWhiteToBlack)"
+                 x="0" y="0" height="100%" width="100%">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<!-- reftest for bug 475092 (see also bug 454098):
+     depends on Windows Vista version of Times New Roman
+     (should always be available on Vista machines) -->
+  <head>
+    <style type="text/css">
+      html, body { margin: 0; background: white; color: black; height: 100%; width: 100%; }
+      p {
+        font-size: 50px;
+        line-height: 80px;
+        border: 1px solid black;
+        min-width: 1px;
+        margin: 10px 0;
+        font-family: Times New Roman;
+      }
+    </style>
+  </head>
+  <body>
+    <p>
+      x<span style="color: red;">o&#x0301;&#x0327;</span>x</p>
+    <p style="direction: rtl; unicode-bidi: bidi-override;">
+      x<span style="color: red;">o&#x0301;&#x0327;</span>x</p>
+  </body>
+</html>
+</foreignObject>
+</svg>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bidi/475092-glyph-vertical-delta.xhtml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg"
+     xmlns:xlink="http://www.w3.org/1999/xlink"
+     version="1.1">
+  <!-- use an empty g to force filters.svg to load before onload -->
+  <use xlink:href="../filters.svg#empty"/>
+  <foreignObject filter="url(../filters.svg#NonWhiteToBlack)"
+                 x="0" y="0" height="100%" width="100%">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<!-- reftest for bug 475092 (see also bug 454098):
+     depends on Windows Vista version of Times New Roman
+     (should always be available on Vista machines) -->
+  <head>
+    <style type="text/css">
+      html, body { margin: 0; background: white; color: black; height: 100%; width: 100%; }
+      p {
+        font-size: 50px;
+        line-height: 80px;
+        border: 1px solid black;
+        min-width: 1px;
+        margin: 10px 0;
+        font-family: Times New Roman;
+      }
+    </style>
+  </head>
+  <body>
+    <p>
+      x<span style="color: red;">o&#x0327;&#x0301;</span>x</p>
+    <p style="direction: rtl; unicode-bidi: bidi-override;">
+      x<span style="color: red;">o&#x0327;&#x0301;</span>x</p>
+	  <!-- bug 475092 causes the accented "o" here to appear horizontally shifted
+           on the canvas; bug 454098 causes it to appear vertically shifted on the
+           Windows screen, but we can't directly reftest that because the reftest
+           image is captured via the canvas codepath instead. -->
+  </body>
+</html>
+</foreignObject>
+</svg>
--- a/layout/reftests/bidi/reftest.list
+++ b/layout/reftests/bidi/reftest.list
@@ -20,8 +20,9 @@ random-if(MOZ_WIDGET_TOOLKIT=="gtk2") ==
 random-if(MOZ_WIDGET_TOOLKIT=="gtk2") == 386339.html 386339-ref.html
 == 409375.html 409375-ref.html
 == 413542-1.html 413542-1-ref.html
 == 413542-2.html 413542-2-ref.html
 == 413928-1.html 413928-1-ref.html
 == 413928-2.html 413928-2-ref.html
 == 425338-1a.html 425338-1-ref.html
 == 425338-1b.html 425338-1-ref.html
+HTTP(..) == 475092-glyph-vertical-delta.xhtml 475092-glyph-vertical-delta-ref.xhtml