Commit e4771a06 authored by pfeldman@chromium.org's avatar pfeldman@chromium.org
Browse files

Web Inspector: extract script navigator overlay logic into the scripts navigator controller.

https://bugs.webkit.org/show_bug.cgi?id=84244

Reviewed by Vsevolod Vlasov.

Overlay logic is well separable from the scripts panel and does not belong there.
Extracting it into a separate class.

* inspector/front-end/ScriptsNavigator.js:
(WebInspector.ScriptsNavigatorController.prototype.wasShown):
(WebInspector.ScriptsNavigatorController.prototype._createNavigatorControlButton):
(WebInspector.ScriptsNavigatorController.prototype._escDownWhileNavigatorOverlayOpen):
(WebInspector.ScriptsNavigatorController.prototype._toggleNavigator):
(WebInspector.ScriptsNavigatorController.prototype._hidePinnedNavigator):
(WebInspector.ScriptsNavigatorController.prototype.set _pinNavigator):
(WebInspector.ScriptsNavigatorController.prototype.set showNavigatorOverlay):
(WebInspector.ScriptsNavigatorController.prototype.hideNavigatorOverlay):
(WebInspector.ScriptsNavigatorController.prototype._navigatorOverlayWasShown):
* inspector/front-end/ScriptsPanel.js:
(WebInspector.ScriptsPanel.prototype.wasShown):
(WebInspector.ScriptsPanel.prototype._editorClosed):
(WebInspector.ScriptsPanel.prototype._editorSelected):
(WebInspector.ScriptsPanel.prototype._scriptSelected):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@114532 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent eb66fc4a
2012-04-18 Pavel Feldman <pfeldman@chromium.org>
Web Inspector: extract script navigator overlay logic into the scripts navigator controller.
https://bugs.webkit.org/show_bug.cgi?id=84244
Reviewed by Vsevolod Vlasov.
Overlay logic is well separable from the scripts panel and does not belong there.
Extracting it into a separate class.
* inspector/front-end/ScriptsNavigator.js:
(WebInspector.ScriptsNavigatorController.prototype.wasShown):
(WebInspector.ScriptsNavigatorController.prototype._createNavigatorControlButton):
(WebInspector.ScriptsNavigatorController.prototype._escDownWhileNavigatorOverlayOpen):
(WebInspector.ScriptsNavigatorController.prototype._toggleNavigator):
(WebInspector.ScriptsNavigatorController.prototype._hidePinnedNavigator):
(WebInspector.ScriptsNavigatorController.prototype.set _pinNavigator):
(WebInspector.ScriptsNavigatorController.prototype.set showNavigatorOverlay):
(WebInspector.ScriptsNavigatorController.prototype.hideNavigatorOverlay):
(WebInspector.ScriptsNavigatorController.prototype._navigatorOverlayWasShown):
* inspector/front-end/ScriptsPanel.js:
(WebInspector.ScriptsPanel.prototype.wasShown):
(WebInspector.ScriptsPanel.prototype._editorClosed):
(WebInspector.ScriptsPanel.prototype._editorSelected):
(WebInspector.ScriptsPanel.prototype._scriptSelected):
2012-04-18 Sheriff Bot <webkit.review.bot@gmail.com>
 
