Changeset 208143 in webkit
- Timestamp:
- Oct 31, 2016, 8:12:00 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r208138 r208143 1 2016-10-31 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Holding down a key to choose an accented character should fire "insertReplacementText" input events 4 https://bugs.webkit.org/show_bug.cgi?id=164209 5 <rdar://problem/29019305> 6 7 Reviewed by Darin Adler. 8 9 Adds 2 new layout tests to verify that inserting replacement text fires input events of inputType 10 "insertReplacementText" instead of the generic "insertText", and that calling preventDefault() on the 11 beforeinput event prevents text from being inserted. Also checks that inserting replacement text in 12 contenteditable areas causes the dataTransfer attribute to be populated, and that the data attribute is null. 13 14 * fast/events/before-input-prevent-insert-replacement-expected.txt: Added. 15 * fast/events/before-input-prevent-insert-replacement.html: Added. 16 * fast/events/input-event-insert-replacement-expected.txt: Added. 17 * fast/events/input-event-insert-replacement.html: Added. 18 * platform/ios-simulator/TestExpectations: 19 * platform/mac-wk1/TestExpectations: 20 1 21 2016-10-30 Gyuyoung Kim <gyuyoung.kim@webkit.org> 2 22 -
trunk/LayoutTests/platform/ios-simulator/TestExpectations
r208105 r208143 1203 1203 fast/events/ime-composition-events-001.html [ Failure ] 1204 1204 fast/events/inputText-never-fired-on-keydown-cancel.html [ Failure ] 1205 fast/events/input-event-insert-replacement.html [ Failure ] 1205 1206 fast/events/input-events-drag-and-drop.html [ Failure ] 1206 1207 fast/events/input-events-insert-by-drop.html [ Failure ] … … 1213 1214 fast/events/input-events-paste-rich-datatransfer.html [ Failure ] 1214 1215 fast/events/input-events-spell-checking-datatransfer.html [ Failure ] 1216 fast/events/before-input-prevent-insert-replacement.html [ Failure ] 1215 1217 fast/events/before-input-events-prevent-default.html [ Failure ] 1216 1218 fast/events/before-input-events-prevent-default-in-textfield.html [ Failure ] -
trunk/LayoutTests/platform/mac-wk1/TestExpectations
r207635 r208143 84 84 # WK1 and WK2 mousemove events are subtly different in ways that break this test on WK1. 85 85 fast/events/ghostly-mousemoves-in-subframe.html [ Skip ] 86 87 # Test support for inserting special characters is not yet implemented on WK1. 88 fast/events/before-input-prevent-insert-replacement.html [ Skip ] 89 fast/events/input-event-insert-replacement.html [ Skip ] 86 90 87 91 # Media Stream API testing is not supported for WK1 yet. -
trunk/Source/WebCore/ChangeLog
r208142 r208143 1 2016-10-31 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Holding down a key to choose an accented character should fire "insertReplacementText" input events 4 https://bugs.webkit.org/show_bug.cgi?id=164209 5 <rdar://problem/29019305> 6 7 Reviewed by Darin Adler. 8 9 For TypingCommands that correspond to "insertReplacementText" inputTypes, vend dataTransfers for resulting 10 beforeinput and input events if the edited area is not an input field or textarea. To do this, convert the plain 11 text representation of the content to be inserted to HTML text using a helper function, 12 MarkupAccumulator::appendCharactersReplacingEntities, that is used when creating markup for Text nodes. 13 14 Tests: fast/events/before-input-prevent-insert-replacement.html 15 fast/events/input-event-insert-replacement.html 16 17 * editing/TypingCommand.cpp: 18 (WebCore::TypingCommand::inputEventData): 19 (WebCore::TypingCommand::inputEventDataTransfer): 20 * editing/TypingCommand.h: 21 1 22 2016-10-30 Dave Hyatt <hyatt@apple.com> 2 23 -
trunk/Source/WebCore/editing/TypingCommand.cpp
r208090 r208143 29 29 #include "AXObjectCache.h" 30 30 #include "BreakBlockquoteCommand.h" 31 #include "DataTransfer.h" 31 32 #include "DeleteSelectionCommand.h" 32 33 #include "Document.h" … … 40 41 #include "InsertTextCommand.h" 41 42 #include "Logging.h" 43 #include "MarkupAccumulator.h" 42 44 #include "MathMLElement.h" 43 45 #include "RenderElement.h" … … 407 409 switch (m_currentTypingEditAction) { 408 410 case EditActionTypingInsertText: 409 case EditActionInsertReplacement:410 411 case EditActionTypingInsertPendingComposition: 411 412 case EditActionTypingInsertFinalComposition: 412 413 return m_currentTextToInsert; 414 case EditActionInsertReplacement: 415 return isEditingTextAreaOrTextInput() ? m_currentTextToInsert : String(); 413 416 default: 414 417 return CompositeEditCommand::inputEventData(); 415 418 } 419 } 420 421 RefPtr<DataTransfer> TypingCommand::inputEventDataTransfer() const 422 { 423 if (m_currentTypingEditAction != EditActionInsertReplacement || isEditingTextAreaOrTextInput()) 424 return nullptr; 425 426 StringBuilder htmlText; 427 MarkupAccumulator::appendCharactersReplacingEntities(htmlText, m_currentTextToInsert, 0, m_currentTextToInsert.length(), EntityMaskInHTMLPCDATA); 428 return DataTransfer::createForInputEvent(m_currentTextToInsert, htmlText.toString()); 416 429 } 417 430 -
trunk/Source/WebCore/editing/TypingCommand.h
r208090 r208143 121 121 String inputEventTypeName() const final; 122 122 String inputEventData() const final; 123 RefPtr<DataTransfer> inputEventDataTransfer() const final; 123 124 bool isBeforeInputEventCancelable() const final; 124 125 -
trunk/Source/WebKit2/ChangeLog
r208135 r208143 1 2016-10-31 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Holding down a key to choose an accented character should fire "insertReplacementText" input events 4 https://bugs.webkit.org/show_bug.cgi?id=164209 5 <rdar://problem/29019305> 6 7 Reviewed by Darin Adler. 8 9 When replacing text, call Editor::insertText with the correct TextEventInputType so that WebCore will know to 10 use EditActionInsertReplacement when creating and applying the corresponding TypingCommand. Additional minor 11 changes in order to support testing replacement text insertion. 12 13 * UIProcess/API/Cocoa/WKWebView.mm: 14 (-[WKWebView _insertText:replacementRange:]): 15 * UIProcess/API/Cocoa/WKWebViewPrivate.h: 16 * WebProcess/WebPage/WebPage.cpp: 17 (WebKit::WebPage::insertTextAsync): 18 1 19 2016-10-30 Darin Adler <darin@apple.com> 2 20 -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
r207822 r208143 4651 4651 // Overridden by subclasses. 4652 4652 } 4653 4654 - (void)_insertText:(id)string replacementRange:(NSRange)replacementRange 4655 { 4656 [self insertText:string replacementRange:replacementRange]; 4657 } 4653 4658 #endif // PLATFORM(MAC) 4654 4659 -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h
r208024 r208143 291 291 - (void)_requestActiveNowPlayingSessionInfo WK_API_AVAILABLE(macosx(WK_MAC_TBA)); 292 292 - (void)_handleActiveNowPlayingSessionInfoResponse:(BOOL)hasActiveSession title:(NSString *)title duration:(double)duration elapsedTime:(double)elapsedTime WK_API_AVAILABLE(macosx(WK_MAC_TBA)); 293 294 - (void)_insertText:(id)string replacementRange:(NSRange)replacementRange WK_API_AVAILABLE(macosx(WK_MAC_TBA)); 293 295 #endif 294 296 -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
r208096 r208143 4626 4626 Frame& frame = m_page->focusController().focusedOrMainFrame(); 4627 4627 4628 bool replacesText = false; 4628 4629 if (replacementEditingRange.location != notFound) { 4629 4630 RefPtr<Range> replacementRange = rangeFromEditingRange(frame, replacementEditingRange, static_cast<EditingRangeIsRelativeTo>(editingRangeIsRelativeTo)); … … 4631 4632 TemporaryChange<bool> isSelectingTextWhileInsertingAsynchronously(m_isSelectingTextWhileInsertingAsynchronously, suppressSelectionUpdate); 4632 4633 frame.selection().setSelection(VisibleSelection(*replacementRange, SEL_DEFAULT_AFFINITY)); 4634 replacesText = true; 4633 4635 } 4634 4636 } … … 4640 4642 // An insertText: might be handled by other responders in the chain if we don't handle it. 4641 4643 // One example is space bar that results in scrolling down the page. 4642 frame.editor().insertText(text, nullptr );4644 frame.editor().insertText(text, nullptr, replacesText ? TextEventInputAutocompletion : TextEventInputKeyboard); 4643 4645 } else 4644 4646 frame.editor().confirmComposition(text); -
trunk/Tools/ChangeLog
r208134 r208143 1 2016-10-31 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Holding down a key to choose an accented character should fire "insertReplacementText" input events 4 https://bugs.webkit.org/show_bug.cgi?id=164209 5 <rdar://problem/29019305> 6 7 Reviewed by Darin Adler. 8 9 Adds test support for inserting replacement text on Mac. This is equivalent to holding down a vowel key (e.g. 10 'a') to bring up the menu containing accented version of the character, then selecting an accented character to 11 insert in place of the typed character. This is exposed via UIScriptController.insertText, which takes a string 12 and an insertion range. 13 14 * DumpRenderTree/mac/UIScriptControllerMac.mm: 15 (WTR::UIScriptController::insertText): 16 * TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl: 17 18 Note that there is no callback argument to insertText, since UIScriptController::insertText is synchronous in 19 the UI process. The tests end when corresponding input events fired as a result of insertText have been received 20 in the web process. Please see the new layout tests for more detail. 21 22 * TestRunnerShared/UIScriptContext/UIScriptController.cpp: 23 (WTR::UIScriptController::insertText): 24 * TestRunnerShared/UIScriptContext/UIScriptController.h: 25 * WebKitTestRunner/mac/UIScriptControllerMac.mm: 26 (WTR::nsStringFromJSString): 27 (WTR::UIScriptController::insertText): 28 1 29 2016-10-30 Sam Weinig <sam@webkit.org> 2 30 -
trunk/Tools/DumpRenderTree/mac/UIScriptControllerMac.mm
r204877 r208143 44 44 } 45 45 46 void UIScriptController::insertText(JSStringRef, int, int) 47 { 48 } 49 46 50 } 47 51 -
trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl
r208090 r208143 157 157 readonly attribute object selectionRangeViewRects; // An array of objects with 'left', 'top', 'width', and 'height' properties. 158 158 159 void insertText(DOMString text, long location, long length); 160 159 161 void uiScriptComplete(DOMString result); 160 162 }; -
trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp
r208090 r208143 318 318 #endif 319 319 320 #if !PLATFORM(MAC) 321 322 void UIScriptController::insertText(JSStringRef, int, int) 323 { 324 } 325 326 #endif 327 320 328 void UIScriptController::uiScriptComplete(JSStringRef result) 321 329 { -
trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h
r208090 r208143 118 118 JSObjectRef selectionRangeViewRects() const; 119 119 120 void insertText(JSStringRef, int location, int length); 121 120 122 void uiScriptComplete(JSStringRef result); 121 123 -
trunk/Tools/WebKitTestRunner/mac/UIScriptControllerMac.mm
r194721 r208143 27 27 #import "UIScriptController.h" 28 28 29 #import "PlatformWebView.h" 30 #import "TestController.h" 31 #import "TestRunnerWKWebView.h" 29 32 #import "UIScriptContext.h" 33 #import <JavaScriptCore/JSStringRefCF.h> 34 #import <WebKit/WKWebViewPrivate.h> 30 35 31 36 namespace WTR { 37 38 NSString *nsString(JSStringRef string) 39 { 40 return (NSString *)adoptCF(JSStringCopyCFString(kCFAllocatorDefault, string)).autorelease(); 41 } 32 42 33 43 void UIScriptController::doAsyncTask(JSValueRef callback) … … 42 52 } 43 53 54 void UIScriptController::insertText(JSStringRef text, int location, int length) 55 { 56 #if WK_API_ENABLED 57 if (location == -1) 58 location = NSNotFound; 59 60 auto* webView = TestController::singleton().mainWebView()->platformView(); 61 [webView _insertText:nsString(text) replacementRange:NSMakeRange(location, length)]; 62 #else 63 UNUSED_PARAM(text); 64 UNUSED_PARAM(location); 65 UNUSED_PARAM(length); 66 #endif 44 67 } 68 69 }
Note:
See TracChangeset
for help on using the changeset viewer.