[iOS WK2] Remove _WKDraggableElementInfo and fold PositionInformationTests into WKReq...
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 23 Jul 2017 05:28:34 +0000 (05:28 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 23 Jul 2017 05:28:34 +0000 (05:28 +0000)
https://bugs.webkit.org/show_bug.cgi?id=174758

Reviewed by Dan Bernstein.

Source/WebKit:

_WKDraggableElementInfo is no longer used in WebKit, so it should be removed. However, some of the scenarios
in PositionInformationTests that depend on _WKDraggableElementInfo are still useful to exercise: namely,
performing both synchronous and asynchronous position information updates while an async position information
update is in flight. This patch refactors these unit tests into 2 new unit tests in the existing
WKRequestActivatedElementInfo test suite.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _draggableElementAtPosition:]): Deleted.
(-[WKWebView _requestDraggableElementAtPosition:completionBlock:]): Deleted.
* UIProcess/API/Cocoa/WKWebViewPrivate.h:
* UIProcess/API/Cocoa/_WKDraggableElementInfo.h: Removed.
* UIProcess/API/Cocoa/_WKDraggableElementInfo.mm: Removed.
* UIProcess/API/Cocoa/_WKDraggableElementInfoInternal.h: Removed.
* UIProcess/ios/WKContentViewInteraction.mm:
* WebKit.xcodeproj/project.pbxproj:

Tools:

Migrate position-information-related unit tests from the PositionInformationTests suite to
WKRequestActivatedElementInfo as 2 new unit tests. See WebKit2 ChangeLog for more details.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2Cocoa/WKRequestActivatedElementInfo.mm:
(TestWebKitAPI::checkElementTypeAndBoundingRect):
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/ios/PositionInformationTests.mm: Removed.
* TestWebKitAPI/cocoa/TestWKWebView.h:
* TestWebKitAPI/cocoa/TestWKWebView.mm:
(-[TestWKWebView activatedElementAtPosition:]):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219768 268f45cc-cd09-0410-ab3c-d52691b4dbfc

14 files changed:
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h
Source/WebKit/UIProcess/API/Cocoa/_WKDraggableElementInfo.h [deleted file]
Source/WebKit/UIProcess/API/Cocoa/_WKDraggableElementInfo.mm [deleted file]
Source/WebKit/UIProcess/API/Cocoa/_WKDraggableElementInfoInternal.h [deleted file]
Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
Source/WebKit/WebKit.xcodeproj/project.pbxproj
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKRequestActivatedElementInfo.mm
Tools/TestWebKitAPI/Tests/ios/PositionInformationTests.mm [deleted file]
Tools/TestWebKitAPI/cocoa/TestWKWebView.h
Tools/TestWebKitAPI/cocoa/TestWKWebView.mm

index b31f566..97bc137 100644 (file)
@@ -1,5 +1,28 @@
 2017-07-22  Wenson Hsieh  <wenson_hsieh@apple.com>
 
+        [iOS WK2] Remove _WKDraggableElementInfo and fold PositionInformationTests into WKRequestActivatedElementInfo
+        https://bugs.webkit.org/show_bug.cgi?id=174758
+
+        Reviewed by Dan Bernstein.
+
+        _WKDraggableElementInfo is no longer used in WebKit, so it should be removed. However, some of the scenarios
+        in PositionInformationTests that depend on _WKDraggableElementInfo are still useful to exercise: namely,
+        performing both synchronous and asynchronous position information updates while an async position information
+        update is in flight. This patch refactors these unit tests into 2 new unit tests in the existing
+        WKRequestActivatedElementInfo test suite.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _draggableElementAtPosition:]): Deleted.
+        (-[WKWebView _requestDraggableElementAtPosition:completionBlock:]): Deleted.
+        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+        * UIProcess/API/Cocoa/_WKDraggableElementInfo.h: Removed.
+        * UIProcess/API/Cocoa/_WKDraggableElementInfo.mm: Removed.
+        * UIProcess/API/Cocoa/_WKDraggableElementInfoInternal.h: Removed.
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        * WebKit.xcodeproj/project.pbxproj:
+
+2017-07-22  Wenson Hsieh  <wenson_hsieh@apple.com>
+
         [Mac WK2] Fix null dereference in asynchronous NSTextInputClient methods when deallocating a WKWebView
         https://bugs.webkit.org/show_bug.cgi?id=174751
         <rdar://problem/33132405>
