Title: [143427] trunk/Source/WebCore
Revision
143427
Author
[email protected]
Date
2013-02-19 21:24:35 -0800 (Tue, 19 Feb 2013)

Log Message

Web Inspector: Cleanup and add JSDocs to SuggestBox
https://bugs.webkit.org/show_bug.cgi?id=110202

Reviewed by Pavel Feldman.

SuggestBox contains some obsolete/unused code and not fully
covered with JSDocs.

* inspector/front-end/SuggestBox.js:
(WebInspector.SuggestBox.prototype.visible):
Replaced getter with function.
(WebInspector.SuggestBox.prototype._onScrollOrResize):
Use camel-case for function names.
(WebInspector.SuggestBox.prototype._onBoxMouseDown): Ditto.
(WebInspector.SuggestBox.prototype.updateSuggestions):
Removed unused code.
(WebInspector.SuggestBox.prototype.hide): Adopt changes.
(WebInspector.SuggestBox.prototype._applySuggestion): Ditto.
* inspector/front-end/TextPrompt.js:
(WebInspector.TextPrompt.prototype.isSuggestBoxVisible): Ditto.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (143426 => 143427)


--- trunk/Source/WebCore/ChangeLog	2013-02-20 03:05:32 UTC (rev 143426)
+++ trunk/Source/WebCore/ChangeLog	2013-02-20 05:24:35 UTC (rev 143427)
@@ -1,3 +1,26 @@
+2013-02-19  Eugene Klyuchnikov  <[email protected]>
+
+        Web Inspector: Cleanup and add JSDocs to SuggestBox
+        https://bugs.webkit.org/show_bug.cgi?id=110202
+
+        Reviewed by Pavel Feldman.
+
+        SuggestBox contains some obsolete/unused code and not fully
+        covered with JSDocs.
+
+        * inspector/front-end/SuggestBox.js:
+        (WebInspector.SuggestBox.prototype.visible):
+        Replaced getter with function.
+        (WebInspector.SuggestBox.prototype._onScrollOrResize):
+        Use camel-case for function names.
+        (WebInspector.SuggestBox.prototype._onBoxMouseDown): Ditto.
+        (WebInspector.SuggestBox.prototype.updateSuggestions):
+        Removed unused code.
+        (WebInspector.SuggestBox.prototype.hide): Adopt changes.
+        (WebInspector.SuggestBox.prototype._applySuggestion): Ditto.
+        * inspector/front-end/TextPrompt.js:
+        (WebInspector.TextPrompt.prototype.isSuggestBoxVisible): Ditto.
+
 2013-02-19  Hayato Ito <[email protected]>
 
         Calculate EventPath in EventDispatcher's constructor.

Modified: trunk/Source/WebCore/inspector/front-end/SuggestBox.js (143426 => 143427)


--- trunk/Source/WebCore/inspector/front-end/SuggestBox.js	2013-02-20 03:05:32 UTC (rev 143426)
+++ trunk/Source/WebCore/inspector/front-end/SuggestBox.js	2013-02-20 05:24:35 UTC (rev 143427)
@@ -66,33 +66,35 @@
     this._length = 0;
     this._selectedIndex = -1;
     this._selectedElement = null;
-    this._boundOnScroll = this._onscrollresize.bind(this, true);
-    this._boundOnResize = this._onscrollresize.bind(this, false);
+    this._boundOnScroll = this._onScrollOrResize.bind(this, true);
+    this._boundOnResize = this._onScrollOrResize.bind(this, false);
     window.addEventListener("scroll", this._boundOnScroll, true);
     window.addEventListener("resize", this._boundOnResize, true);
 
     this._bodyElement = inputElement.ownerDocument.body;
     this._element = inputElement.ownerDocument.createElement("div");
     this._element.className = "suggest-box " + (className || "");
