1209603-1.html (1457B)
1 <!DOCTYPE HTML> 2 <title>Testcase, bug 1209603</title> 3 <style> 4 5 p { 6 font-size: 2em; 7 8 /* ensure font-size dependency in the margin struct; this is also in 9 the UA style sheet, but repeated here for clarity */ 10 margin: 1em 0; 11 } 12 13 </style> 14 15 <div style="font-size: 20px"><p id="a">Should be 40px font size.</p></div> 16 17 <script> 18 19 var a = document.getElementById("a"); 20 21 // force computation of the margin struct on A (caching in rule tree) 22 getComputedStyle(a, "").marginTop; 23 24 </script> 25 26 <!-- will dynamically change font-size to 10px later; 27 also needs to be different from 20px now to avoid sibling-sharing --> 28 <div style="font-size: 30px"><p id="b">Should be 20px font size.</p></div> 29 30 <script> 31 // Note that A and B share rule nodes, and note that the margin struct 32 // has been conditionally (on font size) cached on their shared rule node. 33 var b = document.getElementById("b"); 34 35 // force ComputedStyle construction and computation of the font struct on 36 // B's parent 37 getComputedStyle(b.parentNode, "").fontSize; 38 39 // force ComputedStyle construction (and computation of the color 40 // struct) on B, but not the margin struct or font struct 41 getComputedStyle(b, "").color; 42 43 // restyle B and flush 44 b.parentNode.style.fontSize = "10px"; 45 getComputedStyle(b, "").marginTop; 46 // This flush will call CalcStyleDifference on B, which will find no 47 // cached font struct on the old context, but which will find a 48 // cached margin struct on the rule node. 49 50 </script>