<!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>[169962] 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/169962">169962</a></dd>
<dt>Author</dt> <dd>mitz@apple.com</dd>
<dt>Date</dt> <dd>2014-06-13 22:32:07 -0700 (Fri, 13 Jun 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Make GenericCallback variadic
https://bugs.webkit.org/show_bug.cgi?id=133897
Reviewed by Sam Weinig.
Also eliminated legacy callback functions and all CallbackBase derived classes outside of
GenericCallback.h.
* UIProcess/API/C/WKPage.cpp:
(WKPageValidateCommand): Changed legacy callback (with leading bool parameter) into modern
callback (with trailing error parameter).
(WKPageComputePagesForPrinting): Ditto.
* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _getWebArchiveDataWithCompletionHandler:]): Ditto.
(-[WKWebView _snapshotRect:intoImageOfWidth:completionHandler:]): Ditto.
* UIProcess/API/Cocoa/_WKThumbnailView.mm:
(-[_WKThumbnailView _requestSnapshotIfNeeded]): Ditto.
* UIProcess/API/mac/WKView.mm:
(-[WKView validateUserInterfaceItem:]): Ditto.
(-[WKView startSpeaking:]): Ditto.
* UIProcess/AutoCorrectionCallback.h: Replaced CallbackBase derived classes with
GenericCallback specializations.
* UIProcess/GenericCallback.h:
- Made GenericCallback variadic:
(WebKit::GenericCallback::performCallbackWithReturnValue):
(WebKit::GenericCallback::invalidate):
(WebKit::GenericAPICallback::create):
- Replaced CallbackBase derived classes with GenericCallback specializations:
(WebKit::GenericCallback::create): Deleted.
(WebKit::ComputedPagesCallback::create): Deleted.
(WebKit::ComputedPagesCallback::~ComputedPagesCallback): Deleted.
(WebKit::ComputedPagesCallback::performCallbackWithReturnValue): Deleted.
(WebKit::ComputedPagesCallback::invalidate): Deleted.
(WebKit::ComputedPagesCallback::ComputedPagesCallback): Deleted.
(WebKit::ImageCallback::create): Deleted.
(WebKit::ImageCallback::~ImageCallback): Deleted.
(WebKit::ImageCallback::performCallbackWithReturnValue): Deleted.
(WebKit::ImageCallback::invalidate): Deleted.
(WebKit::ImageCallback::ImageCallback): Deleted.
* UIProcess/WebPageProxy.h: Replaced CallbackBase derived classes with GenericCallback
specializations.
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView requestAutocorrectionRectsForString:withCompletionHandler:]): Changed
legacy callback (with leading bool parameter) into modern callback (with trailing error
parameter).
(-[WKContentView requestDictationContext:]): Ditto.
(-[WKContentView requestAutocorrectionContextWithCompletionHandler:]): Ditto.
* UIProcess/mac/WKPrintingView.mm:
(-[WKPrintingView _preparePDFDataForPrintingOnSecondaryThread]): Ditto.
(-[WKPrintingView _askPageToComputePageRects]): Ditto.
(-[WKPrintingView _drawPreview:]): Ditto.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICWKPagecpp">trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoa_WKThumbnailViewmm">trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKThumbnailView.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPImacWKViewmm">trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAutoCorrectionCallbackh">trunk/Source/WebKit2/UIProcess/AutoCorrectionCallback.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessGenericCallbackh">trunk/Source/WebKit2/UIProcess/GenericCallback.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxyh">trunk/Source/WebKit2/UIProcess/WebPageProxy.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWKContentViewInteractionmm">trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacWKPrintingViewmm">trunk/Source/WebKit2/UIProcess/mac/WKPrintingView.mm</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (169961 => 169962)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-06-14 05:09:37 UTC (rev 169961)
+++ trunk/Source/WebKit2/ChangeLog        2014-06-14 05:32:07 UTC (rev 169962)
</span><span class="lines">@@ -1,3 +1,66 @@
</span><ins>+2014-06-13 Dan Bernstein <mitz@apple.com>
+
+ Make GenericCallback variadic
+ https://bugs.webkit.org/show_bug.cgi?id=133897
+
+ Reviewed by Sam Weinig.
+
+ Also eliminated legacy callback functions and all CallbackBase derived classes outside of
+ GenericCallback.h.
+
+ * UIProcess/API/C/WKPage.cpp:
+ (WKPageValidateCommand): Changed legacy callback (with leading bool parameter) into modern
+ callback (with trailing error parameter).
+ (WKPageComputePagesForPrinting): Ditto.
+
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView _getWebArchiveDataWithCompletionHandler:]): Ditto.
+ (-[WKWebView _snapshotRect:intoImageOfWidth:completionHandler:]): Ditto.
+
+ * UIProcess/API/Cocoa/_WKThumbnailView.mm:
+ (-[_WKThumbnailView _requestSnapshotIfNeeded]): Ditto.
+
+ * UIProcess/API/mac/WKView.mm:
+ (-[WKView validateUserInterfaceItem:]): Ditto.
+ (-[WKView startSpeaking:]): Ditto.
+
+ * UIProcess/AutoCorrectionCallback.h: Replaced CallbackBase derived classes with
+ GenericCallback specializations.
+
+ * UIProcess/GenericCallback.h:
+ - Made GenericCallback variadic:
+ (WebKit::GenericCallback::performCallbackWithReturnValue):
+ (WebKit::GenericCallback::invalidate):
+ (WebKit::GenericAPICallback::create):
+
+ - Replaced CallbackBase derived classes with GenericCallback specializations:
+ (WebKit::GenericCallback::create): Deleted.
+ (WebKit::ComputedPagesCallback::create): Deleted.
+ (WebKit::ComputedPagesCallback::~ComputedPagesCallback): Deleted.
+ (WebKit::ComputedPagesCallback::performCallbackWithReturnValue): Deleted.
+ (WebKit::ComputedPagesCallback::invalidate): Deleted.
+ (WebKit::ComputedPagesCallback::ComputedPagesCallback): Deleted.
+ (WebKit::ImageCallback::create): Deleted.
+ (WebKit::ImageCallback::~ImageCallback): Deleted.
+ (WebKit::ImageCallback::performCallbackWithReturnValue): Deleted.
+ (WebKit::ImageCallback::invalidate): Deleted.
+ (WebKit::ImageCallback::ImageCallback): Deleted.
+
+ * UIProcess/WebPageProxy.h: Replaced CallbackBase derived classes with GenericCallback
+ specializations.
+
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (-[WKContentView requestAutocorrectionRectsForString:withCompletionHandler:]): Changed
+ legacy callback (with leading bool parameter) into modern callback (with trailing error
+ parameter).
+ (-[WKContentView requestDictationContext:]): Ditto.
+ (-[WKContentView requestAutocorrectionContextWithCompletionHandler:]): Ditto.
+
+ * UIProcess/mac/WKPrintingView.mm:
+ (-[WKPrintingView _preparePDFDataForPrintingOnSecondaryThread]): Ditto.
+ (-[WKPrintingView _askPageToComputePageRects]): Ditto.
+ (-[WKPrintingView _drawPreview:]): Ditto.
+
</ins><span class="cx"> 2014-06-13 Tim Horton <timothy_horton@apple.com>
</span><span class="cx">
</span><span class="cx"> Unreviewed; fix the build.
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICWKPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp (169961 => 169962)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp        2014-06-14 05:09:37 UTC (rev 169961)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp        2014-06-14 05:32:07 UTC (rev 169962)
</span><span class="lines">@@ -1657,8 +1657,8 @@
</span><span class="cx">
</span><span class="cx"> void WKPageValidateCommand(WKPageRef pageRef, WKStringRef command, void* context, WKPageValidateCommandCallback callback)
</span><span class="cx"> {
</span><del>- toImpl(pageRef)->validateCommand(toImpl(command)->string(), ValidateCommandCallback::create([context, callback](bool error, StringImpl* commandName, bool isEnabled, int32_t state) {
- callback(toAPI(commandName), isEnabled, state, error ? toAPI(API::Error::create().get()) : 0, context);
</del><ins>+ toImpl(pageRef)->validateCommand(toImpl(command)->string(), ValidateCommandCallback::create([context, callback](StringImpl* commandName, bool isEnabled, int32_t state, CallbackBase::Error error) {
+ callback(toAPI(commandName), isEnabled, state, error != CallbackBase::Error::None ? toAPI(API::Error::create().get()) : 0, context);
</ins><span class="cx"> }));
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1679,11 +1679,11 @@
</span><span class="cx">
</span><span class="cx"> void WKPageComputePagesForPrinting(WKPageRef page, WKFrameRef frame, WKPrintInfo printInfo, WKPageComputePagesForPrintingFunction callback, void* context)
</span><span class="cx"> {
</span><del>- toImpl(page)->computePagesForPrinting(toImpl(frame), printInfoFromWKPrintInfo(printInfo), ComputedPagesCallback::create([context, callback](bool error, const Vector<WebCore::IntRect>& rects, double scaleFactor) {
</del><ins>+ toImpl(page)->computePagesForPrinting(toImpl(frame), printInfoFromWKPrintInfo(printInfo), ComputedPagesCallback::create([context, callback](const Vector<WebCore::IntRect>& rects, double scaleFactor, CallbackBase::Error error) {
</ins><span class="cx"> Vector<WKRect> wkRects(rects.size());
</span><span class="cx"> for (size_t i = 0; i < rects.size(); ++i)
</span><span class="cx"> wkRects[i] = toAPI(rects[i]);
</span><del>- callback(wkRects.data(), wkRects.size(), scaleFactor, error ? toAPI(API::Error::create().get()) : 0, context);
</del><ins>+ callback(wkRects.data(), wkRects.size(), scaleFactor, error != CallbackBase::Error::None ? toAPI(API::Error::create().get()) : 0, context);
</ins><span class="cx"> }));
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (169961 => 169962)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2014-06-14 05:09:37 UTC (rev 169961)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2014-06-14 05:32:07 UTC (rev 169962)
</span><span class="lines">@@ -1520,9 +1520,9 @@
</span><span class="cx"> {
</span><span class="cx"> auto handler = adoptNS([completionHandler copy]);
</span><span class="cx">
</span><del>- _page->getWebArchiveOfFrame(_page->mainFrame(), WebKit::DataCallback::create([handler](bool isError, API::Data* data) {
</del><ins>+ _page->getWebArchiveOfFrame(_page->mainFrame(), WebKit::DataCallback::create([handler](API::Data* data, WebKit::CallbackBase::Error error) {
</ins><span class="cx"> void (^completionHandlerBlock)(NSData *, NSError *) = (void (^)(NSData *, NSError *))handler.get();
</span><del>- if (isError) {
</del><ins>+ if (error != WebKit::CallbackBase::Error::None) {
</ins><span class="cx"> // FIXME: Pipe a proper error in from the WebPageProxy.
</span><span class="cx"> RetainPtr<NSError> error = adoptNS([[NSError alloc] init]);
</span><span class="cx"> completionHandlerBlock(nil, error.get());
</span><span class="lines">@@ -2030,7 +2030,7 @@
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> void(^copiedCompletionHandler)(CGImageRef) = [completionHandler copy];
</span><del>- _page->takeSnapshot(WebCore::enclosingIntRect(snapshotRectInContentCoordinates), WebCore::expandedIntSize(WebCore::FloatSize(imageSize)), WebKit::SnapshotOptionsExcludeDeviceScaleFactor, [=](bool, const WebKit::ShareableBitmap::Handle& imageHandle) {
</del><ins>+ _page->takeSnapshot(WebCore::enclosingIntRect(snapshotRectInContentCoordinates), WebCore::expandedIntSize(WebCore::FloatSize(imageSize)), WebKit::SnapshotOptionsExcludeDeviceScaleFactor, [=](const WebKit::ShareableBitmap::Handle& imageHandle, CallbackBase::Error) {
</ins><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> // Automatically delete when this goes out of scope.
</span><span class="cx"> auto uniqueActivityToken = std::unique_ptr<WebKit::ProcessThrottler::BackgroundActivityToken>(activityToken);
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoa_WKThumbnailViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKThumbnailView.mm (169961 => 169962)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKThumbnailView.mm        2014-06-14 05:09:37 UTC (rev 169961)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKThumbnailView.mm        2014-06-14 05:32:07 UTC (rev 169962)
</span><span class="lines">@@ -129,7 +129,7 @@
</span><span class="cx"> IntSize bitmapSize = snapshotRect.size();
</span><span class="cx"> bitmapSize.scale(_scale * _webPageProxy->deviceScaleFactor());
</span><span class="cx"> _lastSnapshotScale = _scale;
</span><del>- _webPageProxy->takeSnapshot(snapshotRect, bitmapSize, options, [thumbnailView](bool, const ShareableBitmap::Handle& imageHandle) {
</del><ins>+ _webPageProxy->takeSnapshot(snapshotRect, bitmapSize, options, [thumbnailView](const ShareableBitmap::Handle& imageHandle, CallbackBase::Error) {
</ins><span class="cx"> RefPtr<ShareableBitmap> bitmap = ShareableBitmap::create(imageHandle, SharedMemory::ReadOnly);
</span><span class="cx"> RetainPtr<CGImageRef> cgImage = bitmap ? bitmap->makeCGImage() : nullptr;
</span><span class="cx"> [thumbnailView _didTakeSnapshot:cgImage.get()];
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPImacWKViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm (169961 => 169962)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm        2014-06-14 05:09:37 UTC (rev 169961)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm        2014-06-14 05:32:07 UTC (rev 169962)
</span><span class="lines">@@ -835,9 +835,9 @@
</span><span class="cx"> // If we are not already awaiting validation for this command, start the asynchronous validation process.
</span><span class="cx"> // FIXME: Theoretically, there is a race here; when we get the answer it might be old, from a previous time
</span><span class="cx"> // we asked for the same command; there is no guarantee the answer is still valid.
</span><del>- _data->_page->validateCommand(commandName, ValidateCommandCallback::create([self](bool error, StringImpl* commandName, bool isEnabled, int32_t state) {
</del><ins>+ _data->_page->validateCommand(commandName, ValidateCommandCallback::create([self](StringImpl* commandName, bool isEnabled, int32_t state, CallbackBase::Error error) {
</ins><span class="cx"> // If the process exits before the command can be validated, we'll be called back with an error.
</span><del>- if (error)
</del><ins>+ if (error != CallbackBase::Error::None)
</ins><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> [self _setUserInterfaceItemState:nsStringFromWebCoreString(commandName) enabled:isEnabled state:state];
</span><span class="lines">@@ -852,8 +852,8 @@
</span><span class="cx">
</span><span class="cx"> - (IBAction)startSpeaking:(id)sender
</span><span class="cx"> {
</span><del>- _data->_page->getSelectionOrContentsAsString(StringCallback::create([self](bool error, StringImpl* string) {
- if (error)
</del><ins>+ _data->_page->getSelectionOrContentsAsString(StringCallback::create([self](StringImpl* string, CallbackBase::Error error) {
+ if (error != CallbackBase::Error::None)
</ins><span class="cx"> return;
</span><span class="cx"> if (!string)
</span><span class="cx"> return;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAutoCorrectionCallbackh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/AutoCorrectionCallback.h (169961 => 169962)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/AutoCorrectionCallback.h        2014-06-14 05:09:37 UTC (rev 169961)
+++ trunk/Source/WebKit2/UIProcess/AutoCorrectionCallback.h        2014-06-14 05:32:07 UTC (rev 169962)
</span><span class="lines">@@ -35,130 +35,10 @@
</span><span class="cx">
</span><span class="cx"> namespace WebKit {
</span><span class="cx">
</span><del>-class AutocorrectionDataCallback : public CallbackBase {
-public:
- typedef std::function<void (bool, const Vector<WebCore::FloatRect>&, const String&, double, uint64_t)> CallbackFunction;
</del><ins>+typedef GenericCallback<const Vector<WebCore::FloatRect>&, const String&, double, uint64_t> AutocorrectionDataCallback;
+typedef GenericCallback<const String&, const String&, const String&, const String&, uint64_t, uint64_t> AutocorrectionContextCallback;
+typedef GenericCallback<const String&, const String&, const String&> DictationContextCallback;
</ins><span class="cx">
</span><del>- static PassRefPtr<AutocorrectionDataCallback> create(CallbackFunction callback)
- {
- return adoptRef(new AutocorrectionDataCallback(callback));
- }
-
- virtual ~AutocorrectionDataCallback()
- {
- ASSERT(!m_callback);
- }
-
- void performCallbackWithReturnValue(const Vector<WebCore::FloatRect>& returnValue1, const String& returnValue2, double returnValue3, uint64_t returnValue4)
- {
- ASSERT(m_callback);
-
- m_callback(false, returnValue1, returnValue2, returnValue3, returnValue4);
-
- m_callback = 0;
- }
-
- void invalidate()
- {
- ASSERT(m_callback);
-
- m_callback(true, Vector<WebCore::FloatRect>(), String(), 0, 0);
-
- m_callback = 0;
- }
-
-private:
- AutocorrectionDataCallback(CallbackFunction callback)
- : m_callback(callback)
- {
- ASSERT(m_callback);
- }
-
- CallbackFunction m_callback;
-};
-
-class AutocorrectionContextCallback : public CallbackBase {
-public:
- typedef std::function<void (bool, const String&, const String&, const String&, const String&, uint64_t, uint64_t)> CallbackFunction;
-
- static PassRefPtr<AutocorrectionContextCallback> create(CallbackFunction callback)
- {
- return adoptRef(new AutocorrectionContextCallback(callback));
- }
-
- virtual ~AutocorrectionContextCallback()
- {
- ASSERT(!m_callback);
- }
-
- void performCallbackWithReturnValue(const String& returnValue1, const String& returnValue2, const String& returnValue3, const String& returnValue4, uint64_t returnValue5, uint64_t returnValue6)
- {
- ASSERT(m_callback);
-
- m_callback(false, returnValue1, returnValue2, returnValue3, returnValue4, returnValue5, returnValue6);
-
- m_callback = 0;
- }
-
- void invalidate()
- {
- ASSERT(m_callback);
-
- m_callback(true, String(), String(), String(), String(), 0, 0);
-
- m_callback = 0;
- }
-
-private:
- AutocorrectionContextCallback(CallbackFunction callback)
- : m_callback(callback)
- {
- ASSERT(m_callback);
- }
-
- CallbackFunction m_callback;
-};
-
-class DictationContextCallback : public CallbackBase {
-public:
- typedef std::function<void (bool, const String&, const String&, const String&)> CallbackFunction;
-
- static PassRefPtr<DictationContextCallback> create(CallbackFunction callback)
- {
- return adoptRef(new DictationContextCallback(callback));
- }
-
- virtual ~DictationContextCallback()
- {
- ASSERT(!m_callback);
- }
-
- void performCallbackWithReturnValue(const String& returnValue1, const String& returnValue2, const String& returnValue3)
- {
- ASSERT(m_callback);
-
- m_callback(false, returnValue1, returnValue2, returnValue3);
- m_callback = nullptr;
- }
-
- void invalidate()
- {
- ASSERT(m_callback);
-
- m_callback(true, String(), String(), String());
- m_callback = nullptr;
- }
-
-private:
- DictationContextCallback(CallbackFunction callback)
- : m_callback(callback)
- {
- ASSERT(m_callback);
- }
-
- CallbackFunction m_callback;
-};
-
</del><span class="cx"> } // namespace WebKit
</span><span class="cx">
</span><span class="cx"> #endif // AutoCorrectionCallback_h
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessGenericCallbackh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/GenericCallback.h (169961 => 169962)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/GenericCallback.h        2014-06-14 05:09:37 UTC (rev 169961)
+++ trunk/Source/WebKit2/UIProcess/GenericCallback.h        2014-06-14 05:32:07 UTC (rev 169962)
</span><span class="lines">@@ -124,36 +124,27 @@
</span><span class="cx"> }
</span><span class="cx"> };
</span><span class="cx">
</span><del>-template<typename T>
</del><ins>+template<typename... T>
</ins><span class="cx"> class GenericCallback : public CallbackBase {
</span><span class="cx"> public:
</span><del>- typedef std::function<void (T, Error)> CallbackFunction;
</del><ins>+ typedef std::function<void (T..., Error)> CallbackFunction;
</ins><span class="cx">
</span><span class="cx"> static PassRefPtr<GenericCallback> create(CallbackFunction callback)
</span><span class="cx"> {
</span><span class="cx"> return adoptRef(new GenericCallback(callback));
</span><span class="cx"> }
</span><span class="cx">
</span><del>- // FIXME: Get rid of this legacy version.
- typedef std::function<void (bool, T)> LegacyCallbackFunction;
- static PassRefPtr<GenericCallback> create(LegacyCallbackFunction callback)
- {
- return adoptRef(new GenericCallback([callback](T t, Error error) {
- callback(error != Error::None, std::move(t));
- }));
- }
-
</del><span class="cx"> virtual ~GenericCallback()
</span><span class="cx"> {
</span><span class="cx"> ASSERT(!m_callback);
</span><span class="cx"> }
</span><span class="cx">
</span><del>- void performCallbackWithReturnValue(T returnValue)
</del><ins>+ void performCallbackWithReturnValue(T... returnValue)
</ins><span class="cx"> {
</span><span class="cx"> if (!m_callback)
</span><span class="cx"> return;
</span><span class="cx">
</span><del>- m_callback(returnValue, Error::None);
</del><ins>+ m_callback(returnValue..., Error::None);
</ins><span class="cx">
</span><span class="cx"> m_callback = nullptr;
</span><span class="cx"> }
</span><span class="lines">@@ -163,7 +154,7 @@
</span><span class="cx"> if (!m_callback)
</span><span class="cx"> return;
</span><span class="cx">
</span><del>- m_callback(T(), error);
</del><ins>+ m_callback(typename std::remove_reference<T>::type()..., error);
</ins><span class="cx">
</span><span class="cx"> m_callback = nullptr;
</span><span class="cx"> }
</span><span class="lines">@@ -184,99 +175,15 @@
</span><span class="cx">
</span><span class="cx"> static PassRefPtr<GenericCallback<InternalReturnValueType>> create(void* context, CallbackFunction callback)
</span><span class="cx"> {
</span><del>- return GenericCallback<InternalReturnValueType>::create([context, callback](bool error, InternalReturnValueType returnValue) {
- callback(toAPI(returnValue), error ? toAPI(API::Error::create().get()) : 0, context);
</del><ins>+ return GenericCallback<InternalReturnValueType>::create([context, callback](InternalReturnValueType returnValue, CallbackBase::Error error) {
+ callback(toAPI(returnValue), error != CallbackBase::Error::None ? toAPI(API::Error::create().get()) : 0, context);
</ins><span class="cx"> });
</span><span class="cx"> }
</span><span class="cx"> };
</span><span class="cx">
</span><del>-// FIXME: Make a version of GenericCallback with two arguments, and define ComputedPagesCallback as a specialization.
-class ComputedPagesCallback : public CallbackBase {
-public:
- typedef std::function<void (bool, const Vector<WebCore::IntRect>&, double)> CallbackFunction;
</del><ins>+typedef GenericCallback<const Vector<WebCore::IntRect>&, double> ComputedPagesCallback;
+typedef GenericCallback<const ShareableBitmap::Handle&> ImageCallback;
</ins><span class="cx">
</span><del>- static PassRefPtr<ComputedPagesCallback> create(CallbackFunction callback)
- {
- return adoptRef(new ComputedPagesCallback(callback));
- }
-
- virtual ~ComputedPagesCallback()
- {
- ASSERT(!m_callback);
- }
-
- void performCallbackWithReturnValue(const Vector<WebCore::IntRect>& returnValue1, double returnValue2)
- {
- ASSERT(m_callback);
-
- m_callback(false, returnValue1, returnValue2);
-
- m_callback = 0;
- }
-
- void invalidate()
- {
- ASSERT(m_callback);
-
- m_callback(true, Vector<WebCore::IntRect>(), 0);
-
- m_callback = 0;
- }
-
-private:
-
- ComputedPagesCallback(CallbackFunction callback)
- : m_callback(callback)
- {
- }
-
- CallbackFunction m_callback;
-};
-
-class ImageCallback : public CallbackBase {
-public:
- typedef std::function<void (bool, const ShareableBitmap::Handle&)> CallbackFunction;
-
- static PassRefPtr<ImageCallback> create(CallbackFunction callback)
- {
- return adoptRef(new ImageCallback(callback));
- }
-
- virtual ~ImageCallback()
- {
- ASSERT(!m_callback);
- }
-
- void performCallbackWithReturnValue(const ShareableBitmap::Handle& returnValue1)
- {
- ASSERT(m_callback);
-
- m_callback(false, returnValue1);
-
- m_callback = 0;
- }
-
- void invalidate()
- {
- ASSERT(m_callback);
-
- RefPtr<API::Error> error = API::Error::create();
- ShareableBitmap::Handle handle;
- m_callback(true, handle);
-
- m_callback = 0;
- }
-
-private:
-
- ImageCallback(CallbackFunction callback)
- : m_callback(callback)
- {
- }
-
- CallbackFunction m_callback;
-};
-
</del><span class="cx"> template<typename T>
</span><span class="cx"> void invalidateCallbackMap(HashMap<uint64_t, T>& map, CallbackBase::Error error = CallbackBase::Error::Unknown)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (169961 => 169962)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2014-06-14 05:09:37 UTC (rev 169961)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2014-06-14 05:32:07 UTC (rev 169962)
</span><span class="lines">@@ -204,226 +204,16 @@
</span><span class="cx"> };
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>-// FIXME: Make a version of CallbackBase with three arguments, and define ValidateCommandCallback as a specialization.
-class ValidateCommandCallback : public CallbackBase {
-public:
- typedef std::function<void (bool, StringImpl*, bool, int32_t)> CallbackFunction;
</del><ins>+typedef GenericCallback<StringImpl*, bool, int32_t> ValidateCommandCallback;
+typedef GenericCallback<const WebCore::IntRect&, const EditingRange&> RectForCharacterRangeCallback;
</ins><span class="cx">
</span><del>- static PassRefPtr<ValidateCommandCallback> create(CallbackFunction callback)
- {
- return adoptRef(new ValidateCommandCallback(callback));
- }
-
- virtual ~ValidateCommandCallback()
- {
- ASSERT(!m_callback);
- }
-
- void performCallbackWithReturnValue(StringImpl* returnValue1, bool returnValue2, int returnValue3)
- {
- ASSERT(m_callback);
-
- m_callback(false, returnValue1, returnValue2, returnValue3);
-
- m_callback = 0;
- }
-
- void invalidate()
- {
- ASSERT(m_callback);
-
- m_callback(true, 0, 0, 0);
-
- m_callback = 0;
- }
-
-private:
-
- ValidateCommandCallback(CallbackFunction callback)
- : m_callback(callback)
- {
- }
-
- CallbackFunction m_callback;
-};
-
-// FIXME: Make a version of CallbackBase with two arguments, and define RectForCharacterRangeCallback as a specialization.
-class RectForCharacterRangeCallback : public CallbackBase {
-public:
- typedef std::function<void (bool, const WebCore::IntRect&, const EditingRange&)> CallbackFunction;
-
- static PassRefPtr<RectForCharacterRangeCallback> create(CallbackFunction callback)
- {
- return adoptRef(new RectForCharacterRangeCallback(callback));
- }
-
- virtual ~RectForCharacterRangeCallback()
- {
- ASSERT(!m_callback);
- }
-
- void performCallbackWithReturnValue(const WebCore::IntRect& rect, const EditingRange& range)
- {
- ASSERT(m_callback);
-
- m_callback(false, rect, range);
-
- m_callback = 0;
- }
-
- void invalidate()
- {
- ASSERT(m_callback);
-
- m_callback(true, WebCore::IntRect(), EditingRange());
-
- m_callback = 0;
- }
-
-private:
-
- RectForCharacterRangeCallback(CallbackFunction callback)
- : m_callback(callback)
- {
- }
-
- CallbackFunction m_callback;
-};
-
</del><span class="cx"> #if PLATFORM(MAC)
</span><del>-
-// FIXME: Make a version of CallbackBase with two arguments, and define AttributedStringForCharacterRangeCallback as a specialization.
-class AttributedStringForCharacterRangeCallback : public CallbackBase {
-public:
- typedef std::function<void (bool, const AttributedString&, const EditingRange&)> CallbackFunction;
-
- static PassRefPtr<AttributedStringForCharacterRangeCallback> create(CallbackFunction callback)
- {
- return adoptRef(new AttributedStringForCharacterRangeCallback(callback));
- }
-
- virtual ~AttributedStringForCharacterRangeCallback()
- {
- ASSERT(!m_callback);
- }
-
- void performCallbackWithReturnValue(const AttributedString& string, const EditingRange& range)
- {
- ASSERT(m_callback);
-
- m_callback(false, string, range);
-
- m_callback = 0;
- }
-
- void invalidate()
- {
- ASSERT(m_callback);
-
- m_callback(true, AttributedString(), EditingRange());
-
- m_callback = 0;
- }
-
-private:
-
- AttributedStringForCharacterRangeCallback(CallbackFunction callback)
- : m_callback(callback)
- {
- }
-
- CallbackFunction m_callback;
-};
-
</del><ins>+typedef GenericCallback<const AttributedString&, const EditingRange&> AttributedStringForCharacterRangeCallback;
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(IOS)
</span><del>-class GestureCallback : public CallbackBase {
-public:
- typedef std::function<void (bool, const WebCore::IntPoint&, uint32_t, uint32_t, uint32_t)> CallbackFunction;
-
- static PassRefPtr<GestureCallback> create(CallbackFunction callback)
- {
- return adoptRef(new GestureCallback(callback));
- }
-
- virtual ~GestureCallback()
- {
- ASSERT(!m_callback);
- }
-
- void performCallbackWithReturnValue(const WebCore::IntPoint& returnValue1, uint32_t returnValue2, uint32_t returnValue3, uint32_t returnValue4)
- {
- ASSERT(m_callback);
-
- m_callback(false, returnValue1, returnValue2, returnValue3, returnValue4);
-
- m_callback = 0;
- }
-
- void invalidate()
- {
- ASSERT(m_callback);
-
- m_callback(true, WebCore::IntPoint(), 0, 0, 0);
-
- m_callback = 0;
- }
-
-private:
-
- GestureCallback(CallbackFunction callback)
- : m_callback(callback)
- {
- ASSERT(m_callback);
- }
-
- CallbackFunction m_callback;
-};
-
-class TouchesCallback : public CallbackBase {
-public:
- typedef std::function<void(bool, const WebCore::IntPoint&, uint32_t)> CallbackFunction;
-
- static PassRefPtr<TouchesCallback> create(CallbackFunction callback)
- {
- return adoptRef(new TouchesCallback(callback));
- }
-
- virtual ~TouchesCallback()
- {
- ASSERT(!m_callback);
- }
-
- void performCallbackWithReturnValue(const WebCore::IntPoint& returnValue1, uint32_t returnValue2)
- {
- ASSERT(m_callback);
-
- m_callback(false, returnValue1, returnValue2);
-
- m_callback = 0;
- }
-
- void invalidate()
- {
- ASSERT(m_callback);
-
- RefPtr<API::Error> error = API::Error::create();
- m_callback(true, WebCore::IntPoint(), 0);
-
- m_callback = 0;
- }
-
-private:
-
- TouchesCallback(CallbackFunction callback)
- : m_callback(callback)
- {
- ASSERT(m_callback);
- }
-
- CallbackFunction m_callback;
-};
</del><ins>+typedef GenericCallback<const WebCore::IntPoint&, uint32_t, uint32_t, uint32_t> GestureCallback;
+typedef GenericCallback<const WebCore::IntPoint&, uint32_t> TouchesCallback;
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> struct WebPageConfiguration {
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWKContentViewInteractionmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (169961 => 169962)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm        2014-06-14 05:09:37 UTC (rev 169961)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm        2014-06-14 05:32:07 UTC (rev 169962)
</span><span class="lines">@@ -1477,7 +1477,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> _autocorrectionData.autocorrectionHandler = [completionHandler copy];
</span><del>- _page->requestAutocorrectionData(input, AutocorrectionDataCallback::create([self](bool, const Vector<FloatRect>& rects, const String& fontName, double fontSize, uint64_t traits) {
</del><ins>+ _page->requestAutocorrectionData(input, AutocorrectionDataCallback::create([self](const Vector<FloatRect>& rects, const String& fontName, double fontSize, uint64_t traits, CallbackBase::Error) {
</ins><span class="cx"> CGRect firstRect = CGRectZero;
</span><span class="cx"> CGRect lastRect = CGRectZero;
</span><span class="cx"> if (rects.size()) {
</span><span class="lines">@@ -1540,7 +1540,7 @@
</span><span class="cx"> {
</span><span class="cx"> UIWKDictationContextHandler dictationHandler = [completionHandler copy];
</span><span class="cx">
</span><del>- _page->requestDictationContext(DictationContextCallback::create([dictationHandler](bool /*error*/, const String& selectedText, const String& beforeText, const String& afterText) {
</del><ins>+ _page->requestDictationContext(DictationContextCallback::create([dictationHandler](const String& selectedText, const String& beforeText, const String& afterText, CallbackBase::Error) {
</ins><span class="cx"> dictationHandler(selectedText, beforeText, afterText);
</span><span class="cx"> [dictationHandler release];
</span><span class="cx"> }));
</span><span class="lines">@@ -1580,7 +1580,7 @@
</span><span class="cx"> completionHandler([WKAutocorrectionContext autocorrectionContextWithData:beforeText markedText:markedText selectedText:selectedText afterText:afterText selectedRangeInMarkedText:NSMakeRange(location, length)]);
</span><span class="cx"> } else {
</span><span class="cx"> _autocorrectionData.autocorrectionContextHandler = [completionHandler copy];
</span><del>- _page->requestAutocorrectionContext(AutocorrectionContextCallback::create([self](bool /*error*/, const String& beforeText, const String& markedText, const String& selectedText, const String& afterText, uint64_t location, uint64_t length) {
</del><ins>+ _page->requestAutocorrectionContext(AutocorrectionContextCallback::create([self](const String& beforeText, const String& markedText, const String& selectedText, const String& afterText, uint64_t location, uint64_t length, CallbackBase::Error) {
</ins><span class="cx"> _autocorrectionData.autocorrectionContextHandler([WKAutocorrectionContext autocorrectionContextWithData:beforeText markedText:markedText selectedText:selectedText afterText:afterText selectedRangeInMarkedText:NSMakeRange(location, length)]);
</span><span class="cx"> }));
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacWKPrintingViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/WKPrintingView.mm (169961 => 169962)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/WKPrintingView.mm        2014-06-14 05:09:37 UTC (rev 169961)
+++ trunk/Source/WebKit2/UIProcess/mac/WKPrintingView.mm        2014-06-14 05:32:07 UTC (rev 169962)
</span><span class="lines">@@ -265,7 +265,7 @@
</span><span class="cx"> _webFrame->page()->beginPrinting(_webFrame.get(), printInfo);
</span><span class="cx">
</span><span class="cx"> IPCCallbackContext* context = new IPCCallbackContext;
</span><del>- RefPtr<DataCallback> callback = DataCallback::create([context](bool, API::Data* data) {
</del><ins>+ RefPtr<DataCallback> callback = DataCallback::create([context](API::Data* data, CallbackBase::Error) {
</ins><span class="cx"> ASSERT(RunLoop::isMain());
</span><span class="cx">
</span><span class="cx"> OwnPtr<IPCCallbackContext> contextDeleter = adoptPtr(context);
</span><span class="lines">@@ -340,7 +340,7 @@
</span><span class="cx"> ASSERT(!_expectedComputedPagesCallback);
</span><span class="cx">
</span><span class="cx"> IPCCallbackContext* context = new IPCCallbackContext;
</span><del>- RefPtr<ComputedPagesCallback> callback = ComputedPagesCallback::create([context](bool, const Vector<WebCore::IntRect>& pageRects, double totalScaleFactorForPrinting) {
</del><ins>+ RefPtr<ComputedPagesCallback> callback = ComputedPagesCallback::create([context](const Vector<WebCore::IntRect>& pageRects, double totalScaleFactorForPrinting, CallbackBase::Error) {
</ins><span class="cx"> OwnPtr<IPCCallbackContext> contextDeleter = adoptPtr(context);
</span><span class="cx"> pageDidComputePageRects(pageRects, totalScaleFactorForPrinting, context);
</span><span class="cx"> });
</span><span class="lines">@@ -492,7 +492,7 @@
</span><span class="cx"> _webFrame->page()->beginPrinting(_webFrame.get(), PrintInfo([_printOperation printInfo]));
</span><span class="cx">
</span><span class="cx"> IPCCallbackContext* context = new IPCCallbackContext;
</span><del>- RefPtr<ImageCallback> callback = ImageCallback::create([context](bool, const ShareableBitmap::Handle& imageHandle) {
</del><ins>+ RefPtr<ImageCallback> callback = ImageCallback::create([context](const ShareableBitmap::Handle& imageHandle, CallbackBase::Error) {
</ins><span class="cx"> OwnPtr<IPCCallbackContext> contextDeleter = adoptPtr(context);
</span><span class="cx"> pageDidDrawToImage(imageHandle, context);
</span><span class="cx"> });
</span></span></pre>
</div>
</div>
</body>
</html>