Title: [240027] trunk
Revision
240027
Author
[email protected]
Date
2019-01-15 19:35:59 -0800 (Tue, 15 Jan 2019)

Log Message

VisualViewport API should be updated upon opening of keyboard
https://bugs.webkit.org/show_bug.cgi?id=193475

Reviewed by Simon Fraser.

Source/WebCore:

Added a function to update the visual viewport API and schedule a resize event to FrameView.

Test: fast/visual-viewport/ios/resize-event-for-keyboard.html

* page/FrameView.cpp:
(WebCore::FrameView::didUpdateViewportOverrideRects):
* page/FrameView.h:

Source/WebKit:

The bug was caused by the changes to unobscuredContentRectRespectingInputViewBounds not updating the visual viewport
unless it caused a layout to happen. Added a code to update the visual viewport in WebPage::updateVisibleContentRects.

Also fixed the bug that VisibleContentRectUpdateInfo::operator== was not checking differences in
unobscuredContentRectRespectingInputViewBounds which resulted in the visual viewport override not getting updated
while the keyboard is getting brought up.

* Shared/VisibleContentRectUpdateInfo.h:
(WebKit::operator==):
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::updateVisibleContentRects):

LayoutTests:

Added a regression test.

* fast/visual-viewport/ios/resize-event-for-keyboard-expected.txt: Added.
* fast/visual-viewport/ios/resize-event-for-keyboard.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (240026 => 240027)


--- trunk/LayoutTests/ChangeLog	2019-01-16 03:27:11 UTC (rev 240026)
+++ trunk/LayoutTests/ChangeLog	2019-01-16 03:35:59 UTC (rev 240027)
@@ -1,3 +1,15 @@
+2019-01-15  Ryosuke Niwa  <[email protected]>
+
+        VisualViewport API should be updated upon opening of keyboard
+        https://bugs.webkit.org/show_bug.cgi?id=193475
+
+        Reviewed by Simon Fraser.
+
+        Added a regression test.
+
+        * fast/visual-viewport/ios/resize-event-for-keyboard-expected.txt: Added.
+        * fast/visual-viewport/ios/resize-event-for-keyboard.html: Added.
+
 2019-01-15  Chris Dumez  <[email protected]>
 
         Unreviewed, rolling out r239993, r239995, r239997, and

Added: trunk/LayoutTests/fast/visual-viewport/ios/resize-event-for-keyboard-expected.txt (0 => 240027)


--- trunk/LayoutTests/fast/visual-viewport/ios/resize-event-for-keyboard-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/visual-viewport/ios/resize-event-for-keyboard-expected.txt	2019-01-16 03:35:59 UTC (rev 240027)
@@ -0,0 +1,19 @@
+This tests "resize" event on window.visualViewport and height getting updated upon keyboard showing up on iOS
+To manually test, tap the text field below to show the software keyboard then dismiss it.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS resizeCount is 0
+PASS resizeCount is 1
+PASS originalWidth is window.visualViewport.width
+PASS window.visualViewport.height is not originalHeight
+PASS window.visualViewport.height < originalHeight is true
+PASS resizeCount is 2
+PASS originalWidth is window.visualViewport.width
+PASS window.visualViewport.height is originalHeight
+PASS window.visualViewport.height < originalHeight is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/visual-viewport/ios/resize-event-for-keyboard.html (0 => 240027)


--- trunk/LayoutTests/fast/visual-viewport/ios/resize-event-for-keyboard.html	                        (rev 0)
+++ trunk/LayoutTests/fast/visual-viewport/ios/resize-event-for-keyboard.html	2019-01-16 03:35:59 UTC (rev 240027)
@@ -0,0 +1,67 @@
+<!DOCTYPE html><!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+<html>
+<head>
+<meta name="viewport" content="initial-scale=1, user-scalable=no">
+</head>
+<body _onload_="runTest()">
+<input type="text" _onclick_="didFocus()" placeholder="Tap here to open keyboard">
+<script src=""
+<script src=""
+<script>
+description('This tests "resize" event on window.visualViewport and height getting updated upon keyboard showing up on iOS<br>'
+    + 'To manually test, tap the text field below to show the software keyboard then dismiss it.');
+
+jsTestIsAsync = true;
+
+function didFocus() { }
+
+async function runTest() {
+    if (window.testRunner)
+        await UIHelper.ensurePresentationUpdate();
+
+    window.originalWidth = window.visualViewport.width;
+    window.originalHeight = window.visualViewport.height;
+    window.resizeCount = 0;
+    window.visualViewport.addEventListener('resize', () => {
+        resizeCount++;
+    });
+
+    shouldBe('resizeCount', '0');
+
+    const rect = document.querySelector('input').getBoundingClientRect();
+
+    if (window.testRunner) {
+        await UIHelper.activateAndWaitForInputSessionAt(rect.left + 5, rect.top + 5);
+        await UIHelper.ensurePresentationUpdate();
+    } else {
+        await new Promise((resolve) => {
+            window.didFocus = () => setTimeout(resolve, 500);
+        });
+    }
+
+    shouldBe('resizeCount', '1');
+    shouldBe('originalWidth', 'window.visualViewport.width');
+    shouldNotBe('window.visualViewport.height', 'originalHeight');
+    shouldBeTrue('window.visualViewport.height < originalHeight');
+
+    document.querySelector('input').blur();
+    if (window.testRunner) {
+        await UIHelper.waitForKeyboardToHide();
+        await UIHelper.ensurePresentationUpdate();
+    } else {
+        await new Promise((resolve) => {
+            setTimeout(resolve, 500);
+        });
+    }
+
+    shouldBe('resizeCount', '2');
+    shouldBe('originalWidth', 'window.visualViewport.width');
+    shouldBe('window.visualViewport.height', 'originalHeight');
+    shouldBeFalse('window.visualViewport.height < originalHeight');
+
+    finishJSTest();
+}
+
+</script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (240026 => 240027)


