Web Inspector: remove dependency from GoToLine dialog from Panel.
authorpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Oct 2011 09:17:08 +0000 (09:17 +0000)
committerpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Oct 2011 09:17:08 +0000 (09:17 +0000)
https://bugs.webkit.org/show_bug.cgi?id=69327

Reviewed by Yury Semikhatsky.

* inspector/front-end/GoToLineDialog.js:
(WebInspector.GoToLineDialog.install):
(WebInspector.GoToLineDialog._show):
* inspector/front-end/NetworkItemView.js:
(WebInspector.NetworkItemView.prototype._tabSelected):
(WebInspector.ResourceContentView.prototype.contentLoaded):
(WebInspector.ResourceContentView.prototype.canHighlightLine):
(WebInspector.ResourceContentView.prototype.highlightLine):
(set WebInspector):
* inspector/front-end/NetworkPanel.js:
(WebInspector.NetworkPanel.viewGetter):
(WebInspector.NetworkPanel):
* inspector/front-end/Panel.js:
(WebInspector.Panel.prototype.registerShortcut):
* inspector/front-end/ResourcesPanel.js:
(WebInspector.ResourcesPanel.viewGetter):
(WebInspector.ResourcesPanel):
(WebInspector.ResourcesPanel.prototype.showResource):
* inspector/front-end/ScriptsPanel.js:
(WebInspector.ScriptsPanel.viewGetter):
* inspector/front-end/SourceFrame.js:
(WebInspector.SourceFrame.prototype.canHighlightLine):
* inspector/front-end/TabbedPane.js:
(WebInspector.TabbedPane.prototype._hideTab):
(WebInspector.TabbedPane.prototype.canHighlightLine):
(WebInspector.TabbedPane.prototype.highlightLine):
* inspector/front-end/View.js:
(WebInspector.View.prototype.canHighlightLine):
(WebInspector.View.prototype.highlightLine):

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

Source/WebCore/ChangeLog
Source/WebCore/inspector/front-end/GoToLineDialog.js
Source/WebCore/inspector/front-end/NetworkItemView.js
Source/WebCore/inspector/front-end/NetworkPanel.js
Source/WebCore/inspector/front-end/Panel.js
Source/WebCore/inspector/front-end/ResourcesPanel.js
Source/WebCore/inspector/front-end/ScriptsPanel.js
Source/WebCore/inspector/front-end/SourceFrame.js
Source/WebCore/inspector/front-end/TabbedPane.js
Source/WebCore/inspector/front-end/View.js

index 83a76bd..d223d75 100644 (file)
@@ -1,3 +1,40 @@
+2011-10-04  Pavel Feldman  <pfeldman@google.com>
+
+        Web Inspector: remove dependency from GoToLine dialog from Panel.
+        https://bugs.webkit.org/show_bug.cgi?id=69327
+
+        Reviewed by Yury Semikhatsky.
+
+        * inspector/front-end/GoToLineDialog.js:
+        (WebInspector.GoToLineDialog.install):
+        (WebInspector.GoToLineDialog._show):
+        * inspector/front-end/NetworkItemView.js:
+        (WebInspector.NetworkItemView.prototype._tabSelected):
+        (WebInspector.ResourceContentView.prototype.contentLoaded):
+        (WebInspector.ResourceContentView.prototype.canHighlightLine):
+        (WebInspector.ResourceContentView.prototype.highlightLine):
+        (set WebInspector):
+        * inspector/front-end/NetworkPanel.js:
+        (WebInspector.NetworkPanel.viewGetter):
+        (WebInspector.NetworkPanel):
+        * inspector/front-end/Panel.js:
+        (WebInspector.Panel.prototype.registerShortcut):
+        * inspector/front-end/ResourcesPanel.js:
+        (WebInspector.ResourcesPanel.viewGetter):
+        (WebInspector.ResourcesPanel):
+        (WebInspector.ResourcesPanel.prototype.showResource):
+        * inspector/front-end/ScriptsPanel.js:
+        (WebInspector.ScriptsPanel.viewGetter):
+        * inspector/front-end/SourceFrame.js:
+        (WebInspector.SourceFrame.prototype.canHighlightLine):
+        * inspector/front-end/TabbedPane.js:
+        (WebInspector.TabbedPane.prototype._hideTab):
+        (WebInspector.TabbedPane.prototype.canHighlightLine):
+        (WebInspector.TabbedPane.prototype.highlightLine):
+        * inspector/front-end/View.js:
+        (WebInspector.View.prototype.canHighlightLine):
+        (WebInspector.View.prototype.highlightLine):
+
 2011-10-04  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r96491.
index eebd43a..f9e9409 100644 (file)
@@ -66,9 +66,22 @@ WebInspector.GoToLineDialog = function(view)
     this._input.select();
 }
 
