Title: [105066] trunk/Source/WebCore
Revision
105066
Author
[email protected]
Date
2012-01-16 08:47:19 -0800 (Mon, 16 Jan 2012)

Log Message

Web Inspector: setCurrentFocusElement should not update selection when focus is moved to text field or text area.
https://bugs.webkit.org/show_bug.cgi?id=76384

Reviewed by Timothy Hatcher.

* inspector/front-end/_javascript_OutlineDialog.js:
(WebInspector._javascript_OutlineDialog):
* inspector/front-end/UIUtils.js:
(WebInspector._isTextEditingElement):
(WebInspector.setCurrentFocusElement):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (105065 => 105066)


--- trunk/Source/WebCore/ChangeLog	2012-01-16 16:13:20 UTC (rev 105065)
+++ trunk/Source/WebCore/ChangeLog	2012-01-16 16:47:19 UTC (rev 105066)
@@ -1,3 +1,16 @@
+2012-01-16  Vsevolod Vlasov  <[email protected]>
+
+        Web Inspector: setCurrentFocusElement should not update selection when focus is moved to text field or text area.
+        https://bugs.webkit.org/show_bug.cgi?id=76384
+
+        Reviewed by Timothy Hatcher.
+
+        * inspector/front-end/_javascript_OutlineDialog.js:
+        (WebInspector._javascript_OutlineDialog):
+        * inspector/front-end/UIUtils.js:
+        (WebInspector._isTextEditingElement):
+        (WebInspector.setCurrentFocusElement):
+
 2012-01-16  Nikolas Zimmermann  <[email protected]>
 
         Large SVG text layout performance regression in r81168

Modified: trunk/Source/WebCore/inspector/front-end/_javascript_OutlineDialog.js (105065 => 105066)


--- trunk/Source/WebCore/inspector/front-end/_javascript_OutlineDialog.js	2012-01-16 16:13:20 UTC (rev 105065)
+++ trunk/Source/WebCore/inspector/front-end/_javascript_OutlineDialog.js	2012-01-16 16:47:19 UTC (rev 105066)
@@ -91,7 +91,6 @@
 
     this._previousFocusElement = WebInspector.currentFocusElement();
     WebInspector.setCurrentFocusElement(this._promptElement);
-    this._promptElement.select();
 
     this._highlighter = new WebInspector._javascript_OutlineDialog.MatchHighlighter(this);
 }

Modified: trunk/Source/WebCore/inspector/front-end/UIUtils.js (105065 => 105066)


--- trunk/Source/WebCore/inspector/front-end/UIUtils.js	2012-01-16 16:13:20 UTC (rev 105065)
+++ trunk/Source/WebCore/inspector/front-end/UIUtils.js	2012-01-16 16:47:19 UTC (rev 105066)
@@ -587,6 +587,18 @@
     WebInspector.setCurrentFocusElement(event.target);
 }
 
+WebInspector._textInputTypes = ["text", "search", "tel", "url", "email", "password"].keySet(); 
+WebInspector._isTextEditingElement = function(element)
+{
+    if (element instanceof HTMLInputElement)
+        return element.type in WebInspector._textInputTypes;
+
+    if (element instanceof HTMLTextAreaElement)
+        return true;
+
+    return false;
+}
+
 WebInspector.setCurrentFocusElement = function(x)
 {
     if (WebInspector._currentFocusElement !== x)
@@ -596,10 +608,11 @@
     if (WebInspector._currentFocusElement) {
         WebInspector._currentFocusElement.focus();
 
-        // Make a caret selection inside the new element if there isn't a range selection and
-        // there isn't already a caret selection inside.
+        // Make a caret selection inside the new element if there isn't a range selection and there isn't already a caret selection inside.
+        // This is needed (at least) to remove caret from console when focus is moved to some element in the panel.
+        // The code below should not be applied to text fields and text areas, hence _isTextEditingElement check.
         var selection = window.getSelection();
-        if (selection.isCollapsed && !WebInspector._currentFocusElement.isInsertionCaretInside()) {
+        if (!WebInspector._isTextEditingElement(WebInspector._currentFocusElement) && selection.isCollapsed && !WebInspector._currentFocusElement.isInsertionCaretInside()) {
             var selectionRange = WebInspector._currentFocusElement.ownerDocument.createRange();
             selectionRange.setStart(WebInspector._currentFocusElement, 0);
             selectionRange.setEnd(WebInspector._currentFocusElement, 0);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to