Diff
Modified: trunk/Source/WebKit/ChangeLog (272627 => 272628)
--- trunk/Source/WebKit/ChangeLog 2021-02-10 01:28:04 UTC (rev 272627)
+++ trunk/Source/WebKit/ChangeLog 2021-02-10 01:29:32 UTC (rev 272628)
@@ -1,5 +1,33 @@
2021-02-09 Alex Christensen <[email protected]>
+ Use CompletionHandler instead of ImageCallback
+ https://bugs.webkit.org/show_bug.cgi?id=221626
+
+ Reviewed by Chris Dumez.
+
+ * UIProcess/API/Cocoa/WKWebView.mm:
+ (-[WKWebView takeSnapshotWithConfiguration:completionHandler:]):
+ * UIProcess/API/Cocoa/_WKThumbnailView.mm:
+ (-[_WKThumbnailView requestSnapshot]):
+ * UIProcess/API/ios/WKWebViewIOS.mm:
+ (-[WKWebView _snapshotRect:intoImageOfWidth:completionHandler:]):
+ * UIProcess/GenericCallback.h:
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::drawRectToImage):
+ (WebKit::WebPageProxy::takeSnapshot):
+ (WebKit::WebPageProxy::imageCallback): Deleted.
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/WebPageProxy.messages.in:
+ * UIProcess/mac/WKPrintingView.mm:
+ (-[WKPrintingView _drawPreview:]):
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::takeSnapshot):
+ (WebKit::WebPage::drawRectToImage):
+ * WebProcess/WebPage/WebPage.h:
+ * WebProcess/WebPage/WebPage.messages.in:
+
+2021-02-09 Alex Christensen <[email protected]>
+
Use CompletionHandler instead of UnsignedCallback
https://bugs.webkit.org/show_bug.cgi?id=221631
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (272627 => 272628)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2021-02-10 01:28:04 UTC (rev 272627)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2021-02-10 01:29:32 UTC (rev 272628)
@@ -840,26 +840,6 @@
_page->stopLoading();
}
-#if USE(APPKIT)
-static WKErrorCode callbackErrorCode(WebKit::CallbackBase::Error error)
-{
- switch (error) {
- case WebKit::CallbackBase::Error::None:
- ASSERT_NOT_REACHED();
- return WKErrorUnknown;
-
- case WebKit::CallbackBase::Error::Unknown:
- return WKErrorUnknown;
-
- case WebKit::CallbackBase::Error::ProcessExited:
- return WKErrorWebContentProcessTerminated;
-
- case WebKit::CallbackBase::Error::OwnerWasInvalidated:
- return WKErrorWebViewInvalidated;
- }
-}
-#endif
-
- (void)evaluateJavaScript:(NSString *)_javascript_String completionHandler:(void (^)(id, NSError *))completionHandler
{
[self _evaluateJavaScript:_javascript_String asAsyncFunction:NO withSourceURL:nil withArguments:nil forceUserGesture:YES inFrame:nil inWorld:WKContentWorld.pageWorld completionHandler:completionHandler];
@@ -1094,13 +1074,7 @@
// This code doesn't consider snapshotConfiguration.afterScreenUpdates since the software snapshot always
// contains recent updates. If we ever have a UI-side snapshot mechanism on macOS, we will need to factor
// in snapshotConfiguration.afterScreenUpdates at that time.
- _page->takeSnapshot(WebCore::enclosingIntRect(rectInViewCoordinates), bitmapSize, WebKit::SnapshotOptionsInViewCoordinates, [handler, snapshotWidth, imageHeight](const WebKit::ShareableBitmap::Handle& imageHandle, WebKit::CallbackBase::Error errorCode) {
- if (errorCode != WebKit::CallbackBase::Error::None) {
- auto error = createNSError(callbackErrorCode(errorCode));
- handler(nil, error.get());
- return;
- }
-
+ _page->takeSnapshot(WebCore::enclosingIntRect(rectInViewCoordinates), bitmapSize, WebKit::SnapshotOptionsInViewCoordinates, [handler, snapshotWidth, imageHeight](const WebKit::ShareableBitmap::Handle& imageHandle) {
auto bitmap = WebKit::ShareableBitmap::create(imageHandle, WebKit::SharedMemory::Protection::ReadOnly);
RetainPtr<CGImageRef> cgImage = bitmap ? bitmap->makeCGImage() : nullptr;
auto image = adoptNS([[NSImage alloc] initWithCGImage:cgImage.get() size:NSMakeSize(snapshotWidth, imageHeight)]);
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKThumbnailView.mm (272627 => 272628)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKThumbnailView.mm 2021-02-10 01:28:04 UTC (rev 272627)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKThumbnailView.mm 2021-02-10 01:29:32 UTC (rev 272628)
@@ -141,7 +141,7 @@
_lastSnapshotScale = _scale;
_lastSnapshotMaximumSize = _maximumSnapshotSize;
- _webPageProxy->takeSnapshot(snapshotRect, bitmapSize, options, [thumbnailView](const WebKit::ShareableBitmap::Handle& imageHandle, WebKit::CallbackBase::Error) {
+ _webPageProxy->takeSnapshot(snapshotRect, bitmapSize, options, [thumbnailView](const WebKit::ShareableBitmap::Handle& imageHandle) {
auto bitmap = WebKit::ShareableBitmap::create(imageHandle, WebKit::SharedMemory::Protection::ReadOnly);
RetainPtr<CGImageRef> cgImage = bitmap ? bitmap->makeCGImage() : nullptr;
[thumbnailView _didTakeSnapshot:cgImage.get()];
Modified: trunk/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm (272627 => 272628)
--- trunk/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm 2021-02-10 01:28:04 UTC (rev 272627)
+++ trunk/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm 2021-02-10 01:29:32 UTC (rev 272628)
@@ -3088,26 +3088,16 @@
return;
}
- void(^copiedCompletionHandler)(CGImageRef) = [completionHandler copy];
- _page->takeSnapshot(WebCore::enclosingIntRect(snapshotRectInContentCoordinates), WebCore::expandedIntSize(WebCore::FloatSize(imageSize)), WebKit::SnapshotOptionsExcludeDeviceScaleFactor, [=](const WebKit::ShareableBitmap::Handle& imageHandle, WebKit::CallbackBase::Error) {
- if (imageHandle.isNull()) {
- copiedCompletionHandler(nullptr);
- [copiedCompletionHandler release];
- return;
- }
+ _page->takeSnapshot(WebCore::enclosingIntRect(snapshotRectInContentCoordinates), WebCore::expandedIntSize(WebCore::FloatSize(imageSize)), WebKit::SnapshotOptionsExcludeDeviceScaleFactor, [completionHandler = makeBlockPtr(completionHandler)](const WebKit::ShareableBitmap::Handle& imageHandle) {
+ if (imageHandle.isNull())
+ return completionHandler(nil);
auto bitmap = WebKit::ShareableBitmap::create(imageHandle, WebKit::SharedMemory::Protection::ReadOnly);
- if (!bitmap) {
- copiedCompletionHandler(nullptr);
- [copiedCompletionHandler release];
- return;
- }
+ if (!bitmap)
+ return completionHandler(nil);
- RetainPtr<CGImageRef> cgImage;
- cgImage = bitmap->makeCGImage();
- copiedCompletionHandler(cgImage.get());
- [copiedCompletionHandler release];
+ completionHandler(bitmap->makeCGImage().get());
});
}
Modified: trunk/Source/WebKit/UIProcess/GenericCallback.h (272627 => 272628)
--- trunk/Source/WebKit/UIProcess/GenericCallback.h 2021-02-10 01:28:04 UTC (rev 272627)
+++ trunk/Source/WebKit/UIProcess/GenericCallback.h 2021-02-10 01:29:32 UTC (rev 272628)
@@ -155,7 +155,6 @@
}
typedef GenericCallback<> VoidCallback;
-typedef GenericCallback<const ShareableBitmap::Handle&> ImageCallback;
template<typename T>
void invalidateCallbackMap(HashMap<uint64_t, T>& callbackMap, CallbackBase::Error error)
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (272627 => 272628)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2021-02-10 01:28:04 UTC (rev 272627)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2021-02-10 01:29:32 UTC (rev 272628)
@@ -7116,17 +7116,6 @@
callback->performCallbackWithReturnValue(API::Data::create(dataReference.data(), dataReference.size()).ptr());
}
-void WebPageProxy::imageCallback(const ShareableBitmap::Handle& bitmapHandle, CallbackID callbackID)
-{
- auto callback = m_callbacks.take<ImageCallback>(callbackID);
- if (!callback) {
- // FIXME: Log error or assert.
- return;
- }
-
- callback->performCallbackWithReturnValue(bitmapHandle);
-}
-
void WebPageProxy::stringCallback(const String& resultString, CallbackID callbackID)
{
auto callback = m_callbacks.take<StringCallback>(callbackID);
@@ -8523,16 +8512,9 @@
}
#if PLATFORM(COCOA)
-void WebPageProxy::drawRectToImage(WebFrameProxy* frame, const PrintInfo& printInfo, const IntRect& rect, const WebCore::IntSize& imageSize, Ref<ImageCallback>&& callback)
+uint64_t WebPageProxy::drawRectToImage(WebFrameProxy* frame, const PrintInfo& printInfo, const IntRect& rect, const WebCore::IntSize& imageSize, CompletionHandler<void(const WebKit::ShareableBitmap::Handle&)>&& callback)
{
- if (!hasRunningProcess()) {
- callback->invalidate();
- return;
- }
-
- auto callbackID = callback->callbackID();
- m_callbacks.put(WTFMove(callback));
- send(Messages::WebPage::DrawRectToImage(frame->frameID(), printInfo, rect, imageSize, callbackID), printingSendOptions(m_isPerformingDOMPrintOperation));
+ return sendWithAsyncReply(Messages::WebPage::DrawRectToImage(frame->frameID(), printInfo, rect, imageSize), WTFMove(callback), printingSendOptions(m_isPerformingDOMPrintOperation));
}
void WebPageProxy::drawPagesToPDF(WebFrameProxy* frame, const PrintInfo& printInfo, uint32_t first, uint32_t count, Ref<DataCallback>&& callback)
@@ -8980,15 +8962,9 @@
}
#endif
-void WebPageProxy::takeSnapshot(IntRect rect, IntSize bitmapSize, SnapshotOptions options, WTF::Function<void (const ShareableBitmap::Handle&, CallbackBase::Error)>&& callbackFunction)
+void WebPageProxy::takeSnapshot(IntRect rect, IntSize bitmapSize, SnapshotOptions options, CompletionHandler<void(const ShareableBitmap::Handle&)>&& callback)
{
- if (!hasRunningProcess()) {
- callbackFunction(ShareableBitmap::Handle(), CallbackBase::Error::Unknown);
- return;
- }
-
- auto callbackID = m_callbacks.put(WTFMove(callbackFunction), m_process->throttler().backgroundActivity("WebPageProxy::takeSnapshot"_s));
- send(Messages::WebPage::TakeSnapshot(rect, bitmapSize, options, callbackID));
+ sendWithAsyncReply(Messages::WebPage::TakeSnapshot(rect, bitmapSize, options), WTFMove(callback));
}
void WebPageProxy::navigationGestureDidBegin()
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (272627 => 272628)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2021-02-10 01:28:04 UTC (rev 272627)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2021-02-10 01:29:32 UTC (rev 272628)
@@ -1293,7 +1293,7 @@
void endPrinting();
uint64_t computePagesForPrinting(WebFrameProxy*, const PrintInfo&, CompletionHandler<void(const Vector<WebCore::IntRect>&, double, const WebCore::FloatBoxExtent&)>&&);
#if PLATFORM(COCOA)
- void drawRectToImage(WebFrameProxy*, const PrintInfo&, const WebCore::IntRect&, const WebCore::IntSize&, Ref<ImageCallback>&&);
+ uint64_t drawRectToImage(WebFrameProxy*, const PrintInfo&, const WebCore::IntRect&, const WebCore::IntSize&, CompletionHandler<void(const WebKit::ShareableBitmap::Handle&)>&&);
void drawPagesToPDF(WebFrameProxy*, const PrintInfo&, uint32_t first, uint32_t count, Ref<DataCallback>&&);
void drawToPDF(WebCore::FrameIdentifier, const Optional<WebCore::FloatRect>&, CompletionHandler<void(const IPC::DataReference&)>&&);
#if PLATFORM(IOS_FAMILY)
@@ -1427,7 +1427,7 @@
void signedPublicKeyAndChallengeString(unsigned keySizeIndex, const String& challengeString, const URL&, CompletionHandler<void(String)>&&);
- void takeSnapshot(WebCore::IntRect, WebCore::IntSize bitmapSize, SnapshotOptions, WTF::Function<void (const ShareableBitmap::Handle&, CallbackBase::Error)>&&);
+ void takeSnapshot(WebCore::IntRect, WebCore::IntSize bitmapSize, SnapshotOptions, CompletionHandler<void(const ShareableBitmap::Handle&)>&&);
void navigationGestureDidBegin();
void navigationGestureWillEnd(bool willNavigate, WebBackForwardListItem&);
@@ -2156,7 +2156,6 @@
void voidCallback(CallbackID);
void dataCallback(const IPC::DataReference&, CallbackID);
- void imageCallback(const ShareableBitmap::Handle&, CallbackID);
void stringCallback(const String&, CallbackID);
void invalidateStringCallback(CallbackID);
#if ENABLE(APPLICATION_MANIFEST)
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (272627 => 272628)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in 2021-02-10 01:28:04 UTC (rev 272627)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in 2021-02-10 01:29:32 UTC (rev 272628)
@@ -165,7 +165,6 @@
# Callback messages
VoidCallback(WebKit::CallbackID callbackID)
DataCallback(IPC::SharedBufferDataReference resultData, WebKit::CallbackID callbackID)
- ImageCallback(WebKit::ShareableBitmap::Handle bitmapHandle, WebKit::CallbackID callbackID)
StringCallback(String resultString, WebKit::CallbackID callbackID)
InvalidateStringCallback(WebKit::CallbackID callbackID)
#if ENABLE(APPLICATION_MANIFEST)
Modified: trunk/Source/WebKit/UIProcess/mac/WKPrintingView.mm (272627 => 272628)
--- trunk/Source/WebKit/UIProcess/mac/WKPrintingView.mm 2021-02-10 01:28:04 UTC (rev 272627)
+++ trunk/Source/WebKit/UIProcess/mac/WKPrintingView.mm 2021-02-10 01:29:32 UTC (rev 272628)
@@ -540,17 +540,15 @@
_webFrame->page()->beginPrinting(_webFrame.get(), WebKit::PrintInfo([_printOperation.get() printInfo]));
IPCCallbackContext* context = new IPCCallbackContext;
- auto callback = WebKit::ImageCallback::create([context](const WebKit::ShareableBitmap::Handle& imageHandle, WebKit::CallbackBase::Error) {
+ auto callback = [context](const WebKit::ShareableBitmap::Handle& imageHandle) {
std::unique_ptr<IPCCallbackContext> contextDeleter(context);
pageDidDrawToImage(imageHandle, context);
- });
- _latestExpectedPreviewCallback = callback->callbackID().toInteger();
+ };
+ _latestExpectedPreviewCallback = _webFrame->page()->drawRectToImage(_webFrame.get(), WebKit::PrintInfo([_printOperation.get() printInfo]), scaledPrintingRect, imageSize, WTFMove(callback));
_expectedPreviewCallbacks.add(_latestExpectedPreviewCallback, scaledPrintingRect);
context->view = self;
- context->callbackID = callback->callbackID().toInteger();
-
- _webFrame->page()->drawRectToImage(_webFrame.get(), WebKit::PrintInfo([_printOperation.get() printInfo]), scaledPrintingRect, imageSize, WTFMove(callback));
+ context->callbackID = _latestExpectedPreviewCallback;
return;
}
}
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (272627 => 272628)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2021-02-10 01:28:04 UTC (rev 272627)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2021-02-10 01:29:32 UTC (rev 272628)
@@ -2425,7 +2425,7 @@
#endif // !PLATFORM(IOS_FAMILY)
-void WebPage::takeSnapshot(IntRect snapshotRect, IntSize bitmapSize, uint32_t options, CallbackID callbackID)
+void WebPage::takeSnapshot(IntRect snapshotRect, IntSize bitmapSize, uint32_t options, CompletionHandler<void(const WebKit::ShareableBitmap::Handle&)>&& completionHandler)
{
SnapshotOptions snapshotOptions = static_cast<SnapshotOptions>(options);
snapshotOptions |= SnapshotOptionsShareable;
@@ -2436,7 +2436,7 @@
if (image)
image->bitmap().createHandle(handle, SharedMemory::Protection::ReadOnly);
- send(Messages::WebPageProxy::ImageCallback(handle, callbackID));
+ completionHandler(handle);
}
RefPtr<WebImage> WebPage::scaledSnapshotWithOptions(const IntRect& rect, double additionalScaleFactor, SnapshotOptions options)
@@ -5134,7 +5134,7 @@
completionHandler(IPC::DataReference(CFDataGetBytePtr(pdfData.get()), CFDataGetLength(pdfData.get())));
}
-void WebPage::drawRectToImage(FrameIdentifier frameID, const PrintInfo& printInfo, const IntRect& rect, const WebCore::IntSize& imageSize, CallbackID callbackID)
+void WebPage::drawRectToImage(FrameIdentifier frameID, const PrintInfo& printInfo, const IntRect& rect, const WebCore::IntSize& imageSize, CompletionHandler<void(const WebKit::ShareableBitmap::Handle&)>&& completionHandler)
{
WebFrame* frame = WebProcess::singleton().webFrame(frameID);
Frame* coreFrame = frame ? frame->coreFrame() : 0;
@@ -5152,7 +5152,7 @@
auto bitmap = ShareableBitmap::createShareable(imageSize, { });
if (!bitmap) {
ASSERT_NOT_REACHED();
- return;
+ return completionHandler({ });
}
auto graphicsContext = bitmap->createGraphicsContext();
if (graphicsContext) {
@@ -5181,7 +5181,7 @@
if (image)
image->bitmap().createHandle(handle, SharedMemory::Protection::ReadOnly);
- send(Messages::WebPageProxy::ImageCallback(handle, callbackID));
+ completionHandler(handle);
}
void WebPage::drawPagesToPDF(FrameIdentifier frameID, const PrintInfo& printInfo, uint32_t first, uint32_t count, CallbackID callbackID)
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (272627 => 272628)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2021-02-10 01:28:04 UTC (rev 272627)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2021-02-10 01:29:32 UTC (rev 272628)
@@ -965,7 +965,7 @@
void computePagesForPrintingImpl(WebCore::FrameIdentifier, const PrintInfo&, Vector<WebCore::IntRect>& pageRects, double& totalScaleFactor, WebCore::FloatBoxExtent& computedMargin);
#if PLATFORM(COCOA)
- void drawRectToImage(WebCore::FrameIdentifier, const PrintInfo&, const WebCore::IntRect&, const WebCore::IntSize&, CallbackID);
+ void drawRectToImage(WebCore::FrameIdentifier, const PrintInfo&, const WebCore::IntRect&, const WebCore::IntSize&, CompletionHandler<void(const WebKit::ShareableBitmap::Handle&)>&&);
void drawPagesToPDF(WebCore::FrameIdentifier, const PrintInfo&, uint32_t first, uint32_t count, CallbackID);
void drawPagesToPDFImpl(WebCore::FrameIdentifier, const PrintInfo&, uint32_t first, uint32_t count, RetainPtr<CFMutableDataRef>& pdfPageData);
#endif
@@ -1591,7 +1591,7 @@
void runJavaScript(WebFrame*, WebCore::RunJavaScriptParameters&&, ContentWorldIdentifier, CompletionHandler<void(const IPC::DataReference&, const Optional<WebCore::ExceptionDetails>&)>&&);
void runJavaScriptInFrameInScriptWorld(WebCore::RunJavaScriptParameters&&, Optional<WebCore::FrameIdentifier>, const std::pair<ContentWorldIdentifier, String>& worldData, CompletionHandler<void(const IPC::DataReference&, const Optional<WebCore::ExceptionDetails>&)>&&);
void forceRepaint(CompletionHandler<void()>&&);
- void takeSnapshot(WebCore::IntRect snapshotRect, WebCore::IntSize bitmapSize, uint32_t options, CallbackID);
+ void takeSnapshot(WebCore::IntRect snapshotRect, WebCore::IntSize bitmapSize, uint32_t options, CompletionHandler<void(const WebKit::ShareableBitmap::Handle&)>&&);
void preferencesDidChange(const WebPreferencesStore&);
void updatePreferences(const WebPreferencesStore&);
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (272627 => 272628)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in 2021-02-10 01:28:04 UTC (rev 272627)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in 2021-02-10 01:29:32 UTC (rev 272628)
@@ -399,7 +399,7 @@
EndPrinting()
ComputePagesForPrinting(WebCore::FrameIdentifier frameID, struct WebKit::PrintInfo printInfo) -> (Vector<WebCore::IntRect> pageRects, double totalScaleFactorForPrinting, WebCore::RectEdges<float> computedPageMargin) Async
#if PLATFORM(COCOA)
- DrawRectToImage(WebCore::FrameIdentifier frameID, struct WebKit::PrintInfo printInfo, WebCore::IntRect rect, WebCore::IntSize imageSize, WebKit::CallbackID callbackID)
+ DrawRectToImage(WebCore::FrameIdentifier frameID, struct WebKit::PrintInfo printInfo, WebCore::IntRect rect, WebCore::IntSize imageSize) -> (WebKit::ShareableBitmap::Handle image) Async
DrawPagesToPDF(WebCore::FrameIdentifier frameID, struct WebKit::PrintInfo printInfo, uint32_t first, uint32_t count, WebKit::CallbackID callbackID)
#if PLATFORM(IOS_FAMILY)
ComputePagesForPrintingiOS(WebCore::FrameIdentifier frameID, struct WebKit::PrintInfo printInfo) -> (size_t pageCount) Synchronous
@@ -491,7 +491,7 @@
GetSamplingProfilerOutput(WebKit::CallbackID callbackID)
- TakeSnapshot(WebCore::IntRect snapshotRect, WebCore::IntSize bitmapSize, uint32_t options, WebKit::CallbackID callbackID)
+ TakeSnapshot(WebCore::IntRect snapshotRect, WebCore::IntSize bitmapSize, uint32_t options) -> (WebKit::ShareableBitmap::Handle image) Async
#if PLATFORM(MAC)
PerformImmediateActionHitTestAtLocation(WebCore::FloatPoint location)
ImmediateActionDidUpdate()