Title: [117564] trunk/Source/WebCore
Revision
117564
Author
[email protected]
Date
2012-05-18 01:53:05 -0700 (Fri, 18 May 2012)

Log Message

Web Inspector: remove File abstraction from the AdvancedSearchController, migrate it to UISourceCode.
https://bugs.webkit.org/show_bug.cgi?id=86809

Reviewed by Yury Semikhatsky.

This change migrates AdvancedSearchController from "Object" to "UISourceCode".
I don't see why we need this abstraction and as a side effect, it makes search
across scripts work for styles.

* English.lproj/localizedStrings.js:
* inspector/front-end/AdvancedSearchController.js:
(WebInspector.SearchResult):
(WebInspector.FileBasedSearchResultsPane.prototype._createAnchor):
(WebInspector.FileBasedSearchResultsPane.prototype.addSearchResult):
(WebInspector.FileBasedSearchResultsPane.prototype._appendSearchMatches):
(WebInspector.FileBasedSearchResultsPane.prototype._regexMatchRanges):
(WebInspector.FileBasedSearchResultsPane.SearchResult):
* inspector/front-end/ScriptsSearchScope.js:
(WebInspector.ScriptsSearchScope.prototype.createSearchResultsPane):
* inspector/front-end/inspector.js:
(WebInspector._registerShortcuts):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (117563 => 117564)


--- trunk/Source/WebCore/ChangeLog	2012-05-18 08:40:55 UTC (rev 117563)
+++ trunk/Source/WebCore/ChangeLog	2012-05-18 08:53:05 UTC (rev 117564)
@@ -1,3 +1,27 @@
+2012-05-17  Pavel Feldman  <[email protected]>
+
+        Web Inspector: remove File abstraction from the AdvancedSearchController, migrate it to UISourceCode.
+        https://bugs.webkit.org/show_bug.cgi?id=86809
+
+        Reviewed by Yury Semikhatsky.
+
+        This change migrates AdvancedSearchController from "Object" to "UISourceCode".
+        I don't see why we need this abstraction and as a side effect, it makes search
+        across scripts work for styles.
+
+        * English.lproj/localizedStrings.js:
+        * inspector/front-end/AdvancedSearchController.js:
+        (WebInspector.SearchResult):
+        (WebInspector.FileBasedSearchResultsPane.prototype._createAnchor):
+        (WebInspector.FileBasedSearchResultsPane.prototype.addSearchResult):
+        (WebInspector.FileBasedSearchResultsPane.prototype._appendSearchMatches):
+        (WebInspector.FileBasedSearchResultsPane.prototype._regexMatchRanges):
+        (WebInspector.FileBasedSearchResultsPane.SearchResult):
+        * inspector/front-end/ScriptsSearchScope.js:
+        (WebInspector.ScriptsSearchScope.prototype.createSearchResultsPane):
+        * inspector/front-end/inspector.js:
+        (WebInspector._registerShortcuts):
+
 2012-05-17  Yury Semikhatsky  <[email protected]>
 
         Web Inspector: add an option to show last N hidden children of node in heap profiler

Modified: trunk/Source/WebCore/English.lproj/localizedStrings.js


(Binary files differ)

Modified: trunk/Source/WebCore/inspector/front-end/AdvancedSearchController.js (117563 => 117564)


--- trunk/Source/WebCore/inspector/front-end/AdvancedSearchController.js	2012-05-18 08:40:55 UTC (rev 117563)
+++ trunk/Source/WebCore/inspector/front-end/AdvancedSearchController.js	2012-05-18 08:53:05 UTC (rev 117564)
@@ -92,7 +92,7 @@
 
     /**
      * @param {number} searchId
-     * @param {Object} searchResult
+     * @param {WebInspector.FileBasedSearchResultsPane.SearchResult} searchResult
      */
     _onSearchResult: function(searchId, searchResult)
     {
@@ -323,7 +323,7 @@
     },
 
     /**
-     * @param {Object} searchResult
+     * @param {WebInspector.FileBasedSearchResultsPane.SearchResult} searchResult
      */
     addSearchResult: function(searchResult)
     {
@@ -437,7 +437,7 @@
 WebInspector.SearchScope.prototype = {
     /**
      * @param {WebInspector.SearchConfig} searchConfig
-     * @param {function(Object)} searchResultCallback
+     * @param {function(WebInspector.FileBasedSearchResultsPane.SearchResult)} searchResultCallback
      * @param {function(boolean)} searchFinishedCallback
      */
     performSearch: function(searchConfig, searchResultCallback, searchFinishedCallback) { },
@@ -453,6 +453,17 @@
 
 /**
  * @constructor
+ * @param {number} offset
+ * @param {number} length
+ */
+WebInspector.SearchResult = function(offset, length)
+{
+    this.offset = offset;
+    this.length = length;    
+}
+
+/**
+ * @constructor
  * @param {WebInspector.SearchConfig} searchConfig
  */
 WebInspector.SearchResultsPane = function(searchConfig)
@@ -471,7 +482,7 @@
     },
 
     /**
-     * @param {Object} searchResult
+     * @param {WebInspector.FileBasedSearchResultsPane.SearchResult} searchResult
      */
     addSearchResult: function(searchResult) { }
 }
