Index: LayoutTests/fast/canvas/canvas-hit-regions-path2d-transform-test.html |
diff --git a/LayoutTests/fast/canvas/canvas-hit-regions-transform-test.html b/LayoutTests/fast/canvas/canvas-hit-regions-path2d-transform-test.html |
similarity index 86% |
copy from LayoutTests/fast/canvas/canvas-hit-regions-transform-test.html |
copy to LayoutTests/fast/canvas/canvas-hit-regions-path2d-transform-test.html |
index e1030aa703eee11dc3c8e6bc0b60cadf0c9db89b..3d58c597128569eabcd797b148c5b5542227071b 100644 |
--- a/LayoutTests/fast/canvas/canvas-hit-regions-transform-test.html |
+++ b/LayoutTests/fast/canvas/canvas-hit-regions-path2d-transform-test.html |
@@ -1,7 +1,7 @@ |
<!DOCTYPE html> |
<html> |
<head> |
- <title>Canvas Hit Regions: transform test</title> |
+ <title>Canvas Hit Regions: path2d with transform test</title> |
<script src="../../resources/js-test.js"></script> |
</head> |
<body> |
@@ -53,39 +53,46 @@ |
}); |
} |
- function createHitRegion(pathMethod) |
+ function createHitRegion(transformMethod, isRect) |
{ |
context.removeHitRegion("hit"); |
- context.beginPath(); |
context.save(); |
- pathMethod(); |
- context.restore(); |
+ transformMethod(); |
context.addHitRegion({ |
- id : "hit" |
+ id : "hit", |
+ path : drawSomething(isRect) |
}); |
+ context.restore(); |
} |
- function drawStar() |
+ function drawSomething(isRect) |
{ |
- context.beginPath(); |
- context.moveTo(0, -50); |
- context.lineTo(-15, -10); |
- context.lineTo(-50, -10); |
- context.lineTo(-15, 10); |
- context.lineTo(-35, 50); |
- context.lineTo(0, 20); |
- context.lineTo(35, 50); |
- context.lineTo(15, 10); |
- context.lineTo(50, -10); |
- context.lineTo(15, -10); |
- context.lineTo(0, -50); |
+ var path = new Path2D(); |
+ |
+ if (isRect) { |
+ path.rect(0, 0, 50, 50); |
+ return path; |
+ } |
+ |
+ // draw star |
+ path.moveTo(0, -50); |
+ path.lineTo(-15, -10); |
+ path.lineTo(-50, -10); |
+ path.lineTo(-15, 10); |
+ path.lineTo(-35, 50); |
+ path.lineTo(0, 20); |
+ path.lineTo(35, 50); |
+ path.lineTo(15, 10); |
+ path.lineTo(50, -10); |
+ path.lineTo(15, -10); |
+ path.lineTo(0, -50); |
+ return path; |
} |
// Rectangle with context.translate() |
createHitRegion(function() { |
context.translate(20, 20); |
- context.rect(0, 0, 50, 50); |
- }); |
+ }, true); |
clickTests("Rectangle with context.translate():", [ |
{ x : 1, y : 1, expected : null }, |
{ x : 31, y : 21, expected : "hit" }, |
@@ -97,8 +104,7 @@ |
// Rectangle with context.rotate() |
createHitRegion(function() { |
context.rotate(Math.PI * 0.25); // 45 degrees |
- context.rect(0, 0, 50, 50); |
- }); |
+ }, true); |
clickTests("Rectangle with context.rotate():", [ |
{ x : 20, y : 5, expected : null }, |
{ x : 0, y : 25, expected : "hit" }, |
@@ -109,8 +115,7 @@ |
// Rectangle with context.scale() |
createHitRegion(function() { |
context.scale(2, 2); |
- context.rect(0, 0, 50, 50); |
- }); |
+ }, true); |
clickTests("Rectangle with context.scale():", [ |
{ x : 1, y : 1, expected : "hit" }, |
{ x : 49, y : 49, expected : "hit" }, |
@@ -121,8 +126,7 @@ |
// Non rectangle (star) with context.translate() |
createHitRegion(function() { |
context.translate(50, 50); |
- drawStar(); |
- }); |
+ }, false); |
clickTests("Non rectangle (star) with context.translate():", [ |
{ x : 26, y : 23, expected : null }, |
{ x : 82, y : 65, expected : null }, |
@@ -140,8 +144,7 @@ |
createHitRegion(function() { |
context.translate(50, 50); |
context.rotate(Math.PI * 0.25); |
- drawStar(); |
- }); |
+ }, false); |
clickTests("Non rectangle (star) with context.rotate():", [ |
{ x : 26, y : 23, expected : "hit" }, |
{ x : 82, y : 65, expected : null }, |
@@ -159,8 +162,7 @@ |
createHitRegion(function() { |
context.translate(25, 25); |
context.scale(0.5, 0.5); |
- drawStar(); |
- }); |
+ }, false); |
clickTests("Non rectangle (star) with context.scale():", [ |
{ x : 28, y : 13, expected : "hit" }, |
{ x : 38, y : 24, expected : "hit" }, |