Title: [213292] trunk/Source
Revision
213292
Author
[email protected]
Date
2017-03-02 11:16:44 -0800 (Thu, 02 Mar 2017)

Log Message

Data interaction support for WK1
https://bugs.webkit.org/show_bug.cgi?id=169062

Reviewed by Wenson Hsieh.

Source/WebKit/mac:

Support for data interaction in WebKit1

* WebCoreSupport/WebDragClient.mm:
* WebView/WebView.mm:
(-[WebUITextIndicatorData initWithImage:TextIndicatorData:scale:]):
(-[WebUITextIndicatorData initWithImage:scale:]):
(-[WebUITextIndicatorData dealloc]):
(-[WebView _requestStartDataInteraction:globalPosition:]):
(-[WebView _setDataInteractionData:textIndicator:atClientPosition:anchorPoint:action:]):
(-[WebView _getDataInteractionData]):
* WebView/WebViewData.h:
* WebView/WebViewData.mm:
(-[WebViewPrivate dealloc]):
* WebView/WebViewInternal.h:
* WebView/WebViewPrivate.h:

Source/WebKit2:

Allow for separate additions files in WK1 and WK2

* WebProcess/WebCoreSupport/mac/WebDragClientMac.mm:

Modified Paths

Diff

Modified: trunk/Source/WebKit/mac/ChangeLog (213291 => 213292)


--- trunk/Source/WebKit/mac/ChangeLog	2017-03-02 18:42:16 UTC (rev 213291)
+++ trunk/Source/WebKit/mac/ChangeLog	2017-03-02 19:16:44 UTC (rev 213292)
@@ -1,3 +1,26 @@
+2017-03-01  Megan Gardner  <[email protected]>
+
+        Data interaction support for WK1
+        https://bugs.webkit.org/show_bug.cgi?id=169062
+
+        Reviewed by Wenson Hsieh.
+
+        Support for data interaction in WebKit1
+
+        * WebCoreSupport/WebDragClient.mm:
+        * WebView/WebView.mm:
+        (-[WebUITextIndicatorData initWithImage:TextIndicatorData:scale:]):
+        (-[WebUITextIndicatorData initWithImage:scale:]):
+        (-[WebUITextIndicatorData dealloc]):
+        (-[WebView _requestStartDataInteraction:globalPosition:]):
+        (-[WebView _setDataInteractionData:textIndicator:atClientPosition:anchorPoint:action:]):
+        (-[WebView _getDataInteractionData]):
+        * WebView/WebViewData.h:
+        * WebView/WebViewData.mm:
+        (-[WebViewPrivate dealloc]):
+        * WebView/WebViewInternal.h:
+        * WebView/WebViewPrivate.h:
+
 2017-03-02  Youenn Fablet  <[email protected]>
 
         [WebRTC] Activate ICE candidate privacy policy

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebDragClient.mm (213291 => 213292)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebDragClient.mm	2017-03-02 18:42:16 UTC (rev 213291)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebDragClient.mm	2017-03-02 19:16:44 UTC (rev 213292)
@@ -59,6 +59,10 @@
 
 using namespace WebCore;
 
+#if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/WebDragClientAdditionsWebKit1.mm>)
+#import <WebKitAdditions/WebDragClientAdditionsWebKit1.mm>
+#endif
+
 WebDragClient::WebDragClient(WebView* webView)
     : m_webView(webView) 
 {
@@ -198,11 +202,11 @@
 void WebDragClient::willPerformDragSourceAction(WebCore::DragSourceAction, const WebCore::IntPoint&, WebCore::DataTransfer&)
 {
 }
-
+#if !ENABLE(DATA_INTERACTION)
 void WebDragClient::startDrag(WebCore::DragImage, const IntPoint&, const IntPoint&, const FloatPoint&, DataTransfer&, Frame&, WebCore::DragSourceAction)
 {
 }
-
+#endif
 void WebDragClient::beginDrag(DragItem, Frame&, const IntPoint&, const IntPoint&, DataTransfer&, DragSourceAction)
 {
 }

Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (213291 => 213292)


--- trunk/Source/WebKit/mac/WebView/WebView.mm	2017-03-02 18:42:16 UTC (rev 213291)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm	2017-03-02 19:16:44 UTC (rev 213292)
@@ -190,6 +190,7 @@
 #import <WebCore/SecurityPolicy.h>
 #import <WebCore/Settings.h>
 #import <WebCore/SocketProvider.h>
+#import <WebCore/SoftLinking.h>
 #import <WebCore/StyleProperties.h>
 #import <WebCore/TextResourceDecoder.h>
 #import <WebCore/ThreadCheck.h>
@@ -238,7 +239,6 @@
 #import <WebCore/AVKitSPI.h>
 #import <WebCore/LookupSPI.h>
 #import <WebCore/NSImmediateActionGestureRecognizerSPI.h>
-#import <WebCore/SoftLinking.h>
 #import <WebCore/TextIndicator.h>
 #import <WebCore/TextIndicatorWindow.h>
 #import <WebCore/WebVideoFullscreenController.h>
@@ -319,6 +319,12 @@
 #import <WebCore/WebPlaybackSessionModelMediaElement.h>
 #endif
 
+#if ENABLE(DATA_INTERACTION)
+#import <UIKit/UIImage.h>
+SOFT_LINK_FRAMEWORK(UIKit)
+SOFT_LINK_CLASS(UIKit, UIImage)
+#endif
+
 #if HAVE(TOUCH_BAR) && ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
 SOFT_LINK_FRAMEWORK(AVKit)
 SOFT_LINK_CLASS(AVKit, AVFunctionBarPlaybackControlsProvider)
@@ -611,6 +617,65 @@
 
 } // namespace WebKit
 
