Diff
Modified: trunk/Source/WebCore/ChangeLog (212341 => 212342)
--- trunk/Source/WebCore/ChangeLog 2017-02-15 03:06:42 UTC (rev 212341)
+++ trunk/Source/WebCore/ChangeLog 2017-02-15 05:05:47 UTC (rev 212342)
@@ -1,3 +1,34 @@
+2017-02-14 Wenson Hsieh <[email protected]>
+
+ [WK2] Support data interaction on links
+ https://bugs.webkit.org/show_bug.cgi?id=168331
+ <rdar://problem/30200837>
+
+ Reviewed by Tim Horton.
+
+ Adds support for data interaction on links at the WebCore layer, refactoring some drag-and-drop code on the Mac
+ along the way. Also adds two new TestWebKitAPI unit tests in DataInteractionTests.mm: LinkToInput and
+ BackgroundImageLinkToInput (see Tools/ChangeLog for more information).
+
+ * page/DragController.cpp:
+ (WebCore::DragController::startDrag):
+ (WebCore::DragController::doImageDrag):
+ (WebCore::DragController::doSystemDrag):
+
+ Introduce platformAdjustDragImageForDeviceScaleFactor, and special-case drag images for links to anchor at the
+ bottom center.
+
+ * platform/DragImage.cpp:
+ (WebCore::platformAdjustDragImageForDeviceScaleFactor):
+
+ Scale the drag image up by the device scale factor. In WebDragClient, we scale the image back down to the
+ original size. It seems the reason we do this extra dance is because the image sizing heuristic in between
+ assumes that the image dimensions are for a non-retina device, but this work should really not be necessary if
+ we tweak the heuristic to account for deviceScaleFactor. We should address this in a separate patch.
+
+ * platform/DragImage.h:
+ * platform/graphics/Path.h:
+
2017-02-14 Basuke Suzuki <[email protected]>
[CURL] ResourceError created with error information should have default type Type::General
Modified: trunk/Source/WebCore/page/DragController.cpp (212341 => 212342)
--- trunk/Source/WebCore/page/DragController.cpp 2017-02-15 03:06:42 UTC (rev 212341)
+++ trunk/Source/WebCore/page/DragController.cpp 2017-02-15 05:05:47 UTC (rev 212342)
@@ -921,8 +921,7 @@
IntSize size = dragImageSize(dragImage.get());
m_dragOffset = IntPoint(-size.width() / 2, -LinkDragBorderInset);
dragLoc = IntPoint(mouseDraggedPoint.x() + m_dragOffset.x(), mouseDraggedPoint.y() + m_dragOffset.y());
- // Later code expects the drag image to be scaled by device's scale factor.
- dragImage = DragImage { scaleDragImage(dragImage.get(), FloatSize(m_page.deviceScaleFactor(), m_page.deviceScaleFactor())) };
+ dragImage = DragImage { platformAdjustDragImageForDeviceScaleFactor(dragImage.get(), m_page.deviceScaleFactor()) };
}
doSystemDrag(WTFMove(dragImage), dragLoc, mouseDraggedPoint, { }, dataTransfer, src, true);
@@ -977,7 +976,7 @@
dragImage = DragImage { fitDragImageToMaxSize(dragImage.get(), layoutRect.size(), maxDragImageSize()) };
IntSize fittedSize = dragImageSize(dragImage.get());
- dragImage = DragImage { scaleDragImage(dragImage.get(), FloatSize(m_page.deviceScaleFactor(), m_page.deviceScaleFactor())) };
+ dragImage = DragImage { platformAdjustDragImageForDeviceScaleFactor(dragImage.get(), m_page.deviceScaleFactor()) };
dragImage = DragImage { dissolveDragImageToFraction(dragImage.get(), DragImageAlpha) };
// Properly orient the drag image and orient it differently if it's smaller than the original.
@@ -1008,7 +1007,9 @@
void DragController::doSystemDrag(DragImage image, const IntPoint& dragLoc, const IntPoint& eventPos, const IntRect& dragImageBounds, DataTransfer& dataTransfer, Frame& frame, bool forLink)
{
FloatPoint dragImageAnchor = { 0.5, 0.5 };
- if (!dragImageBounds.isEmpty()) {
+ if (forLink)
+ dragImageAnchor.setY(1);
+ else if (!dragImageBounds.isEmpty()) {
dragImageAnchor.setX((eventPos.x() - dragImageBounds.x()) / (float)dragImageBounds.width());
dragImageAnchor.setY((eventPos.y() - dragImageBounds.y()) / (float)dragImageBounds.height());
}
Modified: trunk/Source/WebCore/platform/DragImage.cpp (212341 => 212342)
--- trunk/Source/WebCore/platform/DragImage.cpp 2017-02-15 03:06:42 UTC (rev 212341)
+++ trunk/Source/WebCore/platform/DragImage.cpp 2017-02-15 05:05:47 UTC (rev 212342)
@@ -210,6 +210,14 @@
return createDragImageFromSnapshot(snapshotNode(frame, node), &node);
}
+#if !ENABLE(DATA_INTERACTION)
+DragImageRef platformAdjustDragImageForDeviceScaleFactor(DragImageRef image, float deviceScaleFactor)
+{
+ // Later code expects the drag image to be scaled by device's scale factor.
+ return scaleDragImage(image, { deviceScaleFactor, deviceScaleFactor });
+}
+#endif
+
#if !PLATFORM(COCOA) && !PLATFORM(WIN)
DragImageRef createDragImageForLink(URL&, const String&, FontRenderingMode)
{
Modified: trunk/Source/WebCore/platform/DragImage.h (212341 => 212342)
--- trunk/Source/WebCore/platform/DragImage.h 2017-02-15 03:06:42 UTC (rev 212341)
+++ trunk/Source/WebCore/platform/DragImage.h 2017-02-15 05:05:47 UTC (rev 212342)
@@ -78,6 +78,7 @@
// the input image ref will still be valid after they have been called.
DragImageRef fitDragImageToMaxSize(DragImageRef, const IntSize& srcSize, const IntSize& dstSize);
DragImageRef scaleDragImage(DragImageRef, FloatSize scale);
+DragImageRef platformAdjustDragImageForDeviceScaleFactor(DragImageRef, float deviceScaleFactor);
DragImageRef dissolveDragImageToFraction(DragImageRef, float delta);
DragImageRef createDragImageFromImage(Image*, ImageOrientationDescription);
Modified: trunk/Source/WebCore/platform/graphics/Path.h (212341 => 212342)
--- trunk/Source/WebCore/platform/graphics/Path.h 2017-02-15 03:06:42 UTC (rev 212341)
+++ trunk/Source/WebCore/platform/graphics/Path.h 2017-02-15 05:05:47 UTC (rev 212342)
@@ -122,7 +122,7 @@
// fastBoundingRect() should equal or contain boundingRect(); boundingRect()
// should perfectly bound the points within the path.
FloatRect boundingRect() const;
- FloatRect fastBoundingRect() const;
+ WEBCORE_EXPORT FloatRect fastBoundingRect() const;
FloatRect strokeBoundingRect(StrokeStyleApplier* = 0) const;
float length() const;
Modified: trunk/Source/WebKit2/ChangeLog (212341 => 212342)
--- trunk/Source/WebKit2/ChangeLog 2017-02-15 03:06:42 UTC (rev 212341)
+++ trunk/Source/WebKit2/ChangeLog 2017-02-15 05:05:47 UTC (rev 212342)
@@ -1,3 +1,60 @@
+2017-02-14 Wenson Hsieh <[email protected]>
+
+ [WK2] Support data interaction on links
+ https://bugs.webkit.org/show_bug.cgi?id=168331
+ <rdar://problem/30200837>
+
+ Reviewed by Tim Horton.
+
+ Adds support for data interaction on links at the client layer for WebKit2. This involves several changes,
+ detailed in the per-method changes below:
+
+ * Shared/ios/InteractionInformationAtPosition.h:
+ * Shared/ios/InteractionInformationAtPosition.mm:
+ (WebKit::InteractionInformationAtPosition::encode):
+ (WebKit::InteractionInformationAtPosition::decode):
+
+ Add adjustedPointForNodeRespondingToClickEvents (the request point, adjusted to take nodeRespondingToClickEvents
+ into account) to InteractionInformationAtPosition. The web process sends this adjusted point over to the UI
+ process so that the UI process will be able to begin a data interaction at the adjusted point rather than the
+ request point, which is necessary for small clickable (and data-interactive) elements such as links.
+
+ * UIProcess/ios/WKActionSheet.h:
+ * UIProcess/ios/WKActionSheet.mm:
+ (-[WKActionSheet presentSheet:]):
+ (-[WKActionSheet _presentationRectForStyle:]):
+ (-[WKActionSheet updateSheetPosition]):
+ * UIProcess/ios/WKActionSheetAssistant.h:
+ * UIProcess/ios/WKActionSheetAssistant.mm:
+ (-[WKActionSheetAssistant presentationRectForElementUsingClosestIndicatedRect]):
+ (-[WKActionSheetAssistant presentationRectForIndicatedElement]):
+ (-[WKActionSheetAssistant showImageSheet]):
+ (-[WKActionSheetAssistant _shouldPresentAtTouchLocationForElementRect:]):
+ (-[WKActionSheetAssistant needsLinkIndicator]):
+ (-[WKActionSheetAssistant showLinkSheet]):
+ (-[WKActionSheetAssistant cleanupSheet]):
+ (-[WKActionSheetAssistant _presentationStyleForImageAtElementRect:]): Deleted.
+
+ Add support for the WKActionSheetPresentAtClosestIndicatorRect style of presenting an action sheet. When
+ showing the action sheet for a link and there is space along the margins to show a popover in the first place,
+ we will now target the popover rect to the bounding rect of the set of adjacent (or nearly-adjacent) element
+ rects closest to the user's touch location. This covers cases where the link is split into multiple rects due to
+ a line break, when the link is on multiple lines with a jagged rect per line, and when both of the above are
+ true.
+
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (-[WKContentView pointIsInDataInteractionContent:]):
+ (-[WKContentView _positionInformationDidChange:]):
+ (-[WKContentView positionInformationForActionSheetAssistant:]):
+ (-[WKContentView updatePositionInformationForActionSheetAssistant:]):
+
+ Include link indicator data in the position information request if needed. As the FIXME suggests, this can be
+ improved by asynchronously presenting the action sheet assistant after the request returns, and is something we
+ should address in the future.
+
+ * WebProcess/WebPage/ios/WebPageIOS.mm:
+ (WebKit::WebPage::getPositionInformation):
+
2017-02-14 Jason Rinn <[email protected]>
Add new WKWebKit Cocoa API for getContentsAsString.
Modified: trunk/Source/WebKit2/Shared/ios/InteractionInformationAtPosition.h (212341 => 212342)
--- trunk/Source/WebKit2/Shared/ios/InteractionInformationAtPosition.h 2017-02-15 03:06:42 UTC (rev 212341)
+++ trunk/Source/WebKit2/Shared/ios/InteractionInformationAtPosition.h 2017-02-15 05:05:47 UTC (rev 212342)
@@ -55,6 +55,7 @@
#if ENABLE(DATA_DETECTION)
bool isDataDetectorLink { false };
#endif
+ WebCore::FloatPoint adjustedPointForNodeRespondingToClickEvents;
String url;
String imageURL;
String title;
Modified: trunk/Source/WebKit2/Shared/ios/InteractionInformationAtPosition.mm (212341 => 212342)
--- trunk/Source/WebKit2/Shared/ios/InteractionInformationAtPosition.mm 2017-02-15 03:06:42 UTC (rev 212341)
+++ trunk/Source/WebKit2/Shared/ios/InteractionInformationAtPosition.mm 2017-02-15 05:05:47 UTC (rev 212342)
@@ -54,6 +54,7 @@
encoder << isAttachment;
encoder << isAnimatedImage;
encoder << isElement;
+ encoder << adjustedPointForNodeRespondingToClickEvents;
encoder << url;
encoder << imageURL;
encoder << title;
@@ -119,6 +120,9 @@
if (!decoder.decode(result.isElement))
return false;
+ if (!decoder.decode(result.adjustedPointForNodeRespondingToClickEvents))
+ return false;
+
if (!decoder.decode(result.url))
return false;
Modified: trunk/Source/WebKit2/UIProcess/ios/WKActionSheet.h (212341 => 212342)
--- trunk/Source/WebKit2/UIProcess/ios/WKActionSheet.h 2017-02-15 03:06:42 UTC (rev 212341)
+++ trunk/Source/WebKit2/UIProcess/ios/WKActionSheet.h 2017-02-15 05:05:47 UTC (rev 212342)
@@ -30,7 +30,8 @@
typedef NS_ENUM(NSInteger, WKActionSheetPresentationStyle) {
WKActionSheetPresentAtTouchLocation,
- WKActionSheetPresentAtElementRect
+ WKActionSheetPresentAtElementRect,
+ WKActionSheetPresentAtClosestIndicatorRect
};
@protocol WKActionSheetDelegate;
@@ -51,6 +52,7 @@
- (UIView *)hostViewForSheet;
- (CGRect)initialPresentationRectInHostViewForSheet;
- (CGRect)presentationRectForIndicatedElement;
+- (CGRect)presentationRectForElementUsingClosestIndicatedRect;
- (CGRect)presentationRectInHostViewForSheet;
- (void)updatePositionInformation;
@end
Modified: trunk/Source/WebKit2/UIProcess/ios/WKActionSheet.mm (212341 => 212342)
--- trunk/Source/WebKit2/UIProcess/ios/WKActionSheet.mm 2017-02-15 03:06:42 UTC (rev 212341)
+++ trunk/Source/WebKit2/UIProcess/ios/WKActionSheet.mm 2017-02-15 05:05:47 UTC (rev 212342)
@@ -76,7 +76,7 @@
// Calculate the presentation rect just before showing.
CGRect presentationRect = CGRectZero;
if (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPhone) {
- presentationRect = style == WKActionSheetPresentAtElementRect ? [_sheetDelegate presentationRectForIndicatedElement] : [_sheetDelegate initialPresentationRectInHostViewForSheet];
+ presentationRect = [self _presentationRectForStyle:style];
if (CGRectIsEmpty(presentationRect))
return NO;
}
@@ -85,6 +85,17 @@
return [self presentSheetFromRect:presentationRect];
}
+- (CGRect)_presentationRectForStyle:(WKActionSheetPresentationStyle)style
+{
+ if (style == WKActionSheetPresentAtElementRect)
+ return [_sheetDelegate presentationRectForIndicatedElement];
+
+ if (style == WKActionSheetPresentAtClosestIndicatorRect)
+ return [_sheetDelegate presentationRectForElementUsingClosestIndicatedRect];
+
+ return [_sheetDelegate initialPresentationRectInHostViewForSheet];
+}
+
- (BOOL)presentSheetFromRect:(CGRect)presentationRect
{
UIView *view = [_sheetDelegate hostViewForSheet];
@@ -196,7 +207,7 @@
if (_isRotating || !_readyToPresentAfterRotation || isBeingPresented)
return;
- CGRect presentationRect = _currentPresentationStyle == WKActionSheetPresentAtElementRect ? [_sheetDelegate presentationRectForIndicatedElement] : [_sheetDelegate initialPresentationRectInHostViewForSheet];
+ CGRect presentationRect = [self _presentationRectForStyle:_currentPresentationStyle];
BOOL wasPresentedViewControllerModal = [_presentedViewControllerWhileRotating isModalInPopover];
if (!CGRectIsEmpty(presentationRect) || wasPresentedViewControllerModal) {
Modified: trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.h (212341 => 212342)
--- trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.h 2017-02-15 03:06:42 UTC (rev 212341)
+++ trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.h 2017-02-15 05:05:47 UTC (rev 212342)
@@ -63,6 +63,7 @@
@interface WKActionSheetAssistant : NSObject <WKActionSheetDelegate, DDDetectionControllerInteractionDelegate>
@property (nonatomic, weak) id <WKActionSheetAssistantDelegate> delegate;
+@property (nonatomic) BOOL needsLinkIndicator;
- (id)initWithView:(UIView *)view;
- (void)showLinkSheet;
- (void)showImageSheet;
Modified: trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.mm (212341 => 212342)
--- trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.mm 2017-02-15 03:06:42 UTC (rev 212341)
+++ trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.mm 2017-02-15 05:05:47 UTC (rev 212342)
@@ -41,6 +41,7 @@
#import "_WKElementActionInternal.h"
#import <UIKit/UIView.h>
#import <WebCore/LocalizedStrings.h>
+#import <WebCore/PathUtilities.h>
#import <WebCore/SoftLinking.h>
#import <WebCore/WebCoreNSURLExtras.h>
#import <wtf/text/WTFString.h>
@@ -88,6 +89,7 @@
RetainPtr<WKActionSheet> _interactionSheet;
RetainPtr<_WKActivatedElementInfo> _elementInfo;
UIView *_view;
+ BOOL _needsLinkIndicator;
}
- (id <WKActionSheetAssistantDelegate>)delegate
@@ -148,6 +150,38 @@
return [self superviewForSheet];
}
+static const CGFloat presentationElementRectPadding = 15;
+
+- (CGRect)presentationRectForElementUsingClosestIndicatedRect
+{
+ UIView *view = [self superviewForSheet];
+ auto delegate = _delegate.get();
+ if (!view || !delegate)
+ return CGRectZero;
+
+ auto info = [delegate positionInformationForActionSheetAssistant:self];
+ auto indicator = info.linkIndicator;
+ if (indicator.textRectsInBoundingRectCoordinates.isEmpty())
+ return CGRectZero;
+
+ WebCore::FloatPoint touchLocation = info.request.point;
+ WebCore::FloatPoint linkElementLocation = indicator.textBoundingRectInRootViewCoordinates.location();
+ Vector<WebCore::FloatRect> indicatedRects;
+ for (auto rect : indicator.textRectsInBoundingRectCoordinates) {
+ rect.inflate(2);
+ rect.moveBy(linkElementLocation);
+ indicatedRects.append(rect);
+ }
+
+ for (auto path : WebCore::PathUtilities::pathsWithShrinkWrappedRects(indicatedRects, 0)) {
+ auto boundingRect = path.fastBoundingRect();
+ if (boundingRect.contains(touchLocation))
+ return CGRectInset([view convertRect:(CGRect)boundingRect fromView:_view], -presentationElementRectPadding, -presentationElementRectPadding);
+ }
+
+ return CGRectZero;
+}
+
- (CGRect)presentationRectForIndicatedElement
{
UIView *view = [self superviewForSheet];
@@ -155,7 +189,6 @@
if (!view || !delegate)
return CGRectZero;
- static const CGFloat presentationElementRectPadding = 15;
auto elementBounds = [delegate positionInformationForActionSheetAssistant:self].bounds;
return CGRectInset([view convertRect:elementBounds fromView:_view], -presentationElementRectPadding, -presentationElementRectPadding);
}
@@ -318,11 +351,11 @@
_elementInfo = WTFMove(elementInfo);
- if (![_interactionSheet presentSheet:[self _presentationStyleForImageAtElementRect:elementBounds]])
+ if (![_interactionSheet presentSheet:[self _shouldPresentAtTouchLocationForElementRect:elementBounds] ? WKActionSheetPresentAtTouchLocation : WKActionSheetPresentAtElementRect])
[self cleanupSheet];
}
-- (WKActionSheetPresentationStyle)_presentationStyleForImageAtElementRect:(CGRect)elementRect
+- (BOOL)_shouldPresentAtTouchLocationForElementRect:(CGRect)elementRect
{
auto apparentElementRect = [_view convertRect:elementRect toView:_view.window];
auto windowRect = _view.window.bounds;
@@ -336,10 +369,7 @@
// If at least this much of the window is available for the popover to draw in, then target the element rect when presenting the action menu popover.
// Otherwise, there is not enough space to position the popover around the element, so revert to using the touch location instead.
static const CGFloat minimumAvailableWidthOrHeightRatio = 0.4;
- if (std::max(leftInset, rightInset) > minimumAvailableWidthOrHeightRatio * CGRectGetWidth(windowRect) || std::max(topInset, bottomInset) > minimumAvailableWidthOrHeightRatio * CGRectGetHeight(windowRect))
- return WKActionSheetPresentAtElementRect;
-
- return WKActionSheetPresentAtTouchLocation;
+ return std::max(leftInset, rightInset) <= minimumAvailableWidthOrHeightRatio * CGRectGetWidth(windowRect) && std::max(topInset, bottomInset) <= minimumAvailableWidthOrHeightRatio * CGRectGetHeight(windowRect);
}
- (void)_appendOpenActionsForURL:(NSURL *)url actions:(NSMutableArray *)defaultActions elementInfo:(_WKActivatedElementInfo *)elementInfo
@@ -426,6 +456,11 @@
return defaultActions;
}
+- (BOOL)needsLinkIndicator
+{
+ return _needsLinkIndicator;
+}
+
- (void)showLinkSheet
{
ASSERT(!_elementInfo);
@@ -434,30 +469,39 @@
if (!delegate)
return;
+ _needsLinkIndicator = YES;
const auto& positionInformation = [delegate positionInformationForActionSheetAssistant:self];
NSURL *targetURL = [NSURL _web_URLWithWTFString:positionInformation.url];
- if (!targetURL)
+ if (!targetURL) {
+ _needsLinkIndicator = NO;
return;
+ }
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()])
+ if ([delegate respondsToSelector:@selector(actionSheetAssistant:showCustomSheetForElement:)] && [delegate actionSheetAssistant:self showCustomSheetForElement:elementInfo.get()]) {
+ _needsLinkIndicator = NO;
return;
+ }
auto defaultActions = [self defaultActionsForLinkSheet:elementInfo.get()];
RetainPtr<NSArray> actions = [delegate actionSheetAssistant:self decideActionsForElement:elementInfo.get() defaultActions:WTFMove(defaultActions)];
- if (![actions count])
+ if (![actions count]) {
+ _needsLinkIndicator = NO;
return;
+ }
[self _createSheetWithElementActions:actions.get() showLinkTitle:YES];
- if (!_interactionSheet)
+ if (!_interactionSheet) {
+ _needsLinkIndicator = NO;
return;
+ }
_elementInfo = WTFMove(elementInfo);
- if (![_interactionSheet presentSheet:WKActionSheetPresentAtTouchLocation])
+ if (![_interactionSheet presentSheet:[self _shouldPresentAtTouchLocationForElementRect:positionInformation.bounds] ? WKActionSheetPresentAtTouchLocation : WKActionSheetPresentAtClosestIndicatorRect])
[self cleanupSheet];
}
@@ -533,6 +577,7 @@
[_interactionSheet setSheetDelegate:nil];
_interactionSheet = nil;
_elementInfo = nil;
+ _needsLinkIndicator = NO;
}
@end
Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (212341 => 212342)
--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm 2017-02-15 03:06:42 UTC (rev 212341)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm 2017-02-15 05:05:47 UTC (rev 212342)
@@ -1458,13 +1458,9 @@
InteractionInformationRequest request(roundedIntPoint(point));
[self ensurePositionInformationIsUpToDate:request];
- if (_positionInformation.isImage)
+ if (_positionInformation.isImage || _positionInformation.isLink)
return YES;
- // FIXME: Add support for links.
- if (_positionInformation.isLink)
- return NO;
-
return _positionInformation.hasDataInteractionAtPosition;
}
@@ -1757,6 +1753,10 @@
_hasValidPositionInformation = YES;
if (_actionSheetAssistant)
[_actionSheetAssistant updateSheetPosition];
+
+#if ENABLE(DATA_INTERACTION)
+ [self _updateDataInteractionPreviewSnapshotIfPossible];
+#endif
}
- (void)_willStartScrollingOrZooming
@@ -3957,6 +3957,7 @@
// FIXME: This should be more asynchronous, since we control the presentation of the action sheet.
InteractionInformationRequest request(_positionInformation.request.point);
request.includeSnapshot = true;
+ request.includeLinkIndicator = assistant.needsLinkIndicator;
[self ensurePositionInformationIsUpToDate:request];
return _positionInformation;
@@ -3967,6 +3968,7 @@
_hasValidPositionInformation = NO;
InteractionInformationRequest request(_positionInformation.request.point);
request.includeSnapshot = true;
+ request.includeLinkIndicator = assistant.needsLinkIndicator;
[self requestAsynchronousPositionInformationUpdate:request];
}
Modified: trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm (212341 => 212342)
--- trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm 2017-02-15 03:06:42 UTC (rev 212341)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm 2017-02-15 05:05:47 UTC (rev 212342)
@@ -2551,6 +2551,7 @@
#if ENABLE(DATA_INTERACTION)
info.hasDataInteractionAtPosition = m_page->hasDataInteractionAtPosition(adjustedPoint);
#endif
+ info.adjustedPointForNodeRespondingToClickEvents = adjustedPoint;
}
void WebPage::requestPositionInformation(const InteractionInformationRequest& request)
Modified: trunk/Tools/ChangeLog (212341 => 212342)
--- trunk/Tools/ChangeLog 2017-02-15 03:06:42 UTC (rev 212341)
+++ trunk/Tools/ChangeLog 2017-02-15 05:05:47 UTC (rev 212342)
@@ -1,3 +1,20 @@
+2017-02-14 Wenson Hsieh <[email protected]>
+
+ [WK2] Support data interaction on links
+ https://bugs.webkit.org/show_bug.cgi?id=168331
+ <rdar://problem/30200837>
+
+ Reviewed by Tim Horton.
+
+ Adds 2 unit tests checking that data interaction from a link (with or without a background image) into an
+ editable area results in the link URL being inserted.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebKit2Cocoa/background-image-link-and-input.html: Added.
+ * TestWebKitAPI/Tests/WebKit2Cocoa/link-and-input.html: Added.
+ * TestWebKitAPI/Tests/ios/DataInteractionTests.mm:
+ (TestWebKitAPI::TEST):
+
2017-02-14 Jason Rinn <[email protected]>
Add a test for new WebKit Cocoa API, _getContentsAsString.
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (212341 => 212342)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2017-02-15 03:06:42 UTC (rev 212341)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2017-02-15 05:05:47 UTC (rev 212342)
@@ -556,8 +556,10 @@
E194E1BD177E53C7009C4D4E /* StopLoadingFromDidReceiveResponse.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = E194E1BC177E534A009C4D4E /* StopLoadingFromDidReceiveResponse.html */; };
F415086D1DA040C50044BE9B /* play-audio-on-click.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F415086C1DA040C10044BE9B /* play-audio-on-click.html */; };
F42DA5161D8CEFE400336F40 /* large-input-field-focus-onload.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F42DA5151D8CEFDB00336F40 /* large-input-field-focus-onload.html */; };
+ F4355CF01E52198100900F64 /* background-image-link-and-input.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4355CEF1E52196100900F64 /* background-image-link-and-input.html */; };
F45B960C1E50708800CFAC5D /* autofocus-contenteditable.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F45B960B1E50708200CFAC5D /* autofocus-contenteditable.html */; };
F47728991E4AE3C1007ABF6A /* full-page-contenteditable.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F47728981E4AE3AD007ABF6A /* full-page-contenteditable.html */; };
+ F49C07AE1E51849500F6B01F /* link-and-input.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F49C07AD1E51849100F6B01F /* link-and-input.html */; };
F4BFA68E1E4AD08000154298 /* DragAndDropPasteboardTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4BFA68C1E4AD08000154298 /* DragAndDropPasteboardTests.mm */; };
F4C2AB221DD6D95E00E06D5B /* enormous-video-with-sound.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4C2AB211DD6D94100E06D5B /* enormous-video-with-sound.html */; };
F4D4F3B61E4E2BCB00BB2767 /* DataInteractionSimulator.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4D4F3B41E4E2BCB00BB2767 /* DataInteractionSimulator.mm */; };
@@ -638,6 +640,8 @@
files = (
C25CCA0D1E5141840026CB8A /* AllAhem.svg in Copy Resources */,
C25CCA0B1E5140C10026CB8A /* LineBreaking.html in Copy Resources */,
+ F4355CF01E52198100900F64 /* background-image-link-and-input.html in Copy Resources */,
+ F49C07AE1E51849500F6B01F /* link-and-input.html in Copy Resources */,
F45B960C1E50708800CFAC5D /* autofocus-contenteditable.html in Copy Resources */,
F4F93F341E4E918D00E33E2E /* image-and-textarea.html in Copy Resources */,
F4D4F3BC1E4E511F00BB2767 /* image-and-contenteditable.html in Copy Resources */,
@@ -1389,8 +1393,10 @@
F3FC3EE213678B7300126A65 /* libgtest.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libgtest.a; sourceTree = BUILT_PRODUCTS_DIR; };
F415086C1DA040C10044BE9B /* play-audio-on-click.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "play-audio-on-click.html"; sourceTree = "<group>"; };
F42DA5151D8CEFDB00336F40 /* large-input-field-focus-onload.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = "large-input-field-focus-onload.html"; path = "Tests/WebKit2Cocoa/large-input-field-focus-onload.html"; sourceTree = SOURCE_ROOT; };
+ F4355CEF1E52196100900F64 /* background-image-link-and-input.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = "background-image-link-and-input.html"; path = "Tests/WebKit2Cocoa/background-image-link-and-input.html"; sourceTree = SOURCE_ROOT; };
F45B960B1E50708200CFAC5D /* autofocus-contenteditable.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "autofocus-contenteditable.html"; sourceTree = "<group>"; };
F47728981E4AE3AD007ABF6A /* full-page-contenteditable.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "full-page-contenteditable.html"; sourceTree = "<group>"; };
+ F49C07AD1E51849100F6B01F /* link-and-input.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = "link-and-input.html"; path = "Tests/WebKit2Cocoa/link-and-input.html"; sourceTree = SOURCE_ROOT; };
F4BFA68C1E4AD08000154298 /* DragAndDropPasteboardTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DragAndDropPasteboardTests.mm; sourceTree = "<group>"; };
F4C2AB211DD6D94100E06D5B /* enormous-video-with-sound.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "enormous-video-with-sound.html"; sourceTree = "<group>"; };
F4D4F3B41E4E2BCB00BB2767 /* DataInteractionSimulator.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DataInteractionSimulator.mm; sourceTree = "<group>"; };
@@ -2054,6 +2060,8 @@
BC90977B125571AE00083756 /* Resources */ = {
isa = PBXGroup;
children = (
+ F4355CEF1E52196100900F64 /* background-image-link-and-input.html */,
+ F49C07AD1E51849100F6B01F /* link-and-input.html */,
C045F9461385C2F800C0F3CD /* 18-characters.html */,
1C2B81851C89252300A5529F /* Ahem.ttf */,
93D3D19B17B1A7B000C7C415 /* all-content-in-one-iframe.html */,
Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/background-image-link-and-input.html (0 => 212342)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/background-image-link-and-input.html (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/background-image-link-and-input.html 2017-02-15 05:05:47 UTC (rev 212342)
@@ -0,0 +1,41 @@
+<head>
+ <meta name="viewport" content="width=device-width">
+ <style>
+ body {
+ width: 100%;
+ height: 100%;
+ margin: 0;
+ }
+
+ a, #editor {
+ width: 100%;
+ height: 200px;
+ font-size: 200px;
+ white-space: nowrap;
+ }
+
+ a {
+ background-image: url(icon.png);
+ background-repeat: no-repeat;
+ display: block;
+ }
+
+ #editor {
+ border: black 1px solid;
+ }
+ </style>
+</head>
+
+<body>
+ <div><a href=""
+ <div><input id="editor"></input></div>
+ <script>
+ function postEventType(event) {
+ webkit.messageHandlers.testHandler.postMessage(event.type);
+ }
+
+ editor.addEventListener("drop", postEventType);
+ editor.addEventListener("dragenter", postEventType);
+ editor.addEventListener("dragover", postEventType);
+ </script>
+</body>
Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/link-and-input.html (0 => 212342)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/link-and-input.html (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/link-and-input.html 2017-02-15 05:05:47 UTC (rev 212342)
@@ -0,0 +1,35 @@
+<head>
+ <meta name="viewport" content="width=device-width">
+ <style>
+ body {
+ width: 100%;
+ height: 100%;
+ margin: 0;
+ }
+
+ a, #editor {
+ width: 100%;
+ height: 200px;
+ font-size: 200px;
+ white-space: nowrap;
+ }
+
+ #editor {
+ border: black 1px solid;
+ }
+ </style>
+</head>
+
+<body>
+ <div><a href="" world</a></div>
+ <div><input id="editor"></input></div>
+ <script>
+ function postEventType(event) {
+ webkit.messageHandlers.testHandler.postMessage(event.type);
+ }
+
+ editor.addEventListener("drop", postEventType);
+ editor.addEventListener("dragenter", postEventType);
+ editor.addEventListener("dragover", postEventType);
+ </script>
+</body>
Modified: trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm (212341 => 212342)
--- trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm 2017-02-15 03:06:42 UTC (rev 212341)
+++ trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm 2017-02-15 05:05:47 UTC (rev 212342)
@@ -89,6 +89,32 @@
});
}
+TEST(DataInteractionTests, LinkToInput)
+{
+ RetainPtr<TestWKWebView> webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
+ runTestsExpectingToObserveEvents(webView.get(), @[ DataInteractionEnterEventName, DataInteractionOverEventName, DataInteractionPerformOperationEventName ], ^() {
+ [webView synchronouslyLoadTestPageNamed:@"link-and-input"];
+
+ RetainPtr<DataInteractionSimulator> dataInteractionSimulator = adoptNS([[DataInteractionSimulator alloc] initWithWebView:webView.get() startLocation:CGPointMake(100, 100) endLocation:CGPointMake(100, 300)]);
+ [dataInteractionSimulator run];
+
+ EXPECT_WK_STREQ("https://www.daringfireball.net/", [webView stringByEvaluatingJavaScript:@"editor.value"].UTF8String);
+ });
+}
+
+TEST(DataInteractionTests, BackgroundImageLinkToInput)
+{
+ RetainPtr<TestWKWebView> webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
+ runTestsExpectingToObserveEvents(webView.get(), @[ DataInteractionEnterEventName, DataInteractionOverEventName, DataInteractionPerformOperationEventName ], ^() {
+ [webView synchronouslyLoadTestPageNamed:@"background-image-link-and-input"];
+
+ RetainPtr<DataInteractionSimulator> dataInteractionSimulator = adoptNS([[DataInteractionSimulator alloc] initWithWebView:webView.get() startLocation:CGPointMake(100, 100) endLocation:CGPointMake(100, 300)]);
+ [dataInteractionSimulator run];
+
+ EXPECT_WK_STREQ("https://www.daringfireball.net/", [webView stringByEvaluatingJavaScript:@"editor.value"].UTF8String);
+ });
+}
+
} // namespace TestWebKitAPI
#endif // ENABLE(DATA_INTERACTION)