Diff
Modified: trunk/LayoutTests/ChangeLog (137927 => 137928)
--- trunk/LayoutTests/ChangeLog 2012-12-17 19:35:24 UTC (rev 137927)
+++ trunk/LayoutTests/ChangeLog 2012-12-17 19:44:04 UTC (rev 137928)
@@ -1,3 +1,15 @@
+2012-12-17 John J. Barton <[email protected]>
+
+ Web Inspector: Search by selection
+ https://bugs.webkit.org/show_bug.cgi?id=104970
+
+ Reviewed by Vsevolod Vlasov.
+
+ New inspector test for editor setting the search query
+
+ * inspector/editor/text-editor-selection-to-search-expected.txt: Added.
+ * inspector/editor/text-editor-selection-to-search.html: Added.
+
2012-12-17 Bem Jones-Bey <[email protected]>
[CSS Exclusions] Floats should respect shape-inside on exclusions
Added: trunk/LayoutTests/inspector/editor/text-editor-selection-to-search-expected.txt (0 => 137928)
--- trunk/LayoutTests/inspector/editor/text-editor-selection-to-search-expected.txt (rev 0)
+++ trunk/LayoutTests/inspector/editor/text-editor-selection-to-search-expected.txt 2012-12-17 19:44:04 UTC (rev 137928)
@@ -0,0 +1,7 @@
+Tests synchronizing the search input field to the editor selection.
+
+
+Running: testWordSelectionToSearchQuery
+return
+return
+
Added: trunk/LayoutTests/inspector/editor/text-editor-selection-to-search.html (0 => 137928)
--- trunk/LayoutTests/inspector/editor/text-editor-selection-to-search.html (rev 0)
+++ trunk/LayoutTests/inspector/editor/text-editor-selection-to-search.html 2012-12-17 19:44:04 UTC (rev 137928)
@@ -0,0 +1,62 @@
+<html>
+<head>
+<script src=""
+<script src=""
+<script src=""
+
+<script>
+
+function test()
+{
+ var panel = WebInspector.showPanel("scripts");
+
+ function selectionToSearchInputTest() {
+ WebInspector.searchController.showSearchField();
+ InspectorTest.addResult(WebInspector.searchController._searchInputElement.value);
+ WebInspector.advancedSearchController.show();
+ InspectorTest.addResult(WebInspector.advancedSearchController._searchView._search.value);
+ }
+
+ InspectorTest.showScriptSource("edit-me.js", didShowScriptSource);
+
+ function getLineColumn(sourceFrame, string) {
+ for (var i = 0; i < sourceFrame._textEditor.linesCount; ++i) {
+ var line = sourceFrame._textEditor.line(i);
+ var column = line.indexOf(string);
+ if (column === -1)
+ continue;
+ return {line: i, column: column};
+ break;
+ }
+ }
+
+ function setSelection(sourceFrame, from, to) {
+ range = new WebInspector.TextRange(from.line, from.column, to.line, to.column);
+ return sourceFrame._textEditor.setSelection(range);
+ }
+
+ function didShowScriptSource(sourceFrame)
+ {
+ var string = 'return';
+ var lineColumn = getLineColumn(sourceFrame, string);
+
+ InspectorTest.runTestSuite([
+ function testWordSelectionToSearchQuery(next)
+ {
+ setSelection(sourceFrame, lineColumn, {line: lineColumn.line, column: lineColumn.column + string.length});
+ selectionToSearchInputTest();
+ next();
+ },
+ ]);
+ }
+};
+
+</script>
+
+</head>
+
+<body _onload_="runTest()">
+<p>Tests synchronizing the search input field to the editor selection.</p>
+
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (137927 => 137928)
--- trunk/Source/WebCore/ChangeLog 2012-12-17 19:35:24 UTC (rev 137927)
+++ trunk/Source/WebCore/ChangeLog 2012-12-17 19:44:04 UTC (rev 137928)
@@ -1,3 +1,21 @@
+2012-12-17 John J. Barton <[email protected]>
+
+ Web Inspector: Search by selection
+ https://bugs.webkit.org/show_bug.cgi?id=104970
+
+ Reviewed by Vsevolod Vlasov.
+
+ Upon activation of the search control, conditionally set input.value to window.getSelection().
+ For both single file (SearchController) and multifile (AdvancedSearchController).
+
+ Test: inspector/editor/text-editor-selection-to-search.html
+
+ * inspector/front-end/AdvancedSearchController.js:
+ (WebInspector.AdvancedSearchController.prototype.show):
+ (WebInspector.SearchView.prototype.syncToSelection):
+ * inspector/front-end/SearchController.js:
+ (WebInspector.SearchController.prototype.showSearchField):
+
2012-12-17 Eduardo Lima Mitev <[email protected]>
[GStreamer] Use gst_element_link_pads_full() with CHECK_NOTHING for speed and sanity
Modified: trunk/Source/WebCore/inspector/front-end/AdvancedSearchController.js (137927 => 137928)
--- trunk/Source/WebCore/inspector/front-end/AdvancedSearchController.js 2012-12-17 19:35:24 UTC (rev 137927)
+++ trunk/Source/WebCore/inspector/front-end/AdvancedSearchController.js 2012-12-17 19:44:04 UTC (rev 137928)
@@ -88,6 +88,8 @@
if (!this._searchView)
this._searchView = new WebInspector.SearchView(this);
+ this._searchView.syncToSelection();
+
if (this._searchView.isShowing())
this._searchView.focus();
else
@@ -240,6 +242,13 @@
{
return new WebInspector.SearchConfig(this._search.value, this._ignoreCaseCheckbox.checked, this._regexCheckbox.checked);
},
+
+ syncToSelection: function()
+ {
+ var selection = window.getSelection();
+ if (selection.rangeCount)
+ this._search.value = selection.toString().replace(/\r?\n.*/, "");
+ },
/**
* @type {WebInspector.SearchResultsPane}
Modified: trunk/Source/WebCore/inspector/front-end/SearchController.js (137927 => 137928)
--- trunk/Source/WebCore/inspector/front-end/SearchController.js 2012-12-17 19:35:24 UTC (rev 137927)
+++ trunk/Source/WebCore/inspector/front-end/SearchController.js 2012-12-17 19:44:04 UTC (rev 137928)
@@ -249,6 +249,9 @@
WebInspector.inspectorView.setFooterElement(this._element);
this._updateReplaceVisibility();
this._updateFilterVisibility();
+ var selection = window.getSelection();
+ if (selection.rangeCount)
+ this._searchInputElement.value = selection.toString().replace(/\r?\n.*/, "");
this._searchInputElement.focus();
this._searchInputElement.select();
this._searchIsVisible = true;