+#if ENABLE(DATA_INTERACTION)
+@implementation WebUITextIndicatorData
+
+@synthesize dataInteractionImage=_dataInteractionImage;
+@synthesize selectionRectInRootViewCoordinates=_selectionRectInRootViewCoordinates;
+@synthesize textBoundingRectInRootViewCoordinates=_textBoundingRectInRootViewCoordinates;
+@synthesize textRectsInBoundingRectCoordinates=_textRectsInBoundingRectCoordinates;
+@synthesize contentImageWithHighlight=_contentImageWithHighlight;
+@synthesize contentImage=_contentImage;
+
+@end
+
+@implementation WebUITextIndicatorData (WebUITextIndicatorInternal)
+
+- (WebUITextIndicatorData *)initWithImage:(CGImageRef)image textIndicatorData:(WebCore::TextIndicatorData &)indicatorData scale:(CGFloat)scale
+{
+    if (!(self = [super init]))
+        return nil;
+    
+    _dataInteractionImage = [[[getUIImageClass() alloc] initWithCGImage:image scale:scale orientation:UIImageOrientationDownMirrored] retain];
+    _selectionRectInRootViewCoordinates = indicatorData.selectionRectInRootViewCoordinates;
+    _textBoundingRectInRootViewCoordinates = indicatorData.textBoundingRectInRootViewCoordinates;
+    
+    NSMutableArray *textRectsInBoundingRectCoordinates = [NSMutableArray array];
+    for (auto rect : indicatorData.textRectsInBoundingRectCoordinates)
+        [textRectsInBoundingRectCoordinates addObject:[NSValue valueWithCGRect:rect]];
+    _textRectsInBoundingRectCoordinates = [[NSArray arrayWithArray:textRectsInBoundingRectCoordinates] retain];
+    _contentImageScaleFactor = indicatorData.contentImageScaleFactor;
+    if (indicatorData.contentImageWithHighlight)
+        _contentImageWithHighlight = [[[getUIImageClass() alloc] initWithCGImage:indicatorData.contentImageWithHighlight.get()->nativeImage().get() scale:scale orientation:UIImageOrientationDownMirrored] retain];
+    if (indicatorData.contentImage)
+        _contentImage = [[[getUIImageClass() alloc] initWithCGImage:indicatorData.contentImage.get()->nativeImage().get() scale:scale orientation:UIImageOrientationDownMirrored] retain];
+    
+    return self;
+}
+
+- (WebUITextIndicatorData *)initWithImage:(CGImageRef)image scale:(CGFloat)scale
+{
+    if (!(self = [super init]))
+        return nil;
+    
+    _dataInteractionImage = [[getUIImageClass() alloc] initWithCGImage:image scale:scale orientation:UIImageOrientationDownMirrored];
+    
+    return self;
+}
+
+- (void)dealloc
+{
+    [_dataInteractionImage release];
+    [_textRectsInBoundingRectCoordinates release];
+    [_contentImageWithHighlight release];
+    [_contentImage release];
+    
+    [super dealloc];
+}
+
+@end
+#endif // ENABLE(DATA_INTERACTION)
+
 @interface WebView (WebFileInternal)
 #if !PLATFORM(IOS)
 - (float)_deviceScaleFactor;
@@ -1710,8 +1775,40 @@
         }
     });
 }
-#endif // PLATFORM(IOS)
+#endif
 
