Title: [142142] trunk
Revision
142142
Author
[email protected]
Date
2013-02-07 09:46:41 -0800 (Thu, 07 Feb 2013)

Log Message

Web Inspector: home button behaviour is wrong in DTE
https://bugs.webkit.org/show_bug.cgi?id=109154

Patch by Andrey Lushnikov <[email protected]> on 2013-02-07
Reviewed by Vsevolod Vlasov.

Source/WebCore:

Handle home key shortcut explicitly in TextEditorMainPanel.

New test: inspector/editor/text-editor-home-button.html

* inspector/front-end/DefaultTextEditor.js:
(WebInspector.TextEditorMainPanel.prototype._registerShortcuts):
(WebInspector.TextEditorMainPanel.prototype._handleHomeKey):

LayoutTests:

Add layout test to verify home button behaviour. Exclude this test on
platforms that do not have eventSender object in test shell.

* inspector/editor/text-editor-home-button-expected.txt: Added.
* inspector/editor/text-editor-home-button.html: Added.
* platform/efl/TestExpectations:
* platform/mac/TestExpectations:
* platform/qt/TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (142141 => 142142)


--- trunk/LayoutTests/ChangeLog	2013-02-07 17:32:07 UTC (rev 142141)
+++ trunk/LayoutTests/ChangeLog	2013-02-07 17:46:41 UTC (rev 142142)
@@ -1,3 +1,19 @@
+2013-02-07  Andrey Lushnikov  <[email protected]>
+
+        Web Inspector: home button behaviour is wrong in DTE
+        https://bugs.webkit.org/show_bug.cgi?id=109154
+
+        Reviewed by Vsevolod Vlasov.
+
+        Add layout test to verify home button behaviour. Exclude this test on
+        platforms that do not have eventSender object in test shell.
+
+        * inspector/editor/text-editor-home-button-expected.txt: Added.
+        * inspector/editor/text-editor-home-button.html: Added.
+        * platform/efl/TestExpectations:
+        * platform/mac/TestExpectations:
+        * platform/qt/TestExpectations:
+
 2013-02-07  Allan Sandfeld Jensen  <[email protected]>
 
         Scrollbars misplaced with accelerated compositing for overflow scroll

Added: trunk/LayoutTests/inspector/editor/text-editor-home-button-expected.txt (0 => 142142)


--- trunk/LayoutTests/inspector/editor/text-editor-home-button-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/editor/text-editor-home-button-expected.txt	2013-02-07 17:46:41 UTC (rev 142142)
@@ -0,0 +1,38 @@
+This test verifies that home button triggers selection between first symbol of the line and first non-blank symbol of the line.
+
+function foo()
+{
+    return 42;
+}
+
+Running: testFirstNonBlankCharacter
+{"startLine":2,"startColumn":8,"endLine":2,"endColumn":8}
+{"startLine":2,"startColumn":4,"endLine":2,"endColumn":4}
+
+Running: testFirstNonBlankCharacterFromWhitespace
+{"startLine":2,"startColumn":2,"endLine":2,"endColumn":2}
+{"startLine":2,"startColumn":4,"endLine":2,"endColumn":4}
+
+Running: testHomeButtonTriggering
+{"startLine":2,"startColumn":2,"endLine":2,"endColumn":2}
+{"startLine":2,"startColumn":4,"endLine":2,"endColumn":4}
+{"startLine":2,"startColumn":0,"endLine":2,"endColumn":0}
+{"startLine":2,"startColumn":4,"endLine":2,"endColumn":4}
+
+Running: testHomeButtonDoesNotChangeCursor
+{"startLine":0,"startColumn":2,"endLine":0,"endColumn":2}
+{"startLine":0,"startColumn":0,"endLine":0,"endColumn":0}
+{"startLine":0,"startColumn":0,"endLine":0,"endColumn":0}
+
+Running: testHomeButtonWithShift
+{"startLine":0,"startColumn":0,"endLine":2,"endColumn":8}
+{"startLine":0,"startColumn":0,"endLine":2,"endColumn":4}
+{"startLine":0,"startColumn":0,"endLine":2,"endColumn":0}
+{"startLine":0,"startColumn":0,"endLine":2,"endColumn":4}
+
+Running: testHomeButtonWithShiftInversed
+{"startLine":3,"startColumn":1,"endLine":2,"endColumn":8}
+{"startLine":3,"startColumn":1,"endLine":2,"endColumn":4}
+{"startLine":3,"startColumn":1,"endLine":2,"endColumn":0}
+{"startLine":3,"startColumn":1,"endLine":2,"endColumn":4}
+

Added: trunk/LayoutTests/inspector/editor/text-editor-home-button.html (0 => 142142)


