Web Inspector: get rid of this._lastMarkedRange in TextEditor.
authorpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Jul 2012 17:19:25 +0000 (17:19 +0000)
committerpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Jul 2012 17:19:25 +0000 (17:19 +0000)
https://bugs.webkit.org/show_bug.cgi?id=90691

Reviewed by Vsevolod Vlasov.

We don't need it, should use setSelection instead.

* inspector/front-end/TextEditor.js:
(WebInspector.TextEditor.prototype.markAndRevealRange):
(WebInspector.TextEditor.prototype._handleSelectionChange):
(WebInspector.TextEditor.prototype.setSelection):
(WebInspector.TextEditor.prototype._handleFocused):

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

Source/WebCore/ChangeLog
Source/WebCore/inspector/front-end/TextEditor.js

index 78edf49..7bca590 100644 (file)
@@ -1,3 +1,18 @@
+2012-07-06  Pavel Feldman  <pfeldman@chromium.org>
+
+        Web Inspector: get rid of this._lastMarkedRange in TextEditor.
+        https://bugs.webkit.org/show_bug.cgi?id=90691
+
+        Reviewed by Vsevolod Vlasov.
+
+        We don't need it, should use setSelection instead.
+
+        * inspector/front-end/TextEditor.js:
+        (WebInspector.TextEditor.prototype.markAndRevealRange):
+        (WebInspector.TextEditor.prototype._handleSelectionChange):
+        (WebInspector.TextEditor.prototype.setSelection):
+        (WebInspector.TextEditor.prototype._handleFocused):
+
 2012-07-06  Vsevolod Vlasov  <vsevik@chromium.org>
 
         Web Inspector: Snippet renaming behavior is not correct.
index 05ec5b5..770e9f9 100644 (file)
@@ -159,7 +159,7 @@ WebInspector.TextEditor.prototype = {
     markAndRevealRange: function(range)
     {
         if (range)
-            this._lastMarkedRange = range;
+            this.setSelection(range);
         this._mainPanel.markAndRevealRange(range);
     },
 
@@ -379,8 +379,11 @@ WebInspector.TextEditor.prototype = {
     _handleSelectionChange: function(event)
     {
         var textRange = this._mainPanel._getSelection();
-        if (textRange)
-            this._lastSelection = textRange;
+        if (textRange) {
+            // We do not restore selection after focus lost to avoid selection blinking. We restore only cursor position instead.
+            // FIXME: consider adding selection decoration to blurred editor.
+            this._lastSelection = WebInspector.TextRange.createFromLocation(textRange.endLine, textRange.endColumn);
+        }
         this._delegate.selectionChanged(textRange);
     },
 
@@ -406,7 +409,8 @@ WebInspector.TextEditor.prototype = {
     setSelection: function(textRange)
     {
         this._lastSelection = textRange;
-        this._mainPanel._restoreSelection(textRange);
+        if (this.element.isAncestor(document.activeElement))
+            this._mainPanel._restoreSelection(textRange);
     },
 
     wasShown: function()
@@ -420,19 +424,8 @@ WebInspector.TextEditor.prototype = {
 
     _handleFocused: function()
     {
-        // Convert last marked range into a selection upon focus. This is needed to focus the search result.
-        if (this._lastMarkedRange) {
-            this.setSelection(this._lastMarkedRange);
-            delete this._lastMarkedRange;
-            return;
-        }
-
-        if (this._lastSelection) {
-            // We do not restore selection after focus lost to avoid selection blinking. We restore only cursor position instead.
-            // FIXME: consider adding selection decoration to blurred editor.
-            var newSelection = WebInspector.TextRange.createFromLocation(this._lastSelection.endLine, this._lastSelection.endColumn);
-            this.setSelection(newSelection);
-        }
+        if (this._lastSelection)
+            this.setSelection(this._lastSelection);
     },
 
     willHide: function()