Title: [259840] trunk/Source/WebKit
- Revision
- 259840
- Author
- [email protected]
- Date
- 2020-04-09 16:58:49 -0700 (Thu, 09 Apr 2020)
Log Message
Popovers are dismissed immediately when they try and bring up the keyboard.
https://bugs.webkit.org/show_bug.cgi?id=210230
<rdar://problem/60385504>
Reviewed by Darin Adler.
When popovers use keyboards we dismiss them because the
web view loses firstResponder. We already have ways of
retaining focus when we lose first responde, so extend that
code to cover the case where a keyboard comes up in a popover.
We are also callling controlBeginEditing twice on refocusing a
popover due to behaviour with touch and syntheticClick, so
keep up from presenting the popover twice, and allow for the focus
count to be correclty incremented and decremented.
* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView preserveFocus]):
(-[WKContentView releaseFocus]):
* UIProcess/ios/forms/WKFormInputControl.mm:
(-[WKDateTimePopover popoverWasDismissed:]):
(-[WKDateTimePopover controlBeginEditing]):
(-[WKDateTimePopover controlEndEditing]):
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (259839 => 259840)
--- trunk/Source/WebKit/ChangeLog 2020-04-09 23:45:40 UTC (rev 259839)
+++ trunk/Source/WebKit/ChangeLog 2020-04-09 23:58:49 UTC (rev 259840)
@@ -1,3 +1,30 @@
+2020-04-09 Megan Gardner <[email protected]>
+
+ Popovers are dismissed immediately when they try and bring up the keyboard.
+ https://bugs.webkit.org/show_bug.cgi?id=210230
+ <rdar://problem/60385504>
+
+ Reviewed by Darin Adler.
+
+ When popovers use keyboards we dismiss them because the
+ web view loses firstResponder. We already have ways of
+ retaining focus when we lose first responde, so extend that
+ code to cover the case where a keyboard comes up in a popover.
+
+ We are also callling controlBeginEditing twice on refocusing a
+ popover due to behaviour with touch and syntheticClick, so
+ keep up from presenting the popover twice, and allow for the focus
+ count to be correclty incremented and decremented.
+
+ * UIProcess/ios/WKContentViewInteraction.h:
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (-[WKContentView preserveFocus]):
+ (-[WKContentView releaseFocus]):
+ * UIProcess/ios/forms/WKFormInputControl.mm:
+ (-[WKDateTimePopover popoverWasDismissed:]):
+ (-[WKDateTimePopover controlBeginEditing]):
+ (-[WKDateTimePopover controlEndEditing]):
+
2020-04-09 David Kilzer <[email protected]>
Add using WTF::isInBounds to CheckedArithmetic.h
Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h (259839 => 259840)
--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h 2020-04-09 23:45:40 UTC (rev 259839)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h 2020-04-09 23:58:49 UTC (rev 259840)
@@ -530,6 +530,9 @@
- (BOOL)hasHiddenContentEditable;
- (void)generateSyntheticEditingCommand:(WebKit::SyntheticEditingCommandType)command;
+- (void)preserveFocus;
+- (void)releaseFocus;
+
// UIWebFormAccessoryDelegate protocol
- (void)accessoryDone;
Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (259839 => 259840)
--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2020-04-09 23:45:40 UTC (rev 259839)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2020-04-09 23:58:49 UTC (rev 259840)
@@ -6658,6 +6658,16 @@
return NO;
}
+- (void)preserveFocus
+{
+ [_webView _incrementFocusPreservationCount];
+}
+
+- (void)releaseFocus
+{
+ [_webView _decrementFocusPreservationCount];
+}
+
- (void)_preserveFocusWithToken:(id <NSCopying, NSSecureCoding>)token destructively:(BOOL)destructively
{
if (!_inputPeripheral) {
Modified: trunk/Source/WebKit/UIProcess/ios/forms/WKFormInputControl.mm (259839 => 259840)
--- trunk/Source/WebKit/UIProcess/ios/forms/WKFormInputControl.mm 2020-04-09 23:45:40 UTC (rev 259839)
+++ trunk/Source/WebKit/UIProcess/ios/forms/WKFormInputControl.mm 2020-04-09 23:58:49 UTC (rev 259840)
@@ -50,6 +50,8 @@
@interface WKDateTimePopover : WKFormRotatingAccessoryPopover<WKFormControl> {
RetainPtr<WKDateTimePopoverViewController> _viewController;
WKContentView *_view;
+ BOOL _presenting;
+ BOOL _preservingFocus;
}
- (id)initWithView:(WKContentView *)view datePickerMode:(UIDatePickerMode)mode;
- (WKDateTimePopoverViewController *)viewController;
@@ -334,6 +336,18 @@
[_view page]->setFocusedElementValue(String());
}
+- (void)popoverWasDismissed:(WKRotatingPopover *)popover
+{
+ [super popoverWasDismissed:popover];
+
+ if (popover == self) {
+ if (_preservingFocus) {
+ [_view releaseFocus];
+ _preservingFocus = NO;
+ }
+ }
+}
+
- (id)initWithView:(WKContentView *)view datePickerMode:(UIDatePickerMode)mode
{
if (!(self = [super initWithView:view]))
@@ -377,12 +391,21 @@
- (void)controlBeginEditing
{
- [self presentPopoverAnimated:NO];
- [_viewController.get().innerControl controlBeginEditing];
+ if (!_presenting) {
+ _presenting = YES;
+ [self presentPopoverAnimated:NO];
+ [_viewController.get().innerControl controlBeginEditing];
+
+ if (_view.focusedElementInformation.elementType == InputType::Time || _view.focusedElementInformation.elementType == InputType::DateTimeLocal) {
+ _preservingFocus = YES;
+ [_view preserveFocus];
+ }
+ }
}
- (void)controlEndEditing
{
+ _presenting = NO;
[self dismissPopoverAnimated:NO];
[_viewController.get().innerControl controlEndEditing];
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes