[CSS Regions] Add performance tests for selection with mixed content
[WebKit-https.git] / PerformanceTests / Layout / resources / regions.js
index 14faaa8..508f5af 100644 (file)
@@ -1,6 +1,7 @@
 (function() {
     var templateParagraph = null;
     var templateRegion = null;
+    var templateNode = null;
     var DEFAULT_PARAGRAPH_COUNT = 100;
     var DEFAULT_REGION_COUNT = 100;
 
         return region;
     }
 
+    function createRegularNode(nodeWidth, nodeHeight, nodeMaxHeight) {
+        if (!templateNode) {
+            templateNode = document.createElement("div");
+            templateNode.appendChild(createParagraphNode(0));
+            templateNode.className = "regular";
+        }
+
+        var node = templateNode.cloneNode(true);
+        node.style.width = nodeWidth;
+        node.style.height = nodeHeight;
+        node.style.maxHeight = nodeMaxHeight;
+        return node;
+    }
+
     function createArticle(paragraphCount, breakChance) {
         var article = document.createElement("div");
         for (var i = 0 ; i < paragraphCount; ++i) {
         };
     }
 
+    function createMixedContent(regionCount) {
+        var container = document.createElement("div");
+        for (var i = 0; i < regionCount; ++i) {
+            container.appendChild(createRegularNode("600px", "auto", "auto"));
+            container.appendChild(createRegionNode("600px", "auto", "auto"));
+        }
+        return container;
+    }
+
     window.createRegionsTest = createRegionsTest;
     window.createRegionsSelectionTest = createRegionsSelectionTest;
+    window.createArticle = createArticle;
+    window.createMixedContent = createMixedContent;
 
 })();