haikuwebkit/Tools/WebKitTestRunner/UIScriptControllerCommon.cpp

45 lines
1.7 KiB
C++
Raw Permalink Normal View History

[iPadOS] Unable to change focus between Google Docs windows by tapping https://bugs.webkit.org/show_bug.cgi?id=213985 <rdar://problem/57083267> Reviewed by Darin Adler. Source/WebKit: When putting two Google Docs windows side-by-side on iPad, it's currently not possible to change the window to which keyboard input is routed. In native views (e.g. two side-by-side Notes windows), this is normally handled by `UITextMultiTapRecognizer`, which is part of the `UITextSelectionInteraction`; tapping to place the text selection calls into `-[UITextInteractionAssistant setFirstResponderIfNecessaryActivatingSelection:]`, which updates the key window if needed. This doesn't apply to Google Docs because they instead use touch events to drive their own "text interaction"-like behaviors instead of relying on system gesture recognizers, which we suppress due to the fact that the selection is within a hidden contenteditable. But even in non-hidden editable areas, the initial tap to focus an editable element still doesn't automatically make the window key, since the editable text interaction gestures are still inactive when tapping to focus an editable element. This means two taps are currently required to change the key window when focusing two Safari windows side-by-side: the first tap to focus the element (via the synthetic click gesture), and the second tap to trigger the editable text interaction tap gesture that is used to set the selection. To fix both of these issues, make some minor adjustments to call `-makeKeyWindow` from WebKit when focusing editable elements. See below for more details. Test: editing/selection/ios/become-key-window-when-focusing-editable-area.html * UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView _webTouchEventsRecognized:]): For the case in Google Docs where a hidden editable element is used and tapping in the page does not result in the element being refocused, we additionally need to make sure that we make our window key anyways. Limit this hack to tap gestures, and only when there is a hidden focused editable element to emulate platform behavior of updating the key window based on the text tap gesture. (-[WKContentView _elementDidFocus:userIsInteracting:blurPreviousNode:activityStateChanges:userObject:]): Make the content view's window key when focusing an editable element. (-[WKContentView hasHiddenContentEditable]): Consider the selection to be inside a hidden editable area if the `WebKit::FocusedElementIsTooSmall` flag is set as well. While this doesn't affect Google Docs, it does affect some other custom editors, such as Quip. (-[WKContentView mouseGestureRecognizerChanged:]): Additionally make the current window key when clicking in a hidden editable area with a trackpad on iOS. Tools: Add WebKitTestRunner support for being able to verify that a web view's window has become the key window. * DumpRenderTree/CMakeLists.txt: * DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj: * DumpRenderTree/UIScriptController.cpp: Added. (WTR::UIScriptController::setWindowIsKey): (WTR::UIScriptController::windowIsKey const): * TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl: * TestRunnerShared/UIScriptContext/UIScriptController.h: * TestRunnerShared/UIScriptContext/UIScriptControllerShared.cpp: Renamed from Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp. Rename `UIScriptController.cpp` (in TestRunnerShared) to `UIScriptControllerShared.cpp`, and introduce new DumpRenderTree and WebKitTestRunner versions of `UIScriptController.cpp` to house DumpRenderTree and WebKitTestRunner-specific UIScriptController method implementations. For now, these are just `windowIsKey` and `setWindowIsKey` below, which plumb into their respective platform- agnostic `PlatformWebView` methods in WebKitTestRunner. * WebKitTestRunner/UIScriptController.cpp: Added. (WTR::UIScriptController::windowIsKey const): (WTR::UIScriptController::setWindowIsKey): * WebKitTestRunner/CMakeLists.txt: * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj: * WebKitTestRunner/ios/PlatformWebViewIOS.mm: (-[WebKitTestRunnerWindow becomeKeyWindow]): (-[WebKitTestRunnerWindow resignKeyWindow]): Update these two methods to update `m_windowIsKey` when the test runner's `UIWindow` becomes the key window (or stops being the key window). This is invoked when `-[UIWindow makeKeyWindow]` is called (e.g. from within WebKit code when tapping on an editable element). (WTR::PlatformWebView::setWindowIsKey): Avoid infinitely looping when setting windowIsKey to `true`, due to `-becomeKeyWindow` calling back into `setWindowIsKey`. LayoutTests: Add a new layout test to verify that tapping to focus a plain textarea causes the web view's window to become the key window, as well as tapping to focus a hidden contenteditable area, over a touch handler that prevents default. * editing/selection/ios/become-key-window-when-focusing-editable-area-expected.txt: Added. * editing/selection/ios/become-key-window-when-focusing-editable-area.html: Added. * resources/ui-helper.js: (window.UIHelper.setWindowIsKey): (window.UIHelper.windowIsKey): Canonical link: https://commits.webkit.org/226799@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@263979 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-07-06 19:45:54 +00:00
/*
* Copyright (C) 2020 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
[TestRunnerShared] Add a new class UIScriptControllerCommon to implement UIScriptController::windowIsKey and UIScriptController::setWindowIsKey https://bugs.webkit.org/show_bug.cgi?id=216469 Reviewed by Darin Adler. Even though UIScriptController class is defined in TestRunnerShared, UIScriptController::windowIsKey and UIScriptController::setWindowIsKey methods were defined in the client modules DRT and WTR. I'd like to make TestRunnerShared a stand-alone library which doesn't depend on DRT and WTR (Bug 216465). Add a new class UIScriptControllerCommon to host the common methods by renaming UIScriptController.cpp. * DumpRenderTree/CMakeLists.txt: * TestRunnerShared/UIScriptContext/UIScriptController.h: (WTR::UIScriptController::windowIsKey const): (WTR::UIScriptController::setWindowIsKey): * WebKitTestRunner/CMakeLists.txt: * WebKitTestRunner/UIScriptControllerCommon.cpp: Renamed from Tools/WebKitTestRunner/UIScriptController.cpp. (WTR::UIScriptControllerCommon::windowIsKey const): (WTR::UIScriptControllerCommon::setWindowIsKey): * WebKitTestRunner/UIScriptControllerCommon.h: Added. (WTR::UIScriptControllerCommon::UIScriptControllerCommon): * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj: * WebKitTestRunner/cocoa/UIScriptControllerCocoa.h: * WebKitTestRunner/cocoa/UIScriptControllerCocoa.mm: (WTR::UIScriptControllerCocoa::UIScriptControllerCocoa): * WebKitTestRunner/gtk/UIScriptControllerGtk.h: (WTR::UIScriptControllerGtk::UIScriptControllerGtk): * WebKitTestRunner/win/UIScriptControllerWin.h: (WTR::UIScriptControllerWin::UIScriptControllerWin): * WebKitTestRunner/wpe/UIScriptControllerWPE.h: Canonical link: https://commits.webkit.org/229396@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267120 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-16 00:22:48 +00:00
#include "UIScriptControllerCommon.h"
[iPadOS] Unable to change focus between Google Docs windows by tapping https://bugs.webkit.org/show_bug.cgi?id=213985 <rdar://problem/57083267> Reviewed by Darin Adler. Source/WebKit: When putting two Google Docs windows side-by-side on iPad, it's currently not possible to change the window to which keyboard input is routed. In native views (e.g. two side-by-side Notes windows), this is normally handled by `UITextMultiTapRecognizer`, which is part of the `UITextSelectionInteraction`; tapping to place the text selection calls into `-[UITextInteractionAssistant setFirstResponderIfNecessaryActivatingSelection:]`, which updates the key window if needed. This doesn't apply to Google Docs because they instead use touch events to drive their own "text interaction"-like behaviors instead of relying on system gesture recognizers, which we suppress due to the fact that the selection is within a hidden contenteditable. But even in non-hidden editable areas, the initial tap to focus an editable element still doesn't automatically make the window key, since the editable text interaction gestures are still inactive when tapping to focus an editable element. This means two taps are currently required to change the key window when focusing two Safari windows side-by-side: the first tap to focus the element (via the synthetic click gesture), and the second tap to trigger the editable text interaction tap gesture that is used to set the selection. To fix both of these issues, make some minor adjustments to call `-makeKeyWindow` from WebKit when focusing editable elements. See below for more details. Test: editing/selection/ios/become-key-window-when-focusing-editable-area.html * UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView _webTouchEventsRecognized:]): For the case in Google Docs where a hidden editable element is used and tapping in the page does not result in the element being refocused, we additionally need to make sure that we make our window key anyways. Limit this hack to tap gestures, and only when there is a hidden focused editable element to emulate platform behavior of updating the key window based on the text tap gesture. (-[WKContentView _elementDidFocus:userIsInteracting:blurPreviousNode:activityStateChanges:userObject:]): Make the content view's window key when focusing an editable element. (-[WKContentView hasHiddenContentEditable]): Consider the selection to be inside a hidden editable area if the `WebKit::FocusedElementIsTooSmall` flag is set as well. While this doesn't affect Google Docs, it does affect some other custom editors, such as Quip. (-[WKContentView mouseGestureRecognizerChanged:]): Additionally make the current window key when clicking in a hidden editable area with a trackpad on iOS. Tools: Add WebKitTestRunner support for being able to verify that a web view's window has become the key window. * DumpRenderTree/CMakeLists.txt: * DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj: * DumpRenderTree/UIScriptController.cpp: Added. (WTR::UIScriptController::setWindowIsKey): (WTR::UIScriptController::windowIsKey const): * TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl: * TestRunnerShared/UIScriptContext/UIScriptController.h: * TestRunnerShared/UIScriptContext/UIScriptControllerShared.cpp: Renamed from Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp. Rename `UIScriptController.cpp` (in TestRunnerShared) to `UIScriptControllerShared.cpp`, and introduce new DumpRenderTree and WebKitTestRunner versions of `UIScriptController.cpp` to house DumpRenderTree and WebKitTestRunner-specific UIScriptController method implementations. For now, these are just `windowIsKey` and `setWindowIsKey` below, which plumb into their respective platform- agnostic `PlatformWebView` methods in WebKitTestRunner. * WebKitTestRunner/UIScriptController.cpp: Added. (WTR::UIScriptController::windowIsKey const): (WTR::UIScriptController::setWindowIsKey): * WebKitTestRunner/CMakeLists.txt: * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj: * WebKitTestRunner/ios/PlatformWebViewIOS.mm: (-[WebKitTestRunnerWindow becomeKeyWindow]): (-[WebKitTestRunnerWindow resignKeyWindow]): Update these two methods to update `m_windowIsKey` when the test runner's `UIWindow` becomes the key window (or stops being the key window). This is invoked when `-[UIWindow makeKeyWindow]` is called (e.g. from within WebKit code when tapping on an editable element). (WTR::PlatformWebView::setWindowIsKey): Avoid infinitely looping when setting windowIsKey to `true`, due to `-becomeKeyWindow` calling back into `setWindowIsKey`. LayoutTests: Add a new layout test to verify that tapping to focus a plain textarea causes the web view's window to become the key window, as well as tapping to focus a hidden contenteditable area, over a touch handler that prevents default. * editing/selection/ios/become-key-window-when-focusing-editable-area-expected.txt: Added. * editing/selection/ios/become-key-window-when-focusing-editable-area.html: Added. * resources/ui-helper.js: (window.UIHelper.setWindowIsKey): (window.UIHelper.windowIsKey): Canonical link: https://commits.webkit.org/226799@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@263979 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-07-06 19:45:54 +00:00
#include "PlatformWebView.h"
#include "TestController.h"
namespace WTR {
[TestRunnerShared] Add a new class UIScriptControllerCommon to implement UIScriptController::windowIsKey and UIScriptController::setWindowIsKey https://bugs.webkit.org/show_bug.cgi?id=216469 Reviewed by Darin Adler. Even though UIScriptController class is defined in TestRunnerShared, UIScriptController::windowIsKey and UIScriptController::setWindowIsKey methods were defined in the client modules DRT and WTR. I'd like to make TestRunnerShared a stand-alone library which doesn't depend on DRT and WTR (Bug 216465). Add a new class UIScriptControllerCommon to host the common methods by renaming UIScriptController.cpp. * DumpRenderTree/CMakeLists.txt: * TestRunnerShared/UIScriptContext/UIScriptController.h: (WTR::UIScriptController::windowIsKey const): (WTR::UIScriptController::setWindowIsKey): * WebKitTestRunner/CMakeLists.txt: * WebKitTestRunner/UIScriptControllerCommon.cpp: Renamed from Tools/WebKitTestRunner/UIScriptController.cpp. (WTR::UIScriptControllerCommon::windowIsKey const): (WTR::UIScriptControllerCommon::setWindowIsKey): * WebKitTestRunner/UIScriptControllerCommon.h: Added. (WTR::UIScriptControllerCommon::UIScriptControllerCommon): * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj: * WebKitTestRunner/cocoa/UIScriptControllerCocoa.h: * WebKitTestRunner/cocoa/UIScriptControllerCocoa.mm: (WTR::UIScriptControllerCocoa::UIScriptControllerCocoa): * WebKitTestRunner/gtk/UIScriptControllerGtk.h: (WTR::UIScriptControllerGtk::UIScriptControllerGtk): * WebKitTestRunner/win/UIScriptControllerWin.h: (WTR::UIScriptControllerWin::UIScriptControllerWin): * WebKitTestRunner/wpe/UIScriptControllerWPE.h: Canonical link: https://commits.webkit.org/229396@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267120 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-16 00:22:48 +00:00
bool UIScriptControllerCommon::windowIsKey() const
[iPadOS] Unable to change focus between Google Docs windows by tapping https://bugs.webkit.org/show_bug.cgi?id=213985 <rdar://problem/57083267> Reviewed by Darin Adler. Source/WebKit: When putting two Google Docs windows side-by-side on iPad, it's currently not possible to change the window to which keyboard input is routed. In native views (e.g. two side-by-side Notes windows), this is normally handled by `UITextMultiTapRecognizer`, which is part of the `UITextSelectionInteraction`; tapping to place the text selection calls into `-[UITextInteractionAssistant setFirstResponderIfNecessaryActivatingSelection:]`, which updates the key window if needed. This doesn't apply to Google Docs because they instead use touch events to drive their own "text interaction"-like behaviors instead of relying on system gesture recognizers, which we suppress due to the fact that the selection is within a hidden contenteditable. But even in non-hidden editable areas, the initial tap to focus an editable element still doesn't automatically make the window key, since the editable text interaction gestures are still inactive when tapping to focus an editable element. This means two taps are currently required to change the key window when focusing two Safari windows side-by-side: the first tap to focus the element (via the synthetic click gesture), and the second tap to trigger the editable text interaction tap gesture that is used to set the selection. To fix both of these issues, make some minor adjustments to call `-makeKeyWindow` from WebKit when focusing editable elements. See below for more details. Test: editing/selection/ios/become-key-window-when-focusing-editable-area.html * UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView _webTouchEventsRecognized:]): For the case in Google Docs where a hidden editable element is used and tapping in the page does not result in the element being refocused, we additionally need to make sure that we make our window key anyways. Limit this hack to tap gestures, and only when there is a hidden focused editable element to emulate platform behavior of updating the key window based on the text tap gesture. (-[WKContentView _elementDidFocus:userIsInteracting:blurPreviousNode:activityStateChanges:userObject:]): Make the content view's window key when focusing an editable element. (-[WKContentView hasHiddenContentEditable]): Consider the selection to be inside a hidden editable area if the `WebKit::FocusedElementIsTooSmall` flag is set as well. While this doesn't affect Google Docs, it does affect some other custom editors, such as Quip. (-[WKContentView mouseGestureRecognizerChanged:]): Additionally make the current window key when clicking in a hidden editable area with a trackpad on iOS. Tools: Add WebKitTestRunner support for being able to verify that a web view's window has become the key window. * DumpRenderTree/CMakeLists.txt: * DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj: * DumpRenderTree/UIScriptController.cpp: Added. (WTR::UIScriptController::setWindowIsKey): (WTR::UIScriptController::windowIsKey const): * TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl: * TestRunnerShared/UIScriptContext/UIScriptController.h: * TestRunnerShared/UIScriptContext/UIScriptControllerShared.cpp: Renamed from Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp. Rename `UIScriptController.cpp` (in TestRunnerShared) to `UIScriptControllerShared.cpp`, and introduce new DumpRenderTree and WebKitTestRunner versions of `UIScriptController.cpp` to house DumpRenderTree and WebKitTestRunner-specific UIScriptController method implementations. For now, these are just `windowIsKey` and `setWindowIsKey` below, which plumb into their respective platform- agnostic `PlatformWebView` methods in WebKitTestRunner. * WebKitTestRunner/UIScriptController.cpp: Added. (WTR::UIScriptController::windowIsKey const): (WTR::UIScriptController::setWindowIsKey): * WebKitTestRunner/CMakeLists.txt: * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj: * WebKitTestRunner/ios/PlatformWebViewIOS.mm: (-[WebKitTestRunnerWindow becomeKeyWindow]): (-[WebKitTestRunnerWindow resignKeyWindow]): Update these two methods to update `m_windowIsKey` when the test runner's `UIWindow` becomes the key window (or stops being the key window). This is invoked when `-[UIWindow makeKeyWindow]` is called (e.g. from within WebKit code when tapping on an editable element). (WTR::PlatformWebView::setWindowIsKey): Avoid infinitely looping when setting windowIsKey to `true`, due to `-becomeKeyWindow` calling back into `setWindowIsKey`. LayoutTests: Add a new layout test to verify that tapping to focus a plain textarea causes the web view's window to become the key window, as well as tapping to focus a hidden contenteditable area, over a touch handler that prevents default. * editing/selection/ios/become-key-window-when-focusing-editable-area-expected.txt: Added. * editing/selection/ios/become-key-window-when-focusing-editable-area.html: Added. * resources/ui-helper.js: (window.UIHelper.setWindowIsKey): (window.UIHelper.windowIsKey): Canonical link: https://commits.webkit.org/226799@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@263979 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-07-06 19:45:54 +00:00
{
return TestController::singleton().mainWebView()->windowIsKey();
}
[TestRunnerShared] Add a new class UIScriptControllerCommon to implement UIScriptController::windowIsKey and UIScriptController::setWindowIsKey https://bugs.webkit.org/show_bug.cgi?id=216469 Reviewed by Darin Adler. Even though UIScriptController class is defined in TestRunnerShared, UIScriptController::windowIsKey and UIScriptController::setWindowIsKey methods were defined in the client modules DRT and WTR. I'd like to make TestRunnerShared a stand-alone library which doesn't depend on DRT and WTR (Bug 216465). Add a new class UIScriptControllerCommon to host the common methods by renaming UIScriptController.cpp. * DumpRenderTree/CMakeLists.txt: * TestRunnerShared/UIScriptContext/UIScriptController.h: (WTR::UIScriptController::windowIsKey const): (WTR::UIScriptController::setWindowIsKey): * WebKitTestRunner/CMakeLists.txt: * WebKitTestRunner/UIScriptControllerCommon.cpp: Renamed from Tools/WebKitTestRunner/UIScriptController.cpp. (WTR::UIScriptControllerCommon::windowIsKey const): (WTR::UIScriptControllerCommon::setWindowIsKey): * WebKitTestRunner/UIScriptControllerCommon.h: Added. (WTR::UIScriptControllerCommon::UIScriptControllerCommon): * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj: * WebKitTestRunner/cocoa/UIScriptControllerCocoa.h: * WebKitTestRunner/cocoa/UIScriptControllerCocoa.mm: (WTR::UIScriptControllerCocoa::UIScriptControllerCocoa): * WebKitTestRunner/gtk/UIScriptControllerGtk.h: (WTR::UIScriptControllerGtk::UIScriptControllerGtk): * WebKitTestRunner/win/UIScriptControllerWin.h: (WTR::UIScriptControllerWin::UIScriptControllerWin): * WebKitTestRunner/wpe/UIScriptControllerWPE.h: Canonical link: https://commits.webkit.org/229396@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267120 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-16 00:22:48 +00:00
void UIScriptControllerCommon::setWindowIsKey(bool isKey)
[iPadOS] Unable to change focus between Google Docs windows by tapping https://bugs.webkit.org/show_bug.cgi?id=213985 <rdar://problem/57083267> Reviewed by Darin Adler. Source/WebKit: When putting two Google Docs windows side-by-side on iPad, it's currently not possible to change the window to which keyboard input is routed. In native views (e.g. two side-by-side Notes windows), this is normally handled by `UITextMultiTapRecognizer`, which is part of the `UITextSelectionInteraction`; tapping to place the text selection calls into `-[UITextInteractionAssistant setFirstResponderIfNecessaryActivatingSelection:]`, which updates the key window if needed. This doesn't apply to Google Docs because they instead use touch events to drive their own "text interaction"-like behaviors instead of relying on system gesture recognizers, which we suppress due to the fact that the selection is within a hidden contenteditable. But even in non-hidden editable areas, the initial tap to focus an editable element still doesn't automatically make the window key, since the editable text interaction gestures are still inactive when tapping to focus an editable element. This means two taps are currently required to change the key window when focusing two Safari windows side-by-side: the first tap to focus the element (via the synthetic click gesture), and the second tap to trigger the editable text interaction tap gesture that is used to set the selection. To fix both of these issues, make some minor adjustments to call `-makeKeyWindow` from WebKit when focusing editable elements. See below for more details. Test: editing/selection/ios/become-key-window-when-focusing-editable-area.html * UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView _webTouchEventsRecognized:]): For the case in Google Docs where a hidden editable element is used and tapping in the page does not result in the element being refocused, we additionally need to make sure that we make our window key anyways. Limit this hack to tap gestures, and only when there is a hidden focused editable element to emulate platform behavior of updating the key window based on the text tap gesture. (-[WKContentView _elementDidFocus:userIsInteracting:blurPreviousNode:activityStateChanges:userObject:]): Make the content view's window key when focusing an editable element. (-[WKContentView hasHiddenContentEditable]): Consider the selection to be inside a hidden editable area if the `WebKit::FocusedElementIsTooSmall` flag is set as well. While this doesn't affect Google Docs, it does affect some other custom editors, such as Quip. (-[WKContentView mouseGestureRecognizerChanged:]): Additionally make the current window key when clicking in a hidden editable area with a trackpad on iOS. Tools: Add WebKitTestRunner support for being able to verify that a web view's window has become the key window. * DumpRenderTree/CMakeLists.txt: * DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj: * DumpRenderTree/UIScriptController.cpp: Added. (WTR::UIScriptController::setWindowIsKey): (WTR::UIScriptController::windowIsKey const): * TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl: * TestRunnerShared/UIScriptContext/UIScriptController.h: * TestRunnerShared/UIScriptContext/UIScriptControllerShared.cpp: Renamed from Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp. Rename `UIScriptController.cpp` (in TestRunnerShared) to `UIScriptControllerShared.cpp`, and introduce new DumpRenderTree and WebKitTestRunner versions of `UIScriptController.cpp` to house DumpRenderTree and WebKitTestRunner-specific UIScriptController method implementations. For now, these are just `windowIsKey` and `setWindowIsKey` below, which plumb into their respective platform- agnostic `PlatformWebView` methods in WebKitTestRunner. * WebKitTestRunner/UIScriptController.cpp: Added. (WTR::UIScriptController::windowIsKey const): (WTR::UIScriptController::setWindowIsKey): * WebKitTestRunner/CMakeLists.txt: * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj: * WebKitTestRunner/ios/PlatformWebViewIOS.mm: (-[WebKitTestRunnerWindow becomeKeyWindow]): (-[WebKitTestRunnerWindow resignKeyWindow]): Update these two methods to update `m_windowIsKey` when the test runner's `UIWindow` becomes the key window (or stops being the key window). This is invoked when `-[UIWindow makeKeyWindow]` is called (e.g. from within WebKit code when tapping on an editable element). (WTR::PlatformWebView::setWindowIsKey): Avoid infinitely looping when setting windowIsKey to `true`, due to `-becomeKeyWindow` calling back into `setWindowIsKey`. LayoutTests: Add a new layout test to verify that tapping to focus a plain textarea causes the web view's window to become the key window, as well as tapping to focus a hidden contenteditable area, over a touch handler that prevents default. * editing/selection/ios/become-key-window-when-focusing-editable-area-expected.txt: Added. * editing/selection/ios/become-key-window-when-focusing-editable-area.html: Added. * resources/ui-helper.js: (window.UIHelper.setWindowIsKey): (window.UIHelper.windowIsKey): Canonical link: https://commits.webkit.org/226799@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@263979 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-07-06 19:45:54 +00:00
{
TestController::singleton().mainWebView()->setWindowIsKey(isKey);
}
} // namespace WTR