Reviewed by Adele.
- test for http://bugzilla.opendarwin.org/show_bug.cgi?id=8871
<rdar://problem/
4575417>
REGRESSION: Pressing Enter/Return in a text input removes the selected text
and http://bugzilla.opendarwin.org/show_bug.cgi?id=9743
<rdar://problem/
4614228>
REGRESSION: crash dispatching JavaScript-created keyboard event to input element
* fast/forms/input-text-enter-expected.txt: Added.
* fast/forms/input-text-enter.html: Added.
WebCore:
Reviewed by Adele.
- fix http://bugzilla.opendarwin.org/show_bug.cgi?id=8871
<rdar://problem/
4575417>
REGRESSION: Pressing Enter/Return in a text input removes the selected text
- fix http://bugzilla.opendarwin.org/show_bug.cgi?id=9743
<rdar://problem/
4614228>
REGRESSION: crash dispatching JavaScript-created keyboard event to input element
* bridge/mac/FrameMac.mm: (WebCore::FrameMac::doTextFieldCommandFromEvent):
Add a null check to fix the crash, and a FIXME explaining why this is not necessarily
enough for the future.
* html/HTMLInputElement.cpp: (WebCore::HTMLInputElement::defaultEventHandler):
Consume Enter key keypress events even if the element is not in a form.
* platform/mac/KeyEventMac.mm: (WebCore::keyIdentifierForKeyEvent): Added \n to the
characters that turn into "Enter". Actual keyboard events always are \r or \003 on
the Macintosh, but in layout tests we can use \n, and everything other than the
code path here works, so worth fixing.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@15454
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2006-07-15 Darin Adler <darin@apple.com>
+
+ Reviewed by Adele.
+
+ - test for http://bugzilla.opendarwin.org/show_bug.cgi?id=8871
+ <rdar://problem/4575417>
+ REGRESSION: Pressing Enter/Return in a text input removes the selected text
+ and http://bugzilla.opendarwin.org/show_bug.cgi?id=9743
+ <rdar://problem/4614228>
+ REGRESSION: crash dispatching JavaScript-created keyboard event to input element
+
+ * fast/forms/input-text-enter-expected.txt: Added.
+ * fast/forms/input-text-enter.html: Added.
+
2006-07-15 Darin Adler <darin@apple.com>
Reviewed by John Sullivan.
--- /dev/null
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+This test selects some characters, then simulates a press of the Enter key (marked Return on Macintosh keyboards).
+
+
+Content of input after pressing return is "12345678". It should be "12345678".
+
+
--- /dev/null
+<p>This test selects some characters, then simulates a press of the Enter key (marked Return on Macintosh keyboards).</p>
+<p><input id="input" value="12345678"></input></p>
+<p>Content of input after pressing return is "<span id="result"></span>". It should be "12345678".</p>
+<script>
+if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+var input = document.getElementById("input");
+input.setSelectionRange(2, 6);
+var event = document.createEvent("KeyboardEvents");
+event.initKeyboardEvent("keypress", true, true, document.defaultView, "Enter", 0, false, false, false, false, false);
+input.dispatchEvent(event);
+if (window.eventSender)
+ eventSender.keyDown('\n', []);
+document.getElementById("result").innerText = input.value;
+</script>
+2006-07-15 Darin Adler <darin@apple.com>
+
+ Reviewed by Adele.
+
+ - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=8871
+ <rdar://problem/4575417>
+ REGRESSION: Pressing Enter/Return in a text input removes the selected text
+
+ - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=9743
+ <rdar://problem/4614228>
+ REGRESSION: crash dispatching JavaScript-created keyboard event to input element
+
+ * bridge/mac/FrameMac.mm: (WebCore::FrameMac::doTextFieldCommandFromEvent):
+ Add a null check to fix the crash, and a FIXME explaining why this is not necessarily
+ enough for the future.
+
+ * html/HTMLInputElement.cpp: (WebCore::HTMLInputElement::defaultEventHandler):
+ Consume Enter key keypress events even if the element is not in a form.
+
+ * platform/mac/KeyEventMac.mm: (WebCore::keyIdentifierForKeyEvent): Added \n to the
+ characters that turn into "Enter". Actual keyboard events always are \r or \003 on
+ the Macintosh, but in layout tests we can use \n, and everything other than the
+ code path here works, so worth fixing.
+
2006-07-15 Darin Adler <darin@apple.com>
Reviewed by John Sullivan.
bool FrameMac::doTextFieldCommandFromEvent(Element* input, const PlatformKeyboardEvent* event)
{
+ // FIXME: We might eventually need to make sure key bindings for editing work even with
+ // events created with the DOM API. Those don't have a PlatformKeyboardEvent.
+ if (!event)
+ return false;
+
BEGIN_BLOCK_OBJC_EXCEPTIONS;
return [_bridge textField:(DOMHTMLInputElement *)[DOMElement _elementWith:input] doCommandBySelector:selectorForKeyEvent(event)];
END_BLOCK_OBJC_EXCEPTIONS;
if (clickElement) {
click(false);
evt->setDefaultHandled();
- } else if (clickDefaultFormButton && form()) {
- form()->submitClick();
+ } else if (clickDefaultFormButton) {
+ if (form())
+ form()->submitClick();
evt->setDefaultHandled();
}
}
case NSEndFunctionKey:
return "End";
// "Enter"
- case 0x3: case 0xD: // Macintosh calls the one on the main keyboard Return, but Windows calls it Enter, so we'll do the same for the DOM
+ case 0x3: case 0xA: case 0xD: // Macintosh calls the one on the main keyboard Return, but Windows calls it Enter, so we'll do the same for the DOM
return "Enter";
// "EraseEof"
// "Zoom"
// More function keys, not in the key identifier specification.
- case NSF25FunctionKey:
+ case NSF25FunctionKey:
return "F25";
- case NSF26FunctionKey:
+ case NSF26FunctionKey:
return "F26";
- case NSF27FunctionKey:
+ case NSF27FunctionKey:
return "F27";
- case NSF28FunctionKey:
+ case NSF28FunctionKey:
return "F28";
- case NSF29FunctionKey:
+ case NSF29FunctionKey:
return "F29";
- case NSF30FunctionKey:
+ case NSF30FunctionKey:
return "F30";
- case NSF31FunctionKey:
+ case NSF31FunctionKey:
return "F31";
- case NSF32FunctionKey:
+ case NSF32FunctionKey:
return "F32";
- case NSF33FunctionKey:
+ case NSF33FunctionKey:
return "F33";
- case NSF34FunctionKey:
+ case NSF34FunctionKey:
return "F34";
- case NSF35FunctionKey:
+ case NSF35FunctionKey:
return "F35";
// Turn 0x7F into 0x08, because backspace needs to always be 0x08.
case NSDeleteFunctionKey:
return "U+00007F";
- case NSBeginFunctionKey:
- case NSBreakFunctionKey:
- case NSClearDisplayFunctionKey:
- case NSDeleteCharFunctionKey:
- case NSDeleteLineFunctionKey:
- case NSInsertCharFunctionKey:
- case NSInsertLineFunctionKey:
- case NSNextFunctionKey:
- case NSPrevFunctionKey:
- case NSPrintFunctionKey:
- case NSRedoFunctionKey:
- case NSResetFunctionKey:
- case NSSysReqFunctionKey:
- case NSSystemFunctionKey:
- case NSUserFunctionKey:
+ case NSBeginFunctionKey:
+ case NSBreakFunctionKey:
+ case NSClearDisplayFunctionKey:
+ case NSDeleteCharFunctionKey:
+ case NSDeleteLineFunctionKey:
+ case NSInsertCharFunctionKey:
+ case NSInsertLineFunctionKey:
+ case NSNextFunctionKey:
+ case NSPrevFunctionKey:
+ case NSPrintFunctionKey:
+ case NSRedoFunctionKey:
+ case NSResetFunctionKey:
+ case NSSysReqFunctionKey:
+ case NSSystemFunctionKey:
+ case NSUserFunctionKey:
// FIXME: We should use something other than the vendor-area Unicode values for the above keys.
// For now, just fall through to the default.
default:
{
// Check that this is the type of event that has a keyCode.
switch ([event type]) {
- case NSKeyDown:
- case NSKeyUp:
- case NSFlagsChanged:
+ case NSKeyDown:
+ case NSKeyUp:
+ case NSFlagsChanged:
break;
default:
return false;