Unreviewed, rolling out r114497.
......@@ -764,3 +764,154 @@ WebInspector.NavigatorScriptTreeElement.prototype = {
}
WebInspector.NavigatorScriptTreeElement.prototype.__proto__ = WebInspector.BaseNavigatorTreeElement.prototype;
/**
* @constructor
* @param {WebInspector.Panel} panel
* @param {WebInspector.SplitView} editorView
* @param {WebInspector.ScriptsNavigator} navigator
* @param {WebInspector.TabbedEditorContainer} editorContainer
*/
WebInspector.ScriptsNavigatorController = function(panel, editorView, navigator, editorContainer)
{
this._panel = panel;
this._editorView = editorView;
this._navigator = navigator;
this._editorContainer = editorContainer;
this._navigatorSidebarResizeWidgetElement = document.createElement("div");
this._navigatorSidebarResizeWidgetElement.addStyleClass("scripts-navigator-resizer-widget");
this._editorView.installResizer(this._navigatorSidebarResizeWidgetElement);
this._navigator.view.element.appendChild(this._navigatorSidebarResizeWidgetElement);
this._navigatorShowHideButton = this._createNavigatorControlButton(WebInspector.UIString("Show scripts navigator"), "scripts-navigator-show-hide-button", this._toggleNavigator.bind(this));
this._navigatorShowHideButton.addStyleClass("toggled-on");
this._navigatorShowHideButton.title = WebInspector.UIString("Hide scripts navigator");
this._editorView.element.appendChild(this._navigatorShowHideButton);
this._navigatorPinButton = this._createNavigatorControlButton(WebInspector.UIString("Pin scripts navigator"), "scripts-navigator-pin-button", this._pinNavigator.bind(this));
this._navigatorPinButton.addStyleClass("hidden");
this._navigator.view.element.appendChild(this._navigatorPinButton);
WebInspector.settings.navigatorHidden = WebInspector.settings.createSetting("navigatorHidden", true);
if (WebInspector.settings.navigatorHidden.get())
this._toggleNavigator();
}
WebInspector.ScriptsNavigatorController.prototype = {
wasShown: function()
{
window.setTimeout(this._maybeShowNavigatorOverlay.bind(this), 0);
},
_createNavigatorControlButton: function(title, id, listener)
{
var button = document.createElement("button");
button.title = title;
button.id = id;
button.addStyleClass("scripts-navigator-control-button");
button.addEventListener("click", listener, false);
button.createChild("div", "glyph");
return button;
},
_escDownWhileNavigatorOverlayOpen: function(event)
{
this.hideNavigatorOverlay();
},
_maybeShowNavigatorOverlay: function()
{
if (WebInspector.settings.navigatorHidden.get() && !WebInspector.settings.navigatorWasOnceHidden.get())
this.showNavigatorOverlay();
},
_toggleNavigator: function()
{
if (this._navigatorOverlayShown)
this.hideNavigatorOverlay();
else if (this._navigatorHidden)
this.showNavigatorOverlay();
else
this._hidePinnedNavigator();
},
_hidePinnedNavigator: function()
{
this._navigatorHidden = true;
this._navigatorShowHideButton.removeStyleClass("toggled-on");
this._navigatorShowHideButton.title = WebInspector.UIString("Show scripts navigator");
this._editorContainer.element.addStyleClass("navigator-hidden");
this._navigatorSidebarResizeWidgetElement.addStyleClass("hidden");
this._navigatorPinButton.removeStyleClass("hidden");
this._editorView.hideSidebarElement();
this._navigator.view.detach();
WebInspector.settings.navigatorHidden.set(true);
},
_pinNavigator: function()
{
delete this._navigatorHidden;
this.hideNavigatorOverlay();
this._navigatorPinButton.addStyleClass("hidden");
this._navigatorShowHideButton.addStyleClass("toggled-on");
this._navigatorShowHideButton.title = WebInspector.UIString("Hide scripts navigator");
this._editorContainer.element.removeStyleClass("navigator-hidden");
this._navigatorSidebarResizeWidgetElement.removeStyleClass("hidden");
this._editorView.showSidebarElement();
this._navigator.show(this._editorView.sidebarElement);
this._navigator.focus();
WebInspector.settings.navigatorHidden.set(false);
},
showNavigatorOverlay: function()
{
if (this._navigatorOverlayShown)
return;
this._navigatorOverlayShown = true;
this._sidebarOverlay = new WebInspector.SidebarOverlay(this._navigator.view, "scriptsPanelNavigatorOverlayWidth", Preferences.minScriptsSidebarWidth);
this._sidebarOverlay.addEventListener(WebInspector.SidebarOverlay.EventTypes.WasShown, this._navigatorOverlayWasShown, this);
this._sidebarOverlay.addEventListener(WebInspector.SidebarOverlay.EventTypes.WillHide, this._navigatorOverlayWillHide, this);
var navigatorOverlayResizeWidgetElement = document.createElement("div");
navigatorOverlayResizeWidgetElement.addStyleClass("scripts-navigator-resizer-widget");
this._sidebarOverlay.resizerWidgetElement = navigatorOverlayResizeWidgetElement;
this._sidebarOverlay.show(this._editorView.element);
},
hideNavigatorOverlay: function()
{
if (!this._navigatorOverlayShown)
return;
this._sidebarOverlay.hide();
if (this._editorContainer.visibleView)
this._editorContainer.visibleView.focus();
},
_navigatorOverlayWasShown: function(event)
{
this._navigator.view.element.appendChild(this._navigatorShowHideButton);
this._navigatorShowHideButton.addStyleClass("toggled-on");
this._navigatorShowHideButton.title = WebInspector.UIString("Hide scripts navigator");
this._navigator.focus();
this._panel.registerShortcut(WebInspector.KeyboardShortcut.Keys.Esc.code, this._escDownWhileNavigatorOverlayOpen.bind(this));
},
_navigatorOverlayWillHide: function(event)
{
delete this._navigatorOverlayShown;
WebInspector.settings.navigatorWasOnceHidden.set(true);
this._editorView.element.appendChild(this._navigatorShowHideButton);
this._navigatorShowHideButton.removeStyleClass("toggled-on");
this._navigatorShowHideButton.title = WebInspector.UIString("Show scripts navigator");
this._panel.unregisterShortcut(WebInspector.KeyboardShortcut.Keys.Esc.code);
}
}
......@@ -73,17 +73,13 @@ WebInspector.ScriptsPanel = function(presentationModel)
this.editorView.show(this.splitView.mainElement);
this._navigator = new WebInspector.ScriptsNavigator();
this._navigatorView = this._navigator.view;
this._navigator.show(this.editorView.sidebarElement);
this._editorContainer = new WebInspector.TabbedEditorContainer(this);
this._editorContainer.show(this.editorView.mainElement);
WebInspector.OpenResourceDialog.install(this, this._presentationModel, this.editorView.mainElement);
this._createNavigatorControls();
WebInspector.settings.navigatorHidden = WebInspector.settings.createSetting("navigatorHidden", true);
if (WebInspector.settings.navigatorHidden.get())
this._toggleNavigator();
this._navigatorController = new WebInspector.ScriptsNavigatorController(this, this.editorView, this._navigator, this._editorContainer);
this._navigator.addEventListener(WebInspector.ScriptsNavigator.Events.ScriptSelected, this._scriptSelected, this);
this._editorContainer.addEventListener(WebInspector.TabbedEditorContainer.Events.EditorSelected, this._editorSelected, this);
......@@ -215,7 +211,7 @@ WebInspector.ScriptsPanel.prototype = {
this._debugSidebarContentsElement.insertBefore(this.sidebarPanes.domBreakpoints.element, this.sidebarPanes.xhrBreakpoints.element);
this.sidebarPanes.watchExpressions.show();
window.setTimeout(this._maybeShowNavigatorOverlay.bind(this), 0);
this._navigatorController.wasShown();
},
_didBuildOutlineChunk: function(event)
......@@ -621,7 +617,7 @@ WebInspector.ScriptsPanel.prototype = {
_editorClosed: function(event)
{
this._hideNavigatorOverlay();
this._navigatorController.hideNavigatorOverlay();
var uiSourceCode = /** @type {WebInspector.UISourceCode} */ event.data;
if (this._currentUISourceCode === uiSourceCode)
......@@ -635,14 +631,14 @@ WebInspector.ScriptsPanel.prototype = {
{
var uiSourceCode = /** @type {WebInspector.UISourceCode} */ event.data;
this._showFile(uiSourceCode);
this._hideNavigatorOverlay();
this._navigatorController.hideNavigatorOverlay();
},
_scriptSelected: function(event)
{
var uiSourceCode = /** @type {WebInspector.UISourceCode} */ event.data.uiSourceCode;
var sourceFrame = this._showFile(uiSourceCode);
this._hideNavigatorOverlay();
this._navigatorController.hideNavigatorOverlay();
if (sourceFrame && event.data.focusSource)
sourceFrame.focus();
},
......@@ -902,134 +898,6 @@ WebInspector.ScriptsPanel.prototype = {
return debugToolbar;
},
_createNavigatorControls: function()
{
this._navigatorSidebarResizeWidgetElement = document.createElement("div");
this._navigatorSidebarResizeWidgetElement.addStyleClass("scripts-navigator-resizer-widget");
this.editorView.installResizer(this._navigatorSidebarResizeWidgetElement);
this._navigatorView.element.appendChild(this._navigatorSidebarResizeWidgetElement);
this._navigatorShowHideButton = this._createNavigatorControlButton(WebInspector.UIString("Show scripts navigator"), "scripts-navigator-show-hide-button", this._toggleNavigator.bind(this));
this._navigatorShowHideButton.addStyleClass("toggled-on");
this._navigatorShowHideButton.title = WebInspector.UIString("Hide scripts navigator");
this.editorView.element.appendChild(this._navigatorShowHideButton);
this._navigatorPinButton = this._createNavigatorControlButton(WebInspector.UIString("Pin scripts navigator"), "scripts-navigator-pin-button", this._pinNavigator.bind(this));
this._navigatorPinButton.addStyleClass("hidden");
this._navigatorView.element.appendChild(this._navigatorPinButton);
},
_createNavigatorControlButton: function(title, id, listener)
{
var button = document.createElement("button");
button.title = title;
button.id = id;
button.addStyleClass("scripts-navigator-control-button");
button.addEventListener("click", listener, false);
button.createChild("div", "glyph");
return button;
},
_escDownWhileNavigatorOverlayOpen: function(event)
{
this._hideNavigatorOverlay();
},
_maybeShowNavigatorOverlay: function()
{
if (this._navigator && WebInspector.settings.navigatorHidden.get() && !WebInspector.settings.navigatorWasOnceHidden.get())
this._showNavigatorOverlay();
},
_toggleNavigator: function()
{
if (this._navigatorOverlayShown)
this._hideNavigatorOverlay();
else if (this._navigatorHidden)
this._showNavigatorOverlay();
else
this._hidePinnedNavigator();
},
_hidePinnedNavigator: function()
{
this._navigatorHidden = true;
this._navigatorShowHideButton.removeStyleClass("toggled-on");
this._navigatorShowHideButton.title = WebInspector.UIString("Show scripts navigator");
this._editorContainer.element.addStyleClass("navigator-hidden");
this._navigatorSidebarResizeWidgetElement.addStyleClass("hidden");
this._navigatorPinButton.removeStyleClass("hidden");
this.editorView.hideSidebarElement();
this._navigatorView.detach();
WebInspector.settings.navigatorHidden.set(true);
},
_pinNavigator: function()
{
delete this._navigatorHidden;
this._hideNavigatorOverlay();
this._navigatorPinButton.addStyleClass("hidden");
this._navigatorShowHideButton.addStyleClass("toggled-on");
this._navigatorShowHideButton.title = WebInspector.UIString("Hide scripts navigator");
this._editorContainer.element.removeStyleClass("navigator-hidden");
this._navigatorSidebarResizeWidgetElement.removeStyleClass("hidden");
this.editorView.showSidebarElement();
this._navigator.show(this.editorView.sidebarElement);
this._navigator.focus();
WebInspector.settings.navigatorHidden.set(false);
},
_showNavigatorOverlay: function()
{
if (this._navigatorOverlayShown)
return;
this._navigatorOverlayShown = true;
this._sidebarOverlay = new WebInspector.SidebarOverlay(this._navigatorView, "scriptsPanelNavigatorOverlayWidth", Preferences.minScriptsSidebarWidth);
this._sidebarOverlay.addEventListener(WebInspector.SidebarOverlay.EventTypes.WasShown, this._navigatorOverlayWasShown, this);
this._sidebarOverlay.addEventListener(WebInspector.SidebarOverlay.EventTypes.WillHide, this._navigatorOverlayWillHide, this);
var navigatorOverlayResizeWidgetElement = document.createElement("div");
navigatorOverlayResizeWidgetElement.addStyleClass("scripts-navigator-resizer-widget");
this._sidebarOverlay.resizerWidgetElement = navigatorOverlayResizeWidgetElement;
this._sidebarOverlay.show(this.editorView.element);
},
_hideNavigatorOverlay: function()
{
if (!this._navigatorOverlayShown)
return;
this._sidebarOverlay.hide();
if (this.visibleView)
this.visibleView.focus();
},
_navigatorOverlayWasShown: function(event)
{
this._navigatorView.element.appendChild(this._navigatorShowHideButton);
this._navigatorShowHideButton.addStyleClass("toggled-on");
this._navigatorShowHideButton.title = WebInspector.UIString("Hide scripts navigator");
this._navigator.focus();
this.registerShortcut(WebInspector.KeyboardShortcut.Keys.Esc.code, this._escDownWhileNavigatorOverlayOpen.bind(this));
},
_navigatorOverlayWillHide: function(event)
{
delete this._navigatorOverlayShown;
WebInspector.settings.navigatorWasOnceHidden.set(true);
this.editorView.element.appendChild(this._navigatorShowHideButton);
this._navigatorShowHideButton.removeStyleClass("toggled-on");
this._navigatorShowHideButton.title = WebInspector.UIString("Show scripts navigator");
this.unregisterShortcut(WebInspector.KeyboardShortcut.Keys.Esc.code);
},
_createButtonAndRegisterShortcuts: function(buttonId, buttonTitle, handler, shortcuts, shortcutDescription)
{
var button = document.createElement("button");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment