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

Unified Diff: third_party/WebKit/LayoutTests/svg/as-image/resources/synthesized-viewbox-par-helper.js

Issue 2290173005: Synthesize preserveAspectRatio='none' for non-viewBoxed <img> (Closed)
Patch Set: New baselines Created 4 years, 4 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
Index: third_party/WebKit/LayoutTests/svg/as-image/resources/synthesized-viewbox-par-helper.js
diff --git a/third_party/WebKit/LayoutTests/svg/as-image/resources/synthesized-viewbox-par-helper.js b/third_party/WebKit/LayoutTests/svg/as-image/resources/synthesized-viewbox-par-helper.js
new file mode 100644
index 0000000000000000000000000000000000000000..26a4901fcd6d83c83a55124699da3d99d63e05a5
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/svg/as-image/resources/synthesized-viewbox-par-helper.js
@@ -0,0 +1,34 @@
+'use strict';
+
+function makeSvgImageUrl(width, height, viewBox, pAR) {
+ var data = '<svg xmlns="http://www.w3.org/2000/svg"';
+ data += ' width="' + width + '"';
+ data += ' height="' + height + '"'
+ if (viewBox)
+ data += ' viewBox="' + viewBox + '"';
+ if (pAR)
+ data += ' preserveAspectRatio="' + pAR + '"';
+ data += '><circle cx="100" cy="100" r="100" fill="blue"/></svg>';
+ return 'data:image/svg+xml,' + encodeURIComponent(data);
+}
+
+function makeImage(config) {
+ var img = new Image();
+ img.src = makeSvgImageUrl(config.svgWidthAttr, config.svgHeightAttr);
+ img.style.width = config.placeholderWidthAttr;
+ img.style.height = config.placeholderHeightAttr;
+ return img;
+}
+
+function makeReference(config) {
+ var testData = new TestData(config);
+ var intrinsic = testData.intrinsicInformation();
+ var rect = testData.computeInlineReplacedSize();
+ // Simplified for the case of percentages (assumes 100% in that case.)
+ var viewBox = "0 0 " + (intrinsic.width || rect.width) + " " + (intrinsic.height || rect.height);
+ var img = new Image();
+ img.src = makeSvgImageUrl(rect.width, rect.height, viewBox, "none");
+ img.style.width = rect.width;
+ img.style.height = rect.height;
+ return img;
+}

Powered by Google App Engine
This is Rietveld 408576698