Title: [105156] trunk/Source/WebCore
Revision
105156
Author
[email protected]
Date
2012-01-17 07:34:35 -0800 (Tue, 17 Jan 2012)

Log Message

Web Inspector: Dialogs style and DialogDelegate interface fixes.
https://bugs.webkit.org/show_bug.cgi?id=76449

Reviewed by Pavel Feldman.

* inspector/front-end/Dialog.js:
(WebInspector.Dialog):
(WebInspector.Dialog.currentInstance):
(WebInspector.Dialog.show):
(WebInspector.Dialog.hide):
(WebInspector.Dialog.prototype._hide):
(WebInspector.Dialog.prototype._onGlassPaneFocus):
(WebInspector.Dialog.prototype._onFocus):
(WebInspector.Dialog.prototype._position):
(WebInspector.Dialog.prototype._onKeyDown):
(WebInspector.DialogDelegate.prototype.wasShown):
(WebInspector.DialogDelegate.prototype.position):
(WebInspector.DialogDelegate.prototype.focus):
(WebInspector.DialogDelegate.prototype.onEnter):
(WebInspector.DialogDelegate.prototype.willHide):
* inspector/front-end/GoToLineDialog.js:
(WebInspector.GoToLineDialog):
(WebInspector.GoToLineDialog.prototype.focus):
(WebInspector.GoToLineDialog.prototype._onGoClick):
(WebInspector.GoToLineDialog.prototype._applyLineNumber):
(WebInspector.GoToLineDialog.prototype.onEnter):
* inspector/front-end/dialog.css:
(.dialog):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (105155 => 105156)


--- trunk/Source/WebCore/ChangeLog	2012-01-17 15:30:34 UTC (rev 105155)
+++ trunk/Source/WebCore/ChangeLog	2012-01-17 15:34:35 UTC (rev 105156)
@@ -1,3 +1,34 @@
+2012-01-17  Vsevolod Vlasov  <[email protected]>
+
+        Web Inspector: Dialogs style and DialogDelegate interface fixes.
+        https://bugs.webkit.org/show_bug.cgi?id=76449
+
+        Reviewed by Pavel Feldman.
+
+        * inspector/front-end/Dialog.js:
+        (WebInspector.Dialog):
+        (WebInspector.Dialog.currentInstance):
+        (WebInspector.Dialog.show):
+        (WebInspector.Dialog.hide):
+        (WebInspector.Dialog.prototype._hide):
+        (WebInspector.Dialog.prototype._onGlassPaneFocus):
+        (WebInspector.Dialog.prototype._onFocus):
+        (WebInspector.Dialog.prototype._position):
+        (WebInspector.Dialog.prototype._onKeyDown):
+        (WebInspector.DialogDelegate.prototype.wasShown):
+        (WebInspector.DialogDelegate.prototype.position):
+        (WebInspector.DialogDelegate.prototype.focus):
+        (WebInspector.DialogDelegate.prototype.onEnter):
+        (WebInspector.DialogDelegate.prototype.willHide):
+        * inspector/front-end/GoToLineDialog.js:
+        (WebInspector.GoToLineDialog):
+        (WebInspector.GoToLineDialog.prototype.focus):
+        (WebInspector.GoToLineDialog.prototype._onGoClick):
+        (WebInspector.GoToLineDialog.prototype._applyLineNumber):
+        (WebInspector.GoToLineDialog.prototype.onEnter):
+        * inspector/front-end/dialog.css:
+        (.dialog):
+
 2012-01-17  Yury Semikhatsky  <[email protected]>
 
         Web Inspector: ConsoleMessage.cpp and InspectorResourceAgent.cpp doesn't conform to Inspector.json

Modified: trunk/Source/WebCore/inspector/front-end/Dialog.js (105155 => 105156)


--- trunk/Source/WebCore/inspector/front-end/Dialog.js	2012-01-17 15:30:34 UTC (rev 105155)
+++ trunk/Source/WebCore/inspector/front-end/Dialog.js	2012-01-17 15:34:35 UTC (rev 105156)
@@ -30,47 +30,68 @@
 
 /**
  * @constructor
+ * @param {Element} relativeToElement
+ * @param {WebInspector.DialogDelegate} delegate
  */
