[DevTools] Remove relativeToElement from Dialog.

BUG=none

Review URL: https://codereview.chromium.org/1356363002

git-svn-id: svn://svn.chromium.org/blink/trunk@202664 bbb929c8-8fbe-4397-9dbb-9b2b20218538
diff --git a/Source/devtools/front_end/components_lazy/FilmStripView.js b/Source/devtools/front_end/components_lazy/FilmStripView.js
index 95dbfa1..a13efaa 100644
--- a/Source/devtools/front_end/components_lazy/FilmStripView.js
+++ b/Source/devtools/front_end/components_lazy/FilmStripView.js
@@ -244,7 +244,7 @@
     footerElement.createChild("div", "flex-auto");
 
     this._contentElement.addEventListener("keydown", this._keyDown.bind(this), false);
-    this._render().then(WebInspector.Dialog.show.bind(null, null, this));
+    this._render().then(WebInspector.Dialog.show.bind(null, this));
 }
 
 WebInspector.FilmStripView.DialogDelegate.prototype = {
diff --git a/Source/devtools/front_end/devices/DevicesDialog.js b/Source/devtools/front_end/devices/DevicesDialog.js
index f504111..da5e940 100644
--- a/Source/devtools/front_end/devices/DevicesDialog.js
+++ b/Source/devtools/front_end/devices/DevicesDialog.js
@@ -26,7 +26,7 @@
 {
     if (!WebInspector.DevicesDialog._instance)
         WebInspector.DevicesDialog._instance = new WebInspector.DevicesDialog();
-    WebInspector.Dialog.show(null, WebInspector.DevicesDialog._instance);
+    WebInspector.Dialog.show(WebInspector.DevicesDialog._instance);
 }
 
 WebInspector.DevicesDialog.prototype = {
diff --git a/Source/devtools/front_end/settings/EditFileSystemDialog.js b/Source/devtools/front_end/settings/EditFileSystemDialog.js
index 6def2a4..7b7de4e 100644
--- a/Source/devtools/front_end/settings/EditFileSystemDialog.js
+++ b/Source/devtools/front_end/settings/EditFileSystemDialog.js
@@ -91,10 +91,10 @@
     this._hasMappingChanges = false;
 }
 
-WebInspector.EditFileSystemDialog.show = function(element, fileSystemPath)
+WebInspector.EditFileSystemDialog.show = function(fileSystemPath)
 {
     var dialog = new WebInspector.EditFileSystemDialog(fileSystemPath);
-    WebInspector.Dialog.show(element, dialog);
+    WebInspector.Dialog.show(dialog);
     var glassPane = dialog.element.ownerDocument.getElementById("glass-pane");
     glassPane.classList.add("settings-glass-pane");
 }
@@ -113,29 +113,29 @@
 
     _resize: function()
     {
-        if (!this._dialogElement || !this._relativeToElement)
+        if (!this._dialogElement || !this._container)
             return;
 
         const minWidth = 200;
         const minHeight = 150;
-        var maxHeight = this._relativeToElement.offsetHeight - 10;
+        var maxHeight = this._container.offsetHeight - 10;
         maxHeight = Math.max(minHeight, maxHeight);
-        var maxWidth = Math.min(540, this._relativeToElement.offsetWidth - 10);
+        var maxWidth = Math.min(540, this._container.offsetWidth - 10);
         maxWidth = Math.max(minWidth, maxWidth);
         this._dialogElement.style.maxHeight = maxHeight + "px";
         this._dialogElement.style.width = maxWidth + "px";
 
-        WebInspector.DialogDelegate.prototype.position(this._dialogElement, this._relativeToElement);
+        WebInspector.DialogDelegate.prototype.position(this._dialogElement, this._container);
     },
 
     /**
      * @override
      * @param {!Element} element
-     * @param {!Element} relativeToElement
+     * @param {!Element} container
      */
-    position: function(element, relativeToElement)
+    position: function(element, container)
     {
-        this._relativeToElement = relativeToElement;
+        this._container = container;
         this._resize();
     },
 
diff --git a/Source/devtools/front_end/settings/FrameworkBlackboxDialog.js b/Source/devtools/front_end/settings/FrameworkBlackboxDialog.js
index 17e7b16..c7a581b 100644
--- a/Source/devtools/front_end/settings/FrameworkBlackboxDialog.js
+++ b/Source/devtools/front_end/settings/FrameworkBlackboxDialog.js
@@ -52,10 +52,10 @@
     this.element.tabIndex = 0;
 }
 
