Changeset 31120 in webkit


Ignore:
Timestamp:
Mar 17, 2008 11:12:59 PM (16 years ago)
Author:
timothy@apple.com
Message:

2008-03-17 Timothy Hatcher <timothy@apple.com>

Reviewed by Mark Rowe.

Bug 17908: Various bugs in the Console completion code
http://bugs.webkit.org/show_bug.cgi?id=17908

  • page/inspector/ConsolePanel.js: (WebInspector.ConsolePanel.complete): Moved the code that checked for the caret being at the end of the prompt into the _caretAtEndOfPrompt helper function. (WebInspector.ConsolePanel.messagesSelectStart): Clear and redo the auto complete when the selection changes. (WebInspector.ConsolePanel._caretInsidePrompt): Fixed a logic error that always caused a false result. (WebInspector.ConsolePanel._caretAtEndOfPrompt): Added. Tests if the selection is a caret at the end of the prompt. (WebInspector.ConsolePanel._moveCaretToEndOfPrompt): Changed the offset to use the childNodes length. This makes sure the caret is at the end when there are multiple text nodes in the prompt.
Location:
trunk/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r31117 r31120  
     12008-03-17  Timothy Hatcher  <timothy@apple.com>
     2
     3        Reviewed by Mark Rowe.
     4
     5        Bug 17908: Various bugs in the Console completion code
     6        http://bugs.webkit.org/show_bug.cgi?id=17908
     7
     8        * page/inspector/ConsolePanel.js:
     9        (WebInspector.ConsolePanel.complete): Moved the code that checked for the caret being at the end
     10        of the prompt into the _caretAtEndOfPrompt helper function.
     11        (WebInspector.ConsolePanel.messagesSelectStart): Clear and redo the auto complete when the selection changes.
     12        (WebInspector.ConsolePanel._caretInsidePrompt): Fixed a logic error that always caused a false result.
     13        (WebInspector.ConsolePanel._caretAtEndOfPrompt): Added. Tests if the selection is a caret at the
     14        end of the prompt.
     15        (WebInspector.ConsolePanel._moveCaretToEndOfPrompt): Changed the offset to use the childNodes length.
     16        This makes sure the caret is at the end when there are multiple text nodes in the prompt.
     17
    1182008-03-17  Dan Bernstein  <mitz@apple.com>
    219
  • trunk/WebCore/page/inspector/ConsolePanel.js

    r31101 r31120  
    191191        if (!selectionRange.commonAncestorContainer.isDescendant(this.promptElement))
    192192            return;
    193 
    194         if (auto) {
    195             if (!selection.isCollapsed)
    196                 return;
    197 
    198             var node = selectionRange.startContainer;
    199             if (node.nodeType === Node.TEXT_NODE && selectionRange.startOffset < node.nodeValue.length)
    200                 return;
    201 
    202             var foundNextText = false;
    203             while (node) {
    204                 if (node.nodeType === Node.TEXT_NODE && node.nodeValue.length) {
    205                     if (foundNextText)
    206                         return;
    207                     foundNextText = true;
    208                 }
    209 
    210                 node = node.traverseNextNode(false, this.promptElement);
    211             }
    212         }
     193        if (auto && !this._caretAtEndOfPrompt())
     194            return;
    213195
    214196        // Pass more characters to _backwardsRange so the range will be as short as possible.
     
    339321            clearTimeout(this._selectionTimeout);
    340322
     323        this.clearAutoComplete();
     324
    341325        function moveBackIfOutside()
    342326        {
    343327            delete this._selectionTimeout;
    344             if (this._caretInsidePrompt() || !window.getSelection().isCollapsed)
    345                 return;
    346             this._moveCaretToEndOfPrompt();
     328            if (!this._caretInsidePrompt() && window.getSelection().isCollapsed)
     329                this._moveCaretToEndOfPrompt();
     330            this.autoCompleteSoon();
    347331        }
    348332
     
    456440            return false;
    457441        var selectionRange = selection.getRangeAt(0);
    458         return selectionRange.startContainer === this.promptElement && selectionRange.startContainer.isDescendant(this.promptElement);
     442        return selectionRange.startContainer === this.promptElement || selectionRange.startContainer.isDescendant(this.promptElement);
     443    },
     444
     445    _caretAtEndOfPrompt: function()
     446    {
     447        var selection = window.getSelection();
     448        if (!selection.rangeCount || !selection.isCollapsed)
     449            return false;
     450
     451        var selectionRange = selection.getRangeAt(0);
     452        var node = selectionRange.startContainer;
     453        if (node !== this.promptElement && !node.isDescendant(this.promptElement))
     454            return false;
     455
     456        if (node.nodeType === Node.TEXT_NODE && selectionRange.startOffset < node.nodeValue.length)
     457            return false;
     458
     459        var foundNextText = false;
     460        while (node) {
     461            if (node.nodeType === Node.TEXT_NODE && node.nodeValue.length) {
     462                if (foundNextText)
     463                    return false;
     464                foundNextText = true;
     465            }
     466
     467            node = node.traverseNextNode(false, this.promptElement);
     468        }
     469
     470        return true;
    459471    },
    460472
     
    464476        var selectionRange = document.createRange();
    465477
    466         var offset = this.promptElement.firstChild ? 1 : 0;
     478        var offset = this.promptElement.childNodes.length;
    467479        selectionRange.setStart(this.promptElement, offset);
    468480        selectionRange.setEnd(this.promptElement, offset);
Note: See TracChangeset for help on using the changeset viewer.