-WebInspector.GoToLineDialog.show = function(sourceView)
+WebInspector.GoToLineDialog.install = function(panel, viewGetter)
 {
-    if (!sourceView || typeof sourceView.highlightLine !== "function")
+    function showGoToLineDialog()
+    {
+         var view = viewGetter();
+         if (view)
+             WebInspector.GoToLineDialog._show(view);
+    }
+
+    var goToLineShortcut = WebInspector.GoToLineDialog.createShortcut();
+    panel.registerShortcut(goToLineShortcut.key, showGoToLineDialog);
+}
+
+WebInspector.GoToLineDialog._show = function(sourceView)
+{
+    if (!sourceView || !sourceView.canHighlightLine())
         return;
     if (this._instance)
         return;
index 578398a..6efb1ae 100644 (file)
@@ -79,15 +79,6 @@ WebInspector.NetworkItemView.prototype = {
     {
         if (event.data.isUserGesture)
             WebInspector.settings.resourceViewTab.set(event.data.tabId);
-        this._installHighlightSupport(event.data.view);
-    },
-
-    _installHighlightSupport: function(view)
-    {
-        if (typeof view.highlightLine === "function")
-            this.highlightLine = view.highlightLine.bind(view);
-        else
-            delete this.highlightLine;
     }
 }
 
@@ -145,6 +136,17 @@ WebInspector.ResourceContentView.prototype = {
     contentLoaded: function()
     {
         // Should be implemented by subclasses.
+    },
+
+    canHighlightLine: function()
+    {
+        return this._innerView && this._innerView.canHighlightLine();
+    },
+
+    highlightLine: function(line)
+    {
+        if (this.canHighlightLine())
+            this._innerView.highlightLine(line);
     }
 }
 
index 5bbb59b..3aa1f76 100644 (file)
@@ -1300,7 +1300,11 @@ WebInspector.NetworkPanel = function()
     this._closeButtonElement.addEventListener("click", this._toggleGridMode.bind(this), false);
     this._viewsContainerElement.appendChild(this._closeButtonElement);
 
-    this.registerShortcuts();
+    function viewGetter()
+    {
+        return this.visibleView;
+    }
+    WebInspector.GoToLineDialog.install(this, viewGetter.bind(this));
 }
 
 WebInspector.NetworkPanel.prototype = {
index 0cc5d17..f30cff5 100644 (file)
@@ -407,24 +407,9 @@ WebInspector.Panel.prototype = {
         }
     },
 
-    registerShortcuts: function(shortcuts)
-    {
-        this._shortcuts = shortcuts || {};
-        var goToLineShortcut = WebInspector.GoToLineDialog.createShortcut();
-        this._shortcuts[goToLineShortcut.key] = this._showGoToLineDialog.bind(this);
-    },
-
     registerShortcut: function(key, handler)
     {
         this._shortcuts[key] = handler;
-    },
-
-    _showGoToLineDialog: function(e)
-    {
-         var view = this.visibleView;
-         WebInspector.GoToLineDialog.show(view);
-         if (view)
-             WebInspector.GoToLineDialog.show(view);
     }
 }
 
index 2a88c1e..cd21a0b 100644 (file)
@@ -75,7 +75,11 @@ WebInspector.ResourcesPanel = function(database)
     this.sidebarElement.addEventListener("mousemove", this._onmousemove.bind(this), false);
     this.sidebarElement.addEventListener("mouseout", this._onmouseout.bind(this), false);
 
-    this.registerShortcuts();
+    function viewGetter()
+    {
+        return this.visibleView;
+    }
+    WebInspector.GoToLineDialog.install(this, viewGetter.bind(this));
 
     WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.OnLoad, this._onLoadEventFired, this);
 }
@@ -339,7 +343,7 @@ WebInspector.ResourcesPanel.prototype = {
 
         if (line !== undefined) {
             var view = this._resourceViewForResource(resource);
-            if (view.highlightLine)
+            if (view.canHighlightLine())
                 view.highlightLine(line);
         }
         return true;
index 6115593..c850b72 100644 (file)
@@ -32,7 +32,11 @@ WebInspector.ScriptsPanel = function(presentationModel)
 
     this._presentationModel = presentationModel;
 
-    this.registerShortcuts();
+    function viewGetter()
+    {
+        return this.visibleView;
+    }
+    WebInspector.GoToLineDialog.install(this, viewGetter.bind(this));
 
     this.topStatusBar = document.createElement("div");
     this.topStatusBar.className = "status-bar";
index 07b1911..d6d24b0 100644 (file)
@@ -163,6 +163,11 @@ WebInspector.SourceFrame.prototype = {
         return this._textModel;
     },
 
+    canHighlightLine: function(line)
+    {
+        return true;
+    },
+
     highlightLine: function(line)
     {
         if (this.loaded)
index 4fef5d6..c3f4fd0 100644 (file)
@@ -83,6 +83,17 @@ WebInspector.TabbedPane.prototype = {
     {
         tab.tabElement.removeStyleClass("selected");
         tab.view.visible = false;
+    },
+
+    canHighlightLine: function()
+    {
+        return this._currentTab && this._currentTab.view && this._currentTab.view.canHighlightLine();
+    },
+
+    highlightLine: function(line)
+    {
+        if (this.canHighlightLine())
+            this._currentTab.view.highlightLine(line);
     }
 }
 
index 88ff7c6..22292d1 100644 (file)
@@ -159,6 +159,15 @@ WebInspector.View.prototype = {
     {
     },
 
+    canHighlightLine: function()
+    {
+        return false;
+    },
+
+    highlightLine: function(line)
+    {
+    },
+
     doResize: function()
     {
         this.dispatchToSelfAndVisibleChildren("onResize");