Web Inspector: home button behaviour is wrong in DTE
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Feb 2013 17:46:41 +0000 (17:46 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Feb 2013 17:46:41 +0000 (17:46 +0000)
https://bugs.webkit.org/show_bug.cgi?id=109154

Patch by Andrey Lushnikov <lushnikov@chromium.org> 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:

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

LayoutTests/ChangeLog
LayoutTests/inspector/editor/text-editor-home-button-expected.txt [new file with mode: 0644]
LayoutTests/inspector/editor/text-editor-home-button.html [new file with mode: 0644]
LayoutTests/platform/efl/TestExpectations
LayoutTests/platform/mac/TestExpectations
LayoutTests/platform/qt/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/inspector/front-end/DefaultTextEditor.js

index 134dc38ceb6b930a8585d97bfc17132cb6647fc6..2ad272a7160bdc9d98da275d0158244f7882663d 100644 (file)
@@ -1,3 +1,19 @@
+2013-02-07  Andrey Lushnikov  <lushnikov@chromium.org>
+
+        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  <allan.jensen@digia.com>
 
         Scrollbars misplaced with accelerated compositing for overflow scroll
diff --git a/LayoutTests/inspector/editor/text-editor-home-button-expected.txt b/LayoutTests/inspector/editor/text-editor-home-button-expected.txt
new file mode 100644 (file)
index 0000000..9c06b86
--- /dev/null
@@ -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}
+
diff --git a/LayoutTests/inspector/editor/text-editor-home-button.html b/LayoutTests/inspector/editor/text-editor-home-button.html
new file mode 100644 (file)
index 0000000..699109e
--- /dev/null
@@ -0,0 +1,110 @@
+<html>
+<head>
+<script src="../../http/tests/inspector/inspector-test.js"></script>
+<script src="editor-test.js"></script>
+<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>
index c7cbf69c246b8e7f9e5e98602e5c1cd307d79b3e..5f9c301500a6bca299dce69262ef8358f8d102f9 100644 (file)
@@ -1819,6 +1819,7 @@ webkit.org/b/106743 media/video-controls-captions.html [ Failure ]
 # 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 ]
index bf67f23e8548bc7d738e5671254c35de50264289..95761285b80e5d8f4d750848604a2f058013dea7 100644 (file)
@@ -254,6 +254,7 @@ animations/play-state.html
 # 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
index 334b97c0ad71ea3358d1353524c7c2bd6e1311f4..a7f251f5f9022f6bc039b0476dd73ab0b1a12d21 100644 (file)
@@ -2601,6 +2601,7 @@ webkit.org/b/39725 fast/events/drag-and-drop-autoscroll.html [ Skip ]
 # 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 ]
index 0be1159ad87e15368a83feaec904071e9b46eabd..57b9a3df26ebb40efe3ea730317bb055a888e317 100644 (file)
@@ -1,3 +1,18 @@
+2013-02-07  Andrey Lushnikov  <lushnikov@chromium.org>
+
+        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  <gavinp@chromium.org>
 
         Unreviewed, rolling out r142112.
index 2ae81de2e402f478d697d79e06286a8d556a3dc5..601e58ab96bc9166fa4d8834d4f64bf7ff2b059b 100644 (file)
@@ -1397,6 +1397,35 @@ WebInspector.TextEditorMainPanel.prototype = {
         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;
     },
 
     /**