--- trunk/LayoutTests/inspector/editor/text-editor-home-button.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/editor/text-editor-home-button.html	2013-02-07 17:46:41 UTC (rev 142142)
@@ -0,0 +1,110 @@
+<html>
+<head>
+<script src=""
+<script src=""
+<script>
+
+function test()
+{
+function foo()
+{
+    return 42;
+}
+    var textEditor = InspectorTest.createTestEditor();
+    textEditor.overrideViewportForTest(0, undefined, 3);
+    textEditor.mimeType = "text/_javascript_";
+    textEditor.setReadOnly(false);
+    textEditor.element.focus();
+
+    textEditor.setText(foo.toString());
+
+    InspectorTest.addResult(textEditor.text());
+
+    InspectorTest.runTestSuite([
+        function testFirstNonBlankCharacter(next)
+        {
+            var selection = WebInspector.TextRange.createFromLocation(2, 8);
+            textEditor.setSelection(selection);
+            InspectorTest.addResult(textEditor.selection());
+            eventSender.keyDown("home", []);
+            InspectorTest.addResult(textEditor.selection());
+            next();
+        },
+
+        function testFirstNonBlankCharacterFromWhitespace(next)
+        {
+            var selection = WebInspector.TextRange.createFromLocation(2, 2);
+            textEditor.setSelection(selection);
+            InspectorTest.addResult(textEditor.selection());
+            eventSender.keyDown("home", []);
+            InspectorTest.addResult(textEditor.selection());
+            next();
+        },
+
+        function testHomeButtonTriggering(next)
+        {
+            var selection = WebInspector.TextRange.createFromLocation(2, 2);
+            textEditor.setSelection(selection);
+            InspectorTest.addResult(textEditor.selection());
+            eventSender.keyDown("home", []);
+            InspectorTest.addResult(textEditor.selection());
+            eventSender.keyDown("home", []);
+            InspectorTest.addResult(textEditor.selection());
+            eventSender.keyDown("home", []);
+            InspectorTest.addResult(textEditor.selection());
+            next();
+        },
+
+        function testHomeButtonDoesNotChangeCursor(next)
+        {
+            var selection = WebInspector.TextRange.createFromLocation(0, 2);
+            textEditor.setSelection(selection);
+            InspectorTest.addResult(textEditor.selection());
+            eventSender.keyDown("home", []);
+            InspectorTest.addResult(textEditor.selection());
+            eventSender.keyDown("home", []);
+            InspectorTest.addResult(textEditor.selection());
+            next();
+        },
+
+        function testHomeButtonWithShift(next)
+        {
+            var selection = new WebInspector.TextRange(0, 0, 2, 8);
+            textEditor.setSelection(selection);
+            InspectorTest.addResult(textEditor.selection());
+            eventSender.keyDown("home", ["shiftKey"]);
+            InspectorTest.addResult(textEditor.selection());
+            eventSender.keyDown("home", ["shiftKey"]);
+            InspectorTest.addResult(textEditor.selection());
+            eventSender.keyDown("home", ["shiftKey"]);
+            InspectorTest.addResult(textEditor.selection());
+            next();
+        },
+
+        function testHomeButtonWithShiftInversed(next)
+        {
+            var selection = new WebInspector.TextRange(3, 1, 2, 8);
+            textEditor.setSelection(selection);
+            InspectorTest.addResult(textEditor.selection());
+            eventSender.keyDown("home", ["shiftKey"]);
+            InspectorTest.addResult(textEditor.selection());
+            eventSender.keyDown("home", ["shiftKey"]);
+            InspectorTest.addResult(textEditor.selection());
+            eventSender.keyDown("home", ["shiftKey"]);
+            InspectorTest.addResult(textEditor.selection());
+            next();
+        }
+    ]);
+}
+
+</script>
+</head>
+
+<body _onload_="runTest();">
+<p>
+This test verifies that home button triggers selection between first symbol of the line
+and first non-blank symbol of the line.
+</p>
+
+</body>
+</html>

Modified: trunk/LayoutTests/platform/efl/TestExpectations (142141 => 142142)


--- trunk/LayoutTests/platform/efl/TestExpectations	2013-02-07 17:32:07 UTC (rev 142141)
+++ trunk/LayoutTests/platform/efl/TestExpectations	2013-02-07 17:46:41 UTC (rev 142142)
@@ -1819,6 +1819,7 @@
 # https://bugs.webkit.org/show_bug.cgi?id=106883
 inspector/editor/text-editor-formatter.html
 inspector/editor/text-editor-word-jumps.html
+inspector/editor/text-editor-home-button.html
 
 # Remove from list after enabling CANVAS_PATH
 webkit.org/b/108508 fast/canvas/canvas-path-constructors.html [ Failure ]