+#if ENABLE(DATA_INTERACTION) && defined(__cplusplus)
+- (BOOL)_requestStartDataInteraction:(CGPoint)clientPosition globalPosition:(CGPoint)globalPosition
+{
+    return _private->page->mainFrame().eventHandler().tryToBeginDataInteractionAtPoint(IntPoint(clientPosition), IntPoint(globalPosition));
+}
+
+- (void)_setDataInteractionData:(CGImageRef)image textIndicator:(std::optional<TextIndicatorData>)indicatorData atClientPosition:(CGPoint)clientPosition anchorPoint:(CGPoint)anchorPoint action:(uint64_t)action
+{
+    if (indicatorData)
+        _private->textIndicatorData = [[[WebUITextIndicatorData alloc] initWithImage:image TextIndicatorData:indicatorData.value() scale:_private->page->deviceScaleFactor()] retain];
+    else
+        _private->textIndicatorData = [[[WebUITextIndicatorData alloc] initWithImage:image scale:_private->page->deviceScaleFactor()] retain];
+}
+
+- (WebUITextIndicatorData *)_getDataInteractionData
+{
+    return _private->textIndicatorData;
+}
+#else
+- (BOOL)_requestStartDataInteraction:(CGPoint)clientPosition globalPosition:(CGPoint)globalPosition
+{
+    return NO;
+}
+- (void)_setDataInteractionData:(CGImageRef)image textIndicator:(TextIndicatorData&)indicatorData atClientPosition:(CGPoint)clientPosition anchorPoint:(CGPoint)anchorPoint action:(uint64_t)action
+{
+}
+- (WebUITextIndicatorData *)_getDataInteractionData
+{
+    return nil;
+}
+#endif // ENABLE(DATA_INTERACTION) && defined(__cplusplus)
+
 static NSMutableSet *knownPluginMIMETypes()
 {
     static NSMutableSet *mimeTypes = [[NSMutableSet alloc] init];

Modified: trunk/Source/WebKit/mac/WebView/WebViewData.h (213291 => 213292)


--- trunk/Source/WebKit/mac/WebView/WebViewData.h	2017-03-02 18:42:16 UTC (rev 213291)
+++ trunk/Source/WebKit/mac/WebView/WebViewData.h	2017-03-02 19:16:44 UTC (rev 213292)
@@ -55,6 +55,8 @@
 #endif
 }
 
+@class UIImage;
+@class WebUITextIndicatorData;
 @class WebImmediateActionController;
 @class WebInspector;
 @class WebNodeHighlight;
@@ -282,6 +284,7 @@
     int32_t didDrawTiles;
     WTF::Lock pendingFixedPositionLayoutRectMutex;
     CGRect pendingFixedPositionLayoutRect;
+    WebUITextIndicatorData *textIndicatorData;
 #endif
 
 #if !PLATFORM(IOS)

Modified: trunk/Source/WebKit/mac/WebView/WebViewData.mm (213291 => 213292)


--- trunk/Source/WebKit/mac/WebView/WebViewData.mm	2017-03-02 18:42:16 UTC (rev 213291)
+++ trunk/Source/WebKit/mac/WebView/WebViewData.mm	2017-03-02 19:16:44 UTC (rev 213292)
@@ -212,6 +212,7 @@
     [formDelegateForwarder release];
     [_caretChangeListeners release];
     [_fixedPositionContent release];
+    [textIndicatorData release];
 #endif
 
     [super dealloc];

Modified: trunk/Source/WebKit/mac/WebView/WebViewInternal.h (213291 => 213292)


--- trunk/Source/WebKit/mac/WebView/WebViewInternal.h	2017-03-02 18:42:16 UTC (rev 213291)
+++ trunk/Source/WebKit/mac/WebView/WebViewInternal.h	2017-03-02 19:16:44 UTC (rev 213292)
@@ -40,6 +40,7 @@
 #import <WebCore/HTMLMediaElementEnums.h>
 #import <WebCore/LayoutMilestones.h>
 #import <WebCore/TextAlternativeWithRange.h>
+#import <WebCore/TextIndicator.h>
 #import <WebCore/TextIndicatorWindow.h>
 #import <WebCore/WebCoreKeyboardUIMode.h>
 #import <functional>
@@ -89,6 +90,13 @@
 OBJC_CLASS NSTextAlternatives;
 #endif
 
+#if ENABLE(DATA_INTERACTION) && defined(__cplusplus)
+@interface WebUITextIndicatorData (WebUITextIndicatorInternal)
+- (WebUITextIndicatorData *)initWithImage:(CGImageRef)image textIndicatorData:(WebCore::TextIndicatorData&)indicatorData scale:(CGFloat)scale;
+- (WebUITextIndicatorData *)initWithImage:(CGImageRef)image scale:(CGFloat)scale;
+@end
+#endif
+
 @interface WebView (WebViewEditingExtras)
 - (BOOL)_shouldChangeSelectedDOMRange:(DOMRange *)currentRange toDOMRange:(DOMRange *)proposedRange affinity:(NSSelectionAffinity)selectionAffinity stillSelecting:(BOOL)flag;
 @end
