Changeset 28620 in webkit
- Timestamp:
- Dec 11, 2007, 11:11:46 AM (17 years ago)
- Location:
- trunk
- Files:
-
- 7 added
- 75 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r28612 r28620 1 2007-12-07 Alexey Proskuryakov <ap@webkit.org> 2 3 Reviewed by Darin. 4 5 <rdar://problem/5535636> 6 Have to press 4 times instead of 2 times to get the expected result of ^^ with german keyboard. 7 8 http://bugs.webkit.org/show_bug.cgi?id=13916 9 JavaScript detects Tab as a character input on a textfield validation 10 11 * platform/win/fast/events: Added. 12 * platform/win/fast/events/double-dead-char-expected.txt: Added. 13 * platform/win/fast/events/double-dead-char.html: Added. 14 * fast/events/key-events-in-input-button.html: Added 15 * fast/events/key-events-in-input-button-expected.txt: Added 16 * fast/events/key-events-in-input-text.html: Added 17 * fast/events/key-events-in-input-text-expected.txt: Added 18 19 * fast/events/access-key-self-destruct.html: 20 * fast/forms/listbox-onchange.html: 21 * fast/forms/listbox-selection.html: 22 * fast/forms/access-key.html: 23 * fast/forms/legend-access-key.html: 24 * fast/forms/enter-clicks-buttons.html: 25 * fast/forms/check-box-enter-key.html: 26 * fast/forms/button-enter-click.html: 27 * fast/events/onsearch-enter.html: 28 * fast/events/onchange-passwordfield.html: 29 * fast/events/onchange-searchfield.html: 30 * fast/events/onchange-textfield.html: 31 Use eventSender instead of DOM events, because it emulates the real user action much better, 32 and we weren't getting cross-browser compatibility for the tests anyway. 33 34 * fast/events/frame-tab-focus.html: 35 * fast/html/tab-order.html: 36 * fast/forms/select-enter-key.html: 37 * fast/forms/focus2-expected.txt: 38 * fast/forms/focus2.html: 39 * fast/events/option-tab.html: 40 Dispatch a keydown instead of keypress, as this is when default processing is now done. 41 Possibly, it would be better stiull to use eventSender here, as well. 42 43 * fast/forms/onchange-enter-submit.html: 44 * fast/forms/select-double-onchange.html: 45 * fast/forms/textfield-onchange-deletion.html: 46 The correct code is '\r', not '\n' - previously, the difference was lost while converting 47 events back and forth. 48 49 * fast/forms/search-event-delay.html: Use a new named key to dispatch backspace - the 50 character code for it is cross-platform, but key code is not. 51 Also changed the test to call notifyDone() from a timer - otherwise, DRT would hang as 52 WM_KEYUP was dispatched after WM_QUIT. I tried and couldn't make DRT work, but I'm 53 fairly confident that this issue doesn't affect Safari. 54 55 * fast/events/keydown-keypress-preventDefault-expected.txt: 56 * fast/events/keydown-keypress-preventDefault.html: 57 This test claimed that its expacted behavior matched both IE and Firefox, but it did not. 58 We now match IE. 59 60 * fast/events/js-keyboard-event-creation-expected.txt: 61 * fast/events/js-keyboard-event-creation.html: 62 This test was problematic, because it was tabbing out to chrome, and that doesn't work 63 well in DRT. I have added another input for it to have a nicer target. 64 65 * platform/mac/fast/events/objc-event-api-expected.txt: 66 Updated for new behavior: 67 - eventSender.keyDown() now dispatches a keyUp, too; 68 - raw events do not have charCode; 69 - keypresses do not have keyIdentifiers. 70 1 71 2007-12-10 Oliver Hunt <oliver@apple.com> 2 72 -
trunk/LayoutTests/fast/events/access-key-self-destruct.html
r26721 r28620 6 6 function test() 7 7 { 8 if (window.layoutTestController) 8 if (window.layoutTestController) { 9 9 layoutTestController.dumpAsText(); 10 11 var event = document.createEvent("KeyboardEvent"); 12 if (navigator.userAgent.search(/\bMac OS X\b/) != -1) 13 event.initKeyboardEvent("keydown", true, true, document.defaultView, "a", 0, true, false, false, false, false); 14 else 15 event.initKeyboardEvent("keydown", true, true, document.defaultView, "a", 0, false, true, false, false, false); 16 document.dispatchEvent(event); 10 if (navigator.userAgent.search(/\bMac OS X\b/) != -1) 11 modifier = "ctrlKey"; 12 else 13 modifier = "altKey"; 14 eventSender.keyDown("a", [modifier]); 15 } 17 16 } 18 17 </script> -
trunk/LayoutTests/fast/events/frame-tab-focus.html
r21445 r28620 90 90 var event = document.createEvent('KeyboardEvents'); 91 91 var tabKeyIdentifier = 'U+0009'; 92 event.initKeyboardEvent('key press', true, true, document.defaultView, tabKeyIdentifier, 0, false, altKey, shiftKey, false, false);92 event.initKeyboardEvent('keydown', true, true, document.defaultView, tabKeyIdentifier, 0, false, altKey, shiftKey, false, false); 93 93 element.dispatchEvent(event); 94 94 } -
trunk/LayoutTests/fast/events/js-keyboard-event-creation-expected.txt
r21687 r28620 1 1 2 2 This tests that DOMKeyboardEvents are created correctly in the JavaScript API. 3 3 4 keydown - key: U+0009@0 (keyCode/charCode: 9/ 9) modifiers: false,false,false,false4 keydown - key: U+0009@0 (keyCode/charCode: 9/0) modifiers: false,false,false,false 5 5 6 keypress - key: U+0009@0 (keyCode/charCode: 9/9) modifiers: false,false,false,false 7 8 keydown - key: U+0009@0 (keyCode/charCode: 9/9) modifiers: false,false,true,false 9 10 keypress - key: U+0009@0 (keyCode/charCode: 9/9) modifiers: false,false,true,false 6 keyup - key: U+0009@0 (keyCode/charCode: 9/0) modifiers: false,false,true,false -
trunk/LayoutTests/fast/events/js-keyboard-event-creation.html
r17124 r28620 15 15 input.addEventListener("keyup", keyevent, true); 16 16 17 if ( layoutTestController)17 if (window.layoutTestController) 18 18 layoutTestController.dumpAsText(); 19 19 … … 29 29 <form> 30 30 <input type="text" size="50" id="testinput" /> 31 <input type="text" size="50" /> 31 32 </form> 32 33 -
trunk/LayoutTests/fast/events/keydown-keypress-preventDefault-expected.txt
r24542 r28620 1 This tests that preventing the default behavior for a keydown event will not prevent the keypress event from firing, butwill prevent text from being inserted.2 This matches IE7 and Firefox.1 This tests that preventing the default behavior for a keydown event will prevent the keypress event from firing, and will prevent text from being inserted. 2 This matches IE7, but not Firefox, which still dispatches a keypress. 3 3 4 4 key down 5 key press6 5 key down 7 key press8 6 key down 9 key press10 7 key down 11 key press12 8 13 9 -
trunk/LayoutTests/fast/events/keydown-keypress-preventDefault.html
r24542 r28620 20 20 </script> 21 21 <body onload="test()"> 22 This tests that preventing the default behavior for a keydown event will not prevent the keypress event from firing, butwill prevent text from being inserted.<br>23 This matches IE7 and Firefox.<br>24 <input id="tf" onkeydown="log('key down'); event.preventDefault();" onkeypress="log('key press')">22 This tests that preventing the default behavior for a keydown event will prevent the keypress event from firing, and will prevent text from being inserted.<br> 23 This matches IE7, but not Firefox, which still dispatches a keypress.<br> 24 <input id="tf" onkeydown="log('key down'); return false" onkeypress="log('key press')"> 25 25 <br> 26 26 <div id="res"></div> -
trunk/LayoutTests/fast/events/onchange-passwordfield.html
r21045 r28620 28 28 29 29 // hit enter 30 var enterEvent = document.createEvent("KeyboardEvents");31 enterEvent.initKeyboardEvent("keypress", true, false, window, "Enter", 0, false, false, false, false, false); // This is not at all like pulling teeth 32 input.dispatchEvent(enterEvent);30 input.focus(); 31 if (window.eventSender) 32 eventSender.keyDown("\r", []); 33 33 34 34 </script> -
trunk/LayoutTests/fast/events/onchange-searchfield.html
r21045 r28620 28 28 29 29 // hit enter 30 var enterEvent = document.createEvent("KeyboardEvents");31 enterEvent.initKeyboardEvent("keypress", true, false, window, "Enter", 0, false, false, false, false, false); // This is not at all like pulling teeth 32 input.dispatchEvent(enterEvent);30 input.focus(); 31 if (window.eventSender) 32 eventSender.keyDown("\r", []); 33 33 34 34 </script> -
trunk/LayoutTests/fast/events/onchange-textfield.html
r21045 r28620 28 28 29 29 // hit enter 30 var enterEvent = document.createEvent("KeyboardEvents");31 enterEvent.initKeyboardEvent("keypress", true, false, window, "Enter", 0, false, false, false, false, false); // This is not at all like pulling teeth 32 input.dispatchEvent(enterEvent);30 input.focus(); 31 if (window.eventSender) 32 eventSender.keyDown("\r", []); 33 33 34 34 </script> -
trunk/LayoutTests/fast/events/onsearch-enter.html
r18384 r28620 6 6 var sf = document.getElementById('sf'); 7 7 sf.focus(); 8 var enterEvent = document.createEvent("KeyboardEvents"); 9 enterEvent.initKeyboardEvent("keypress", true, false, window, "Enter", 0, false, false, false, false, false); 10 sf.dispatchEvent(enterEvent); 11 if (window.layoutTestController) 8 if (window.layoutTestController) { 12 9 layoutTestController.dumpAsText(); 10 eventSender.keyDown("\r", []); 11 } 13 12 } 14 13 function log(msg) -
trunk/LayoutTests/fast/events/option-tab.html
r21445 r28620 15 15 document.getElementById(fieldId).focus(); 16 16 var event = document.createEvent("KeyboardEvents"); 17 event.initKeyboardEvent("key press", true, true, document.defaultView, "U+0009", 0, false, true, false, false, false);17 event.initKeyboardEvent("keydown", true, true, document.defaultView, "U+0009", 0, false, true, false, false, false); 18 18 document.getElementById(fieldId).dispatchEvent(event); 19 19 if (window.linkFocused) … … 25 25 document.getElementById(fieldId).focus(); 26 26 event = document.createEvent("KeyboardEvents"); 27 event.initKeyboardEvent("key press", true, true, document.defaultView, "U+0009", 0, false, false, false, false, false);27 event.initKeyboardEvent("keydown", true, true, document.defaultView, "U+0009", 0, false, false, false, false, false); 28 28 document.getElementById(fieldId).dispatchEvent(event); 29 29 if (window.linkFocused) -
trunk/LayoutTests/fast/forms/access-key.html
r27599 r28620 10 10 function pressKey(key) 11 11 { 12 var event = document.createEvent("KeyboardEvent");13 12 if (navigator.userAgent.search(/\bMac OS X\b/) != -1) 14 event.initKeyboardEvent("keydown", true, true, document.defaultView, key, 0, true, false, false, false, false);13 modifier = "ctrlKey"; 15 14 else 16 event.initKeyboardEvent("keydown", true, true, document.defaultView, key, 0, false, true, false, false, false);17 document.dispatchEvent(event);15 modifier = "altKey"; 16 eventSender.keyDown(key, [modifier]); 18 17 } 19 18 function test() 20 19 { 21 if (window.layoutTestController) 20 if (window.layoutTestController) { 22 21 layoutTestController.dumpAsText(); 23 22 24 for (i = 1; i <= 9; i++) 25 pressKey(i); 26 pressKey("a"); 27 pressKey("b"); 28 pressKey("c"); 23 for (i = 1; i <= 9; i++) 24 pressKey(i.toString()); 25 pressKey("a"); 26 pressKey("b"); 27 pressKey("c"); 28 } 29 29 } 30 30 </script> -
trunk/LayoutTests/fast/forms/button-enter-click.html
r21174 r28620 5 5 var bt = document.getElementById('bt'); 6 6 bt.focus(); 7 if (window.layoutTestController) 7 if (window.layoutTestController) { 8 8 layoutTestController.dumpAsText(); 9 var keyEvent = document.createEvent("KeyboardEvents"); 10 keyEvent.initKeyboardEvent("keypress", true, true, window, "Enter", 0, false, false, false, false, false); 11 bt.dispatchEvent(keyEvent); 9 eventSender.keyDown("\r", []); 10 } 12 11 } 13 12 function log(msg) { -
trunk/LayoutTests/fast/forms/check-box-enter-key.html
r11995 r28620 19 19 function test() 20 20 { 21 if (window.layoutTestController) 21 document.getElementById("form").onsubmit = submitHandler; 22 document.getElementById("check").focus(); 23 if (window.layoutTestController) { 22 24 layoutTestController.dumpAsText(); 23 24 document.getElementById("form").onsubmit = submitHandler; 25 var event = document.createEvent("KeyboardEvents"); 26 event.initKeyboardEvent("keypress", true, true, document.defaultView, "Enter", 0, false, false, false, false, false); 27 document.getElementById("check").dispatchEvent(event); 25 eventSender.keyDown("\r", []); 26 } 28 27 } 29 28 </script> -
trunk/LayoutTests/fast/forms/enter-clicks-buttons.html
r27652 r28620 26 26 layoutTestController.dumpAsText(); 27 27 28 var keys = ['Enter', 'U+0020']; 28 var keys = ['\r', ' ']; 29 var keyNames = ['Enter', 'U+0020']; 29 30 var tagNames = ['button', 'input']; 30 31 31 32 for (var i in keys) { 32 log('\n\nSending ' + key s[i] + ' keypresses...\n');33 log('\n\nSending ' + keyNames[i] + ' keypresses...\n'); 33 34 for (var j in tagNames) { 34 35 var elements = document.getElementsByTagName(tagNames[j]); 35 36 log('\nLooping over ' + elements.length + ' ' + tagNames[j] + ' elements...\n'); 36 37 for (var k = 0; k < elements.length; ++k) { 37 var event = elements[k].ownerDocument.createEvent("KeyboardEvent"); 38 event.initKeyboardEvent("keypress", true, true, elements[k].ownerDocument.defaultView, keys[i], 0, false, false, false, false, false); 39 elements[k].dispatchEvent(event); 38 elements[k].focus(); 39 eventSender.keyDown(keys[i], []); 40 40 } 41 41 } -
trunk/LayoutTests/fast/forms/focus2-expected.txt
r19636 r28620 6 6 PARENT DOCUMENT: 7 7 focus event: [to] BUTTON 8 key pressevent: [to] BUTTON8 keydown event: [to] BUTTON 9 9 blur event: [to] BUTTON 10 10 focus event: [to] CHECKBOX 11 key pressevent: [to] CHECKBOX11 keydown event: [to] CHECKBOX 12 12 blur event: [to] CHECKBOX 13 13 focus event: [to] FILE 14 key pressevent: [to] FILE14 keydown event: [to] FILE 15 15 blur event: [to] FILE 16 16 focus event: [to] IMAGE 17 key pressevent: [to] IMAGE17 keydown event: [to] IMAGE 18 18 blur event: [to] IMAGE 19 19 focus event: [to] ISINDEX 20 key pressevent: [to] ISINDEX20 keydown event: [to] ISINDEX 21 21 blur event: [to] ISINDEX 22 22 focus event: [to] PASSWORD 23 key pressevent: [to] PASSWORD23 keydown event: [to] PASSWORD 24 24 blur event: [to] PASSWORD 25 25 focus event: [to] RANGE 26 key pressevent: [to] RANGE26 keydown event: [to] RANGE 27 27 blur event: [to] RANGE 28 28 focus event: [to] RESET 29 key pressevent: [to] RESET29 keydown event: [to] RESET 30 30 blur event: [to] RESET 31 31 focus event: [to] SEARCH 32 key pressevent: [to] SEARCH32 keydown event: [to] SEARCH 33 33 blur event: [to] SEARCH 34 34 focus event: [to] SUBMIT 35 key pressevent: [to] SUBMIT35 keydown event: [to] SUBMIT 36 36 blur event: [to] SUBMIT 37 37 focus event: [to] TEXT 38 key pressevent: [to] TEXT38 keydown event: [to] TEXT 39 39 blur event: [to] TEXT 40 40 focus event: [to] TEXTAREA 41 key pressevent: [to] TEXTAREA41 keydown event: [to] TEXTAREA 42 42 blur event: [to] TEXTAREA 43 43 focus event: [to] DIV 44 key pressevent: [to] DIV44 keydown event: [to] DIV 45 45 blur event: [to] DIV 46 46 focus event: [to] ANCHOR … … 49 49 IFRAME DOCUMENT: 50 50 focus event: [to] BUTTON 51 key pressevent: [to] BUTTON51 keydown event: [to] BUTTON 52 52 blur event: [to] BUTTON 53 53 focus event: [to] CHECKBOX 54 key pressevent: [to] CHECKBOX54 keydown event: [to] CHECKBOX 55 55 blur event: [to] CHECKBOX 56 56 focus event: [to] FILE 57 key pressevent: [to] FILE57 keydown event: [to] FILE 58 58 blur event: [to] FILE 59 59 focus event: [to] IMAGE 60 key pressevent: [to] IMAGE60 keydown event: [to] IMAGE 61 61 blur event: [to] IMAGE 62 62 focus event: [to] ISINDEX 63 key pressevent: [to] ISINDEX63 keydown event: [to] ISINDEX 64 64 blur event: [to] ISINDEX 65 65 focus event: [to] PASSWORD 66 key pressevent: [to] PASSWORD66 keydown event: [to] PASSWORD 67 67 blur event: [to] PASSWORD 68 68 focus event: [to] RANGE 69 key pressevent: [to] RANGE69 keydown event: [to] RANGE 70 70 blur event: [to] RANGE 71 71 focus event: [to] RESET 72 key pressevent: [to] RESET72 keydown event: [to] RESET 73 73 blur event: [to] RESET 74 74 focus event: [to] SEARCH 75 key pressevent: [to] SEARCH75 keydown event: [to] SEARCH 76 76 blur event: [to] SEARCH 77 77 focus event: [to] SUBMIT 78 key pressevent: [to] SUBMIT78 keydown event: [to] SUBMIT 79 79 blur event: [to] SUBMIT 80 80 focus event: [to] TEXT 81 key pressevent: [to] TEXT81 keydown event: [to] TEXT 82 82 blur event: [to] TEXT 83 83 focus event: [to] TEXTAREA 84 key pressevent: [to] TEXTAREA84 keydown event: [to] TEXTAREA 85 85 blur event: [to] TEXTAREA 86 86 focus event: [to] DIV 87 key pressevent: [to] DIV87 keydown event: [to] DIV 88 88 blur event: [to] DIV 89 89 focus event: [to] ANCHOR -
trunk/LayoutTests/fast/forms/focus2.html
r21651 r28620 36 36 } 37 37 38 function key pressListener(event)38 function keydownListener(event) 39 39 { 40 log("key pressevent: [to] " + description(event.target) + "\n");40 log("keydown event: [to] " + description(event.target) + "\n"); 41 41 } 42 42 … … 55 55 function addEventListeners(element) 56 56 { 57 element.addEventListener('key press', keypressListener, false);57 element.addEventListener('keydown', keydownListener, false); 58 58 element.addEventListener('focus', focusListener, false); 59 59 element.addEventListener('blur', blurListener, false); … … 110 110 var event = document.createEvent("KeyboardEvents"); 111 111 var tabKeyIdentifier = "U+0009"; 112 event.initKeyboardEvent("key press", true, true, document.defaultView, tabKeyIdentifier, 0, false, true, shiftKey, false, false);112 event.initKeyboardEvent("keydown", true, true, document.defaultView, tabKeyIdentifier, 0, false, true, shiftKey, false, false); 113 113 element.dispatchEvent(event); 114 114 } -
trunk/LayoutTests/fast/forms/legend-access-key.html
r26721 r28620 10 10 function test() 11 11 { 12 if (window.layoutTestController) 12 if (window.layoutTestController) { 13 13 layoutTestController.dumpAsText(); 14 14 15 var event = document.createEvent("KeyboardEvent");16 if (navigator.userAgent.search(/\bMac OS X\b/) != -1)17 e vent.initKeyboardEvent("keydown", true, true, document.defaultView, "f", 0, true, false, false, false, false);18 else19 event .initKeyboardEvent("keydown", true, true, document.defaultView, "f", 0, false, true, false, false, false);20 document.dispatchEvent(event);15 if (navigator.userAgent.search(/\bMac OS X\b/) != -1) 16 modifier = "ctrlKey"; 17 else 18 modifier = "altKey"; 19 eventSender.keyDown("f", [modifier]); 20 } 21 21 } 22 22 </script> -
trunk/LayoutTests/fast/forms/listbox-onchange.html
r26687 r28620 52 52 53 53 log("6) Make sure onChange fires when changing the selection with the keyboard"); 54 key PressOnSelect("sl1", "Down", true, false);54 keyDownOnSelect("sl1", "downArrow", true, false); 55 55 checkSelection("0,1"); 56 56 … … 148 148 } 149 149 150 function key PressOnSelect(selId, identifier, shift, metaOrCtrl)150 function keyDownOnSelect(selId, identifier, shift, metaOrCtrl) 151 151 { 152 var meta = false; 153 var ctrl = false; 152 modifiers = []; 153 if (shift) 154 modifiers[0] = "shiftKey"; 154 155 if (metaOrCtrl) { 155 156 if (navigator.userAgent.search(/\bMac OS X\b/) != -1) 156 m eta = true;157 modifiers[modifiers.length] = "metaKey"; 157 158 else 158 ctrl = true;159 modifiers[modifiers.length] = "controlKey"; 159 160 } 160 var sl = document.getElementById(selId); 161 var event = document.createEvent("KeyboardEvents"); 162 event.initKeyboardEvent("keypress", true, true, document.defaultView, identifier, 0, ctrl, false, shift, meta, false); 163 sl.dispatchEvent(event); 161 162 document.getElementById(selId).focus(); 163 eventSender.keyDown(identifier, modifiers); 164 164 } 165 165 -
trunk/LayoutTests/fast/forms/listbox-selection.html
r26687 r28620 45 45 46 46 // 3) Select one item with the keyboard (no previous selection) 47 key PressOnSelect("sl3", "Up", false, false);47 keyDownOnSelect("sl3", "upArrow", false, false); 48 48 expectedSelectionResults = new Array(false, false, false, false, true); 49 49 testResults(expectedSelectionResults, 3); 50 50 51 51 // 4) Select one item with the keyboard (with previous selection) 52 key PressOnSelect("sl4", "Down", false, false);52 keyDownOnSelect("sl4", "downArrow", false, false); 53 53 expectedSelectionResults = new Array(false, false, true, false, false); 54 54 testResults(expectedSelectionResults, 4); … … 65 65 66 66 // 7) Attempt to select a range with the keyboard 67 key PressOnSelect("sl7", "Down", true, false);67 keyDownOnSelect("sl7", "downArrow", true, false); 68 68 expectedSelectionResults = new Array(false, false, true, false, false); 69 69 testResults(expectedSelectionResults, 7); … … 83 83 84 84 // 10) Select one item with the keyboard (no previous selection) 85 key PressOnSelect("sl10", "Up", false, false);85 keyDownOnSelect("sl10", "upArrow", false, false); 86 86 expectedSelectionResults = new Array(false, false, false, false, true); 87 87 testResults(expectedSelectionResults, 10); 88 88 89 89 // 11) Select one item with the keyboard (with previous selection) 90 key PressOnSelect("sl11", "Down", false, false);90 keyDownOnSelect("sl11", "downArrow", false, false); 91 91 expectedSelectionResults = new Array(false, false, true, false, false); 92 92 testResults(expectedSelectionResults, 11); … … 103 103 104 104 // 14) Select a range with the keyboard 105 key PressOnSelect("sl14", "Down", true, false);105 keyDownOnSelect("sl14", "downArrow", true, false); 106 106 expectedSelectionResults = new Array(false, true, true, false, false); 107 107 testResults(expectedSelectionResults, 14); … … 131 131 } 132 132 133 function keyPressOnSelect(selId, identifier, shift, metaOrCtrl) 134 { 135 var meta = false; 136 var ctrl = false; 133 function keyDownOnSelect(selId, identifier, shift, metaOrCtrl) 134 { 135 modifiers = []; 136 if (shift) 137 modifiers[0] = "shiftKey"; 137 138 if (metaOrCtrl) { 138 139 if (navigator.userAgent.search(/\bMac OS X\b/) != -1) 139 m eta = true;140 modifiers[modifiers.length] = "metaKey"; 140 141 else 141 ctrl = true; 142 } 143 var sl = document.getElementById(selId); 144 sl.focus(); 145 var event = document.createEvent("KeyboardEvents"); 146 event.initKeyboardEvent("keypress", true, true, document.defaultView, identifier, 0, ctrl, false, shift, meta, false); 147 sl.dispatchEvent(event); 142 modifiers[modifiers.length] = "controlKey"; 143 } 144 145 document.getElementById(selId).focus(); 146 eventSender.keyDown(identifier, modifiers); 148 147 } 149 148 -
trunk/LayoutTests/fast/forms/onchange-enter-submit.html
r15720 r28620 17 17 if (window.layoutTestController) { 18 18 eventSender.keyDown('a'); 19 eventSender.keyDown('\ n');19 eventSender.keyDown('\r'); 20 20 } 21 21 -
trunk/LayoutTests/fast/forms/search-event-delay.html
r19336 r28620 13 13 { 14 14 if (window.eventSender) 15 eventSender.keyDown(" \x7F");15 eventSender.keyDown("delete"); 16 16 } 17 17 … … 34 34 } else { 35 35 if (window.layoutTestController) 36 layoutTestController.notifyDone();36 setTimeout("layoutTestController.notifyDone()", 0); // Do it on a timer to avoid Windows DRT hanging. 37 37 } 38 38 } … … 56 56 <p>As of this writing we can't use DOM events to type into a search field, so the test uses the event sender and only runs under DumpRenderTree.</p> 57 57 58 <p><input id="search" type="search" incremental onkey press="keyEvent(event)" onsearch="searchEvent(event)"></p>58 <p><input id="search" type="search" incremental onkeydown="keyEvent(event)" onsearch="searchEvent(event)"></p> 59 59 60 60 <div>The two rows below should match.</div> -
trunk/LayoutTests/fast/forms/select-double-onchange.html
r21734 r28620 16 16 17 17 eventSender.keyDown("t", null); 18 eventSender.keyDown("\ n", null);18 eventSender.keyDown("\r", null); 19 19 } 20 20 -
trunk/LayoutTests/fast/forms/select-enter-key.html
r19633 r28620 14 14 function test() 15 15 { 16 if (window.layoutTestController) 16 document.getElementById("form").onsubmit = submitHandler; 17 document.getElementById("select").focus(); 18 if (window.layoutTestController) { 17 19 layoutTestController.dumpAsText(); 18 19 document.getElementById("form").onsubmit = submitHandler; 20 var event = document.createEvent("KeyboardEvents"); 21 event.initKeyboardEvent("keypress", true, true, document.defaultView, "Enter", 0, false, false, false, false, false); 22 document.getElementById("select").dispatchEvent(event); 20 eventSender.keyDown("\r", []); 21 } 23 22 } 24 23 </script> -
trunk/LayoutTests/fast/forms/textfield-onchange-deletion.html
r26934 r28620 11 11 document.getElementById('tf').focus(); 12 12 eventSender.keyDown('a'); 13 eventSender.keyDown("\ n", null);13 eventSender.keyDown("\r", null); 14 14 if (window.layoutTestController) 15 15 layoutTestController.notifyDone(); -
trunk/LayoutTests/fast/html/tab-order.html
r21445 r28620 20 20 var event = document.createEvent('KeyboardEvents'); 21 21 var tabKeyIdentifier = 'U+0009'; 22 event.initKeyboardEvent('key press', true, true, document.defaultView, tabKeyIdentifier, 0, false, false, shiftKey, false, false);22 event.initKeyboardEvent('keydown', true, true, document.defaultView, tabKeyIdentifier, 0, false, false, shiftKey, false, false); 23 23 element.dispatchEvent(event); 24 24 } -
trunk/LayoutTests/platform/mac/fast/events/objc-event-api-expected.txt
r28203 r28620 80 80 modifier keys: c:0 s:0 a:0 m:0 81 81 keyCode: 65 82 charCode: 9782 charCode: 0 83 83 event type: keypress 84 84 target: <body> … … 88 88 detail: 0 89 89 view: OK (document: OK) 90 keyIdentifier: U+004190 keyIdentifier: 91 91 keyLocation: 0 92 92 modifier keys: c:0 s:0 a:0 m:0 93 93 keyCode: 97 94 94 charCode: 97 95 event type: keyup 96 target: <body> 97 eventPhase: 3 98 bubbles: 1 99 cancelable: 1 100 detail: 0 101 view: OK (document: OK) 102 keyIdentifier: U+0041 103 keyLocation: 0 104 modifier keys: c:0 s:0 a:0 m:0 105 keyCode: 65 106 charCode: 0 95 107 event type: keydown 96 108 target: <body> … … 104 116 modifier keys: c:1 s:0 a:0 m:0 105 117 keyCode: 66 106 charCode: 98118 charCode: 0 107 119 event type: keypress 108 120 target: <body> … … 112 124 detail: 0 113 125 view: OK (document: OK) 114 keyIdentifier: U+0042126 keyIdentifier: 115 127 keyLocation: 0 116 128 modifier keys: c:1 s:0 a:0 m:0 117 129 keyCode: 98 118 130 charCode: 98 131 event type: keyup 132 target: <body> 133 eventPhase: 3 134 bubbles: 1 135 cancelable: 1 136 detail: 0 137 view: OK (document: OK) 138 keyIdentifier: U+0042 139 keyLocation: 0 140 modifier keys: c:1 s:0 a:0 m:0 141 keyCode: 66 142 charCode: 0 119 143 event type: keydown 120 144 target: <body> … … 128 152 modifier keys: c:0 s:1 a:0 m:0 129 153 keyCode: 68 130 charCode: 100154 charCode: 0 131 155 event type: keypress 132 156 target: <body> … … 136 160 detail: 0 137 161 view: OK (document: OK) 138 keyIdentifier: U+0044162 keyIdentifier: 139 163 keyLocation: 0 140 164 modifier keys: c:0 s:1 a:0 m:0 141 165 keyCode: 100 142 166 charCode: 100 167 event type: keyup 168 target: <body> 169 eventPhase: 3 170 bubbles: 1 171 cancelable: 1 172 detail: 0 173 view: OK (document: OK) 174 keyIdentifier: U+0044 175 keyLocation: 0 176 modifier keys: c:0 s:1 a:0 m:0 177 keyCode: 68 178 charCode: 0 143 179 event type: keydown 144 180 target: <body> … … 152 188 modifier keys: c:0 s:0 a:1 m:1 153 189 keyCode: 69 154 charCode: 101190 charCode: 0 155 191 event type: keypress 156 192 target: <body> … … 160 196 detail: 0 161 197 view: OK (document: OK) 162 keyIdentifier: U+0045198 keyIdentifier: 163 199 keyLocation: 0 164 200 modifier keys: c:0 s:0 a:1 m:1 165 201 keyCode: 101 166 202 charCode: 101 203 event type: keyup 204 target: <body> 205 eventPhase: 3 206 bubbles: 1 207 cancelable: 1 208 detail: 0 209 view: OK (document: OK) 210 keyIdentifier: U+0045 211 keyLocation: 0 212 modifier keys: c:0 s:0 a:1 m:1 213 keyCode: 69 214 charCode: 0 167 215 event type: mousemove 168 216 target: <div> -
trunk/WebCore/ChangeLog
r28616 r28620 1 2007-12-07 Alexey Proskuryakov <ap@webkit.org> 2 3 Reviewed by Darin. 4 5 <rdar://problem/5535636> 6 Have to press 4 times instead of 2 times to get the expected result of ^^ with german keyboard. 7 8 http://bugs.webkit.org/show_bug.cgi?id=13916 9 JavaScript detects Tab as a character input on a textfield validation 10 11 Test: platform/win/fast/events/double-dead-char.html 12 13 * platform/PlatformKeyboardEvent.h: 14 (WebCore::PlatformKeyboardEvent::): 15 (WebCore::PlatformKeyboardEvent::type): 16 (WebCore::PlatformKeyboardEvent::windowsVirtualKeyCode): 17 (WebCore::PlatformKeyboardEvent::setWindowsVirtualKeyCode): 18 (WebCore::PlatformKeyboardEvent::keyIdentifier): 19 (WebCore::PlatformKeyboardEvent::setIsAutoRepeat): 20 Added an explicit type member to differentiate different kinds of events: 21 RawKeyDown == keydown == WM_KEYDOWN 22 KeyUp == keyup == WM_KEYUP 23 Char == keypress == WM_CHAR 24 KeyDown == e.g. NSKeyDown or NSFlagsChanged, used on platforms that have a different model for 25 event processing, and needs to be converted to RawKeyDown (+ Char) for processing in DOM. 26 27 * platform/mac/KeyEventMac.mm: 28 (WebCore::PlatformKeyboardEvent::PlatformKeyboardEvent): Updated for changed data members. 29 Fix Enter (numeric keypad) charCode to match Return, as we check for it from keypress default handlers. 30 (WebCore::windowsKeyCodeForKeyEvent): 31 (WebCore::isKeyUpEvent): Made it do something closer to what it claims; added a FIXME explaining 32 that it still fails. 33 (WebCore::disambiguateKeyDownEvent): Downgrade from KeyDown to RawKeyDown or Char, removing information that 34 should not be available in those (because it cannot be provided on Windows). 35 36 * platform/win/KeyEventWin.cpp: 37 (WebCore::PlatformKeyboardEvent::PlatformKeyboardEvent): Updated for changed data members. 38 Used standard Windows constants for bit masks instead of our own ones. 39 (WebCore::PlatformKeyboardEvent::disambiguateKeyDownEvent): Should never be called on Windows. 40 41 * platform/gtk/KeyEventGtk.cpp: 42 (WebCore::PlatformKeyboardEvent::PlatformKeyboardEvent): 43 (WebCore::PlatformKeyboardEvent::disambiguateKeyDownEvent): 44 * platform/qt/PlatformKeyboardEventQt.cpp: 45 (WebCore::PlatformKeyboardEvent::PlatformKeyboardEvent): 46 (WebCore::PlatformKeyboardEvent::disambiguateKeyDownEvent): 47 * platform/wx/KeyboardEventWx.cpp: 48 (WebCore::PlatformKeyboardEvent::PlatformKeyboardEvent): 49 (WebCore::PlatformKeyboardEvent::disambiguateKeyDownEvent): 50 Updated for cross-platform changes as much as it was possible without appropriate build 51 environments. 52 53 * WebCore.base.exp: Export PlatformKeyboardEvent::disambiguateKeyDownEvent(), used by platforms that need to 54 convert their fancy key events to RawKeyDown/Char pairs. Export Editor::isTextInsertionCommand(). 55 56 * bridge/EditorClient.h: 57 Renamed handleKeypress() to handleKeyboardEvent(), as it gets both keydowns and keypresses. 58 Renamed handleInputMethodKeypress() to handleInputMethodKeydown(), as IMs work with raw keydowns. 59 60 * dom/Document.h: 61 * dom/Document.cpp: 62 (WebCore::Document::defaultEventHandler): Moved accesskey processing to EventHandler. 63 64 * dom/KeyboardEvent.h: Added comments describing keyCode/charCode behavior. 65 66 * dom/KeyboardEvent.cpp: 67 (WebCore::eventTypeForKeyboardEventType): 68 (WebCore::KeyboardEvent::KeyboardEvent): Conversion between platform and DOM event types is 69 now straightforward, so scary hacks such as using autorepeat to distinguish types are 70 not needed. 71 (WebCore::KeyboardEvent::keyCode): Added a comment describing other browsers' behavior. 72 (WebCore::KeyboardEvent::charCode): Added a comment describing other browsers' behavior. 73 Changed to a more compatible behavior: raw keydown/keyup events do not and can not have 74 character codes. 75 76 * editing/Editor.h: 77 * editing/Editor.cpp: 78 (WebCore::Editor::isTextInsertionCommand): Is this command actually text input in disguise? 79 (WebCore::Editor::handleKeyboardEvent): Updated for new function names. 80 (WebCore::Editor::handleInputMethodKeydown): Ditto. 81 82 * html/HTMLButtonElement.cpp: 83 (WebCore::HTMLButtonElement::defaultEventHandler): Perform the default action when handling an 84 appropriate event. Enter is processed on keypress (and thus should be checked for via charCode, 85 not keyIdentifier), Space is processed on keydown+keyup! We now match IE in that a button is 86 highlighted when Space is pressed. 87 88 * html/HTMLInputElement.cpp: 89 (WebCore::HTMLInputElement::defaultEventHandler): 90 * html/HTMLSelectElement.cpp: 91 (WebCore::HTMLSelectElement::menuListDefaultEventHandler): 92 (WebCore::HTMLSelectElement::listBoxDefaultEventHandler): 93 Made a number of fixes to when default actions take place, similar to HTMLButtonElement ones 94 described above. 95 96 * page/EventHandler.cpp: 97 (WebCore::EventHandler::keyEvent): Unless we have a combined KeyDown, just forward the event 98 to the target. Call accesskey handling directly, as it doesn't seem to be part of normal event 99 handling in IE. Also streamlined the code in KeyDown case, thanks to handleInputMethodKeypress() 100 now being handleInputMethodKeydown(). 101 (WebCore::EventHandler::handleTextInputEvent): Check that we were not called from keydown. 102 (WebCore::EventHandler::defaultTextInputEventHandler): Removed a call to defaultTabEventHandler, 103 as default tab handling happens when processing keydown. 104 (WebCore::handleAccessKey): Moved from Document, as access keys are processed outside normal 105 event handling. Fixed accesskey processing to use information that's available in a raw keydown 106 event. 107 108 (WebCore::EventHandler::defaultKeyboardEventHandler): Do not ignore keydown; in particular, 109 handle tabs during keydown processing. 110 111 * page/mac/EventHandlerMac.mm: 112 (WebCore::EventHandler::currentKeyboardEvent): Disambiguate KeyDown as RawKeyDown, as this is 113 what callers want. 114 115 * platform/text/PlatformString.h: 116 * platform/text/String.cpp: 117 (WebCore::String::characterStartingAt): 118 * platform/text/StringImpl.cpp: 119 (WebCore::StringImpl::characterStartingAt): 120 * platform/text/StringImpl.h: 121 Added a UChar32 accessor. 122 123 * svg/graphics/SVGImageEmptyClients.h: 124 (WebCore::SVGEmptyEditorClient::handleKeyboardEvent): 125 (WebCore::SVGEmptyEditorClient::handleInputMethodKeydown): 126 Updated for new function names. 127 1 128 2007-12-11 John Sullivan <sullivan@apple.com> 2 129 -
trunk/WebCore/WebCore.base.exp
r28468 r28620 355 355 __ZN7WebCore20ResourceResponseBase24setExpectedContentLengthEx 356 356 __ZN7WebCore21ContextMenuController16clearContextMenuEv 357 __ZN7WebCore21PlatformKeyboardEventC1EP7NSEventb 357 __ZN7WebCore21PlatformKeyboardEventC1EP7NSEvent 358 __ZN7WebCore21PlatformKeyboardEvent24disambiguateKeyDownEventENS0_4TypeEb 358 359 __ZN7WebCore21WindowsLatin1EncodingEv 359 360 __ZN7WebCore21findEventWithKeyStateEPNS_5EventE … … 415 416 __ZN7WebCore6Editor10insertTextERKNS_6StringEPNS_5EventE 416 417 __ZN7WebCore6Editor11canDHTMLCutEv 418 __ZN7WebCore6Editor22isTextInsertionCommandERKNS_12AtomicStringE 417 419 __ZN7WebCore6Editor11execCommandERKNS_12AtomicStringEPNS_5EventE 418 420 __ZN7WebCore6Editor11tryDHTMLCutEv -
trunk/WebCore/bridge/EditorClient.h
r25547 r28620 109 109 virtual void redo() = 0; 110 110 111 virtual void handleKey press(KeyboardEvent*) = 0;112 virtual void handleInputMethodKey press(KeyboardEvent*) = 0;111 virtual void handleKeyboardEvent(KeyboardEvent*) = 0; 112 virtual void handleInputMethodKeydown(KeyboardEvent*) = 0; 113 113 114 114 virtual void textFieldDidBeginEditing(Element*) = 0; -
trunk/WebCore/dom/Document.cpp
r28555 r28620 2443 2443 } 2444 2444 2445 2446 void Document::defaultEventHandler(Event *evt)2447 {2448 // handle accesskey2449 if (evt->type() == keydownEvent) {2450 KeyboardEvent* kevt = static_cast<KeyboardEvent *>(evt);2451 #if PLATFORM(MAC)2452 if (kevt->ctrlKey())2453 #else2454 if (kevt->altKey())2455 #endif2456 {2457 const PlatformKeyboardEvent* ev = kevt->keyEvent();2458 String key = (ev ? ev->unmodifiedText() : kevt->keyIdentifier()).lower();2459 Element* elem = getElementByAccessKey(key);2460 if (elem) {2461 elem->accessKeyAction(false);2462 evt->setDefaultHandled();2463 return;2464 }2465 }2466 }2467 2468 ContainerNode::defaultEventHandler(evt);2469 }2470 2471 2445 void Document::setHTMLWindowEventListener(const AtomicString &eventType, PassRefPtr<EventListener> listener) 2472 2446 { -
trunk/WebCore/dom/Document.h
r28327 r28620 484 484 CSSStyleDeclaration* getOverrideStyle(Element*, const String& pseudoElt); 485 485 486 virtual void defaultEventHandler(Event*);487 486 void handleWindowEvent(Event*, bool useCapture); 488 487 void setHTMLWindowEventListener(const AtomicString &eventType, PassRefPtr<EventListener>); -
trunk/WebCore/dom/KeyboardEvent.cpp
r25754 r28620 24 24 #include "KeyboardEvent.h" 25 25 26 #include "Document.h" 27 #include "DOMWindow.h" 26 28 #include "EventNames.h" 27 29 #include "PlatformKeyboardEvent.h" 30 #include "Settings.h" 28 31 29 32 namespace WebCore { 30 33 31 34 using namespace EventNames; 35 36 static inline const AtomicString& eventTypeForKeyboardEventType(PlatformKeyboardEvent::Type type) 37 { 38 switch (type) { 39 case PlatformKeyboardEvent::KeyUp: 40 return keyupEvent; 41 case PlatformKeyboardEvent::RawKeyDown: 42 return keydownEvent; 43 case PlatformKeyboardEvent::Char: 44 return keypressEvent; 45 case PlatformKeyboardEvent::KeyDown: 46 // The caller should disambiguate the combined event into RawKeyDown or Char events. 47 break; 48 } 49 ASSERT_NOT_REACHED(); 50 return keydownEvent; 51 } 32 52 33 53 KeyboardEvent::KeyboardEvent() … … 39 59 40 60 KeyboardEvent::KeyboardEvent(const PlatformKeyboardEvent& key, AbstractView* view) 41 : UIEventWithKeyState( key.isKeyUp() ? keyupEvent : key.isAutoRepeat() ? keypressEvent : keydownEvent,61 : UIEventWithKeyState(eventTypeForKeyboardEventType(key.type()), 42 62 true, true, view, 0, key.ctrlKey(), key.altKey(), key.shiftKey(), key.metaKey()) 43 63 , m_keyEvent(new PlatformKeyboardEvent(key)) 44 64 , m_keyIdentifier(key.keyIdentifier()) 45 , m_keyLocation(key.isKeypad() ? DOM_KEY_LOCATION_NUMPAD : DOM_KEY_LOCATION_STANDARD) 65 , m_keyLocation(key.isKeypad() ? DOM_KEY_LOCATION_NUMPAD : DOM_KEY_LOCATION_STANDARD) // FIXME: differentiate right/left, too 46 66 , m_altGraphKey(false) 47 67 { … … 97 117 int KeyboardEvent::keyCode() const 98 118 { 119 // IE: virtual key code for keyup/keydown, character code for keypress 120 // Firefox: virtual key code for keyup/keydown, zero for keypress 121 // We match IE. 99 122 if (!m_keyEvent) 100 123 return 0; 101 124 if (type() == keydownEvent || type() == keyupEvent) 102 return m_keyEvent-> WindowsKeyCode();125 return m_keyEvent->windowsVirtualKeyCode(); 103 126 return charCode(); 104 127 } … … 106 129 int KeyboardEvent::charCode() const 107 130 { 108 if (!m_keyEvent) 131 // IE: not supported 132 // Firefox: 0 for keydown/keyup events, character code for keypress 133 // We match Firefox, unless in Dashboard compatibility mode, where we always return the character code. 134 bool dashboardCompatibilityMode = false; 135 if (view()) 136 if (Settings* settings = view()->document()->settings()) 137 dashboardCompatibilityMode = settings->usesDashboardBackwardCompatibilityMode(); 138 139 if (!m_keyEvent || (type() != keypressEvent && !dashboardCompatibilityMode)) 109 140 return 0; 110 141 String text = m_keyEvent->text(); 111 if (text.length() != 1) 112 return 0; 113 return text[0]; 142 return static_cast<int>(text.characterStartingAt(0)); 114 143 } 115 144 -
trunk/WebCore/dom/KeyboardEvent.h
r25754 r28620 71 71 const PlatformKeyboardEvent* keyEvent() const { return m_keyEvent; } 72 72 73 int keyCode() const; // key code for keydown and keyup, character for other events74 int charCode() const; 73 int keyCode() const; // key code for keydown and keyup, character for keypress 74 int charCode() const; // character code for keypress, 0 for keydown and keyup 75 75 76 76 virtual bool isKeyboardEvent() const; -
trunk/WebCore/editing/Editor.cpp
r28126 r28620 112 112 } 113 113 114 void Editor::handleKey press(KeyboardEvent* event)114 void Editor::handleKeyboardEvent(KeyboardEvent* event) 115 115 { 116 116 if (EditorClient* c = client()) 117 117 if (selectionForEvent(m_frame, event).isContentEditable()) 118 c->handleKey press(event);119 } 120 121 void Editor::handleInputMethodKey press(KeyboardEvent* event)118 c->handleKeyboardEvent(event); 119 } 120 121 void Editor::handleInputMethodKeydown(KeyboardEvent* event) 122 122 { 123 123 if (EditorClient* c = client()) 124 124 if (selectionForEvent(m_frame, event).isContentEditable()) 125 c->handleInputMethodKey press(event);125 c->handleInputMethodKeydown(event); 126 126 } 127 127 … … 1327 1327 } 1328 1328 1329 bool Editor::isTextInsertionCommand(const AtomicString& command) 1330 { 1331 return command == "InsertBacktab" 1332 || command == "InsertTab" 1333 || command == "InsertLineBreak" 1334 || command == "InsertNewline"; 1335 } 1336 1329 1337 bool Editor::execCommand(const AtomicString& command, Event* triggeringEvent) 1330 1338 { -
trunk/WebCore/editing/Editor.h
r27874 r28620 78 78 EditCommand* lastEditCommand() { return m_lastEditCommand.get(); } 79 79 80 void handleKey press(KeyboardEvent*);81 void handleInputMethodKey press(KeyboardEvent*);80 void handleKeyboardEvent(KeyboardEvent*); 81 void handleInputMethodKeydown(KeyboardEvent*); 82 82 83 83 bool canEdit() const; … … 157 157 158 158 bool clientIsEditable() const; 159 159 160 static bool isTextInsertionCommand(const AtomicString&); 161 160 162 bool execCommand(const AtomicString&, Event* triggeringEvent = 0); 161 163 -
trunk/WebCore/html/HTMLButtonElement.cpp
r27652 r28620 92 92 } 93 93 94 if (evt->type() == keypressEvent && evt->isKeyboardEvent()) { 95 String key = static_cast<KeyboardEvent*>(evt)->keyIdentifier(); 96 97 if (key == "Enter" || key == "U+0020") { 98 dispatchSimulatedClick(evt); 94 if (evt->isKeyboardEvent()) { 95 if (evt->type() == keydownEvent && static_cast<KeyboardEvent*>(evt)->keyIdentifier() == "U+0020") { 96 setActive(true, true); 97 // No setDefaultHandled() - IE dispatches a keypress in this case. 98 return; 99 } 100 if (evt->type() == keypressEvent) { 101 switch (static_cast<KeyboardEvent*>(evt)->charCode()) { 102 case '\r': 103 dispatchSimulatedClick(evt); 104 evt->setDefaultHandled(); 105 return; 106 case ' ': 107 // Prevent scrolling down the page. 108 evt->setDefaultHandled(); 109 return; 110 default: 111 break; 112 } 113 } 114 if (evt->type() == keyupEvent && static_cast<KeyboardEvent*>(evt)->keyIdentifier() == "U+0020") { 115 if (active()) 116 dispatchSimulatedClick(evt); 99 117 evt->setDefaultHandled(); 100 118 return; -
trunk/WebCore/html/HTMLInputElement.cpp
r28212 r28620 1123 1123 } 1124 1124 1125 // Before calling the base class defaultEventHandler, which will call handleKeypress, call doTextFieldCommandFromEvent. 1126 if (isTextField() && evt->type() == keypressEvent && evt->isKeyboardEvent() && focused() && document()->frame() 1125 if (isTextField() && evt->type() == keydownEvent && evt->isKeyboardEvent() && focused() && document()->frame() 1127 1126 && document()->frame()->doTextFieldCommandFromEvent(this, static_cast<KeyboardEvent*>(evt))) { 1128 1127 evt->setDefaultHandled(); … … 1174 1173 bool clickElement = false; 1175 1174 1176 String key = static_cast<KeyboardEvent*>(evt)->keyIdentifier(); 1177 1178 if (key == "U+0020") { 1179 switch (inputType()) { 1180 case BUTTON: 1181 case CHECKBOX: 1182 case FILE: 1183 case IMAGE: 1184 case RESET: 1185 case SUBMIT: 1186 // Simulate mouse click for spacebar for these types of elements. 1187 // The AppKit already does this for some, but not all, of them. 1188 clickElement = true; 1189 break; 1190 case RADIO: 1191 // If an unselected radio is tabbed into (because the entire group has nothing 1192 // checked, or because of some explicit .focus() call), then allow space to check it. 1193 if (!checked()) 1194 clickElement = true; 1195 break; 1196 case HIDDEN: 1197 case ISINDEX: 1198 case PASSWORD: 1199 case RANGE: 1200 case SEARCH: 1201 case TEXT: 1202 break; 1203 } 1204 } 1205 1206 if (key == "Enter") { 1175 int charCode = static_cast<KeyboardEvent*>(evt)->charCode(); 1176 1177 if (charCode == '\r') { 1207 1178 switch (inputType()) { 1208 1179 case CHECKBOX: … … 1226 1197 case RADIO: 1227 1198 break; // Don't do anything for enter on a radio button. 1199 } 1200 } else if (charCode == ' ') { 1201 switch (inputType()) { 1202 case BUTTON: 1203 case CHECKBOX: 1204 case FILE: 1205 case IMAGE: 1206 case RESET: 1207 case SUBMIT: 1208 case RADIO: 1209 // Prevent scrolling down the page. 1210 evt->setDefaultHandled(); 1211 return; 1212 default: 1213 break; 1214 } 1215 } 1216 1217 if (clickElement) { 1218 dispatchSimulatedClick(evt); 1219 evt->setDefaultHandled(); 1220 return; 1221 } 1222 } 1223 1224 if (evt->type() == keydownEvent && evt->isKeyboardEvent()) { 1225 String key = static_cast<KeyboardEvent*>(evt)->keyIdentifier(); 1226 1227 if (key == "U+0020") { 1228 switch (inputType()) { 1229 case BUTTON: 1230 case CHECKBOX: 1231 case FILE: 1232 case IMAGE: 1233 case RESET: 1234 case SUBMIT: 1235 case RADIO: 1236 setActive(true, true); 1237 // No setDefaultHandled() - IE dispatches a keypress in this case. 1238 return; 1239 default: 1240 break; 1228 1241 } 1229 1242 } … … 1263 1276 } 1264 1277 } 1278 } 1279 1280 if (evt->type() == keyupEvent && evt->isKeyboardEvent()) { 1281 bool clickElement = false; 1282 1283 String key = static_cast<KeyboardEvent*>(evt)->keyIdentifier(); 1284 1285 if (key == "U+0020") { 1286 switch (inputType()) { 1287 case BUTTON: 1288 case CHECKBOX: 1289 case FILE: 1290 case IMAGE: 1291 case RESET: 1292 case SUBMIT: 1293 // Simulate mouse click for spacebar for these types of elements. 1294 // The AppKit already does this for some, but not all, of them. 1295 clickElement = true; 1296 break; 1297 case RADIO: 1298 // If an unselected radio is tabbed into (because the entire group has nothing 1299 // checked, or because of some explicit .focus() call), then allow space to check it. 1300 if (!checked()) 1301 clickElement = true; 1302 break; 1303 case HIDDEN: 1304 case ISINDEX: 1305 case PASSWORD: 1306 case RANGE: 1307 case SEARCH: 1308 case TEXT: 1309 break; 1310 } 1311 } 1265 1312 1266 1313 if (clickElement) { 1267 dispatchSimulatedClick(evt); 1314 if (active()) 1315 dispatchSimulatedClick(evt); 1268 1316 evt->setDefaultHandled(); 1269 1317 return; -
trunk/WebCore/html/HTMLSelectElement.cpp
r28524 r28620 620 620 RenderMenuList* menuList = static_cast<RenderMenuList*>(renderer()); 621 621 622 // Use key press event here since sending simulated mouse events 623 // on key down blocks the proper sending of the key press event. 624 if (evt->type() == keypressEvent) { 622 if (evt->type() == keydownEvent) { 625 623 if (!renderer() || !evt->isKeyboardEvent()) 626 624 return; … … 628 626 bool handled = false; 629 627 #if ARROW_KEYS_POP_MENU 630 if (keyIdentifier == "Enter") { 631 menuListOnChange(); 632 if (form()) 633 form()->submitClick(evt); 634 handled = true; 635 } 636 if (keyIdentifier == "Down" || keyIdentifier == "Up" || keyIdentifier == "U+0020") { 628 if (keyIdentifier == "Down" || keyIdentifier == "Up") { 637 629 focus(); 638 630 // Save the selection so it can be compared to the new selection when we call onChange during setSelectedIndex, … … 662 654 setSelectedIndex(listToOptionIndex(listIndex)); 663 655 handled = true; 664 } else if (keyIdentifier == "Enter") { 656 } 657 #endif 658 if (handled) 659 evt->setDefaultHandled(); 660 } 661 662 // Use key press event here since sending simulated mouse events 663 // on key down blocks the proper sending of the key press event. 664 if (evt->type() == keypressEvent) { 665 if (!renderer() || !evt->isKeyboardEvent()) 666 return; 667 int keyCode = static_cast<KeyboardEvent*>(evt)->keyCode(); 668 bool handled = false; 669 #if ARROW_KEYS_POP_MENU 670 if (keyCode == ' ') { 671 focus(); 672 // Save the selection so it can be compared to the new selection when we call onChange during setSelectedIndex, 673 // which gets called from RenderMenuList::valueChanged, which gets called after the user makes a selection from the menu. 674 saveLastSelection(); 675 menuList->showPopup(); 676 handled = true; 677 } 678 if (keyCode == '\r') { 679 menuListOnChange(); 680 if (form()) 681 form()->submitClick(evt); 682 handled = true; 683 } 684 #else 685 int listIndex = optionToListIndex(selectedIndex()); 686 if (keyCode == '\r') { 665 687 // listIndex should already be selected, but this will fire the onchange handler. 666 688 setSelectedIndex(listToOptionIndex(listIndex), true, true); … … 670 692 if (handled) 671 693 evt->setDefaultHandled(); 672 673 } 694 } 695 674 696 if (evt->type() == mousedownEvent && evt->isMouseEvent() && static_cast<MouseEvent*>(evt)->button() == LeftButton) { 675 697 focus(); … … 751 773 // This makes sure we fire onChange for a single click. For drag selection, onChange will fire when the autoscroll timer stops. 752 774 listBoxOnChange(); 753 else if (evt->type() == key pressEvent) {775 else if (evt->type() == keydownEvent) { 754 776 if (!evt->isKeyboardEvent()) 755 777 return; 756 778 String keyIdentifier = static_cast<KeyboardEvent*>(evt)->keyIdentifier(); 757 758 if (keyIdentifier == "Enter") {759 if (form())760 form()->submitClick(evt);761 evt->setDefaultHandled();762 return;763 }764 779 765 780 int endIndex = 0; … … 799 814 evt->setDefaultHandled(); 800 815 } 816 } else if (evt->type() == keypressEvent) { 817 if (!evt->isKeyboardEvent()) 818 return; 819 int keyCode = static_cast<KeyboardEvent*>(evt)->keyCode(); 820 821 if (keyCode == '\r') { 822 if (form()) 823 form()->submitClick(evt); 824 evt->setDefaultHandled(); 825 return; 826 } 801 827 } 802 828 } -
trunk/WebCore/page/EventHandler.cpp
r28233 r28620 1465 1465 } 1466 1466 1467 static bool handleAccessKey(Document* document, const PlatformKeyboardEvent& evt) 1468 { 1469 #if PLATFORM(MAC) 1470 if (evt.ctrlKey()) 1471 #else 1472 if (evt.altKey()) 1473 #endif 1474 { 1475 String key = evt.unmodifiedText(); 1476 Element* elem = document->getElementByAccessKey(key.lower()); 1477 if (elem) { 1478 elem->accessKeyAction(false); 1479 return true; 1480 } 1481 } 1482 1483 return false; 1484 } 1467 1485 1468 1486 bool EventHandler::keyEvent(const PlatformKeyboardEvent& initialKeyEvent) … … 1470 1488 // Check for cases where we are too early for events -- possible unmatched key up 1471 1489 // from pressing return in the location bar. 1472 EventTargetNode*node = eventTargetNodeForDocument(m_frame->document());1490 RefPtr<EventTargetNode> node = eventTargetNodeForDocument(m_frame->document()); 1473 1491 if (!node) 1474 1492 return false; 1475 1476 if (initialKeyEvent.isKeyUp()) 1493 1494 // FIXME: what is this doing here, in keyboard event handler? 1495 m_frame->loader()->resetMultipleFormSubmissionProtection(); 1496 1497 // In IE, access keys are special, they are handled after default keydown processing, but cannot be canceled - this is hard to match. 1498 // On Windows, we process them before dispatching keypress event (and rely on WebKit to not drop WM_SYSCHAR events when a keydown representing WM_SYSKEYDOWN is canceled). 1499 // On Mac OS X, we process them before dispatching keydown, as the default keydown handler implements Emacs key bindings, which may conflict with access keys. 1500 // Other platforms currently match either Mac or Windows behavior, depending on whether they send combined KeyDown events. 1501 bool matchedAnAccessKey = false; 1502 if (initialKeyEvent.type() == PlatformKeyboardEvent::Char) { 1503 if (handleAccessKey(m_frame->document(), initialKeyEvent)) 1504 return true; 1505 } else if (initialKeyEvent.type() == PlatformKeyboardEvent::KeyDown) 1506 matchedAnAccessKey = handleAccessKey(m_frame->document(), initialKeyEvent); 1507 1508 // FIXME: it would be fair to let an input method handle KeyUp events before DOM dispatch. 1509 if (initialKeyEvent.type() == PlatformKeyboardEvent::KeyUp || initialKeyEvent.type() == PlatformKeyboardEvent::Char) 1477 1510 return !node->dispatchKeyEvent(initialKeyEvent); 1478 1479 m_frame->loader()->resetMultipleFormSubmissionProtection(); 1480 1481 // Prepare the keyPress in advance of the keyDown so we can fire the input method 1482 // in advance of keyDown 1483 PlatformKeyboardEvent keyPressEvent = initialKeyEvent; 1484 keyPressEvent.setIsAutoRepeat(true); 1511 1512 bool dashboardCompatibilityMode = false; 1513 if (Settings* settings = node->document()->settings()) 1514 dashboardCompatibilityMode = settings->usesDashboardBackwardCompatibilityMode(); 1515 1516 ExceptionCode ec; 1517 PlatformKeyboardEvent keyDownEvent = initialKeyEvent; 1518 if (keyDownEvent.type() != PlatformKeyboardEvent::RawKeyDown) 1519 keyDownEvent.disambiguateKeyDownEvent(PlatformKeyboardEvent::RawKeyDown, dashboardCompatibilityMode); 1520 RefPtr<KeyboardEvent> keydown = new KeyboardEvent(keyDownEvent, m_frame->document()->defaultView()); 1521 if (matchedAnAccessKey) 1522 keydown->setDefaultPrevented(true); 1523 keydown->setTarget(node); 1524 1525 if (initialKeyEvent.type() == PlatformKeyboardEvent::RawKeyDown) { 1526 node->dispatchEvent(keydown, ec, true); 1527 return keydown->defaultHandled() || keydown->defaultPrevented(); 1528 } 1529 1530 // Run input method in advance of DOM event handling. This may result in the IM 1531 // modifying the page prior the keydown event, but this behaviour is necessary 1532 // in order to match IE: 1533 // 1. preventing default handling of keydown and keypress events has no effect on IM input; 1534 // 2. if an input method handles the event, its keyCode is set to 229 in keydown event. 1535 m_frame->editor()->handleInputMethodKeydown(keydown.get()); 1536 1537 bool handledByInputMethod = keydown->defaultHandled(); 1538 1539 if (handledByInputMethod) { 1540 keyDownEvent.setWindowsVirtualKeyCode(CompositionEventKeyCode); 1541 keydown = new KeyboardEvent(keyDownEvent, m_frame->document()->defaultView()); 1542 keydown->setTarget(node); 1543 keydown->setDefaultHandled(); 1544 } 1545 1546 node->dispatchEvent(keydown, ec, true); 1547 bool keydownResult = keydown->defaultHandled() || keydown->defaultPrevented(); 1548 if (handledByInputMethod || (keydownResult && !dashboardCompatibilityMode) || initialKeyEvent.text().isEmpty()) 1549 return keydownResult; 1550 1551 // Focus may have changed during keydown handling, so refetch node. 1552 // But if we are dispatching a fake Dashboard compatibility keypress, then we pretend that the keypress happened on the original node. 1553 if (!keydownResult) { 1554 node = eventTargetNodeForDocument(m_frame->document()); 1555 if (!node) 1556 return false; 1557 } 1558 1559 PlatformKeyboardEvent keyPressEvent = initialKeyEvent; 1560 keyPressEvent.disambiguateKeyDownEvent(PlatformKeyboardEvent::Char, dashboardCompatibilityMode); 1485 1561 RefPtr<KeyboardEvent> keypress = new KeyboardEvent(keyPressEvent, m_frame->document()->defaultView()); 1486 1562 keypress->setTarget(node); 1487 1488 // Run input method in advance of DOM event handling. This may result in the IM 1489 // modifying the page prior the keydown event, however this behaviour is necessary 1490 // in order to match IE 1491 m_frame->editor()->handleInputMethodKeypress(keypress.get()); 1492 1493 bool handledByInputMethod = keypress->defaultHandled(); 1494 1495 PlatformKeyboardEvent keyDownEvent = initialKeyEvent; 1496 1497 if (handledByInputMethod) 1498 keyDownEvent.setWindowsKeyCode(CompositionEventKeyCode); 1499 1500 // We always send keyDown and keyPress for all events, including autorepeat keys 1501 keyDownEvent.setIsAutoRepeat(false); 1502 1503 bool result = !node->dispatchKeyEvent(keyDownEvent); 1504 1505 // Focus may have change during the keyDown handling, so refetch node 1506 node = eventTargetNodeForDocument(m_frame->document()); 1507 if (!node) 1508 return result; 1509 1510 if (keypress->defaultHandled()) 1511 return true; 1512 1513 if (handledByInputMethod || initialKeyEvent.isModifierKeyPress()) 1514 return result; 1515 1516 // If the default handling has been prevented on the keydown, we prevent it on 1517 // the keypress as well 1518 if (result) 1519 keypress->setDefaultHandled(); 1520 1521 ExceptionCode ec; 1563 if (keydownResult) 1564 keypress->setDefaultPrevented(true); 1522 1565 node->dispatchEvent(keypress, ec, true); 1523 1524 return result || keypress->defaultHandled() || keypress->defaultPrevented();1566 1567 return keydownResult || keypress->defaultPrevented() || keypress->defaultHandled(); 1525 1568 } 1526 1569 1527 1570 void EventHandler::defaultKeyboardEventHandler(KeyboardEvent* event) 1528 1571 { 1529 if (event->type() == key pressEvent) {1530 m_frame->editor()->handleKey press(event);1572 if (event->type() == keydownEvent) { 1573 m_frame->editor()->handleKeyboardEvent(event); 1531 1574 if (event->defaultHandled()) 1532 1575 return; 1533 1576 if (event->keyIdentifier() == "U+0009") 1534 1577 defaultTabEventHandler(event, false); 1535 } 1578 } 1579 if (event->type() == keypressEvent) { 1580 m_frame->editor()->handleKeyboardEvent(event); 1581 if (event->defaultHandled()) 1582 return; 1583 } 1536 1584 } 1537 1585 … … 1725 1773 if (!m_frame) 1726 1774 return false; 1775 #ifndef NDEBUG 1776 // Platforms should differentiate real commands like selectAll from text input in disguise (like insertNewline), 1777 // and avoid dispatching text input events from keydown default handlers. 1778 if (underlyingEvent && underlyingEvent->isKeyboardEvent()) 1779 ASSERT(static_cast<KeyboardEvent*>(underlyingEvent)->type() == keypressEvent); 1780 #endif 1727 1781 EventTarget* target; 1728 1782 if (underlyingEvent) … … 1763 1817 { 1764 1818 String data = event->data(); 1765 if (data == "\t") {1766 defaultTabEventHandler(event, event->isBackTab());1767 if (event->defaultHandled())1768 return;1769 }1770 1819 if (data == "\n") { 1771 1820 if (event->isLineBreak()) { -
trunk/WebCore/page/mac/EventHandlerMac.mm
r24098 r28620 88 88 return 0; 89 89 switch ([event type]) { 90 case NSKeyDown: 90 case NSKeyDown: { 91 PlatformKeyboardEvent platformEvent(event); 92 platformEvent.disambiguateKeyDownEvent(PlatformKeyboardEvent::RawKeyDown); 93 return new KeyboardEvent(platformEvent, m_frame->document() ? m_frame->document()->defaultView() : 0); 94 } 91 95 case NSKeyUp: 92 96 return new KeyboardEvent(event, m_frame->document() ? m_frame->document()->defaultView() : 0); -
trunk/WebCore/platform/PlatformKeyboardEvent.h
r27459 r28620 61 61 class PlatformKeyboardEvent { 62 62 public: 63 enum Type { 64 // KeyDown is sent by platforms such as Mac OS X, gtk and Qt, and has information about both physical pressed key, and its translation. 65 // For DOM processing, it needs to be disambiguated as RawKeyDown or Char event. 66 KeyDown, 67 68 // KeyUp is sent by all platforms. 69 KeyUp, 70 71 // These events are sent by platforms such as Windows and wxWidgets. RawKeyDown only has information about a physical key, and Char 72 // only has information about a character it was translated into. 73 RawKeyDown, 74 Char 75 }; 76 77 Type type() const { return m_type; } 78 void disambiguateKeyDownEvent(Type, bool dashboardCompatibilityMode = false); // Only used on platforms that need it, i.e. those that generate KeyDown events. 79 80 // Text as as generated by processing a virtual key code with a keyboard layout 81 // (in most cases, just a character code, but the layout can emit several 82 // characters in a single keypress event on some platforms). 83 // This may bear no resemblance to the ultimately inserted text if an input method 84 // processes the input. 85 // Will be null for KeyUp and RawKeyDown events. 63 86 String text() const { return m_text; } 87 88 // Text that would have been generated by the keyboard if no modifiers were pressed 89 // (except for Shift); useful for shortcut (accelerator) key handling. 90 // Otherwise, same as text(). 64 91 String unmodifiedText() const { return m_unmodifiedText; } 92 93 // Most compatible Windows virtual key code associated with the event. 94 // Zero for Char events. 95 int windowsVirtualKeyCode() const { return m_windowsVirtualKeyCode; } 96 void setWindowsVirtualKeyCode(int code) { m_windowsVirtualKeyCode = code; } 97 65 98 String keyIdentifier() const { return m_keyIdentifier; } 66 bool isKeyUp() const { return m_isKeyUp; }67 99 bool isAutoRepeat() const { return m_autoRepeat; } 68 100 void setIsAutoRepeat(bool in) { m_autoRepeat = in; } 69 int WindowsKeyCode() const { return m_WindowsKeyCode; }70 void setWindowsKeyCode(int code) { m_WindowsKeyCode = code; }71 101 bool isKeypad() const { return m_isKeypad; } 72 102 bool shiftKey() const { return m_shiftKey; } … … 74 104 bool altKey() const { return m_altKey; } 75 105 bool metaKey() const { return m_metaKey; } 76 bool isModifierKeyPress() const { return m_isModifierKeyPress; }77 106 78 107 static bool currentCapsLockState(); 79 108 80 109 #if PLATFORM(MAC) 81 PlatformKeyboardEvent(NSEvent* , bool forceAutoRepeat = false);110 PlatformKeyboardEvent(NSEvent*); 82 111 NSEvent* macEvent() const { return m_macEvent.get(); } 83 112 #endif 84 113 85 114 #if PLATFORM(WIN) 86 PlatformKeyboardEvent(HWND, WPARAM, LPARAM, UChar, bool);115 PlatformKeyboardEvent(HWND, WPARAM, LPARAM, Type, bool); 87 116 bool isSystemKey() const { return m_isSystemKey; } 88 117 #endif … … 98 127 #if PLATFORM(WX) 99 128 PlatformKeyboardEvent(wxKeyEvent&); 100 bool isWxCharEvent() const { return m_isWxCharEvent; }101 129 #endif 102 130 103 131 private: 132 Type m_type; 104 133 String m_text; 105 134 String m_unmodifiedText; 106 135 String m_keyIdentifier; 107 bool m_isKeyUp;108 136 bool m_autoRepeat; 109 int m_ WindowsKeyCode;137 int m_windowsVirtualKeyCode; 110 138 bool m_isKeypad; 111 139 bool m_shiftKey; … … 113 141 bool m_altKey; 114 142 bool m_metaKey; 115 116 // A control key event -- eg. keydown/up for shift, ctrl, alt, and meta -- needs 117 // a flag to indicate that we should not generate a keyPress event. 118 bool m_isModifierKeyPress; 119 #if PLATFORM(WX) 120 bool m_isWxCharEvent; 121 #endif 143 122 144 #if PLATFORM(MAC) 123 145 RetainPtr<NSEvent> m_macEvent; -
trunk/WebCore/platform/gtk/KeyEventGtk.cpp
r27932 r28620 475 475 476 476 PlatformKeyboardEvent::PlatformKeyboardEvent(GdkEventKey* event) 477 : m_text(singleCharacterString(event->keyval)) 477 : m_type((event->type == GDK_KEY_RELEASE) ? KeyUp : KeyDown) 478 , m_text(singleCharacterString(event->keyval)) 478 479 , m_unmodifiedText(singleCharacterString(event->keyval)) 479 480 , m_keyIdentifier(keyIdentifierForGdkKeyCode(event->keyval)) 480 , m_isKeyUp(event->type == GDK_KEY_RELEASE)481 481 , m_autoRepeat(false) 482 , m_ WindowsKeyCode(windowsKeyCodeForKeyEvent(event->keyval))482 , m_windowsVirtualKeyCode(windowsKeyCodeForKeyEvent(event->keyval)) 483 483 , m_isKeypad(false) 484 484 , m_shiftKey((event->state & GDK_SHIFT_MASK) || (event->keyval == GDK_3270_BackTab)) … … 486 486 , m_altKey(event->state & GDK_MOD1_MASK) 487 487 , m_metaKey(event->state & GDK_MOD2_MASK) 488 , m_isModifierKeyPress(false)489 488 { 489 } 490 491 void PlatformKeyboardEvent::disambiguateKeyDownEvent(Type type, bool) 492 { 493 // Can only change type from KeyDown to RawKeyDown or Char, as we lack information for other conversions. 494 ASSERT(m_type == KeyDown); 495 m_type = type; 496 497 if (type == RawKeyDown) { 498 m_text = String(); 499 m_unmodifiedText = String(); 500 } else { 501 m_keyIdentifier = String(); 502 m_windowsVirtualKeyCode = 0; 503 } 490 504 } 491 505 -
trunk/WebCore/platform/mac/KeyEventMac.mm
r27372 r28620 394 394 } 395 395 396 static int WindowsKeyCodeForKeyEvent(NSEvent* event)396 static int windowsKeyCodeForKeyEvent(NSEvent* event) 397 397 { 398 398 switch ([event keyCode]) { … … 765 765 { 766 766 if ([event type] != NSFlagsChanged) 767 return false; 767 return [event type] == NSKeyUp; 768 // FIXME: This logic fails if the user presses both Shift keys at once, for example: 769 // we treat releasing one of them as keyDown. 768 770 switch ([event keyCode]) { 769 771 case 54: // Right Command … … 806 808 return [event charactersIgnoringModifiers]; 807 809 } 808 809 PlatformKeyboardEvent::PlatformKeyboardEvent(NSEvent *event, bool forceAutoRepeat) 810 : m_text(textFromEvent(event)) 810 811 PlatformKeyboardEvent::PlatformKeyboardEvent(NSEvent *event) 812 : m_type(isKeyUpEvent(event) ? PlatformKeyboardEvent::KeyUp : PlatformKeyboardEvent::KeyDown) 813 , m_text(textFromEvent(event)) 811 814 , m_unmodifiedText(unmodifiedTextFromEvent(event)) 812 815 , m_keyIdentifier(keyIdentifierForKeyEvent(event)) 813 , m_isKeyUp([event type] == NSKeyUp || isKeyUpEvent(event)) 814 , m_autoRepeat(([event type] != NSFlagsChanged) && (forceAutoRepeat || [event isARepeat])) 815 , m_WindowsKeyCode(WindowsKeyCodeForKeyEvent(event)) 816 , m_autoRepeat(([event type] != NSFlagsChanged) && [event isARepeat]) 817 , m_windowsVirtualKeyCode(windowsKeyCodeForKeyEvent(event)) 816 818 , m_isKeypad(isKeypadEvent(event)) 817 819 , m_shiftKey([event modifierFlags] & NSShiftKeyMask) … … 819 821 , m_altKey([event modifierFlags] & NSAlternateKeyMask) 820 822 , m_metaKey([event modifierFlags] & NSCommandKeyMask) 821 , m_isModifierKeyPress([event type] == NSFlagsChanged)822 823 , m_macEvent(event) 823 824 { 825 // Always use 13 for Enter/Return -- we don't want to use AppKit's different character for Enter. 826 if (m_windowsVirtualKeyCode == '\r') { 827 m_text = "\r"; 828 m_unmodifiedText = "\r"; 829 } 830 831 // The adjustments below are only needed in Dashboard compatibility mode, but we cannot tell what mode we are in from here. 832 824 833 // Turn 0x7F into 8, because backspace needs to always be 8. 825 834 if (m_text == "\x7F") … … 828 837 m_unmodifiedText = "\x8"; 829 838 // Always use 9 for tab -- we don't want to use AppKit's different character for shift-tab. 830 if (m_ WindowsKeyCode == 9) {839 if (m_windowsVirtualKeyCode == 9) { 831 840 m_text = "\x9"; 832 841 m_unmodifiedText = "\x9"; … … 834 843 } 835 844 845 void PlatformKeyboardEvent::disambiguateKeyDownEvent(Type type, bool dashboardCompatibilityMode) 846 { 847 // Can only change type from KeyDown to RawKeyDown or Char, as we lack information for other conversions. 848 ASSERT(m_type == KeyDown); 849 ASSERT(type == RawKeyDown || type == Char); 850 m_type = type; 851 if (dashboardCompatibilityMode) 852 return; 853 854 if (type == RawKeyDown) { 855 m_text = String(); 856 m_unmodifiedText = String(); 857 } else { 858 m_keyIdentifier = String(); 859 m_windowsVirtualKeyCode = 0; 860 } 861 } 862 836 863 bool PlatformKeyboardEvent::currentCapsLockState() 837 864 { -
trunk/WebCore/platform/qt/PlatformKeyboardEventQt.cpp
r27306 r28620 436 436 { 437 437 const int state = event->modifiers(); 438 m_type = (event->type() == QEvent::KeyRelease) ? KeyUp : KeyDown; 438 439 m_text = event->text(); 439 440 m_unmodifiedText = event->text(); // FIXME: not correct 440 441 m_keyIdentifier = keyIdentifierForQtKeyCode(event->key()); 441 m_isKeyUp = (event->type() == QEvent::KeyRelease);442 442 m_autoRepeat = event->isAutoRepeat(); 443 443 m_ctrlKey = (state & Qt::ControlModifier) != 0; 444 444 m_altKey = (state & Qt::AltModifier) != 0; 445 445 m_metaKey = (state & Qt::MetaModifier) != 0; 446 m_ WindowsKeyCode = windowsKeyCodeForKeyEvent(event->key());446 m_windowsVirtualKeyCode = windowsKeyCodeForKeyEvent(event->key()); 447 447 m_isKeypad = (state & Qt::KeypadModifier) != 0; 448 448 m_shiftKey = (state & Qt::ShiftModifier) != 0 || event->key() == Qt::Key_Backtab; // Simulate Shift+Tab with Key_Backtab 449 } 450 451 void PlatformKeyboardEvent::disambiguateKeyDownEvent(Type type, bool) 452 { 453 // Can only change type from KeyDown to RawKeyDown or Char, as we lack information for other conversions. 454 ASSERT(m_type == KeyDown); 455 m_type = type; 456 457 if (type == RawKeyDown) { 458 m_text = String(); 459 m_unmodifiedText = String(); 460 } else { 461 m_keyIdentifier = String(); 462 m_windowsVirtualKeyCode = 0; 463 } 449 464 } 450 465 -
trunk/WebCore/platform/text/PlatformString.h
r28234 r28620 75 75 const UChar* charactersWithNullTermination(); 76 76 77 UChar operator[](unsigned i) const; // if i >= length(), returns 0 77 UChar operator[](unsigned i) const; // if i >= length(), returns 0 78 UChar32 characterStartingAt(unsigned) const; // Ditto. 78 79 79 80 bool contains(UChar c) const { return find(c) != -1; } -
trunk/WebCore/platform/text/String.cpp
r28234 r28620 176 176 } 177 177 178 UChar32 String::characterStartingAt(unsigned i) const 179 { 180 if (!m_impl || i >= m_impl->length()) 181 return 0; 182 return m_impl->characterStartingAt(i); 183 } 178 184 unsigned String::length() const 179 185 { -
trunk/WebCore/platform/text/StringImpl.cpp
r28234 r28620 270 270 len = m_length - pos; 271 271 return new StringImpl(m_data + pos, len); 272 } 273 274 UChar32 StringImpl::characterStartingAt(unsigned i) const 275 { 276 if (U16_IS_SINGLE(m_data[i])) 277 return m_data[i]; 278 if (i + 1 < m_length && U16_IS_LEAD(m_data[i]) && U16_IS_TRAIL(m_data[i + 1])) 279 return U16_GET_SUPPLEMENTARY(m_data[i], m_data[i + 1]); 280 return 0; 272 281 } 273 282 -
trunk/WebCore/platform/text/StringImpl.h
r28234 r28620 94 94 95 95 UChar operator[](int pos) const { return m_data[pos]; } 96 UChar32 characterStartingAt(unsigned) const; 96 97 97 98 Length toLength() const; -
trunk/WebCore/platform/win/KeyEventWin.cpp
r27459 r28620 33 33 34 34 namespace WebCore { 35 36 static const unsigned REPEAT_COUNT_MASK = 0x0000FFFF;37 static const unsigned NEW_RELEASE_STATE_MASK = 0x80000000;38 static const unsigned PREVIOUS_DOWN_STATE_MASK = 0x40000000;39 35 40 36 static const unsigned short HIGH_BIT_MASK_SHORT = 0x8000; … … 149 145 static inline String singleCharacterString(UChar c) { return String(&c, 1); } 150 146 151 PlatformKeyboardEvent::PlatformKeyboardEvent(HWND, WPARAM virtualKeyCode, LPARAM keyData, UChar characterCode, bool systemKey)152 : m_t ext(singleCharacterString(characterCode))153 , m_ unmodifiedText(singleCharacterString(characterCode))154 , m_ keyIdentifier(keyIdentifierForWindowsKeyCode(virtualKeyCode))155 , m_ isKeyUp((keyData & NEW_RELEASE_STATE_MASK))156 , m_autoRepeat( (keyData & REPEAT_COUNT_MASK) > 1)157 , m_ WindowsKeyCode(virtualKeyCode)147 PlatformKeyboardEvent::PlatformKeyboardEvent(HWND, WPARAM code, LPARAM keyData, Type type, bool systemKey) 148 : m_type(type) 149 , m_text((type == Char) ? singleCharacterString(code) : String()) 150 , m_unmodifiedText((type == Char) ? singleCharacterString(code) : String()) 151 , m_keyIdentifier((type == Char) ? String() : keyIdentifierForWindowsKeyCode(code)) 152 , m_autoRepeat(keyData & KF_REPEAT) 153 , m_windowsVirtualKeyCode((type == RawKeyDown || type == KeyUp) ? code : 0) 158 154 , m_isKeypad(false) // FIXME: Need to implement this. 159 155 , m_shiftKey(GetKeyState(VK_SHIFT) & HIGH_BIT_MASK_SHORT) … … 161 157 , m_altKey(GetKeyState(VK_MENU) & HIGH_BIT_MASK_SHORT) 162 158 , m_metaKey(m_altKey) 163 , m_isModifierKeyPress(virtualKeyCode == VK_SHIFT || virtualKeyCode == VK_CONTROL || virtualKeyCode == VK_MENU || virtualKeyCode == VK_CAPITAL)164 159 , m_isSystemKey(systemKey) 165 160 { 161 } 162 163 void PlatformKeyboardEvent::disambiguateKeyDownEvent(Type, bool) 164 { 165 // No KeyDown events here to change. 166 ASSERT_NOT_REACHED(); 166 167 } 167 168 -
trunk/WebCore/platform/wx/KeyboardEventWx.cpp
r27466 r28620 326 326 PlatformKeyboardEvent::PlatformKeyboardEvent(wxKeyEvent& event) 327 327 { 328 m_text = wxString(event.GetUnicodeKey()); 329 m_unmodifiedText = m_text; 330 m_keyIdentifier = keyIdentifierForWxKeyCode(event.GetKeyCode()); 331 m_isKeyUp = event.GetEventType() == wxEVT_KEY_UP; 328 switch (event.GetEventType()) { 329 case wxEVT_KEY_UP: 330 m_type = KeyUp; 331 break; 332 case wxEVT_KEY_DOWN: 333 m_type = KeyDown; 334 break; 335 case wxEVT_CHAR: 336 m_type = Char; 337 break; 338 default: 339 ASSERT_NOT_REACHED(); 340 } 341 m_text = (type == Char) ? wxString(event.GetUnicodeKey()) : String(); 342 m_unmodifiedText = (type == Char) ? m_text : String(); 343 m_keyIdentifier = (type == Char) ? String() : keyIdentifierForWxKeyCode(event.GetKeyCode()); 332 344 m_autoRepeat = false; // FIXME: not correct. 333 m_ WindowsKeyCode = windowsKeyCodeForKeyEvent(event.GetKeyCode());345 m_windowsVirtualKeyCode = windowsKeyCodeForKeyEvent(event.GetKeyCode()); 334 346 m_isKeypad = (event.GetKeyCode() >= WXK_NUMPAD_SPACE) && (event.GetKeyCode() <= WXK_NUMPAD_DIVIDE); 335 347 m_shiftKey = event.ShiftDown(); … … 337 349 m_altKey = event.AltDown(); 338 350 m_metaKey = event.MetaDown(); 339 m_isModifierKeyPress = false; 340 m_isWxCharEvent = event.GetEventType() == wxEVT_CHAR; 351 } 352 353 void PlatformKeyboardEvent::disambiguateKeyDownEvent(Type type, bool) 354 { 355 // Can only change type from KeyDown to RawKeyDown or Char, as we lack information for other conversions. 356 ASSERT(m_type == KeyDown); 357 m_type = type; 358 if (type == RawKeyDown) { 359 m_text = String(); 360 m_unmodifiedText = String(); 361 } else { 362 m_keyIdentifier = String(); 363 m_windowsVirtualKeyCode = 0; 364 } 341 365 } 342 366 -
trunk/WebCore/svg/graphics/SVGImageEmptyClients.h
r28399 r28620 323 323 virtual void redo() { } 324 324 325 virtual void handleKey press(KeyboardEvent*) { }326 virtual void handleInputMethodKey press(KeyboardEvent*) { }325 virtual void handleKeyboardEvent(KeyboardEvent*) { } 326 virtual void handleInputMethodKeydown(KeyboardEvent*) { } 327 327 328 328 virtual void textFieldDidBeginEditing(Element*) { } -
trunk/WebKit/gtk/ChangeLog
r28564 r28620 1 2007-12-07 Alexey Proskuryakov <ap@webkit.org> 2 3 Reviewed by Darin. 4 5 <rdar://problem/5535636> 6 Have to press 4 times instead of 2 times to get the expected result of ^^ with german keyboard. 7 8 http://bugs.webkit.org/show_bug.cgi?id=13916 9 JavaScript detects Tab as a character input on a textfield validation 10 11 * WebCoreSupport/EditorClientGtk.cpp: 12 (WebKit::EditorClient::handleKeyboardEvent): 13 (WebKit::EditorClient::handleInputMethodKeydown): 14 * WebCoreSupport/EditorClientGtk.h: 15 Updated for cross-platform changes as much as it was possible without a gtk build environment. 16 1 17 2007-12-08 Luca Bruno <lethalman88@gmail.com> 2 18 -
trunk/WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp
r28564 r28620 213 213 } 214 214 215 void EditorClient::handleKey press(KeyboardEvent* event)215 void EditorClient::handleKeyboardEvent(KeyboardEvent* event) 216 216 { 217 217 Frame* frame = core(m_page)->focusController()->focusedOrMainFrame(); … … 220 220 221 221 const PlatformKeyboardEvent* kevent = event->keyEvent(); 222 if (!kevent || kevent-> isKeyUp())222 if (!kevent || kevent->type() == PlatformKeyboardEvent::KeyUp) 223 223 return; 224 224 … … 231 231 232 232 if (start->isContentEditable()) { 233 switch (kevent->WindowsKeyCode()) {233 switch (kevent->windowsVirtualKeyCode()) { 234 234 case VK_BACK: 235 235 frame->editor()->deleteWithDirection(SelectionController::BACKWARD, … … 305 305 frame->editor()->insertText(kevent->text(), event); 306 306 } else if (kevent->ctrlKey()) { 307 switch (kevent-> WindowsKeyCode()) {307 switch (kevent->windowsVirtualKeyCode()) { 308 308 case VK_B: 309 309 frame->editor()->execCommand("ToggleBold"); … … 324 324 } 325 325 } else { 326 switch (kevent-> WindowsKeyCode()) {326 switch (kevent->windowsVirtualKeyCode()) { 327 327 case VK_UP: 328 328 frame->editor()->execCommand("MoveUp"); … … 353 353 354 354 355 void EditorClient::handleInputMethodKey press(KeyboardEvent*)355 void EditorClient::handleInputMethodKeydown(KeyboardEvent*) 356 356 { 357 357 notImplemented(); -
trunk/WebKit/gtk/WebCoreSupport/EditorClientGtk.h
r28273 r28620 88 88 virtual void redo(); 89 89 90 virtual void handleKey press(WebCore::KeyboardEvent*);91 virtual void handleInputMethodKey press(WebCore::KeyboardEvent*);90 virtual void handleKeyboardEvent(WebCore::KeyboardEvent*); 91 virtual void handleInputMethodKeydown(WebCore::KeyboardEvent*); 92 92 93 93 virtual void textFieldDidBeginEditing(WebCore::Element*); -
trunk/WebKit/mac/ChangeLog
r28597 r28620 1 2007-12-07 Alexey Proskuryakov <ap@webkit.org> 2 3 Reviewed by Darin. 4 5 <rdar://problem/5535636> 6 Have to press 4 times instead of 2 times to get the expected result of ^^ with german keyboard. 7 8 http://bugs.webkit.org/show_bug.cgi?id=13916 9 JavaScript detects Tab as a character input on a textfield validation 10 11 * WebCoreSupport/WebEditorClient.h: 12 Renamed handleKeypress() to handleKeyboardEvent(), as it gets both keydowns and keypresses. 13 Renamed handleInputMethodKeypress() to handleInputMethodKeydown(). 14 * WebCoreSupport/WebEditorClient.mm: 15 (WebEditorClient::handleKeyboardEvent): This change makes sense only remotely, but it helped 16 to get tests working. I guess Mac keyboard event handling needs further refactoring. 17 18 * WebView/WebHTMLView.mm: 19 (selectorToCommandName): Convert AppKit editing selector name to Editor command name - extracted 20 from callWebCoreCommand:. 21 (_interceptEditingKeyEvent:shouldSaveCommand:): Insert text from keypress. 22 23 * WebView/WebPDFView.mm: 24 (-[WebPDFView PDFViewWillClickOnLink:withURL:]): 25 Convert incoming platform KeyDown into RawKeyDown, as this is what the view is interested in. 26 1 27 2007-12-10 Brady Eidson <beidson@apple.com> 2 28 -
trunk/WebKit/mac/WebCoreSupport/WebEditorClient.h
r25547 r28620 88 88 virtual void redo(); 89 89 90 virtual void handleKey press(WebCore::KeyboardEvent*);91 virtual void handleInputMethodKey press(WebCore::KeyboardEvent*);90 virtual void handleKeyboardEvent(WebCore::KeyboardEvent*); 91 virtual void handleInputMethodKeydown(WebCore::KeyboardEvent*); 92 92 93 93 virtual void textFieldDidBeginEditing(WebCore::Element*); -
trunk/WebKit/mac/WebCoreSupport/WebEditorClient.mm
r27753 r28620 431 431 } 432 432 433 void WebEditorClient::handleKey press(KeyboardEvent* event)433 void WebEditorClient::handleKeyboardEvent(KeyboardEvent* event) 434 434 { 435 435 Frame* frame = event->target()->toNode()->document()->frame(); … … 439 439 } 440 440 441 void WebEditorClient::handleInputMethodKey press(KeyboardEvent* event)441 void WebEditorClient::handleInputMethodKeydown(KeyboardEvent* event) 442 442 { 443 443 Frame* frame = event->target()->toNode()->document()->frame(); -
trunk/WebKit/mac/WebView/WebHTMLView.mm
r28585 r28620 2048 2048 } 2049 2049 2050 - (void)callWebCoreCommand:(SEL)selector 2051 { 2052 if ([self callDelegateDoCommandBySelectorIfNeeded:selector]) 2053 return; 2054 2055 Frame* coreFrame = core([self _frame]); 2056 if (!coreFrame) 2057 return; 2058 2050 static AtomicString selectorToCommandName(SEL selector) 2051 { 2059 2052 // Capitalize the first letter of the selector, since we use capitalized command 2060 2053 // names in the Editor object (why?). And remove the trailing colon. 2054 // And change a few command names into ones supported by WebCore::Editor. 2055 2056 if (selector == @selector(insertParagraphSeparator:) || selector == @selector(insertNewlineIgnoringFieldEditor:)) 2057 return "InsertNewline"; 2058 if (selector == @selector(insertTabIgnoringFieldEditor:)) 2059 return "InsertTab"; 2060 2061 2061 const char* selectorName = sel_getName(selector); 2062 2062 size_t selectorNameLength = strlen(selectorName); … … 2068 2068 commandName[selectorNameLength - 1] = 0; 2069 2069 2070 coreFrame->editor()->execCommand(commandName.data()); 2070 return AtomicString(commandName.data()); 2071 } 2072 2073 - (void)callWebCoreCommand:(SEL)selector 2074 { 2075 if ([self callDelegateDoCommandBySelectorIfNeeded:selector]) 2076 return; 2077 2078 Frame* coreFrame = core([self _frame]); 2079 if (!coreFrame) 2080 return; 2081 2082 coreFrame->editor()->execCommand(selectorToCommandName(selector)); 2071 2083 } 2072 2084 … … 5186 5198 // We assume the IM will *not* consume hotkey sequences 5187 5199 parameters.consumedByIM = !event->metaKey() && shouldSave; 5188 5200 5189 5201 if (const PlatformKeyboardEvent* platformEvent = event->keyEvent()) { 5190 5202 NSEvent *macEvent = platformEvent->macEvent(); … … 5201 5213 bool hasKeypressCommand = !command.commandNames.isEmpty() || !command.text.isEmpty(); 5202 5214 5215 // FIXME: interpretKeyEvents doesn't match application key equivalents (such as Cmd+A), 5216 // and sends noop: for those. As a result, we don't handle those from within WebCore, 5217 // but send a full sequence of DOM events, including an unneeded keypress. 5203 5218 if (parameters.shouldSaveCommand || !hasKeypressCommand) 5204 5219 [self interpretKeyEvents:[NSArray arrayWithObject:macEvent]]; 5205 5220 else { 5206 if (!command.text.isEmpty()) 5207 [self insertText:command.text]; 5208 else { 5209 size_t size = command.commandNames.size(); 5221 ASSERT(platformEvent->type() == PlatformKeyboardEvent::RawKeyDown); 5222 size_t size = command.commandNames.size(); 5223 // Are there commands that would just cause text insertion if executed via Editor? 5224 // WebKit doesn't have enough information about mode to decide how they should be treated, so we leave it upon WebCore 5225 // to either handle them immediately (e.g. Tab that changes focus) or let a keypress event be generated 5226 // (e.g. Tab that inserts a Tab character, or Enter). 5227 bool haveTextInsertionCommands = false; 5228 for (size_t i = 0; i < size; ++i) { 5229 if (Editor::isTextInsertionCommand(selectorToCommandName(NSSelectorFromString(command.commandNames[i])))) 5230 haveTextInsertionCommands = true; 5231 } 5232 if (!haveTextInsertionCommands) 5210 5233 for (size_t i = 0; i < size; ++i) 5211 5234 [self doCommandBySelector:NSSelectorFromString(command.commandNames[i])]; 5212 }5213 5235 } 5214 5236 _private->interpretKeyEventsParameters = 0; … … 5548 5570 Frame* coreFrame = core([self _frame]); 5549 5571 if (![[webView _editingDelegateForwarder] webView:webView doCommandBySelector:selector] && coreFrame) { 5550 if (selector == @selector(insertNewline:) || selector == @selector(insertParagraphSeparator:) || selector == @selector(insertNewlineIgnoringFieldEditor:)) 5551 eventWasHandled = coreFrame->editor()->execCommand("InsertNewline", event); 5552 else if (selector == @selector(insertLineBreak:)) 5553 eventWasHandled = coreFrame->editor()->execCommand("InsertLineBreak", event); 5554 else if (selector == @selector(insertTab:) || selector == @selector(insertTabIgnoringFieldEditor:)) 5555 eventWasHandled = coreFrame->editor()->execCommand("InsertTab", event); 5556 else if (selector == @selector(insertBacktab:)) 5557 eventWasHandled = coreFrame->editor()->execCommand("InsertBacktab", event); 5572 AtomicString commandName = selectorToCommandName(selector); 5573 if (Editor::isTextInsertionCommand(commandName)) 5574 eventWasHandled = coreFrame->editor()->execCommand(commandName, event); 5558 5575 else { 5559 5576 _private->selectorForDoCommandBySelector = selector; -
trunk/WebKit/mac/WebView/WebPDFView.mm
r27718 r28620 948 948 case NSKeyDown: { 949 949 PlatformKeyboardEvent pe(nsEvent); 950 pe.disambiguateKeyDownEvent(PlatformKeyboardEvent::RawKeyDown); 950 951 event = new KeyboardEvent(keydownEvent, true, true, 0, 951 pe.keyIdentifier(), pe. WindowsKeyCode(),952 pe.keyIdentifier(), pe.windowsVirtualKeyCode(), 952 953 pe.ctrlKey(), pe.altKey(), pe.shiftKey(), pe.metaKey(), false); 953 954 } -
trunk/WebKit/qt/ChangeLog
r28550 r28620 1 2007-12-07 Alexey Proskuryakov <ap@webkit.org> 2 3 Reviewed by Darin. 4 5 <rdar://problem/5535636> 6 Have to press 4 times instead of 2 times to get the expected result of ^^ with german keyboard. 7 8 http://bugs.webkit.org/show_bug.cgi?id=13916 9 JavaScript detects Tab as a character input on a textfield validation 10 11 * WebCoreSupport/EditorClientQt.cpp: 12 (WebCore::EditorClientQt::handleKeyboardEvent): 13 (WebCore::EditorClientQt::handleInputMethodKeydown): 14 * WebCoreSupport/EditorClientQt.h: 15 Updated for cross-platform changes as much as it was possible without a Qt build environment. 16 1 17 2007-12-07 Darin Adler <darin@apple.com> 2 18 -
trunk/WebKit/qt/WebCoreSupport/EditorClientQt.cpp
r28230 r28620 326 326 } 327 327 328 void EditorClientQt::handleKey press(KeyboardEvent* event)328 void EditorClientQt::handleKeyboardEvent(KeyboardEvent* event) 329 329 { 330 330 Frame* frame = m_page->d->page->focusController()->focusedOrMainFrame(); … … 333 333 334 334 const PlatformKeyboardEvent* kevent = event->keyEvent(); 335 if (!kevent || kevent-> isKeyUp())335 if (!kevent || kevent->type() == PlatformKeyboardEvent::KeyUp) 336 336 return; 337 337 … … 342 342 // FIXME: refactor all of this to use Actions or something like them 343 343 if (start->isContentEditable()) { 344 switch (kevent->WindowsKeyCode()) {344 switch (kevent->windowsVirtualKeyCode()) { 345 345 case VK_RETURN: 346 346 frame->editor()->execCommand("InsertLineBreak"); … … 386 386 frame->editor()->insertText(kevent->text(), event); 387 387 } else if (kevent->ctrlKey()) { 388 switch (kevent-> WindowsKeyCode()) {388 switch (kevent->windowsVirtualKeyCode()) { 389 389 case VK_A: 390 390 frame->editor()->execCommand("SelectAll"); … … 417 417 } 418 418 } else { 419 switch (kevent-> WindowsKeyCode()) {419 switch (kevent->windowsVirtualKeyCode()) { 420 420 case VK_UP: 421 421 frame->editor()->execCommand("MoveUp"); … … 440 440 default: 441 441 if (kevent->ctrlKey()) { 442 switch(kevent-> WindowsKeyCode()) {442 switch(kevent->windowsVirtualKeyCode()) { 443 443 case VK_A: 444 444 frame->editor()->execCommand("SelectAll"); … … 456 456 } 457 457 458 void EditorClientQt::handleInputMethodKey press(KeyboardEvent*)458 void EditorClientQt::handleInputMethodKeydown(KeyboardEvent*) 459 459 { 460 460 } -
trunk/WebKit/qt/WebCoreSupport/EditorClientQt.h
r27780 r28620 85 85 virtual void redo(); 86 86 87 virtual void handleKey press(KeyboardEvent*);88 virtual void handleInputMethodKey press(KeyboardEvent*);87 virtual void handleKeyboardEvent(KeyboardEvent*); 88 virtual void handleInputMethodKeydown(KeyboardEvent*); 89 89 90 90 virtual void textFieldDidBeginEditing(Element*); -
trunk/WebKit/win/ChangeLog
r28608 r28620 1 2007-12-07 Alexey Proskuryakov <ap@webkit.org> 2 3 Reviewed by Darin. 4 5 <rdar://problem/5535636> 6 Have to press 4 times instead of 2 times to get the expected result of ^^ with german keyboard. 7 8 http://bugs.webkit.org/show_bug.cgi?id=13916 9 JavaScript detects Tab as a character input on a textfield validation 10 11 Listen to WM_CHAR messages, and actually pass the type of message received down to WebCore. 12 Since WM_KEYDOWN == keydown and WM_CHAR == keypress, this allows for much better IE compatibility 13 than layering Windows keyboard event handling on top of Mac one. 14 15 * WebView.cpp: 16 (WebView::keyUp): Do not special case Alt+F4 and Alt+Space - we don't get keyups for those anyway! 17 (WebView::interpretKeyEvent): Renamed WindowsKeyCode() to windowsVirtualKeyCode(). 18 (WebView::handleEditingKeyboardEvent): Use the additional information about event type that 19 we now pass with PlatformKeyboardEvent. 20 (WebView::keyDown): (WebView::keyPress): Split WM_KEYDOWN and WM_CHAR handling in separate 21 functions, pass them down as is, without trying to guess what WM_CHAR Windows would have sent 22 for a given WM_KEYDOWN. 23 24 (WebViewWndProc): Handle WM_CHAR and WM_SYSCHAR. 25 26 * WebView.h: Removed inIMEKeyDown() - it doesn't look like we need it at all. At least, I didn't 27 notice any regressions after removing the only call to it in WebEditorClient. 28 29 * WebEditorClient.cpp: 30 (WebEditorClient::handleKeyboardEvent): 31 (WebEditorClient::handleInputMethodKeydown): 32 * WebEditorClient.h: 33 Renamed handleKeypress() to handleKeyboardEvent(), as it gets both keydowns and keypresses. 34 Renamed handleInputMethodKeypress() to handleInputMethodKeydown() and removed 35 inIMEKeyDown()-related code. 36 1 37 2007-12-10 Geoffrey Garen <ggaren@apple.com> 2 38 -
trunk/WebKit/win/WebEditorClient.cpp
r27368 r28620 595 595 } 596 596 597 void WebEditorClient::handleKey press(KeyboardEvent* evt)597 void WebEditorClient::handleKeyboardEvent(KeyboardEvent* evt) 598 598 { 599 599 if (m_webView->handleEditingKeyboardEvent(evt)) … … 601 601 } 602 602 603 void WebEditorClient::handleInputMethodKeypress(KeyboardEvent* evt) 604 { 605 if (m_webView->inIMEKeyDown()) 606 evt->setDefaultHandled(); 603 void WebEditorClient::handleInputMethodKeydown(KeyboardEvent* ) 604 { 607 605 } 608 606 -
trunk/WebKit/win/WebEditorClient.h
r25345 r28620 95 95 virtual void textDidChangeInTextArea(WebCore::Element*); 96 96 97 void handleKey press(WebCore::KeyboardEvent*);98 void handleInputMethodKey press(WebCore::KeyboardEvent*);97 void handleKeyboardEvent(WebCore::KeyboardEvent*); 98 void handleInputMethodKeydown(WebCore::KeyboardEvent*); 99 99 100 100 virtual void ignoreWordInSpellDocument(const WebCore::String&); -
trunk/WebKit/win/WebView.cpp
r28505 r28620 1240 1240 bool WebView::keyUp(WPARAM virtualKeyCode, LPARAM keyData, bool systemKeyDown) 1241 1241 { 1242 PlatformKeyboardEvent keyEvent(m_viewWindow, virtualKeyCode, keyData, m_currentCharacterCode, systemKeyDown); 1243 1244 // Don't send key events for alt+space and alt+f4. 1245 if (keyEvent.altKey() && (virtualKeyCode == VK_SPACE || virtualKeyCode == VK_F4)) 1246 return false; 1242 PlatformKeyboardEvent keyEvent(m_viewWindow, virtualKeyCode, keyData, PlatformKeyboardEvent::KeyUp, systemKeyDown); 1247 1243 1248 1244 Frame* frame = m_page->focusController()->focusedOrMainFrame(); … … 1257 1253 1258 1254 1259 struct Key Entry {1255 struct KeyDownEntry { 1260 1256 unsigned virtualKey; 1261 1257 unsigned modifiers; … … 1263 1259 }; 1264 1260 1265 static const KeyEntry keyEntries[] = { 1261 struct KeyPressEntry { 1262 unsigned charCode; 1263 unsigned modifiers; 1264 const char* name; 1265 }; 1266 1267 static const KeyDownEntry keyDownEntries[] = { 1266 1268 { VK_LEFT, 0, "MoveLeft" }, 1267 1269 { VK_LEFT, ShiftKey, "MoveLeftAndModifySelection" }, … … 1317 1319 }; 1318 1320 1321 static const KeyPressEntry keyPressEntries[] = { 1322 { '\t', 0, "InsertTab" }, 1323 { '\t', ShiftKey, "InsertBacktab" }, 1324 { '\r', 0, "InsertNewline" }, 1325 { '\r', CtrlKey, "InsertNewline" }, 1326 { '\r', AltKey, "InsertNewline" }, 1327 { '\r', AltKey | ShiftKey, "InsertNewline" }, 1328 }; 1329 1319 1330 const char* WebView::interpretKeyEvent(const KeyboardEvent* evt) 1320 1331 { 1321 const PlatformKeyboardEvent* keyEvent = evt->keyEvent(); 1322 if (!keyEvent) 1323 return ""; 1324 1325 static HashMap<int, const char*>* commandsMap = 0; 1326 1327 if (!commandsMap) { 1328 commandsMap = new HashMap<int, const char*>; 1329 1330 for (unsigned i = 0; i < _countof(keyEntries); i++) 1331 commandsMap->set(keyEntries[i].modifiers << 16 | keyEntries[i].virtualKey, keyEntries[i].name); 1332 ASSERT(evt->type() == keydownEvent || evt->type() == keypressEvent); 1333 1334 static HashMap<int, const char*>* keyDownCommandsMap = 0; 1335 static HashMap<int, const char*>* keyPressCommandsMap = 0; 1336 1337 if (!keyDownCommandsMap) { 1338 keyDownCommandsMap = new HashMap<int, const char*>; 1339 keyPressCommandsMap = new HashMap<int, const char*>; 1340 1341 for (unsigned i = 0; i < _countof(keyDownEntries); i++) 1342 keyDownCommandsMap->set(keyDownEntries[i].modifiers << 16 | keyDownEntries[i].virtualKey, keyDownEntries[i].name); 1343 1344 for (unsigned i = 0; i < _countof(keyPressEntries); i++) 1345 keyPressCommandsMap->set(keyPressEntries[i].modifiers << 16 | keyPressEntries[i].virtualKey, keyPressEntries[i].name); 1332 1346 } 1333 1347 1334 1348 unsigned modifiers = 0; 1335 if ( keyEvent->shiftKey())1349 if (evt->shiftKey()) 1336 1350 modifiers |= ShiftKey; 1337 if ( keyEvent->altKey())1351 if (evt->altKey()) 1338 1352 modifiers |= AltKey; 1339 if ( keyEvent->ctrlKey())1353 if (evt->ctrlKey()) 1340 1354 modifiers |= CtrlKey; 1341 1355 1342 return commandsMap->get(modifiers << 16 | keyEvent->WindowsKeyCode()); 1356 return evt->type() == keydownEvent ? 1357 keyDownCommandsMap->get(modifiers << 16 | evt->keyCode()) : 1358 keyPressCommandsMap->get(modifiers << 16 | evt->charCode()); 1343 1359 } 1344 1360 1345 1361 bool WebView::handleEditingKeyboardEvent(KeyboardEvent* evt) 1346 1362 { 1347 String command(interpretKeyEvent(evt));1348 1349 1363 Node* node = evt->target()->toNode(); 1350 1364 ASSERT(node); … … 1352 1366 ASSERT(frame); 1353 1367 1354 if (!command.isEmpty()) 1368 const PlatformKeyboardEvent* keyEvent = evt->keyEvent(); 1369 if (!keyEvent || keyEvent->isSystemKey()) // do not treat this as text input if it's a system key event 1370 return false; 1371 1372 if (keyEvent->type() == PlatformKeyboardEvent::RawKeyDown) { 1373 String command = interpretKeyEvent(evt); 1374 1375 // WebKit doesn't have enough information about mode to decide how commands that just insert text if executed via Editor should be treated, 1376 // so we leave it upon WebCore to either handle them immediately (e.g. Tab that changes focus) or let a keypress event be generated 1377 // (e.g. Tab that inserts a Tab character, or Enter). 1378 if (!command.isEmpty() && !Editor::isTextInsertionCommand(command)) 1379 if (frame->editor()->execCommand(command, evt)) 1380 return true; 1381 return false; 1382 } 1383 1384 String command = interpretKeyEvent(evt); 1385 if (!command.isEmpty()) 1355 1386 if (frame->editor()->execCommand(command, evt)) 1356 1387 return true; 1357 1388 1358 if (!evt->keyEvent() || evt->keyEvent()->isSystemKey()) // do not treat this as text input if it's a system key event 1389 // Don't insert null or control characters as they can result in unexpected behaviour 1390 if (evt->charCode() < ' ') 1359 1391 return false; 1360 1361 if (evt->keyEvent()->text().length() == 1) {1362 UChar ch = evt->keyEvent()->text()[0];1363 // Don't insert null or control characters as they can reslt in unexpected behaviour1364 if (ch < ' ')1365 return false;1366 }1367 1392 1368 1393 return frame->editor()->insertText(evt->keyEvent()->text(), evt); … … 1375 1400 frame->eventHandler()->capsLockStateMayHaveChanged(); 1376 1401 1377 // Don't send key events for alt+space and alt+f4, since the OS needs to handle that. 1378 if (systemKeyDown && (virtualKeyCode == VK_SPACE || virtualKeyCode == VK_F4)) 1379 return false; 1380 1381 MSG msg; 1382 // If the next message is a WM_CHAR message, then take it out of the queue, and use 1383 // the message parameters to get the character code to construct the PlatformKeyboardEvent. 1384 if (systemKeyDown) { 1385 if (::PeekMessage(&msg, m_viewWindow, WM_SYSCHAR, WM_SYSCHAR, PM_NOREMOVE)) // don't remove sys key message from the windows message queue until we know we can handle it 1386 m_currentCharacterCode = (UChar)msg.wParam; 1387 } else if (::PeekMessage(&msg, m_viewWindow, WM_CHAR, WM_CHAR, PM_REMOVE)) 1388 m_currentCharacterCode = (UChar)msg.wParam; 1389 1390 // FIXME: We need to check WM_UNICHAR to support supplementary characters. 1391 // FIXME: We may need to handle other messages for international text. 1392 1393 m_inIMEKeyDown = virtualKeyCode == VK_PROCESSKEY; 1394 if (virtualKeyCode == VK_PROCESSKEY && !m_inIMEComposition) 1395 virtualKeyCode = MapVirtualKey(LOBYTE(HIWORD(keyData)), 1); 1396 1397 PlatformKeyboardEvent keyEvent(m_viewWindow, virtualKeyCode, keyData, m_currentCharacterCode, systemKeyDown); 1402 PlatformKeyboardEvent keyEvent(m_viewWindow, virtualKeyCode, keyData, PlatformKeyboardEvent::RawKeyDown, systemKeyDown); 1398 1403 bool handled = frame->eventHandler()->keyEvent(keyEvent); 1399 m_inIMEKeyDown = false; 1400 if (handled) 1401 goto exit; 1404 1405 // These events cannot be canceled. 1406 // FIXME: match IE list more closely, see <http://msdn2.microsoft.com/en-us/library/ms536938.aspx>. 1407 if (systemKeyDown) 1408 handled = false; 1409 1410 if (handled) { 1411 // FIXME: remove WM_UNICHAR, too 1412 MSG msg; 1413 // WM_SYSCHAR events should not be removed, because access keys are implemented in WebCore in WM_SYSCHAR handler. 1414 if (!systemKeyDown) 1415 ::PeekMessage(&msg, m_viewWindow, WM_CHAR, WM_CHAR, PM_REMOVE); 1416 return true; 1417 } 1402 1418 1403 1419 // We need to handle back/forward using either Backspace(+Shift) or Ctrl+Left/Right Arrow keys. 1404 int windowsKeyCode = keyEvent.WindowsKeyCode(); 1405 if ((windowsKeyCode == VK_BACK && keyEvent.shiftKey()) || (windowsKeyCode == VK_RIGHT && keyEvent.ctrlKey())) 1420 if ((virtualKeyCode == VK_BACK && keyEvent.shiftKey()) || (virtualKeyCode == VK_RIGHT && keyEvent.ctrlKey())) 1406 1421 m_page->goForward(); 1407 else if ( windowsKeyCode == VK_BACK || (windowsKeyCode == VK_LEFT && keyEvent.ctrlKey()))1422 else if (virtualKeyCode == VK_BACK || (virtualKeyCode == VK_LEFT && keyEvent.ctrlKey())) 1408 1423 m_page->goBack(); 1409 1424 … … 1411 1426 ScrollDirection direction; 1412 1427 ScrollGranularity granularity; 1413 switch ( windowsKeyCode) {1428 switch (virtualKeyCode) { 1414 1429 case VK_LEFT: 1415 1430 granularity = ScrollByLine; … … 1451 1466 // We want to let Windows handle the WM_SYSCHAR event if we can't handle it 1452 1467 // We do want to return true for regular key down case so the WM_CHAR handler won't pick up unhandled messages 1453 return !systemKeyDown;1468 return false; 1454 1469 } 1455 1470 1456 1471 if (!frame->eventHandler()->scrollOverflow(direction, granularity)) 1457 1472 frame->view()->scroll(direction, granularity); 1458 1459 exit:1460 if (systemKeyDown) // remove sys key message if we have handled it1461 ::PeekMessage(&msg, m_viewWindow, WM_SYSCHAR, WM_SYSCHAR, PM_REMOVE);1462 1463 1473 return true; 1474 } 1475 1476 bool WebView::keyPress(WPARAM charCode, LPARAM keyData, bool systemKeyDown) 1477 { 1478 Frame* frame = m_page->focusController()->focusedOrMainFrame(); 1479 1480 PlatformKeyboardEvent keyEvent(m_viewWindow, charCode, keyData, PlatformKeyboardEvent::Char, systemKeyDown); 1481 return frame->eventHandler()->keyEvent(keyEvent); 1464 1482 } 1465 1483 … … 1577 1595 handled = webView->keyUp(wParam, lParam); 1578 1596 break; 1597 case WM_SYSCHAR: 1598 handled = webView->keyPress(wParam, lParam, true); 1599 break; 1600 case WM_CHAR: 1601 handled = webView->keyPress(wParam, lParam); 1602 break; 1603 // FIXME: We need to check WM_UNICHAR to support supplementary characters (that don't fit in 16 bits). 1579 1604 case WM_SIZE: 1580 1605 if (webView->isBeingDestroyed()) -
trunk/WebKit/win/WebView.h
r28505 r28620 640 640 bool keyDown(WPARAM, LPARAM, bool systemKeyDown = false); 641 641 bool keyUp(WPARAM, LPARAM, bool systemKeyDown = false); 642 bool keyPress(WPARAM, LPARAM, bool systemKeyDown = false); 642 643 bool inResizer(LPARAM lParam); 643 644 void paint(HDC, LPARAM); … … 666 667 void selectionChanged(); 667 668 void resetIME(WebCore::Frame*); 668 bool inIMEKeyDown() const { return m_inIMEKeyDown; }669 669 void setInputMethodState(bool); 670 670 … … 760 760 bool m_hasCustomDropTarget; 761 761 unsigned m_inIMEComposition; 762 bool m_inIMEKeyDown;763 762 HWND m_toolTipHwnd; 764 763 WebCore::String m_toolTip; -
trunk/WebKit/wx/ChangeLog
r28518 r28620 1 2007-12-07 Alexey Proskuryakov <ap@webkit.org> 2 3 Reviewed by Darin. 4 5 <rdar://problem/5535636> 6 Have to press 4 times instead of 2 times to get the expected result of ^^ with german keyboard. 7 8 http://bugs.webkit.org/show_bug.cgi?id=13916 9 JavaScript detects Tab as a character input on a textfield validation 10 11 * WebKitSupport/EditorClientWx.cpp: 12 (WebCore::EditorClientWx::handleInputMethodKeydown): 13 (WebCore::EditorClientWx::handleKeyboardEvent): 14 * WebKitSupport/EditorClientWx.h: 15 Updated for cross-platform changes as much as it was possible without a wx build environment. 16 The keyboard event model of wx is similar to Windows one, so further fixes can be modeled 17 after the Windows port. 18 1 19 2007-12-06 Kevin Ollivier <kevino@theolliviers.com> 2 20 -
trunk/WebKit/wx/WebKitSupport/EditorClientWx.cpp
r27631 r28620 233 233 } 234 234 235 void EditorClientWx::handleInputMethodKey press(KeyboardEvent* event)235 void EditorClientWx::handleInputMethodKeydown(KeyboardEvent* event) 236 236 { 237 237 // NOTE: we don't currently need to handle this. When key events occur, 238 // both this method and handleKey pressget a chance at handling them.238 // both this method and handleKeyboardEvent get a chance at handling them. 239 239 // We might use this method later on for IME-specific handling. 240 240 } 241 241 242 void EditorClientWx::handleKey press(KeyboardEvent* event)242 void EditorClientWx::handleKeyboardEvent(KeyboardEvent* event) 243 243 { 244 244 Frame* frame = m_page->focusController()->focusedOrMainFrame(); … … 247 247 248 248 const PlatformKeyboardEvent* kevent = event->keyEvent(); 249 if (!kevent-> isKeyUp()) {249 if (!kevent->type() == PlatformKeyboardEvent::KeyUp) { 250 250 Node* start = frame->selectionController()->start().node(); 251 251 if (!start || !start->isContentEditable()) 252 252 return; 253 253 254 if (kevent-> isWxCharEvent()&& !kevent->ctrlKey() && !kevent->altKey()) {255 switch (kevent->WindowsKeyCode()) {254 if (kevent->type() == PlatformKeyboardEvent::Char && !kevent->ctrlKey() && !kevent->altKey()) { 255 switch (kevent->windowsVirtualKeyCode()) { 256 256 // we handled these on key down, ignore them for char events 257 257 case VK_BACK: … … 270 270 } 271 271 272 switch (kevent->WindowsKeyCode()) {272 switch (kevent->windowsVirtualKeyCode()) { 273 273 case VK_BACK: 274 274 frame->editor()->deleteWithDirection(SelectionController::BACKWARD, -
trunk/WebKit/wx/WebKitSupport/EditorClientWx.h
r27631 r28620 81 81 virtual void redo(); 82 82 83 virtual void handleKey press(KeyboardEvent*);84 virtual void handleInputMethodKey press(KeyboardEvent*);83 virtual void handleKeyboardEvent(KeyboardEvent*); 84 virtual void handleInputMethodKeydown(KeyboardEvent*); 85 85 86 86 virtual void textFieldDidBeginEditing(Element*); -
trunk/WebKitTools/ChangeLog
r28615 r28620 1 2007-12-07 Alexey Proskuryakov <ap@webkit.org> 2 3 Reviewed by Darin. 4 5 <rdar://problem/5535636> 6 Have to press 4 times instead of 2 times to get the expected result of ^^ with german keyboard. 7 8 http://bugs.webkit.org/show_bug.cgi?id=13916 9 JavaScript detects Tab as a character input on a textfield validation 10 11 * DumpRenderTree/mac/EventSendingController.mm: 12 (-[EventSendingController keyDown:withModifiers:]): Added a few more named keys. 13 Dispatch a keyup to better match what happens when a key is physically pressed. 14 15 * DumpRenderTree/win/EventSender.cpp: 16 (keyDownCallback): Ditto. Also make sure that WM_CHAR is consistently dispatched before 17 returning from keyDown(). 18 (getConstantCallback): Fixed a couple copy/paste mistakes. 19 1 20 2007-12-07 Kevin McCullough <kmccullough@apple.com> 2 21 -
trunk/WebKitTools/DumpRenderTree/mac/EventSendingController.mm
r28124 r28620 351 351 { 352 352 NSString *eventCharacter = character; 353 if ([character isEqualToString:@"rightArrow"]) { 354 const unichar rightArrowCharacter = NSRightArrowFunctionKey; 355 eventCharacter = [NSString stringWithCharacters:&rightArrowCharacter length:1]; 353 if ([character isEqualToString:@"leftArrow"]) { 354 const unichar ch = NSLeftArrowFunctionKey; 355 eventCharacter = [NSString stringWithCharacters:&ch length:1]; 356 } else if ([character isEqualToString:@"rightArrow"]) { 357 const unichar ch = NSRightArrowFunctionKey; 358 eventCharacter = [NSString stringWithCharacters:&ch length:1]; 359 } else if ([character isEqualToString:@"upArrow"]) { 360 const unichar ch = NSUpArrowFunctionKey; 361 eventCharacter = [NSString stringWithCharacters:&ch length:1]; 362 } else if ([character isEqualToString:@"downArrow"]) { 363 const unichar ch = NSDownArrowFunctionKey; 364 eventCharacter = [NSString stringWithCharacters:&ch length:1]; 365 } else if ([character isEqualToString:@"delete"]) { 366 const unichar ch = 0x7f; 367 eventCharacter = [NSString stringWithCharacters:&ch length:1]; 356 368 } 357 369 … … 392 404 393 405 [[[[mainFrame webView] window] firstResponder] keyDown:event]; 406 407 event = [NSEvent keyEventWithType:NSKeyUp 408 location:NSMakePoint(5, 5) 409 modifierFlags:modifierFlags 410 timestamp:[self currentEventTime] 411 windowNumber:[[[mainFrame webView] window] windowNumber] 412 context:[NSGraphicsContext currentContext] 413 characters:eventCharacter 414 charactersIgnoringModifiers:charactersIgnoringModifiers 415 isARepeat:NO 416 keyCode:0]; 417 418 [[[[mainFrame webView] window] firstResponder] keyUp:event]; 394 419 } 395 420 -
trunk/WebKitTools/DumpRenderTree/win/EventSender.cpp
r28453 r28620 71 71 return JSValueMakeNumber(context, WM_KEYUP); 72 72 if (JSStringIsEqualToUTF8CString(propertyName, "WM_CHAR")) 73 return JSValueMakeNumber(context, WM_ KEYDOWN);73 return JSValueMakeNumber(context, WM_CHAR); 74 74 if (JSStringIsEqualToUTF8CString(propertyName, "WM_DEADCHAR")) 75 return JSValueMakeNumber(context, WM_ CHAR);75 return JSValueMakeNumber(context, WM_DEADCHAR); 76 76 if (JSStringIsEqualToUTF8CString(propertyName, "WM_SYSKEYDOWN")) 77 77 return JSValueMakeNumber(context, WM_SYSKEYDOWN); … … 293 293 int charCode = 0; 294 294 bool needsShiftKeyModifier = false; 295 if (JSStringIsEqualToUTF8CString(character, "rightArrow")) { 295 if (JSStringIsEqualToUTF8CString(character, "leftArrow")) 296 virtualKeyCode = VK_LEFT; 297 else if (JSStringIsEqualToUTF8CString(character, "rightArrow")) 296 298 virtualKeyCode = VK_RIGHT; 297 } else { 299 else if (JSStringIsEqualToUTF8CString(character, "upArrow")) 300 virtualKeyCode = VK_UP; 301 else if (JSStringIsEqualToUTF8CString(character, "downArrow")) 302 virtualKeyCode = VK_DOWN; 303 else if (JSStringIsEqualToUTF8CString(character, "delete")) 304 virtualKeyCode = VK_BACK; 305 else { 298 306 charCode = JSStringGetCharactersPtr(character)[0]; 299 307 virtualKeyCode = LOBYTE(VkKeyScan(charCode)); … … 344 352 // ::Translate will not work, so we post an WM_CHAR event ourselves. 345 353 ::PostMessage(webViewWindow, WM_CHAR, charCode, 0); 354 } 355 356 // Tests expect that all messages are processed by the time keyDown() returns. 357 if (::PeekMessage(&msg, webViewWindow, WM_CHAR, WM_CHAR, PM_REMOVE)) 346 358 ::DispatchMessage(&msg); 347 } 359 360 MSG msgUp = makeMsg(webViewWindow, WM_KEYUP, virtualKeyCode, 0); 361 ::DispatchMessage(&msgUp); 348 362 349 363 if (argumentCount > 1 || needsShiftKeyModifier) … … 385 399 msg.pt = lastMousePosition; 386 400 387 dispatchMessage(&msg);401 ::DispatchMessage(&msg); 388 402 389 403 return JSValueMakeUndefined(context);
Note:
See TracChangeset
for help on using the changeset viewer.