b=296904, canvas rects incorrectly affect current path; r+sr+a=vlad, patch from philip@zaynar.demon.co.uk
git-svn-id: svn://10.0.0.236/trunk@237546 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -1156,12 +1156,16 @@ nsCanvasRenderingContext2D::ClearRect(float x, float y, float w, float h)
|
||||
if (!FloatValidate(x,y,w,h))
|
||||
return NS_ERROR_DOM_SYNTAX_ERR;
|
||||
|
||||
cairo_path_t *old_path = cairo_copy_path (mCairo);
|
||||
cairo_save (mCairo);
|
||||
cairo_set_operator (mCairo, CAIRO_OPERATOR_CLEAR);
|
||||
cairo_new_path (mCairo);
|
||||
cairo_rectangle (mCairo, x, y, w, h);
|
||||
cairo_fill (mCairo);
|
||||
cairo_restore (mCairo);
|
||||
cairo_new_path (mCairo);
|
||||
cairo_append_path (mCairo, old_path);
|
||||
cairo_path_destroy (old_path);
|
||||
|
||||
return Redraw();
|
||||
}
|
||||
@@ -1172,11 +1176,15 @@ nsCanvasRenderingContext2D::FillRect(float x, float y, float w, float h)
|
||||
if (!FloatValidate(x,y,w,h))
|
||||
return NS_ERROR_DOM_SYNTAX_ERR;
|
||||
|
||||
cairo_path_t *old_path = cairo_copy_path (mCairo);
|
||||
cairo_new_path (mCairo);
|
||||
cairo_rectangle (mCairo, x, y, w, h);
|
||||
|
||||
ApplyStyle(STYLE_FILL);
|
||||
cairo_fill (mCairo);
|
||||
cairo_new_path (mCairo);
|
||||
cairo_append_path (mCairo, old_path);
|
||||
cairo_path_destroy (old_path);
|
||||
|
||||
return Redraw();
|
||||
}
|
||||
@@ -1187,11 +1195,15 @@ nsCanvasRenderingContext2D::StrokeRect(float x, float y, float w, float h)
|
||||
if (!FloatValidate(x,y,w,h))
|
||||
return NS_ERROR_DOM_SYNTAX_ERR;
|
||||
|
||||
cairo_path_t *old_path = cairo_copy_path (mCairo);
|
||||
cairo_new_path (mCairo);
|
||||
cairo_rectangle (mCairo, x, y, w, h);
|
||||
|
||||
ApplyStyle(STYLE_STROKE);
|
||||
cairo_stroke (mCairo);
|
||||
cairo_new_path (mCairo);
|
||||
cairo_append_path (mCairo, old_path);
|
||||
cairo_path_destroy (old_path);
|
||||
|
||||
return Redraw();
|
||||
}
|
||||
@@ -1868,7 +1880,8 @@ nsCanvasRenderingContext2D::DrawImage()
|
||||
|
||||
cairo_surface_t *imgSurf = nsnull;
|
||||
cairo_matrix_t surfMat;
|
||||
cairo_pattern_t* pat;
|
||||
cairo_pattern_t *pat;
|
||||
cairo_path_t *old_path;
|
||||
PRUint8 *imgData = nsnull;
|
||||
PRInt32 imgWidth, imgHeight;
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
@@ -1942,6 +1955,7 @@ nsCanvasRenderingContext2D::DrawImage()
|
||||
pat = cairo_pattern_create_for_surface(imgSurf);
|
||||
cairo_pattern_set_matrix(pat, &surfMat);
|
||||
|
||||
old_path = cairo_copy_path(mCairo);
|
||||
cairo_save(mCairo);
|
||||
cairo_translate(mCairo, dx, dy);
|
||||
cairo_new_path(mCairo);
|
||||
@@ -1966,6 +1980,10 @@ nsCanvasRenderingContext2D::DrawImage()
|
||||
|
||||
cairo_pattern_destroy(pat);
|
||||
|
||||
cairo_new_path(mCairo);
|
||||
cairo_append_path(mCairo, old_path);
|
||||
cairo_path_destroy(old_path);
|
||||
|
||||
FINISH:
|
||||
if (imgSurf)
|
||||
cairo_surface_destroy(imgSurf);
|
||||
@@ -2592,6 +2610,7 @@ nsCanvasRenderingContext2D::PutImageData()
|
||||
imgsurf = cairo_image_surface_create_for_data (imageBuffer.get(),
|
||||
CAIRO_FORMAT_ARGB32,
|
||||
w, h, w*4);
|
||||
cairo_path_t *old_path = cairo_copy_path (mCairo);
|
||||
cairo_save (mCairo);
|
||||
cairo_identity_matrix (mCairo);
|
||||
cairo_translate (mCairo, x, y);
|
||||
@@ -2601,6 +2620,9 @@ nsCanvasRenderingContext2D::PutImageData()
|
||||
cairo_set_operator (mCairo, CAIRO_OPERATOR_SOURCE);
|
||||
cairo_fill (mCairo);
|
||||
cairo_restore (mCairo);
|
||||
cairo_new_path (mCairo);
|
||||
cairo_append_path (mCairo, old_path);
|
||||
cairo_path_destroy (old_path);
|
||||
|
||||
cairo_surface_destroy (imgsurf);
|
||||
}
|
||||
|
||||
2
mozilla/layout/reftests/bugs/296904-1-ref.html
Normal file
2
mozilla/layout/reftests/bugs/296904-1-ref.html
Normal file
@@ -0,0 +1,2 @@
|
||||
<!DOCTYPE HTML>
|
||||
<canvas width="100" height="100" id="c" style="background: #0f0"></canvas>
|
||||
25
mozilla/layout/reftests/bugs/296904-1.html
Normal file
25
mozilla/layout/reftests/bugs/296904-1.html
Normal file
@@ -0,0 +1,25 @@
|
||||
<!DOCTYPE HTML>
|
||||
<canvas width="100" height="100" id="c"></canvas>
|
||||
<script>
|
||||
window.onload = function () {
|
||||
var ctx = document.getElementById('c').getContext('2d');
|
||||
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(0, 0);
|
||||
ctx.lineTo(0, 100);
|
||||
ctx.lineTo(100, 100);
|
||||
|
||||
ctx.fillStyle = '#f00';
|
||||
ctx.strokeStyle = '#00f';
|
||||
|
||||
ctx.fillRect(30, 10, 10, 10);
|
||||
ctx.strokeRect(60, 10, 10, 10);
|
||||
ctx.clearRect(25, 15, 50, 10);
|
||||
ctx.drawImage(document.getElementById('c'), 0, 0);
|
||||
if (ctx.putImageData) ctx.putImageData(ctx.getImageData(0, 0, 10, 10), 0, 0);
|
||||
|
||||
ctx.lineTo(100, 0);
|
||||
ctx.fillStyle = '#0f0';
|
||||
ctx.fill();
|
||||
}
|
||||
</script>
|
||||
@@ -109,6 +109,7 @@ fails-if(MOZ_WIDGET_TOOLKIT=="cocoa") == 28811-2a.html 28811-2-ref.html # bug 38
|
||||
== 273681-1.html 273681-1-ref.html
|
||||
== 291078-1.html 291078-1-ref.html
|
||||
== 291078-2.html 291078-2-ref.html
|
||||
== 296904-1.html 296904-1-ref.html
|
||||
== 300691-1a.html 300691-1-ref.html
|
||||
== 300691-1b.html 300691-1-ref.html
|
||||
== 300691-1c.html 300691-1-ref.html
|
||||
|
||||
Reference in New Issue
Block a user