summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/compositing/geometry/layer-due-to-layer-children-deep-switch.html
blob: cd525018cde92bc12e68ccd35e26bd6bbc42be2e (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
<!DOCTYPE html>

<html>
<head>
  <style type="text/css" media="screen">
    body {
      position: relative;
    }
    #parent {
      position: relative;
      width: 300px;
      height: 250px;
      padding: 20px;
      border: 1px solid black;
      -webkit-transform: translate(0px, 0px);
    }
    
    #child {
      position: relative;
      left: 10px;
      width: 250px;
      height: 220px;
      background-color: blue;
      -webkit-transform: translate(0px, 0px);
    }
    
   #grandchild {
      position: relative;
      top: 10px;
      left: 10px;
      width: 200px;
      height: 200px;
      background-color: yellow;
      -webkit-transform: rotate(30deg);
    }
    
   #greatgrandchild {
      position: relative;
      left: 100px;
      width: 250px;
      height: 100px;
      background-color: green;
    }
    
  </style>
  <script type="text/javascript" charset="utf-8">
    if (window.testRunner) {
        testRunner.dumpAsText();
        testRunner.waitUntilDone();
    }
    
    var text = "";
    function showTree(which)
    {
        setTimeout(function() {
            if (window.testRunner) {
                text += "\n" + which + " dump layer tree:\n";
                text += window.internals.layerTreeAsText(document);
                document.getElementById('layers').innerText = text;
            }
        }, 0);
    }

    function doTest()
    {
        if (window.testRunner)
            //document.getElementById('layers').innerText = "";
        showTree("First");

        //Put child in compositing mode
        setTimeout(function() {
            document.getElementById("greatgrandchild").style.webkitTransform = "perspective(400)  translate3D(-30px, 30px, 100px) rotateY(60deg)";
            showTree("Second");
            
            // Take it back out of compositing mode
            setTimeout(function() {
                document.getElementById("greatgrandchild").style.webkitTransform = "";
                showTree("Third");
                
                setTimeout(function() {
                    testRunner.notifyDone();
                }, 0);
            }, 100);
        }, 100);
    }

    window.addEventListener('load', doTest, false);
  </script>
</head>

<body>
  
  <!-- Normally we skip making a compositing layer on a parent, even if its children are composited -->
  <!-- But if the parent has a 2D transform it should get a compositing layer -->
  <!-- Here we test that the entire hierarchy gets layers when some elements are transformed and others arent -->
  <!-- Should see a box containing a blue box containing a rotated yellow box containing a green box in perspective -->
  <div id="parent">
      This content is in the parent
      <div id="child">
          <div id="grandchild">
              <div id="greatgrandchild">
                  Box should switch between perspective and flat
              </div>
          </div>
      </div>
  </div>
  
  <pre id="layers">Layer tree goes here in DRT</pre>
</body>
</html>