Diff
Modified: trunk/Source/WebKit2/ChangeLog (209404 => 209405)
--- trunk/Source/WebKit2/ChangeLog 2016-12-06 17:58:39 UTC (rev 209404)
+++ trunk/Source/WebKit2/ChangeLog 2016-12-06 18:24:28 UTC (rev 209405)
@@ -1,3 +1,104 @@
+2016-12-06 Tim Horton <timothy_hor...@apple.com>
+
+ Almost half-second stall scrolling apple.com because of synchronous getPositionInformation
+ https://bugs.webkit.org/show_bug.cgi?id=165403
+ <rdar://problem/29493285>
+
+ Reviewed by Enrica Casucci.
+
+ When retrieving interaction information, we don't always need to do
+ snapshots for 3D Touch or the action sheet, especially if we're
+ synchronously blocking the UI process main thread waiting for the reply.
+
+ Add a new InteractionInformationRequest, which allows callers of
+ getPositionInformation and requestPositionInformation to specify which
+ optional pieces of information they would like to compute.
+
+ * Shared/AssistedNodeInformation.h:
+ Fix a incorrect comment.
+
+ * Shared/ios/InteractionInformationRequest.cpp: Added.
+ (WebKit::InteractionInformationRequest::encode):
+ (WebKit::InteractionInformationRequest::decode):
+ (WebKit::InteractionInformationRequest::isValidForRequest):
+ * Shared/ios/InteractionInformationRequest.h: Added.
+ (WebKit::InteractionInformationRequest::InteractionInformationRequest):
+ * WebKit2.xcodeproj/project.pbxproj:
+ Add InteractionInformationRequest, which encapsulates all of the
+ parameters required to generate an InteractionInformationAtPosition.
+ Previously, that was just a point, but now we have two new parameters:
+ whether we should generate a snapshot of the element, and whether
+ we should generate a TextIndicator if the element is a link.
+
+ * Shared/ios/InteractionInformationAtPosition.h:
+ * Shared/ios/InteractionInformationAtPosition.mm:
+ (WebKit::InteractionInformationAtPosition::encode):
+ (WebKit::InteractionInformationAtPosition::decode):
+ (WebKit::InteractionInformationAtPosition::mergeCompatibleOptionalInformation):
+ Adopt InteractionInformationRequest.
+
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/ios/WebPageProxyIOS.mm:
+ (WebKit::WebPageProxy::getPositionInformation):
+ (WebKit::WebPageProxy::requestPositionInformation):
+ * UIProcess/ios/WKActionSheetAssistant.mm:
+ (-[WKActionSheetAssistant initialPresentationRectInHostViewForSheet]):
+ (-[WKActionSheetAssistant presentationRectInHostViewForSheet]):
+ (-[WKActionSheetAssistant showImageSheet]):
+ (-[WKActionSheetAssistant showLinkSheet]):
+ * UIProcess/ios/WKPDFView.mm:
+ (-[WKPDFView annotation:isBeingPressedAtPoint:controller:]):
+ * WebProcess/WebPage/WebPage.h:
+ * WebProcess/WebPage/WebPage.messages.in:
+ Adopt InteractionInformationRequest.
+
+ * UIProcess/ios/WKContentViewInteraction.h:
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (-[WKContentView _showAttachmentSheet]):
+ (-[WKContentView ensurePositionInformationIsUpToDate:]):
+ If we have a outstanding asynchronous position information request
+ for the current point, instead of sending a second separate request,
+ just wait for the async one to come in.
+
+ (-[WKContentView requestAsynchronousPositionInformationUpdate:]):
+ If asked to do an asynchronous request with more optional bits than
+ the current otherwise-valid response's request, update the position information.
+
+ (-[WKContentView gestureRecognizerShouldBegin:]):
+ The design of this mechanism is that during the highlight long press,
+ we do an async position information update, and then when we actually
+ begin a 3D Touch gesture, we hope to already have the requisite snapshots
+ ready (so that we can avoid synchronously blocking for them, there).
+ So, in the highlight long-press async request, ask for all the goodies.
+
+ (-[WKContentView hasSelectablePositionAtPoint:]):
+ (-[WKContentView pointIsNearMarkedText:]):
+ (-[WKContentView pointIsInAssistedNode:]):
+ (-[WKContentView _didNotHandleTapAsClick:]):
+ (-[WKContentView _positionInformationDidChange:]):
+ If we get a position information update for the same point, but with less
+ goodies attached (the snapshot/link indicator), copy them over from the old
+ position information, so that we never accidentally "downgrade" our info.
+
+ (-[WKContentView updatePositionInformationForActionSheetAssistant:]):
+ (-[WKContentView actionSheetAssistant:willStartInteractionWithElement:]):
+ (-[WKContentView _interactionShouldBeginFromPreviewItemController:forPosition:]):
+ (-[WKContentView _dataForPreviewItemController:atPosition:type:]):
+ (-[WKContentView _presentedViewControllerForPreviewItemController:]):
+ More adoption.
+
+ * WebProcess/WebPage/ios/WebPageIOS.mm:
+ (WebKit::WebPage::handleTap):
+ (WebKit::WebPage::handleTwoFingerTapAtPoint):
+ (WebKit::WebPage::commitPotentialTap):
+ Adopt InteractionInformationRequest.
+
+ (WebKit::WebPage::getPositionInformation):
+ (WebKit::WebPage::requestPositionInformation):
+ Copy the request into the response.
+ Only snapshot if the request wants a snapshot.
+ Only make a link indicator if the request wants one.
+
2016-12-06 Daniel Bates <daba...@apple.com>
Cleanup: Rename some HTTP 0.9-specific functions to conform to WebKit Code Style Guidelines
Modified: trunk/Source/WebKit2/Shared/AssistedNodeInformation.h (209404 => 209405)
--- trunk/Source/WebKit2/Shared/AssistedNodeInformation.h 2016-12-06 17:58:39 UTC (rev 209404)
+++ trunk/Source/WebKit2/Shared/AssistedNodeInformation.h 2016-12-06 18:24:28 UTC (rev 209405)
@@ -23,8 +23,7 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef AssistedNodeInformation_h
-#define AssistedNodeInformation_h
+#pragma once
#include "ArgumentCoders.h"
#include <WebCore/AutocapitalizeTypes.h>
@@ -118,5 +117,3 @@
#endif
}
-
-#endif // InteractionInformationAtPosition_h
Modified: trunk/Source/WebKit2/Shared/ios/InteractionInformationAtPosition.h (209404 => 209405)
--- trunk/Source/WebKit2/Shared/ios/InteractionInformationAtPosition.h 2016-12-06 17:58:39 UTC (rev 209404)
+++ trunk/Source/WebKit2/Shared/ios/InteractionInformationAtPosition.h 2016-12-06 18:24:28 UTC (rev 209405)
@@ -23,12 +23,12 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef InteractionInformationAtPosition_h
-#define InteractionInformationAtPosition_h
+#pragma once
#if PLATFORM(IOS)
#include "ArgumentCoders.h"
+#include "InteractionInformationRequest.h"
#include "ShareableBitmap.h"
#include <WebCore/IntPoint.h>
#include <WebCore/SelectionRect.h>
@@ -38,7 +38,8 @@
namespace WebKit {
struct InteractionInformationAtPosition {
- WebCore::IntPoint point;
+ InteractionInformationRequest request;
+
bool nodeAtPositionIsAssistedNode { false };
bool isSelectable { false };
bool isNearMarkedText { false };
@@ -66,6 +67,11 @@
RetainPtr<NSArray> dataDetectorResults;
#endif
+ // Copy compatible optional bits forward (for example, if we have a InteractionInformationAtPosition
+ // with snapshots in it, and perform another request for the same point without requesting the snapshots,
+ // we can fetch the cheap information and copy the snapshots into the new response).
+ void mergeCompatibleOptionalInformation(const InteractionInformationAtPosition& oldInformation);
+
void encode(IPC::Encoder&) const;
static bool decode(IPC::Decoder&, InteractionInformationAtPosition&);
};
@@ -73,5 +79,3 @@
}
#endif // PLATFORM(IOS)
-
-#endif // InteractionInformationAtPosition_h
Modified: trunk/Source/WebKit2/Shared/ios/InteractionInformationAtPosition.mm (209404 => 209405)
--- trunk/Source/WebKit2/Shared/ios/InteractionInformationAtPosition.mm 2016-12-06 17:58:39 UTC (rev 209404)
+++ trunk/Source/WebKit2/Shared/ios/InteractionInformationAtPosition.mm 2016-12-06 18:24:28 UTC (rev 209405)
@@ -40,7 +40,8 @@
void InteractionInformationAtPosition::encode(IPC::Encoder& encoder) const
{
- encoder << point;
+ encoder << request;
+
encoder << nodeAtPositionIsAssistedNode;
encoder << isSelectable;
encoder << isNearMarkedText;
@@ -80,7 +81,7 @@
bool InteractionInformationAtPosition::decode(IPC::Decoder& decoder, InteractionInformationAtPosition& result)
{
- if (!decoder.decode(result.point))
+ if (!decoder.decode(result.request))
return false;
if (!decoder.decode(result.nodeAtPositionIsAssistedNode))
@@ -167,6 +168,19 @@
return true;
}
-#endif
+void InteractionInformationAtPosition::mergeCompatibleOptionalInformation(const InteractionInformationAtPosition& oldInformation)
+{
+ if (oldInformation.request.point != request.point)
+ return;
+
+ if (oldInformation.request.includeSnapshot && !request.includeSnapshot)
+ image = oldInformation.image;
+
+ if (oldInformation.request.includeLinkIndicator && !request.includeLinkIndicator)
+ linkIndicator = oldInformation.linkIndicator;
}
+
+#endif // PLATFORM(IOS)
+
+}
Added: trunk/Source/WebKit2/Shared/ios/InteractionInformationRequest.cpp (0 => 209405)
--- trunk/Source/WebKit2/Shared/ios/InteractionInformationRequest.cpp (rev 0)
+++ trunk/Source/WebKit2/Shared/ios/InteractionInformationRequest.cpp 2016-12-06 18:24:28 UTC (rev 209405)
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "InteractionInformationRequest.h"
+
+#import "ArgumentCodersCF.h"
+#import "WebCoreArgumentCoders.h"
+
+namespace WebKit {
+
+#if PLATFORM(IOS)
+
+void InteractionInformationRequest::encode(IPC::Encoder& encoder) const
+{
+ encoder << point;
+ encoder << includeSnapshot;
+ encoder << includeLinkIndicator;
+}
+
+bool InteractionInformationRequest::decode(IPC::Decoder& decoder, InteractionInformationRequest& result)
+{
+ if (!decoder.decode(result.point))
+ return false;
+
+ if (!decoder.decode(result.includeSnapshot))
+ return false;
+
+ if (!decoder.decode(result.includeLinkIndicator))
+ return false;
+
+ return true;
+}
+
+bool InteractionInformationRequest::isValidForRequest(const InteractionInformationRequest& other)
+{
+ if (other.point != point)
+ return false;
+
+ if (other.includeSnapshot && !includeSnapshot)
+ return false;
+
+ if (other.includeLinkIndicator && !includeLinkIndicator)
+ return false;
+
+ return true;
+}
+
+#endif // PLATFORM(IOS)
+
+}
Added: trunk/Source/WebKit2/Shared/ios/InteractionInformationRequest.h (0 => 209405)
--- trunk/Source/WebKit2/Shared/ios/InteractionInformationRequest.h (rev 0)
+++ trunk/Source/WebKit2/Shared/ios/InteractionInformationRequest.h 2016-12-06 18:24:28 UTC (rev 209405)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if PLATFORM(IOS)
+
+#include "ArgumentCoders.h"
+#include "ShareableBitmap.h"
+#include <WebCore/IntPoint.h>
+#include <WebCore/SelectionRect.h>
+#include <WebCore/TextIndicator.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebKit {
+
+struct InteractionInformationRequest {
+ WebCore::IntPoint point;
+
+ bool includeSnapshot { false };
+ bool includeLinkIndicator { false };
+
+ InteractionInformationRequest() { }
+ explicit InteractionInformationRequest(WebCore::IntPoint point)
+ {
+ this->point = point;
+ }
+
+ bool isValidForRequest(const InteractionInformationRequest&);
+
+ void encode(IPC::Encoder&) const;
+ static bool decode(IPC::Decoder&, InteractionInformationRequest&);
+};
+
+}
+
+#endif // PLATFORM(IOS)
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (209404 => 209405)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h 2016-12-06 17:58:39 UTC (rev 209404)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h 2016-12-06 18:24:28 UTC (rev 209405)
@@ -210,6 +210,7 @@
struct EditingRange;
struct EditorState;
class GamepadData;
+struct InteractionInformationRequest;
struct LoadParameters;
struct PlatformPopupMenuData;
struct PrintInfo;
@@ -511,8 +512,8 @@
void replaceDictatedText(const String& oldText, const String& newText);
void replaceSelectedText(const String& oldText, const String& newText);
void didReceivePositionInformation(const InteractionInformationAtPosition&);
- void getPositionInformation(const WebCore::IntPoint&, InteractionInformationAtPosition&);
- void requestPositionInformation(const WebCore::IntPoint&);
+ void getPositionInformation(const InteractionInformationRequest&, InteractionInformationAtPosition&);
+ void requestPositionInformation(const InteractionInformationRequest&);
void startInteractionWithElementAtPosition(const WebCore::IntPoint&);
void stopInteraction();
void performActionOnElement(uint32_t action);
Modified: trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.mm (209404 => 209405)
--- trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.mm 2016-12-06 17:58:39 UTC (rev 209404)
+++ trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.mm 2016-12-06 18:24:28 UTC (rev 209405)
@@ -159,7 +159,7 @@
if (!view || !delegate)
return CGRectZero;
- return [self _presentationRectForSheetGivenPoint:[delegate positionInformationForActionSheetAssistant:self].point inHostView:view];
+ return [self _presentationRectForSheetGivenPoint:[delegate positionInformationForActionSheetAssistant:self].request.point inHostView:view];
}
- (CGRect)presentationRectInHostViewForSheet
@@ -172,7 +172,7 @@
const auto& positionInformation = [delegate positionInformationForActionSheetAssistant:self];
CGRect boundingRect = positionInformation.bounds;
- CGPoint fromPoint = positionInformation.point;
+ CGPoint fromPoint = positionInformation.request.point;
// FIXME: We must adjust our presentation point to take into account a change in document scale.
@@ -293,7 +293,7 @@
const auto& positionInformation = [delegate positionInformationForActionSheetAssistant:self];
NSURL *targetURL = [NSURL _web_URLWithWTFString:positionInformation.url];
- auto elementInfo = adoptNS([[_WKActivatedElementInfo alloc] _initWithType:_WKActivatedElementTypeImage URL:targetURL location:positionInformation.point title:positionInformation.title ID:positionInformation.idAttribute rect:positionInformation.bounds image:positionInformation.image.get()]);
+ auto elementInfo = adoptNS([[_WKActivatedElementInfo alloc] _initWithType:_WKActivatedElementTypeImage URL:targetURL location:positionInformation.request.point title:positionInformation.title ID:positionInformation.idAttribute rect:positionInformation.bounds image:positionInformation.image.get()]);
if ([delegate respondsToSelector:@selector(actionSheetAssistant:showCustomSheetForElement:)] && [delegate actionSheetAssistant:self showCustomSheetForElement:elementInfo.get()])
return;
auto defaultActions = [self defaultActionsForImageSheet:elementInfo.get()];
@@ -411,7 +411,7 @@
if (!targetURL)
return;
- auto elementInfo = adoptNS([[_WKActivatedElementInfo alloc] _initWithType:_WKActivatedElementTypeLink URL:targetURL location:positionInformation.point title:positionInformation.title ID:positionInformation.idAttribute rect:positionInformation.bounds image:positionInformation.image.get()]);
+ auto elementInfo = adoptNS([[_WKActivatedElementInfo alloc] _initWithType:_WKActivatedElementTypeLink URL:targetURL location:positionInformation.request.point title:positionInformation.title ID:positionInformation.idAttribute rect:positionInformation.bounds image:positionInformation.image.get()]);
if ([delegate respondsToSelector:@selector(actionSheetAssistant:showCustomSheetForElement:)] && [delegate actionSheetAssistant:self showCustomSheetForElement:elementInfo.get()])
return;
Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h (209404 => 209405)
--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h 2016-12-06 17:58:39 UTC (rev 209404)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h 2016-12-06 18:24:28 UTC (rev 209405)
@@ -159,6 +159,8 @@
WebKit::WKSelectionDrawingInfo _lastSelectionDrawingInfo;
+ std::optional<WebKit::InteractionInformationRequest> _outstandingPositionInformationRequest;
+
BOOL _isEditable;
BOOL _showingTextStyleOptions;
BOOL _hasValidPositionInformation;
Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (209404 => 209405)
--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm 2016-12-06 17:58:39 UTC (rev 209404)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm 2016-12-06 18:24:28 UTC (rev 209405)
@@ -1192,7 +1192,7 @@
if (![uiDelegate respondsToSelector:@selector(_webView:showCustomSheetForElement:)])
return;
- auto element = adoptNS([[_WKActivatedElementInfo alloc] _initWithType:_WKActivatedElementTypeAttachment URL:[NSURL _web_URLWithWTFString:_positionInformation.url] location:_positionInformation.point title:_positionInformation.title ID:_positionInformation.idAttribute rect:_positionInformation.bounds image:nil]);
+ auto element = adoptNS([[_WKActivatedElementInfo alloc] _initWithType:_WKActivatedElementTypeAttachment URL:[NSURL _web_URLWithWTFString:_positionInformation.url] location:_positionInformation.request.point title:_positionInformation.title ID:_positionInformation.idAttribute rect:_positionInformation.bounds image:nil]);
[uiDelegate _webView:_webView showCustomSheetForElement:element.get()];
}
@@ -1227,14 +1227,32 @@
return nil;
}
-- (void)ensurePositionInformationIsUpToDate:(CGPoint)point
+- (void)ensurePositionInformationIsUpToDate:(WebKit::InteractionInformationRequest)request
{
- if (!_hasValidPositionInformation || roundedIntPoint(point) != _positionInformation.point) {
- _page->getPositionInformation(roundedIntPoint(point), _positionInformation);
- _hasValidPositionInformation = YES;
+ if (_hasValidPositionInformation && _positionInformation.request.isValidForRequest(request))
+ return;
+
+ if (_outstandingPositionInformationRequest && _outstandingPositionInformationRequest->isValidForRequest(request)) {
+ if (auto* connection = _page->process().connection()) {
+ connection->waitForAndDispatchImmediately<Messages::WebPageProxy::DidReceivePositionInformation>(_page->pageID(), Seconds::infinity());
+ return;
+ }
}
+
+ _page->getPositionInformation(request, _positionInformation);
+ _hasValidPositionInformation = YES;
}
+- (void)requestAsynchronousPositionInformationUpdate:(WebKit::InteractionInformationRequest)request
+{
+ if (_hasValidPositionInformation && _positionInformation.request.isValidForRequest(request))
+ return;
+
+ _outstandingPositionInformationRequest = request;
+
+ _page->requestPositionInformation(request);
+}
+
#if ENABLE(DATA_DETECTION)
- (NSArray *)_dataDetectionResults
{
@@ -1255,7 +1273,8 @@
if (_textSelectionAssistant) {
// Request information about the position with sync message.
// If the assisted node is the same, prevent the gesture.
- _page->getPositionInformation(roundedIntPoint(point), _positionInformation);
+ InteractionInformationRequest request(roundedIntPoint(point));
+ _page->getPositionInformation(request, _positionInformation);
_hasValidPositionInformation = YES;
if (_positionInformation.nodeAtPositionIsAssistedNode)
return NO;
@@ -1274,7 +1293,17 @@
// We still have no idea about what is at the location.
// Send and async message to find out.
_hasValidPositionInformation = NO;
- _page->requestPositionInformation(roundedIntPoint(point));
+ InteractionInformationRequest request(roundedIntPoint(point));
+
+ // If 3D Touch is enabled, asynchronously collect snapshots in the hopes that
+ // they'll arrive before we have to synchronously request them in
+ // _interactionShouldBeginFromPreviewItemController.
+ if (self.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable) {
+ request.includeSnapshot = true;
+ request.includeLinkIndicator = true;
+ }
+
+ [self requestAsynchronousPositionInformationUpdate:request];
return YES;
}
}
@@ -1283,7 +1312,8 @@
// Use the information retrieved with one of the previous calls
// to gestureRecognizerShouldBegin.
// Force a sync call if not ready yet.
- [self ensurePositionInformationIsUpToDate:point];
+ InteractionInformationRequest request(roundedIntPoint(point));
+ [self ensurePositionInformationIsUpToDate:request];
if (_textSelectionAssistant) {
// Prevent the gesture if it is the same node.
@@ -1323,19 +1353,22 @@
if (_inspectorNodeSearchEnabled)
return NO;
- [self ensurePositionInformationIsUpToDate:point];
+ InteractionInformationRequest request(roundedIntPoint(point));
+ [self ensurePositionInformationIsUpToDate:request];
return _positionInformation.isSelectable;
}
- (BOOL)pointIsNearMarkedText:(CGPoint)point
{
- [self ensurePositionInformationIsUpToDate:point];
+ InteractionInformationRequest request(roundedIntPoint(point));
+ [self ensurePositionInformationIsUpToDate:request];
return _positionInformation.isNearMarkedText;
}
- (BOOL)pointIsInAssistedNode:(CGPoint)point
{
- [self ensurePositionInformationIsUpToDate:point];
+ InteractionInformationRequest request(roundedIntPoint(point));
+ [self ensurePositionInformationIsUpToDate:request];
return _positionInformation.nodeAtPositionIsAssistedNode;
}
@@ -1465,7 +1498,7 @@
{
// FIXME: we should also take into account whether or not the UI delegate
// has handled this notification.
- if (_hasValidPositionInformation && point == _positionInformation.point && _positionInformation.isDataDetectorLink) {
+ if (_hasValidPositionInformation && point == _positionInformation.request.point && _positionInformation.isDataDetectorLink) {
[self _showDataDetectorsSheet];
return;
}
@@ -1581,7 +1614,12 @@
- (void)_positionInformationDidChange:(const InteractionInformationAtPosition&)info
{
- _positionInformation = info;
+ _outstandingPositionInformationRequest = std::nullopt;
+
+ InteractionInformationAtPosition newInfo = info;
+ newInfo.mergeCompatibleOptionalInformation(_positionInformation);
+
+ _positionInformation = newInfo;
_hasValidPositionInformation = YES;
if (_actionSheetAssistant)
[_actionSheetAssistant updateSheetPosition];
@@ -3766,7 +3804,10 @@
- (void)updatePositionInformationForActionSheetAssistant:(WKActionSheetAssistant *)assistant
{
_hasValidPositionInformation = NO;
- _page->requestPositionInformation(_positionInformation.point);
+ InteractionInformationRequest request(_positionInformation.request.point);
+ request.includeSnapshot = YES;
+
+ [self requestAsynchronousPositionInformationUpdate:request];
}
- (void)actionSheetAssistant:(WKActionSheetAssistant *)assistant performAction:(WebKit::SheetAction)action
@@ -3816,7 +3857,7 @@
- (void)actionSheetAssistant:(WKActionSheetAssistant *)assistant willStartInteractionWithElement:(_WKActivatedElementInfo *)element
{
- _page->startInteractionWithElementAtPosition(_positionInformation.point);
+ _page->startInteractionWithElementAtPosition(_positionInformation.request.point);
}
- (void)actionSheetAssistantDidStopInteraction:(WKActionSheetAssistant *)assistant
@@ -3894,10 +3935,13 @@
if (!_highlightLongPressCanClick)
return NO;
- [self ensurePositionInformationIsUpToDate:position];
+ InteractionInformationRequest request(roundedIntPoint(position));
+ request.includeSnapshot = true;
+ request.includeLinkIndicator = true;
+ [self ensurePositionInformationIsUpToDate:request];
if (!_positionInformation.isLink && !_positionInformation.isImage && !_positionInformation.isAttachment)
return NO;
-
+
String absoluteLinkURL = _positionInformation.url;
if (_positionInformation.isLink) {
NSURL *targetURL = [NSURL _web_URLWithWTFString:_positionInformation.url];
@@ -3986,7 +4030,7 @@
} else if (canShowAttachmentPreview) {
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 100000
*type = UIPreviewItemTypeAttachment;
- auto element = adoptNS([[_WKActivatedElementInfo alloc] _initWithType:_WKActivatedElementTypeAttachment URL:[NSURL _web_URLWithWTFString:_positionInformation.url] location:_positionInformation.point title:_positionInformation.title ID:_positionInformation.idAttribute rect:_positionInformation.bounds image:nil]);
+ auto element = adoptNS([[_WKActivatedElementInfo alloc] _initWithType:_WKActivatedElementTypeAttachment URL:[NSURL _web_URLWithWTFString:_positionInformation.url] location:_positionInformation.request.point title:_positionInformation.title ID:_positionInformation.idAttribute rect:_positionInformation.bounds image:nil]);
NSUInteger index = [uiDelegate _webView:_webView indexIntoAttachmentListForElement:element.get()];
if (index != NSNotFound) {
BOOL sourceIsManaged = NO;
@@ -4042,11 +4086,11 @@
if ([_previewItemController type] == UIPreviewItemTypeLink) {
_highlightLongPressCanClick = NO;
- _page->startInteractionWithElementAtPosition(_positionInformation.point);
+ _page->startInteractionWithElementAtPosition(_positionInformation.request.point);
// Treat animated images like a link preview
if (isValidURLForImagePreview && _positionInformation.isAnimatedImage) {
- RetainPtr<_WKActivatedElementInfo> animatedImageElementInfo = adoptNS([[_WKActivatedElementInfo alloc] _initWithType:_WKActivatedElementTypeImage URL:targetURL location:_positionInformation.point title:_positionInformation.title ID:_positionInformation.idAttribute rect:_positionInformation.bounds image:_positionInformation.image.get()]);
+ RetainPtr<_WKActivatedElementInfo> animatedImageElementInfo = adoptNS([[_WKActivatedElementInfo alloc] _initWithType:_WKActivatedElementTypeImage URL:targetURL location:_positionInformation.request.point title:_positionInformation.title ID:_positionInformation.idAttribute rect:_positionInformation.bounds image:_positionInformation.image.get()]);
if ([uiDelegate respondsToSelector:@selector(_webView:previewViewControllerForAnimatedImageAtURL:defaultActions:elementInfo:imageSize:)]) {
RetainPtr<NSArray> actions = [_actionSheetAssistant defaultActionsForImageSheet:animatedImageElementInfo.get()];
@@ -4054,7 +4098,7 @@
}
}
- RetainPtr<_WKActivatedElementInfo> elementInfo = adoptNS([[_WKActivatedElementInfo alloc] _initWithType:_WKActivatedElementTypeLink URL:targetURL location:_positionInformation.point title:_positionInformation.title ID:_positionInformation.idAttribute rect:_positionInformation.bounds image:_positionInformation.image.get()]);
+ RetainPtr<_WKActivatedElementInfo> elementInfo = adoptNS([[_WKActivatedElementInfo alloc] _initWithType:_WKActivatedElementTypeLink URL:targetURL location:_positionInformation.request.point title:_positionInformation.title ID:_positionInformation.idAttribute rect:_positionInformation.bounds image:_positionInformation.image.get()]);
auto actions = [_actionSheetAssistant defaultActionsForLinkSheet:elementInfo.get()];
if ([uiDelegate respondsToSelector:@selector(webView:previewingViewControllerForElement:defaultActions:)]) {
@@ -4082,8 +4126,8 @@
if (!isValidURLForImagePreview)
return nil;
- RetainPtr<_WKActivatedElementInfo> elementInfo = adoptNS([[_WKActivatedElementInfo alloc] _initWithType:_WKActivatedElementTypeImage URL:targetURL location:_positionInformation.point title:_positionInformation.title ID:_positionInformation.idAttribute rect:_positionInformation.bounds image:_positionInformation.image.get()]);
- _page->startInteractionWithElementAtPosition(_positionInformation.point);
+ RetainPtr<_WKActivatedElementInfo> elementInfo = adoptNS([[_WKActivatedElementInfo alloc] _initWithType:_WKActivatedElementTypeImage URL:targetURL location:_positionInformation.request.point title:_positionInformation.title ID:_positionInformation.idAttribute rect:_positionInformation.bounds image:_positionInformation.image.get()]);
+ _page->startInteractionWithElementAtPosition(_positionInformation.request.point);
if ([uiDelegate respondsToSelector:@selector(_webView:willPreviewImageWithURL:)])
[uiDelegate _webView:_webView willPreviewImageWithURL:targetURL];
Modified: trunk/Source/WebKit2/UIProcess/ios/WKPDFView.mm (209404 => 209405)
--- trunk/Source/WebKit2/UIProcess/ios/WKPDFView.mm 2016-12-06 17:58:39 UTC (rev 209404)
+++ trunk/Source/WebKit2/UIProcess/ios/WKPDFView.mm 2016-12-06 18:24:28 UTC (rev 209405)
@@ -690,8 +690,9 @@
if (!url)
return;
+ _positionInformation.request.point = roundedIntPoint([controller.pageView convertPoint:point toView:self]);
+
_positionInformation.url = ""
- _positionInformation.point = roundedIntPoint([controller.pageView convertPoint:point toView:self]);
_positionInformation.bounds = roundedIntRect([self convertRect:[controller.pageView convertRectFromPDFPageSpace:annotation.Rect] fromView:controller.pageView]);
[self _highlightLinkAnnotation:linkAnnotation forDuration:.75 completionHandler:^{
Modified: trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm (209404 => 209405)
--- trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm 2016-12-06 17:58:39 UTC (rev 209404)
+++ trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm 2016-12-06 18:24:28 UTC (rev 209405)
@@ -628,14 +628,14 @@
m_pageClient.positionInformationDidChange(info);
}
-void WebPageProxy::getPositionInformation(const WebCore::IntPoint& point, InteractionInformationAtPosition& info)
+void WebPageProxy::getPositionInformation(const InteractionInformationRequest& request, InteractionInformationAtPosition& info)
{
- m_process->sendSync(Messages::WebPage::GetPositionInformation(point), Messages::WebPage::GetPositionInformation::Reply(info), m_pageID);
+ m_process->sendSync(Messages::WebPage::GetPositionInformation(request), Messages::WebPage::GetPositionInformation::Reply(info), m_pageID);
}
-void WebPageProxy::requestPositionInformation(const WebCore::IntPoint& point)
+void WebPageProxy::requestPositionInformation(const InteractionInformationRequest& request)
{
- m_process->send(Messages::WebPage::RequestPositionInformation(point), m_pageID);
+ m_process->send(Messages::WebPage::RequestPositionInformation(request), m_pageID);
}
void WebPageProxy::startInteractionWithElementAtPosition(const WebCore::IntPoint& point)
Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (209404 => 209405)
--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj 2016-12-06 17:58:39 UTC (rev 209404)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj 2016-12-06 18:24:28 UTC (rev 209405)
@@ -628,6 +628,8 @@
2D429BFD1721E2C700EC681F /* PDFPluginPasswordField.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D429BFB1721E2BA00EC681F /* PDFPluginPasswordField.mm */; };
2D47B56C1810714E003A3AEE /* RemoteLayerBackingStore.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D47B56A1810714E003A3AEE /* RemoteLayerBackingStore.mm */; };
2D47B56D1810714E003A3AEE /* RemoteLayerBackingStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D47B56B1810714E003A3AEE /* RemoteLayerBackingStore.h */; };
+ 2D4D2C811DF60BF3002EB10C /* InteractionInformationRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D4D2C7F1DF60BF3002EB10C /* InteractionInformationRequest.h */; };
+ 2D4D2C821DF60BF3002EB10C /* InteractionInformationRequest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D4D2C801DF60BF3002EB10C /* InteractionInformationRequest.cpp */; };
2D50365E1BCC793F00E20BB3 /* NativeWebGestureEventMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2D50365D1BCC793F00E20BB3 /* NativeWebGestureEventMac.mm */; };
2D50366B1BCDE17900E20BB3 /* NativeWebGestureEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D50366A1BCDE17900E20BB3 /* NativeWebGestureEvent.h */; };
2D5036751BCED19F00E20BB3 /* WebGestureEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D5036731BCED19F00E20BB3 /* WebGestureEvent.cpp */; };
@@ -2697,6 +2699,8 @@
2D429BFB1721E2BA00EC681F /* PDFPluginPasswordField.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = PDFPluginPasswordField.mm; path = PDF/PDFPluginPasswordField.mm; sourceTree = "<group>"; };
2D47B56A1810714E003A3AEE /* RemoteLayerBackingStore.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RemoteLayerBackingStore.mm; sourceTree = "<group>"; };
2D47B56B1810714E003A3AEE /* RemoteLayerBackingStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteLayerBackingStore.h; sourceTree = "<group>"; };
+ 2D4D2C7F1DF60BF3002EB10C /* InteractionInformationRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = InteractionInformationRequest.h; path = ios/InteractionInformationRequest.h; sourceTree = "<group>"; };
+ 2D4D2C801DF60BF3002EB10C /* InteractionInformationRequest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = InteractionInformationRequest.cpp; path = ios/InteractionInformationRequest.cpp; sourceTree = "<group>"; };
2D50365D1BCC793F00E20BB3 /* NativeWebGestureEventMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NativeWebGestureEventMac.mm; sourceTree = "<group>"; };
2D50366A1BCDE17900E20BB3 /* NativeWebGestureEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NativeWebGestureEvent.h; sourceTree = "<group>"; };
2D5036731BCED19F00E20BB3 /* WebGestureEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebGestureEvent.cpp; sourceTree = "<group>"; };
@@ -5038,6 +5042,8 @@
2DA9449D1884E4F000ED86DB /* GestureTypes.h */,
C5BCE5DA1C50761D00CDE3FA /* InteractionInformationAtPosition.h */,
C5BCE5DB1C50761D00CDE3FA /* InteractionInformationAtPosition.mm */,
+ 2D4D2C7F1DF60BF3002EB10C /* InteractionInformationRequest.h */,
+ 2D4D2C801DF60BF3002EB10C /* InteractionInformationRequest.cpp */,
2DA944971884E4F000ED86DB /* NativeWebKeyboardEventIOS.mm */,
2DA944981884E4F000ED86DB /* NativeWebTouchEventIOS.mm */,
A118A9EC1907AD6F00F7C92B /* QuickLookDocumentData.cpp */,
@@ -7934,6 +7940,7 @@
2DAF06D618BD1A470081CEB1 /* SmartMagnificationController.h in Headers */,
2DE6943E18BD2A68005C15E5 /* SmartMagnificationControllerMessages.h in Headers */,
5272B28B1406985D0096A5D0 /* StatisticsData.h in Headers */,
+ 2D4D2C811DF60BF3002EB10C /* InteractionInformationRequest.h in Headers */,
514BDED316C98EDD00E4E25E /* StatisticsRequest.h in Headers */,
1AD3306F16B1D991004F60E7 /* StorageAreaImpl.h in Headers */,
1ACECD2517162DB1001FC9EF /* StorageAreaMap.h in Headers */,
@@ -9186,6 +9193,7 @@
51E35209180F5D6B00E53BE9 /* DatabaseServiceEntryPoint.mm in Sources */,
51E35200180F5D0F00E53BE9 /* DatabaseToWebProcessConnection.cpp in Sources */,
51032F1D180F791700961BB7 /* DatabaseToWebProcessConnectionMessageReceiver.cpp in Sources */,
+ 2D4D2C821DF60BF3002EB10C /* InteractionInformationRequest.cpp in Sources */,
C55F91701C595F630029E92D /* DataDetectionResult.mm in Sources */,
1AC7537F183BE50F0072CB15 /* DataReference.cpp in Sources */,
BC032DA510F437D10058C15A /* Decoder.cpp in Sources */,
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (209404 => 209405)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h 2016-12-06 17:58:39 UTC (rev 209404)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h 2016-12-06 18:24:28 UTC (rev 209405)
@@ -197,6 +197,7 @@
struct EditorState;
class GamepadData;
struct InteractionInformationAtPosition;
+struct InteractionInformationRequest;
struct LoadParameters;
struct PrintInfo;
struct WebPageCreationParameters;
@@ -561,8 +562,8 @@
void syncApplyAutocorrection(const String& correction, const String& originalText, bool& correctionApplied);
void requestAutocorrectionContext(uint64_t callbackID);
void getAutocorrectionContext(String& beforeText, String& markedText, String& selectedText, String& afterText, uint64_t& location, uint64_t& length);
- void getPositionInformation(const WebCore::IntPoint&, InteractionInformationAtPosition&);
- void requestPositionInformation(const WebCore::IntPoint&);
+ void getPositionInformation(const InteractionInformationRequest&, InteractionInformationAtPosition&);
+ void requestPositionInformation(const InteractionInformationRequest&);
void startInteractionWithElementAtPosition(const WebCore::IntPoint&);
void stopInteraction();
void performActionOnElement(uint32_t action);
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in (209404 => 209405)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in 2016-12-06 17:58:39 UTC (rev 209404)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in 2016-12-06 18:24:28 UTC (rev 209405)
@@ -76,8 +76,8 @@
SyncApplyAutocorrection(String correction, String originalText) -> (bool autocorrectionApplied)
RequestAutocorrectionContext(uint64_t callbackID)
GetAutocorrectionContext() -> (String beforeContext, String markedText, String selectedText, String afterContext, uint64_t location, uint64_t length)
- GetPositionInformation(WebCore::IntPoint point) -> (struct WebKit::InteractionInformationAtPosition information)
- RequestPositionInformation(WebCore::IntPoint point)
+ GetPositionInformation(struct WebKit::InteractionInformationRequest request) -> (struct WebKit::InteractionInformationAtPosition information)
+ RequestPositionInformation(struct WebKit::InteractionInformationRequest request)
StartInteractionWithElementAtPosition(WebCore::IntPoint point)
StopInteraction()
PerformActionOnElement(uint32_t action)
Modified: trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm (209404 => 209405)
--- trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm 2016-12-06 17:58:39 UTC (rev 209404)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm 2016-12-06 18:24:28 UTC (rev 209405)
@@ -598,7 +598,8 @@
if (!frameRespondingToClick || lastLayerTreeTransactionId < WebFrame::fromCoreFrame(*frameRespondingToClick)->firstLayerTreeTransactionIDAfterDidCommitLoad())
send(Messages::WebPageProxy::DidNotHandleTapAsClick(adjustedIntPoint));
else if (is<Element>(*nodeRespondingToClick) && DataDetection::shouldCancelDefaultAction(downcast<Element>(*nodeRespondingToClick))) {
- requestPositionInformation(adjustedIntPoint);
+ InteractionInformationRequest request(adjustedIntPoint);
+ requestPositionInformation(request);
send(Messages::WebPageProxy::DidNotHandleTapAsClick(adjustedIntPoint));
} else
handleSyntheticClick(nodeRespondingToClick, adjustedPoint);
@@ -658,7 +659,8 @@
}
sendTapHighlightForNodeIfNecessary(requestID, nodeRespondingToClick);
if (is<Element>(*nodeRespondingToClick) && DataDetection::shouldCancelDefaultAction(downcast<Element>(*nodeRespondingToClick))) {
- requestPositionInformation(roundedIntPoint(adjustedPoint));
+ InteractionInformationRequest request(roundedIntPoint(adjustedPoint));
+ requestPositionInformation(request);
send(Messages::WebPageProxy::DidNotHandleTapAsClick(roundedIntPoint(adjustedPoint)));
} else
completeSyntheticClick(nodeRespondingToClick, adjustedPoint, WebCore::TwoFingerTap);
@@ -692,7 +694,8 @@
if (m_potentialTapNode == nodeRespondingToClick) {
if (is<Element>(*nodeRespondingToClick) && DataDetection::shouldCancelDefaultAction(downcast<Element>(*nodeRespondingToClick))) {
- requestPositionInformation(roundedIntPoint(m_potentialTapLocation));
+ InteractionInformationRequest request(roundedIntPoint(m_potentialTapLocation));
+ requestPositionInformation(request);
commitPotentialTapFailed();
} else
handleSyntheticClick(nodeRespondingToClick, adjustedPoint);
@@ -2274,12 +2277,13 @@
return nullptr;
}
-void WebPage::getPositionInformation(const IntPoint& point, InteractionInformationAtPosition& info)
+void WebPage::getPositionInformation(const InteractionInformationRequest& request, InteractionInformationAtPosition& info)
{
+ info.request = request;
+
FloatPoint adjustedPoint;
- Node* hitNode = m_page->mainFrame().nodeRespondingToClickEvents(point, adjustedPoint);
+ Node* hitNode = m_page->mainFrame().nodeRespondingToClickEvents(request.point, adjustedPoint);
- info.point = point;
info.nodeAtPositionIsAssistedNode = (hitNode == m_assistedNode);
if (m_assistedNode) {
const Frame& frame = m_page->focusController().focusedOrMainFrame();
@@ -2287,7 +2291,7 @@
const uint32_t kHitAreaWidth = 66;
const uint32_t kHitAreaHeight = 66;
FrameView& view = *frame.view();
- IntPoint adjustedPoint(view.rootViewToContents(point));
+ IntPoint adjustedPoint(view.rootViewToContents(request.point));
IntPoint constrainedPoint = m_assistedNode ? constrainPoint(adjustedPoint, frame, *m_assistedNode) : adjustedPoint;
VisiblePosition position = frame.visiblePositionForPoint(constrainedPoint);
@@ -2297,9 +2301,9 @@
else if (position > compositionRange->endPosition())
position = compositionRange->endPosition();
IntRect caretRect = view.contentsToRootView(position.absoluteCaretBounds());
- float deltaX = abs(caretRect.x() + (caretRect.width() / 2) - point.x());
- float deltaYFromTheTop = abs(caretRect.y() - point.y());
- float deltaYFromTheBottom = abs(caretRect.y() + caretRect.height() - point.y());
+ float deltaX = abs(caretRect.x() + (caretRect.width() / 2) - request.point.x());
+ float deltaYFromTheTop = abs(caretRect.y() - request.point.y());
+ float deltaYFromTheBottom = abs(caretRect.y() + caretRect.height() - request.point.y());
info.isNearMarkedText = !(deltaX > kHitAreaWidth || deltaYFromTheTop > kHitAreaHeight || deltaYFromTheBottom > kHitAreaHeight);
}
@@ -2323,20 +2327,26 @@
if (linkElement) {
info.isLink = true;
- // Ensure that the image contains at most 600K pixels, so that it is not too big.
- if (RefPtr<WebImage> snapshot = snapshotNode(*element, SnapshotOptionsShareable, 600 * 1024))
- info.image = snapshot->bitmap();
+ if (request.includeSnapshot) {
+ // Ensure that the image contains at most 600K pixels, so that it is not too big.
+ if (RefPtr<WebImage> snapshot = snapshotNode(*element, SnapshotOptionsShareable, 600 * 1024))
+ info.image = snapshot->bitmap();
+ }
- RefPtr<Range> linkRange = rangeOfContents(*linkElement);
- if (linkRange) {
- float deviceScaleFactor = corePage()->deviceScaleFactor();
- const float marginInPoints = 4;
+ if (request.includeLinkIndicator) {
+ RefPtr<Range> linkRange = rangeOfContents(*linkElement);
+ if (linkRange) {
+ float deviceScaleFactor = corePage()->deviceScaleFactor();
+ const float marginInPoints = 4;
- RefPtr<TextIndicator> textIndicator = TextIndicator::createWithRange(*linkRange, TextIndicatorOptionTightlyFitContent | TextIndicatorOptionRespectTextColor | TextIndicatorOptionPaintBackgrounds | TextIndicatorOptionUseBoundingRectAndPaintAllContentForComplexRanges |
- TextIndicatorOptionIncludeMarginIfRangeMatchesSelection, TextIndicatorPresentationTransition::None, FloatSize(marginInPoints * deviceScaleFactor, marginInPoints * deviceScaleFactor));
- if (textIndicator)
- info.linkIndicator = textIndicator->data();
+ RefPtr<TextIndicator> textIndicator = TextIndicator::createWithRange(*linkRange, TextIndicatorOptionTightlyFitContent | TextIndicatorOptionRespectTextColor | TextIndicatorOptionPaintBackgrounds | TextIndicatorOptionUseBoundingRectAndPaintAllContentForComplexRanges |
+ TextIndicatorOptionIncludeMarginIfRangeMatchesSelection, TextIndicatorPresentationTransition::None, FloatSize(marginInPoints * deviceScaleFactor, marginInPoints * deviceScaleFactor));
+
+ if (textIndicator)
+ info.linkIndicator = textIndicator->data();
+ }
}
+
#if ENABLE(DATA_DETECTION)
info.isDataDetectorLink = DataDetection::isDataDetectorLink(*element);
if (info.isDataDetectorLink) {
@@ -2400,7 +2410,7 @@
}
if (!elementIsLinkOrImage) {
- HitTestResult result = m_page->mainFrame().eventHandler().hitTestResultAtPoint((point), HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::DisallowUserAgentShadowContent | HitTestRequest::AllowChildFrameContent);
+ HitTestResult result = m_page->mainFrame().eventHandler().hitTestResultAtPoint(request.point, HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::DisallowUserAgentShadowContent | HitTestRequest::AllowChildFrameContent);
hitNode = result.innerNode();
// Hit test could return HTMLHtmlElement that has no renderer, if the body is smaller than the document.
if (hitNode && hitNode->renderer()) {
@@ -2423,11 +2433,11 @@
}
}
-void WebPage::requestPositionInformation(const IntPoint& point)
+void WebPage::requestPositionInformation(const InteractionInformationRequest& request)
{
InteractionInformationAtPosition info;
- getPositionInformation(point, info);
+ getPositionInformation(request, info);
send(Messages::WebPageProxy::DidReceivePositionInformation(info));
}