Modified: trunk/LayoutTests/platform/mac/TestExpectations (142141 => 142142)


--- trunk/LayoutTests/platform/mac/TestExpectations	2013-02-07 17:32:07 UTC (rev 142141)
+++ trunk/LayoutTests/platform/mac/TestExpectations	2013-02-07 17:46:41 UTC (rev 142142)
@@ -254,6 +254,7 @@
 # https://bugs.webkit.org/show_bug.cgi?id=106793
 inspector/editor/text-editor-formatter.html [ Skip ]
 inspector/editor/text-editor-word-jumps.html [ Skip ]
+inspector/editor/text-editor-home-button.html [ Skip ]
 
 # https://bugs.webkit.org/show_bug.cgi?id=71120
 inspector/debugger/selected-call-frame-after-formatting-source.html

Modified: trunk/LayoutTests/platform/qt/TestExpectations (142141 => 142142)


--- trunk/LayoutTests/platform/qt/TestExpectations	2013-02-07 17:32:07 UTC (rev 142141)
+++ trunk/LayoutTests/platform/qt/TestExpectations	2013-02-07 17:46:41 UTC (rev 142142)
@@ -2601,6 +2601,7 @@
 # https://bugs.webkit.org/show_bug.cgi?id=106883
 inspector/editor/text-editor-formatter.html
 inspector/editor/text-editor-word-jumps.html
+inspector/editor/text-editor-home-button.html
 
 # Needs rebaseline after https://bugs.webkit.org/show_bug.cgi?id=14664
 webkit.org/b/107476 fast/block/float/024.html [ Failure ]

Modified: trunk/Source/WebCore/ChangeLog (142141 => 142142)


--- trunk/Source/WebCore/ChangeLog	2013-02-07 17:32:07 UTC (rev 142141)
+++ trunk/Source/WebCore/ChangeLog	2013-02-07 17:46:41 UTC (rev 142142)
@@ -1,3 +1,18 @@
+2013-02-07  Andrey Lushnikov  <[email protected]>
+
+        Web Inspector: home button behaviour is wrong in DTE
+        https://bugs.webkit.org/show_bug.cgi?id=109154
+
+        Reviewed by Vsevolod Vlasov.
+
+        Handle home key shortcut explicitly in TextEditorMainPanel.
+
+        New test: inspector/editor/text-editor-home-button.html
+
+        * inspector/front-end/DefaultTextEditor.js:
+        (WebInspector.TextEditorMainPanel.prototype._registerShortcuts):
+        (WebInspector.TextEditorMainPanel.prototype._handleHomeKey):
+
 2013-02-07  Gavin Peters  <[email protected]>
 
         Unreviewed, rolling out r142112.

Modified: trunk/Source/WebCore/inspector/front-end/DefaultTextEditor.js (142141 => 142142)


--- trunk/Source/WebCore/inspector/front-end/DefaultTextEditor.js	2013-02-07 17:32:07 UTC (rev 142141)
+++ trunk/Source/WebCore/inspector/front-end/DefaultTextEditor.js	2013-02-07 17:46:41 UTC (rev 142142)
@@ -1397,9 +1397,38 @@
         var handleShiftTabKey = this._handleTabKeyPress.bind(this, true);
         this._shortcuts[WebInspector.KeyboardShortcut.makeKey(keys.Tab.code)] = handleTabKey;
         this._shortcuts[WebInspector.KeyboardShortcut.makeKey(keys.Tab.code, modifiers.Shift)] = handleShiftTabKey;
+
+        this._shortcuts[WebInspector.KeyboardShortcut.makeKey(keys.Home.code, modifiers.None)] = this._handleHomeKey.bind(this, false);
+        this._shortcuts[WebInspector.KeyboardShortcut.makeKey(keys.Home.code, modifiers.Shift)] = this._handleHomeKey.bind(this, true);
     },
 
     /**
+     * @param {boolean} shift
+     */
+    _handleHomeKey: function(shift)
+    {
+        var selection = this.selection();
+
+        var line = this._textModel.line(selection.endLine);
+        var firstNonBlankCharacter = 0;
+        while (firstNonBlankCharacter < line.length) {
+            var char = line.charAt(firstNonBlankCharacter);
+            if (char === " " || char === "\t")
+                ++firstNonBlankCharacter;
+            else
+                break;
+        }
+        if (firstNonBlankCharacter >= line.length || selection.endColumn === firstNonBlankCharacter)
+            return false;
+
+        selection.endColumn = firstNonBlankCharacter;
+        if (!shift)
+            selection = selection.collapseToEnd();
+        this._restoreSelection(selection);
+        return true;
+    },
+
+    /**
      * @param {string} regex
      * @param {string} cssClass
      * @return {WebInspector.TextEditorMainPanel.HighlightDescriptor}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to