Index: third_party/WebKit/PerformanceTests/Paint/color-changes.html |
diff --git a/third_party/WebKit/PerformanceTests/Paint/color-changes.html b/third_party/WebKit/PerformanceTests/Paint/color-changes.html |
index 3ed433d400e5e3a85eb2a41928f948faa0097a1c..a18e675eb3f2b9a94ae7f13ed44fde03c7d1316e 100644 |
--- a/third_party/WebKit/PerformanceTests/Paint/color-changes.html |
+++ b/third_party/WebKit/PerformanceTests/Paint/color-changes.html |
@@ -3,7 +3,6 @@ |
<script src="../resources/runner.js"></script> |
<style> |
span { |
- background-color: white; |
padding: 1px; |
} |
.changeColor { |
@@ -14,29 +13,43 @@ |
// This test measures the lifecycle update performance of changing background |
// colors in large trees. |
-function buildTree(parent, depth, arity, createElementCallback) { |
+function buildTree(parent, depth, arity, tagNameCallback, createElementCallback) { |
for (var child = 0; child < arity; child++) { |
- var element = document.createElement('span'); |
+ var element = document.createElement(tagNameCallback(depth)); |
parent.appendChild(element); |
createElementCallback(element, depth); |
if (depth > 1) |
- buildTree(element, depth - 1, arity, createElementCallback); |
+ buildTree(element, depth - 1, arity, tagNameCallback, createElementCallback); |
} |
} |
-// Build a tall tree (depth=10) that is skinny (arity=2). A middle layer of |
+// Build a tall tree that is skinny. A middle layer of |
// the tree should have the changeColor class. |
-buildTree(document.body, 11, 2, function(element, depth) { |
- if (depth == 5) |
- element.setAttribute('class', 'changeColor'); |
-}); |
+buildTree(document.body, 15, 2, |
+ function(depth) { |
+ // Use divs at upper levels to avoid too much layout time. |
+ return depth > 9 ? 'div' : 'span'; |
+ }, |
+ function(element, depth) { |
+ element.style.backgroundColor = 'green'; |
+ if (depth == 5) |
+ element.setAttribute('class', 'changeColor'); |
+ } |
+); |
-// Build a short tree (depth=6) that is fat (arity=4). A middle layer of |
+// Build a short tree that is fat. A middle layer of |
// the tree should have the changeColor class. |
-buildTree(document.body, 6, 4, function(element, depth) { |
- if (depth == 3) |
- element.setAttribute('class', 'changeColor'); |
-}); |
+buildTree(document.body, 6, 7, |
+ function(depth) { |
+ // Use divs at upper levels to avoid too much layout time. |
+ return depth > 4 ? 'div' : 'span'; |
+ }, |
+ function(element, depth) { |
+ element.style.backgroundColor = 'orange'; |
+ if (depth == 3) |
+ element.setAttribute('class', 'changeColor'); |
+ } |
+); |
var runCount = 0; |
var elementsToChange = document.getElementsByClassName('changeColor'); |