Changeset 264352 in webkit
- Timestamp:
- Jul 14, 2020, 10:55:57 AM (6 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 3 edited
-
ChangeLog (modified) (1 diff)
-
UIProcess/ios/WKContentViewInteraction.h (modified) (1 diff)
-
UIProcess/ios/WKContentViewInteraction.mm (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r264333 r264352 1 2020-07-14 Daniel Bates <dabates@apple.com> 2 3 [iOS] Sometimes unable to type Japanese on docs.google.com 4 https://bugs.webkit.org/show_bug.cgi?id=214272 5 <rdar://problem/59449972> 6 7 Reviewed by Wenson Hsieh. 8 9 Tell the web process to restore the selection of the focused element when re-focusing it 10 on page activation. 11 12 When resigning first responder the text interaction assistant is deactivated and calls 13 back into WKContentView's -clearSelection, which clears the focused element and tells 14 the web process to clear the selection. Keep in mind that the focused element in the web 15 process is not changed. When the WKContentView subsequently becomes first responder the 16 web process messages the UI process to tell it to start assistance (aka focus) for focused 17 element. However the selection is not restored and thus the editor state the UI process 18 has, and is even sent up until there is a selection change, mismatches with the focused 19 element information it also has. To match Mac, key events are only passed to the input 20 manager if an editable element is focused (see <https://bugs.webkit.org/show_bug.cgi?id=199122>). 21 So, key events are not passed to the input manager when in this state. To prevent this, 22 restore the selection of the focused element when the element is re-focused because the 23 page became active again. 24 25 Selection restoration is driven by the UI process (not the web process) because element re- 26 focusing may be denied by the embedding client. In this case, selection should not be restored 27 because UI assistance was not started. For the same reason, I do not restore it in -becomeFirstResponderForWebView. 28 29 * UIProcess/ios/WKContentViewInteraction.h: 30 * UIProcess/ios/WKContentViewInteraction.mm: 31 (-[WKContentView cleanUpInteraction]): 32 (-[WKContentView _didCommitLoadForMainFrame]): 33 Clear out the flag. See below for more details. 34 35 (-[WKContentView handleKeyWebEvent:withCompletionHandler:]): Pass the key to the input manager 36 if the _treatAsContentEditableUntilNextEditorStateUpdate is YES. 37 (-[WKContentView _elementDidFocus:userIsInteracting:blurPreviousNode:activityStateChanges:userObject:]): 38 If this request is a result of the page activating (aka focus activity change) into an editable field 39 (i.e. mayContainSelectableText() resturns YES) and assistance is not being suppressed then tell the web 40 process to restore the selection. As part of this I tell the text interaction assistant to activate even 41 though -becomeFirstResponderForWebView was called beforehand because -becomeFirstResponderForWebView only 42 activates it if there is a non-empty selection. (Note the page having an empty selection could have been 43 a result of -clearSelection having been called though the page could have done it programmatically as well). 44 I also set a new flag to YES and schedule a full editor state update to ensure this flag is cleared. 45 The flag is so that key events that come in between now and the next editor state update are passed to the 46 input manager. 47 (-[WKContentView _didUpdateEditorState]): Clear out the flag. See above for more details. 48 1 49 2020-07-14 Fujii Hironori <Hironori.Fujii@sony.com> 2 50 -
trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
r264187 r264352 361 361 BOOL _textInteractionDidChangeFocusedElement; 362 362 BOOL _textInteractionIsHappening; 363 BOOL _treatAsContentEditableUntilNextEditorStateUpdate; 363 364 bool _isWaitingOnPositionInformation; 364 365 -
trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
r264205 r264352 936 936 _textInteractionIsHappening = NO; 937 937 938 _treatAsContentEditableUntilNextEditorStateUpdate = NO; 939 938 940 if (_interactionViewsContainerView) { 939 941 [self.layer removeObserver:self forKeyPath:@"transform"]; … … 4302 4304 _textInteractionDidChangeFocusedElement = NO; 4303 4305 _textInteractionIsHappening = NO; 4306 _treatAsContentEditableUntilNextEditorStateUpdate = NO; 4304 4307 _hasValidPositionInformation = NO; 4305 4308 _positionInformation = { }; … … 5338 5341 #if USE(UIKIT_KEYBOARD_ADDITIONS) 5339 5342 auto* keyboard = [UIKeyboardImpl sharedInstance]; 5340 if ( _page->editorState().isContentEditable&& [keyboard respondsToSelector:@selector(handleKeyInputMethodCommandForCurrentEvent)] && [keyboard handleKeyInputMethodCommandForCurrentEvent]) {5343 if ((_page->editorState().isContentEditable || _treatAsContentEditableUntilNextEditorStateUpdate) && [keyboard respondsToSelector:@selector(handleKeyInputMethodCommandForCurrentEvent)] && [keyboard handleKeyInputMethodCommandForCurrentEvent]) { 5341 5344 completionHandler(theEvent, YES); 5342 5345 _page->handleKeyboardEvent(WebKit::NativeWebKeyboardEvent(theEvent, HandledByInputMethod::Yes)); … … 5979 5982 [self becomeFirstResponder]; 5980 5983 5984 if (!_suppressSelectionAssistantReasons && isSelectable && activityStateChanges.contains(WebCore::ActivityState::IsFocused)) { 5985 _treatAsContentEditableUntilNextEditorStateUpdate = YES; 5986 [_textInteractionAssistant activateSelection]; 5987 _page->restoreSelectionInFocusedEditableElement(); 5988 _page->scheduleFullEditorStateUpdate(); 5989 } 5990 5981 5991 _inputPeripheral = createInputPeripheralWithView(_focusedElementInformation.elementType, self); 5982 5992 … … 6185 6195 if (mayContainSelectableText(_focusedElementInformation.elementType)) 6186 6196 [self _zoomToRevealFocusedElement]; 6197 6198 _treatAsContentEditableUntilNextEditorStateUpdate = NO; 6187 6199 } 6188 6200
Note:
See TracChangeset
for help on using the changeset viewer.