index 2419555..8421efb 100644 (file)
 #import "WKScrollView.h"
 #import "WKWebViewContentProviderRegistry.h"
 #import "WebVideoFullscreenManagerProxy.h"
-#import "_WKDraggableElementInfoInternal.h"
 #import "_WKWebViewPrintFormatter.h"
 #import <UIKit/UIApplication.h>
 #import <WebCore/CoreGraphicsSPI.h>
@@ -5295,19 +5294,6 @@ static WebCore::UserInterfaceLayoutDirection toUserInterfaceLayoutDirection(UISe
 }
 
 #if PLATFORM(IOS)
-- (_WKDraggableElementInfo *)_draggableElementAtPosition:(CGPoint)position
-{
-    [_contentView ensurePositionInformationIsUpToDate:WebKit::InteractionInformationRequest(WebCore::roundedIntPoint(position))];
-    return [_WKDraggableElementInfo infoWithInteractionInformationAtPosition:[_contentView currentPositionInformation]];
-}
-
-- (void)_requestDraggableElementAtPosition:(CGPoint)position completionBlock:(void (^)(_WKDraggableElementInfo *))block
-{
-    [_contentView doAfterPositionInformationUpdate:[capturedBlock = makeBlockPtr(block)] (WebKit::InteractionInformationAtPosition information) {
-        capturedBlock([_WKDraggableElementInfo infoWithInteractionInformationAtPosition:information]);
-    } forRequest:WebKit::InteractionInformationRequest(WebCore::roundedIntPoint(position))];
-}
-
 - (void)_requestActivatedElementAtPosition:(CGPoint)position completionBlock:(void (^)(_WKActivatedElementInfo *))block
 {
     auto infoRequest = WebKit::InteractionInformationRequest(WebCore::roundedIntPoint(position));
index 899e27c..c50fbd4 100644 (file)
@@ -83,7 +83,6 @@ typedef NS_ENUM(NSInteger, _WKImmediateActionType) {
 #endif
 
 @class WKBrowsingContextHandle;
-@class _WKDraggableElementInfo;
 @class _WKFrameHandle;
 @class _WKHitTestResult;
 @class _WKIconLoadingDelegate;
@@ -377,9 +376,6 @@ typedef NS_ENUM(NSInteger, _WKImmediateActionType) {
 
 @property (nonatomic, readonly) CGRect _dragCaretRect WK_API_AVAILABLE(ios(WK_IOS_TBA));
 
-- (_WKDraggableElementInfo *)_draggableElementAtPosition:(CGPoint)position WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
-- (void)_requestDraggableElementAtPosition:(CGPoint)position completionBlock:(void (^)(_WKDraggableElementInfo *))block WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
-
 - (void)_requestActivatedElementAtPosition:(CGPoint)position completionBlock:(void (^)(_WKActivatedElementInfo *))block WK_API_AVAILABLE(ios(WK_IOS_TBA));
 
 #endif // TARGET_OS_IPHONE
diff --git a/Source/WebKit/UIProcess/API/Cocoa/_WKDraggableElementInfo.h b/Source/WebKit/UIProcess/API/Cocoa/_WKDraggableElementInfo.h
deleted file mode 100644 (file)
index 306dc8c..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2017 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 <WebKit/WKFoundation.h>
-
-#if WK_API_ENABLED
-
-NS_ASSUME_NONNULL_BEGIN
-
-WK_CLASS_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA))
-@interface _WKDraggableElementInfo : NSObject <NSCopying>
-
-@property (nonatomic, readonly) CGPoint point;
-
-@property (nonatomic, readonly, getter=isLink) BOOL link;
-@property (nonatomic, readonly, getter=isAttachment) BOOL attachment;
-@property (nonatomic, readonly, getter=isImage) BOOL image;
-@property (nonatomic, readonly, getter=isSelected) BOOL selected;
-
-@end
-
-NS_ASSUME_NONNULL_END
-
-#endif
diff --git a/Source/WebKit/UIProcess/API/Cocoa/_WKDraggableElementInfo.mm b/Source/WebKit/UIProcess/API/Cocoa/_WKDraggableElementInfo.mm
deleted file mode 100644 (file)
index e0ff921..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2017 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.
- */
-
-#include "config.h"
-#include "_WKDraggableElementInfoInternal.h"
-
-#if WK_API_ENABLED
-
-@implementation _WKDraggableElementInfo
-
-#if PLATFORM(IOS)
-
-+ (instancetype)infoWithInteractionInformationAtPosition:(const WebKit::InteractionInformationAtPosition&)information
-{
-    return [[[self alloc] initWithInteractionInformationAtPosition:information] autorelease];
-}
-
-- (instancetype)initWithInteractionInformationAtPosition:(const WebKit::InteractionInformationAtPosition&)information
-{
-    if (!(self = [super init]))
-        return nil;
-
-    _point = information.request.point;
-    _link = information.isLink;
-    _attachment = information.isAttachment;
-    _image = information.isImage;
-#if ENABLE(DATA_INTERACTION)
-    _selected = information.hasSelectionAtPosition;
-#endif
-
-    return self;
-}
-
-#endif
-
-- (instancetype)copyWithZone:(NSZone *)zone
-{
-    _WKDraggableElementInfo *copy = [[_WKDraggableElementInfo alloc] init];
-
-    copy.point = self.point;
-    copy.link = self.link;
-    copy.attachment = self.attachment;
-    copy.image = self.image;
-    copy.selected = self.selected;
-
-    return copy;
-}
-
-@end
-
-#endif
diff --git a/Source/WebKit/UIProcess/API/Cocoa/_WKDraggableElementInfoInternal.h b/Source/WebKit/UIProcess/API/Cocoa/_WKDraggableElementInfoInternal.h
deleted file mode 100644 (file)
index f806ce7..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2017 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 "InteractionInformationAtPosition.h"
-#import "_WKDraggableElementInfo.h"
-
-#if WK_API_ENABLED
-
-@interface _WKDraggableElementInfo ()
-
-#if TARGET_OS_IPHONE
-+ (instancetype)infoWithInteractionInformationAtPosition:(const WebKit::InteractionInformationAtPosition&)information;
-- (instancetype)initWithInteractionInformationAtPosition:(const WebKit::InteractionInformationAtPosition&)information;
-#endif
-
-@property (nonatomic) CGPoint point;
-@property (nonatomic, getter=isLink) BOOL link;
-@property (nonatomic, getter=isAttachment) BOOL attachment;
-@property (nonatomic, getter=isImage) BOOL image;
-@property (nonatomic, getter=isSelected) BOOL selected;
-
-@end
-
-#endif
index f6fa76c..94ea374 100644 (file)
@@ -58,7 +58,6 @@
 #import "WebPageMessages.h"
 #import "WebProcessProxy.h"
 #import "_WKActivatedElementInfoInternal.h"
-#import "_WKDraggableElementInfoInternal.h"
 #import "_WKElementAction.h"
 #import "_WKFocusedElementInfo.h"
 #import "_WKFormInputSession.h"
index 3c20236..db8905e 100644 (file)
                F409BA181E6E64BC009DA28E /* WKDragDestinationAction.h in Headers */ = {isa = PBXBuildFile; fileRef = F409BA171E6E64B3009DA28E /* WKDragDestinationAction.h */; settings = {ATTRIBUTES = (Private, ); }; };
                F44DFEB21E9E752F0038D196 /* WebIconUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = F44DFEB01E9E752F0038D196 /* WebIconUtilities.h */; };
                F44DFEB31E9E752F0038D196 /* WebIconUtilities.mm in Sources */ = {isa = PBXBuildFile; fileRef = F44DFEB11E9E752F0038D196 /* WebIconUtilities.mm */; };