--- trunk/Source/WebCore/ChangeLog	2019-01-16 03:27:11 UTC (rev 240026)
+++ trunk/Source/WebCore/ChangeLog	2019-01-16 03:35:59 UTC (rev 240027)
@@ -1,3 +1,18 @@
+2019-01-15  Ryosuke Niwa  <[email protected]>
+
+        VisualViewport API should be updated upon opening of keyboard
+        https://bugs.webkit.org/show_bug.cgi?id=193475
+
+        Reviewed by Simon Fraser.
+
+        Added a function to update the visual viewport API and schedule a resize event to FrameView.
+
+        Test: fast/visual-viewport/ios/resize-event-for-keyboard.html
+
+        * page/FrameView.cpp:
+        (WebCore::FrameView::didUpdateViewportOverrideRects):
+        * page/FrameView.h:
+
 2019-01-15  Myles C. Maxfield  <[email protected]>
 
         Fix build after r240018

Modified: trunk/Source/WebCore/page/FrameView.cpp (240026 => 240027)


--- trunk/Source/WebCore/page/FrameView.cpp	2019-01-16 03:27:11 UTC (rev 240026)
+++ trunk/Source/WebCore/page/FrameView.cpp	2019-01-16 03:35:59 UTC (rev 240027)
@@ -2797,6 +2797,15 @@
 
 #if PLATFORM(IOS_FAMILY)
 
+void FrameView::didUpdateViewportOverrideRects()
+{
+    if (!frame().settings().visualViewportAPIEnabled())
+        return;
+
+    if (auto* window = frame().window())
+        window->visualViewport().update();
+}
+
 void FrameView::unobscuredContentSizeChanged()
 {
     updateTiledBackingAdaptiveSizing();

Modified: trunk/Source/WebCore/page/FrameView.h (240026 => 240027)


--- trunk/Source/WebCore/page/FrameView.h	2019-01-16 03:27:11 UTC (rev 240026)
+++ trunk/Source/WebCore/page/FrameView.h	2019-01-16 03:35:59 UTC (rev 240027)
@@ -590,6 +590,10 @@
     void updateTiledBackingAdaptiveSizing();
     TiledBacking::Scrollability computeScrollability() const;
 
+#if PLATFORM(IOS_FAMILY)
+    WEBCORE_EXPORT void didUpdateViewportOverrideRects();
+#endif
+
     void addPaintPendingMilestones(OptionSet<LayoutMilestone>);
     void firePaintRelatedMilestonesIfNeeded();
     void fireLayoutRelatedMilestonesIfNeeded();

Modified: trunk/Source/WebKit/ChangeLog (240026 => 240027)


--- trunk/Source/WebKit/ChangeLog	2019-01-16 03:27:11 UTC (rev 240026)
+++ trunk/Source/WebKit/ChangeLog	2019-01-16 03:35:59 UTC (rev 240027)
@@ -1,3 +1,22 @@
+2019-01-15  Ryosuke Niwa  <[email protected]>
+
+        VisualViewport API should be updated upon opening of keyboard
+        https://bugs.webkit.org/show_bug.cgi?id=193475
+
+        Reviewed by Simon Fraser.
+
+        The bug was caused by the changes to unobscuredContentRectRespectingInputViewBounds not updating the visual viewport
+        unless it caused a layout to happen. Added a code to update the visual viewport in WebPage::updateVisibleContentRects.
+
+        Also fixed the bug that VisibleContentRectUpdateInfo::operator== was not checking differences in
+        unobscuredContentRectRespectingInputViewBounds which resulted in the visual viewport override not getting updated
+        while the keyboard is getting brought up.
+
+        * Shared/VisibleContentRectUpdateInfo.h:
+        (WebKit::operator==):
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::updateVisibleContentRects):
+
 2019-01-15  Megan Gardner  <[email protected]>
 
         Add Reveal support in iOSMac

Modified: trunk/Source/WebKit/Shared/VisibleContentRectUpdateInfo.h (240026 => 240027)


--- trunk/Source/WebKit/Shared/VisibleContentRectUpdateInfo.h	2019-01-16 03:27:11 UTC (rev 240026)
+++ trunk/Source/WebKit/Shared/VisibleContentRectUpdateInfo.h	2019-01-16 03:35:59 UTC (rev 240027)
@@ -121,6 +121,7 @@
     return a.scale() == b.scale()
         && a.exposedContentRect() == b.exposedContentRect()
         && a.unobscuredContentRect() == b.unobscuredContentRect()
+        && a.unobscuredContentRectRespectingInputViewBounds() == b.unobscuredContentRectRespectingInputViewBounds()
         && a.customFixedPositionRect() == b.customFixedPositionRect()
         && a.obscuredInsets() == b.obscuredInsets()
         && a.unobscuredSafeAreaInsets() == b.unobscuredSafeAreaInsets()

Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (240026 => 240027)


--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2019-01-16 03:27:11 UTC (rev 240026)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2019-01-16 03:35:59 UTC (rev 240027)
@@ -3041,6 +3041,8 @@
                 frameView.frame().selection().setCaretRectNeedsUpdate();
                 sendPartialEditorStateAndSchedulePostLayoutUpdate();
             }
+
+            frameView.didUpdateViewportOverrideRects();
         } else
             frameView.setCustomFixedPositionLayoutRect(enclosingIntRect(visibleContentRectUpdateInfo.customFixedPositionRect()));
     }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to