Diff
Modified: trunk/Source/WebInspectorUI/ChangeLog (183338 => 183339)
--- trunk/Source/WebInspectorUI/ChangeLog 2015-04-26 01:25:22 UTC (rev 183338)
+++ trunk/Source/WebInspectorUI/ChangeLog 2015-04-26 01:26:06 UTC (rev 183339)
@@ -1,5 +1,97 @@
2015-04-25 Timothy Hatcher <[email protected]>
+ Web Inspector: Split search from ResourceSidebarPanel into a Search tab and sidebar
+ https://bugs.webkit.org/show_bug.cgi?id=144197
+
+ Reviewed by Joseph Pecoraro.
+
+ * UserInterface/Base/Main.js:
+ (WebInspector.contentLoaded):
+ (WebInspector._tabContentViewForType):
+ (WebInspector._searchTextDidChange):
+ (WebInspector._focusSearchField):
+ (WebInspector._domNodeWasInspected):
+ * UserInterface/Controllers/DebuggerManager.js:
+ (WebInspector.DebuggerManager.prototype.get knownNonResourceScripts):
+ * UserInterface/Images/SearchResults.svg: Added.
+ * UserInterface/Main.html:
+ * UserInterface/Views/ResourceSidebarPanel.js:
+ (WebInspector.ResourceSidebarPanel):
+ (WebInspector.ResourceSidebarPanel.prototype.showDefaultContentView):
+ (WebInspector.ResourceSidebarPanel.prototype.treeElementForRepresentedObject):
+ (WebInspector.ResourceSidebarPanel.prototype._mainFrameDidChange):
+ (WebInspector.ResourceSidebarPanel.prototype._scriptWasAdded):
+ (WebInspector.ResourceSidebarPanel.prototype._treeElementSelected):
+ (WebInspector.ResourceSidebarPanel.prototype._addStorageChild):
+ (WebInspector.ResourceSidebarPanel.prototype._extraDomainsActivated):
+ (WebInspector.ResourceSidebarPanel.prototype.get contentTreeOutlineToAutoPrune): Deleted.
+ (WebInspector.ResourceSidebarPanel.prototype.performSearch.updateEmptyContentPlaceholderSoon): Deleted.
+ (WebInspector.ResourceSidebarPanel.prototype.performSearch.updateEmptyContentPlaceholder): Deleted.
+ (WebInspector.ResourceSidebarPanel.prototype.performSearch.forEachMatch): Deleted.
+ (WebInspector.ResourceSidebarPanel.prototype.performSearch.resourceCallback): Deleted.
+ (WebInspector.ResourceSidebarPanel.prototype.performSearch.resourcesCallback): Deleted.
+ (WebInspector.ResourceSidebarPanel.prototype.performSearch.searchScripts.scriptCallback): Deleted.
+ (WebInspector.ResourceSidebarPanel.prototype.performSearch.searchScripts): Deleted.
+ (WebInspector.ResourceSidebarPanel.prototype.performSearch.domSearchResults): Deleted.
+ (WebInspector.ResourceSidebarPanel.prototype.performSearch.domCallback): Deleted.
+ (WebInspector.ResourceSidebarPanel.prototype.performSearch): Deleted.
+ (WebInspector.ResourceSidebarPanel.prototype._showResourcesContentTreeOutline): Deleted.
+ (WebInspector.ResourceSidebarPanel.prototype._showSearchContentTreeOutline): Deleted.
+ (WebInspector.ResourceSidebarPanel.prototype._searchFieldChanged): Deleted.
+ (WebInspector.ResourceSidebarPanel.prototype._searchFieldInput): Deleted.
+ (WebInspector.ResourceSidebarPanel.prototype._searchTreeElementForResource): Deleted.
+ (WebInspector.ResourceSidebarPanel.prototype._searchTreeElementForScript): Deleted.
+ (WebInspector.ResourceSidebarPanel.prototype._focusSearchField): Deleted.
+ (WebInspector.ResourceSidebarPanel.prototype._scriptsToSearch): Deleted.
+ * UserInterface/Views/SearchBar.js:
+ (WebInspector.SearchBar):
+ * UserInterface/Views/SearchSidebarPanel.css: Renamed from Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.css.
+ (.sidebar > .panel.navigation.search > :matches(.content, .empty-content-placeholder)):
+ (body.mac-platform.legacy .sidebar > .panel.navigation.search > :matches(.content, .empty-content-placeholder)):
+ (.sidebar > .panel.navigation.search > .search-bar):
+ (body.mac-platform.legacy .sidebar > .panel.navigation.search > .search-bar):
+ (.sidebar > .panel.navigation.search > .search-bar > input[type="search"]):
+ (body.mac-platform.legacy .sidebar > .panel.navigation.search > .search-bar > input[type="search"]):
+ * UserInterface/Views/SearchSidebarPanel.js: Added.
+ (WebInspector.SearchSidebarPanel):
+ (WebInspector.SearchSidebarPanel.prototype.closed):
+ (WebInspector.SearchSidebarPanel.prototype.focusSearchField):
+ (WebInspector.SearchSidebarPanel.prototype.performSearch.updateEmptyContentPlaceholderSoon):
+ (WebInspector.SearchSidebarPanel.prototype.performSearch.updateEmptyContentPlaceholder):
+ (WebInspector.SearchSidebarPanel.prototype.performSearch.forEachMatch):
+ (WebInspector.SearchSidebarPanel.prototype.performSearch.resourceCallback):
+ (WebInspector.SearchSidebarPanel.prototype.performSearch.resourcesCallback):
+ (WebInspector.SearchSidebarPanel.prototype.performSearch.searchScripts.scriptCallback):
+ (WebInspector.SearchSidebarPanel.prototype.performSearch.searchScripts):
+ (WebInspector.SearchSidebarPanel.prototype.performSearch.domSearchResults):
+ (WebInspector.SearchSidebarPanel.prototype.performSearch.domCallback):
+ (WebInspector.SearchSidebarPanel.prototype.performSearch):
+ (WebInspector.SearchSidebarPanel.prototype._searchFieldChanged):
+ (WebInspector.SearchSidebarPanel.prototype._searchFieldInput):
+ (WebInspector.SearchSidebarPanel.prototype._searchTreeElementForResource):
+ (WebInspector.SearchSidebarPanel.prototype._searchTreeElementForScript):
+ (WebInspector.SearchSidebarPanel.prototype._mainResourceDidChange.delayedWork):
+ (WebInspector.SearchSidebarPanel.prototype._mainResourceDidChange):
+ (WebInspector.SearchSidebarPanel.prototype._treeElementSelected):
+ * UserInterface/Views/SearchTabContentView.js: Added.
+ (WebInspector.SearchTabContentView):
+ (WebInspector.SearchTabContentView.prototype.get type):
+ (WebInspector.SearchTabContentView.prototype.shown):
+ (WebInspector.SearchTabContentView.prototype.closed):
+ (WebInspector.SearchTabContentView.prototype.canShowRepresentedObject):
+ (WebInspector.SearchTabContentView.prototype.focusSearchField):
+ (WebInspector.SearchTabContentView.prototype.performSearch):
+ * UserInterface/Views/Toolbar.css:
+ (.toolbar .item-section.center-right):
+ (.toolbar .item-section.right):
+ (.toolbar .search-bar):
+ (.toolbar .search-bar > input[type="search"]):
+ (.toolbar .search-bar > input[type="search"]::-webkit-textfield-decoration-container):
+ (body.window-inactive .toolbar .search-bar > input[type="search"]):
+ (.toolbar .item): Deleted.
+
+2015-04-25 Timothy Hatcher <[email protected]>
+
Web Inspector: New Toolbar UI for tabs
https://bugs.webkit.org/show_bug.cgi?id=144185
Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Main.js (183338 => 183339)
--- trunk/Source/WebInspectorUI/UserInterface/Base/Main.js 2015-04-26 01:25:22 UTC (rev 183338)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Main.js 2015-04-26 01:26:06 UTC (rev 183339)
@@ -220,6 +220,8 @@
this.detailsSidebar = new WebInspector.Sidebar(document.getElementById("details-sidebar"), WebInspector.Sidebar.Sides.Right, null, null, WebInspector.UIString("Details"), true);
this.detailsSidebar.addEventListener(WebInspector.Sidebar.Event.WidthDidChange, this._sidebarWidthDidChange, this);
+ this.searchKeyboardShortcut = new WebInspector.KeyboardShortcut(WebInspector.KeyboardShortcut.Modifier.CommandOrControl | WebInspector.KeyboardShortcut.Modifier.Shift, "F", this._focusSearchField.bind(this));
+
this.navigationSidebarKeyboardShortcut = new WebInspector.KeyboardShortcut(WebInspector.KeyboardShortcut.Modifier.CommandOrControl, "0", this.toggleNavigationSidebar.bind(this));
this.detailsSidebarKeyboardShortcut = new WebInspector.KeyboardShortcut(WebInspector.KeyboardShortcut.Modifier.CommandOrControl | WebInspector.KeyboardShortcut.Modifier.Option, "0", this.toggleDetailsSidebar.bind(this));
@@ -285,6 +287,9 @@
this._dashboardContainer = new WebInspector.DashboardContainerView;
this._dashboardContainer.showDashboardViewForRepresentedObject(this.dashboardManager.dashboards.default);
+ this._searchToolbarItem = new WebInspector.SearchBar("inspector-search", WebInspector.UIString("Search"), null, true);
+ this._searchToolbarItem.addEventListener(WebInspector.SearchBar.Event.TextChanged, this._searchTextDidChange, this);
+
this.toolbar.addToolbarItem(this._closeToolbarButton, WebInspector.Toolbar.Section.Control);
this.toolbar.addToolbarItem(this._undockToolbarButton, WebInspector.Toolbar.Section.Left);
@@ -299,6 +304,8 @@
if (this._inspectModeToolbarButton)
this.toolbar.addToolbarItem(this._inspectModeToolbarButton, WebInspector.Toolbar.Section.CenterRight);
+ this.toolbar.addToolbarItem(this._searchToolbarItem, WebInspector.Toolbar.Section.Right);
+
this.resourceDetailsSidebarPanel = new WebInspector.ResourceDetailsSidebarPanel;
this.domNodeDetailsSidebarPanel = new WebInspector.DOMNodeDetailsSidebarPanel;
this.cssStyleDetailsSidebarPanel = new WebInspector.CSSStyleDetailsSidebarPanel;
@@ -365,6 +372,8 @@
return new WebInspector.DebuggerTabContentView;
case WebInspector.ConsoleTabContentView.Type:
return new WebInspector.ConsoleTabContentView;
+ case WebInspector.SearchTabContentView.Type:
+ return new WebInspector.SearchTabContentView;
default:
console.error("Unknown tab type", tabType);
}
@@ -868,6 +877,30 @@
WebInspector.debuggerManager.stepOut();
};
+WebInspector._searchTextDidChange = function(event)
+{
+ var tabContentView = this.tabBrowser.bestTabContentViewForClass(WebInspector.SearchTabContentView);
+ if (!tabContentView)
+ tabContentView = new WebInspector.SearchTabContentView;
+
+ var searchQuery = this._searchToolbarItem.text;
+ this._searchToolbarItem.text = "";
+
+ this.tabBrowser.showTabForContentView(tabContentView);
+
+ tabContentView.performSearch(searchQuery);
+};
+
+WebInspector._focusSearchField = function(event)
+{
+ if (this.tabBrowser.selectedTabContentView instanceof WebInspector.SearchTabContentView) {
+ this.tabBrowser.selectedTabContentView.focusSearchField();
+ return;
+ }
+
+ this._searchToolbarItem.focus();
+};
+
WebInspector._focusChanged = function(event)
{
// Make a caret selection inside the focused element if there isn't a range selection and there isn't already
@@ -1297,6 +1330,7 @@
InspectorFrontendHost.bringToFront();
+ this.showElementsTab();
this.showMainFrameDOMTree(event.data.node, true);
};
Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js (183338 => 183339)
--- trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js 2015-04-26 01:25:22 UTC (rev 183338)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js 2015-04-26 01:26:06 UTC (rev 183339)
@@ -310,6 +310,21 @@
DebuggerAgent.continueToLocation({scriptId: scriptIdentifier, lineNumber, columnNumber});
}
+ get knownNonResourceScripts()
+ {
+ var knownScripts = [];
+ for (var id in this._scriptIdMap) {
+ var script = this._scriptIdMap[id];
+ if (script.resource)
+ continue;
+ if (script.url && script.url.startsWith("__WebInspector"))
+ continue;
+ knownScripts.push(script);
+ }
+
+ return knownScripts;
+ }
+
addBreakpoint(breakpoint, skipEventDispatch, shouldSpeculativelyResolve)
{
console.assert(breakpoint instanceof WebInspector.Breakpoint, "Bad argument to DebuggerManger.addBreakpoint: ", breakpoint);
Added: trunk/Source/WebInspectorUI/UserInterface/Images/SearchResults.svg (0 => 183339)
--- trunk/Source/WebInspectorUI/UserInterface/Images/SearchResults.svg (rev 0)
+++ trunk/Source/WebInspectorUI/UserInterface/Images/SearchResults.svg 2015-04-26 01:26:06 UTC (rev 183339)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright © 2015 Apple Inc. All rights reserved. -->
+<svg viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg">
+ <rect x="0.5" y="0.5" width="15" height="15" rx="2" class="stroked" fill="none" stroke="black"/>
+ <circle cx="7" cy="7" r="3" class="stroked" fill="none" stroke="black"/>
+ <path d="M 9.5 9.5 L 12.5 12.5" class="stroked" fill="none" stroke="black"/>
+</svg>
Modified: trunk/Source/WebInspectorUI/UserInterface/Main.html (183338 => 183339)
--- trunk/Source/WebInspectorUI/UserInterface/Main.html 2015-04-26 01:25:22 UTC (rev 183338)
+++ trunk/Source/WebInspectorUI/UserInterface/Main.html 2015-04-26 01:26:06 UTC (rev 183339)
@@ -118,7 +118,6 @@
<link rel="stylesheet" href=""
<link rel="stylesheet" href=""
<link rel="stylesheet" href=""
- <link rel="stylesheet" href=""
<link rel="stylesheet" href=""
<link rel="stylesheet" href=""
<link rel="stylesheet" href=""
@@ -127,6 +126,7 @@
<link rel="stylesheet" href=""
<link rel="stylesheet" href=""
<link rel="stylesheet" href=""
+ <link rel="stylesheet" href=""
<link rel="stylesheet" href=""
<link rel="stylesheet" href=""
<link rel="stylesheet" href=""
@@ -348,6 +348,7 @@
<script src=""
<script src=""
<script src=""
+ <script src=""
<script src=""
<script src=""
@@ -491,6 +492,7 @@
<script src=""
<script src=""
<script src=""
+ <script src=""
<script src=""
<script src=""
<script src=""
Deleted: trunk/Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.css (183338 => 183339)
--- trunk/Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.css 2015-04-26 01:25:22 UTC (rev 183338)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.css 2015-04-26 01:26:06 UTC (rev 183339)
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-.sidebar > .panel.navigation.resource > :matches(.content, .empty-content-placeholder) {
- top: 28px;
-}
-
-body.mac-platform.legacy .sidebar > .panel.navigation.resource > :matches(.content, .empty-content-placeholder) {
- top: 21px;
-}
-
-.sidebar > .panel.navigation.resource > .search-bar {
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
-
- display: flex;
-
- box-shadow: inset rgba(255, 255, 255, 0.2) 0 1px 0;
-
- height: 28px;
-
- white-space: nowrap;
- overflow: hidden;
-}
-
-body.mac-platform.legacy .sidebar > .panel.navigation.resource > .search-bar {
- height: 21px;
-}
-
-.sidebar > .panel.navigation.resource > .search-bar > input[type="search"] {
- display: flex;
- flex: 1;
-
- margin: 3px 6px;
- padding-left: 4px;
-}
-
-body.mac-platform.legacy .sidebar > .panel.navigation.resource > .search-bar > input[type="search"] {
- margin: 1px 6px;
- padding-left: 0;
-}
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.js (183338 => 183339)
--- trunk/Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.js 2015-04-26 01:25:22 UTC (rev 183338)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.js 2015-04-26 01:26:06 UTC (rev 183339)
@@ -27,34 +27,14 @@
{
constructor(contentBrowser)
{
- super("resource", WebInspector.UIString("Resources"), true, true);
+ super("resource", WebInspector.UIString("Resources"), true);
this.contentBrowser = contentBrowser;
- var searchElement = document.createElement("div");
- searchElement.classList.add("search-bar");
- this.element.appendChild(searchElement);
-
- this._inputElement = document.createElement("input");
- this._inputElement.type = "search";
- this._inputElement.spellcheck = false;
- this._inputElement.addEventListener("search", this._searchFieldChanged.bind(this));
- this._inputElement.addEventListener("input", this._searchFieldInput.bind(this));
- this._inputElement.setAttribute("results", 5);
- this._inputElement.setAttribute("autosave", "inspector-search");
- this._inputElement.setAttribute("placeholder", WebInspector.UIString("Search Resource Content"));
- searchElement.appendChild(this._inputElement);
-
this.filterBar.placeholder = WebInspector.UIString("Filter Resource List");
this._waitingForInitialMainFrame = true;
- this._lastSearchedPageSetting = new WebInspector.Setting("last-searched-page", null);
- this._searchQuerySetting = new WebInspector.Setting("search-sidebar-query", "");
- this._inputElement.value = this._searchQuerySetting.value;
-
- this._searchKeyboardShortcut = new WebInspector.KeyboardShortcut(WebInspector.KeyboardShortcut.Modifier.CommandOrControl | WebInspector.KeyboardShortcut.Modifier.Shift, "F", this._focusSearchField.bind(this));
-
this._localStorageRootTreeElement = null;
this._sessionStorageRootTreeElement = null;
@@ -87,16 +67,11 @@
WebInspector.notifications.addEventListener(WebInspector.Notification.ExtraDomainsActivated, this._extraDomainsActivated, this);
- this._resourcesContentTreeOutline = this.contentTreeOutline;
- this._searchContentTreeOutline = this.createContentTreeOutline();
+ this.contentTreeOutline._onselect_ = this._treeElementSelected.bind(this);
+ this.contentTreeOutline.includeSourceMapResourceChildren = true;
- this._resourcesContentTreeOutline._onselect_ = this._treeElementSelected.bind(this);
- this._searchContentTreeOutline._onselect_ = this._treeElementSelected.bind(this);
-
- this._resourcesContentTreeOutline.includeSourceMapResourceChildren = true;
-
if (WebInspector.debuggableType === WebInspector.DebuggableType._javascript_)
- this._resourcesContentTreeOutline.element.classList.add(WebInspector.NavigationSidebarPanel.HideDisclosureButtonsStyleClassName);
+ this.contentTreeOutline.element.classList.add(WebInspector.NavigationSidebarPanel.HideDisclosureButtonsStyleClassName);
}
// Public
@@ -108,16 +83,11 @@
return;
}
- var firstTreeElement = this._resourcesContentTreeOutline.children[0];
+ var firstTreeElement = this.contentTreeOutline.children[0];
if (firstTreeElement)
firstTreeElement.revealAndSelect();
}
- get contentTreeOutlineToAutoPrune()
- {
- return this._searchContentTreeOutline;
- }
-
treeElementForRepresentedObject(representedObject)
{
// A custom implementation is needed for this since the frames are populated lazily.
@@ -160,7 +130,7 @@
return resourceOrFrame.parentFrame;
}
- var treeElement = this._resourcesContentTreeOutline.findTreeElement(representedObject, isAncestor, getParent);
+ var treeElement = this.contentTreeOutline.findTreeElement(representedObject, isAncestor, getParent);
if (treeElement)
return treeElement;
@@ -182,8 +152,8 @@
this._anonymousScriptsFolderTreeElement = new WebInspector.FolderTreeElement(WebInspector.UIString("Anonymous Scripts"));
if (!this._anonymousScriptsFolderTreeElement.parent) {
- var index = insertionIndexForObjectInListSortedByFunction(this._anonymousScriptsFolderTreeElement, this._resourcesContentTreeOutline.children, this._compareTreeElements);
- this._resourcesContentTreeOutline.insertChild(this._anonymousScriptsFolderTreeElement, index);
+ var index = insertionIndexForObjectInListSortedByFunction(this._anonymousScriptsFolderTreeElement, this.contentTreeOutline.children, this._compareTreeElements);
+ this.contentTreeOutline.insertChild(this._anonymousScriptsFolderTreeElement, index);
}
var scriptTreeElement = new WebInspector.ScriptTreeElement(representedObject);
@@ -192,282 +162,13 @@
return scriptTreeElement;
}
- performSearch(searchTerm)
- {
- // Before performing a new search, clear the old search.
- this._searchContentTreeOutline.removeChildren();
-
- this._inputElement.value = searchTerm;
- this._searchQuerySetting.value = searchTerm;
- this._lastSearchedPageSetting.value = searchTerm && WebInspector.frameResourceManager.mainFrame ? WebInspector.frameResourceManager.mainFrame.url.hash : null;
-
- this.hideEmptyContentPlaceholder();
-
- searchTerm = searchTerm.trim();
- if (!searchTerm.length) {
- this._showResourcesContentTreeOutline();
- return;
- }
-
- this._showSearchContentTreeOutline();
-
- // FIXME: Provide UI to toggle regex and case sensitive searches.
- var isCaseSensitive = false;
- var isRegex = false;
-
- var updateEmptyContentPlaceholderTimeout = null;
-
- function updateEmptyContentPlaceholderSoon()
- {
- if (updateEmptyContentPlaceholderTimeout)
- return;
- updateEmptyContentPlaceholderTimeout = setTimeout(updateEmptyContentPlaceholder.bind(this), 100);
- }
-
- function updateEmptyContentPlaceholder()
- {
- if (updateEmptyContentPlaceholderTimeout) {
- clearTimeout(updateEmptyContentPlaceholderTimeout);
- updateEmptyContentPlaceholderTimeout = null;
- }
-
- this.updateEmptyContentPlaceholder(WebInspector.UIString("No Search Results"));
- }
-
- function forEachMatch(searchTerm, lineContent, callback)
- {
- var lineMatch;
- var searchRegex = new RegExp(searchTerm.escapeForRegExp(), "gi");
- while ((searchRegex.lastIndex < lineContent.length) && (lineMatch = searchRegex.exec(lineContent)))
- callback(lineMatch, searchRegex.lastIndex);
- }
-
- function resourcesCallback(error, result)
- {
- updateEmptyContentPlaceholderSoon.call(this);
-
- if (error)
- return;
-
- function resourceCallback(url, error, resourceMatches)
- {
- updateEmptyContentPlaceholderSoon.call(this);
-
- if (error || !resourceMatches || !resourceMatches.length)
- return;
-
- var frame = WebInspector.frameResourceManager.frameForIdentifier(searchResult.frameId);
- if (!frame)
- return;
-
- var resource = frame.url ="" url ? frame.mainResource : frame.resourceForURL(url);
- if (!resource)
- return;
-
- var resourceTreeElement = this._searchTreeElementForResource(resource);
-
- for (var i = 0; i < resourceMatches.length; ++i) {
- var match = resourceMatches[i];
- forEachMatch(searchTerm, match.lineContent, function(lineMatch, lastIndex) {
- var matchObject = new WebInspector.SourceCodeSearchMatchObject(resource, match.lineContent, searchTerm, new WebInspector.TextRange(match.lineNumber, lineMatch.index, match.lineNumber, lastIndex));
- var matchTreeElement = new WebInspector.SearchResultTreeElement(matchObject);
- resourceTreeElement.appendChild(matchTreeElement);
- });
- }
-
- updateEmptyContentPlaceholder.call(this);
- }
-
- for (var i = 0; i < result.length; ++i) {
- var searchResult = result[i];
- if (!searchResult.url || !searchResult.frameId)
- continue;
-
- PageAgent.searchInResource(searchResult.frameId, searchResult.url, searchTerm, isCaseSensitive, isRegex, resourceCallback.bind(this, searchResult.url));
- }
- }
-
- function searchScripts(scriptsToSearch)
- {
- updateEmptyContentPlaceholderSoon.call(this);
-
- if (!scriptsToSearch.length)
- return;
-
- function scriptCallback(script, error, scriptMatches)
- {
- updateEmptyContentPlaceholderSoon.call(this);
-
- if (error || !scriptMatches || !scriptMatches.length)
- return;
-
- var scriptTreeElement = this._searchTreeElementForScript(script);
-
- for (var i = 0; i < scriptMatches.length; ++i) {
- var match = scriptMatches[i];
- forEachMatch(searchTerm, match.lineContent, function(lineMatch, lastIndex) {
- var matchObject = new WebInspector.SourceCodeSearchMatchObject(script, match.lineContent, searchTerm, new WebInspector.TextRange(match.lineNumber, lineMatch.index, match.lineNumber, lastIndex));
- var matchTreeElement = new WebInspector.SearchResultTreeElement(matchObject);
- scriptTreeElement.appendChild(matchTreeElement);
- });
- }
-
- updateEmptyContentPlaceholder.call(this);
- }
-
- for (var script of scriptsToSearch)
- DebuggerAgent.searchInContent(script.id, searchTerm, isCaseSensitive, isRegex, scriptCallback.bind(this, script));
- }
-
- function domCallback(error, searchId, resultsCount)
- {
- updateEmptyContentPlaceholderSoon.call(this);
-
- if (error || !resultsCount)
- return;
-
- this._domSearchIdentifier = searchId;
-
- function domSearchResults(error, nodeIds)
- {
- updateEmptyContentPlaceholderSoon.call(this);
-
- if (error)
- return;
-
- for (var i = 0; i < nodeIds.length; ++i) {
- // If someone started a new search, then return early and stop showing seach results from the old query.
- if (this._domSearchIdentifier !== searchId)
- return;
-
- var domNode = WebInspector.domTreeManager.nodeForId(nodeIds[i]);
- if (!domNode || !domNode.ownerDocument)
- continue;
-
- // We do not display the document node when the search query is "/". We don't have anything to display in the content view for it.
- if (domNode.nodeType() === Node.DOCUMENT_NODE)
- continue;
-
- // FIXME: This should use a frame to do resourceForURL, but DOMAgent does not provide a frameId.
- var resource = WebInspector.frameResourceManager.resourceForURL(domNode.ownerDocument.documentURL);
- if (!resource)
- continue;
-
- var resourceTreeElement = this._searchTreeElementForResource(resource);
- var domNodeTitle = WebInspector.DOMSearchMatchObject.titleForDOMNode(domNode);
-
- // Textual matches.
- var didFindTextualMatch = false;
- forEachMatch(searchTerm, domNodeTitle, function(lineMatch, lastIndex) {
- var matchObject = new WebInspector.DOMSearchMatchObject(resource, domNode, domNodeTitle, searchTerm, new WebInspector.TextRange(0, lineMatch.index, 0, lastIndex));
- var matchTreeElement = new WebInspector.SearchResultTreeElement(matchObject);
- resourceTreeElement.appendChild(matchTreeElement);
- didFindTextualMatch = true;
- });
-
- // Non-textual matches are CSS Selector or XPath matches. In such cases, display the node entirely highlighted.
- if (!didFindTextualMatch) {
- var matchObject = new WebInspector.DOMSearchMatchObject(resource, domNode, domNodeTitle, domNodeTitle, new WebInspector.TextRange(0, 0, 0, domNodeTitle.length));
- var matchTreeElement = new WebInspector.SearchResultTreeElement(matchObject);
- resourceTreeElement.appendChild(matchTreeElement);
- }
-
- updateEmptyContentPlaceholder.call(this);
- }
- }
-
- DOMAgent.getSearchResults(searchId, 0, resultsCount, domSearchResults.bind(this));
- }
-
- if (window.DOMAgent)
- WebInspector.domTreeManager.requestDocument();
-
- if (window.PageAgent)
- PageAgent.searchInResources(searchTerm, isCaseSensitive, isRegex, resourcesCallback.bind(this));
-
- setTimeout(searchScripts.bind(this, this._scriptsToSearch()), 0);
-
- if (window.DOMAgent) {
- if ("_domSearchIdentifier" in this) {
- DOMAgent.discardSearchResults(this._domSearchIdentifier);
- delete this._domSearchIdentifier;
- }
-
- DOMAgent.performSearch(searchTerm, domCallback.bind(this));
- }
-
- // FIXME: Resource search should work in JSContext inspection.
- // <https://webkit.org/b/131252> Web Inspector: JSContext inspection Resource search does not work
- if (!window.DOMAgent && !window.PageAgent)
- updateEmptyContentPlaceholderSoon.call(this);
- }
-
// Private
- _showResourcesContentTreeOutline()
- {
- this.filterBar.placeholder = WebInspector.UIString("Filter Resource List");
- this.contentTreeOutline = this._resourcesContentTreeOutline;
- }
-
- _showSearchContentTreeOutline()
- {
- this.filterBar.placeholder = WebInspector.UIString("Filter Search Results");
- this.contentTreeOutline = this._searchContentTreeOutline;
- }
-
- _searchFieldChanged(event)
- {
- this.performSearch(event.target.value);
- }
-
- _searchFieldInput(event)
- {
- // If the search field is cleared, immediately clear the search results tree outline.
- if (!event.target.value.length && this.contentTreeOutline === this._searchContentTreeOutline)
- this.performSearch("");
- }
-
- _searchTreeElementForResource(resource)
- {
- var resourceTreeElement = this._searchContentTreeOutline.getCachedTreeElement(resource);
- if (!resourceTreeElement) {
- resourceTreeElement = new WebInspector.ResourceTreeElement(resource);
- resourceTreeElement.hasChildren = true;
- resourceTreeElement.expand();
-
- this._searchContentTreeOutline.appendChild(resourceTreeElement);
- }
-
- return resourceTreeElement;
- }
-
- _searchTreeElementForScript(script)
- {
- var scriptTreeElement = this._searchContentTreeOutline.getCachedTreeElement(script);
- if (!scriptTreeElement) {
- scriptTreeElement = new WebInspector.ScriptTreeElement(script);
- scriptTreeElement.hasChildren = true;
- scriptTreeElement.expand();
-
- this._searchContentTreeOutline.appendChild(scriptTreeElement);
- }
-
- return scriptTreeElement;
- }
-
- _focusSearchField(keyboardShortcut, event)
- {
- this.show();
-
- this._inputElement.select();
- }
-
_mainFrameDidChange(event)
{
if (this._mainFrameTreeElement) {
this._mainFrameTreeElement.frame.removeEventListener(WebInspector.Frame.Event.MainResourceDidChange, this._mainFrameMainResourceDidChange, this);
- this._resourcesContentTreeOutline.removeChild(this._mainFrameTreeElement);
+ this.contentTreeOutline.removeChild(this._mainFrameTreeElement);
this._mainFrameTreeElement = null;
}
@@ -475,10 +176,10 @@
if (newFrame) {
newFrame.addEventListener(WebInspector.Frame.Event.MainResourceDidChange, this._mainFrameMainResourceDidChange, this);
this._mainFrameTreeElement = new WebInspector.FrameTreeElement(newFrame);
- this._resourcesContentTreeOutline.insertChild(this._mainFrameTreeElement, 0);
+ this.contentTreeOutline.insertChild(this._mainFrameTreeElement, 0);
// Select a tree element by default. Allow onselect if we aren't showing a content view.
- if (!this._resourcesContentTreeOutline.selectedTreeElement) {
+ if (!this.contentTreeOutline.selectedTreeElement) {
var currentContentView = this.contentBrowser.currentContentView;
var treeElement = currentContentView ? this.treeElementForRepresentedObject(currentContentView.representedObject) : null;
if (!treeElement)
@@ -499,13 +200,6 @@
return;
this._waitingForInitialMainFrame = false;
-
- // Only if the last page searched is the same as the current page.
- if (this._lastSearchedPageSetting.value !== newFrame.url.hash)
- return;
-
- // Search for whatever is in the input field. This was populated with the last used search term.
- this.performSearch(this._inputElement.value);
}
_mainFrameMainResourceDidChange(event)
@@ -519,9 +213,6 @@
this.contentBrowser.contentViewContainer.closeAllContentViews();
- // Break out of search tree outline if there was an active search.
- this._showResourcesContentTreeOutline();
-
function delayedWork()
{
// Show the main frame since there is no content view showing or we were showing a resource before.
@@ -574,12 +265,12 @@
var scriptTreeElement = new WebInspector.ScriptTreeElement(script);
if (insertIntoTopLevel) {
- var index = insertionIndexForObjectInListSortedByFunction(scriptTreeElement, this._resourcesContentTreeOutline.children, this._compareTreeElements);
- this._resourcesContentTreeOutline.insertChild(scriptTreeElement, index);
+ var index = insertionIndexForObjectInListSortedByFunction(scriptTreeElement, this.contentTreeOutline.children, this._compareTreeElements);
+ this.contentTreeOutline.insertChild(scriptTreeElement, index);
} else {
if (!parentFolderTreeElement.parent) {
- var index = insertionIndexForObjectInListSortedByFunction(parentFolderTreeElement, this._resourcesContentTreeOutline.children, this._compareTreeElements);
- this._resourcesContentTreeOutline.insertChild(parentFolderTreeElement, index);
+ var index = insertionIndexForObjectInListSortedByFunction(parentFolderTreeElement, this.contentTreeOutline.children, this._compareTreeElements);
+ this.contentTreeOutline.insertChild(parentFolderTreeElement, index);
}
parentFolderTreeElement.appendChild(scriptTreeElement);
@@ -607,33 +298,6 @@
}
}
- _scriptsToSearch(event)
- {
- var nonResourceScripts = [];
-
- function collectFromTreeElement(folderTreeElement)
- {
- if (!folderTreeElement)
- return;
-
- var children = folderTreeElement.children;
- for (var treeElement of children) {
- if (treeElement instanceof WebInspector.ScriptTreeElement)
- nonResourceScripts.push(treeElement.script);
- }
- }
-
- if (WebInspector.debuggableType === WebInspector.DebuggableType._javascript_ && !WebInspector.hasExtraDomains)
- collectFromTreeElement(this._resourcesContentTreeOutline);
- else {
- collectFromTreeElement(this._extensionScriptsFolderTreeElement);
- collectFromTreeElement(this._extraScriptsFolderTreeElement);
- collectFromTreeElement(this._anonymousScriptsFolderTreeElement);
- }
-
- return nonResourceScripts;
- }
-
_treeElementSelected(treeElement, selectedByUser)
{
if (treeElement instanceof WebInspector.FolderTreeElement || treeElement instanceof WebInspector.DatabaseHostTreeElement ||
@@ -649,14 +313,7 @@
return;
}
- console.assert(treeElement instanceof WebInspector.SearchResultTreeElement);
- if (!(treeElement instanceof WebInspector.SearchResultTreeElement))
- return;
-
- if (treeElement.representedObject instanceof WebInspector.DOMSearchMatchObject)
- WebInspector.showMainFrameDOMTree(treeElement.representedObject.domNode);
- else if (treeElement.representedObject instanceof WebInspector.SourceCodeSearchMatchObject)
- WebInspector.showOriginalOrFormattedSourceCodeTextRange(treeElement.representedObject.sourceCodeTextRange);
+ console.error("Unknown tree element", treeElement);
}
_domStorageObjectWasAdded(event)
@@ -762,7 +419,7 @@
if (!parentElement) {
childElement.flattened = true;
- this._resourcesContentTreeOutline.insertChild(childElement, insertionIndexForObjectInListSortedByFunction(childElement, this._resourcesContentTreeOutline.children, this._compareTreeElements));
+ this.contentTreeOutline.insertChild(childElement, insertionIndexForObjectInListSortedByFunction(childElement, this.contentTreeOutline.children, this._compareTreeElements));
return childElement;
}
@@ -772,10 +429,10 @@
var previousOnlyChild = parentElement;
previousOnlyChild.flattened = false;
- this._resourcesContentTreeOutline.removeChild(previousOnlyChild);
+ this.contentTreeOutline.removeChild(previousOnlyChild);
var folderElement = new WebInspector.FolderTreeElement(folderName);
- this._resourcesContentTreeOutline.insertChild(folderElement, insertionIndexForObjectInListSortedByFunction(folderElement, this._resourcesContentTreeOutline.children, this._compareTreeElements));
+ this.contentTreeOutline.insertChild(folderElement, insertionIndexForObjectInListSortedByFunction(folderElement, this.contentTreeOutline.children, this._compareTreeElements));
folderElement.appendChild(previousOnlyChild);
folderElement.insertChild(childElement, insertionIndexForObjectInListSortedByFunction(childElement, folderElement.children, this._compareTreeElements));
@@ -830,6 +487,6 @@
_extraDomainsActivated()
{
if (WebInspector.debuggableType === WebInspector.DebuggableType._javascript_)
- this._resourcesContentTreeOutline.element.classList.remove(WebInspector.NavigationSidebarPanel.HideDisclosureButtonsStyleClassName);
+ this.contentTreeOutline.element.classList.remove(WebInspector.NavigationSidebarPanel.HideDisclosureButtonsStyleClassName);
}
};
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/SearchBar.js (183338 => 183339)
--- trunk/Source/WebInspectorUI/UserInterface/Views/SearchBar.js 2015-04-26 01:25:22 UTC (rev 183338)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/SearchBar.js 2015-04-26 01:26:06 UTC (rev 183339)
@@ -25,7 +25,7 @@
WebInspector.SearchBar = class SearchBar extends WebInspector.NavigationItem
{
- constructor(identifier, placeholder, delegate)
+ constructor(identifier, placeholder, delegate, supressIncremental)
{
super(identifier);
@@ -39,7 +39,7 @@
this._searchInput = this._element.appendChild(document.createElement("input"));
this._searchInput.type = "search";
this._searchInput.spellcheck = false;
- this._searchInput.incremental = true;
+ this._searchInput.incremental = !supressIncremental;
this._searchInput.setAttribute("results", 5);
this._searchInput.setAttribute("autosave", identifier + "-autosave");
this._searchInput.setAttribute("placeholder", placeholder);
Copied: trunk/Source/WebInspectorUI/UserInterface/Views/SearchSidebarPanel.css (from rev 183338, trunk/Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.css) (0 => 183339)
--- trunk/Source/WebInspectorUI/UserInterface/Views/SearchSidebarPanel.css (rev 0)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/SearchSidebarPanel.css 2015-04-26 01:26:06 UTC (rev 183339)
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+.sidebar > .panel.navigation.search > :matches(.content, .empty-content-placeholder) {
+ top: 28px;
+}
+
+body.mac-platform.legacy .sidebar > .panel.navigation.search > :matches(.content, .empty-content-placeholder) {
+ top: 21px;
+}
+
+.sidebar > .panel.navigation.search > .search-bar {
+ position: absolute;
+ top: 0;
+ left: 0;
+ right: 0;
+
+ display: flex;
+
+ box-shadow: inset rgba(255, 255, 255, 0.2) 0 1px 0;
+
+ height: 28px;
+
+ white-space: nowrap;
+ overflow: hidden;
+}
+
+body.mac-platform.legacy .sidebar > .panel.navigation.search > .search-bar {
+ height: 21px;
+}
+
+.sidebar > .panel.navigation.search > .search-bar > input[type="search"] {
+ display: flex;
+ flex: 1;
+
+ margin: 3px 6px;
+ padding-left: 4px;
+}
+
+body.mac-platform.legacy .sidebar > .panel.navigation.search > .search-bar > input[type="search"] {
+ margin: 1px 6px;
+ padding-left: 0;
+}
Added: trunk/Source/WebInspectorUI/UserInterface/Views/SearchSidebarPanel.js (0 => 183339)
--- trunk/Source/WebInspectorUI/UserInterface/Views/SearchSidebarPanel.js (rev 0)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/SearchSidebarPanel.js 2015-04-26 01:26:06 UTC (rev 183339)
@@ -0,0 +1,385 @@
+/*
+ * Copyright (C) 2013, 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+WebInspector.SearchSidebarPanel = class SearchSidebarPanel extends WebInspector.NavigationSidebarPanel
+{
+ constructor(contentBrowser)
+ {
+ super("search", WebInspector.UIString("Search"), true, true);
+
+ this.contentBrowser = contentBrowser;
+
+ var searchElement = document.createElement("div");
+ searchElement.classList.add("search-bar");
+ this.element.appendChild(searchElement);
+
+ this._inputElement = document.createElement("input");
+ this._inputElement.type = "search";
+ this._inputElement.spellcheck = false;
+ this._inputElement.addEventListener("search", this._searchFieldChanged.bind(this));
+ this._inputElement.addEventListener("input", this._searchFieldInput.bind(this));
+ this._inputElement.setAttribute("results", 5);
+ this._inputElement.setAttribute("autosave", "inspector-search-autosave");
+ this._inputElement.setAttribute("placeholder", WebInspector.UIString("Search Resource Content"));
+ searchElement.appendChild(this._inputElement);
+
+ this.filterBar.placeholder = WebInspector.UIString("Filter Search Results");
+
+ this._lastSearchedPageSetting = new WebInspector.Setting("last-searched-page", null);
+
+ this._searchQuerySetting = new WebInspector.Setting("search-sidebar-query", "");
+ this._inputElement.value = this._searchQuerySetting.value;
+
+ WebInspector.Frame.addEventListener(WebInspector.Frame.Event.MainResourceDidChange, this._mainResourceDidChange, this);
+
+ this.contentTreeOutline._onselect_ = this._treeElementSelected.bind(this);
+
+ if (WebInspector.debuggableType === WebInspector.DebuggableType._javascript_)
+ this._resourcesContentTreeOutline.element.classList.add(WebInspector.NavigationSidebarPanel.HideDisclosureButtonsStyleClassName);
+ }
+
+ // Public
+
+ closed()
+ {
+ WebInspector.Frame.removeEventListener(null, null, this);
+ }
+
+ focusSearchField()
+ {
+ this.show();
+
+ this._inputElement.select();
+ }
+
+ performSearch(searchQuery)
+ {
+ // Before performing a new search, clear the old search.
+ this.contentTreeOutline.removeChildren();
+ this.contentBrowser.contentViewContainer.closeAllContentViews();
+
+ this._inputElement.value = searchQuery;
+ this._searchQuerySetting.value = searchQuery;
+ this._lastSearchedPageSetting.value = searchQuery && WebInspector.frameResourceManager.mainFrame ? WebInspector.frameResourceManager.mainFrame.url.hash : null;
+
+ this.hideEmptyContentPlaceholder();
+
+ searchQuery = searchQuery.trim();
+ if (!searchQuery.length)
+ return;
+
+ // FIXME: Provide UI to toggle regex and case sensitive searches.
+ var isCaseSensitive = false;
+ var isRegex = false;
+
+ var updateEmptyContentPlaceholderTimeout = null;
+
+ function updateEmptyContentPlaceholderSoon()
+ {
+ if (updateEmptyContentPlaceholderTimeout)
+ return;
+ updateEmptyContentPlaceholderTimeout = setTimeout(updateEmptyContentPlaceholder.bind(this), 100);
+ }
+
+ function updateEmptyContentPlaceholder()
+ {
+ if (updateEmptyContentPlaceholderTimeout) {
+ clearTimeout(updateEmptyContentPlaceholderTimeout);
+ updateEmptyContentPlaceholderTimeout = null;
+ }
+
+ this.updateEmptyContentPlaceholder(WebInspector.UIString("No Search Results"));
+ }
+
+ function forEachMatch(searchQuery, lineContent, callback)
+ {
+ var lineMatch;
+ var searchRegex = new RegExp(searchQuery.escapeForRegExp(), "gi");
+ while ((searchRegex.lastIndex < lineContent.length) && (lineMatch = searchRegex.exec(lineContent)))
+ callback(lineMatch, searchRegex.lastIndex);
+ }
+
+ function resourcesCallback(error, result)
+ {
+ updateEmptyContentPlaceholderSoon.call(this);
+
+ if (error)
+ return;
+
+ function resourceCallback(url, error, resourceMatches)
+ {
+ updateEmptyContentPlaceholderSoon.call(this);
+
+ if (error || !resourceMatches || !resourceMatches.length)
+ return;
+
+ var frame = WebInspector.frameResourceManager.frameForIdentifier(searchResult.frameId);
+ if (!frame)
+ return;
+
+ var resource = frame.url ="" url ? frame.mainResource : frame.resourceForURL(url);
+ if (!resource)
+ return;
+
+ var resourceTreeElement = this._searchTreeElementForResource(resource);
+
+ for (var i = 0; i < resourceMatches.length; ++i) {
+ var match = resourceMatches[i];
+ forEachMatch(searchQuery, match.lineContent, function(lineMatch, lastIndex) {
+ var matchObject = new WebInspector.SourceCodeSearchMatchObject(resource, match.lineContent, searchQuery, new WebInspector.TextRange(match.lineNumber, lineMatch.index, match.lineNumber, lastIndex));
+ var matchTreeElement = new WebInspector.SearchResultTreeElement(matchObject);
+ resourceTreeElement.appendChild(matchTreeElement);
+ if (!this.contentTreeOutline.selectedTreeElement)
+ matchTreeElement.revealAndSelect(false, true);
+ }.bind(this));
+ }
+
+ updateEmptyContentPlaceholder.call(this);
+ }
+
+ for (var i = 0; i < result.length; ++i) {
+ var searchResult = result[i];
+ if (!searchResult.url || !searchResult.frameId)
+ continue;
+
+ PageAgent.searchInResource(searchResult.frameId, searchResult.url, searchQuery, isCaseSensitive, isRegex, resourceCallback.bind(this, searchResult.url));
+ }
+ }
+
+ function searchScripts(scriptsToSearch)
+ {
+ updateEmptyContentPlaceholderSoon.call(this);
+
+ if (!scriptsToSearch.length)
+ return;
+
+ function scriptCallback(script, error, scriptMatches)
+ {
+ updateEmptyContentPlaceholderSoon.call(this);
+
+ if (error || !scriptMatches || !scriptMatches.length)
+ return;
+
+ var scriptTreeElement = this._searchTreeElementForScript(script);
+
+ for (var i = 0; i < scriptMatches.length; ++i) {
+ var match = scriptMatches[i];
+ forEachMatch(searchQuery, match.lineContent, function(lineMatch, lastIndex) {
+ var matchObject = new WebInspector.SourceCodeSearchMatchObject(script, match.lineContent, searchQuery, new WebInspector.TextRange(match.lineNumber, lineMatch.index, match.lineNumber, lastIndex));
+ var matchTreeElement = new WebInspector.SearchResultTreeElement(matchObject);
+ scriptTreeElement.appendChild(matchTreeElement);
+ if (!this.contentTreeOutline.selectedTreeElement)
+ matchTreeElement.revealAndSelect(false, true);
+ }.bind(this));
+ }
+
+ updateEmptyContentPlaceholder.call(this);
+ }
+
+ for (var script of scriptsToSearch)
+ DebuggerAgent.searchInContent(script.id, searchQuery, isCaseSensitive, isRegex, scriptCallback.bind(this, script));
+ }
+
+ function domCallback(error, searchId, resultsCount)
+ {
+ updateEmptyContentPlaceholderSoon.call(this);
+
+ if (error || !resultsCount)
+ return;
+
+ this._domSearchIdentifier = searchId;
+
+ function domSearchResults(error, nodeIds)
+ {
+ updateEmptyContentPlaceholderSoon.call(this);
+
+ if (error)
+ return;
+
+ for (var i = 0; i < nodeIds.length; ++i) {
+ // If someone started a new search, then return early and stop showing seach results from the old query.
+ if (this._domSearchIdentifier !== searchId)
+ return;
+
+ var domNode = WebInspector.domTreeManager.nodeForId(nodeIds[i]);
+ if (!domNode || !domNode.ownerDocument)
+ continue;
+
+ // We do not display the document node when the search query is "/". We don't have anything to display in the content view for it.
+ if (domNode.nodeType() === Node.DOCUMENT_NODE)
+ continue;
+
+ // FIXME: This should use a frame to do resourceForURL, but DOMAgent does not provide a frameId.
+ var resource = WebInspector.frameResourceManager.resourceForURL(domNode.ownerDocument.documentURL);
+ if (!resource)
+ continue;
+
+ var resourceTreeElement = this._searchTreeElementForResource(resource);
+ var domNodeTitle = WebInspector.DOMSearchMatchObject.titleForDOMNode(domNode);
+
+ // Textual matches.
+ var didFindTextualMatch = false;
+ forEachMatch(searchQuery, domNodeTitle, function(lineMatch, lastIndex) {
+ var matchObject = new WebInspector.DOMSearchMatchObject(resource, domNode, domNodeTitle, searchQuery, new WebInspector.TextRange(0, lineMatch.index, 0, lastIndex));
+ var matchTreeElement = new WebInspector.SearchResultTreeElement(matchObject);
+ resourceTreeElement.appendChild(matchTreeElement);
+ if (!this.contentTreeOutline.selectedTreeElement)
+ matchTreeElement.revealAndSelect(false, true);
+ didFindTextualMatch = true;
+ }.bind(this));
+
+ // Non-textual matches are CSS Selector or XPath matches. In such cases, display the node entirely highlighted.
+ if (!didFindTextualMatch) {
+ var matchObject = new WebInspector.DOMSearchMatchObject(resource, domNode, domNodeTitle, domNodeTitle, new WebInspector.TextRange(0, 0, 0, domNodeTitle.length));
+ var matchTreeElement = new WebInspector.SearchResultTreeElement(matchObject);
+ resourceTreeElement.appendChild(matchTreeElement);
+ if (!this.contentTreeOutline.selectedTreeElement)
+ matchTreeElement.revealAndSelect(false, true);
+ }
+
+ updateEmptyContentPlaceholder.call(this);
+ }
+ }
+
+ DOMAgent.getSearchResults(searchId, 0, resultsCount, domSearchResults.bind(this));
+ }
+
+ if (window.DOMAgent)
+ WebInspector.domTreeManager.requestDocument();
+
+ if (window.PageAgent)
+ PageAgent.searchInResources(searchQuery, isCaseSensitive, isRegex, resourcesCallback.bind(this));
+
+ setTimeout(searchScripts.bind(this, WebInspector.debuggerManager.knownNonResourceScripts), 0);
+
+ if (window.DOMAgent) {
+ if ("_domSearchIdentifier" in this) {
+ DOMAgent.discardSearchResults(this._domSearchIdentifier);
+ delete this._domSearchIdentifier;
+ }
+
+ DOMAgent.performSearch(searchQuery, domCallback.bind(this));
+ }
+
+ // FIXME: Resource search should work in JSContext inspection.
+ // <https://webkit.org/b/131252> Web Inspector: JSContext inspection Resource search does not work
+ if (!window.DOMAgent && !window.PageAgent)
+ updateEmptyContentPlaceholderSoon.call(this);
+ }
+
+ // Private
+
+ _searchFieldChanged(event)
+ {
+ this.performSearch(event.target.value);
+ }
+
+ _searchFieldInput(event)
+ {
+ // If the search field is cleared, immediately clear the search results tree outline.
+ if (!event.target.value.length)
+ this.performSearch("");
+ }
+
+ _searchTreeElementForResource(resource)
+ {
+ var resourceTreeElement = this.contentTreeOutline.getCachedTreeElement(resource);
+ if (!resourceTreeElement) {
+ resourceTreeElement = new WebInspector.ResourceTreeElement(resource);
+ resourceTreeElement.hasChildren = true;
+ resourceTreeElement.expand();
+
+ this.contentTreeOutline.appendChild(resourceTreeElement);
+ }
+
+ return resourceTreeElement;
+ }
+
+ _searchTreeElementForScript(script)
+ {
+ var scriptTreeElement = this.contentTreeOutline.getCachedTreeElement(script);
+ if (!scriptTreeElement) {
+ scriptTreeElement = new WebInspector.ScriptTreeElement(script);
+ scriptTreeElement.hasChildren = true;
+ scriptTreeElement.expand();
+
+ this.contentTreeOutline.appendChild(scriptTreeElement);
+ }
+
+ return scriptTreeElement;
+ }
+
+ _mainResourceDidChange(event)
+ {
+ if (!event.target.isMainFrame())
+ return;
+
+ if (this._delayedSearchTimeout) {
+ clearTimeout(this._delayedSearchTimeout);
+ this._delayedSearchTimeout = undefined;
+ }
+
+ this.contentBrowser.contentViewContainer.closeAllContentViews();
+
+ if (this.visible)
+ this.focusSearchField();
+
+ // Only if the last page searched is the same as the current page.
+ var mainFrame = event.target;
+ if (this._lastSearchedPageSetting.value !== mainFrame.url.hash)
+ return;
+
+ function delayedWork()
+ {
+ this._delayedSearchTimeout = undefined;
+
+ // Search for whatever is in the input field. This was populated with the last used search term.
+ this.performSearch(this._inputElement.value);
+ }
+
+ // Perform the search on a delay so we have a better chance of finding subresource results.
+ this._delayedSearchTimeout = setTimeout(delayedWork.bind(this), 500);
+ }
+
+ _treeElementSelected(treeElement, selectedByUser)
+ {
+ if (treeElement instanceof WebInspector.FolderTreeElement)
+ return;
+
+ if (treeElement instanceof WebInspector.ResourceTreeElement || treeElement instanceof WebInspector.ScriptTreeElement) {
+ WebInspector.showRepresentedObject(treeElement.representedObject);
+ return;
+ }
+
+ console.assert(treeElement instanceof WebInspector.SearchResultTreeElement);
+ if (!(treeElement instanceof WebInspector.SearchResultTreeElement))
+ return;
+
+ if (treeElement.representedObject instanceof WebInspector.DOMSearchMatchObject)
+ WebInspector.showMainFrameDOMTree(treeElement.representedObject.domNode);
+ else if (treeElement.representedObject instanceof WebInspector.SourceCodeSearchMatchObject)
+ WebInspector.showOriginalOrFormattedSourceCodeTextRange(treeElement.representedObject.sourceCodeTextRange);
+ }
+};
Added: trunk/Source/WebInspectorUI/UserInterface/Views/SearchTabContentView.js (0 => 183339)
--- trunk/Source/WebInspectorUI/UserInterface/Views/SearchTabContentView.js (rev 0)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/SearchTabContentView.js 2015-04-26 01:26:06 UTC (rev 183339)
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+WebInspector.SearchTabContentView = function(identifier)
+{
+ var tabBarItem = new WebInspector.TabBarItem("Images/SearchResults.svg", WebInspector.UIString("Search"));
+ var detailsSidebarPanels = [WebInspector.resourceDetailsSidebarPanel, WebInspector.probeDetailsSidebarPanel,
+ WebInspector.domNodeDetailsSidebarPanel, WebInspector.cssStyleDetailsSidebarPanel];
+
+ if (WebInspector.layerTreeDetailsSidebarPanel)
+ detailsSidebarPanels.push(WebInspector.layerTreeDetailsSidebarPanel);
+
+ WebInspector.ContentBrowserTabContentView.call(this, identifier || "search", "search", tabBarItem, WebInspector.SearchSidebarPanel, detailsSidebarPanels);
+};
+
+WebInspector.SearchTabContentView.prototype = {
+ constructor: WebInspector.SearchTabContentView,
+ __proto__: WebInspector.ContentBrowserTabContentView.prototype,
+
+ // Public
+
+ get type()
+ {
+ return WebInspector.SearchTabContentView.Type;
+ },
+
+ shown: function()
+ {
+ WebInspector.ContentBrowserTabContentView.prototype.shown.call(this);
+
+ // Perform on a delay because the field might not be visible yet.
+ setTimeout(this.focusSearchField.bind(this));
+ },
+
+ closed: function()
+ {
+ WebInspector.ContentBrowserTabContentView.prototype.closed.call(this);
+
+ this.navigationSidebarPanel.closed();
+ },
+
+ canShowRepresentedObject: function(representedObject)
+ {
+ return representedObject instanceof WebInspector.Resource || representedObject instanceof WebInspector.DOMTree;
+ },
+
+ focusSearchField: function()
+ {
+ this.navigationSidebarPanel.focusSearchField();
+ },
+
+ performSearch: function(searchQuery)
+ {
+ this.navigationSidebarPanel.performSearch(searchQuery);
+ }
+};
+
+WebInspector.SearchTabContentView.Type = "search";
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/Toolbar.css (183338 => 183339)
--- trunk/Source/WebInspectorUI/UserInterface/Views/Toolbar.css 2015-04-26 01:25:22 UTC (rev 183338)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/Toolbar.css 2015-04-26 01:26:06 UTC (rev 183339)
@@ -106,7 +106,7 @@
}
.toolbar .item-section.center-right {
- justify-content: flex-end;
+ justify-content: center;
}
.toolbar .item-section.center {
@@ -115,9 +115,48 @@
.toolbar .item-section.right {
justify-content: flex-end;
+ padding-right: 4px;
}
.toolbar .item {
display: flex;
outline: none;
}
+
+.toolbar .search-bar {
+ width: 100%;
+ min-width: 100px;
+}
+
+.toolbar .search-bar > input[type="search"] {
+ width: 100%;
+
+ font-size: 12px;
+
+ border-radius: 4px;
+ background-color: rgb(252, 252, 252) !important;
+
+ border: 1px solid transparent;
+ border-top-color: white;
+
+ box-shadow: rgba(0, 0, 0, 0.15) 0 1px 0;
+
+ background-clip: initial;
+
+ margin: 4px;
+}
+
+.toolbar .search-bar > input[type="search"]:focus {
+ outline: auto 5px -webkit-focus-ring-color;
+ outline-offset: -2px
+}
+
+.toolbar .search-bar > input[type="search"]::-webkit-textfield-decoration-container {
+ margin-left: 4px;
+}
+
+body.window-inactive .toolbar .search-bar > input[type="search"] {
+ border: 1px solid rgb(220, 220, 220);
+ background-color: rgb(246, 246, 246);
+ box-shadow: none;
+}