-               F4E8CB911EA6AB5B00E31198 /* _WKDraggableElementInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = F4E8CB8E1EA6AB5B00E31198 /* _WKDraggableElementInfo.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               F4E8CB921EA6AB5B00E31198 /* _WKDraggableElementInfo.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4E8CB8F1EA6AB5B00E31198 /* _WKDraggableElementInfo.mm */; };
-               F4E8CB931EA6AB5B00E31198 /* _WKDraggableElementInfoInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = F4E8CB901EA6AB5B00E31198 /* _WKDraggableElementInfoInternal.h */; };
                F6113E25126CE1820057D0A7 /* APIUserContentURLPattern.h in Headers */ = {isa = PBXBuildFile; fileRef = F6113E24126CE1820057D0A7 /* APIUserContentURLPattern.h */; };
                F6113E28126CE19B0057D0A7 /* WKUserContentURLPattern.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6113E26126CE19B0057D0A7 /* WKUserContentURLPattern.cpp */; };
                F6113E29126CE19B0057D0A7 /* WKUserContentURLPattern.h in Headers */ = {isa = PBXBuildFile; fileRef = F6113E27126CE19B0057D0A7 /* WKUserContentURLPattern.h */; settings = {ATTRIBUTES = (Private, ); }; };
                F409BA171E6E64B3009DA28E /* WKDragDestinationAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKDragDestinationAction.h; sourceTree = "<group>"; };
                F44DFEB01E9E752F0038D196 /* WebIconUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebIconUtilities.h; path = ios/WebIconUtilities.h; sourceTree = "<group>"; };
                F44DFEB11E9E752F0038D196 /* WebIconUtilities.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebIconUtilities.mm; path = ios/WebIconUtilities.mm; sourceTree = "<group>"; };
-               F4E8CB8E1EA6AB5B00E31198 /* _WKDraggableElementInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKDraggableElementInfo.h; sourceTree = "<group>"; };
-               F4E8CB8F1EA6AB5B00E31198 /* _WKDraggableElementInfo.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKDraggableElementInfo.mm; sourceTree = "<group>"; };
-               F4E8CB901EA6AB5B00E31198 /* _WKDraggableElementInfoInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKDraggableElementInfoInternal.h; sourceTree = "<group>"; };
                F6113E24126CE1820057D0A7 /* APIUserContentURLPattern.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIUserContentURLPattern.h; sourceTree = "<group>"; };
                F6113E26126CE19B0057D0A7 /* WKUserContentURLPattern.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKUserContentURLPattern.cpp; sourceTree = "<group>"; };
                F6113E27126CE19B0057D0A7 /* WKUserContentURLPattern.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKUserContentURLPattern.h; sourceTree = "<group>"; };
                                A1A4FE5818DCE9FA00B5EA8A /* _WKDownload.mm */,
                                A1A4FE6018DD54A400B5EA8A /* _WKDownloadDelegate.h */,
                                A1A4FE5918DCE9FA00B5EA8A /* _WKDownloadInternal.h */,