-WebInspector.Dialog = function(relativeToElement, dialogDelegate)
+WebInspector.Dialog = function(relativeToElement, delegate)
 {
-    this._dialogDelegate = dialogDelegate;
+    this._delegate = delegate;
     this._relativeToElement = relativeToElement;
 
     // Install glass pane capturing events.
     this._glassPaneElement = document.body.createChild("div");
     this._glassPaneElement.className = "dialog-glass-pane";
     this._glassPaneElement.tabIndex = 0;
-    this._glassPaneElement.addEventListener("focus", this._onFocus.bind(this), false);
-    
+    this._glassPaneElement.addEventListener("focus", this._onGlassPaneFocus.bind(this), false);
+
     this._element = this._glassPaneElement.createChild("div");
     this._element.className = "dialog";
     this._element.tabIndex = 0;
+    this._element.addEventListener("focus", this._onFocus.bind(this), false);
     this._element.addEventListener("keydown", this._onKeyDown.bind(this), false);
     this._closeKeys = [
         WebInspector.KeyboardShortcut.Keys.Enter.code,
         WebInspector.KeyboardShortcut.Keys.Esc.code,
     ];
 
-    if (dialogDelegate.okButton)
-        dialogDelegate.okButton.addEventListener("click", this._onClick.bind(this), false);
-    dialogDelegate.element.addStyleClass("dialog-contents");
-    this._element.appendChild(dialogDelegate.element);
-    
+    delegate.element.addStyleClass("dialog-contents");
+    this._element.appendChild(delegate.element);
+
+    this._delegate.wasShown();
     this._position();
     this._windowResizeHandler = this._position.bind(this);
     window.addEventListener("resize", this._windowResizeHandler, true);
 
     this._previousFocusElement = WebInspector.currentFocusElement();
-    this._doFocus();
+    this._delegate.focus();
 }
 
-WebInspector.Dialog.show = function(relativeToElement, dialogDelegate)
+/**
+ * @return {WebInspector.Dialog}
+ */
+WebInspector.Dialog.currentInstance = function()
 {
+    return WebInspector.Dialog._instance;
+}
+
+/**
+ * @param {Element} relativeToElement
+ * @param {WebInspector.DialogDelegate} delegate
+ */
+WebInspector.Dialog.show = function(relativeToElement, delegate)
+{
     if (WebInspector.Dialog._instance)
         return;
-    WebInspector.Dialog._instance = new WebInspector.Dialog(relativeToElement, dialogDelegate);
+    WebInspector.Dialog._instance = new WebInspector.Dialog(relativeToElement, delegate);
 }
 
+WebInspector.Dialog.hide = function()
+{
+    if (!WebInspector.Dialog._instance)
+        return;
+    WebInspector.Dialog._instance._hide();
+}
+
 WebInspector.Dialog.prototype = {
     _hide: function()
     {
@@ -78,39 +99,27 @@
             return;
         this._isHiding = true;
 
+        this._delegate.willHide();
+
         WebInspector.setCurrentFocusElement(this._previousFocusElement);
         WebInspector.Dialog._instance = null;
         document.body.removeChild(this._glassPaneElement);
         window.removeEventListener("resize", this._windowResizeHandler, true);
     },
 
-    _onFocus: function(event)
+    _onGlassPaneFocus: function(event)
     {
         this._hide();
     },
 
-    _doFocus: function()
+    _onFocus: function(event)
     {
-        if (this._dialogDelegate.defaultFocusedElement) {
-            WebInspector.setCurrentFocusElement(this._dialogDelegate.defaultFocusedElement);
-            if (typeof(this._dialogDelegate.defaultFocusedElement.select) === "function")
-                this._dialogDelegate.defaultFocusedElement.select();
-        } else 
-            WebInspector.setCurrentFocusElement(this._element);
+        this._delegate.focus();
     },
 
     _position: function()
     {
-        var offset = this._relativeToElement.offsetRelativeToWindow(window);
-
-        var positionX = offset.x + (this._relativeToElement.offsetWidth - this._element.offsetWidth) / 2;
-        positionX = Number.constrain(positionX, 0, window.innerWidth - this._element.offsetWidth);
-        
-        var positionY = offset.y + (this._relativeToElement.offsetHeight - this._element.offsetHeight) / 2;
-        positionY = Number.constrain(positionY, 0, window.innerHeight - this._element.offsetHeight);
-        
-        this._element.style.left = positionX + "px";
-        this._element.style.top = positionY + "px";
+        this._delegate.position(this._element, this._relativeToElement);
     },
 
     _onKeyDown: function(event)
@@ -121,33 +130,43 @@
         }
 
         if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Enter.code)
