Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(348)

Side by Side Diff: LayoutTests/compositing/overflow/universal-acceleration/resources/universal-overflow.js

Issue 22620002: Add layout tests for universal overflow scrolling (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: . Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 if (window.internals) {
2 window.internals.settings.setAcceleratedCompositingForOverflowScrollEnabled( true);
3 // internals.setUniversalAcceleratedCompositingForOverflowScrollEnabled(true) ;
Julien - ping for review 2013/08/21 01:34:40 This line is probably unneeded :)
Ian Vollick 2013/08/23 15:02:40 lol. Done.
4 }
5
6 var isFixedPositioned = true;
7 var isContainingBlock = true;
8 var hasSibling = true;
9 var hasGrandchildren = true;
Julien - ping for review 2013/08/21 01:34:40 These variables are just magical and make it hard
Ian Vollick 2013/08/23 15:02:40 I've rearranged things a bunch and come up with so
10
11 function addDomElement(elementType, className, id, parent, description, indent)
12 {
13 var element = document.createElement(elementType);
14 element.setAttribute("class", className);
15 element.setAttribute("id", id);
16 if (parent === "body")
17 document.body.appendChild(element);
18 else
19 document.getElementById(parent).appendChild(element);
20
21 if (elementType === "div") {
22 for (var i = 0; i < indent; ++i)
23 description.push(" ");
24 description.push("+ ");
25 description.push(id);
26 if (className) {
27 description.push(", class: ");
28 description.push(className);
29 }
30 description.push("\n");
31 } else {
32 element.innerHTML = description.join("");
33 }
34 }
35
36 function buildDom(description, indent)
37 {
38 var parentElement = "body";
39 if (hasSibling) {
40 addDomElement("div", "", "ancestor", "body", description, indent);
41 indent++;
42 addDomElement("div", "positionFixed", "sibling", "ancestor", description , indent);
43 parentElement = "ancestor";
44 }
45
46 var overflowClass = isContainingBlock
47 ? "positionAbsolute overflow"
48 : "overflow";
49
50 addDomElement("div", overflowClass, "container", parentElement, description, indent);
51 indent++;
52
53 parentElement = "container";
54 if (hasGrandchildren) {
55 addDomElement("div", "", "scrollingContainer", parentElement, descriptio n, indent);
56 indent++;
57 parentElement = "scrollingContainer";
58 }
59
60 positionedClass = isFixedPositioned ? "positionFixed" : "positionAbsolute";
61
62 addDomElement("div", positionedClass, "positioned", parentElement, descripti on, indent);
63
64 for (var i = 0; i < 5; ++i) {
65 var scrolledClass = "scrolled";
66 if ((i % 2) == 0) {
Julien - ping for review 2013/08/21 01:34:40 We usually don't put curly braces for single line
Ian Vollick 2013/08/23 15:02:40 Done.
67 scrolledClass += " onTop";
68 }
69 addDomElement("div", scrolledClass, "scrolled", parentElement, descripti on, indent);
70 }
71 }
72
73 function doTest() {
74 var description = ["This test constructs the following tree:\n"];
75 var indent = 0;
76 buildDom(description, indent)
77
78 if (!window.internals) {
79 addDomElement("pre", "", "console", "body", description, indent);
80 var pre = document.getElementById("console");
81 pre.innerHTML += "\nWe then check that scrolling is accelerated.";
82 } else {
83 testRunner.dumpAsText(true);
84
85 var container = document.getElementById("container");
86 container.scrollTop = container.scrollHeight - container.clientHeight;
87
88 var layerTreeAsText = internals.layerTreeAsText(document);
89
90 addDomElement("pre", "", "console", "body", description, indent);
91 var pre = document.getElementById("console");
92 pre.style.left = "-80000px";
93 pre.innerHTML = layerTreeAsText;
94 }
95 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698