Diff
Modified: trunk/LayoutTests/ChangeLog (142438 => 142439)
--- trunk/LayoutTests/ChangeLog 2013-02-11 09:04:50 UTC (rev 142438)
+++ trunk/LayoutTests/ChangeLog 2013-02-11 09:34:16 UTC (rev 142439)
@@ -1,3 +1,22 @@
+2013-02-11 Andrey Lushnikov <lushni...@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/editor-test.js:
+ (initialize_EditorTests.lineWithCursor):
+ (initialize_EditorTests.InspectorTest.textWithSelection): Added helper method to add selection symbols in text.
+ * 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-11 Philippe Normand <pnorm...@igalia.com>
Unreviewed, GTK gardening
Modified: trunk/LayoutTests/inspector/editor/editor-test.js (142438 => 142439)
--- trunk/LayoutTests/inspector/editor/editor-test.js 2013-02-11 09:04:50 UTC (rev 142438)
+++ trunk/LayoutTests/inspector/editor/editor-test.js 2013-02-11 09:34:16 UTC (rev 142439)
@@ -19,6 +19,26 @@
textModel.setText(lines.join("\n"));
}
+InspectorTest.textWithSelection = function(text, selection)
+{
+ if (!selection)
+ return text;
+
+ function lineWithCursor(line, column, cursorChar)
+ {
+ return line.substring(0, column) + cursorChar + line.substring(column);
+ }
+
+ var lines = text.split("\n");
+ selection = selection.normalize();
+ var endCursorChar = selection.isEmpty() ? "|" : "<";
+ lines[selection.endLine] = lineWithCursor(lines[selection.endLine], selection.endColumn, endCursorChar);
+ if (!selection.isEmpty()) {
+ lines[selection.startLine] = lineWithCursor(lines[selection.startLine], selection.startColumn, ">");
+ }
+ return lines.join("\n");
+}
+
InspectorTest.insertTextLine = function(line)
{
function enter()
Added: trunk/LayoutTests/inspector/editor/text-editor-home-button-expected.txt (0 => 142439)
--- trunk/LayoutTests/inspector/editor/text-editor-home-button-expected.txt (rev 0)
+++ trunk/LayoutTests/inspector/editor/text-editor-home-button-expected.txt 2013-02-11 09:34:16 UTC (rev 142439)
@@ -0,0 +1,95 @@
+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
+function foo()
+{
+ retu|rn 42;
+}
+function foo()
+{
+ |return 42;
+}
+
+Running: testFirstNonBlankCharacterFromWhitespace
+function foo()
+{
+ | return 42;
+}
+function foo()
+{
+ |return 42;
+}
+
+Running: testHomeButtonToggling
+function foo()
+{
+ | return 42;
+}
+function foo()
+{
+ |return 42;
+}
+function foo()
+{
+| return 42;
+}
+function foo()
+{
+ |return 42;
+}
+
+Running: testHomeButtonDoesNotChangeCursor
+fu|nction foo()
+{
+ return 42;
+}
+|function foo()
+{
+ return 42;
+}
+|function foo()
+{
+ return 42;
+}
+
+Running: testHomeButtonWithShift
+>function foo()
+{
+ retu<rn 42;
+}
+>function foo()
+{
+ <return 42;
+}
+>function foo()
+{
+< return 42;
+}
+>function foo()
+{
+ <return 42;
+}
+
+Running: testHomeButtonWithShiftInversed
+function foo()
+{
+ retu>rn 42;
+}<
+function foo()
+{
+ >return 42;
+}<
+function foo()
+{
+> return 42;
+}<
+function foo()
+{
+ >return 42;
+}<
+
Added: trunk/LayoutTests/inspector/editor/text-editor-home-button.html (0 => 142439)
--- trunk/LayoutTests/inspector/editor/text-editor-home-button.html (rev 0)
+++ trunk/LayoutTests/inspector/editor/text-editor-home-button.html 2013-02-11 09:34:16 UTC (rev 142439)
@@ -0,0 +1,124 @@
+<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());
+
+ function dumpTextEditorWithSelection()
+ {
+ InspectorTest.addResult(InspectorTest.textWithSelection(textEditor.text(), textEditor.selection()));
+ }
+
+ function homeButton(shift)
+ {
+ var key = WebInspector.isMac() ? "leftArrow" : "home";
+ var modifiers = WebInspector.isMac() ? ["metaKey"] : [];
+ if (shift)
+ modifiers.push("shiftKey");
+ eventSender.keyDown(key, modifiers);
+ }
+
+ InspectorTest.runTestSuite([
+ function testFirstNonBlankCharacter(next)
+ {
+ var selection = WebInspector.TextRange.createFromLocation(2, 8);
+ textEditor.setSelection(selection);
+ dumpTextEditorWithSelection();
+ homeButton(false);
+ dumpTextEditorWithSelection();
+ next();
+ },
+
+ function testFirstNonBlankCharacterFromWhitespace(next)
+ {
+ var selection = WebInspector.TextRange.createFromLocation(2, 2);
+ textEditor.setSelection(selection);
+ dumpTextEditorWithSelection();
+ homeButton(false);
+ dumpTextEditorWithSelection();
+ next();
+ },
+
+ function testHomeButtonToggling(next)
+ {
+ var selection = WebInspector.TextRange.createFromLocation(2, 2);
+ textEditor.setSelection(selection);
+ dumpTextEditorWithSelection();
+ homeButton(false);
+ dumpTextEditorWithSelection();
+ homeButton(false);
+ dumpTextEditorWithSelection();
+ homeButton(false);
+ dumpTextEditorWithSelection();
+ next();
+ },
+
+ function testHomeButtonDoesNotChangeCursor(next)
+ {
+ var selection = WebInspector.TextRange.createFromLocation(0, 2);
+ textEditor.setSelection(selection);
+ dumpTextEditorWithSelection();
+ homeButton(false);
+ dumpTextEditorWithSelection();
+ homeButton(false);
+ dumpTextEditorWithSelection();
+ next();
+ },
+
+ function testHomeButtonWithShift(next)
+ {
+ var selection = new WebInspector.TextRange(0, 0, 2, 8);
+ textEditor.setSelection(selection);
+ dumpTextEditorWithSelection();
+ homeButton(true);
+ dumpTextEditorWithSelection();
+ homeButton(true);
+ dumpTextEditorWithSelection();
+ homeButton(true);
+ dumpTextEditorWithSelection();
+ next();
+ },
+
+ function testHomeButtonWithShiftInversed(next)
+ {
+ var selection = new WebInspector.TextRange(3, 1, 2, 8);
+ textEditor.setSelection(selection);
+ dumpTextEditorWithSelection();
+ homeButton(true);
+ dumpTextEditorWithSelection();
+ homeButton(true);
+ dumpTextEditorWithSelection();
+ homeButton(true);
+ dumpTextEditorWithSelection();
+ 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 (142438 => 142439)
--- trunk/LayoutTests/platform/efl/TestExpectations 2013-02-11 09:04:50 UTC (rev 142438)
+++ trunk/LayoutTests/platform/efl/TestExpectations 2013-02-11 09:34:16 UTC (rev 142439)
@@ -1835,6 +1835,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 (142438 => 142439)
--- trunk/LayoutTests/platform/mac/TestExpectations 2013-02-11 09:04:50 UTC (rev 142438)
+++ trunk/LayoutTests/platform/mac/TestExpectations 2013-02-11 09:34:16 UTC (rev 142439)
@@ -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 (142438 => 142439)
--- trunk/LayoutTests/platform/qt/TestExpectations 2013-02-11 09:04:50 UTC (rev 142438)
+++ trunk/LayoutTests/platform/qt/TestExpectations 2013-02-11 09:34:16 UTC (rev 142439)
@@ -2603,6 +2603,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
# [Qt] REGRESSION(r141634) test failing
webkit.org/b/108813 compositing/visibility/visibility-image-layers-dynamic.html [ Skip ]
Modified: trunk/Source/WebCore/ChangeLog (142438 => 142439)
--- trunk/Source/WebCore/ChangeLog 2013-02-11 09:04:50 UTC (rev 142438)
+++ trunk/Source/WebCore/ChangeLog 2013-02-11 09:34:16 UTC (rev 142439)
@@ -1,3 +1,18 @@
+2013-02-11 Andrey Lushnikov <lushni...@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-11 Abhishek Arya <infe...@chromium.org>
Add ASSERT_WITH_SECURITY_IMPLICATION to detect out of bounds access
Modified: trunk/Source/WebCore/inspector/front-end/DefaultTextEditor.js (142438 => 142439)
--- trunk/Source/WebCore/inspector/front-end/DefaultTextEditor.js 2013-02-11 09:04:50 UTC (rev 142438)
+++ trunk/Source/WebCore/inspector/front-end/DefaultTextEditor.js 2013-02-11 09:34:16 UTC (rev 142439)
@@ -1408,8 +1408,39 @@
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;
+
+ var homeKey = WebInspector.isMac() ? keys.Right : keys.Home;
+ var homeModifier = WebInspector.isMac() ? modifiers.Meta : modifiers.None;
+ this._shortcuts[WebInspector.KeyboardShortcut.makeKey(homeKey.code, homeModifier)] = this._handleHomeKey.bind(this, false);
+ this._shortcuts[WebInspector.KeyboardShortcut.makeKey(homeKey.code, homeModifier | 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;
+ },
+
_handleShowWhitespaceInEditorChange: function()
{
this._showWhitespace = WebInspector.settings.showWhitespaceInEditor.get();