-WebInspector.FrameworkBlackboxDialog.show = function(element)
+WebInspector.FrameworkBlackboxDialog.show = function()
 {
     var dialog = new WebInspector.FrameworkBlackboxDialog();
-    WebInspector.Dialog.show(element, dialog);
+    WebInspector.Dialog.show(dialog);
     var glassPane = dialog.element.ownerDocument.getElementById("glass-pane");
     glassPane.classList.add("settings-glass-pane");
 }
@@ -74,29 +74,29 @@
 
     _resize: function()
     {
-        if (!this._dialogElement || !this._relativeToElement)
+        if (!this._dialogElement || !this._container)
             return;
 
         const minWidth = 200;
         const minHeight = 150;
-        var maxHeight = this._relativeToElement.offsetHeight - 10;
+        var maxHeight = this._container.offsetHeight - 10;
         maxHeight = Math.max(minHeight, maxHeight);
-        var maxWidth = Math.min(540, this._relativeToElement.offsetWidth - 10);
+        var maxWidth = Math.min(540, this._container.offsetWidth - 10);
         maxWidth = Math.max(minWidth, maxWidth);
         this._dialogElement.style.maxHeight = maxHeight + "px";
         this._dialogElement.style.width = maxWidth + "px";
 
-        WebInspector.DialogDelegate.prototype.position(this._dialogElement, this._relativeToElement);
+        WebInspector.DialogDelegate.prototype.position(this._dialogElement, this._container);
     },
 
     /**
      * @override
      * @param {!Element} element
-     * @param {!Element} relativeToElement
+     * @param {!Element} container
      */
-    position: function(element, relativeToElement)
+    position: function(element, container)
     {
-        this._relativeToElement = relativeToElement;
+        this._container = container;
         this._resize();
     },
 
diff --git a/Source/devtools/front_end/settings/SettingsScreen.js b/Source/devtools/front_end/settings/SettingsScreen.js
index fceee6e..8184ec8 100644
--- a/Source/devtools/front_end/settings/SettingsScreen.js
+++ b/Source/devtools/front_end/settings/SettingsScreen.js
@@ -325,7 +325,7 @@
 
     _onManageButtonClick: function()
     {
-        WebInspector.FrameworkBlackboxDialog.show(WebInspector.inspectorView.element);
+        WebInspector.FrameworkBlackboxDialog.show();
     }
 }
 
@@ -424,7 +424,7 @@
      */
     _editFileSystem: function(id)
     {
-        WebInspector.EditFileSystemDialog.show(WebInspector.inspectorView.element, id);
+        WebInspector.EditFileSystemDialog.show(id);
     },
 
     /**
diff --git a/Source/devtools/front_end/source_frame/GoToLineDialog.js b/Source/devtools/front_end/source_frame/GoToLineDialog.js
index 949542e..72c786b 100644
--- a/Source/devtools/front_end/source_frame/GoToLineDialog.js
+++ b/Source/devtools/front_end/source_frame/GoToLineDialog.js
@@ -70,7 +70,7 @@
     var sourceFrame = sourceFrameGetter();
     if (!sourceFrame)
         return false;
-    WebInspector.Dialog.show(sourceFrame.element, new WebInspector.GoToLineDialog(sourceFrame));
+    WebInspector.Dialog.show(new WebInspector.GoToLineDialog(sourceFrame));
     return true;
 }
 
diff --git a/Source/devtools/front_end/sources/AddSourceMapURLDialog.js b/Source/devtools/front_end/sources/AddSourceMapURLDialog.js
index 9403e85..9688cc5 100644
--- a/Source/devtools/front_end/sources/AddSourceMapURLDialog.js
+++ b/Source/devtools/front_end/sources/AddSourceMapURLDialog.js
@@ -17,19 +17,18 @@
     this._input.setAttribute("type", "text");
 
     this._goButton = this.element.createChild("button");
-    this._goButton.textContent = WebInspector.UIString("Go");
+    this._goButton.textContent = WebInspector.UIString("Add");
     this._goButton.addEventListener("click", this._onGoClick.bind(this), false);
 
     this._callback = callback;
 }
 
 /**
- * @param {!Element} element
  * @param {function(string)} callback
  */
