Add an option to select the results form the graphics benchmark
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 30 Nov 2015 22:15:27 +0000 (22:15 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 30 Nov 2015 22:15:27 +0000 (22:15 +0000)
https://bugs.webkit.org/show_bug.cgi?id=151666

Patch by Said Abou-Hallawa <sabouhallawa@apple.com> on 2015-11-30
Reviewed by Ryosuke Niwa.

We need an easy way to select the graphics benchmark results table such
that when it is copied to the clipboard, rich text format is set to the
clipboard.

* Animometer/runner/animometer.html: Add a new button to select the results table or JSON.

* Animometer/runner/resources/animometer.js:
(window.sectionsManager._sectionDataElement): Selects the container <data> element.
(window.sectionsManager._sectionDataDivElement): Replace a literal string with a string table entry.
(window.sectionsManager.showTestName): Replace a literal string with a string table entry.
(window.sectionsManager.selectData): Selects the container <data> element in a selection.
(window.sectionsManager.selectDataContents): Select the contents of container <data> element in a selection.
(window.benchmarkController.selectResults): Selects the results table.
(window.benchmarkController.showJSON): Function rename.
(window.benchmarkController.selectJSON): Selects the contents of the results JSON.
(window.benchmarkController.showJson): Deleted.

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

PerformanceTests/Animometer/runner/animometer.html
PerformanceTests/Animometer/runner/resources/animometer.js
PerformanceTests/ChangeLog

index 6cabb57..8e3924e 100644 (file)
@@ -55,7 +55,8 @@
                 <table class="results-table"></table>
             </data>
             <footer>
-                <button class="large-button" onclick="benchmarkController.showJson()">JSON</button>
+                <button class="large-button" onclick="benchmarkController.selectResults()">Select</button>
+                <button class="large-button" onclick="benchmarkController.showJSON()">JSON</button>
                 <button class="large-button" onclick="benchmarkController.startTest()">Test Again</button>
             </footer>
         </section>  
@@ -67,6 +68,7 @@
                 <div class="results-json" contentEditable="true"></div>
             </data>
             <footer>
+                <button class="large-button" onclick="benchmarkController.selectJSON('json')">Select</button>
                 <button class="large-button" onclick="benchmarkController.showResults()">Results</button>
                 <button class="large-button" onclick="benchmarkController.startTest()">Test Again</button>
             </footer>
@@ -79,6 +81,7 @@
                 <div class="results-json" contentEditable="true"></div>
             </data>
             <footer>
+                <button class="large-button" onclick="benchmarkController.selectJSON('test-json')">Select</button>
                 <button class="large-button" onclick="benchmarkController.showResults()">Results</button>
                 <button class="large-button" onclick="benchmarkController.startTest()">Test Again</button>        
             </footer>
index d3ac8db..82b531f 100644 (file)
@@ -58,6 +58,11 @@ window.sectionsManager =
     {
         return document.querySelector("#" + sectionIdentifier + " > header > h1");
     },
+
+    _sectionDataElement: function(sectionIdentifier)
+    {
+        return document.querySelector("#" + sectionIdentifier + " > data");
+    },
     
     _sectionDataDivElement: function(sectionIdentifier)
     {
@@ -70,7 +75,7 @@ window.sectionsManager =
         element.textContent = title + ":";
 
         var score = benchmarkRunnerClient.score.toFixed(2);
-        element.textContent += " [Score = " + score + "]";
+        element.textContent += " [" + Strings.text.score + " = " + score + "]";
     },
     
     showTestName: function(sectionIdentifier, title, testName)
@@ -81,7 +86,7 @@ window.sectionsManager =
         if (!testName.length)
             return;
             
-        element.textContent += " [test = " + testName + "]";
+        element.textContent += " [" + Strings.text.testName + " = " + testName + "]";
     },
     
     showJSON: function(sectionIdentifier, json)
@@ -94,6 +99,24 @@ window.sectionsManager =
         }, 4);
     },
     
+    selectData: function(sectionIdentifier)
+    {
+        window.getSelection().removeAllRanges();
+        var element = this._sectionDataElement(sectionIdentifier);
+        var range = document.createRange();
+        range.selectNode(element);
+        window.getSelection().addRange(range);  
+    },
+    
+    selectDataContents: function(sectionIdentifier)
+    {
+        window.getSelection().removeAllRanges();
+        var element = this._sectionDataDivElement(sectionIdentifier);
+        var range = document.createRange();
+        range.selectNodeContents(element);
+        window.getSelection().addRange(range);
+    },
+        
     showSection: function(sectionIdentifier, pushState)
     {
         var currentSectionElement = document.querySelector("section.selected");
@@ -414,6 +437,11 @@ window.benchmarkController =
         this._runBenchmark(suites, options);
         sectionsManager.showSection("running");
     },
+
+    selectResults: function()
+    {
+        sectionsManager.selectData("results");
+    },
     
     showResults: function()
     {
@@ -421,12 +449,12 @@ window.benchmarkController =
         sectionsManager.showSection("results", true);
     },
     
-    showJson: function()
+    showJSON: function()
     {
         sectionsManager.showScore("json", Strings.text.results.results);
         sectionsManager.showSection("json", true);
     },
-    
+
     showTestGraph: function(testName, axes, samples, samplingTimeOffset)
     {
         sectionsManager.showTestName("test-graph", Strings.text.results.graph, testName);
@@ -439,7 +467,12 @@ window.benchmarkController =
         sectionsManager.showTestName("test-json", Strings.text.results.graph, testName);
         sectionsManager.showJSON("test-json", json);
         sectionsManager.showSection("test-json", true);
-    }
+    },
+    
+    selectJSON: function(sectionIdentifier)
+    {
+        sectionsManager.selectDataContents(sectionIdentifier);
+    },
 }
 
 window.addEventListener("load", benchmarkController.initialize);
index dbc4231..5d13874 100644 (file)
@@ -1,3 +1,27 @@
+2015-11-30  Said Abou-Hallawa  <sabouhallawa@apple.com>
+
+        Add an option to select the results form the graphics benchmark
+        https://bugs.webkit.org/show_bug.cgi?id=151666
+
+        Reviewed by Ryosuke Niwa.
+
+        We need an easy way to select the graphics benchmark results table such
+        that when it is copied to the clipboard, rich text format is set to the
+        clipboard.
+
+        * Animometer/runner/animometer.html: Add a new button to select the results table or JSON.
+        
+        * Animometer/runner/resources/animometer.js:
+        (window.sectionsManager._sectionDataElement): Selects the container <data> element.
+        (window.sectionsManager._sectionDataDivElement): Replace a literal string with a string table entry.
+        (window.sectionsManager.showTestName): Replace a literal string with a string table entry.
+        (window.sectionsManager.selectData): Selects the container <data> element in a selection.
+        (window.sectionsManager.selectDataContents): Select the contents of container <data> element in a selection.
+        (window.benchmarkController.selectResults): Selects the results table.
+        (window.benchmarkController.showJSON): Function rename.
+        (window.benchmarkController.selectJSON): Selects the contents of the results JSON.
+        (window.benchmarkController.showJson): Deleted.
+
 2015-11-20  Simon Fraser  <simon.fraser@apple.com>
 
         Animometer: graphs should not do interpolation