Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <script src="../../resources/run-after-layout-and-paint.js"></script> | |
| 4 <style type="text/css"> | 3 <style type="text/css"> |
| 5 #test1 div { | 4 #test1 div { |
| 6 height: 100px; | 5 height: 100px; |
| 7 width: 100px; | 6 width: 100px; |
| 8 } | 7 } |
| 9 #test1 .parent { | 8 #test1 .parent { |
| 10 background-image: url(resources/animated.gif) | 9 background-image: url(resources/animated.gif) |
| 11 } | 10 } |
| 12 #test1 .child { | 11 #test1 .child { |
| 13 background-color: green; | 12 background-color: green; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 | 51 |
| 53 if (window.internals) { | 52 if (window.internals) { |
| 54 internals.settings.setUseDefaultImageInterpolationQuality(true); | 53 internals.settings.setUseDefaultImageInterpolationQuality(true); |
| 55 internals.runtimeFlags.slimmingPaintUnderInvalidationCheckingEnabled = t rue; | 54 internals.runtimeFlags.slimmingPaintUnderInvalidationCheckingEnabled = t rue; |
| 56 } | 55 } |
| 57 | 56 |
| 58 function finish() { | 57 function finish() { |
| 59 var layerTree = window.internals.layerTreeAsText(document, internals.LAY ER_TREE_INCLUDES_PAINT_INVALIDATIONS); | 58 var layerTree = window.internals.layerTreeAsText(document, internals.LAY ER_TREE_INCLUDES_PAINT_INVALIDATIONS); |
| 60 var invalidations = JSON.parse(layerTree).objectPaintInvalidations; | 59 var invalidations = JSON.parse(layerTree).objectPaintInvalidations; |
| 61 // Passes if there is no invalidations, | 60 // Passes if there is no invalidations, |
| 62 // or only invalidations because of background obscuration change. | 61 // or only invalidations because of background obscuration change. |
| 63 // This is because before the delayed image decoder finishes decodin g the image, | 62 // This is because before the delayed image decoder finishes decoding th e image, |
| 64 // we first assume the image is not opaque. If the image is found ac tually opaque | 63 // we first assume the image is not opaque. If the image is found actual ly opaque |
| 65 // after decoding, the background obscuration status of covered elem ents will | 64 // after decoding, the background obscuration status of covered elements will |
| 66 // change and cause paint invalidation. | 65 // change and cause paint invalidation. |
| 67 var invalidatedObjects = {}; | 66 var invalidatedObjects = {}; |
| 68 for (var i = 0; i < invalidations.length; ++i) { | 67 if (invalidations) { |
|
chrishtr
2016/08/11 17:33:44
Why would |invalidations| sometimes be false in a
Xianzhu
2016/08/11 18:10:07
It will be undefined if there is no invalidations.
| |
| 69 var object = invalidations[i].object; | 68 for (var i = 0; i < invalidations.length; ++i) { |
| 70 // Paint invalidation of target3 and target4 depends on opaqueness o f the foreground image (apple.jpg). | 69 var object = invalidations[i].object; |
| 71 // Because of delayed image decoding, we may get actual opaqueness o f the image after the test is started. | 70 if ((object.indexOf('target3') != -1 || object.indexOf('target4' ) != -1) && invalidations[i].reason == 'background obscuration change') |
| 72 // Omit paint invalidations so far if we see 'background obscuration change' for these targets. | 71 continue; |
| 73 if ((object.indexOf('target3') != -1 || object.indexOf('target4') != -1) && invalidations[i].reason == 'background obscuration change') | |
| 74 delete invalidatedObjects[object]; | |
| 75 else | |
| 76 invalidatedObjects[object] = true; | 72 invalidatedObjects[object] = true; |
| 73 } | |
| 77 } | 74 } |
| 78 | 75 |
| 79 if (Object.keys(invalidatedObjects).length) | 76 if (Object.keys(invalidatedObjects).length) |
| 80 output.textContent = 'FAIL: Unexpected paint invalidations: ' + JSON .stringify(invalidatedObjects) + '\n' + layerTree; | 77 output.textContent = 'FAIL: Unexpected paint invalidations: ' + JSON .stringify(invalidatedObjects) + '\n' + layerTree; |
| 81 else | 78 else |
| 82 output.textContent = 'PASS'; | 79 output.textContent = 'PASS'; |
| 83 testRunner.notifyDone(); | 80 testRunner.notifyDone(); |
| 84 } | 81 } |
| 85 | 82 |
| 86 function start() { | 83 function start() { |
| 87 if (!window.testRunner || !window.internals) | 84 if (!window.testRunner || !window.internals) |
| 88 return; | 85 return; |
| 89 | 86 |
| 90 runAfterLayoutAndPaint(function() { | 87 // Ensure the deferred decoder has decoded resources/apple.jpg. |
| 88 testRunner.capturePixelsAsyncThen(function() { | |
| 91 internals.startTrackingRepaints(document); | 89 internals.startTrackingRepaints(document); |
| 92 // Wait a while to let the animated gif advance frames. | 90 // Wait a while to let the animated gif advance frames. |
| 93 setTimeout(finish, 300); | 91 setTimeout(finish, 300); |
|
chrishtr
2016/08/11 17:33:44
Use internals.advanceTimeForImage for this.
Xianzhu
2016/08/11 18:10:07
Tried it in the latest patch set, and modified cod
Xianzhu
2016/08/11 18:16:25
Never mind. I can reproduce the bug with internal.
| |
| 94 }); | 92 }); |
| 95 } | 93 } |
| 96 | 94 |
| 97 </script> | 95 </script> |
| 98 </head> | 96 </head> |
| 99 <body onload="start()"> | 97 <body onload="start()"> |
| 100 <div id="test1"> | 98 <div id="test1"> |
| 101 <div id="target1" class="parent"> | 99 <div id="target1" class="parent"> |
| 102 <div class="child"> | 100 <div class="child"> |
| 103 </div> | 101 </div> |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 118 <div></div> | 116 <div></div> |
| 119 <div> | 117 <div> |
| 120 <img src="resources/apple.jpg"> | 118 <img src="resources/apple.jpg"> |
| 121 </div> | 119 </div> |
| 122 </a> | 120 </a> |
| 123 </div> | 121 </div> |
| 124 </div> | 122 </div> |
| 125 <pre id="output"></pre> | 123 <pre id="output"></pre> |
| 126 </body> | 124 </body> |
| 127 </html> | 125 </html> |
| OLD | NEW |