<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[164666] trunk/Source/WebKit2</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/164666">164666</a></dd>
<dt>Author</dt> <dd>mitz@apple.com</dd>
<dt>Date</dt> <dd>2014-02-25 13:10:14 -0800 (Tue, 25 Feb 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>[Cocoa] Add delegate method for customizing actions on activated elements
https://bugs.webkit.org/show_bug.cgi?id=129290
Reviewed by Anders Carlsson.
* UIProcess/API/Cocoa/WKUIDelegatePrivate.h: Added. Declared new delegate method.
* UIProcess/API/Cocoa/_WKActivatedElementInfo.h:
(_WKActivatedElementType): Defined enum of element types.
* UIProcess/API/Cocoa/_WKActivatedElementInfo.mm:
(-[_WKActivatedElementInfo _initWithType:URL:location:title:rect:]): Added type parameter
to the initializer, used to set the new type property.
* UIProcess/API/Cocoa/_WKActivatedElementInfoInternal.h:
* UIProcess/Cocoa/UIClient.h:
* UIProcess/Cocoa/UIClient.mm:
(WebKit::UIClient::setDelegate): Initialize webViewActionsForElementDefaultActions member
of m_delegateMethods.
(WebKit::UIClient::actionsForElement): Added. Calls out to the new delegate method if
implemented. Otherwise returns the default actions.
* UIProcess/ios/WKActionSheetAssistant.mm:
(-[WKActionSheetAssistant actionSheet:clickedButtonAtIndex:]): Use new _elementInfo ivar
instead of creating element info here.
(-[WKActionSheetAssistant showImageSheet]): Create element info here and assign it to
_elementInfo ivar if presenting a sheet. Call the UI client to get custom actions.
(-[WKActionSheetAssistant showLinkSheet]): Ditto.
(-[WKActionSheetAssistant cleanupSheet]): Clear _elementInfo ivar.
* WebKit2.xcodeproj/project.pbxproj: Added reference to WKUIDelegatePrivate.h.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoa_WKActivatedElementInfoh">trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKActivatedElementInfo.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoa_WKActivatedElementInfomm">trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKActivatedElementInfo.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoa_WKActivatedElementInfoInternalh">trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKActivatedElementInfoInternal.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaUIClienth">trunk/Source/WebKit2/UIProcess/Cocoa/UIClient.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaUIClientmm">trunk/Source/WebKit2/UIProcess/Cocoa/UIClient.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWKActionSheetAssistantmm">trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.mm</a></li>
<li><a href="#trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj">trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKUIDelegatePrivateh">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (164665 => 164666)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-02-25 20:56:27 UTC (rev 164665)
+++ trunk/Source/WebKit2/ChangeLog        2014-02-25 21:10:14 UTC (rev 164666)
</span><span class="lines">@@ -1,3 +1,35 @@
</span><ins>+2014-02-25 Dan Bernstein <mitz@apple.com>
+
+ [Cocoa] Add delegate method for customizing actions on activated elements
+ https://bugs.webkit.org/show_bug.cgi?id=129290
+
+ Reviewed by Anders Carlsson.
+
+ * UIProcess/API/Cocoa/WKUIDelegatePrivate.h: Added. Declared new delegate method.
+
+ * UIProcess/API/Cocoa/_WKActivatedElementInfo.h:
+ (_WKActivatedElementType): Defined enum of element types.
+ * UIProcess/API/Cocoa/_WKActivatedElementInfo.mm:
+ (-[_WKActivatedElementInfo _initWithType:URL:location:title:rect:]): Added type parameter
+ to the initializer, used to set the new type property.
+ * UIProcess/API/Cocoa/_WKActivatedElementInfoInternal.h:
+
+ * UIProcess/Cocoa/UIClient.h:
+ * UIProcess/Cocoa/UIClient.mm:
+ (WebKit::UIClient::setDelegate): Initialize webViewActionsForElementDefaultActions member
+ of m_delegateMethods.
+ (WebKit::UIClient::actionsForElement): Added. Calls out to the new delegate method if
+ implemented. Otherwise returns the default actions.
+
+ * UIProcess/ios/WKActionSheetAssistant.mm:
+ (-[WKActionSheetAssistant actionSheet:clickedButtonAtIndex:]): Use new _elementInfo ivar
+ instead of creating element info here.
+ (-[WKActionSheetAssistant showImageSheet]): Create element info here and assign it to
+ _elementInfo ivar if presenting a sheet. Call the UI client to get custom actions.
+ (-[WKActionSheetAssistant showLinkSheet]): Ditto.
+ (-[WKActionSheetAssistant cleanupSheet]): Clear _elementInfo ivar.
+ * WebKit2.xcodeproj/project.pbxproj: Added reference to WKUIDelegatePrivate.h.
+
</ins><span class="cx"> 2014-02-25 Michał Pakuła vel Rutka <m.pakula@samsung.com>
</span><span class="cx">
</span><span class="cx"> Unreviewed EFL build fix attempt after r164562
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKUIDelegatePrivateh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h (0 => 164666)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h         (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKUIDelegatePrivate.h        2014-02-25 21:10:14 UTC (rev 164666)
</span><span class="lines">@@ -0,0 +1,42 @@
</span><ins>+/*
+ * Copyright (C) 2014 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 <WebKit2/WKUIDelegate.h>
+
+#if WK_API_ENABLED
+
+#import <WebKit2/_WKActivatedElementInfo.h>
+
+@protocol WKUIDelegatePrivate <WKUIDelegate>
+
+@optional
+
+#if TARGET_OS_IPHONE
+- (NSArray *)_webView:(WKWebView *)webView actionsForElement:(_WKActivatedElementInfo *)element defaultActions:(NSArray *)defaultActions;
+#endif
+
+@end
+
+#endif // WK_API_ENABLED
</ins></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoa_WKActivatedElementInfoh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKActivatedElementInfo.h (164665 => 164666)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKActivatedElementInfo.h        2014-02-25 20:56:27 UTC (rev 164665)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKActivatedElementInfo.h        2014-02-25 21:10:14 UTC (rev 164666)
</span><span class="lines">@@ -29,11 +29,17 @@
</span><span class="cx">
</span><span class="cx"> #import <Foundation/Foundation.h>
</span><span class="cx">
</span><ins>+typedef NS_ENUM(NSInteger, _WKActivatedElementType) {
+ _WKActivatedElementTypeLink,
+ _WKActivatedElementTypeImage,
+};
+
</ins><span class="cx"> WK_API_CLASS
</span><span class="cx"> @interface _WKActivatedElementInfo : NSObject
</span><span class="cx">
</span><span class="cx"> @property (nonatomic, readonly) NSURL *URL;
</span><span class="cx"> @property (nonatomic, readonly) NSString *title;
</span><ins>+@property (nonatomic, readonly) _WKActivatedElementType type;
</ins><span class="cx">
</span><span class="cx"> @end
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoa_WKActivatedElementInfomm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKActivatedElementInfo.mm (164665 => 164666)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKActivatedElementInfo.mm        2014-02-25 20:56:27 UTC (rev 164665)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKActivatedElementInfo.mm        2014-02-25 21:10:14 UTC (rev 164666)
</span><span class="lines">@@ -37,7 +37,7 @@
</span><span class="cx"> CGRect _boundingRect;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-- (instancetype)_initWithURL:(NSURL *)url location:(CGPoint)location title:(NSString *)title rect:(CGRect)rect
</del><ins>+- (instancetype)_initWithType:(_WKActivatedElementType)type URL:(NSURL *)url location:(CGPoint)location title:(NSString *)title rect:(CGRect)rect
</ins><span class="cx"> {
</span><span class="cx"> if (!(self = [super init]))
</span><span class="cx"> return nil;
</span><span class="lines">@@ -46,6 +46,7 @@
</span><span class="cx"> _interactionLocation = location;
</span><span class="cx"> _title = adoptNS([title copy]);
</span><span class="cx"> _boundingRect = rect;
</span><ins>+ _type = type;
</ins><span class="cx">
</span><span class="cx"> return self;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoa_WKActivatedElementInfoInternalh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKActivatedElementInfoInternal.h (164665 => 164666)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKActivatedElementInfoInternal.h        2014-02-25 20:56:27 UTC (rev 164665)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKActivatedElementInfoInternal.h        2014-02-25 21:10:14 UTC (rev 164666)
</span><span class="lines">@@ -29,7 +29,7 @@
</span><span class="cx">
</span><span class="cx"> @interface _WKActivatedElementInfo ()
</span><span class="cx">
</span><del>-- (instancetype)_initWithURL:(NSURL *)url location:(CGPoint)location title:(NSString *)title rect:(CGRect)rect;
</del><ins>+- (instancetype)_initWithType:(_WKActivatedElementType)type URL:(NSURL *)url location:(CGPoint)location title:(NSString *)title rect:(CGRect)rect;
</ins><span class="cx">
</span><span class="cx"> @property (nonatomic, readonly) CGPoint _interactionLocation;
</span><span class="cx"> @property (nonatomic, readonly) CGRect _boundingRect;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaUIClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/UIClient.h (164665 => 164666)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/UIClient.h        2014-02-25 20:56:27 UTC (rev 164665)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/UIClient.h        2014-02-25 21:10:14 UTC (rev 164666)
</span><span class="lines">@@ -34,6 +34,7 @@
</span><span class="cx"> #import "WeakObjCPtr.h"
</span><span class="cx"> #import <wtf/RetainPtr.h>
</span><span class="cx">
</span><ins>+@class _WKActivatedElementInfo;
</ins><span class="cx"> @class WKWebView;
</span><span class="cx"> @protocol WKUIDelegate;
</span><span class="cx">
</span><span class="lines">@@ -47,6 +48,8 @@
</span><span class="cx"> RetainPtr<id <WKUIDelegate> > delegate();
</span><span class="cx"> void setDelegate(id <WKUIDelegate>);
</span><span class="cx">
</span><ins>+ NSArray *actionsForElement(_WKActivatedElementInfo *, NSArray *defaultActions);
+
</ins><span class="cx"> private:
</span><span class="cx"> // API::UIClient
</span><span class="cx"> virtual void runJavaScriptAlert(WebKit::WebPageProxy*, const WTF::String&, WebKit::WebFrameProxy*, std::function<void ()> completionHandler) override;
</span><span class="lines">@@ -60,6 +63,9 @@
</span><span class="cx"> bool webViewRunJavaScriptAlertPanelWithMessageInitiatedByFrameCompletionHandler : 1;
</span><span class="cx"> bool webViewRunJavaScriptConfirmPanelWithMessageInitiatedByFrameCompletionHandler : 1;
</span><span class="cx"> bool webViewRunJavaScriptTextInputPanelWithPromptDefaultTextInitiatedByFrameCompletionHandler : 1;
</span><ins>+#if PLATFORM(IOS)
+ bool webViewActionsForElementDefaultActions : 1;
+#endif
</ins><span class="cx"> } m_delegateMethods;
</span><span class="cx"> };
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaUIClientmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/UIClient.mm (164665 => 164666)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/UIClient.mm        2014-02-25 20:56:27 UTC (rev 164665)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/UIClient.mm        2014-02-25 21:10:14 UTC (rev 164666)
</span><span class="lines">@@ -29,7 +29,7 @@
</span><span class="cx"> #if WK_API_ENABLED
</span><span class="cx">
</span><span class="cx"> #import "WKFrameInfoInternal.h"
</span><del>-#import "WKUIDelegate.h"
</del><ins>+#import "WKUIDelegatePrivate.h"
</ins><span class="cx">
</span><span class="cx"> namespace WebKit {
</span><span class="cx">
</span><span class="lines">@@ -54,8 +54,26 @@
</span><span class="cx"> m_delegateMethods.webViewRunJavaScriptAlertPanelWithMessageInitiatedByFrameCompletionHandler = [delegate respondsToSelector:@selector(webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:)];
</span><span class="cx"> m_delegateMethods.webViewRunJavaScriptConfirmPanelWithMessageInitiatedByFrameCompletionHandler = [delegate respondsToSelector:@selector(webView:runJavaScriptConfirmPanelWithMessage:initiatedByFrame:completionHandler:)];
</span><span class="cx"> m_delegateMethods.webViewRunJavaScriptTextInputPanelWithPromptDefaultTextInitiatedByFrameCompletionHandler = [delegate respondsToSelector:@selector(webView:runJavaScriptTextInputPanelWithPrompt:defaultText:initiatedByFrame:completionHandler:)];
</span><ins>+#if PLATFORM(IOS)
+ m_delegateMethods.webViewActionsForElementDefaultActions = [delegate respondsToSelector:@selector(_webView:actionsForElement:defaultActions:)];
+#endif
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+NSArray *UIClient::actionsForElement(_WKActivatedElementInfo *elementInfo, NSArray *defaultActions)
+{
+#if PLATFORM(IOS)
+ if (!m_delegateMethods.webViewRunJavaScriptTextInputPanelWithPromptDefaultTextInitiatedByFrameCompletionHandler)
+ return defaultActions;
+
+ auto delegate = m_delegate.get();
+ if (!delegate)
+ return defaultActions;
+
+ return [(id <WKUIDelegatePrivate>)delegate _webView:m_webView actionsForElement:elementInfo defaultActions:defaultActions];
+#endif
+ return defaultActions;
+}
+
</ins><span class="cx"> void UIClient::runJavaScriptAlert(WebKit::WebPageProxy*, const WTF::String& message, WebKit::WebFrameProxy* webFrameProxy, std::function<void ()> completionHandler)
</span><span class="cx"> {
</span><span class="cx"> if (!m_delegateMethods.webViewRunJavaScriptAlertPanelWithMessageInitiatedByFrameCompletionHandler) {
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWKActionSheetAssistantmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.mm (164665 => 164666)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.mm        2014-02-25 20:56:27 UTC (rev 164665)
+++ trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.mm        2014-02-25 21:10:14 UTC (rev 164666)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx">
</span><span class="cx"> #import "_WKActivatedElementInfoInternal.h"
</span><span class="cx"> #import "_WKElementActionInternal.h"
</span><ins>+#import "UIClient.h"
</ins><span class="cx"> #import "WKActionSheet.h"
</span><span class="cx"> #import "WKContentViewInteraction.h"
</span><span class="cx"> #import "WebPageProxy.h"
</span><span class="lines">@@ -53,8 +54,11 @@
</span><span class="cx"> SOFT_LINK_PRIVATE_FRAMEWORK(DataDetectorsUI)
</span><span class="cx"> SOFT_LINK_CLASS(DataDetectorsUI, DDDetectionController)
</span><span class="cx">
</span><ins>+using namespace WebKit;
+
</ins><span class="cx"> @implementation WKActionSheetAssistant {
</span><span class="cx"> RetainPtr<WKActionSheet> _interactionSheet;
</span><ins>+ RetainPtr<_WKActivatedElementInfo> _elementInfo;
</ins><span class="cx"> RetainPtr<NSArray> _elementActions;
</span><span class="cx"> WKContentView *_view;
</span><span class="cx"> }
</span><span class="lines">@@ -154,12 +158,8 @@
</span><span class="cx"> if (actionSheet != _interactionSheet)
</span><span class="cx"> return;
</span><span class="cx">
</span><del>- if (_elementActions && buttonIndex < (NSInteger)[_elementActions count]) {
- _WKActivatedElementInfo *actionInfo = [[_WKActivatedElementInfo alloc] _initWithURL:[NSURL URLWithString:_view.positionInformation.url]
- location:_view.positionInformation.point title:_view.positionInformation.title rect:_view.positionInformation.bounds];
- [[_elementActions objectAtIndex:buttonIndex] _runActionWithElementInfo:actionInfo view:_view];
- [actionInfo release];
- }
</del><ins>+ if (_elementActions && buttonIndex < (NSInteger)[_elementActions count])
+ [[_elementActions objectAtIndex:buttonIndex] _runActionWithElementInfo:_elementInfo.get() view:_view];
</ins><span class="cx">
</span><span class="cx"> [self cleanupSheet];
</span><span class="cx"> }
</span><span class="lines">@@ -215,24 +215,35 @@
</span><span class="cx"> - (void)showImageSheet
</span><span class="cx"> {
</span><span class="cx"> ASSERT(!_interactionSheet);
</span><ins>+ ASSERT(!_elementInfo);
</ins><span class="cx">
</span><del>- NSURL *targetURL = [NSURL URLWithString:_view.positionInformation.url];
- NSMutableArray *actions = [NSMutableArray array];
- if (!_view.positionInformation.url.isEmpty())
- [actions addObject:[_WKElementAction elementActionWithType:_WKElementActionTypeOpen]];
</del><ins>+ const auto& positionInformation = _view.positionInformation;
+
+ NSURL *targetURL = [NSURL URLWithString:positionInformation.url];
+ NSMutableArray *defaultActions = [NSMutableArray array];
+ if (!positionInformation.url.isEmpty())
+ [defaultActions addObject:[_WKElementAction elementActionWithType:_WKElementActionTypeOpen]];
</ins><span class="cx"> if ([getSSReadingListClass() supportsURL:targetURL])
</span><del>- [actions addObject:[_WKElementAction elementActionWithType:_WKElementActionTypeAddToReadingList]];
</del><ins>+ [defaultActions addObject:[_WKElementAction elementActionWithType:_WKElementActionTypeAddToReadingList]];
</ins><span class="cx"> if (TCCAccessPreflight(getkTCCServicePhotos(), NULL) != kTCCAccessPreflightDenied)
</span><del>- [actions addObject:[_WKElementAction elementActionWithType:_WKElementActionTypeSaveImage]];
- if (![[targetURL scheme] length] || [[targetURL scheme] caseInsensitiveCompare:@"javascript"] != NSOrderedSame)
- [actions addObject:[_WKElementAction elementActionWithType:_WKElementActionTypeCopy]];
</del><ins>+ [defaultActions addObject:[_WKElementAction elementActionWithType:_WKElementActionTypeSaveImage]];
+ if (!targetURL.scheme.length || [targetURL.scheme caseInsensitiveCompare:@"javascript"] != NSOrderedSame)
+ [defaultActions addObject:[_WKElementAction elementActionWithType:_WKElementActionTypeCopy]];
</ins><span class="cx">
</span><del>- // FIXME: Add call to delegate to add custom actions.
</del><ins>+ RetainPtr<_WKActivatedElementInfo> elementInfo = adoptNS([[_WKActivatedElementInfo alloc] _initWithType:_WKActivatedElementTypeImage
+ URL:targetURL location:positionInformation.point title:positionInformation.title rect:positionInformation.bounds]);
</ins><span class="cx">
</span><del>- [self _createSheetWithElementActions:actions showLinkTitle:YES];
</del><ins>+ RetainPtr<NSArray> actions = static_cast<UIClient&>(_view.page->uiClient()).actionsForElement(elementInfo.get(), [[defaultActions copy] autorelease]);
+
+ if (![actions count])
+ return;
+
+ [self _createSheetWithElementActions:actions.get() showLinkTitle:YES];
</ins><span class="cx"> if (!_interactionSheet)
</span><span class="cx"> return;
</span><span class="cx">
</span><ins>+ _elementInfo = std::move(elementInfo);
+
</ins><span class="cx"> if (![_interactionSheet presentSheet])
</span><span class="cx"> [self actionSheet:_interactionSheet.get() clickedButtonAtIndex:[_interactionSheet cancelButtonIndex]];
</span><span class="cx"> }
</span><span class="lines">@@ -240,23 +251,35 @@
</span><span class="cx"> - (void)showLinkSheet
</span><span class="cx"> {
</span><span class="cx"> ASSERT(!_interactionSheet);
</span><del>- NSURL *targetURL = [NSURL URLWithString:_view.positionInformation.url];
</del><ins>+ ASSERT(!_elementInfo);
+
+ const auto& positionInformation = _view.positionInformation;
+
+ NSURL *targetURL = [NSURL URLWithString:positionInformation.url];
</ins><span class="cx"> if (!targetURL)
</span><span class="cx"> return;
</span><span class="cx">
</span><del>- NSMutableArray *actions = [NSMutableArray array];
- [actions addObject:[_WKElementAction elementActionWithType:_WKElementActionTypeOpen]];
</del><ins>+ NSMutableArray *defaultActions = [NSMutableArray array];
+ [defaultActions addObject:[_WKElementAction elementActionWithType:_WKElementActionTypeOpen]];
</ins><span class="cx"> if ([getSSReadingListClass() supportsURL:targetURL])
</span><del>- [actions addObject:[_WKElementAction elementActionWithType:_WKElementActionTypeAddToReadingList]];
</del><ins>+ [defaultActions addObject:[_WKElementAction elementActionWithType:_WKElementActionTypeAddToReadingList]];
</ins><span class="cx"> if (![[targetURL scheme] length] || [[targetURL scheme] caseInsensitiveCompare:@"javascript"] != NSOrderedSame)
</span><del>- [actions addObject:[_WKElementAction elementActionWithType:_WKElementActionTypeCopy]];
</del><ins>+ [defaultActions addObject:[_WKElementAction elementActionWithType:_WKElementActionTypeCopy]];
</ins><span class="cx">
</span><del>- // FIXME: Add call to delegate to add custom actions.
</del><ins>+ RetainPtr<_WKActivatedElementInfo> elementInfo = adoptNS([[_WKActivatedElementInfo alloc] _initWithType:_WKActivatedElementTypeLink
+ URL:targetURL location:positionInformation.point title:positionInformation.title rect:positionInformation.bounds]);
</ins><span class="cx">
</span><del>- [self _createSheetWithElementActions:actions showLinkTitle:YES];
</del><ins>+ RetainPtr<NSArray> actions = static_cast<UIClient&>(_view.page->uiClient()).actionsForElement(elementInfo.get(), [[defaultActions copy] autorelease]);
+
+ if (![actions count])
+ return;
+
+ [self _createSheetWithElementActions:actions.get() showLinkTitle:YES];
</ins><span class="cx"> if (!_interactionSheet)
</span><span class="cx"> return;
</span><span class="cx">
</span><ins>+ _elementInfo = std::move(elementInfo);
+
</ins><span class="cx"> if (![_interactionSheet presentSheet])
</span><span class="cx"> [self actionSheet:_interactionSheet.get() clickedButtonAtIndex:[_interactionSheet cancelButtonIndex]];
</span><span class="cx"> }
</span><span class="lines">@@ -321,6 +344,7 @@
</span><span class="cx"> [_interactionSheet setSheetDelegate:nil];
</span><span class="cx"> [_interactionSheet setDelegate:nil];
</span><span class="cx"> _interactionSheet = nil;
</span><ins>+ _elementInfo = nil;
</ins><span class="cx">
</span><span class="cx"> _elementActions = nil;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (164665 => 164666)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2014-02-25 20:56:27 UTC (rev 164665)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2014-02-25 21:10:14 UTC (rev 164666)
</span><span class="lines">@@ -600,6 +600,7 @@
</span><span class="cx">                 373D122518A473B30066D9CC /* WKBrowsingContextHandleInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 373D122418A473B30066D9CC /* WKBrowsingContextHandleInternal.h */; };
</span><span class="cx">                 373D122718A473F60066D9CC /* WKFrameHandleInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 373D122618A473F60066D9CC /* WKFrameHandleInternal.h */; };
</span><span class="cx">                 373D122D18A4B6EB0066D9CC /* WKWebProcessPlugInFramePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 373D122C18A4B6A80066D9CC /* WKWebProcessPlugInFramePrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><ins>+                3743925818BC4C60001C8675 /* WKUIDelegatePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 3743925718BC4C60001C8675 /* WKUIDelegatePrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 374436881820E7240049579F /* WKObject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 374436871820E7240049579F /* WKObject.mm */; };
</span><span class="cx">                 3760881E150413E900FC82C7 /* WebRenderObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3760881C150413E900FC82C7 /* WebRenderObject.cpp */; };
</span><span class="cx">                 3760881F150413E900FC82C7 /* WebRenderObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 3760881D150413E900FC82C7 /* WebRenderObject.h */; };
</span><span class="lines">@@ -2333,6 +2334,7 @@
</span><span class="cx">                 373D122418A473B30066D9CC /* WKBrowsingContextHandleInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKBrowsingContextHandleInternal.h; sourceTree = "<group>"; };
</span><span class="cx">                 373D122618A473F60066D9CC /* WKFrameHandleInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKFrameHandleInternal.h; sourceTree = "<group>"; };
</span><span class="cx">                 373D122C18A4B6A80066D9CC /* WKWebProcessPlugInFramePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebProcessPlugInFramePrivate.h; sourceTree = "<group>"; };
</span><ins>+                3743925718BC4C60001C8675 /* WKUIDelegatePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKUIDelegatePrivate.h; sourceTree = "<group>"; };
</ins><span class="cx">                 374436871820E7240049579F /* WKObject.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKObject.mm; sourceTree = "<group>"; };
</span><span class="cx">                 375FB4731883415600BE34D4 /* Info-iOS.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Info-iOS.plist"; sourceTree = "<group>"; };
</span><span class="cx">                 3760881C150413E900FC82C7 /* WebRenderObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebRenderObject.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -4448,6 +4450,7 @@
</span><span class="cx">                                 1A43E82B188F3CF5009E4D30 /* WKProcessPoolConfigurationPrivate.h */,
</span><span class="cx">                                 1A3CC16818907EB0001E6ED8 /* WKProcessPoolInternal.h */,
</span><span class="cx">                                 1AD8790918B6C38A006CAFD7 /* WKUIDelegate.h */,
</span><ins>+                                3743925718BC4C60001C8675 /* WKUIDelegatePrivate.h */,
</ins><span class="cx">                                 1A3CC16518906ACF001E6ED8 /* WKWebView.h */,
</span><span class="cx">                                 1A3CC16418906ACF001E6ED8 /* WKWebView.mm */,
</span><span class="cx">                                 1ADF59191890528E0043C145 /* WKWebViewConfiguration.h */,
</span><span class="lines">@@ -6541,6 +6544,7 @@
</span><span class="cx">                                 1A7865BA16CAC71500ACE83A /* PluginProcessConnectionManagerMessages.h in Headers */,
</span><span class="cx">                                 1A2BB6D114117B4D000F35D4 /* PluginProcessConnectionMessages.h in Headers */,
</span><span class="cx">                                 1A2D90D21281C966001EB962 /* PluginProcessCreationParameters.h in Headers */,
</span><ins>+                                3743925818BC4C60001C8675 /* WKUIDelegatePrivate.h in Headers */,
</ins><span class="cx">                                 1A0EC603124A9F2C007EF4A5 /* PluginProcessManager.h in Headers */,
</span><span class="cx">                                 0FCB4E6618BBE3D9000FCFC9 /* WKPrintingView.h in Headers */,
</span><span class="cx">                                 1A1EC69E1872092100B951F0 /* ImportanceAssertion.h in Headers */,
</span></span></pre>
</div>
</div>
</body>
</html>