<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[192432] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/192432">192432</a></dd>
<dt>Author</dt> <dd>timothy_horton@apple.com</dd>
<dt>Date</dt> <dd>2015-11-13 10:11:42 -0800 (Fri, 13 Nov 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Hardware keyboard spacebar scrolls too far on iOS
https://bugs.webkit.org/show_bug.cgi?id=151227
<rdar://problem/23500681>
Reviewed by Simon Fraser.
There were two bugs conspiring here to make spacebar scrolling very wrong on iOS:
1) Incoming key events were being handled twice
- fix this by only propagating the event to super if we don't
end up handling the event ourselves
2) _scrollByOffset was not converting the offset delta out of content coordinates
- fix this by doing the relevant conversion and renaming the function
to make it more clear exactly what it does
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _scrollByContentOffset:]):
(-[WKWebView _scrollByOffset:]): Deleted.
* UIProcess/API/Cocoa/WKWebViewInternal.h:
Rename to _scrollByContentOffset to make it clear that this is
in content coordinates, and do the conversion from content coordinates
(apply the scale) so that we scroll by the right amount.
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::doneWithKeyEvent):
Pass whether the event was handled through to WKContentView.
* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKWebEvent dealloc]):
Add WKWebEvent, which is a WebEvent and retains a reference to the UIEvent
from which it came.
(-[WKContentView _handleKeyUIEvent:]):
Only pass the event to super immediately if we don't try to handle it.
We'll re-send it to super asynchronously if we decide not to handle it.
(-[WKContentView handleKeyEvent:]):
If we're in the middle of resending an event we didn't handle the first
time, just ignore it.
Make a WKWebEvent and store the UIEvent on it.
(-[WKContentView _didHandleKeyEvent:eventWasHandled:]):
If the event wasn't handled, and is one of our special events with a
wrapped UIEvent, resend it to super. We'll ignore it as noted above.
(-[WKContentView _interpretKeyEvent:isCharEvent:]):
Factor out unobscured content rect retrieval.
Make use of Scrollbar::pageStep to match the Mac behavior of not
scrolling quite a whole page when scrolling with the spacebar.
* fast/events/ios/keyboard-scrolling-distance-expected.txt: Added.
* fast/events/ios/keyboard-scrolling-distance.html: Added.
Add a test that records how much we scroll when pressing the spacebar.
The test is at a fixed scale of 1.5 to expose the bug fixed by this patch.
* WebKitTestRunner/UIScriptContext/Bindings/UIScriptController.idl:
* WebKitTestRunner/UIScriptContext/UIScriptContext.h:
* WebKitTestRunner/UIScriptContext/UIScriptController.cpp:
(WTR::UIScriptController::setDidEndScrollingCallback):
(WTR::UIScriptController::didEndScrollingCallback):
(WTR::UIScriptController::platformSetDidEndScrollingCallback):
* WebKitTestRunner/UIScriptContext/UIScriptController.h:
* WebKitTestRunner/cocoa/TestRunnerWKWebView.h:
* WebKitTestRunner/cocoa/TestRunnerWKWebView.mm:
(-[TestRunnerWKWebView dealloc]):
(-[TestRunnerWKWebView _didFinishScrolling]):
* WebKitTestRunner/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptController::platformSetDidEndScrollingCallback):
(WTR::UIScriptController::platformClearAllCallbacks):
Expose _didFinishScrolling on WKWebView to the UIScriptController.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebViewInternalh">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosPageClientImplIOSmm">trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWKContentViewInteractionh">trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWKContentViewInteractionmm">trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsWebKitTestRunnerUIScriptContextBindingsUIScriptControlleridl">trunk/Tools/WebKitTestRunner/UIScriptContext/Bindings/UIScriptController.idl</a></li>
<li><a href="#trunkToolsWebKitTestRunnerUIScriptContextUIScriptContexth">trunk/Tools/WebKitTestRunner/UIScriptContext/UIScriptContext.h</a></li>
<li><a href="#trunkToolsWebKitTestRunnerUIScriptContextUIScriptControllercpp">trunk/Tools/WebKitTestRunner/UIScriptContext/UIScriptController.cpp</a></li>
<li><a href="#trunkToolsWebKitTestRunnerUIScriptContextUIScriptControllerh">trunk/Tools/WebKitTestRunner/UIScriptContext/UIScriptController.h</a></li>
<li><a href="#trunkToolsWebKitTestRunnercocoaTestRunnerWKWebViewh">trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.h</a></li>
<li><a href="#trunkToolsWebKitTestRunnercocoaTestRunnerWKWebViewmm">trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.mm</a></li>
<li><a href="#trunkToolsWebKitTestRunneriosUIScriptControllerIOSmm">trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfasteventsioskeyboardscrollingdistanceexpectedtxt">trunk/LayoutTests/fast/events/ios/keyboard-scrolling-distance-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfasteventsioskeyboardscrollingdistancehtml">trunk/LayoutTests/fast/events/ios/keyboard-scrolling-distance.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (192431 => 192432)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-11-13 18:08:15 UTC (rev 192431)
+++ trunk/LayoutTests/ChangeLog        2015-11-13 18:11:42 UTC (rev 192432)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2015-11-13 Tim Horton <timothy_horton@apple.com>
+
+ Hardware keyboard spacebar scrolls too far on iOS
+ https://bugs.webkit.org/show_bug.cgi?id=151227
+ <rdar://problem/23500681>
+
+ Reviewed by Simon Fraser.
+
+ * fast/events/ios/keyboard-scrolling-distance-expected.txt: Added.
+ * fast/events/ios/keyboard-scrolling-distance.html: Added.
+ Add a test that records how much we scroll when pressing the spacebar.
+ The test is at a fixed scale of 1.5 to expose the bug fixed by this patch.
+
</ins><span class="cx"> 2015-11-13 Ryan Haddad <ryanhaddad@apple.com>
</span><span class="cx">
</span><span class="cx"> Removing a deleted test from mac-wk2 test expectations.
</span></span></pre></div>
<a id="trunkLayoutTestsfasteventsioskeyboardscrollingdistanceexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/ios/keyboard-scrolling-distance-expected.txt (0 => 192432)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/ios/keyboard-scrolling-distance-expected.txt         (rev 0)
+++ trunk/LayoutTests/fast/events/ios/keyboard-scrolling-distance-expected.txt        2015-11-13 18:11:42 UTC (rev 192432)
</span><span class="lines">@@ -0,0 +1,6 @@
</span><ins>+PASS successfullyParsed is true
+
+TEST COMPLETE
+Before pressing the spacebar, window.scrollY = 0
+After pressing the spacebar, window.scrollY = 255
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfasteventsioskeyboardscrollingdistancehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/events/ios/keyboard-scrolling-distance.html (0 => 192432)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/events/ios/keyboard-scrolling-distance.html         (rev 0)
+++ trunk/LayoutTests/fast/events/ios/keyboard-scrolling-distance.html        2015-11-13 18:11:42 UTC (rev 192432)
</span><span class="lines">@@ -0,0 +1,58 @@
</span><ins>+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+
+<html>
+
+<head>
+ <script src="../../../resources/js-test-pre.js"></script>
+ <meta name="viewport" content="initial-scale=1.5, user-scalable=no">
+ <script id="ui-script" type="text/plain">
+ (function() {
+ // FIXME (151264): Need to tap to focus so that key events go through.
+ uiController.singleTapAtPoint(50, 25, function() {
+ uiController.typeCharacterUsingHardwareKeyboard(" ", function() {
+ uiController.didEndScrollingCallback = function() {
+ uiController.uiScriptComplete();
+ };
+ });
+ });
+ })();
+ </script>
+
+ <script>
+ if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+ }
+
+ function getUIScript()
+ {
+ return document.getElementById("ui-script").text;
+ }
+
+ function runTest()
+ {
+ if (!window.testRunner || !testRunner.runUIScript)
+ return;
+
+ debug("Before pressing the spacebar, window.scrollY = " + window.scrollY);
+ testRunner.runUIScript(getUIScript(), function(result) {
+ debug("After pressing the spacebar, window.scrollY = " + window.scrollY);
+ testRunner.notifyDone();
+ });
+ }
+ </script>
+ <style>
+ #placeholder {
+ width: 100px;
+ height: 5000px;
+ }
+ </style>
+</head>
+
+<body style="margin: 0;" onload="runTest()">
+ <div id="placeholder">
+ <div id="console"></div>
+ <script src="../../../resources/js-test-post.js"></script>
+</body>
+
+</html>
</ins></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (192431 => 192432)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2015-11-13 18:08:15 UTC (rev 192431)
+++ trunk/Source/WebKit2/ChangeLog        2015-11-13 18:11:42 UTC (rev 192432)
</span><span class="lines">@@ -1,3 +1,58 @@
</span><ins>+2015-11-13 Tim Horton <timothy_horton@apple.com>
+
+ Hardware keyboard spacebar scrolls too far on iOS
+ https://bugs.webkit.org/show_bug.cgi?id=151227
+ <rdar://problem/23500681>
+
+ Reviewed by Simon Fraser.
+
+ There were two bugs conspiring here to make spacebar scrolling very wrong on iOS:
+
+ 1) Incoming key events were being handled twice
+ - fix this by only propagating the event to super if we don't
+ end up handling the event ourselves
+
+ 2) _scrollByOffset was not converting the offset delta out of content coordinates
+ - fix this by doing the relevant conversion and renaming the function
+ to make it more clear exactly what it does
+
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView _scrollByContentOffset:]):
+ (-[WKWebView _scrollByOffset:]): Deleted.
+ * UIProcess/API/Cocoa/WKWebViewInternal.h:
+ Rename to _scrollByContentOffset to make it clear that this is
+ in content coordinates, and do the conversion from content coordinates
+ (apply the scale) so that we scroll by the right amount.
+
+ * UIProcess/ios/PageClientImplIOS.mm:
+ (WebKit::PageClientImpl::doneWithKeyEvent):
+ Pass whether the event was handled through to WKContentView.
+
+ * UIProcess/ios/WKContentViewInteraction.h:
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (-[WKWebEvent dealloc]):
+ Add WKWebEvent, which is a WebEvent and retains a reference to the UIEvent
+ from which it came.
+
+ (-[WKContentView _handleKeyUIEvent:]):
+ Only pass the event to super immediately if we don't try to handle it.
+ We'll re-send it to super asynchronously if we decide not to handle it.
+
+ (-[WKContentView handleKeyEvent:]):
+ If we're in the middle of resending an event we didn't handle the first
+ time, just ignore it.
+
+ Make a WKWebEvent and store the UIEvent on it.
+
+ (-[WKContentView _didHandleKeyEvent:eventWasHandled:]):
+ If the event wasn't handled, and is one of our special events with a
+ wrapped UIEvent, resend it to super. We'll ignore it as noted above.
+
+ (-[WKContentView _interpretKeyEvent:isCharEvent:]):
+ Factor out unobscured content rect retrieval.
+ Make use of Scrollbar::pageStep to match the Mac behavior of not
+ scrolling quite a whole page when scrolling with the spacebar.
+
</ins><span class="cx"> 2015-11-12 Ryuan Choi <ryuan.choi@navercorp.com>
</span><span class="cx">
</span><span class="cx"> [EFL] Fix wrong test case for window_create since r192196
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (192431 => 192432)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2015-11-13 18:08:15 UTC (rev 192431)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2015-11-13 18:11:42 UTC (rev 192432)
</span><span class="lines">@@ -1309,12 +1309,15 @@
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-- (void)_scrollByOffset:(WebCore::FloatPoint)offset
</del><ins>+- (void)_scrollByContentOffset:(WebCore::FloatPoint)contentOffsetDelta
</ins><span class="cx"> {
</span><del>- CGPoint currentOffset = ([_scrollView _isAnimatingScroll]) ? [_scrollView _animatedTargetOffset] : [_scrollView contentOffset];
</del><ins>+ WebCore::FloatPoint scaledOffsetDelta = contentOffsetDelta;
+ CGFloat zoomScale = contentZoomScale(self);
+ scaledOffsetDelta.scale(zoomScale, zoomScale);
</ins><span class="cx">
</span><del>- CGPoint boundedOffset = contentOffsetBoundedInValidRange(_scrollView.get(), currentOffset + offset);
-
</del><ins>+ CGPoint currentOffset = [_scrollView _isAnimatingScroll] ? [_scrollView _animatedTargetOffset] : [_scrollView contentOffset];
+ CGPoint boundedOffset = contentOffsetBoundedInValidRange(_scrollView.get(), currentOffset + scaledOffsetDelta);
+
</ins><span class="cx"> if (CGPointEqualToPoint(boundedOffset, currentOffset))
</span><span class="cx"> return;
</span><span class="cx"> [_contentView willStartZoomOrScroll];
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKWebViewInternalh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h (192431 => 192432)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h        2015-11-13 18:08:15 UTC (rev 192431)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h        2015-11-13 18:11:42 UTC (rev 192432)
</span><span class="lines">@@ -83,7 +83,7 @@
</span><span class="cx">
</span><span class="cx"> - (void)_scrollToContentOffset:(WebCore::FloatPoint)contentOffset scrollOrigin:(WebCore::IntPoint)scrollOrigin;
</span><span class="cx"> - (BOOL)_scrollToRect:(WebCore::FloatRect)targetRect origin:(WebCore::FloatPoint)origin minimumScrollDistance:(float)minimumScrollDistance;
</span><del>-- (void)_scrollByOffset:(WebCore::FloatPoint)offset;
</del><ins>+- (void)_scrollByContentOffset:(WebCore::FloatPoint)offset;
</ins><span class="cx"> - (void)_zoomToFocusRect:(WebCore::FloatRect)focusedElementRect selectionRect:(WebCore::FloatRect)selectionRectInDocumentCoordinates fontSize:(float)fontSize minimumScale:(double)minimumScale maximumScale:(double)maximumScale allowScaling:(BOOL)allowScaling forceScroll:(BOOL)forceScroll;
</span><span class="cx"> - (BOOL)_zoomToRect:(WebCore::FloatRect)targetRect withOrigin:(WebCore::FloatPoint)origin fitEntireRect:(BOOL)fitEntireRect minimumScale:(double)minimumScale maximumScale:(double)maximumScale minimumScrollDistance:(float)minimumScrollDistance;
</span><span class="cx"> - (void)_zoomOutWithOrigin:(WebCore::FloatPoint)origin animated:(BOOL)animated;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosPageClientImplIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm (192431 => 192432)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm        2015-11-13 18:08:15 UTC (rev 192431)
+++ trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm        2015-11-13 18:11:42 UTC (rev 192432)
</span><span class="lines">@@ -421,9 +421,9 @@
</span><span class="cx"> return enclosingIntRect(rootViewRect);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void PageClientImpl::doneWithKeyEvent(const NativeWebKeyboardEvent& event, bool)
</del><ins>+void PageClientImpl::doneWithKeyEvent(const NativeWebKeyboardEvent& event, bool eventWasHandled)
</ins><span class="cx"> {
</span><del>- [m_contentView _didHandleKeyEvent:event.nativeEvent()];
</del><ins>+ [m_contentView _didHandleKeyEvent:event.nativeEvent() eventWasHandled:eventWasHandled];
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #if ENABLE(TOUCH_EVENTS)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWKContentViewInteractionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h (192431 => 192432)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h        2015-11-13 18:08:15 UTC (rev 192431)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h        2015-11-13 18:11:42 UTC (rev 192432)
</span><span class="lines">@@ -141,6 +141,7 @@
</span><span class="cx"> WebKit::InteractionInformationAtPosition _positionInformation;
</span><span class="cx"> WebKit::AssistedNodeInformation _assistedNodeInformation;
</span><span class="cx"> RetainPtr<NSObject<WKFormPeripheral>> _inputPeripheral;
</span><ins>+ RetainPtr<UIEvent> _uiEventBeingResent;
</ins><span class="cx">
</span><span class="cx"> CGPoint _lastInteractionLocation;
</span><span class="cx">
</span><span class="lines">@@ -202,7 +203,7 @@
</span><span class="cx"> - (void)_showPlaybackTargetPicker:(BOOL)hasVideo fromRect:(const WebCore::IntRect&)elementRect;
</span><span class="cx"> - (void)_showRunOpenPanel:(WebKit::WebOpenPanelParameters*)parameters resultListener:(WebKit::WebOpenPanelResultListenerProxy*)listener;
</span><span class="cx"> - (void)accessoryDone;
</span><del>-- (void)_didHandleKeyEvent:(WebIOSEvent *)event;
</del><ins>+- (void)_didHandleKeyEvent:(WebIOSEvent *)event eventWasHandled:(BOOL)eventWasHandled;
</ins><span class="cx"> - (Vector<WebKit::OptionItem>&) assistedNodeSelectOptions;
</span><span class="cx"> - (void)_enableInspectorNodeSearch;
</span><span class="cx"> - (void)_disableInspectorNodeSearch;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWKContentViewInteractionmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (192431 => 192432)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm        2015-11-13 18:08:15 UTC (rev 192431)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm        2015-11-13 18:11:42 UTC (rev 192432)
</span><span class="lines">@@ -78,6 +78,20 @@
</span><span class="cx"> @property (nonatomic, assign) UIKeyboardInputFlags _inputFlags;
</span><span class="cx"> @end
</span><span class="cx">
</span><ins>+@interface WKWebEvent : WebEvent
+@property (nonatomic, retain) UIEvent *uiEvent;
+@end
+
+@implementation WKWebEvent
+
+- (void)dealloc
+{
+ [_uiEvent release];
+ [super dealloc];
+}
+
+@end
+
</ins><span class="cx"> using namespace WebCore;
</span><span class="cx"> using namespace WebKit;
</span><span class="cx">
</span><span class="lines">@@ -2789,15 +2803,21 @@
</span><span class="cx"> {
</span><span class="cx"> // We only want to handle key event from the hardware keyboard when we are
</span><span class="cx"> // first responder and we are not interacting with editable content.
</span><del>- if ([self isFirstResponder] && event._hidEvent && !_page->editorState().isContentEditable)
</del><ins>+ if ([self isFirstResponder] && event._hidEvent && !_page->editorState().isContentEditable) {
</ins><span class="cx"> [self handleKeyEvent:event];
</span><ins>+ return;
+ }
</ins><span class="cx">
</span><span class="cx"> [super _handleKeyUIEvent:event];
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (void)handleKeyEvent:(::UIEvent *)event
</span><span class="cx"> {
</span><del>- ::WebEvent *webEvent = [[[::WebEvent alloc] initWithKeyEventType:(event._isKeyDown) ? WebEventKeyDown : WebEventKeyUp
</del><ins>+ // WebCore has already seen the event, no need for custom processing.
+ if (event == _uiEventBeingResent)
+ return;
+
+ WKWebEvent *webEvent = [[[WKWebEvent alloc] initWithKeyEventType:(event._isKeyDown) ? WebEventKeyDown : WebEventKeyUp
</ins><span class="cx"> timeStamp:event.timestamp
</span><span class="cx"> characters:event._modifiedInput
</span><span class="cx"> charactersIgnoringModifiers:event._unmodifiedInput
</span><span class="lines">@@ -2807,6 +2827,7 @@
</span><span class="cx"> keyCode:0
</span><span class="cx"> isTabKey:[event._modifiedInput isEqualToString:@"\t"]
</span><span class="cx"> characterSet:WebEventCharacterSetUnicode] autorelease];
</span><ins>+ webEvent.uiEvent = event;
</ins><span class="cx">
</span><span class="cx"> [self handleKeyWebEvent:webEvent];
</span><span class="cx"> }
</span><span class="lines">@@ -2816,7 +2837,7 @@
</span><span class="cx"> _page->handleKeyboardEvent(NativeWebKeyboardEvent(theEvent));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-- (void)_didHandleKeyEvent:(WebIOSEvent *)event
</del><ins>+- (void)_didHandleKeyEvent:(WebIOSEvent *)event eventWasHandled:(BOOL)eventWasHandled
</ins><span class="cx"> {
</span><span class="cx"> if (event.type == WebEventKeyDown) {
</span><span class="cx"> // FIXME: This is only for staging purposes.
</span><span class="lines">@@ -2825,6 +2846,22 @@
</span><span class="cx"> else
</span><span class="cx"> [[UIKeyboardImpl sharedInstance] didHandleWebKeyEvent];
</span><span class="cx"> }
</span><ins>+
+ if (eventWasHandled)
+ return;
+
+ if (![event isKindOfClass:[WKWebEvent class]])
+ return;
+
+ // Resending the event may destroy this WKContentView.
+ RetainPtr<WKContentView> protector(self);
+
+ // We keep here the event when resending it to the application to distinguish
+ // the case of a new event from one that has been already sent to WebCore.
+ ASSERT(!_uiEventBeingResent);
+ _uiEventBeingResent = [(WKWebEvent *)event uiEvent];
+ [super _handleKeyUIEvent:_uiEventBeingResent.get()];
+ _uiEventBeingResent = nil;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> - (BOOL)_interpretKeyEvent:(WebIOSEvent *)event isCharEvent:(BOOL)isCharEvent
</span><span class="lines">@@ -2837,6 +2874,7 @@
</span><span class="cx"> static const unsigned kWebSpaceKey = 0x20;
</span><span class="cx">
</span><span class="cx"> BOOL contentEditable = _page->editorState().isContentEditable;
</span><ins>+ WebCore::FloatRect unobscuredContentRect = _page->unobscuredContentRect();
</ins><span class="cx">
</span><span class="cx"> if (!contentEditable && event.isTabKey)
</span><span class="cx"> return NO;
</span><span class="lines">@@ -2852,29 +2890,29 @@
</span><span class="cx"> scrollOffset.setX(-Scrollbar::pixelsPerLineStep());
</span><span class="cx"> else if ([charactersIgnoringModifiers isEqualToString:UIKeyInputUpArrow]) {
</span><span class="cx"> if (option)
</span><del>- scrollOffset.setY(-_page->unobscuredContentRect().height());
</del><ins>+ scrollOffset.setY(-unobscuredContentRect.height());
</ins><span class="cx"> else if (command)
</span><del>- scrollOffset.setY(-[self bounds].size.height);
</del><ins>+ scrollOffset.setY(-self.bounds.size.height);
</ins><span class="cx"> else
</span><span class="cx"> scrollOffset.setY(-Scrollbar::pixelsPerLineStep());
</span><span class="cx"> } else if ([charactersIgnoringModifiers isEqualToString:UIKeyInputRightArrow])
</span><span class="cx"> scrollOffset.setX(Scrollbar::pixelsPerLineStep());
</span><span class="cx"> else if ([charactersIgnoringModifiers isEqualToString:UIKeyInputDownArrow]) {
</span><span class="cx"> if (option)
</span><del>- scrollOffset.setY(_page->unobscuredContentRect().height());
</del><ins>+ scrollOffset.setY(unobscuredContentRect.height());
</ins><span class="cx"> else if (command)
</span><del>- scrollOffset.setY([self bounds].size.height);
</del><ins>+ scrollOffset.setY(self.bounds.size.height);
</ins><span class="cx"> else
</span><span class="cx"> scrollOffset.setY(Scrollbar::pixelsPerLineStep());
</span><span class="cx"> } else if ([charactersIgnoringModifiers isEqualToString:UIKeyInputPageDown])
</span><del>- scrollOffset.setY(_page->unobscuredContentRect().height());
</del><ins>+ scrollOffset.setY(unobscuredContentRect.height());
</ins><span class="cx"> else if ([charactersIgnoringModifiers isEqualToString:UIKeyInputPageUp])
</span><del>- scrollOffset.setY(-_page->unobscuredContentRect().height());
</del><ins>+ scrollOffset.setY(-unobscuredContentRect.height());
</ins><span class="cx"> else
</span><span class="cx"> shouldScroll = NO;
</span><span class="cx">
</span><span class="cx"> if (shouldScroll) {
</span><del>- [_webView _scrollByOffset:scrollOffset];
</del><ins>+ [_webView _scrollByContentOffset:scrollOffset];
</ins><span class="cx"> return YES;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -2899,7 +2937,8 @@
</span><span class="cx">
</span><span class="cx"> case kWebSpaceKey:
</span><span class="cx"> if (!contentEditable) {
</span><del>- [_webView _scrollByOffset:FloatPoint(0, shift ? -_page->unobscuredContentRect().height() : _page->unobscuredContentRect().height())];
</del><ins>+ int pageStep = Scrollbar::pageStep(unobscuredContentRect.height(), self.bounds.size.height);
+ [_webView _scrollByContentOffset:FloatPoint(0, shift ? -pageStep : pageStep)];
</ins><span class="cx"> return YES;
</span><span class="cx"> }
</span><span class="cx"> if (isCharEvent) {
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (192431 => 192432)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2015-11-13 18:08:15 UTC (rev 192431)
+++ trunk/Tools/ChangeLog        2015-11-13 18:11:42 UTC (rev 192432)
</span><span class="lines">@@ -1,3 +1,27 @@
</span><ins>+2015-11-13 Tim Horton <timothy_horton@apple.com>
+
+ Hardware keyboard spacebar scrolls too far on iOS
+ https://bugs.webkit.org/show_bug.cgi?id=151227
+ <rdar://problem/23500681>
+
+ Reviewed by Simon Fraser.
+
+ * WebKitTestRunner/UIScriptContext/Bindings/UIScriptController.idl:
+ * WebKitTestRunner/UIScriptContext/UIScriptContext.h:
+ * WebKitTestRunner/UIScriptContext/UIScriptController.cpp:
+ (WTR::UIScriptController::setDidEndScrollingCallback):
+ (WTR::UIScriptController::didEndScrollingCallback):
+ (WTR::UIScriptController::platformSetDidEndScrollingCallback):
+ * WebKitTestRunner/UIScriptContext/UIScriptController.h:
+ * WebKitTestRunner/cocoa/TestRunnerWKWebView.h:
+ * WebKitTestRunner/cocoa/TestRunnerWKWebView.mm:
+ (-[TestRunnerWKWebView dealloc]):
+ (-[TestRunnerWKWebView _didFinishScrolling]):
+ * WebKitTestRunner/ios/UIScriptControllerIOS.mm:
+ (WTR::UIScriptController::platformSetDidEndScrollingCallback):
+ (WTR::UIScriptController::platformClearAllCallbacks):
+ Expose _didFinishScrolling on WKWebView to the UIScriptController.
+
</ins><span class="cx"> 2015-11-13 Brent Fulgham <bfulgham@apple.com>
</span><span class="cx">
</span><span class="cx"> [Win] Unreviewed test fix.
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerUIScriptContextBindingsUIScriptControlleridl"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/UIScriptContext/Bindings/UIScriptController.idl (192431 => 192432)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/UIScriptContext/Bindings/UIScriptController.idl        2015-11-13 18:08:15 UTC (rev 192431)
+++ trunk/Tools/WebKitTestRunner/UIScriptContext/Bindings/UIScriptController.idl        2015-11-13 18:11:42 UTC (rev 192432)
</span><span class="lines">@@ -43,6 +43,8 @@
</span><span class="cx"> attribute object willBeginZoomingCallback;
</span><span class="cx"> attribute object didEndZoomingCallback;
</span><span class="cx">
</span><ins>+ attribute object didEndScrollingCallback;
+
</ins><span class="cx"> // View state
</span><span class="cx"> readonly attribute double zoomScale;
</span><span class="cx"> readonly attribute double minimumZoomScale;
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerUIScriptContextUIScriptContexth"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/UIScriptContext/UIScriptContext.h (192431 => 192432)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/UIScriptContext/UIScriptContext.h        2015-11-13 18:08:15 UTC (rev 192431)
+++ trunk/Tools/WebKitTestRunner/UIScriptContext/UIScriptContext.h        2015-11-13 18:11:42 UTC (rev 192432)
</span><span class="lines">@@ -46,6 +46,7 @@
</span><span class="cx"> CallbackTypeDidEndZooming,
</span><span class="cx"> CallbackTypeDidShowKeyboard,
</span><span class="cx"> CallbackTypeDidHideKeyboard,
</span><ins>+ CallbackTypeDidEndScrolling,
</ins><span class="cx"> CallbackTypeNonPersistent = firstNonPersistentCallbackID
</span><span class="cx"> } CallbackType;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerUIScriptContextUIScriptControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/UIScriptContext/UIScriptController.cpp (192431 => 192432)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/UIScriptContext/UIScriptController.cpp        2015-11-13 18:08:15 UTC (rev 192431)
+++ trunk/Tools/WebKitTestRunner/UIScriptContext/UIScriptController.cpp        2015-11-13 18:11:42 UTC (rev 192432)
</span><span class="lines">@@ -75,6 +75,17 @@
</span><span class="cx"> return m_context.callbackWithID(CallbackTypeDidEndZooming);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void UIScriptController::setDidEndScrollingCallback(JSValueRef callback)
+{
+ m_context.registerCallback(callback, CallbackTypeDidEndScrolling);
+ platformSetDidEndScrollingCallback();
+}
+
+JSValueRef UIScriptController::didEndScrollingCallback() const
+{
+ return m_context.callbackWithID(CallbackTypeDidEndScrolling);
+}
+
</ins><span class="cx"> void UIScriptController::setDidShowKeyboardCallback(JSValueRef callback)
</span><span class="cx"> {
</span><span class="cx"> m_context.registerCallback(callback, CallbackTypeDidShowKeyboard);
</span><span class="lines">@@ -142,6 +153,10 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void UIScriptController::platformSetDidEndScrollingCallback()
+{
+}
+
</ins><span class="cx"> void UIScriptController::platformSetDidShowKeyboardCallback()
</span><span class="cx"> {
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerUIScriptContextUIScriptControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/UIScriptContext/UIScriptController.h (192431 => 192432)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/UIScriptContext/UIScriptController.h        2015-11-13 18:08:15 UTC (rev 192431)
+++ trunk/Tools/WebKitTestRunner/UIScriptContext/UIScriptController.h        2015-11-13 18:11:42 UTC (rev 192432)
</span><span class="lines">@@ -62,6 +62,9 @@
</span><span class="cx"> void setDidHideKeyboardCallback(JSValueRef);
</span><span class="cx"> JSValueRef didHideKeyboardCallback() const;
</span><span class="cx">
</span><ins>+ void setDidEndScrollingCallback(JSValueRef);
+ JSValueRef didEndScrollingCallback() const;
+
</ins><span class="cx"> double zoomScale() const;
</span><span class="cx"> double minimumZoomScale() const;
</span><span class="cx"> double maximumZoomScale() const;
</span><span class="lines">@@ -77,6 +80,7 @@
</span><span class="cx"> void platformSetDidEndZoomingCallback();
</span><span class="cx"> void platformSetDidShowKeyboardCallback();
</span><span class="cx"> void platformSetDidHideKeyboardCallback();
</span><ins>+ void platformSetDidEndScrollingCallback();
</ins><span class="cx"> void platformClearAllCallbacks();
</span><span class="cx">
</span><span class="cx"> virtual JSClassRef wrapperClass() override;
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnercocoaTestRunnerWKWebViewh"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.h (192431 => 192432)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.h        2015-11-13 18:08:15 UTC (rev 192431)
+++ trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.h        2015-11-13 18:11:42 UTC (rev 192432)
</span><span class="lines">@@ -35,6 +35,7 @@
</span><span class="cx"> @property (nonatomic, copy) void (^didEndZoomingCallback)(void);
</span><span class="cx"> @property (nonatomic, copy) void (^didShowKeyboardCallback)(void);
</span><span class="cx"> @property (nonatomic, copy) void (^didHideKeyboardCallback)(void);
</span><ins>+@property (nonatomic, copy) void (^didEndScrollingCallback)(void);
</ins><span class="cx">
</span><span class="cx"> - (instancetype)initWithFrame:(CGRect)frame configuration:(WKWebViewConfiguration *)configuration;
</span><span class="cx"> - (void)dealloc;
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnercocoaTestRunnerWKWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.mm (192431 => 192432)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.mm        2015-11-13 18:08:15 UTC (rev 192431)
+++ trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.mm        2015-11-13 18:11:42 UTC (rev 192432)
</span><span class="lines">@@ -36,6 +36,7 @@
</span><span class="cx"> // FIXME: move these to WKWebView_Private.h
</span><span class="cx"> - (void)scrollViewWillBeginZooming:(UIScrollView *)scrollView withView:(UIView *)view;
</span><span class="cx"> - (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(CGFloat)scale;
</span><ins>+- (void)_didFinishScrolling;
</ins><span class="cx">
</span><span class="cx"> @end
</span><span class="cx"> #endif
</span><span class="lines">@@ -76,6 +77,7 @@
</span><span class="cx"> self.didEndZoomingCallback = nil;
</span><span class="cx"> self.didShowKeyboardCallback = nil;
</span><span class="cx"> self.didHideKeyboardCallback = nil;
</span><ins>+ self.didEndScrollingCallback = nil;
</ins><span class="cx">
</span><span class="cx"> self.zoomToScaleCompletionHandler = nil;
</span><span class="cx"> self.showKeyboardCompletionHandler = nil;
</span><span class="lines">@@ -123,6 +125,14 @@
</span><span class="cx"> self.zoomToScaleCompletionHandler = nullptr;
</span><span class="cx"> }
</span><span class="cx"> }
</span><ins>+
+- (void)_didFinishScrolling
+{
+ [super _didFinishScrolling];
+
+ if (self.didEndScrollingCallback)
+ self.didEndScrollingCallback();
+}
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> @end
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunneriosUIScriptControllerIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm (192431 => 192432)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm        2015-11-13 18:08:15 UTC (rev 192431)
+++ trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm        2015-11-13 18:11:42 UTC (rev 192432)
</span><span class="lines">@@ -157,6 +157,14 @@
</span><span class="cx"> };
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void UIScriptController::platformSetDidEndScrollingCallback()
+{
+ TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();
+ webView.didEndScrollingCallback = ^{
+ m_context.fireCallback(CallbackTypeDidEndScrolling);
+ };
+}
+
</ins><span class="cx"> void UIScriptController::platformClearAllCallbacks()
</span><span class="cx"> {
</span><span class="cx"> TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();
</span><span class="lines">@@ -164,6 +172,7 @@
</span><span class="cx"> webView.willBeginZoomingCallback = nil;
</span><span class="cx"> webView.didHideKeyboardCallback = nil;
</span><span class="cx"> webView.didShowKeyboardCallback = nil;
</span><ins>+ webView.didEndScrollingCallback = nil;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> }
</span></span></pre>
</div>
</div>
</body>
</html>