@@ -248,6 +256,10 @@
 - (BOOL)_fetchCustomFixedPositionLayoutRect:(NSRect*)rect;
 #endif
 
+#if ENABLE(DATA_INTERACTION) && defined(__cplusplus)
+- (void)_setDataInteractionData:(CGImageRef)image textIndicator:(std::optional<WebCore::TextIndicatorData>)textIndicator atClientPosition:(CGPoint)clientPosition anchorPoint:(CGPoint)anchorPoint action:(uint64_t)action;
+#endif
+
 - (void)_preferencesChanged:(WebPreferences *)preferences;
 
 #if ENABLE(VIDEO) && defined(__cplusplus)

Modified: trunk/Source/WebKit/mac/WebView/WebViewPrivate.h (213291 => 213292)


--- trunk/Source/WebKit/mac/WebView/WebViewPrivate.h	2017-03-02 18:42:16 UTC (rev 213291)
+++ trunk/Source/WebKit/mac/WebView/WebViewPrivate.h	2017-03-02 19:16:44 UTC (rev 213292)
@@ -55,6 +55,7 @@
 #endif
 #endif
 
+@class UIImage;
 @class NSError;
 @class WebFrame;
 @class WebDeviceOrientation;
@@ -180,6 +181,17 @@
     WebNotificationPermissionDenied
 } WebNotificationPermission;
 
+@interface WebUITextIndicatorData : NSObject
+@property (nonatomic, retain) UIImage *dataInteractionImage;
+@property (nonatomic, assign) CGRect selectionRectInRootViewCoordinates;
+@property (nonatomic, assign) CGRect textBoundingRectInRootViewCoordinates;
+@property (nonatomic, retain) NSArray<NSValue *> *textRectsInBoundingRectCoordinates; // CGRect values
+@property (nonatomic, assign) CGFloat contentImageScaleFactor;
+@property (nonatomic, retain) UIImage *contentImageWithHighlight;
+@property (nonatomic, retain) UIImage *contentImage;
+
+@end
+
 #if !TARGET_OS_IPHONE
 @interface WebController : NSTreeController {
     IBOutlet WebView *webView;
@@ -449,8 +461,11 @@
 + (void)_releaseMemoryNow;
 
 - (void)_replaceCurrentHistoryItem:(WebHistoryItem *)item;
-#endif // PLATFORM(IOS)
+#endif // TARGET_OS_IPHONE
 
+- (BOOL)_requestStartDataInteraction:(CGPoint)clientPosition globalPosition:(CGPoint)globalPosition;
+- (WebUITextIndicatorData *)_getDataInteractionData;
+
 #if TARGET_OS_IPHONE
 // Deprecated. Use -[WebDataSource _quickLookContent] instead.
 - (NSDictionary *)quickLookContentForURL:(NSURL *)url;

Modified: trunk/Source/WebKit2/ChangeLog (213291 => 213292)


--- trunk/Source/WebKit2/ChangeLog	2017-03-02 18:42:16 UTC (rev 213291)
+++ trunk/Source/WebKit2/ChangeLog	2017-03-02 19:16:44 UTC (rev 213292)
@@ -1,3 +1,14 @@
+2017-03-01  Megan Gardner  <[email protected]>
+
+        Data interaction support for WK1
+        https://bugs.webkit.org/show_bug.cgi?id=169062
+
+        Reviewed by Wenson Hsieh.
+
+        Allow for separate additions files in WK1 and WK2
+
+        * WebProcess/WebCoreSupport/mac/WebDragClientMac.mm:
+
 2017-03-02  Youenn Fablet  <[email protected]>
 
         [WebRTC] Activate ICE candidate privacy policy

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm (213291 => 213292)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm	2017-03-02 18:42:16 UTC (rev 213291)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDragClientMac.mm	2017-03-02 19:16:44 UTC (rev 213292)
@@ -51,8 +51,8 @@
 using namespace WebCore;
 using namespace WebKit;
 
-#if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/WebDragClientAdditions.mm>)
-#import <WebKitAdditions/WebDragClientAdditions.mm>
+#if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/WebDragClientAdditionsWebKit2.mm>)
+#import <WebKitAdditions/WebDragClientAdditionsWebKit2.mm>
 #endif
 
 #if PLATFORM(MAC)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to