-                               F4E8CB8E1EA6AB5B00E31198 /* _WKDraggableElementInfo.h */,
-                               F4E8CB8F1EA6AB5B00E31198 /* _WKDraggableElementInfo.mm */,
-                               F4E8CB901EA6AB5B00E31198 /* _WKDraggableElementInfoInternal.h */,
                                379A873818BBFE0F00588AF2 /* _WKElementAction.h */,
                                379A873718BBFE0F00588AF2 /* _WKElementAction.mm */,
                                379A873B18BBFF0700588AF2 /* _WKElementActionInternal.h */,
                                A1A4FE5A18DCE9FA00B5EA8A /* _WKDownload.h in Headers */,
                                A1A4FE6118DD54A400B5EA8A /* _WKDownloadDelegate.h in Headers */,
                                A1A4FE5C18DCE9FA00B5EA8A /* _WKDownloadInternal.h in Headers */,
-                               F4E8CB911EA6AB5B00E31198 /* _WKDraggableElementInfo.h in Headers */,
-                               F4E8CB931EA6AB5B00E31198 /* _WKDraggableElementInfoInternal.h in Headers */,
                                379A873A18BBFE0F00588AF2 /* _WKElementAction.h in Headers */,
                                379A873C18BBFF0700588AF2 /* _WKElementActionInternal.h in Headers */,
                                1AD01BC91905D37E00C9C45F /* _WKErrorRecoveryAttempting.h in Headers */,
                                990D28B21C65209400986977 /* _WKAutomationSession.mm in Sources */,
                                1A5704F71BE01FF400874AF1 /* _WKContextMenuElementInfo.mm in Sources */,
                                A1A4FE5B18DCE9FA00B5EA8A /* _WKDownload.mm in Sources */,
-                               F4E8CB921EA6AB5B00E31198 /* _WKDraggableElementInfo.mm in Sources */,
                                379A873918BBFE0F00588AF2 /* _WKElementAction.mm in Sources */,
                                1AD01BC81905D37E00C9C45F /* _WKErrorRecoveryAttempting.mm in Sources */,
                                317FE7CE1C487DB800A0CA89 /* _WKExperimentalFeature.mm in Sources */,
index 9eca74d..2b55516 100644 (file)
@@ -1,3 +1,22 @@
+2017-07-22  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        [iOS WK2] Remove _WKDraggableElementInfo and fold PositionInformationTests into WKRequestActivatedElementInfo
+        https://bugs.webkit.org/show_bug.cgi?id=174758
+
+        Reviewed by Dan Bernstein.
+
+        Migrate position-information-related unit tests from the PositionInformationTests suite to
+        WKRequestActivatedElementInfo as 2 new unit tests. See WebKit2 ChangeLog for more details.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit2Cocoa/WKRequestActivatedElementInfo.mm:
+        (TestWebKitAPI::checkElementTypeAndBoundingRect):
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/Tests/ios/PositionInformationTests.mm: Removed.
+        * TestWebKitAPI/cocoa/TestWKWebView.h:
+        * TestWebKitAPI/cocoa/TestWKWebView.mm:
+        (-[TestWKWebView activatedElementAtPosition:]):
+
 2017-07-22  Chris Dumez  <cdumez@apple.com>
 
         REGRESSION(r204565): WKObject is broken
