OLD | NEW |
(Empty) | |
| 1 'use strict'; |
| 2 |
| 3 function makeSvgImageUrl(width, height, viewBox, pAR) { |
| 4 var data = '<svg xmlns="http://www.w3.org/2000/svg"'; |
| 5 data += ' width="' + width + '"'; |
| 6 data += ' height="' + height + '"' |
| 7 if (viewBox) |
| 8 data += ' viewBox="' + viewBox + '"'; |
| 9 if (pAR) |
| 10 data += ' preserveAspectRatio="' + pAR + '"'; |
| 11 data += '><circle cx="100" cy="100" r="100" fill="blue"/></svg>'; |
| 12 return 'data:image/svg+xml,' + encodeURIComponent(data); |
| 13 } |
| 14 |
| 15 function makeImage(config) { |
| 16 var img = new Image(); |
| 17 img.src = makeSvgImageUrl(config.svgWidthAttr, config.svgHeightAttr); |
| 18 img.style.width = config.placeholderWidthAttr; |
| 19 img.style.height = config.placeholderHeightAttr; |
| 20 return img; |
| 21 } |
| 22 |
| 23 function makeReference(config) { |
| 24 var testData = new TestData(config); |
| 25 var intrinsic = testData.intrinsicInformation(); |
| 26 var rect = testData.computeInlineReplacedSize(); |
| 27 // Simplified for the case of percentages (assumes 100% in that case.) |
| 28 var viewBox = "0 0 " + (intrinsic.width || rect.width) + " " + (intrinsic.heig
ht || rect.height); |
| 29 var img = new Image(); |
| 30 img.src = makeSvgImageUrl(rect.width, rect.height, viewBox, "none"); |
| 31 img.style.width = rect.width; |
| 32 img.style.height = rect.height; |
| 33 return img; |
| 34 } |
OLD | NEW |