@@ -503,34 +514,35 @@
 
 WebInspector.FileBasedSearchResultsPane.prototype = {
     /**
-     * @param {Object} file
+     * @param {WebInspector.UISourceCode} uiSourceCode
      * @param {number} lineNumber
      * @param {number} columnNumber
      * @return {Element}
      */
-    createAnchor: function(file, lineNumber, columnNumber) { },
+    _createAnchor: function(uiSourceCode, lineNumber, columnNumber)
+    {
+        var anchor = document.createElement("a");
+        anchor.preferredPanel = "scripts";
+        anchor.href = ""
+        anchor.uiSourceCode = uiSourceCode;
+        anchor.lineNumber = lineNumber;
+        return anchor;
+    },
 
     /**
-     * @param {Object} file
-     * @return {string}
+     * @param {WebInspector.FileBasedSearchResultsPane.SearchResult} searchResult
      */
-    fileName: function(file) { },
-
-    /**
-     * @param {Object} searchResult
-     */
     addSearchResult: function(searchResult)
     {
         this._searchResults.push(searchResult);
-        var file = searchResult.file;
-        var fileName = this.fileName(file);
+        var uiSourceCode = searchResult.uiSourceCode;
         var searchMatches = searchResult.searchMatches;
 
-        var fileTreeElement = this._addFileTreeElement(fileName, searchMatches.length, this._searchResults.length - 1);
+        var fileTreeElement = this._addFileTreeElement(uiSourceCode.url, searchMatches.length, this._searchResults.length - 1);
     },
 
     /**
-     * @param {Object} searchResult
+     * @param {WebInspector.FileBasedSearchResultsPane.SearchResult} searchResult
      * @param {TreeElement} fileTreeElement
      */
     _fileTreeElementExpanded: function(searchResult, fileTreeElement)
@@ -550,23 +562,22 @@
 
     /**
      * @param {TreeElement} fileTreeElement
-     * @param {Object} searchResult
+     * @param {WebInspector.FileBasedSearchResultsPane.SearchResult} searchResult
      * @param {number} fromIndex
      * @param {number} toIndex
      */
     _appendSearchMatches: function(fileTreeElement, searchResult, fromIndex, toIndex)
     {
-        var file = searchResult.file;
-        var fileName = this.fileName(file);
+        var uiSourceCode = searchResult.uiSourceCode;
         var searchMatches = searchResult.searchMatches;
-        
+
         var regex = createSearchRegex(this._searchConfig.query, !this._searchConfig.ignoreCase, this._searchConfig.isRegex);
         for (var i = fromIndex; i < toIndex; ++i) {
             var lineNumber = searchMatches[i].lineNumber;
             var lineContent = searchMatches[i].lineContent;
             var matchRanges = this._regexMatchRanges(lineContent, regex);
             
-            var anchor = this.createAnchor(file, lineNumber, matchRanges[0].offset);
+            var anchor = this._createAnchor(uiSourceCode, lineNumber, matchRanges[0].offset);
             
             var numberString = numberToStringWithSpacesPadding(lineNumber + 1, 4);
             var lineNumberSpan = document.createElement("span");
@@ -587,7 +598,7 @@
 
     /**
      * @param {TreeElement} fileTreeElement
-     * @param {Object} searchResult
+     * @param {WebInspector.FileBasedSearchResultsPane.SearchResult} searchResult
      * @param {number} startMatchIndex
      */
     _appendShowMoreMatchesElement: function(fileTreeElement, searchResult, startMatchIndex)
@@ -601,7 +612,7 @@
     },
 
     /**
-     * @param {Object} searchResult
+     * @param {WebInspector.FileBasedSearchResultsPane.SearchResult} searchResult
      * @param {number} startMatchIndex
      * @param {TreeElement} showMoreMatchesElement
      */
@@ -654,7 +665,7 @@
     /**
      * @param {string} lineContent
      * @param {RegExp} regex
-     * @return {Array.<Object>}
+     * @return {Array.<WebInspector.SearchResult>}
      */
     _regexMatchRanges: function(lineContent, regex)
     {
@@ -663,14 +674,14 @@
         var offset = 0;
         var matchRanges = [];
         while ((regex.lastIndex < lineContent.length) && (match = regex.exec(lineContent)))
-            matchRanges.push({ offset: match.index, length: match[0].length });
-        
+            matchRanges.push(new WebInspector.SearchResult(match.index, match[0].length));
+
         return matchRanges;
     },
     
     /**
      * @param {string} lineContent
-     * @param {Array.<Object>} matchRanges
+     * @param {Array.<WebInspector.SearchResult>} matchRanges
      */
     _createContentSpan: function(lineContent, matchRanges)
     {
@@ -686,11 +697,11 @@
 
 /**
  * @constructor
- * @param {Object} file
+ * @param {WebInspector.UISourceCode} uiSourceCode
  * @param {Array.<Object>} searchMatches
  */
-WebInspector.FileBasedSearchResultsPane.SearchResult = function(file, searchMatches) {
-    this.file = file;
+WebInspector.FileBasedSearchResultsPane.SearchResult = function(uiSourceCode, searchMatches) {
+    this.uiSourceCode = uiSourceCode;
     this.searchMatches = searchMatches;
 }
 

Modified: trunk/Source/WebCore/inspector/front-end/ScriptsSearchScope.js (117563 => 117564)


--- trunk/Source/WebCore/inspector/front-end/ScriptsSearchScope.js	2012-05-18 08:40:55 UTC (rev 117563)
+++ trunk/Source/WebCore/inspector/front-end/ScriptsSearchScope.js	2012-05-18 08:53:05 UTC (rev 117564)
@@ -42,7 +42,7 @@
 WebInspector.ScriptsSearchScope.prototype = {
     /**
      * @param {WebInspector.SearchConfig} searchConfig
-     * @param {function(Object)} searchResultCallback
+     * @param {function(WebInspector.FileBasedSearchResultsPane.SearchResult)} searchResultCallback
      * @param {function(boolean)} searchFinishedCallback
      */
     performSearch: function(searchConfig, searchResultCallback, searchFinishedCallback)
@@ -97,7 +97,7 @@
      */
     createSearchResultsPane: function(searchConfig)
     {
-        return new WebInspector.ScriptsSearchResultsPane(searchConfig);
+        return new WebInspector.FileBasedSearchResultsPane(searchConfig);
     },
 
     /**
@@ -126,65 +126,4 @@
 
 WebInspector.ScriptsSearchScope.prototype.__proto__ = WebInspector.SearchScope.prototype;
 
-/**
- * @constructor
- * @extends {WebInspector.FileBasedSearchResultsPane}
- * @param {WebInspector.SearchConfig} searchConfig
- */
-WebInspector.ScriptsSearchResultsPane = function(searchConfig)
-{
-    WebInspector.FileBasedSearchResultsPane.call(this, searchConfig)
-
-    this._linkifier = new WebInspector.Linkifier(new WebInspector.ScriptsSearchResultsPane.LinkifierFormatter());
-}
-
-WebInspector.ScriptsSearchResultsPane.prototype = {
-    /**
-     * @param {Object} file
-     * @param {number} lineNumber
-     * @param {number} columnNumber
-     */
-    createAnchor: function(file, lineNumber, columnNumber)
-    {
-        var uiSourceCode = /** @type {WebInspector.UISourceCode} */ file;
-        var rawLocation = uiSourceCode.uiLocationToRawLocation(lineNumber, columnNumber);
-        var anchor = this._linkifier.linkifyRawLocation(rawLocation);
-        anchor.removeChildren();
-        return anchor;
-    },
-    
-    /**
-     * @param {Object} file
-     * @return {string}
-     */
-    fileName: function(file)
-    {
-        var uiSourceCode = file;
-        return uiSourceCode.url;
-    },
-}
-
-WebInspector.ScriptsSearchResultsPane.prototype.__proto__ = WebInspector.FileBasedSearchResultsPane.prototype;
-
-/**
- * @constructor
- * @implements {WebInspector.LinkifierFormatter}
- */
-WebInspector.ScriptsSearchResultsPane.LinkifierFormatter = function()
-{
-}
-
-WebInspector.ScriptsSearchResultsPane.LinkifierFormatter.prototype = {
-    /**
-     * @param {Element} anchor
-     * @param {WebInspector.UILocation} uiLocation
-     */
-    formatLiveAnchor: function(anchor, uiLocation)
-    {
-        // Empty because we don't want to ever update anchor contents after creation.
-    }
-}
-
-WebInspector.ScriptsSearchResultsPane.LinkifierFormatter.prototype.__proto__ = WebInspector.LinkifierFormatter.prototype;
-
 WebInspector.settings.searchInContentScripts = WebInspector.settings.createSetting("searchInContentScripts", false);

Modified: trunk/Source/WebCore/inspector/front-end/inspector.js (117563 => 117564)


--- trunk/Source/WebCore/inspector/front-end/inspector.js	2012-05-18 08:40:55 UTC (rev 117563)
+++ trunk/Source/WebCore/inspector/front-end/inspector.js	2012-05-18 08:53:05 UTC (rev 117564)
@@ -653,7 +653,7 @@
     section.addKey(shortcut.shortcutToString("f", shortcut.Modifiers.CtrlOrMeta), WebInspector.UIString("Search"));
     
     var advancedSearchShortcut = WebInspector.AdvancedSearchController.createShortcut();
-    section.addKey(advancedSearchShortcut.name, WebInspector.UIString("Search across all scripts"));
+    section.addKey(advancedSearchShortcut.name, WebInspector.UIString("Search across all sources"));
     
     if (WebInspector.isMac()) {
         keys = [
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to