WebKit Bugzilla
Attachment 373473 Details for
Bug 199490
: Touching media controls sometimes shows software keyboard
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-199490-20190704154154.patch (text/plain), 19.19 KB, created by
Wenson Hsieh
on 2019-07-04 15:41:55 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Wenson Hsieh
Created:
2019-07-04 15:41:55 PDT
Size:
19.19 KB
patch
obsolete
>Subversion Revision: 247030 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index f94edefc73d575a1c74dfb33b170d71b0a2db971..a73c07f8fd59e67c445bf3a2a44c52b53c93f90d 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,39 @@ >+2019-07-04 Wenson Hsieh <wenson_hsieh@apple.com> >+ >+ Touching media controls sometimes shows software keyboard >+ https://bugs.webkit.org/show_bug.cgi?id=199490 >+ <rdar://problem/52076270> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ In r243044, we added a compatibility hack for Google Slides (and other G-suite properties) to allow the on- >+ screen keyboard to show up after a prevented touch event in the case where an element was already focused, even >+ if the touch event handler doesn't explicitly refocus the element. However, this means that if a regular text >+ field (or other form control) has been programmatically focused, then interacting with any other element that >+ prevents default on touchstart will cause us to show the keyboard for that focused element. >+ >+ To mitigate this, only fall down this refocusing codepath in the case where the focused element is a hidden >+ editable element (in the style of many Google productivity web apps). For non-hidden editable elements that are >+ already focused, this refocusing logic is not necessary, since the user should be able to interact with the >+ control to show the keyboard anyways; for hidden editable areas, this compatibility hack is actually needed, >+ since there is typically no other way for a user to focus these elements and show an on-screen keyboard. >+ >+ Tests: fast/events/touch/ios/show-keyboard-after-preventing-touchstart.html >+ fast/events/touch/ios/do-not-show-keyboard-after-preventing-touchstart.html >+ >+ * WebProcess/WebPage/WebPage.cpp: >+ (WebKit::WebPage::dispatchTouchEvent): >+ * WebProcess/WebPage/WebPage.h: >+ * WebProcess/WebPage/ios/WebPageIOS.mm: >+ (WebKit::WebPage::isTransparentOrFullyClipped const): >+ >+ Renamed from enclosingLayerIsTransparentOrFullyClipped, and pulled out into a private helper method. >+ >+ (WebKit::WebPage::platformEditorState const): >+ (WebKit::WebPage::requestEvasionRectsAboveSelection): >+ (WebKit::WebPage::getFocusedElementInformation): >+ (WebKit::enclosingLayerIsTransparentOrFullyClipped): Deleted. >+ > 2019-07-03 Wenson Hsieh <wenson_hsieh@apple.com> > > Click events on outer page are not being dispatched correctly after touch-zooming within an iframe >diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.cpp b/Source/WebKit/WebProcess/WebPage/WebPage.cpp >index 3a73eb827b93d48b544bc8644a319b9793f5e0a1..a5c6f4abbc01495027457bcfadf147a74a72ddbb 100644 >--- a/Source/WebKit/WebProcess/WebPage/WebPage.cpp >+++ b/Source/WebKit/WebProcess/WebPage/WebPage.cpp >@@ -2896,7 +2896,7 @@ void WebPage::dispatchTouchEvent(const WebTouchEvent& touchEvent, bool& handled) > if (handled && oldFocusedElement) { > auto newFocusedFrame = makeRefPtr(m_page->focusController().focusedFrame()); > auto newFocusedElement = makeRefPtr(newFocusedFrame ? newFocusedFrame->document()->focusedElement() : nullptr); >- if (oldFocusedElement == newFocusedElement) >+ if (oldFocusedElement == newFocusedElement && isTransparentOrFullyClipped(*newFocusedElement)) > elementDidRefocus(*newFocusedElement); > } > } >diff --git a/Source/WebKit/WebProcess/WebPage/WebPage.h b/Source/WebKit/WebProcess/WebPage/WebPage.h >index 7485534e27be0ca9bcf552449de4b018387f19e1..4e0ce4a47927d6176f5ba9aaa55e8ad2f443b2ad 100644 >--- a/Source/WebKit/WebProcess/WebPage/WebPage.h >+++ b/Source/WebKit/WebProcess/WebPage/WebPage.h >@@ -1449,6 +1449,7 @@ private: > > #if PLATFORM(IOS_FAMILY) > void didChooseFilesForOpenPanelWithDisplayStringAndIcon(const Vector<String>&, const String& displayString, const IPC::DataReference& iconData); >+ bool isTransparentOrFullyClipped(const WebCore::Element&) const; > #endif > > #if ENABLE(SANDBOX_EXTENSIONS) >diff --git a/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm b/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm >index a5ab1b6b6123a0fd5469a93073ab074001224968..b3b5f8597e01c454deb7b79ef5d49e3d013991dd 100644 >--- a/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm >+++ b/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm >@@ -184,9 +184,13 @@ static void computeEditableRootHasContentAndPlainText(const VisibleSelection& se > data.hasPlainText = data.hasContent && hasAnyPlainText(Range::create(root->document(), VisiblePosition { startInEditableRoot }, VisiblePosition { lastPositionInNode(root) })); > } > >-static bool enclosingLayerIsTransparentOrFullyClipped(const RenderObject& renderer) >+bool WebPage::isTransparentOrFullyClipped(const Element& element) const > { >- auto* enclosingLayer = renderer.enclosingLayer(); >+ auto* renderer = element.renderer(); >+ if (!renderer) >+ return false; >+ >+ auto* enclosingLayer = renderer->enclosingLayer(); > return enclosingLayer && enclosingLayer->isTransparentOrFullyClippedRespectingParentFrames(); > } > >@@ -263,9 +267,8 @@ void WebPage::platformEditorState(Frame& frame, EditorState& result, IncludePost > postLayoutData.caretColor = renderer.style().caretColor(); > } > if (result.isContentEditable) { >- auto container = makeRefPtr(selection.rootEditableElement()); >- if (container && container->renderer()) >- postLayoutData.editableRootIsTransparentOrFullyClipped = enclosingLayerIsTransparentOrFullyClipped(*container->renderer()); >+ if (auto container = makeRefPtr(selection.rootEditableElement())) >+ postLayoutData.editableRootIsTransparentOrFullyClipped = isTransparentOrFullyClipped(*container); > } > computeEditableRootHasContentAndPlainText(selection, postLayoutData); > } >@@ -1795,7 +1798,7 @@ void WebPage::requestEvasionRectsAboveSelection(CompletionHandler<void(const Vec > return; > } > >- if (!m_focusedElement || !m_focusedElement->renderer() || enclosingLayerIsTransparentOrFullyClipped(*m_focusedElement->renderer())) { >+ if (!m_focusedElement || !m_focusedElement->renderer() || isTransparentOrFullyClipped(*m_focusedElement)) { > reply({ }); > return; > } >@@ -2983,7 +2986,7 @@ void WebPage::getFocusedElementInformation(FocusedElementInformation& informatio > information.isReadOnly = false; > } > >- if (m_focusedElement->document().quirks().shouldSuppressAutocorrectionAndAutocaptializationInHiddenEditableAreas() && m_focusedElement->renderer() && enclosingLayerIsTransparentOrFullyClipped(*m_focusedElement->renderer())) { >+ if (m_focusedElement->document().quirks().shouldSuppressAutocorrectionAndAutocaptializationInHiddenEditableAreas() && isTransparentOrFullyClipped(*m_focusedElement)) { > information.autocapitalizeType = AutocapitalizeTypeNone; > information.isAutocorrect = false; > } >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 54929459bab8d23208efb4666e627e62f2e0de08..4684ae556f3184380b7dc10947ad44ae8169952f 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,23 @@ >+2019-07-04 Wenson Hsieh <wenson_hsieh@apple.com> >+ >+ Touching media controls sometimes shows software keyboard >+ https://bugs.webkit.org/show_bug.cgi?id=199490 >+ <rdar://problem/52076270> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Adds plumbing for a new testing hook to check whether or not there is an active input session. See other >+ ChangeLog entries for more detail. >+ >+ * DumpRenderTree/ios/UIScriptControllerIOS.mm: >+ (WTR::UIScriptController::hasInputSession const): >+ * TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl: >+ * TestRunnerShared/UIScriptContext/UIScriptController.cpp: >+ (WTR::UIScriptController::hasInputSession const): >+ * TestRunnerShared/UIScriptContext/UIScriptController.h: >+ * WebKitTestRunner/ios/UIScriptControllerIOS.mm: >+ (WTR::UIScriptController::hasInputSession const): >+ > 2019-07-01 Alex Christensen <achristensen@webkit.org> > > Add new decidePolicyForNavigationAction SPI with preferences and userInfo >diff --git a/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm b/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm >index ba1f3eda73ee9cc3f392540464db22b0a9b7117a..d7ea4665e384b57a57f286ddea4f23b104842d28 100644 >--- a/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm >+++ b/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm >@@ -287,6 +287,11 @@ bool UIScriptController::isShowingKeyboard() const > return false; > } > >+bool UIScriptController::hasInputSession() const >+{ >+ return false; >+} >+ > double UIScriptController::minimumZoomScale() const > { > return gWebScrollView.minimumZoomScale; >diff --git a/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl b/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl >index 3b69cde12753d41303c61529cf76b8402cfab41f..9e868cec269b8a91389e36146fd4d0a05488464d 100644 >--- a/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl >+++ b/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl >@@ -224,6 +224,7 @@ interface UIScriptController { > attribute object didShowKeyboardCallback; > attribute object didHideKeyboardCallback; > readonly attribute boolean isShowingKeyboard; >+ readonly attribute boolean hasInputSession; > > attribute object didShowMenuCallback; > attribute object didHideMenuCallback; >diff --git a/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp b/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp >index 1bedd7eb16f7459616199885a4fd210a3eeb76d5..0f8db133add3b1bc616bee958a05e5e7ef004d31 100644 >--- a/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp >+++ b/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp >@@ -453,6 +453,11 @@ bool UIScriptController::isShowingKeyboard() const > return false; > } > >+bool UIScriptController::hasInputSession() const >+{ >+ return false; >+} >+ > double UIScriptController::zoomScale() const > { > return 1; >diff --git a/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h b/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h >index 0bedc04a12ec4ac3c2340b407d77e0b0ecedb8a7..18e18ab9c980199d0c8070b3072bf850b1eb3619 100644 >--- a/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h >+++ b/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h >@@ -163,6 +163,7 @@ public: > JSValueRef didHideKeyboardCallback() const; > > bool isShowingKeyboard() const; >+ bool hasInputSession() const; > > void setDidHideMenuCallback(JSValueRef); > JSValueRef didHideMenuCallback() const; >diff --git a/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm b/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm >index 9933150503f489d567811a35132c5ed5c5a477c9..955f65461dc32100aaeecca6b066fed710e57a92 100644 >--- a/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm >+++ b/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm >@@ -625,6 +625,11 @@ bool UIScriptController::isShowingKeyboard() const > return TestController::singleton().mainWebView()->platformView().showingKeyboard; > } > >+bool UIScriptController::hasInputSession() const >+{ >+ return TestController::singleton().mainWebView()->platformView().isInteractingWithFormControl; >+} >+ > void UIScriptController::applyAutocorrection(JSStringRef newString, JSStringRef oldString, JSValueRef callback) > { > unsigned callbackID = m_context->prepareForAsyncTask(callback, CallbackTypeNonPersistent); >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 266b35916c6ede73a00c57fb744b5c918fb98cd0..c3b3378335ba7b86b6cad0a6e4f548278b10fa76 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,29 @@ >+2019-07-04 Wenson Hsieh <wenson_hsieh@apple.com> >+ >+ Touching media controls sometimes shows software keyboard >+ https://bugs.webkit.org/show_bug.cgi?id=199490 >+ <rdar://problem/52076270> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Adds a new layout test to verify that the keyboard only appears after a handled touch event if the focused >+ element is inside a hidden editable area; otherwise, the keyboard should not be present. >+ >+ * fast/events/touch/ios/do-not-show-keyboard-after-preventing-touchstart-expected.txt: Added. >+ * fast/events/touch/ios/do-not-show-keyboard-after-preventing-touchstart.html: Added. >+ >+ This test passes as long as we didn't begin showing the keyboard after tapping. >+ >+ * fast/events/touch/ios/show-keyboard-after-preventing-touchstart-expected.txt: >+ * fast/events/touch/ios/show-keyboard-after-preventing-touchstart.html: >+ >+ Adjust this existing test to make the focused textarea hidden. >+ >+ * resources/ui-helper.js: >+ (window.UIHelper.hasInputSession): >+ >+ Add a new testing hook to check whether there is an active input session. >+ > 2019-07-03 Wenson Hsieh <wenson_hsieh@apple.com> > > Click events on outer page are not being dispatched correctly after touch-zooming within an iframe >diff --git a/LayoutTests/fast/events/touch/ios/do-not-show-keyboard-after-preventing-touchstart-expected.txt b/LayoutTests/fast/events/touch/ios/do-not-show-keyboard-after-preventing-touchstart-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..8dc7ff71718e97d0c3e1867c181239cac2f45f1d >--- /dev/null >+++ b/LayoutTests/fast/events/touch/ios/do-not-show-keyboard-after-preventing-touchstart-expected.txt >@@ -0,0 +1,11 @@ >+ >+Verifies that the keyboard does not show up even after preventing default on touchstart when a regular input field is focused. To manually test, tap the red box; the keyboard should not appear. >+ >+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". >+ >+PASS hasInputSession is false >+PASS document.activeElement is textarea >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+ >diff --git a/LayoutTests/fast/events/touch/ios/do-not-show-keyboard-after-preventing-touchstart.html b/LayoutTests/fast/events/touch/ios/do-not-show-keyboard-after-preventing-touchstart.html >new file mode 100644 >index 0000000000000000000000000000000000000000..9225fb369455bb9957d3a64ce66059ad1b424265 >--- /dev/null >+++ b/LayoutTests/fast/events/touch/ios/do-not-show-keyboard-after-preventing-touchstart.html >@@ -0,0 +1,48 @@ >+<!DOCTYPE html> >+<html> >+<head> >+<script src="../../../../resources/js-test.js"></script> >+<script src="../../../../resources/ui-helper.js"></script> >+<style> >+html, body { >+ width: 100%; >+ height: 100%; >+ margin: 0; >+} >+ >+textarea, #target { >+ width: 100%; >+ height: 100px; >+} >+ >+#target { >+ background-color: tomato; >+ opacity: 0.25; >+} >+</style> >+</head> >+<body> >+ <textarea></textarea> >+ <div id="target"></div> >+ <pre id="description"></pre> >+ <pre id="console"></pre> >+</body> >+<script> >+ jsTestIsAsync = true; >+ textarea = document.querySelector("textarea"); >+ target = document.getElementById("target"); >+ target.addEventListener("touchstart", event => event.preventDefault()); >+ >+ description("Verifies that the keyboard does not show up even after preventing default on touchstart when a regular input field is focused. To manually test, tap the red box; the keyboard should not appear."); >+ >+ addEventListener("load", async () => { >+ textarea.focus(); >+ await UIHelper.activateElement(target); >+ await UIHelper.ensurePresentationUpdate(); >+ hasInputSession = await UIHelper.hasInputSession(); >+ shouldBe("hasInputSession", "false"); >+ shouldBe("document.activeElement", "textarea"); >+ finishJSTest(); >+ }); >+</script> >+</html> >diff --git a/LayoutTests/fast/events/touch/ios/show-keyboard-after-preventing-touchstart-expected.txt b/LayoutTests/fast/events/touch/ios/show-keyboard-after-preventing-touchstart-expected.txt >index d8c45bf6977ae71bb9401f5b7c1c1e26c79c82a1..02f793586d111aaf13357267838fcd9cbfaa9966 100644 >--- a/LayoutTests/fast/events/touch/ios/show-keyboard-after-preventing-touchstart-expected.txt >+++ b/LayoutTests/fast/events/touch/ios/show-keyboard-after-preventing-touchstart-expected.txt >@@ -1,5 +1,5 @@ > >-Verifies that the keyboard shows up even after preventing default on touchstart. To manually test, tap the textarea; the textarea should remain focused, and the keyboard should appear. >+Verifies that the keyboard shows up even after preventing default on touchstart when focusing a hidden editable area. To manually test, tap the red box; the textarea should remain focused, and the keyboard should appear. > > On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". > >diff --git a/LayoutTests/fast/events/touch/ios/show-keyboard-after-preventing-touchstart.html b/LayoutTests/fast/events/touch/ios/show-keyboard-after-preventing-touchstart.html >index b25af030e4b347ab0cab3c76254adb56b4b6cae4..48a6ad725a606893337dadae254a3e69427e4de4 100644 >--- a/LayoutTests/fast/events/touch/ios/show-keyboard-after-preventing-touchstart.html >+++ b/LayoutTests/fast/events/touch/ios/show-keyboard-after-preventing-touchstart.html >@@ -10,29 +10,45 @@ html, body { > margin: 0; > } > >-textarea { >+textarea, #target { > width: 100%; > height: 100px; >- font-size: 50px; >- text-align: center; >+ position: absolute; >+ top: 0; >+} >+ >+#target { >+ background-color: tomato; >+ z-index: 1; >+ opacity: 0.25; >+} >+ >+textarea { >+ opacity: 0; >+} >+ >+#description { >+ margin-top: 100px; > } > </style> > </head> > <body> > <textarea></textarea> >+ <div id="target"></div> > <pre id="description"></pre> > <pre id="console"></pre> > </body> > <script> > jsTestIsAsync = true; > textarea = document.querySelector("textarea"); >+ target = document.getElementById("target"); >+ target.addEventListener("touchstart", event => event.preventDefault()); > >- description("Verifies that the keyboard shows up even after preventing default on touchstart. To manually test, tap the textarea; the textarea should remain focused, and the keyboard should appear."); >+ description("Verifies that the keyboard shows up even after preventing default on touchstart when focusing a hidden editable area. To manually test, tap the red box; the textarea should remain focused, and the keyboard should appear."); > >- textarea.addEventListener("touchstart", event => event.preventDefault()); > addEventListener("load", async () => { > textarea.focus(); >- await UIHelper.activateElementAndWaitForInputSession(textarea); >+ await UIHelper.activateElementAndWaitForInputSession(target); > testPassed("keyboard was shown."); > shouldBe("document.activeElement", "textarea"); > textarea.blur(); >diff --git a/LayoutTests/resources/ui-helper.js b/LayoutTests/resources/ui-helper.js >index 9eb97d070eeb4d0cd4c4c89d1ed8650f4c55cebc..96684aab9e4835a5171283ed1568fc81bbfa13c1 100644 >--- a/LayoutTests/resources/ui-helper.js >+++ b/LayoutTests/resources/ui-helper.js >@@ -372,6 +372,13 @@ window.UIHelper = class UIHelper { > }); > } > >+ static hasInputSession() >+ { >+ return new Promise(resolve => { >+ testRunner.runUIScript("uiController.hasInputSession", result => resolve(result === "true")); >+ }); >+ } >+ > static isPresentingModally() > { > return new Promise(resolve => {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 199490
:
373450
| 373473