index f049007..abacbae 100644 (file)
                F4D4F3B61E4E2BCB00BB2767 /* DataInteractionSimulator.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4D4F3B41E4E2BCB00BB2767 /* DataInteractionSimulator.mm */; };
                F4D4F3B91E4E36E400BB2767 /* DataInteractionTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4D4F3B71E4E36E400BB2767 /* DataInteractionTests.mm */; };
                F4D5E4E81F0C5D38008C1A49 /* dragstart-clear-selection.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4D5E4E71F0C5D27008C1A49 /* dragstart-clear-selection.html */; };
-               F4D7BCD81EA5789800C421D3 /* PositionInformationTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4D7BCD61EA574DD00C421D3 /* PositionInformationTests.mm */; };
                F4DEF6ED1E9B4DB60048EF61 /* image-in-link-and-input.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4DEF6EC1E9B4D950048EF61 /* image-in-link-and-input.html */; };
                F4F137921D9B683E002BEC57 /* large-video-test-now-playing.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4F137911D9B6832002BEC57 /* large-video-test-now-playing.html */; };
                F4F405BC1D4C0D1C007A9707 /* full-size-autoplaying-video-with-audio.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4F405BA1D4C0CF8007A9707 /* full-size-autoplaying-video-with-audio.html */; };
                F4D4F3B51E4E2BCB00BB2767 /* DataInteractionSimulator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DataInteractionSimulator.h; sourceTree = "<group>"; };
                F4D4F3B71E4E36E400BB2767 /* DataInteractionTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DataInteractionTests.mm; sourceTree = "<group>"; };
                F4D5E4E71F0C5D27008C1A49 /* dragstart-clear-selection.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "dragstart-clear-selection.html"; sourceTree = "<group>"; };
-               F4D7BCD61EA574DD00C421D3 /* PositionInformationTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = PositionInformationTests.mm; sourceTree = "<group>"; };
                F4DEF6EC1E9B4D950048EF61 /* image-in-link-and-input.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "image-in-link-and-input.html"; sourceTree = "<group>"; };
                F4F137911D9B6832002BEC57 /* large-video-test-now-playing.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "large-video-test-now-playing.html"; sourceTree = "<group>"; };
                F4F405BA1D4C0CF8007A9707 /* full-size-autoplaying-video-with-audio.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "full-size-autoplaying-video-with-audio.html"; sourceTree = "<group>"; };
                                A1C4FB6F1BACCEFA003742D0 /* Resources */,
                                F4D4F3B71E4E36E400BB2767 /* DataInteractionTests.mm */,
                                7560917719259C59009EF06E /* MemoryCacheAddImageToCacheIOS.mm */,
-                               F4D7BCD61EA574DD00C421D3 /* PositionInformationTests.mm */,
                                F46849BD1EEF58E400B937FE /* UIPasteboardTests.mm */,
                                F45B63FC1F19D410009D38B9 /* ActionSheetTests.mm */,
                        );
                                7C83E0531D0A643A00FEBCF3 /* PendingAPIRequestURL.cpp in Sources */,
                                7CCE7EAF1A411A3800447C4C /* PlatformUtilities.cpp in Sources */,
                                0F139E781A423A6B00F590F5 /* PlatformUtilitiesCocoa.mm in Sources */,
-                               F4D7BCD81EA5789800C421D3 /* PositionInformationTests.mm in Sources */,
                                7CCE7EA61A411A0F00447C4C /* PlatformUtilitiesMac.mm in Sources */,
                                51DB16CE1F085137001FA4C5 /* WebViewIconLoading.mm in Sources */,
                                7CCE7EA71A411A1300447C4C /* PlatformWebViewMac.mm in Sources */,
