Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(183)

Unified Diff: third_party/WebKit/LayoutTests/svg/canvas/canvas-default-object-sizing.html

Issue 1767633002: Support canvas size as default object size (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pass-default-object-size
Patch Set: Save image size on stack Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/svg/canvas/canvas-default-object-sizing-expected.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/svg/canvas/canvas-default-object-sizing.html
diff --git a/third_party/WebKit/LayoutTests/svg/canvas/canvas-default-object-sizing.html b/third_party/WebKit/LayoutTests/svg/canvas/canvas-default-object-sizing.html
new file mode 100644
index 0000000000000000000000000000000000000000..b15fda2f0a3015791f9c396b7b700c0f13465a27
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/svg/canvas/canvas-default-object-sizing.html
@@ -0,0 +1,99 @@
+<!DOCTYPE html>
+<title>Sizing SVG image when drawn to canvas</title>
+<script>
+function createCanvasWithImage(imgSrc, drawFunc)
+{
+ var canvas = document.createElement('canvas');
+ canvas.width = 100;
+ canvas.height = 100;
+ var img = document.createElement('img');
+ img.src = imgSrc;
+ img.onload = function() {
+ drawFunc(canvas.getContext('2d'), img);
+ document.documentElement.removeChild(img);
+ }
+ document.documentElement.appendChild(img);
+ document.documentElement.appendChild(canvas);
+}
+
+createCanvasWithImage(
+ 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10"><circle cx="5" cy="5" r="5" fill="blue"/></svg>',
+ function(ctx, img) {
+ ctx.drawImage(img, 0, 0);
+ });
+
+createCanvasWithImage(
+ 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 10"><circle cx="10" cy="5" r="5" fill="blue"/></svg>',
+ function(ctx, img) {
+ ctx.drawImage(img, 0, 0);
+ });
+
+createCanvasWithImage(
+ 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 20"><circle cx="5" cy="10" r="5" fill="blue"/></svg>',
+ function(ctx, img) {
+ ctx.drawImage(img, 0, 0);
+ });
+
+createCanvasWithImage(
+ 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 10"><circle cx="10" cy="5" r="5" fill="blue"/></svg>',
+ function(ctx, img) {
+ ctx.drawImage(img, 0, 0, 100, 100);
+ });
+
+createCanvasWithImage(
+ 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 20"><circle cx="5" cy="10" r="5" fill="blue"/></svg>',
+ function(ctx, img) {
+ ctx.drawImage(img, 0, 0, 100, 100);
+ });
+
+createCanvasWithImage(
+ 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="50" viewBox="0 0 10 20"><circle cx="5" cy="10" r="5" fill="blue"/></svg>',
+ function(ctx, img) {
+ ctx.drawImage(img, 0, 0);
+ });
+
+createCanvasWithImage(
+ 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" height="50" viewBox="0 0 20 10"><circle cx="10" cy="5" r="5" fill="blue"/></svg>',
+ function(ctx, img) {
+ ctx.drawImage(img, 0, 0);
+ });
+
+createCanvasWithImage(
+ 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="50"><circle cx="50" cy="25" r="25" fill="blue"/></svg>',
+ function(ctx, img) {
+ ctx.drawImage(img, 0, 0);
+ });
+
+createCanvasWithImage(
+ 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10"><circle cx="5" cy="5" r="5" fill="blue"/></svg>',
+ function(ctx, img) {
+ ctx.drawImage(img, 0, 0, 50, 50, 0, 0, 50, 50);
+ ctx.drawImage(img, 50, 50, 50, 50, 50, 50, 50, 50);
+ ctx.drawImage(img, 0, 50, 50, 50, 0, 50, 50, 50);
+ ctx.drawImage(img, 50, 0, 50, 50, 50, 0, 50, 50);
+ });
+
+createCanvasWithImage(
+ 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10"><circle cx="5" cy="5" r="5" fill="blue"/></svg>',
+ function(ctx, img) {
+ var pattern = ctx.createPattern(img, "repeat");
+ ctx.fillStyle = pattern;
+ ctx.fillRect(0, 0, 100, 100);
+ });
+
+createCanvasWithImage(
+ 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 10"><circle cx="10" cy="5" r="5" fill="blue"/></svg>',
+ function(ctx, img) {
+ var pattern = ctx.createPattern(img, "repeat");
+ ctx.fillStyle = pattern;
+ ctx.fillRect(0, 0, 100, 100);
+ });
+
+createCanvasWithImage(
+ 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg"><circle cx="50" cy="50" r="50" fill="blue"/></svg>',
+ function(ctx, img) {
+ var pattern = ctx.createPattern(img, "repeat");
+ ctx.fillStyle = pattern;
+ ctx.fillRect(0, 0, 100, 100);
+ });
+</script>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/svg/canvas/canvas-default-object-sizing-expected.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698