Need a way for SPI clients to know when to avoid resizing to accommodate for the...
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 28 Jun 2019 20:12:45 +0000 (20:12 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 28 Jun 2019 20:12:45 +0000 (20:12 +0000)
https://bugs.webkit.org/show_bug.cgi?id=199331
<rdar://problem/52116170>

Reviewed by Tim Horton.

Source/WebCore:

Add a new quirk to avoid resizing the web view when input view bounds change.

* page/Quirks.cpp:
(WebCore::Quirks::shouldAvoidResizingWhenInputViewBoundsChange const):
* page/Quirks.h:

Source/WebKit:

Expose new SPI, such that clients may check whether to avoid resizing the web view when changing input view
bounds. In particular, resizing the web view in this case causes toolbar menus in Microsoft Word online to
dismiss immediately after opening them, due to resize events fired as a result of the input view dismissing.

* Shared/FocusedElementInformation.cpp:
(WebKit::FocusedElementInformation::encode const):
(WebKit::FocusedElementInformation::decode):
* Shared/FocusedElementInformation.h:

Add a new flag to FocusedElementInformation to indicate whether we should avoid resizing the web view when an
input view is presented.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _shouldAvoidResizingWhenInputViewBoundsChange]):
* UIProcess/API/Cocoa/WKWebViewPrivate.h:
* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _elementDidBlur]):

Reset the value of the flag.

(-[WKContentView _shouldAvoidResizingWhenInputViewBoundsChange]):
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::getFocusedElementInformation):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@246931 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/page/Quirks.cpp
Source/WebCore/page/Quirks.h
Source/WebKit/ChangeLog
Source/WebKit/Shared/FocusedElementInformation.cpp
Source/WebKit/Shared/FocusedElementInformation.h
Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h
Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

index a5f9ee5..5344bad 100644 (file)
@@ -1,3 +1,17 @@
+2019-06-28  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        Need a way for SPI clients to know when to avoid resizing to accommodate for the input view bounds
+        https://bugs.webkit.org/show_bug.cgi?id=199331
+        <rdar://problem/52116170>
+
+        Reviewed by Tim Horton.
+
+        Add a new quirk to avoid resizing the web view when input view bounds change.
+
+        * page/Quirks.cpp:
+        (WebCore::Quirks::shouldAvoidResizingWhenInputViewBoundsChange const):
+        * page/Quirks.h:
+
 2019-06-28  Konstantin Tokarev  <annulen@yandex.ru>
 
         Remove traces of ENABLE_ICONDATABASE remaining after its removal in 219733
index 6fe3b8e..f02efe2 100644 (file)
@@ -298,6 +298,15 @@ bool Quirks::shouldDispatchSimulatedMouseEventsOnTarget(EventTarget* target) con
 }
 #endif
 
+bool Quirks::shouldAvoidResizingWhenInputViewBoundsChange() const
+{
+    if (!needsQuirks())
+        return false;
+
+    auto host = m_document->topDocument().url().host();
+    return equalLettersIgnoringASCIICase(host, "live.com") || host.endsWithIgnoringASCIICase(".live.com");
+}
+
 bool Quirks::shouldDisablePointerEventsQuirk() const
 {
 #if PLATFORM(IOS_FAMILY)
index 0702dfc..05122a9 100644 (file)
@@ -60,6 +60,7 @@ public:
     WEBCORE_EXPORT bool shouldSuppressAutocorrectionAndAutocaptializationInHiddenEditableAreas() const;
     WEBCORE_EXPORT bool isTouchBarUpdateSupressedForHiddenContentEditable() const;
     WEBCORE_EXPORT bool isNeverRichlyEditableForTouchBar() const;
+    WEBCORE_EXPORT bool shouldAvoidResizingWhenInputViewBoundsChange() const;
 
     bool needsGMailOverflowScrollQuirk() const;
     bool needsYouTubeOverflowScrollQuirk() const;
index f03dec1..96fe4b6 100644 (file)
@@ -1,3 +1,36 @@
+2019-06-28  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        Need a way for SPI clients to know when to avoid resizing to accommodate for the input view bounds
+        https://bugs.webkit.org/show_bug.cgi?id=199331
+        <rdar://problem/52116170>
+
+        Reviewed by Tim Horton.
+
+        Expose new SPI, such that clients may check whether to avoid resizing the web view when changing input view
+        bounds. In particular, resizing the web view in this case causes toolbar menus in Microsoft Word online to
+        dismiss immediately after opening them, due to resize events fired as a result of the input view dismissing.
+
+        * Shared/FocusedElementInformation.cpp:
+        (WebKit::FocusedElementInformation::encode const):
+        (WebKit::FocusedElementInformation::decode):
+        * Shared/FocusedElementInformation.h:
+
+        Add a new flag to FocusedElementInformation to indicate whether we should avoid resizing the web view when an
+        input view is presented.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _shouldAvoidResizingWhenInputViewBoundsChange]):
+        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _elementDidBlur]):
+
+        Reset the value of the flag.
+
+        (-[WKContentView _shouldAvoidResizingWhenInputViewBoundsChange]):
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::getFocusedElementInformation):
+
 2019-06-28  Jer Noble  <jer.noble@apple.com>
 
         Add new -[WKWebView _closeAllMediaPresentations] SPI