index b87846d..28303a6 100644 (file)
 #if WK_API_ENABLED && PLATFORM(IOS)
 
 namespace TestWebKitAPI {
+
+static void checkElementTypeAndBoundingRect(_WKActivatedElementInfo *elementInfo, _WKActivatedElementType expectedType, CGRect expectedBoundingRect)
+{
+    auto observedBoundingRect = elementInfo.boundingRect;
+    EXPECT_EQ(CGRectGetWidth(expectedBoundingRect), CGRectGetWidth(observedBoundingRect));
+    EXPECT_EQ(CGRectGetHeight(expectedBoundingRect), CGRectGetHeight(observedBoundingRect));
+    EXPECT_EQ(CGRectGetMinX(expectedBoundingRect), CGRectGetMinX(observedBoundingRect));
+    EXPECT_EQ(CGRectGetMinY(expectedBoundingRect), CGRectGetMinY(observedBoundingRect));
+    EXPECT_EQ(expectedType, elementInfo.type);
+}
     
-TEST(WebKit2, ReqestActivatedElementInfoForLink)
+TEST(WebKit2, RequestActivatedElementInfoForLink)
 {
     auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
     [webView loadHTMLString:@"<html><head><meta name='viewport' content='initial-scale=1'></head><body style = 'margin: 0px;'><a href='testURL.test' style='display: block; height: 100%;' title='HitTestLinkTitle' id='testID'></a></body></html>" baseURL:nil];
@@ -62,7 +72,7 @@ TEST(WebKit2, ReqestActivatedElementInfoForLink)
     TestWebKitAPI::Util::run(&finished);
 }
     
-TEST(WebKit2, ReqestActivatedElementInfoForBlank)
+TEST(WebKit2, RequestActivatedElementInfoForBlank)
 {
     auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
     [webView loadHTMLString:@"<html><head><meta name='viewport' content='initial-scale=1'></head><body style = 'margin: 0px;'></body></html>" baseURL:nil];
@@ -81,6 +91,62 @@ TEST(WebKit2, ReqestActivatedElementInfoForBlank)
     TestWebKitAPI::Util::run(&finished);
 }
     
+TEST(WebKit2, RequestActivatedElementInfoWithNestedSynchronousUpdates)
+{
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
+    [webView synchronouslyLoadHTMLString:@"<meta name='viewport' content='initial-scale=1'><style>body { margin:0 } a { display:block; width:200px; height:200px }</style><a href='https://www.apple.com'>FOO</a>"];
+
+    __block bool finished = false;
+    [webView _requestActivatedElementAtPosition:CGPointMake(100, 100) completionBlock:^(_WKActivatedElementInfo *elementInfo) {
+        _WKActivatedElementInfo *synchronousElementInfo = [webView activatedElementAtPosition:CGPointMake(300, 300)];
+        EXPECT_EQ(_WKActivatedElementTypeUnspecified, synchronousElementInfo.type);
+        checkElementTypeAndBoundingRect(elementInfo, _WKActivatedElementTypeLink, CGRectMake(0, 0, 200, 200));
+        finished = true;
+    }];
+    TestWebKitAPI::Util::run(&finished);
+
+    finished = false;
+    [webView _requestActivatedElementAtPosition:CGPointMake(100, 100) completionBlock:^(_WKActivatedElementInfo *elementInfo) {
+        _WKActivatedElementInfo *synchronousElementInfo = [webView activatedElementAtPosition:CGPointMake(100, 100)];
+        checkElementTypeAndBoundingRect(synchronousElementInfo, _WKActivatedElementTypeLink, CGRectMake(0, 0, 200, 200));
+        checkElementTypeAndBoundingRect(elementInfo, _WKActivatedElementTypeLink, CGRectMake(0, 0, 200, 200));
+        finished = true;
+    }];
+    TestWebKitAPI::Util::run(&finished);
+}
+
+TEST(WebKit2, RequestActivatedElementInfoWithNestedRequests)
+{
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
+    [webView synchronouslyLoadTestPageNamed:@"image-and-contenteditable"];
+
+    __block bool finishedWithInner = false;
+    __block bool finishedWithOuter = false;
+    [webView _requestActivatedElementAtPosition:CGPointMake(100, 50) completionBlock:^(_WKActivatedElementInfo *outerElementInfo) {
+        [webView _requestActivatedElementAtPosition:CGPointMake(100, 50) completionBlock:^(_WKActivatedElementInfo *innerElementInfo) {
+            checkElementTypeAndBoundingRect(innerElementInfo, _WKActivatedElementTypeImage, CGRectMake(0, 0, 200, 200));
+            finishedWithInner = true;
+        }];
+        checkElementTypeAndBoundingRect(outerElementInfo, _WKActivatedElementTypeImage, CGRectMake(0, 0, 200, 200));
+        finishedWithOuter = true;
+    }];
+    TestWebKitAPI::Util::run(&finishedWithOuter);
+    TestWebKitAPI::Util::run(&finishedWithInner);
+
+    finishedWithInner = false;
+    finishedWithOuter = false;
+    [webView _requestActivatedElementAtPosition:CGPointMake(100, 50) completionBlock:^(_WKActivatedElementInfo *outerElementInfo) {
+        [webView _requestActivatedElementAtPosition:CGPointMake(300, 300) completionBlock:^(_WKActivatedElementInfo *innerElementInfo) {
+            EXPECT_EQ(_WKActivatedElementTypeUnspecified, innerElementInfo.type);
+            finishedWithInner = true;
+        }];
+        checkElementTypeAndBoundingRect(outerElementInfo, _WKActivatedElementTypeImage, CGRectMake(0, 0, 200, 200));
+        finishedWithOuter = true;
+    }];
+    TestWebKitAPI::Util::run(&finishedWithOuter);
+    TestWebKitAPI::Util::run(&finishedWithInner);
+}
+
 }
 
 #endif
