Commit 3ba66c39 authored by ap@webkit.org's avatar ap@webkit.org

Reviewed by Darin.

        Live to the promise of never making AppKit special character codes visible via DOM.

        Test: fast/events/arrow-keys-on-body.html

        * page/EventHandler.cpp:
        (WebCore::EventHandler::keyEvent): Check for empty keypress characters after disambiguation,
        to let quirks-aware code strip special charactrers.
        * platform/mac/KeyEventMac.mm:
        (WebCore::PlatformKeyboardEvent::disambiguateKeyDownEvent): If not in keyboard event quirks
        mode, remove the text if it's a special character.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@28813 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 4edae2b5
2007-12-17 Alexey Proskuryakov <ap@webkit.org>
Reviewed by Darin.
Live to the promise of never making AppKit special character codes visible via DOM.
* fast/events/arrow-keys-on-body-expected.txt: Added.
* fast/events/arrow-keys-on-body.html: Added.
2007-12-16 Darin Adler <darin@apple.com>
* fast/js/regexp-overflow-expected.txt: Updated. I accidentally checked in an
......
Test that arrow keys do not dispatch keypress events even if there is no default handler.
To test manually, press arrow keys and verify that no keypress events are logged.
target - type - ctrlKey,altKey,shiftKey,metaKey - keyIdentifier - keyLocation - keyCode - charCode
BODY - keydown - false,false,false,false - Left - DOM_KEY_LOCATION_STANDARD - 37 - 0
BODY - keyup - false,false,false,false - Left - DOM_KEY_LOCATION_STANDARD - 37 - 0
<body
onkeypress="log(eventInfo(event))"
onkeydown="log(eventInfo(event))"
onkeyup="log(eventInfo(event))">
<p>Test that arrow keys do not dispatch keypress events even if there is no default handler.</p>
<p>To test manually, press arrow keys and verify that no keypress events are logged.</p>
<div id="log"></div>
<script>
function log(msg) {
document.getElementById("log").innerHTML+= msg + "<br />";
}
function locationName(code) {
switch (code) {
case 0:
return "DOM_KEY_LOCATION_STANDARD";
case 1:
return "DOM_KEY_LOCATION_LEFT";
case 2:
return "DOM_KEY_LOCATION_RIGHT";
case 3:
return "DOM_KEY_LOCATION_NUMPAD";
default:
return code.toString();
}
}
function eventInfo(event, where) {
try {
if (!event)
event = window.event;
target = event.srcElement ? event.srcElement : event.target;
if (event.type == "textInput")
return (where ? "(" + where + ") " : "") + target.tagName + " - " + event.type + " - " + event.data
+ '. Value: "' + target.value + '".';
else if (event.type == "keydown" || event.type == "keypress" || event.type == "keyup")
return (where ? "(" + where + ") " : "") + target.tagName
+ (target.tagName == "INPUT" ? " " + target.type : "")
+ " - " + event.type
+ ' - ' + [event.ctrlKey, event.altKey, event.shiftKey, event.metaKey]
+ ' - ' + event.keyIdentifier
+ ' - ' + (event.keyLocation === undefined ? "undefined" : locationName(event.keyLocation))
+ ' - ' + event.keyCode
+ ' - ' + event.charCode;
} catch (ex) {
alert(ex);
}
}
log("target - type - " + ["ctrlKey", "altKey", "shiftKey", "metaKey"]
+ ' - ' + "keyIdentifier"
+ ' - ' + "keyLocation"
+ ' - ' + "keyCode"
+ ' - ' + "charCode");
if (window.layoutTestController) {
layoutTestController.dumpAsText();
eventSender.keyDown("leftArrow", []);
}
</script>
</body>
2007-12-17 Alexey Proskuryakov <ap@webkit.org>
Reviewed by Darin.
Live to the promise of never making AppKit special character codes visible via DOM.
Test: fast/events/arrow-keys-on-body.html
* page/EventHandler.cpp:
(WebCore::EventHandler::keyEvent): Check for empty keypress characters after disambiguation,
to let quirks-aware code strip special charactrers.
* platform/mac/KeyEventMac.mm:
(WebCore::PlatformKeyboardEvent::disambiguateKeyDownEvent): If not in keyboard event quirks
mode, remove the text if it's a special character.
2007-12-17 Mark Rowe <mrowe@apple.com>
Reviewed by Darin Adler.
......
......@@ -1548,7 +1548,7 @@ bool EventHandler::keyEvent(const PlatformKeyboardEvent& initialKeyEvent)
node->dispatchEvent(keydown, ec, true);
bool keydownResult = keydown->defaultHandled() || keydown->defaultPrevented();
if (handledByInputMethod || (keydownResult && !backwardCompatibilityMode) || initialKeyEvent.text().isEmpty())
if (handledByInputMethod || (keydownResult && !backwardCompatibilityMode))
return keydownResult;
// Focus may have changed during keydown handling, so refetch node.
......@@ -1561,6 +1561,8 @@ bool EventHandler::keyEvent(const PlatformKeyboardEvent& initialKeyEvent)
PlatformKeyboardEvent keyPressEvent = initialKeyEvent;
keyPressEvent.disambiguateKeyDownEvent(PlatformKeyboardEvent::Char, backwardCompatibilityMode);
if (keyPressEvent.text().isEmpty())
return keydownResult;
RefPtr<KeyboardEvent> keypress = new KeyboardEvent(keyPressEvent, m_frame->document()->defaultView());
keypress->setTarget(node);
if (keydownResult)
......
......@@ -857,6 +857,13 @@ void PlatformKeyboardEvent::disambiguateKeyDownEvent(Type type, bool backwardCom
} else {
m_keyIdentifier = String();
m_windowsVirtualKeyCode = 0;
if (m_text.length() == 1 && (m_text[0U] >= 0xF700 && m_text[0U] <= 0xF7FF)) {
// According to NSEvents.h, OpenStep reserves the range 0xF700-0xF8FF for function keys. However, some actual private use characters
// happen to be in this range, e.g. the Apple logo (Option+Shift+K).
// 0xF7FF is an arbitrary cut-off.
m_text = String();
m_unmodifiedText = String();
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment