summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/compositing/squashing/do-not-squash-scroll-child-with-composited-descendants.html
blob: 50a32863d4fe382792e2df99769a943473e163bb (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
<!DOCTYPE HTML>
<style>
#scroller {
  width: 200px;
  height: 200px;
  border: 1px solid black;
  overflow: scroll;
}

.scrolled {
  width: 100px;
  height: 100px;
  background: papayawhip;
  border: 1px solid black;
  margin: 10px;
  position: relative;
}

#fixed {
  width: 80px;
  height: 80px;
  background: blue;
  will-change: transform;
  position: fixed;
  top: 0px;
  left: 0px;
}

#composited {
  width: 20px;
  height: 20px;
  background: green;
  position: relative;
  will-change: transform;
}

#unsquashed {
  z-index: 1;
}
</style>
<div id="scroller">
  <div id="fixed"></div>
  <div class="scrolled"></div>
  <div class="scrolled"></div>
  <div id="unsquashed" class="scrolled">
    <div id="composited"></div>
  </div>
</div>

<script src='../../resources/js-test.js'></script>


<script>
description('Verifies that scroll children with composited descendants' +
            ' do not squash.');

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

function scrollChildDoesNotSquash(layer) {
  if (layer.children) {
    for (var i = 0; i < layer.children.length; i++) {
      var child = layer.children[i];
      if (child.bounds && layer.bounds &&
          child.bounds[0] == 20 && child.bounds[1] == 20 &&
          layer.bounds[0] == 102 && layer.bounds[1] == 102) {
        // If the child's bounds are 20x20, we're the scroll child with the
        // composited descendant. We should not have squashed and therefore our
        // bounds should remain 102x102 (100x100 plus the 1px border).
        return true;
      }

      if (scrollChildDoesNotSquash(child))
        return true;
    }
  }
  return false;
}

onload = function() {
  if (!window.internals)
    return;
  documentLayerTree = JSON.parse(window.internals.layerTreeAsText(document));
  shouldBe('scrollChildDoesNotSquash(documentLayerTree)', 'true');
};

</script>