summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/compositing/squashing/squash-above-fixed-1.html
blob: 2dab9f580d43b6534bdae6e60315b83ffc91c96d (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<!DOCTYPE html>
<html>
<head>
<script src="../../resources/run-after-layout-and-paint.js"></script>
<style>
.composited {
  transform: translatez(0);
}

.background {
  position: fixed;
  background-color: lightgray;
  width: 300px;
  height: 300px;
  top: 150px;
  left: 100px;
}

.cyan {
  background-color: cyan;
}

.lime {
  background-color: lime;
}

.overlapping {
  position: relative;
  z-index: 1;
  width: 200px;
  height: 100px;
}

#description {
  position: absolute;
  top: 100px;
  left: 450px;
  width: 300px;
}

#testResults {
  display: none;
}

body {
  margin: 0px;
}
</style>

<script>
    if (window.testRunner) {
        testRunner.waitUntilDone();
        testRunner.dumpAsText();
    }

    if (window.internals)
        internals.settings.setPreferCompositingToLCDTextEnabled(true);

    function runTest()
    {
        if (!window.internals)
            return;

        (function() {

          return new Promise(function(resolve) {
              // Case 1
              document.getElementById('Case1').textContent = window.internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_REPAINT_RECTS);

              resolve();
          });

        })().then(function() {

            return new Promise(function(resolve) {

                // Case 2
                window.internals.startTrackingRepaints(document);
                window.scrollTo(0, 80);
                runAfterLayoutAndPaint(function() {
                    document.getElementById('Case2').textContent = window.internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_REPAINT_RECTS);
                    window.internals.stopTrackingRepaints(document);

                    resolve();
                });

          });

        }).then(function() {

            return new Promise(function(resolve) {

                // Case 3
                window.internals.startTrackingRepaints(document);
                window.scrollTo(0, 120);
                runAfterLayoutAndPaint(function() {
                    document.getElementById('Case3').textContent = window.internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_REPAINT_RECTS);
                    window.internals.stopTrackingRepaints(document);

                    resolve();
                });

            });

        }).then(function() {

            return new Promise(function(resolve) {

                // Case 4
                window.internals.startTrackingRepaints(document);
                window.scrollTo(0, 170);
                runAfterLayoutAndPaint(function() {
                    document.getElementById('Case4').textContent = window.internals.layerTreeAsText(document, internals.LAYER_TREE_INCLUDES_REPAINT_RECTS);
                    window.internals.stopTrackingRepaints(document);

                    resolve();
                });

            });

        }).then(function() {

          // Display the test results only after test is done so that it does not affect repaint rect results.
          document.getElementById('testResults').style.display = "block";

          if (window.testRunner)
              testRunner.notifyDone();

        }).catch(function(e) {

          console.error(e);
          
        });
    }
</script>
</head>

<body onload="runTest()">

  <div id="description">
    <p>The gray div is a composited fixed-position element, and the cyan/lime
    elements should be squashed together on top. When scrolling, paragraphs may
    pop in-and-out of the squashing layer when they change overlapping status
    with respect to the composited layer underneath.</p>
  
    <p>This scenario tests (1) that content repaints correctly as layers pop in
    and out of squashing, and (2) that the positioning of the squashing layer
    remains correct (i.e. scrolls properly) when the squashing layer is on top
    of a fixed-position composited layer.</p>
  </div>

  <div class="composited background"> </div>

  <div id="paragraph-a" class="overlapping cyan"></div>
  <div id="paragraph-b" class="overlapping lime"></div>
  <div id="paragraph-c" class="overlapping cyan"></div>
  <div id="paragraph-d" class="overlapping lime"></div>
  <div id="paragraph-e" class="overlapping cyan"></div>
  <div id="paragraph-f" class="overlapping lime"></div>
  <div id="paragraph-g" class="overlapping cyan"></div>
  <div id="paragraph-h" class="overlapping lime"></div>
  <div id="paragraph-i" class="overlapping cyan"></div>
  <div id="paragraph-j" class="overlapping lime"></div>
  <div id="paragraph-k" class="overlapping cyan"></div>
  <div id="paragraph-l" class="overlapping lime"></div>
  <div id="paragraph-m" class="overlapping cyan"></div>
  <div id="paragraph-n" class="overlapping lime"></div>

  <div id="testResults">
    CASE 1, original layer tree:
    <pre id="Case1"></pre>

    CASE 2, scrolling y to 80, new layers will be squashed, so things repaint:
    <pre id="Case2"></pre>

    CASE 3, scrolling y to 120, no repaints expected:
    <pre id="Case3"></pre>

    CASE 4, scrolling y to 170 new layers will be squashed, so things repaint:
    <pre id="Case4"></pre>
  </div>

</body>

</html>