diff --git a/Tools/TestWebKitAPI/Tests/ios/PositionInformationTests.mm b/Tools/TestWebKitAPI/Tests/ios/PositionInformationTests.mm
deleted file mode 100644 (file)
index 0e9a286..0000000
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (C) 2017 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.
- */
-
-#include "config.h"
-
-#if ENABLE(DATA_INTERACTION)
-
-#import "PlatformUtilities.h"
-#import "TestWKWebView.h"
-#import <WebKit/WKWebViewPrivate.h>
-#import <WebKit/_WKDraggableElementInfo.h>
-
-@implementation _WKDraggableElementInfo (PositionInformationTests)
-
-- (void)expectToBeLink:(BOOL)isLink image:(BOOL)isImage atPoint:(CGPoint)point
-{
-    EXPECT_EQ(isLink, self.isLink);
-    EXPECT_EQ(isImage, self.isImage);
-    EXPECT_EQ(point.x, self.point.x);
-    EXPECT_EQ(point.y, self.point.y);
-}
-
-@end
-
-namespace TestWebKitAPI {
-
-TEST(PositionInformationTests, FindDraggableLinkAtPosition)
-{
-    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
-    [webView synchronouslyLoadTestPageNamed:@"link-and-input"];
-
-    _WKDraggableElementInfo *information = [webView _draggableElementAtPosition:CGPointMake(100, 50)];
-    [information expectToBeLink:YES image:NO atPoint:CGPointMake(100, 50)];
-}
-
-TEST(PositionInformationTests, RequestDraggableLinkAtPosition)
-{
-    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
-    [webView synchronouslyLoadTestPageNamed:@"link-and-input"];
-
-    __block bool isDone = false;
-    [webView _requestDraggableElementAtPosition:CGPointMake(100, 50) completionBlock:^(_WKDraggableElementInfo *information) {
-        [information expectToBeLink:YES image:NO atPoint:CGPointMake(100, 50)];
-        isDone = true;
-    }];
-
-    TestWebKitAPI::Util::run(&isDone);
-}
-
-TEST(PositionInformationTests, FindDraggableLinkAtDifferentPositionWithinRequestBlock)
-{
-    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
-    [webView synchronouslyLoadTestPageNamed:@"link-and-input"];
-
-    __block bool isDone = false;
-    [webView _requestDraggableElementAtPosition:CGPointMake(100, 50) completionBlock:^(_WKDraggableElementInfo *information) {
-        _WKDraggableElementInfo *synchronousInformation = [webView _draggableElementAtPosition:CGPointMake(100, 300)];
-        [synchronousInformation expectToBeLink:NO image:NO atPoint:CGPointMake(100, 300)];
-        [information expectToBeLink:YES image:NO atPoint:CGPointMake(100, 50)];
-        isDone = true;
-    }];
-
-    TestWebKitAPI::Util::run(&isDone);
-}
-
-TEST(PositionInformationTests, FindDraggableLinkAtSamePositionWithinRequestBlock)
-{
-    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
-    [webView synchronouslyLoadTestPageNamed:@"link-and-input"];
-
-    __block bool isDone = false;
-    [webView _requestDraggableElementAtPosition:CGPointMake(100, 50) completionBlock:^(_WKDraggableElementInfo *information) {
-        _WKDraggableElementInfo *synchronousInformation = [webView _draggableElementAtPosition:CGPointMake(100, 50)];
-        [synchronousInformation expectToBeLink:YES image:NO atPoint:CGPointMake(100, 50)];
-        [information expectToBeLink:YES image:NO atPoint:CGPointMake(100, 50)];
-        isDone = true;
-    }];
-
-    TestWebKitAPI::Util::run(&isDone);
-}
-
-TEST(PositionInformationTests, RequestDraggableLinkAtSamePositionWithinRequestBlock)
-{
-    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
-    [webView synchronouslyLoadTestPageNamed:@"image-and-contenteditable"];
-
-    __block bool isDoneWithInner = false;
-    __block bool isDoneWithOuter = false;
-
-    [webView _requestDraggableElementAtPosition:CGPointMake(100, 50) completionBlock:^(_WKDraggableElementInfo *outerInformation) {
-        [webView _requestDraggableElementAtPosition:CGPointMake(100, 50) completionBlock:^(_WKDraggableElementInfo *innerInformation) {
-            [innerInformation expectToBeLink:NO image:YES atPoint:CGPointMake(100, 50)];
-            isDoneWithInner = true;
-        }];
-        [outerInformation expectToBeLink:NO image:YES atPoint:CGPointMake(100, 50)];
-        isDoneWithOuter = true;
-    }];
-
-    TestWebKitAPI::Util::run(&isDoneWithOuter);
-    TestWebKitAPI::Util::run(&isDoneWithInner);
-}
-
-TEST(PositionInformationTests, RequestDraggableLinkAtDifferentPositionWithinRequestBlock)
-{
-    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
-    [webView synchronouslyLoadTestPageNamed:@"image-and-contenteditable"];
-
-    __block bool isDoneWithInner = false;
-    __block bool isDoneWithOuter = false;
-
-    [webView _requestDraggableElementAtPosition:CGPointMake(100, 50) completionBlock:^(_WKDraggableElementInfo *outerInformation) {
-        [webView _requestDraggableElementAtPosition:CGPointMake(100, 300) completionBlock:^(_WKDraggableElementInfo *innerInformation) {
-            [innerInformation expectToBeLink:NO image:NO atPoint:CGPointMake(100, 300)];
-            isDoneWithInner = true;
-        }];
-        [outerInformation expectToBeLink:NO image:YES atPoint:CGPointMake(100, 50)];
-        isDoneWithOuter = true;
-    }];
-
-    TestWebKitAPI::Util::run(&isDoneWithOuter);
-    TestWebKitAPI::Util::run(&isDoneWithInner);
-}
-
-} // namespace TestWebKitAPI
-
-#endif
index edb1fd5..2497ebd 100644 (file)
 
 @class _WKProcessPoolConfiguration;
 
