<!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>[192979] branches/safari-601.1.46-branch</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/192979">192979</a></dd>
<dt>Author</dt> <dd>matthew_hanson@apple.com</dd>
<dt>Date</dt> <dd>2015-12-02 15:04:34 -0800 (Wed, 02 Dec 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/192432">r192432</a>. rdar://problem/23558672</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari601146branchLayoutTestsChangeLog">branches/safari-601.1.46-branch/LayoutTests/ChangeLog</a></li>
<li><a href="#branchessafari601146branchSourceWebKit2ChangeLog">branches/safari-601.1.46-branch/Source/WebKit2/ChangeLog</a></li>
<li><a href="#branchessafari601146branchSourceWebKit2UIProcessAPICocoaWKWebViewmm">branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm</a></li>
<li><a href="#branchessafari601146branchSourceWebKit2UIProcessAPICocoaWKWebViewInternalh">branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h</a></li>
<li><a href="#branchessafari601146branchSourceWebKit2UIProcessiosPageClientImplIOSmm">branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm</a></li>
<li><a href="#branchessafari601146branchSourceWebKit2UIProcessiosWKContentViewInteractionh">branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h</a></li>
<li><a href="#branchessafari601146branchSourceWebKit2UIProcessiosWKContentViewInteractionmm">branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm</a></li>
<li><a href="#branchessafari601146branchToolsChangeLog">branches/safari-601.1.46-branch/Tools/ChangeLog</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li>branches/safari-601.1.46-branch/LayoutTests/fast/events/ios/</li>
<li><a href="#branchessafari601146branchLayoutTestsfasteventsioskeyboardscrollingdistanceexpectedtxt">branches/safari-601.1.46-branch/LayoutTests/fast/events/ios/keyboard-scrolling-distance-expected.txt</a></li>
<li><a href="#branchessafari601146branchLayoutTestsfasteventsioskeyboardscrollingdistancehtml">branches/safari-601.1.46-branch/LayoutTests/fast/events/ios/keyboard-scrolling-distance.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari601146branchLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/LayoutTests/ChangeLog (192978 => 192979)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/LayoutTests/ChangeLog        2015-12-02 23:04:28 UTC (rev 192978)
+++ branches/safari-601.1.46-branch/LayoutTests/ChangeLog        2015-12-02 23:04:34 UTC (rev 192979)
</span><span class="lines">@@ -1,5 +1,22 @@
</span><span class="cx"> 2015-12-01 Matthew Hanson <matthew_hanson@apple.com>
</span><span class="cx">
</span><ins>+ Merge r192432. rdar://problem/23558672
+
+ 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.
+
+2015-12-01 Matthew Hanson <matthew_hanson@apple.com>
+
</ins><span class="cx"> Merge r192169. rdar://problem/23189763
</span><span class="cx">
</span><span class="cx"> 2015-11-09 Myles C. Maxfield <mmaxfield@apple.com>
</span></span></pre></div>
<a id="branchessafari601146branchLayoutTestsfasteventsioskeyboardscrollingdistanceexpectedtxt"></a>
<div class="addfile"><h4>Added: branches/safari-601.1.46-branch/LayoutTests/fast/events/ios/keyboard-scrolling-distance-expected.txt (0 => 192979)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/LayoutTests/fast/events/ios/keyboard-scrolling-distance-expected.txt         (rev 0)
+++ branches/safari-601.1.46-branch/LayoutTests/fast/events/ios/keyboard-scrolling-distance-expected.txt        2015-12-02 23:04:34 UTC (rev 192979)
</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="branchessafari601146branchLayoutTestsfasteventsioskeyboardscrollingdistancehtml"></a>
<div class="addfile"><h4>Added: branches/safari-601.1.46-branch/LayoutTests/fast/events/ios/keyboard-scrolling-distance.html (0 => 192979)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/LayoutTests/fast/events/ios/keyboard-scrolling-distance.html         (rev 0)
+++ branches/safari-601.1.46-branch/LayoutTests/fast/events/ios/keyboard-scrolling-distance.html        2015-12-02 23:04:34 UTC (rev 192979)
</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="branchessafari601146branchSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebKit2/ChangeLog (192978 => 192979)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/WebKit2/ChangeLog        2015-12-02 23:04:28 UTC (rev 192978)
+++ branches/safari-601.1.46-branch/Source/WebKit2/ChangeLog        2015-12-02 23:04:34 UTC (rev 192979)
</span><span class="lines">@@ -1,5 +1,64 @@
</span><span class="cx"> 2015-12-01 Matthew Hanson <matthew_hanson@apple.com>
</span><span class="cx">
</span><ins>+ Merge r192432. rdar://problem/23558672
+
+ 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.
+
+2015-12-01 Matthew Hanson <matthew_hanson@apple.com>
+
</ins><span class="cx"> Merge r187544. rdar://problem/23395970
</span><span class="cx">
</span><span class="cx"> 2015-07-29 Chris Dumez <cdumez@apple.com>
</span></span></pre></div>
<a id="branchessafari601146branchSourceWebKit2UIProcessAPICocoaWKWebViewmm"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (192978 => 192979)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2015-12-02 23:04:28 UTC (rev 192978)
+++ branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2015-12-02 23:04:34 UTC (rev 192979)
</span><span class="lines">@@ -1254,12 +1254,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="branchessafari601146branchSourceWebKit2UIProcessAPICocoaWKWebViewInternalh"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h (192978 => 192979)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h        2015-12-02 23:04:28 UTC (rev 192978)
+++ branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h        2015-12-02 23:04:34 UTC (rev 192979)
</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="branchessafari601146branchSourceWebKit2UIProcessiosPageClientImplIOSmm"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm (192978 => 192979)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm        2015-12-02 23:04:28 UTC (rev 192978)
+++ branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm        2015-12-02 23:04:34 UTC (rev 192979)
</span><span class="lines">@@ -429,9 +429,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="branchessafari601146branchSourceWebKit2UIProcessiosWKContentViewInteractionh"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h (192978 => 192979)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h        2015-12-02 23:04:28 UTC (rev 192978)
+++ branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h        2015-12-02 23:04:34 UTC (rev 192979)
</span><span class="lines">@@ -145,6 +145,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="branchessafari601146branchSourceWebKit2UIProcessiosWKContentViewInteractionmm"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (192978 => 192979)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm        2015-12-02 23:04:28 UTC (rev 192978)
+++ branches/safari-601.1.46-branch/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm        2015-12-02 23:04:34 UTC (rev 192979)
</span><span class="lines">@@ -80,6 +80,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">@@ -2625,15 +2639,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">@@ -2643,6 +2663,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">@@ -2652,7 +2673,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">@@ -2661,6 +2682,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">@@ -2673,6 +2710,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">@@ -2688,29 +2726,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">@@ -2735,7 +2773,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="branchessafari601146branchToolsChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Tools/ChangeLog (192978 => 192979)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.46-branch/Tools/ChangeLog        2015-12-02 23:04:28 UTC (rev 192978)
+++ branches/safari-601.1.46-branch/Tools/ChangeLog        2015-12-02 23:04:34 UTC (rev 192979)
</span><span class="lines">@@ -1,3 +1,31 @@
</span><ins>+2015-12-01 Matthew Hanson <matthew_hanson@apple.com>
+
+ Merge r192432. rdar://problem/23558672
+
+ 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-10-27 Matthew Hanson <matthew_hanson@apple.com>
</span><span class="cx">
</span><span class="cx"> Merge r191395. rdar://problem/22846455
</span></span></pre>
</div>
</div>
</body>
</html>