Web Inspector: copying a search result out of Search Tab navigation sidebar does...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 25 Feb 2017 08:29:59 +0000 (08:29 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 25 Feb 2017 08:29:59 +0000 (08:29 +0000)
https://bugs.webkit.org/show_bug.cgi?id=167074

Patch by Devin Rousso <dcrousso+webkit@gmail.com> on 2017-02-25
Reviewed by Brian Burg.

* UserInterface/Base/Main.js:
(WebInspector._copy):
* UserInterface/Views/SearchTabContentView.js:
(WebInspector.SearchTabContentView.prototype.handleCopyEvent):
Provide the container TabContentView with the opportunity to intercept the copy event.

* UserInterface/Models/SourceCodeTextRange.js:
(WebInspector.SourceCodeTextRange.prototype.get synthesizedTextValue):
* UserInterface/Views/SearchResultTreeElement.js:
(WebInspector.SearchResultTreeElement.prototype.get synthesizedTextValue):
Generate a string with the format `${url}:${lineNumber}:${resultLine}`.

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

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Base/Main.js
Source/WebInspectorUI/UserInterface/Models/SourceCodeTextRange.js
Source/WebInspectorUI/UserInterface/Views/SearchResultTreeElement.js
Source/WebInspectorUI/UserInterface/Views/SearchTabContentView.js

index 2dc4576..c87c986 100644 (file)
@@ -1,5 +1,24 @@
 2017-02-25  Devin Rousso  <dcrousso+webkit@gmail.com>
 
+        Web Inspector: copying a search result out of Search Tab navigation sidebar does nothing
+        https://bugs.webkit.org/show_bug.cgi?id=167074
+
+        Reviewed by Brian Burg.
+
+        * UserInterface/Base/Main.js:
+        (WebInspector._copy):
+        * UserInterface/Views/SearchTabContentView.js:
+        (WebInspector.SearchTabContentView.prototype.handleCopyEvent):
+        Provide the container TabContentView with the opportunity to intercept the copy event.
+
+        * UserInterface/Models/SourceCodeTextRange.js:
+        (WebInspector.SourceCodeTextRange.prototype.get synthesizedTextValue):
+        * UserInterface/Views/SearchResultTreeElement.js:
+        (WebInspector.SearchResultTreeElement.prototype.get synthesizedTextValue):
+        Generate a string with the format `${url}:${lineNumber}:${resultLine}`.
+
+2017-02-25  Devin Rousso  <dcrousso+webkit@gmail.com>
+
         Web Inspector: RTL: Styles - Rules sidebar icons are misaligned
         https://bugs.webkit.org/show_bug.cgi?id=168807
 
index e2bb507..0a7d7e4 100644 (file)
@@ -2108,6 +2108,12 @@ WebInspector._copy = function(event)
             return;
         }
 
+        let tabContentView = this.tabBrowser.selectedTabContentView;
+        if (tabContentView && typeof tabContentView.handleCopyEvent === "function") {
+            tabContentView.handleCopyEvent(event);
+            return;
+        }
+
         return;
     }
 
index 2167432..08143c9 100644 (file)
@@ -105,6 +105,12 @@ WebInspector.SourceCodeTextRange = class SourceCodeTextRange extends WebInspecto
         return new WebInspector.TextRange(startLine, startColumn, endLine, endColumn);
     }
 
+    get synthesizedTextValue()
+    {
+        // Must add 1 to the lineNumber since it starts counting at 0.
+        return this._sourceCode.url + ":" + (this._startLocation.lineNumber + 1);
+    }
+
     // Private
 
     _startAndEndLocationsInSameMappedResource()
index 89ad735..f6fb6cb 100644 (file)
@@ -80,6 +80,11 @@ WebInspector.SearchResultTreeElement = class SearchResultTreeElement extends Web
     {
         return {text: [this.representedObject.title]};
     }
+
+    get synthesizedTextValue()
+    {
+        return this.representedObject.sourceCodeTextRange.synthesizedTextValue + ":" + this.representedObject.title;
+    }
 };
 
 WebInspector.SearchResultTreeElement.CharactersToShowBeforeSearchMatch = 15;
index cedabd7..25fff78 100644 (file)
@@ -85,6 +85,17 @@ WebInspector.SearchTabContentView = class SearchTabContentView extends WebInspec
         this.navigationSidebarPanel.performSearch(searchQuery);
     }
 
+    handleCopyEvent(event)
+    {
+        let selectedTreeElement = this.navigationSidebarPanel.contentTreeOutline.selectedTreeElement;
+        if (!selectedTreeElement)
+            return;
+
+        event.clipboardData.setData("text/plain", selectedTreeElement.synthesizedTextValue);
+        event.stopPropagation();
+        event.preventDefault();
+    }
+
     // Protected
 
     initialLayout()