-WebInspector.AddSourceMapURLDialog.show = function(element, callback)
+WebInspector.AddSourceMapURLDialog.show = function(callback)
 {
-    WebInspector.Dialog.show(element, new WebInspector.AddSourceMapURLDialog(callback));
+    WebInspector.Dialog.show(new WebInspector.AddSourceMapURLDialog(callback));
 }
 
 WebInspector.AddSourceMapURLDialog.prototype = {
diff --git a/Source/devtools/front_end/sources/FilteredItemSelectionDialog.js b/Source/devtools/front_end/sources/FilteredItemSelectionDialog.js
index 4d88611..562322d 100644
--- a/Source/devtools/front_end/sources/FilteredItemSelectionDialog.js
+++ b/Source/devtools/front_end/sources/FilteredItemSelectionDialog.js
@@ -64,23 +64,22 @@
     /**
      * @override
      * @param {!Element} element
-     * @param {!Element} relativeToElement
+     * @param {!Element} container
      */
-    position: function(element, relativeToElement)
+    position: function(element, container)
     {
         const shadow = 10;
         const shadowPadding = 20; // shadow + padding
-        var container = WebInspector.Dialog.modalHostView().element;
-        var preferredWidth = Math.max(relativeToElement.offsetWidth * 2 / 3, 500);
+        var preferredWidth = Math.max(container.offsetWidth * 2 / 3, 500);
         var width = Math.min(preferredWidth, container.offsetWidth - 2 * shadowPadding);
-        var preferredHeight = Math.max(relativeToElement.offsetHeight * 2 / 3, 204);
+        var preferredHeight = Math.max(container.offsetHeight * 2 / 3, 204);
         var height = Math.min(preferredHeight, container.offsetHeight - 2 * shadowPadding);
 
         this.element.style.width = width + "px";
-        var box = relativeToElement.boxInWindow(window).relativeToElement(container);
-        var positionX = box.x + Math.max((box.width - width - 2 * shadowPadding) / 2, shadow);
+        var box = container.boxInWindow(window);
+        var positionX = Math.max((box.width - width - 2 * shadowPadding) / 2, shadow);
         positionX = Math.max(shadow, Math.min(container.offsetWidth - width - 2 * shadowPadding, positionX));
-        var positionY = box.y + Math.max((box.height - height - 2 * shadowPadding) / 2, shadow);
+        var positionY = Math.max((box.height - height - 2 * shadowPadding) / 2, shadow);
         positionY = Math.max(shadow, Math.min(container.offsetHeight - height - 2 * shadowPadding, positionY));
         element.positionAt(positionX, positionY, container);
         this._dialogHeight = height;
@@ -537,16 +536,15 @@
 }
 
 /**
- * @param {!WebInspector.Widget} view
  * @param {!WebInspector.UISourceCode} uiSourceCode
  * @param {function(number, number)} selectItemCallback
  */
-WebInspector.JavaScriptOutlineDialog.show = function(view, uiSourceCode, selectItemCallback)
+WebInspector.JavaScriptOutlineDialog.show = function(uiSourceCode, selectItemCallback)
 {
     if (WebInspector.Dialog.currentInstance())
         return;
     var filteredItemSelectionDialog = new WebInspector.FilteredItemSelectionDialog(new WebInspector.JavaScriptOutlineDialog(uiSourceCode, selectItemCallback));
-    WebInspector.Dialog.show(view.element, filteredItemSelectionDialog);
+    WebInspector.Dialog.show(filteredItemSelectionDialog);
 }
 
 WebInspector.JavaScriptOutlineDialog.prototype = {
@@ -882,18 +880,17 @@
 
 /**
  * @param {!WebInspector.SourcesView} sourcesView
- * @param {!Element} relativeToElement
  * @param {string=} query
  * @param {!Map.<!WebInspector.UISourceCode, number>=} defaultScores
  */
-WebInspector.OpenResourceDialog.show = function(sourcesView, relativeToElement, query, defaultScores)
+WebInspector.OpenResourceDialog.show = function(sourcesView, query, defaultScores)
 {
     if (WebInspector.Dialog.currentInstance())
         return;
 
     var filteredItemSelectionDialog = new WebInspector.FilteredItemSelectionDialog(new WebInspector.OpenResourceDialog(sourcesView, defaultScores));
     filteredItemSelectionDialog.renderAsTwoRows();
-    WebInspector.Dialog.show(relativeToElement, filteredItemSelectionDialog);
+    WebInspector.Dialog.show(filteredItemSelectionDialog);
     if (query)
         filteredItemSelectionDialog.setQuery(query);
 }
@@ -940,9 +937,8 @@
  * @param {string} name
  * @param {!Array.<string>} types
  * @param {function(?WebInspector.UISourceCode)} callback
- * @param {!Element} relativeToElement
  */
-WebInspector.SelectUISourceCodeForProjectTypesDialog.show = function(name, types, callback, relativeToElement)
+WebInspector.SelectUISourceCodeForProjectTypesDialog.show = function(name, types, callback)
 {
     if (WebInspector.Dialog.currentInstance())
         return;
@@ -950,7 +946,7 @@
     var filteredItemSelectionDialog = new WebInspector.FilteredItemSelectionDialog(new WebInspector.SelectUISourceCodeForProjectTypesDialog(types, callback));
     filteredItemSelectionDialog.setQuery(name);
     filteredItemSelectionDialog.renderAsTwoRows();
-    WebInspector.Dialog.show(relativeToElement, filteredItemSelectionDialog);
+    WebInspector.Dialog.show(filteredItemSelectionDialog);
 }
 
 /**
diff --git a/Source/devtools/front_end/sources/JavaScriptSourceFrame.js b/Source/devtools/front_end/sources/JavaScriptSourceFrame.js
index d8700ae..6a6d2dd 100644
--- a/Source/devtools/front_end/sources/JavaScriptSourceFrame.js
+++ b/Source/devtools/front_end/sources/JavaScriptSourceFrame.js
@@ -294,12 +294,11 @@
         }
 
         /**
-         * @this {WebInspector.JavaScriptSourceFrame}
          * @param {!WebInspector.ResourceScriptFile} scriptFile
          */
         function addSourceMapURL(scriptFile)
         {
-            WebInspector.AddSourceMapURLDialog.show(this.element, addSourceMapURLDialogCallback.bind(null, scriptFile));
+            WebInspector.AddSourceMapURLDialog.show(addSourceMapURLDialogCallback.bind(null, scriptFile));
         }
 
         /**
@@ -319,7 +318,7 @@
             if (this._scriptFileForTarget.size) {
                 var scriptFile = this._scriptFileForTarget.valuesArray()[0];
                 var addSourceMapURLLabel = WebInspector.UIString.capitalize("Add ^source ^map\u2026");
-                contextMenu.appendItem(addSourceMapURLLabel, addSourceMapURL.bind(this, scriptFile));
+                contextMenu.appendItem(addSourceMapURLLabel, addSourceMapURL.bind(null, scriptFile));
                 contextMenu.appendSeparator();
             }
         }
diff --git a/Source/devtools/front_end/sources/SourcesPanel.js b/Source/devtools/front_end/sources/SourcesPanel.js
index 380b268..f651f21 100644
--- a/Source/devtools/front_end/sources/SourcesPanel.js
+++ b/Source/devtools/front_end/sources/SourcesPanel.js
@@ -840,7 +840,7 @@
      */
     mapFileSystemToNetwork: function(uiSourceCode)
     {
-        WebInspector.SelectUISourceCodeForProjectTypesDialog.show(uiSourceCode.name(), [WebInspector.projectTypes.Network, WebInspector.projectTypes.ContentScripts], mapFileSystemToNetwork.bind(this), this._sourcesView.element);
+        WebInspector.SelectUISourceCodeForProjectTypesDialog.show(uiSourceCode.name(), [WebInspector.projectTypes.Network, WebInspector.projectTypes.ContentScripts], mapFileSystemToNetwork.bind(this));
 
         /**
          * @param {?WebInspector.UISourceCode} networkUISourceCode
@@ -860,7 +860,7 @@
      */
     mapNetworkToFileSystem: function(networkUISourceCode)
     {
-        WebInspector.SelectUISourceCodeForProjectTypesDialog.show(networkUISourceCode.name(), [WebInspector.projectTypes.FileSystem], mapNetworkToFileSystem.bind(this), this._sourcesView.element);
+        WebInspector.SelectUISourceCodeForProjectTypesDialog.show(networkUISourceCode.name(), [WebInspector.projectTypes.FileSystem], mapNetworkToFileSystem.bind(this));
 
         /**
          * @param {?WebInspector.UISourceCode} uiSourceCode
diff --git a/Source/devtools/front_end/sources/SourcesView.js b/Source/devtools/front_end/sources/SourcesView.js
index 1d3bf45..cb4027b 100644
--- a/Source/devtools/front_end/sources/SourcesView.js
+++ b/Source/devtools/front_end/sources/SourcesView.js
@@ -651,10 +651,10 @@
         switch (uiSourceCode.contentType()) {
         case WebInspector.resourceTypes.Document:
         case WebInspector.resourceTypes.Script:
-            WebInspector.JavaScriptOutlineDialog.show(this, uiSourceCode, this.showSourceLocation.bind(this, uiSourceCode));
+            WebInspector.JavaScriptOutlineDialog.show(uiSourceCode, this.showSourceLocation.bind(this, uiSourceCode));
             return true;
         case WebInspector.resourceTypes.Stylesheet:
-            WebInspector.StyleSheetOutlineDialog.show(this, uiSourceCode, this.showSourceLocation.bind(this, uiSourceCode));
+            WebInspector.StyleSheetOutlineDialog.show(uiSourceCode, this.showSourceLocation.bind(this, uiSourceCode));
             return true;
         default:
             // We don't want default browser shortcut to be executed, so pretend to handle this event.
@@ -672,7 +672,7 @@
         var defaultScores = new Map();
         for (var i = 1; i < uiSourceCodes.length; ++i) // Skip current element
             defaultScores.set(uiSourceCodes[i], uiSourceCodes.length - i);
-        WebInspector.OpenResourceDialog.show(this, this.element, query, defaultScores);
+        WebInspector.OpenResourceDialog.show(this, query, defaultScores);
     },
 
     /**
diff --git a/Source/devtools/front_end/sources/StyleSheetOutlineDialog.js b/Source/devtools/front_end/sources/StyleSheetOutlineDialog.js
index 94d6b66..c2ceabf 100644
--- a/Source/devtools/front_end/sources/StyleSheetOutlineDialog.js
+++ b/Source/devtools/front_end/sources/StyleSheetOutlineDialog.js
@@ -42,17 +42,16 @@
 }
 
 /**
- * @param {!WebInspector.Widget} view
  * @param {!WebInspector.UISourceCode} uiSourceCode
  * @param {function(number, number)} selectItemCallback
  */
-WebInspector.StyleSheetOutlineDialog.show = function(view, uiSourceCode, selectItemCallback)
+WebInspector.StyleSheetOutlineDialog.show = function(uiSourceCode, selectItemCallback)
 {
     if (WebInspector.Dialog.currentInstance())
         return;
     var delegate = new WebInspector.StyleSheetOutlineDialog(uiSourceCode, selectItemCallback);
     var filteredItemSelectionDialog = new WebInspector.FilteredItemSelectionDialog(delegate);
-    WebInspector.Dialog.show(view.element, filteredItemSelectionDialog);
+    WebInspector.Dialog.show(filteredItemSelectionDialog);
 }
 
 WebInspector.StyleSheetOutlineDialog.prototype = {
diff --git a/Source/devtools/front_end/timeline/TimelinePanel.js b/Source/devtools/front_end/timeline/TimelinePanel.js
index 7b838d2..6c92284 100644
--- a/Source/devtools/front_end/timeline/TimelinePanel.js
+++ b/Source/devtools/front_end/timeline/TimelinePanel.js
@@ -659,7 +659,7 @@
         console.assert(!this._statusDialog, "Status dialog is already opened.");
         this._statusDialog = new WebInspector.TimelinePanel.StatusDialog();
         this._statusDialog.addEventListener(WebInspector.TimelinePanel.StatusDialog.Events.Finish, this._stopRecording, this);
-        WebInspector.Dialog.show(null, this._statusDialog, true);
+        WebInspector.Dialog.show(this._statusDialog, true);
         this._updateStatus(WebInspector.UIString("Initializing recording\u2026"));
 
         this._autoRecordGeneration = userInitiated ? null : {};
diff --git a/Source/devtools/front_end/ui/Dialog.js b/Source/devtools/front_end/ui/Dialog.js
index 3ba4851..1acb316 100644
--- a/Source/devtools/front_end/ui/Dialog.js
+++ b/Source/devtools/front_end/ui/Dialog.js
@@ -30,17 +30,15 @@
 
 /**
  * @constructor
- * @param {!Element} relativeToElement
  * @param {!WebInspector.DialogDelegate} delegate
  * @param {boolean=} modal
  */
-WebInspector.Dialog = function(relativeToElement, delegate, modal)
+WebInspector.Dialog = function(delegate, modal)
 {
     this._delegate = delegate;
-    this._relativeToElement = relativeToElement;
     this._modal = modal;
 
-    this._glassPane = new WebInspector.GlassPane(/** @type {!Document} */ (relativeToElement.ownerDocument));
+    this._glassPane = new WebInspector.GlassPane(/** @type {!Document} */ (WebInspector.Dialog._modalHostView.element.ownerDocument));
     WebInspector.GlassPane.DefaultFocusedViewStack.push(this);
 
     // Install glass pane capturing events.
@@ -73,15 +71,14 @@
 }
 
 /**
- * @param {?Element} relativeToElement
  * @param {!WebInspector.DialogDelegate} delegate
  * @param {boolean=} modal
  */
-WebInspector.Dialog.show = function(relativeToElement, delegate, modal)
+WebInspector.Dialog.show = function(delegate, modal)
 {
     if (WebInspector.Dialog._instance)
         return;
-    WebInspector.Dialog._instance = new WebInspector.Dialog(relativeToElement || WebInspector.Dialog.modalHostView().element, delegate, modal);
+    WebInspector.Dialog._instance = new WebInspector.Dialog(delegate, modal);
     WebInspector.Dialog._instance.focus();
 }
 
@@ -128,7 +125,7 @@
 
     _position: function()
     {
-        this._delegate.position(this._element, this._relativeToElement);
+        this._delegate.position(this._element, WebInspector.Dialog._modalHostView.element);
     },
 
     _onKeyDown: function(event)
@@ -172,17 +169,14 @@
 
     /**
      * @param {!Element} element
-     * @param {!Element} relativeToElement
+     * @param {!Element} container
      */
-    position: function(element, relativeToElement)
+    position: function(element, container)
     {
-        var container = WebInspector.Dialog._modalHostView.element;
-        var box = relativeToElement.boxInWindow(window).relativeToElement(container);
-
-        var positionX = box.x + (relativeToElement.offsetWidth - element.offsetWidth) / 2;
+        var positionX = (container.offsetWidth - element.offsetWidth) / 2;
         positionX = Number.constrain(positionX, 0, container.offsetWidth - element.offsetWidth);
 
-        var positionY = box.y + (relativeToElement.offsetHeight - element.offsetHeight) / 2;
+        var positionY = (container.offsetHeight - element.offsetHeight) / 2;
         positionY = Number.constrain(positionY, 0, container.offsetHeight - element.offsetHeight);
 
         element.style.position = "absolute";