Refactoring: Pull all fullscreen code out of Document and into its own helper class
[WebKit-https.git] / PerformanceTests / Layout / RegionsExtendingSelectionMixedContent.html
1 <!DOCTYPE html>
2 <html>
3     <head>
4         <link rel="stylesheet" href="resources/regions.css" type="text/css"></link>
5         <script src="../resources/runner.js"></script>
6         <script src="resources/regions.js"></script>
7         <style type="text/css">
8         #log {
9             position: fixed;
10         }
11         </style>
12     </head>
13     <body>
14         <pre id="log"></pre>
15         <script>
16             function performSelectionMixedContent() {
17                 var paragraphs = document.getElementsByClassName("contentParagraph");
18                 var selection = getSelection();
19
20                 selection.collapse(paragraphs[paragraphs.length / 2], 0);
21
22                 // Traverse the paragraphs following visual order and not DOM order.
23                 for (var i = 1; i < paragraphs.length; i++) {
24                     var paragraph;
25                     if (i % 2)
26                         paragraph = paragraphs[(i - 1) / 2];
27                     else
28                         paragraph = paragraphs[(paragraphs.length + i) / 2];
29                     selection.extend(paragraph, 0);
30                 }
31             }
32
33             function createRegionsExtendingSelectionMixedContentTest(regionCount) {
34                 var article = createArticle(regionCount, 1);
35                 article.className = "articleInFlow";
36                 var container = createMixedContent(regionCount);
37                 document.body.appendChild(article);
38                 document.body.appendChild(container);
39                 return {
40                     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.",
41                     run: function() {
42                         performSelectionMixedContent();
43                     },
44                     setup: function() {
45                         window.getSelection().removeAllRanges();
46                     },
47                     done: function() {
48                         document.body.removeChild(article);
49                         document.body.removeChild(container);
50                         templateParagraph = null;
51                         templateRegion = null;
52                     }
53                 };
54             }
55
56             PerfTestRunner.measureTime(createRegionsExtendingSelectionMixedContentTest(100));
57         </script>
58     </body>
59 </html>