summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/scrollingcoordinator/resources/non-fast-scrollable-region-testing.js
blob: 51500d2f7478cfb76e2bcbde6e613db83b69e1c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// setMockScrollbarsEnabled doesn't actually invalidate scrollbars
// so if we don't set it immediately, they won't repaint/relayout
// correctly!  http://crbug.com/365509
if (window.internals)
    window.internals.settings.setMockScrollbarsEnabled(true);

// Draws green overlays for non-fast scrollable regions. This provides a visual
// feedback that is useful when running the test interactively.
function drawNonFastScrollableRegionOverlays() {
    var overlay = document.createElement("div");
    overlay.style.position = "absolute";
    overlay.style.left = 0;
    overlay.style.top = 0;
    overlay.style.opacity = 0.5;

    var rects = window.internals.nonFastScrollableRects(document);
    for (var i = 0; i < rects.length; i++) {
        var rect = rects[i];
        var patch = document.createElement("div");
        patch.style.position = "absolute";
        patch.style.backgroundColor = "#00ff00";
        patch.style.left = rect.left + "px";
        patch.style.top = rect.top  + "px";
        patch.style.width = rect.width + "px";
        patch.style.height = rect.height + "px";

        overlay.appendChild(patch);
    }

    document.body.appendChild(overlay);
}

function rectToString(rect) {
    return '[' + [rect.left, rect.top, rect.width, rect.height].join(', ') + ']';
}