Chromium Code Reviews| Index: LayoutTests/compositing/overflow/universal-acceleration/resources/universal-overflow.js |
| diff --git a/LayoutTests/compositing/overflow/universal-acceleration/resources/universal-overflow.js b/LayoutTests/compositing/overflow/universal-acceleration/resources/universal-overflow.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..818589d466230707c1ac39f8e42f718773d0a9d8 |
| --- /dev/null |
| +++ b/LayoutTests/compositing/overflow/universal-acceleration/resources/universal-overflow.js |
| @@ -0,0 +1,95 @@ |
| +if (window.internals) { |
| + window.internals.settings.setAcceleratedCompositingForOverflowScrollEnabled(true); |
| +// 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.
|
| +} |
| + |
| +var isFixedPositioned = true; |
| +var isContainingBlock = true; |
| +var hasSibling = true; |
| +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
|
| + |
| +function addDomElement(elementType, className, id, parent, description, indent) |
| +{ |
| + var element = document.createElement(elementType); |
| + element.setAttribute("class", className); |
| + element.setAttribute("id", id); |
| + if (parent === "body") |
| + document.body.appendChild(element); |
| + else |
| + document.getElementById(parent).appendChild(element); |
| + |
| + if (elementType === "div") { |
| + for (var i = 0; i < indent; ++i) |
| + description.push(" "); |
| + description.push("+ "); |
| + description.push(id); |
| + if (className) { |
| + description.push(", class: "); |
| + description.push(className); |
| + } |
| + description.push("\n"); |
| + } else { |
| + element.innerHTML = description.join(""); |
| + } |
| +} |
| + |
| +function buildDom(description, indent) |
| +{ |
| + var parentElement = "body"; |
| + if (hasSibling) { |
| + addDomElement("div", "", "ancestor", "body", description, indent); |
| + indent++; |
| + addDomElement("div", "positionFixed", "sibling", "ancestor", description, indent); |
| + parentElement = "ancestor"; |
| + } |
| + |
| + var overflowClass = isContainingBlock |
| + ? "positionAbsolute overflow" |
| + : "overflow"; |
| + |
| + addDomElement("div", overflowClass, "container", parentElement, description, indent); |
| + indent++; |
| + |
| + parentElement = "container"; |
| + if (hasGrandchildren) { |
| + addDomElement("div", "", "scrollingContainer", parentElement, description, indent); |
| + indent++; |
| + parentElement = "scrollingContainer"; |
| + } |
| + |
| + positionedClass = isFixedPositioned ? "positionFixed" : "positionAbsolute"; |
| + |
| + addDomElement("div", positionedClass, "positioned", parentElement, description, indent); |
| + |
| + for (var i = 0; i < 5; ++i) { |
| + var scrolledClass = "scrolled"; |
| + 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.
|
| + scrolledClass += " onTop"; |
| + } |
| + addDomElement("div", scrolledClass, "scrolled", parentElement, description, indent); |
| + } |
| +} |
| + |
| +function doTest() { |
| + var description = ["This test constructs the following tree:\n"]; |
| + var indent = 0; |
| + buildDom(description, indent) |
| + |
| + if (!window.internals) { |
| + addDomElement("pre", "", "console", "body", description, indent); |
| + var pre = document.getElementById("console"); |
| + pre.innerHTML += "\nWe then check that scrolling is accelerated."; |
| + } else { |
| + testRunner.dumpAsText(true); |
| + |
| + var container = document.getElementById("container"); |
| + container.scrollTop = container.scrollHeight - container.clientHeight; |
| + |
| + var layerTreeAsText = internals.layerTreeAsText(document); |
| + |
| + addDomElement("pre", "", "console", "body", description, indent); |
| + var pre = document.getElementById("console"); |
| + pre.style.left = "-80000px"; |
| + pre.innerHTML = layerTreeAsText; |
| + } |
| +} |