img-novb-height-all-1-ref.html (1913B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <link rel="stylesheet" type="text/css" href="svg-image-util.css" /> 5 <script src="svg-image-util.js"></script> 6 </head> 7 <body style="width: 600px"><!-- width for pct vals to resolve against --> 8 <script> 9 var svgParams = { 10 viewBox: null, // This gets set on a case-by-case basis below. 11 width : "10%", 12 height : "30px", 13 meetOrSlice: null // This means "use pAR=none" 14 }; 15 16 // Descriptions below describe the behavior of the rows of <img> elements 17 // in the corresponding test cases, which we mimic with specially-crafted 18 // <embed> elements. 19 20 // * FIRST TWO ROWS: <img> has width=auto height=auto 21 // - Each <img> renders w/ width = 300px (default) 22 // - Synthesized viewBox has width = 10% * viewport_width = .1*300 = 30 23 // - <img> & viewBox both get height=30px, from <svg> height attr 24 svgParams.viewBox = [0, 0, 30, 30], 25 appendSVGSubArrayWithParams(svgParams, "embed", "300px", "30px"); 26 27 // * SECOND TWO ROWS: <img> has width=auto, height=20px 28 // Calculations are as above, except <img> now imposes height="20px". 29 appendSVGSubArrayWithParams(svgParams, "embed", "300px", "20px"); 30 31 // * THIRD TWO ROWS: <img> has width=30px height=auto 32 // - <img> now renders w/ width = 30px (imposed by <img> width attr) 33 // - Synthesized viewBox has width = 10% * viewport_width = .1*30 = 3 34 // - <img> & viewBox both get height=30px, from <svg> height attr 35 svgParams.viewBox = [0, 0, 3, 30]; 36 appendSVGSubArrayWithParams(svgParams, "embed", "30px", "30px"); 37 38 // * FOURTH TWO ROWS: <img> has width=30px height=20px 39 // Calculations are as above, except <img> now imposes height="20px". 40 appendSVGSubArrayWithParams(svgParams, "embed", "30px", "20px"); 41 42 </script> 43 <!-- Body gets populated by script --> 44 </body> 45 </html>