[CSS Regions] Add performance tests for selection with mixed content
authorrego@igalia.com <rego@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Jan 2014 11:26:33 +0000 (11:26 +0000)
committerrego@igalia.com <rego@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Jan 2014 11:26:33 +0000 (11:26 +0000)
https://bugs.webkit.org/show_bug.cgi?id=126427

Reviewed by Ryosuke Niwa.

Add new performance tests for selection in CSS Regions mixing regular
content with regions. 2 new tests are added, one checking select all
command and another simulating a user selection passing through all the
paragraphs (similar to Layout/RegionsSelection.html).

Test are skipped for now while implementation of selection in CSS
Regions is still evolving.

* Layout/RegionsExtendingSelectionMixedContent.html: Added.
* Layout/RegionsSelectAllMixedContent.html: Added.
* Layout/resources/regions.css:
(.regular):
* Layout/resources/regions.js:
* Skipped:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@162065 268f45cc-cd09-0410-ab3c-d52691b4dbfc

PerformanceTests/ChangeLog
PerformanceTests/Layout/RegionsExtendingSelectionMixedContent.html [new file with mode: 0644]
PerformanceTests/Layout/RegionsSelectAllMixedContent.html [new file with mode: 0644]
PerformanceTests/Layout/resources/regions.css
PerformanceTests/Layout/resources/regions.js
PerformanceTests/Skipped

index 214fa96..383bf9e 100644 (file)
@@ -1,3 +1,25 @@
+2014-01-15  Manuel Rego Casasnovas  <rego@igalia.com>
+
+        [CSS Regions] Add performance tests for selection with mixed content
+        https://bugs.webkit.org/show_bug.cgi?id=126427
+
+        Reviewed by Ryosuke Niwa.
+
+        Add new performance tests for selection in CSS Regions mixing regular
+        content with regions. 2 new tests are added, one checking select all
+        command and another simulating a user selection passing through all the
+        paragraphs (similar to Layout/RegionsSelection.html).
+
+        Test are skipped for now while implementation of selection in CSS
+        Regions is still evolving.
+
+        * Layout/RegionsExtendingSelectionMixedContent.html: Added.
+        * Layout/RegionsSelectAllMixedContent.html: Added.
+        * Layout/resources/regions.css:
+        (.regular):
+        * Layout/resources/regions.js:
+        * Skipped:
+
 2014-01-14  Ryosuke Niwa  <rniwa@webkit.org>
 
         Make DoYouEvenBench runnable by run-perf-tests
diff --git a/PerformanceTests/Layout/RegionsExtendingSelectionMixedContent.html b/PerformanceTests/Layout/RegionsExtendingSelectionMixedContent.html
new file mode 100644 (file)
index 0000000..360e30e
--- /dev/null
@@ -0,0 +1,59 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <link rel="stylesheet" href="resources/regions.css" type="text/css"></link>
+        <script src="../resources/runner.js"></script>
+        <script src="resources/regions.js"></script>
+        <style type="text/css">
+        #log {
+            position: fixed;
+        }
+        </style>
+    </head>
+    <body>
+        <pre id="log"></pre>
+        <script>
+            function performSelectionMixedContent() {
+                var paragraphs = document.getElementsByClassName("contentParagraph");
+                var selection = getSelection();
+
+                selection.collapse(paragraphs[paragraphs.length / 2], 0);
+
+                // Traverse the paragraphs following visual order and not DOM order.
+                for (var i = 1; i < paragraphs.length; i++) {
+                    var paragraph;
+                    if (i % 2)
+                        paragraph = paragraphs[(i - 1) / 2];
+                    else
+                        paragraph = paragraphs[(paragraphs.length + i) / 2];
+                    selection.extend(paragraph, 0);
+                }
+            }
+
+            function createRegionsExtendingSelectionMixedContentTest(regionCount) {
+                var article = createArticle(regionCount, 1);
+                article.className = "articleInFlow";
+                var container = createMixedContent(regionCount);
+                document.body.appendChild(article);
+                document.body.appendChild(container);
+                return {
+                    description: "Testing selection with mixed content (" + regionCount + " regular paragraphs and " + regionCount + " regions). Select text from first paragraph to last one passing through all the paragraphs.",
+                    run: function() {
+                        performSelectionMixedContent();
+                    },
+                    setup: function() {
+                        window.getSelection().removeAllRanges();
+                    },
+                    done: function() {
+                        document.body.removeChild(article);
+                        document.body.removeChild(container);
+                        templateParagraph = null;
+                        templateRegion = null;
+                    }
+                };
+            }
+
+            PerfTestRunner.measureTime(createRegionsExtendingSelectionMixedContentTest(100));
+        </script>
+    </body>
+</html>
diff --git a/PerformanceTests/Layout/RegionsSelectAllMixedContent.html b/PerformanceTests/Layout/RegionsSelectAllMixedContent.html
new file mode 100644 (file)
index 0000000..85f1c93
--- /dev/null
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <link rel="stylesheet" href="resources/regions.css" type="text/css"></link>
+        <script src="../resources/runner.js"></script>
+        <script src="resources/regions.js"></script>
+        <style type="text/css">
+        #log {
+            position: fixed;
+        }
+        </style>
+    </head>
+    <body>
+        <pre id="log"></pre>
+        <script>
+            function createRegionsSelectAllMixedContentTest(regionCount) {
+                var article = createArticle(regionCount, 1);
+                article.className = "articleInFlow";
+                var container = createMixedContent(regionCount);
+                document.body.appendChild(article);
+                document.body.appendChild(container);
+                return {
+                    description: "Testing selection with mixed content (" + regionCount + " regular paragraphs and " + regionCount + " regions). Select text using select all command.",
+                    run: function() {
+                        document.execCommand('SelectAll');
+                    },
+                    setup: function() {
+                        window.getSelection().removeAllRanges();
+                    },
+                    done: function() {
+                        document.body.removeChild(article);
+                        document.body.removeChild(container);
+                        templateParagraph = null;
+                        templateRegion = null;
+                    }
+                };
+            }
+
+            PerfTestRunner.measureTime(createRegionsSelectAllMixedContentTest(1000));
+        </script>
+    </body>
+</html>
index c752952..9225d79 100644 (file)
     -webkit-region-fragment: break;
 }
 
+.regular {
+    border: 1px solid red;
+}
+
 .contentParagraph {
     font-size: 16px;
 }
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;
 
 })();
index 398aad2..353fd06 100644 (file)
@@ -83,6 +83,8 @@ Layout/RegionsAutoMaxHeight.html
 Layout/RegionsFixed.html
 Layout/RegionsFixedShort.html
 Layout/RegionsSelection.html
+Layout/RegionsSelectionMixedContent.html
+Layout/RegionsSelectAllMixedContent.html
 
 # https://bugs.webkit.org/show_bug.cgi?id=113811#c2
 Layout/LineLayoutJapanese.html