-    this._element.addEventListener("mousedown", this._onboxmousedown.bind(this), true);
+    this._element.addEventListener("mousedown", this._onBoxMouseDown.bind(this), true);
     this.containerElement = this._element.createChild("div", "container");
     this.contentElement = this.containerElement.createChild("div", "content");
 }
 
 WebInspector.SuggestBox.prototype = {
-    get visible()
+    /**
+     * @return {boolean}
+     */
+    visible: function()
     {
         return !!this._element.parentElement;
     },
 
-    get hasSelection()
+    /**
+     * @param {boolean} isScroll
+     * @param {Event} event
+     */
+    _onScrollOrResize: function(isScroll, event)
     {
-        return !!this._selectedElement;
-    },
-
-    _onscrollresize: function(isScroll, event)
-    {
-        if (isScroll && this._element.isAncestor(event.target) || !this.visible)
+        if (isScroll && this._element.isAncestor(event.target) || !this.visible())
             return;
         this._updateBoxPositionWithExistingAnchor();
     },
@@ -155,14 +157,17 @@
         this._element.style.height = height + "px";
     },
 
-    _onboxmousedown: function(event)
+    /**
+     * @param {Event} event
+     */
+    _onBoxMouseDown: function(event)
     {
         event.preventDefault();
     },
 
     hide: function()
     {
-        if (!this.visible)
+        if (!this.visible())
             return;
 
         this._element.parentElement.removeChild(this._element);
@@ -182,7 +187,7 @@
      */
     _applySuggestion: function(text, isIntermediateSuggestion)
     {
-        if (!this.visible || !(text || this._selectedElement))
+        if (!this.visible() || !(text || this._selectedElement))
             return false;
 
         var suggestion = text || this._selectedElement.textContent;
@@ -231,26 +236,19 @@
     },
 
     /**
-     * @param {AnchorBox} anchorBox
-     * @param {Array.<string>=} completions
-     * @param {number=} selectedIndex
-     * @param {boolean=} canShowForSingleItem
+     * @param {string} text
+     * @param {Event} event
      */
-    updateSuggestions: function(anchorBox, completions, selectedIndex, canShowForSingleItem)
-    {
-        if (this._suggestTimeout) {
-            clearTimeout(this._suggestTimeout);
-            delete this._suggestTimeout;
-        }
-        this._completionsReady(anchorBox, completions, selectedIndex, canShowForSingleItem);
-    },
-
     _onItemMouseDown: function(text, event)
     {
         this.acceptSuggestion(text);
         event.consume(true);
     },
 
+    /**
+     * @param {string} prefix
+     * @param {string} text
+     */
     _createItemElement: function(prefix, text)
     {
         var element = document.createElement("div");
@@ -335,12 +333,12 @@
      * @param {number=} selectedIndex
      * @param {boolean=} canShowForSingleItem
      */
-    _completionsReady: function(anchorBox, completions, selectedIndex, canShowForSingleItem)
+    updateSuggestions: function(anchorBox, completions, selectedIndex, canShowForSingleItem)
     {
         if (this._canShowBox(completions, canShowForSingleItem)) {
             this._updateItems(completions, selectedIndex);
             this._updateBoxPosition(anchorBox);
-            if (!this.visible)
+            if (!this.visible())
                 this._bodyElement.appendChild(this._element);
             this._rememberRowCountPerViewport();
         } else

Modified: trunk/Source/WebCore/inspector/front-end/TextPrompt.js (143426 => 143427)


--- trunk/Source/WebCore/inspector/front-end/TextPrompt.js	2013-02-20 03:05:32 UTC (rev 143426)
+++ trunk/Source/WebCore/inspector/front-end/TextPrompt.js	2013-02-20 05:24:35 UTC (rev 143427)
@@ -630,7 +630,7 @@
 
     isSuggestBoxVisible: function()
     {
-        return this._suggestBox && this._suggestBox.visible;
+        return this._suggestBox && this._suggestBox.visible();
     },
 
     isCaretInsidePrompt: function()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to