index f1e5364..14821ec 100644 (file)
@@ -106,6 +106,7 @@ void FocusedElementInformation::encode(IPC::Encoder& encoder) const
 #endif
     encoder << shouldSynthesizeKeyEventsForEditing;
     encoder << isSpellCheckingEnabled;
+    encoder << shouldAvoidResizingWhenInputViewBoundsChange;
 }
 
 bool FocusedElementInformation::decode(IPC::Decoder& decoder, FocusedElementInformation& result)
@@ -230,6 +231,9 @@ bool FocusedElementInformation::decode(IPC::Decoder& decoder, FocusedElementInfo
     if (!decoder.decode(result.isSpellCheckingEnabled))
         return false;
 
+    if (!decoder.decode(result.shouldAvoidResizingWhenInputViewBoundsChange))
+        return false;
+
     return true;
 }
 #endif
index 2f665a9..46bf753 100644 (file)
@@ -138,6 +138,7 @@ struct FocusedElementInformation {
 #endif
     bool shouldSynthesizeKeyEventsForEditing { false };
     bool isSpellCheckingEnabled { true };
+    bool shouldAvoidResizingWhenInputViewBoundsChange { false };
 
     FocusedElementIdentifier focusedElementIdentifier { 0 };
 
index c11f7ef..1f0b641 100644 (file)
@@ -1425,6 +1425,11 @@ static _WKSelectionAttributes selectionAttributes(const WebKit::EditorState& edi
     return self._currentContentView.isFirstResponder;
 }
 
+- (BOOL)_shouldAvoidResizingWhenInputViewBoundsChange
+{
+    return [_contentView _shouldAvoidResizingWhenInputViewBoundsChange];
+}
+
 - (_WKDragInteractionPolicy)_dragInteractionPolicy
 {
     return _dragInteractionPolicy;
index 95be80a..dc58ac7 100644 (file)
@@ -272,6 +272,7 @@ typedef NS_OPTIONS(NSUInteger, _WKRectEdge) {
 @property (nonatomic, readonly) _WKWebViewPrintFormatter *_webViewPrintFormatter;
 
 @property (nonatomic, setter=_setDragInteractionPolicy:) _WKDragInteractionPolicy _dragInteractionPolicy WK_API_AVAILABLE(ios(11.0));
+@property (nonatomic, readonly) BOOL _shouldAvoidResizingWhenInputViewBoundsChange WK_API_AVAILABLE(ios(WK_IOS_TBA));
 
 - (void)_beginInteractiveObscuredInsetsChange;
 - (void)_endInteractiveObscuredInsetsChange;
index db52020..438e4b1 100644 (file)
@@ -525,7 +525,8 @@ FOR_EACH_PRIVATE_WKCONTENTVIEW_ACTION(DECLARE_WKCONTENTVIEW_ACTION_FOR_WEB_VIEW)
 
 - (void)_didStartProvisionalLoadForMainFrame;
 
-@property (nonatomic, readonly, getter=_shouldUseContextMenus) BOOL _shouldUseContextMenus;
+@property (nonatomic, readonly) BOOL _shouldUseContextMenus;
+@property (nonatomic, readonly) BOOL _shouldAvoidResizingWhenInputViewBoundsChange;
 
 @end
 
index f731345..580e7f6 100644 (file)
@@ -5300,6 +5300,7 @@ static RetainPtr<NSObject <WKFormPeripheral>> createInputPeripheralWithView(WebK
 
     _focusedElementInformation.elementType = WebKit::InputType::None;
     _focusedElementInformation.shouldSynthesizeKeyEventsForEditing = false;
+    _focusedElementInformation.shouldAvoidResizingWhenInputViewBoundsChange = false;
     _inputPeripheral = nil;
     _focusRequiresStrongPasswordAssistance = NO;
 
@@ -6221,6 +6222,11 @@ ALLOW_DEPRECATED_DECLARATIONS_END
     return NO;
 }
 
+- (BOOL)_shouldAvoidResizingWhenInputViewBoundsChange
+{
+    return _focusedElementInformation.shouldAvoidResizingWhenInputViewBoundsChange;
+}
+
 - (UIView *)containerViewForTargetedPreviews
 {
     return self.unscaledView ?: self;
index 91905a3..e332e9b 100644 (file)
@@ -2969,6 +2969,8 @@ void WebPage::getFocusedElementInformation(FocusedElementInformation& informatio
         information.autocapitalizeType = AutocapitalizeTypeNone;
         information.isAutocorrect = false;
     }
+
+    information.shouldAvoidResizingWhenInputViewBoundsChange = m_focusedElement->document().quirks().shouldAvoidResizingWhenInputViewBoundsChange();
 }
 
 void WebPage::autofillLoginCredentials(const String& username, const String& password)