+#if PLATFORM(IOS)
+@class _WKActivatedElementInfo;
+#endif
+
 @interface TestMessageHandler : NSObject <WKScriptMessageHandler>
 - (void)addMessage:(NSString *)message withHandler:(dispatch_block_t)handler;
 @end
@@ -49,6 +53,7 @@
 #if PLATFORM(IOS)
 @interface TestWKWebView (IOSOnly)
 @property (nonatomic, readonly) RetainPtr<NSArray> selectionRectsAfterPresentationUpdate;
+- (_WKActivatedElementInfo *)activatedElementAtPosition:(CGPoint)position;
 @end
 #endif
 
index 1f0f07e..8d4adc7 100644 (file)
@@ -33,6 +33,7 @@
 
 #import <WebKit/WKWebViewConfigurationPrivate.h>
 #import <WebKit/WebKitPrivate.h>
+#import <WebKit/_WKActivatedElementInfo.h>
 #import <WebKit/_WKProcessPoolConfiguration.h>
 #import <objc/runtime.h>
 #import <wtf/RetainPtr.h>
@@ -294,6 +295,19 @@ NSEventMask __simulated_forceClickAssociatedEventsMask(id self, SEL _cmd)
     return selectionRects;
 }
 
+- (_WKActivatedElementInfo *)activatedElementAtPosition:(CGPoint)position
+{
+    __block RetainPtr<_WKActivatedElementInfo> info;
+    __block bool finished = false;
+    [self _requestActivatedElementAtPosition:position completionBlock:^(_WKActivatedElementInfo *elementInfo) {
+        info = elementInfo;
+        finished = true;
+    }];
+
+    TestWebKitAPI::Util::run(&finished);
+    return info.autorelease();
+}
+
 @end
 
 #endif