OLD | NEW |
1 // setMockScrollbarsEnabled doesn't actually invalidate scrollbars | 1 // setMockScrollbarsEnabled doesn't actually invalidate scrollbars |
2 // so if we don't set it immediately, they won't repaint/relayout | 2 // so if we don't set it immediately, they won't repaint/relayout |
3 // correctly! http://crbug.com/365509 | 3 // correctly! http://crbug.com/365509 |
4 if (window.internals) | 4 if (window.internals) |
5 window.internals.settings.setMockScrollbarsEnabled(true); | 5 window.internals.settings.setMockScrollbarsEnabled(true); |
6 | 6 |
7 function runNonFastScrollableRegionTest(scale) { | 7 // Draws green overlays for non-fast scrollable regions. This provides a visual |
8 var invScale; | 8 // feedback that is useful when running the test interactively. |
9 if (scale != undefined) { | 9 function drawNonFastScrollableRegionOverlays() { |
10 if (window.eventSender) | |
11 eventSender.setPageScaleFactor(scale, 0, 0); | |
12 // FIXME: This is a hack for applyPageScaleFactorInCompositor() == false
. | |
13 invScale = 1 / scale; | |
14 } else { | |
15 invScale = 1; | |
16 } | |
17 | |
18 var overlay = document.createElement("div"); | 10 var overlay = document.createElement("div"); |
19 overlay.style.position = "absolute"; | 11 overlay.style.position = "absolute"; |
20 overlay.style.left = 0; | 12 overlay.style.left = 0; |
21 overlay.style.top = 0; | 13 overlay.style.top = 0; |
22 overlay.style.opacity = 0.5; | 14 overlay.style.opacity = 0.5; |
23 | 15 |
24 var rects = window.internals.nonFastScrollableRects(document); | 16 var rects = window.internals.nonFastScrollableRects(document); |
25 for (var i = 0; i < rects.length; i++) { | 17 for (var i = 0; i < rects.length; i++) { |
26 var rect = rects[i]; | 18 var rect = rects[i]; |
27 var patch = document.createElement("div"); | 19 var patch = document.createElement("div"); |
28 patch.style.position = "absolute"; | 20 patch.style.position = "absolute"; |
29 patch.style.backgroundColor = "#00ff00"; | 21 patch.style.backgroundColor = "#00ff00"; |
30 patch.style.left = rect.left * invScale + "px"; | 22 patch.style.left = rect.left + "px"; |
31 patch.style.top = rect.top * invScale + "px"; | 23 patch.style.top = rect.top + "px"; |
32 patch.style.width = rect.width * invScale + "px"; | 24 patch.style.width = rect.width + "px"; |
33 patch.style.height = rect.height * invScale + "px"; | 25 patch.style.height = rect.height + "px"; |
34 | 26 |
35 overlay.appendChild(patch); | 27 overlay.appendChild(patch); |
36 } | 28 } |
37 | 29 |
38 document.body.appendChild(overlay); | 30 document.body.appendChild(overlay); |
39 } | 31 } |
40 | 32 |
| 33 // Waits for one RAF call to ensure compositing update has occurred and invokes
task. |
| 34 function awaitCompsitingUpdate(task) { |
| 35 window.requestAnimationFrame(task); |
| 36 } |
| 37 |
| 38 function rectToString(rect) { |
| 39 return '[' + [rect.left, rect.top, rect.width, rect.height].join(', ') + ']'
; |
| 40 } |
| 41 |
OLD | NEW |