-            this._dialogDelegate.onAction();
+            this._delegate.onEnter();
 
         if (this._closeKeys.indexOf(event.keyCode) >= 0) {
             this._hide();
             event.preventDefault();
             event.stopPropagation();
         }
-    },
-
-    _onClick: function(event)
-    {
-        this._dialogDelegate.onAction();
-        this._hide();
     }
 };
 
 /**
- * @interface
+ * @constructor
  */
 WebInspector.DialogDelegate = function()
 {
 }
 
 WebInspector.DialogDelegate.prototype = {
-    get defaultFocusedElement() { },
-    
-    get okButton() { },
-    
-    onAction: function() { }
+    wasShown: function() { },
+
+    position: function(element, relativeToElement)
+    {
+        var offset = relativeToElement.offsetRelativeToWindow(window);
+
+        var positionX = offset.x + (relativeToElement.offsetWidth - element.offsetWidth) / 2;
+        positionX = Number.constrain(positionX, 0, window.innerWidth - element.offsetWidth);
+
+        var positionY = offset.y + (relativeToElement.offsetHeight - element.offsetHeight) / 2;
+        positionY = Number.constrain(positionY, 0, window.innerHeight - element.offsetHeight);
+
+        element.style.left = positionX + "px";
+        element.style.top = positionY + "px";
+    },
+
+    focus: function() { },
+
+    onEnter: function() { },
+
+    willHide: function() { }
 };

Modified: trunk/Source/WebCore/inspector/front-end/GoToLineDialog.js (105155 => 105156)


--- trunk/Source/WebCore/inspector/front-end/GoToLineDialog.js	2012-01-17 15:30:34 UTC (rev 105155)
+++ trunk/Source/WebCore/inspector/front-end/GoToLineDialog.js	2012-01-17 15:34:35 UTC (rev 105156)
@@ -30,7 +30,7 @@
 
 /**
  * @constructor
- * @implements {WebInspector.DialogDelegate}
+ * @extends {WebInspector.DialogDelegate}
  */
 WebInspector.GoToLineDialog = function(view)
 {
@@ -47,10 +47,14 @@
 
     this._goButton = this.element.createChild("button");
     this._goButton.textContent = WebInspector.UIString("Go");
+    this._goButton.addEventListener("click", this._onGoClick.bind(this), false);
 
     this._view = view;
 }
 
+/**
+ * @param {WebInspector.Panel} panel
+ */
 WebInspector.GoToLineDialog.install = function(panel, viewGetter)
 {
     function showGoToLineDialog()
@@ -81,22 +85,29 @@
 }
 
 WebInspector.GoToLineDialog.prototype = {
-    get defaultFocusedElement()
+    focus: function()
     {
-        return this._input;
+        WebInspector.setCurrentFocusElement(this._input);
+        this._input.select();
     },
-
-    get okButton()
+    
+    _onGoClick: function()
     {
-        return this._goButton;
+        this._applyLineNumber();
+        WebInspector.Dialog.hide();
     },
     
-    onAction: function()
+    _applyLineNumber: function()
     {
         var value = this._input.value;
         var lineNumber = parseInt(value, 10) - 1;
         if (!isNaN(lineNumber) && lineNumber >= 0)
             this._view.highlightLine(lineNumber);
+    },
+    
+    onEnter: function()
+    {
+        this._applyLineNumber();
     }
 }
 

Modified: trunk/Source/WebCore/inspector/front-end/dialog.css (105155 => 105156)


--- trunk/Source/WebCore/inspector/front-end/dialog.css	2012-01-17 15:30:34 UTC (rev 105155)
+++ trunk/Source/WebCore/inspector/front-end/dialog.css	2012-01-17 15:34:35 UTC (rev 105156)
@@ -10,11 +10,18 @@
 .dialog {
     position: absolute;
     
-    background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#E9E9E9), to(#CFCFCF));
     padding: 10px;
     border-radius: 10px;
     border: 1px solid gray;
+
     -webkit-box-shadow: rgb(40,40,40) 0px 0px 50px;
+    
+    display: -webkit-box;
+    -webkit-box-orient: vertical;
+    
+    background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#E9E9E9), to(#CFCFCF));
+    font-size: 11px;
+    font-family: 'Lucida Grande', sans-serif;
 }
 
 .dialog-contents {
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to