Changeset 244975 in webkit
- Timestamp:
- May 6, 2019 1:41:02 PM (5 years ago)
- Location:
- trunk/Source
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r244971 r244975 1 2019-05-06 Daniel Bates <dabates@apple.com> 2 3 Google Docs & Yahoo! Japan: Can’t compose characters with Chinese or Japanese keyboard 4 https://bugs.webkit.org/show_bug.cgi?id=197474 5 <rdar://problem/47219324> 6 7 Reviewed by Ryosuke Niwa. 8 9 Fix up some #if defs to compile more Mac code when building on iOS. 10 11 * dom/KeyboardEvent.cpp: 12 (WebCore::KeyboardEvent::KeyboardEvent): 13 * platform/PlatformKeyboardEvent.h: 14 (WebCore::PlatformKeyboardEvent::PlatformKeyboardEvent): 15 1 16 2019-05-06 Chris Dumez <cdumez@apple.com> 2 17 -
trunk/Source/WebCore/dom/KeyboardEvent.cpp
r239427 r244975 108 108 , m_repeat(key.isAutoRepeat()) 109 109 , m_isComposing(view && is<DOMWindow>(view->window()) && downcast<DOMWindow>(*view->window()).frame() && downcast<DOMWindow>(*view->window()).frame()->editor().hasComposition()) 110 #if USE(APPKIT) || USE(UIKIT_KEYBOARD_ADDITIONS) 111 , m_handledByInputMethod(key.handledByInputMethod()) 112 #endif 110 113 #if USE(APPKIT) 111 , m_handledByInputMethod(key.handledByInputMethod())112 114 , m_keypressCommands(key.commands()) 113 115 #endif -
trunk/Source/WebCore/platform/PlatformKeyboardEvent.h
r239427 r244975 54 54 : PlatformEvent(PlatformEvent::KeyDown) 55 55 , m_windowsVirtualKeyCode(0) 56 #if USE(APPKIT) || PLATFORM(GTK)57 , m_handledByInputMethod(false)58 #endif59 56 , m_autoRepeat(false) 60 57 , m_isKeypad(false) … … 85 82 , m_keyIdentifier(keyIdentifier) 86 83 , m_windowsVirtualKeyCode(windowsVirtualKeyCode) 87 #if USE(APPKIT) || PLATFORM(GTK)88 , m_handledByInputMethod(false)89 #endif90 84 , m_autoRepeat(isAutoRepeat) 91 85 , m_isKeypad(isKeypad) … … 123 117 void setWindowsVirtualKeyCode(int code) { m_windowsVirtualKeyCode = code; } 124 118 125 #if USE(APPKIT) || PLATFORM(GTK)119 #if USE(APPKIT) || USE(UIKIT_KEYBOARD_ADDITIONS) || PLATFORM(GTK) 126 120 bool handledByInputMethod() const { return m_handledByInputMethod; } 127 121 #endif … … 186 180 String m_keyIdentifier; 187 181 int m_windowsVirtualKeyCode; 188 #if USE(APPKIT) || PLATFORM(GTK)189 bool m_handledByInputMethod ;182 #if USE(APPKIT) || USE(UIKIT_KEYBOARD_ADDITIONS) || PLATFORM(GTK) 183 bool m_handledByInputMethod { false }; 190 184 #endif 191 185 #if USE(APPKIT) -
trunk/Source/WebKit/ChangeLog
r244970 r244975 1 2019-05-06 Daniel Bates <dabates@apple.com> 2 3 Google Docs & Yahoo! Japan: Can’t compose characters with Chinese or Japanese keyboard 4 https://bugs.webkit.org/show_bug.cgi?id=197474 5 <rdar://problem/47219324> 6 7 Reviewed by Ryosuke Niwa. 8 9 Adopt UIKit SPI (added in <rdar://problem/50181162>) to ask the Input Manager to handle 10 the key event. If the Input Manager handled it then we pass along this information to 11 WebCore, just as we do for Mac, so that it can alter its event handling logic. Otherwise, 12 we handle the event as we do now. 13 14 A large part of this patch is fixing up #if defs to compile more Mac code when building 15 on iOS. 16 17 * Platform/spi/ios/UIKitSPI.h: Expose more SPI. 18 * Shared/NativeWebKeyboardEvent.h: 19 * Shared/WebEvent.h: 20 * Shared/WebEventConversion.cpp: 21 (WebKit::WebKit2PlatformKeyboardEvent::WebKit2PlatformKeyboardEvent): 22 * Shared/WebKeyboardEvent.cpp: 23 (WebKit::WebKeyboardEvent::WebKeyboardEvent): 24 (WebKit::WebKeyboardEvent::encode const): 25 (WebKit::WebKeyboardEvent::decode): 26 * Shared/ios/NativeWebKeyboardEventIOS.mm: 27 (WebKit::NativeWebKeyboardEvent::NativeWebKeyboardEvent): 28 * Shared/ios/WebIOSEventFactory.h: 29 * Shared/ios/WebIOSEventFactory.mm: 30 (WebIOSEventFactory::createWebKeyboardEvent): 31 Compile more Mac code on iOS. Just like on Mac we maintain some bookkeeping on 32 whether an event was handled by the Input Manager. 33 34 * UIProcess/Automation/ios/WebAutomationSessionIOS.mm: 35 (WebKit::WebAutomationSession::sendSynthesizedEventsToPage): Pass NativeWebKeyboardEvent::HandledByInputMethod::No 36 to keep the behavior we have now. 37 38 * UIProcess/ios/WKContentViewInteraction.h: 39 * UIProcess/ios/WKContentViewInteraction.mm: 40 (-[WKContentView cleanupInteraction]): 41 (-[WKContentView shouldSuppressUpdateCandidateView]): Added. Used to tell UIKit whether to 42 suppress updating/showing the candidate view. 43 (-[WKContentView setMarkedText:selectedRange:]): 44 Bookkeeping to track whether we need to delay showing/updating the inline candidate view. 45 The concept in UIKit is deferment, but at the time of writing its simply a request to delay 46 the update for 0.4 seconds. We opt into this delay only for the first key that begins 47 marked text (i.e. the transition from no marked text to marked text). We do this because we 48 may not have up-to-date editor state at the time UIKit is ready to show/update the inline 49 candidate view for us to answer -textFirstRect and -textLastRect, which UIKit calls as part 50 of computing the frame rect for the inline candidate view on screen. Once we receive up-to-date 51 editor state, in -selectionChanged, we tell UIKit to layout the keyboard, which ultimately 52 causes it to re-compute the frame rect for the inline candidate view and show it. 53 54 (-[WKContentView handleKeyWebEvent:]): Pass NativeWebKeyboardEvent::HandledByInputMethod::No 55 to keep the behavior we have now. 56 (-[WKContentView handleKeyWebEvent:withCompletionHandler:]): Ask the keyboard to handle the 57 event using the Input Manager. If it was handled then there is no need to delay calling the 58 completion handler, call it, then tell the web process about the key event and that it was 59 already handled by the Input Manager. 60 (-[WKContentView _selectionChanged]): Tell the keyboard to update the candidate view, if needed. 61 * WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm: 62 (WebKit::WebEditorClient::handleInputMethodKeydown): Mark the event as default handled if 63 the UI process told us that the event was handled by the Input Manager just like we do on Mac. 64 1 65 2019-05-06 Alex Christensen <achristensen@webkit.org> 2 66 -
trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h
r244955 r244975 387 387 @end 388 388 389 @protocol UITextInputDelegatePrivate 390 - (void)layoutHasChanged; 391 @end 392 389 393 @class UITextInputArrowKeyHistory; 390 394 … … 1122 1126 - (BOOL)handleKeyTextCommandForCurrentEvent; 1123 1127 - (BOOL)handleKeyAppCommandForCurrentEvent; 1128 - (BOOL)handleKeyInputMethodCommandForCurrentEvent; 1124 1129 @property (nonatomic, readonly) UIKeyboardInputMode *currentInputModeInPreference; 1125 1130 @end -
trunk/Source/WebKit/Shared/NativeWebKeyboardEvent.h
r238384 r244975 66 66 public: 67 67 #if USE(APPKIT) 68 // FIXME: Share iOS's HandledByInputMethod enum here instead of passing a boolean. 68 69 NativeWebKeyboardEvent(NSEvent *, bool handledByInputMethod, bool replacesSoftSpace, const Vector<WebCore::KeypressCommand>&); 69 70 #elif PLATFORM(GTK) … … 71 72 NativeWebKeyboardEvent(GdkEvent*, const WebCore::CompositionResults&, InputMethodFilter::EventFakedForComposition, Vector<String>&& commands); 72 73 #elif PLATFORM(IOS_FAMILY) 73 NativeWebKeyboardEvent(::WebEvent *); 74 enum class HandledByInputMethod : bool { No, Yes }; 75 NativeWebKeyboardEvent(::WebEvent *, HandledByInputMethod); 74 76 #elif USE(LIBWPE) 75 77 NativeWebKeyboardEvent(struct wpe_input_keyboard_event*); -
trunk/Source/WebKit/Shared/WebEvent.h
r243460 r244975 260 260 WebKeyboardEvent(Type, const String& text, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool handledByInputMethod, Vector<String>&& commands, bool isKeypad, OptionSet<Modifier>, WallTime timestamp); 261 261 #elif PLATFORM(IOS_FAMILY) 262 WebKeyboardEvent(Type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<Modifier>, WallTime timestamp);262 WebKeyboardEvent(Type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool handledByInputMethod, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<Modifier>, WallTime timestamp); 263 263 #elif USE(LIBWPE) 264 264 WebKeyboardEvent(Type, const String& text, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, bool isKeypad, OptionSet<Modifier>, WallTime timestamp); … … 279 279 int32_t nativeVirtualKeyCode() const { return m_nativeVirtualKeyCode; } 280 280 int32_t macCharCode() const { return m_macCharCode; } 281 #if USE(APPKIT) || PLATFORM(GTK)281 #if USE(APPKIT) || USE(UIKIT_KEYBOARD_ADDITIONS) || PLATFORM(GTK) 282 282 bool handledByInputMethod() const { return m_handledByInputMethod; } 283 283 #endif … … 309 309 int32_t m_nativeVirtualKeyCode; 310 310 int32_t m_macCharCode; 311 #if USE(APPKIT) || PLATFORM(GTK)311 #if USE(APPKIT) || USE(UIKIT_KEYBOARD_ADDITIONS) || PLATFORM(GTK) 312 312 bool m_handledByInputMethod; 313 313 #endif -
trunk/Source/WebKit/Shared/WebEventConversion.cpp
r241044 r244975 222 222 m_keyIdentifier = webEvent.keyIdentifier(); 223 223 m_windowsVirtualKeyCode = webEvent.windowsVirtualKeyCode(); 224 #if USE(APPKIT) || USE(UIKIT_KEYBOARD_ADDITIONS) || PLATFORM(GTK) 225 m_handledByInputMethod = webEvent.handledByInputMethod(); 226 #endif 224 227 #if USE(APPKIT) || PLATFORM(GTK) 225 m_handledByInputMethod = webEvent.handledByInputMethod();226 228 m_commands = webEvent.commands(); 227 229 #endif -
trunk/Source/WebKit/Shared/WebKeyboardEvent.cpp
r241000 r244975 84 84 #elif PLATFORM(IOS_FAMILY) 85 85 86 WebKeyboardEvent::WebKeyboardEvent(Type type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<Modifier> modifiers, WallTime timestamp)86 WebKeyboardEvent::WebKeyboardEvent(Type type, const String& text, const String& unmodifiedText, const String& key, const String& code, const String& keyIdentifier, int windowsVirtualKeyCode, int nativeVirtualKeyCode, int macCharCode, bool handledByInputMethod, bool isAutoRepeat, bool isKeypad, bool isSystemKey, OptionSet<Modifier> modifiers, WallTime timestamp) 87 87 : WebEvent(type, modifiers, timestamp) 88 88 , m_text(text) … … 98 98 , m_nativeVirtualKeyCode(nativeVirtualKeyCode) 99 99 , m_macCharCode(macCharCode) 100 #if USE(UIKIT_KEYBOARD_ADDITIONS) 101 , m_handledByInputMethod(handledByInputMethod) 102 #endif 100 103 , m_isAutoRepeat(isAutoRepeat) 101 104 , m_isKeypad(isKeypad) … … 167 170 encoder << m_nativeVirtualKeyCode; 168 171 encoder << m_macCharCode; 172 #if USE(APPKIT) || USE(UIKIT_KEYBOARD_ADDITIONS) || PLATFORM(GTK) 173 encoder << m_handledByInputMethod; 174 #endif 169 175 #if USE(APPKIT) || PLATFORM(GTK) 170 encoder << m_handledByInputMethod;171 176 encoder << m_commands; 172 177 #endif … … 201 206 if (!decoder.decode(result.m_macCharCode)) 202 207 return false; 208 #if USE(APPKIT) || USE(UIKIT_KEYBOARD_ADDITIONS) || PLATFORM(GTK) 209 if (!decoder.decode(result.m_handledByInputMethod)) 210 return false; 211 #endif 203 212 #if USE(APPKIT) || PLATFORM(GTK) 204 if (!decoder.decode(result.m_handledByInputMethod))205 return false;206 213 if (!decoder.decode(result.m_commands)) 207 214 return false; -
trunk/Source/WebKit/Shared/ios/NativeWebKeyboardEventIOS.mm
r244955 r244975 35 35 namespace WebKit { 36 36 37 NativeWebKeyboardEvent::NativeWebKeyboardEvent(::WebEvent *event )38 : WebKeyboardEvent(WebIOSEventFactory::createWebKeyboardEvent(event ))37 NativeWebKeyboardEvent::NativeWebKeyboardEvent(::WebEvent *event, HandledByInputMethod handledByInputMethod) 38 : WebKeyboardEvent(WebIOSEventFactory::createWebKeyboardEvent(event, handledByInputMethod == HandledByInputMethod::Yes)) 39 39 , m_nativeEvent(event) 40 40 { -
trunk/Source/WebKit/Shared/ios/WebIOSEventFactory.h
r241282 r244975 34 34 class WebIOSEventFactory { 35 35 public: 36 static WebKit::WebKeyboardEvent createWebKeyboardEvent(::WebEvent * );36 static WebKit::WebKeyboardEvent createWebKeyboardEvent(::WebEvent *, bool handledByInputMethod); 37 37 static WebKit::WebMouseEvent createWebMouseEvent(::WebEvent *); 38 38 -
trunk/Source/WebKit/Shared/ios/WebIOSEventFactory.mm
r241282 r244975 65 65 } 66 66 67 WebKit::WebKeyboardEvent WebIOSEventFactory::createWebKeyboardEvent(::WebEvent *event )67 WebKit::WebKeyboardEvent WebIOSEventFactory::createWebKeyboardEvent(::WebEvent *event, bool handledByInputMethod) 68 68 { 69 69 WebKit::WebEvent::Type type = (event.type == WebEventKeyUp) ? WebKit::WebEvent::KeyUp : WebKit::WebEvent::KeyDown; … … 110 110 } 111 111 112 return WebKit::WebKeyboardEvent (type, text, unmodifiedText, key, code, keyIdentifier, windowsVirtualKeyCode, nativeVirtualKeyCode, macCharCode, autoRepeat, isKeypad, isSystemKey, modifiers, WallTime::fromRawSeconds(timestamp));112 return WebKit::WebKeyboardEvent { type, text, unmodifiedText, key, code, keyIdentifier, windowsVirtualKeyCode, nativeVirtualKeyCode, macCharCode, handledByInputMethod, autoRepeat, isKeypad, isSystemKey, modifiers, WallTime::fromRawSeconds(timestamp) }; 113 113 } 114 114 -
trunk/Source/WebKit/UIProcess/Automation/ios/WebAutomationSessionIOS.mm
r240554 r244975 59 59 case WebEventKeyDown: 60 60 case WebEventKeyUp: 61 page.handleKeyboardEvent(NativeWebKeyboardEvent(event ));61 page.handleKeyboardEvent(NativeWebKeyboardEvent(event, NativeWebKeyboardEvent::HandledByInputMethod::No)); 62 62 break; 63 63 } -
trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
r244955 r244975 324 324 325 325 BOOL _keyboardDidRequestDismissal; 326 327 #if USE(UIKIT_KEYBOARD_ADDITIONS) 328 BOOL _candidateViewNeedsUpdate; 329 #endif 326 330 327 331 BOOL _becomingFirstResponder; -
trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
r244955 r244975 840 840 _focusRequiresStrongPasswordAssistance = NO; 841 841 842 #if USE(UIKIT_KEYBOARD_ADDITIONS) 843 _candidateViewNeedsUpdate = NO; 844 #endif 845 842 846 if (_interactionViewsContainerView) { 843 847 [self.layer removeObserver:self forKeyPath:@"transform"]; … … 4041 4045 - (void)setMarkedText:(NSString *)markedText selectedRange:(NSRange)selectedRange 4042 4046 { 4047 #if USE(UIKIT_KEYBOARD_ADDITIONS) 4048 _candidateViewNeedsUpdate = !self.hasMarkedText; 4049 #endif 4043 4050 _markedText = markedText; 4044 4051 _page->setCompositionAsync(markedText, Vector<WebCore::CompositionUnderline>(), selectedRange, WebKit::EditingRange()); … … 4424 4431 4425 4432 #if USE(UIKIT_KEYBOARD_ADDITIONS) 4433 4426 4434 - (void)modifierFlagsDidChangeFrom:(UIKeyModifierFlags)oldFlags to:(UIKeyModifierFlags)newFlags 4427 4435 { … … 4440 4448 dispatchSyntheticFlagsChangedEvents(addedFlags, true); 4441 4449 } 4450 4451 - (BOOL)shouldSuppressUpdateCandidateView 4452 { 4453 return _candidateViewNeedsUpdate; 4454 } 4455 4442 4456 #endif 4443 4457 … … 4484 4498 - (void)handleKeyWebEvent:(::WebEvent *)theEvent 4485 4499 { 4486 _page->handleKeyboardEvent(WebKit::NativeWebKeyboardEvent(theEvent ));4500 _page->handleKeyboardEvent(WebKit::NativeWebKeyboardEvent(theEvent, WebKit::NativeWebKeyboardEvent::HandledByInputMethod::No)); 4487 4501 } 4488 4502 … … 4491 4505 [self _handleDOMPasteRequestWithResult:WebCore::DOMPasteAccessResponse::DeniedForGesture]; 4492 4506 4507 using HandledByInputMethod = WebKit::NativeWebKeyboardEvent::HandledByInputMethod; 4508 #if USE(UIKIT_KEYBOARD_ADDITIONS) 4509 auto* keyboard = [UIKeyboardImpl sharedInstance]; 4510 if ([keyboard respondsToSelector:@selector(handleKeyInputMethodCommandForCurrentEvent)] && [keyboard handleKeyInputMethodCommandForCurrentEvent]) { 4511 completionHandler(theEvent, YES); 4512 _page->handleKeyboardEvent(WebKit::NativeWebKeyboardEvent(theEvent, HandledByInputMethod::Yes)); 4513 return; 4514 } 4515 #endif 4493 4516 _keyWebEventHandler = makeBlockPtr(completionHandler); 4494 _page->handleKeyboardEvent(WebKit::NativeWebKeyboardEvent(theEvent ));4517 _page->handleKeyboardEvent(WebKit::NativeWebKeyboardEvent(theEvent, HandledByInputMethod::No)); 4495 4518 } 4496 4519 … … 5633 5656 if (_usingGestureForSelection) 5634 5657 [self _updateChangedSelection]; 5658 5659 #if USE(UIKIT_KEYBOARD_ADDITIONS) 5660 if (_candidateViewNeedsUpdate) { 5661 _candidateViewNeedsUpdate = NO; 5662 if ([self.inputDelegate respondsToSelector:@selector(layoutHasChanged)]) 5663 [(id <UITextInputDelegatePrivate>)self.inputDelegate layoutHasChanged]; 5664 } 5665 #endif 5635 5666 5636 5667 [_webView _didChangeEditorState]; -
trunk/Source/WebKit/WebProcess/WebCoreSupport/ios/WebEditorClientIOS.mm
r244932 r244975 45 45 void WebEditorClient::handleInputMethodKeydown(KeyboardEvent&) 46 46 { 47 #if USE(UIKIT_KEYBOARD_ADDITIONS) 48 if (event->handledByInputMethod()) 49 event->setDefaultHandled(); 50 #else 47 51 notImplemented(); 52 #endif 48 53 } 49 54
Note: See TracChangeset
for help on using the changeset viewer.