Diff
Modified: trunk/LayoutTests/ChangeLog (250815 => 250816)
--- trunk/LayoutTests/ChangeLog 2019-10-08 04:56:31 UTC (rev 250815)
+++ trunk/LayoutTests/ChangeLog 2019-10-08 06:22:46 UTC (rev 250816)
@@ -1,3 +1,20 @@
+2019-10-07 Ryosuke Niwa <rn...@webkit.org>
+
+ Add IDL for requestIdleCallback
+ https://bugs.webkit.org/show_bug.cgi?id=202653
+
+ Reviewed by Geoffrey Garen.
+
+ Added basic tests for validating requestIdleCallback is enabled or disabled, and its identifier starts at 1 in each document.
+
+ * requestidlecallback: Added.
+ * requestidlecallback/requestidlecallback-enabled-expected.txt: Added.
+ * requestidlecallback/requestidlecallback-enabled.html: Added.
+ * requestidlecallback/requestidlecallback-id-expected.txt: Added.
+ * requestidlecallback/requestidlecallback-id.html: Added.
+ * requestidlecallback/requestidlecallback-not-enabled-expected.txt: Added.
+ * requestidlecallback/requestidlecallback-not-enabled.html: Added.
+
2019-10-07 Jiewen Tan <jiewen_...@apple.com>
Only wrapping CryptoKeys for IDB during serialization
Added: trunk/LayoutTests/requestidlecallback/requestidlecallback-enabled-expected.txt (0 => 250816)
--- trunk/LayoutTests/requestidlecallback/requestidlecallback-enabled-expected.txt (rev 0)
+++ trunk/LayoutTests/requestidlecallback/requestidlecallback-enabled-expected.txt 2019-10-08 06:22:46 UTC (rev 250816)
@@ -0,0 +1,19 @@
+This tests that when requestIdleCallback is enabled, requestIdleCallback and IdleDeadline are defined.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS typeof window.requestIdleCallback is "function"
+PASS window.requestIdleCallback.length is 1
+PASS typeof window.cancelIdleCallback is "function"
+PASS window.cancelIdleCallback.length is 1
+PASS window.IdleDeadline is defined.
+PASS idleDeadlineProperties = Object.getOwnPropertyNames(window.IdleDeadline.prototype); idleDeadlineProperties.length is 3
+PASS JSON.stringify(idleDeadlineProperties.sort()) is "[\"constructor\",\"didTimeout\",\"timeRemaining\"]"
+PASS didTimeoutDescriptor = Object.getOwnPropertyDescriptor(window.IdleDeadline.prototype, "didTimeout"); didTimeoutDescriptor.get is defined.
+PASS didTimeoutDescriptor.set is undefined.
+PASS typeof window.IdleDeadline.prototype.timeRemaining is "function"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/requestidlecallback/requestidlecallback-enabled.html (0 => 250816)
--- trunk/LayoutTests/requestidlecallback/requestidlecallback-enabled.html (rev 0)
+++ trunk/LayoutTests/requestidlecallback/requestidlecallback-enabled.html 2019-10-08 06:22:46 UTC (rev 250816)
@@ -0,0 +1,22 @@
+<!DOCTYPE html><!-- webkit-test-runner [ experimental:RequestIdleCallbackEnabled=true ] -->
+<html>
+<body>
+<script src=""
+<script>
+
+description('This tests that when requestIdleCallback is enabled, requestIdleCallback and IdleDeadline are defined.');
+
+shouldBeEqualToString('typeof window.requestIdleCallback', 'function');
+shouldBe('window.requestIdleCallback.length', '1');
+shouldBeEqualToString('typeof window.cancelIdleCallback', 'function');
+shouldBe('window.cancelIdleCallback.length', '1');
+shouldBeDefined('window.IdleDeadline');
+shouldBe('idleDeadlineProperties = Object.getOwnPropertyNames(window.IdleDeadline.prototype); idleDeadlineProperties.length', '3');
+shouldBeEqualToString('JSON.stringify(idleDeadlineProperties.sort())', '["constructor","didTimeout","timeRemaining"]');
+shouldBeDefined('didTimeoutDescriptor = Object.getOwnPropertyDescriptor(window.IdleDeadline.prototype, "didTimeout"); didTimeoutDescriptor.get');
+shouldBeUndefined('didTimeoutDescriptor.set');
+shouldBeEqualToString('typeof window.IdleDeadline.prototype.timeRemaining', 'function');
+
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/requestidlecallback/requestidlecallback-id-expected.txt (0 => 250816)
--- trunk/LayoutTests/requestidlecallback/requestidlecallback-id-expected.txt (rev 0)
+++ trunk/LayoutTests/requestidlecallback/requestidlecallback-id-expected.txt 2019-10-08 06:22:46 UTC (rev 250816)
@@ -0,0 +1,16 @@
+This tests that requestIdleCallback identifier starts from 1 in each document.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS requestIdleCallback(() => { }) is 1
+PASS requestIdleCallback(() => { }) is 2
+PASS iframe1.contentWindow.requestIdleCallback(() => { }) is 1
+PASS iframe2.contentWindow.requestIdleCallback(() => { }) is 1
+PASS iframe1.contentWindow.requestIdleCallback(() => { }) is 2
+PASS iframe1.contentWindow.requestIdleCallback(() => { }) is 3
+PASS iframe2.contentWindow.requestIdleCallback(() => { }) is 2
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/requestidlecallback/requestidlecallback-id.html (0 => 250816)
--- trunk/LayoutTests/requestidlecallback/requestidlecallback-id.html (rev 0)
+++ trunk/LayoutTests/requestidlecallback/requestidlecallback-id.html 2019-10-08 06:22:46 UTC (rev 250816)
@@ -0,0 +1,23 @@
+<!DOCTYPE html><!-- webkit-test-runner [ experimental:RequestIdleCallbackEnabled=true ] -->
+<html>
+<body>
+<script src=""
+<script>
+
+description('This tests that requestIdleCallback identifier starts from 1 in each document.');
+
+shouldBe('requestIdleCallback(() => { })', '1');
+shouldBe('requestIdleCallback(() => { })', '2');
+
+const iframe1 = document.body.appendChild(document.createElement('iframe'));
+const iframe2 = document.body.appendChild(document.createElement('iframe'));
+
+shouldBe('iframe1.contentWindow.requestIdleCallback(() => { })', '1');
+shouldBe('iframe2.contentWindow.requestIdleCallback(() => { })', '1');
+shouldBe('iframe1.contentWindow.requestIdleCallback(() => { })', '2');
+shouldBe('iframe1.contentWindow.requestIdleCallback(() => { })', '3');
+shouldBe('iframe2.contentWindow.requestIdleCallback(() => { })', '2');
+
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/requestidlecallback/requestidlecallback-not-enabled-expected.txt (0 => 250816)
--- trunk/LayoutTests/requestidlecallback/requestidlecallback-not-enabled-expected.txt (rev 0)
+++ trunk/LayoutTests/requestidlecallback/requestidlecallback-not-enabled-expected.txt 2019-10-08 06:22:46 UTC (rev 250816)
@@ -0,0 +1,12 @@
+This tests that when requestIdleCallback is not enabled, requestIdleCallback and IdleDeadline are not defined.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS window.requestIdleCallback is undefined.
+PASS window.cancelIdleCallback is undefined.
+PASS window.IdleDeadline is undefined.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/requestidlecallback/requestidlecallback-not-enabled.html (0 => 250816)
--- trunk/LayoutTests/requestidlecallback/requestidlecallback-not-enabled.html (rev 0)
+++ trunk/LayoutTests/requestidlecallback/requestidlecallback-not-enabled.html 2019-10-08 06:22:46 UTC (rev 250816)
@@ -0,0 +1,15 @@
+<!DOCTYPE html><!-- webkit-test-runner [ experimental:RequestIdleCallbackEnabled=false ] -->
+<html>
+<body>
+<script src=""
+<script>
+
+description('This tests that when requestIdleCallback is not enabled, requestIdleCallback and IdleDeadline are not defined.');
+
+shouldBeUndefined('window.requestIdleCallback');
+shouldBeUndefined('window.cancelIdleCallback');
+shouldBeUndefined('window.IdleDeadline');
+
+</script>
+</body>
+</html>
Modified: trunk/Source/WebCore/CMakeLists.txt (250815 => 250816)
--- trunk/Source/WebCore/CMakeLists.txt 2019-10-08 04:56:31 UTC (rev 250815)
+++ trunk/Source/WebCore/CMakeLists.txt 2019-10-08 06:22:46 UTC (rev 250816)
@@ -706,6 +706,9 @@
dom/FocusEvent.idl
dom/GlobalEventHandlers.idl
dom/HashChangeEvent.idl
+ dom/IdleDeadline.idl
+ dom/IdleRequestCallback.idl
+ dom/IdleRequestOptions.idl
dom/InputEvent.idl
dom/KeyboardEvent.idl
dom/MessageChannel.idl
Modified: trunk/Source/WebCore/ChangeLog (250815 => 250816)
--- trunk/Source/WebCore/ChangeLog 2019-10-08 04:56:31 UTC (rev 250815)
+++ trunk/Source/WebCore/ChangeLog 2019-10-08 06:22:46 UTC (rev 250816)
@@ -1,3 +1,49 @@
+2019-10-07 Ryosuke Niwa <rn...@webkit.org>
+
+ Add IDL for requestIdleCallback
+ https://bugs.webkit.org/show_bug.cgi?id=202653
+
+ Reviewed by Geoffrey Garen.
+
+ Added the basic scaffolding for implementing requestIdleCallback disabled by default:
+ https://w3c.github.io/requestidlecallback/
+
+ This patch just adds the support for calling requestIdleCallback which generates a monotonically increasing number.
+ The callback is never called for now.
+
+ Tests: requestidlecallback/requestidlecallback-enabled.html
+ requestidlecallback/requestidlecallback-id.html
+ requestidlecallback/requestidlecallback-not-enabled.html
+
+ * CMakeLists.txt:
+ * DerivedSources.make:
+ * Sources.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * bindings/js/WebCoreBuiltinNames.h:
+ * dom/Document.cpp:
+ (WebCore::Document::requestIdleCallback):
+ (WebCore::Document::cancelIdleCallback):
+ * dom/Document.h:
+ * dom/IdleCallbackController.cpp: Added.
+ (WebCore::IdleCallbackController::queueIdleCallback):
+ (WebCore::IdleCallbackController::removeIdleCallback):
+ * dom/IdleCallbackController.h: Added.
+ * dom/IdleDeadline.cpp: Added.
+ (WebCore::IdleDeadline::timeRemaining const):
+ (WebCore::IdleDeadline::didTimeout const):
+ * dom/IdleDeadline.h: Added.
+ * dom/IdleDeadline.idl: Added.
+ * dom/IdleRequestCallback.h: Added.
+ * dom/IdleRequestCallback.idl: Added.
+ * dom/IdleRequestOptions.h: Added.
+ * dom/IdleRequestOptions.idl: Added.
+ * page/DOMWindow.cpp:
+ (WebCore::DOMWindow::requestIdleCallback):
+ (WebCore::DOMWindow::cancelIdleCallback):
+ * page/DOMWindow.h:
+ * page/DOMWindow.idl:
+ * page/Settings.yaml:
+
2019-10-07 Jiewen Tan <jiewen_...@apple.com>
Only wrapping CryptoKeys for IDB during serialization
Modified: trunk/Source/WebCore/DerivedSources.make (250815 => 250816)
--- trunk/Source/WebCore/DerivedSources.make 2019-10-08 04:56:31 UTC (rev 250815)
+++ trunk/Source/WebCore/DerivedSources.make 2019-10-08 06:22:46 UTC (rev 250816)
@@ -606,6 +606,9 @@
$(WebCore)/dom/FocusEvent.idl \
$(WebCore)/dom/GlobalEventHandlers.idl \
$(WebCore)/dom/HashChangeEvent.idl \
+ $(WebCore)/dom/IdleDeadline.idl \
+ $(WebCore)/dom/IdleRequestCallback.idl \
+ $(WebCore)/dom/IdleRequestOptions.idl \
$(WebCore)/dom/InputEvent.idl \
$(WebCore)/dom/KeyboardEvent.idl \
$(WebCore)/dom/MessageChannel.idl \
Modified: trunk/Source/WebCore/Sources.txt (250815 => 250816)
--- trunk/Source/WebCore/Sources.txt 2019-10-08 04:56:31 UTC (rev 250815)
+++ trunk/Source/WebCore/Sources.txt 2019-10-08 06:22:46 UTC (rev 250816)
@@ -886,6 +886,8 @@
dom/HashChangeEvent.cpp
dom/IdTargetObserver.cpp
dom/IdTargetObserverRegistry.cpp
+dom/IdleDeadline.cpp
+dom/IdleCallbackController.cpp
dom/InlineClassicScript.cpp
dom/InlineStyleSheetOwner.cpp
dom/InputEvent.cpp
@@ -2965,6 +2967,9 @@
JSIDBTransaction.cpp
JSIDBTransactionMode.cpp
JSIDBVersionChangeEvent.cpp
+JSIdleRequestCallback.cpp
+JSIdleRequestOptions.cpp
+JSIdleDeadline.cpp
JSImageBitmap.cpp
JSImageBitmapOptions.cpp
JSImageBitmapRenderingContext.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (250815 => 250816)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2019-10-08 04:56:31 UTC (rev 250815)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2019-10-08 06:22:46 UTC (rev 250816)
@@ -2852,6 +2852,10 @@
9B69D3B91B99100700E3512B /* JSHTMLSlotElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B69D3B71B99100700E3512B /* JSHTMLSlotElement.h */; };
9B6C41531344949000085B62 /* StringWithDirection.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B6C41521344949000085B62 /* StringWithDirection.h */; settings = {ATTRIBUTES = (Private, ); }; };
9B714E211C91166900AC0E92 /* EventPath.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B714E1F1C91166900AC0E92 /* EventPath.h */; };
+ 9B742605234BE95600DB52E9 /* IdleRequestCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B742603234BE95600DB52E9 /* IdleRequestCallback.h */; };
+ 9B74260B234BEA6E00DB52E9 /* IdleDeadline.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B742608234BEA6E00DB52E9 /* IdleDeadline.h */; };
+ 9B864F02234C028A006D10EB /* IdleRequestOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B864F00234C028A006D10EB /* IdleRequestOptions.h */; };
+ 9B864F06234C0893006D10EB /* IdleCallbackController.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B864F05234C0893006D10EB /* IdleCallbackController.h */; };
9BA273F4172206BB0097CE47 /* LogicalSelectionOffsetCaches.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BA273F3172206BB0097CE47 /* LogicalSelectionOffsetCaches.h */; };
9BAAC45C21520128003D4A98 /* GCReachableRef.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BAAC4562151E39E003D4A98 /* GCReachableRef.h */; settings = {ATTRIBUTES = (Private, ); }; };
9BAB6C6C12550631001626D4 /* EditingStyle.h in Headers */ = {isa = PBXBuildFile; fileRef = 9BAB6C6A12550631001626D4 /* EditingStyle.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -11068,7 +11072,16 @@
9B6C41521344949000085B62 /* StringWithDirection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringWithDirection.h; sourceTree = "<group>"; };
9B714E1E1C91166900AC0E92 /* EventPath.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EventPath.cpp; sourceTree = "<group>"; };
9B714E1F1C91166900AC0E92 /* EventPath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventPath.h; sourceTree = "<group>"; };
+ 9B742603234BE95600DB52E9 /* IdleRequestCallback.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IdleRequestCallback.h; sourceTree = "<group>"; };
+ 9B742604234BE95600DB52E9 /* IdleRequestCallback.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = IdleRequestCallback.idl; sourceTree = "<group>"; };
+ 9B742608234BEA6E00DB52E9 /* IdleDeadline.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IdleDeadline.h; sourceTree = "<group>"; };
+ 9B742609234BEA6E00DB52E9 /* IdleDeadline.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = IdleDeadline.cpp; sourceTree = "<group>"; };
+ 9B74260A234BEA6E00DB52E9 /* IdleDeadline.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = IdleDeadline.idl; sourceTree = "<group>"; };
9B85530520E733B5009EEF4F /* EventTargetFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = EventTargetFactory.cpp; path = DerivedSources/WebCore/EventTargetFactory.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
+ 9B864F00234C028A006D10EB /* IdleRequestOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IdleRequestOptions.h; sourceTree = "<group>"; };
+ 9B864F01234C028A006D10EB /* IdleRequestOptions.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = IdleRequestOptions.idl; sourceTree = "<group>"; };
+ 9B864F05234C0893006D10EB /* IdleCallbackController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IdleCallbackController.h; sourceTree = "<group>"; };
+ 9B864F07234C08A3006D10EB /* IdleCallbackController.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = IdleCallbackController.cpp; sourceTree = "<group>"; };
9B9299B01F6796A4006723C2 /* WebContentReaderCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebContentReaderCocoa.mm; sourceTree = "<group>"; };
9B9CADA72165DC7600E8D858 /* JSMutationRecordCustom.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSMutationRecordCustom.cpp; sourceTree = "<group>"; };
9BA273F3172206BB0097CE47 /* LogicalSelectionOffsetCaches.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LogicalSelectionOffsetCaches.h; sourceTree = "<group>"; };
@@ -27667,6 +27680,15 @@
E3BF19E622AF302A009C9926 /* HashChangeEvent.cpp */,
2442BBF81194C9D300D49469 /* HashChangeEvent.h */,
8482B7441198C32E00BFB005 /* HashChangeEvent.idl */,
+ 9B864F07234C08A3006D10EB /* IdleCallbackController.cpp */,
+ 9B864F05234C0893006D10EB /* IdleCallbackController.h */,
+ 9B742609234BEA6E00DB52E9 /* IdleDeadline.cpp */,
+ 9B742608234BEA6E00DB52E9 /* IdleDeadline.h */,
+ 9B74260A234BEA6E00DB52E9 /* IdleDeadline.idl */,
+ 9B742603234BE95600DB52E9 /* IdleRequestCallback.h */,
+ 9B742604234BE95600DB52E9 /* IdleRequestCallback.idl */,
+ 9B864F00234C028A006D10EB /* IdleRequestOptions.h */,
+ 9B864F01234C028A006D10EB /* IdleRequestOptions.idl */,
C3CF17A015B0063F00276D39 /* IdTargetObserver.cpp */,
C3CF17A115B0063F00276D39 /* IdTargetObserver.h */,
C3CF17A215B0063F00276D39 /* IdTargetObserverRegistry.cpp */,
@@ -29699,6 +29721,10 @@
1A71D57C0F33819000F9CE4E /* IdentifierRep.h in Headers */,
49E911C50EF86D47009D0CAF /* IdentityTransformOperation.h in Headers */,
7CE9A12B1EA2F1DB00651AD1 /* IDLAttributes.json in Headers */,
+ 9B864F06234C0893006D10EB /* IdleCallbackController.h in Headers */,
+ 9B74260B234BEA6E00DB52E9 /* IdleDeadline.h in Headers */,
+ 9B742605234BE95600DB52E9 /* IdleRequestCallback.h in Headers */,
+ 9B864F02234C028A006D10EB /* IdleRequestOptions.h in Headers */,
C0C054CD1118C8E400CE2636 /* IDLParser.pm in Headers */,
7C5222961E1DAE03002CB8F7 /* IDLTypes.h in Headers */,
C3CF17A515B0063F00276D39 /* IdTargetObserver.h in Headers */,
Modified: trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h (250815 => 250816)
--- trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h 2019-10-08 04:56:31 UTC (rev 250815)
+++ trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h 2019-10-08 06:22:46 UTC (rev 250816)
@@ -130,6 +130,7 @@
macro(IDBVersionChangeEvent) \
macro(ImageBitmap) \
macro(ImageBitmapRenderingContext) \
+ macro(IdleDeadline) \
macro(InputEvent) \
macro(IntersectionObserver) \
macro(IntersectionObserverEntry) \
@@ -243,6 +244,7 @@
macro(byobRequest) \
macro(caches) \
macro(cancel) \
+ macro(cancelIdleCallback) \
macro(cloneArrayBuffer) \
macro(close) \
macro(closeRequested) \
@@ -317,6 +319,7 @@
macro(readableStreamController) \
macro(reader) \
macro(readyPromiseCapability) \
+ macro(requestIdleCallback) \
macro(response) \
macro(responseCacheIsValid) \
macro(retrieveResponse) \
Modified: trunk/Source/WebCore/dom/Document.cpp (250815 => 250816)
--- trunk/Source/WebCore/dom/Document.cpp 2019-10-08 04:56:31 UTC (rev 250815)
+++ trunk/Source/WebCore/dom/Document.cpp 2019-10-08 06:22:46 UTC (rev 250816)
@@ -109,6 +109,7 @@
#include "HashChangeEvent.h"
#include "History.h"
#include "HitTestResult.h"
+#include "IdleCallbackController.h"
#include "ImageBitmapRenderingContext.h"
#include "ImageLoader.h"
#include "InspectorInstrumentation.h"
@@ -6361,6 +6362,20 @@
m_scriptedAnimationController = nullptr;
}
+int Document::requestIdleCallback(Ref<IdleRequestCallback>&& callback, Seconds timeout)
+{
+ if (!m_idleCallbackController)
+ m_idleCallbackController = makeUnique<IdleCallbackController>();
+ return m_idleCallbackController->queueIdleCallback(WTFMove(callback), timeout);
+}
+
+void Document::cancelIdleCallback(int id)
+{
+ if (!m_idleCallbackController)
+ return;
+ m_idleCallbackController->removeIdleCallback(id);
+}
+
void Document::wheelEventHandlersChanged()
{
Page* page = this->page();
Modified: trunk/Source/WebCore/dom/Document.h (250815 => 250816)
--- trunk/Source/WebCore/dom/Document.h 2019-10-08 04:56:31 UTC (rev 250815)
+++ trunk/Source/WebCore/dom/Document.h 2019-10-08 06:22:46 UTC (rev 250816)
@@ -145,6 +145,8 @@
class HitTestLocation;
class HitTestRequest;
class HitTestResult;
+class IdleCallbackController;
+class IdleRequestCallback;
class ImageBitmapRenderingContext;
class IntPoint;
class JSNode;
@@ -1206,6 +1208,9 @@
int requestAnimationFrame(Ref<RequestAnimationFrameCallback>&&);
void cancelAnimationFrame(int id);
+ int requestIdleCallback(Ref<IdleRequestCallback>&&, Seconds timeout);
+ void cancelIdleCallback(int id);
+
EventTarget* errorEventTarget() final;
void logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, int columnNumber, RefPtr<Inspector::ScriptCallStack>&&) final;
@@ -1838,6 +1843,8 @@
void clearScriptedAnimationController();
RefPtr<ScriptedAnimationController> m_scriptedAnimationController;
+ std::unique_ptr<IdleCallbackController> m_idleCallbackController;
+
void notifyMediaCaptureOfVisibilityChanged();
void didLogMessage(const WTFLogChannel&, WTFLogLevel, Vector<JSONLogValue>&&) final;
Added: trunk/Source/WebCore/dom/IdleCallbackController.cpp (0 => 250816)
--- trunk/Source/WebCore/dom/IdleCallbackController.cpp (rev 0)
+++ trunk/Source/WebCore/dom/IdleCallbackController.cpp 2019-10-08 06:22:46 UTC (rev 250816)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "IdleCallbackController.h"
+
+namespace WebCore {
+
+int IdleCallbackController::queueIdleCallback(Ref<IdleRequestCallback>&& callback, Seconds)
+{
+ ++m_idleCallbackIdentifier;
+ auto handle = m_idleCallbackIdentifier;
+
+ m_idleRequests.append({ handle, WTFMove(callback) });
+
+ // FIXME: Queue a task if start_idle_period is true.
+ // FIXME: Queue a task if timeout is positive.
+
+ return handle;
+}
+
+void IdleCallbackController::removeIdleCallback(int signedIdentifier)
+{
+ if (signedIdentifier <= 0)
+ return;
+ unsigned identifier = signedIdentifier;
+ m_idleRequests.removeFirstMatching([identifier](auto& request) {
+ return request.identifier == identifier;
+ });
+}
+
+} // namespace WebCore
Added: trunk/Source/WebCore/dom/IdleCallbackController.h (0 => 250816)
--- trunk/Source/WebCore/dom/IdleCallbackController.h (rev 0)
+++ trunk/Source/WebCore/dom/IdleCallbackController.h 2019-10-08 06:22:46 UTC (rev 250816)
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+#pragma once
+
+#include "IdleRequestCallback.h"
+#include <wtf/Seconds.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+class IdleCallbackController {
+ WTF_MAKE_FAST_ALLOCATED;
+
+public:
+ int queueIdleCallback(Ref<IdleRequestCallback>&&, Seconds timeout);
+ void removeIdleCallback(int);
+
+private:
+ unsigned m_idleCallbackIdentifier { 0 };
+
+ struct IdleRequest {
+ unsigned identifier;
+ Ref<IdleRequestCallback> callback;
+ };
+
+ Vector<IdleRequest> m_idleRequests;
+};
+
+} // namespace WebCore
Added: trunk/Source/WebCore/dom/IdleDeadline.cpp (0 => 250816)
--- trunk/Source/WebCore/dom/IdleDeadline.cpp (rev 0)
+++ trunk/Source/WebCore/dom/IdleDeadline.cpp 2019-10-08 06:22:46 UTC (rev 250816)
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "IdleDeadline.h"
+
+#include "DOMWindow.h"
+#include "Document.h"
+#include "Performance.h"
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+DOMHighResTimeStamp IdleDeadline::timeRemaining(Document& document) const
+{
+ auto window = makeRefPtr(document.domWindow());
+ if (!window)
+ return 0;
+ return window->performance().relativeTimeFromTimeOriginInReducedResolution(m_deadline);
+}
+
+bool IdleDeadline::didTimeout(Document& document) const
+{
+ auto window = makeRefPtr(document.domWindow());
+ if (!window)
+ return true;
+
+ // Reduce the resolution before the comparision to prevent resolution leakage.
+ auto deadline = window->performance().relativeTimeFromTimeOriginInReducedResolution(m_deadline);
+ auto now = window->performance().now();
+ return deadline >= now;
+}
+
+} // namespace WebCore
Added: trunk/Source/WebCore/dom/IdleDeadline.h (0 => 250816)
--- trunk/Source/WebCore/dom/IdleDeadline.h (rev 0)
+++ trunk/Source/WebCore/dom/IdleDeadline.h 2019-10-08 06:22:46 UTC (rev 250816)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+#pragma once
+
+#include "DOMHighResTimeStamp.h"
+#include <wtf/MonotonicTime.h>
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class Document;
+
+class IdleDeadline final : public RefCounted<IdleDeadline> {
+public:
+ Ref<IdleDeadline> create(MonotonicTime deadline)
+ {
+ return adoptRef(*new IdleDeadline(deadline));
+ }
+
+ DOMHighResTimeStamp timeRemaining(Document&) const;
+ bool didTimeout(Document&) const;
+
+private:
+ IdleDeadline(MonotonicTime deadline)
+ : m_deadline(deadline)
+ { }
+
+ const MonotonicTime m_deadline;
+};
+
+} // namespace WebCore
Added: trunk/Source/WebCore/dom/IdleDeadline.idl (0 => 250816)
--- trunk/Source/WebCore/dom/IdleDeadline.idl (rev 0)
+++ trunk/Source/WebCore/dom/IdleDeadline.idl 2019-10-08 06:22:46 UTC (rev 250816)
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+typedef double DOMHighResTimeStamp;
+
+[
+ EnabledBySetting=requestIdleCallback,
+ ImplementationLacksVTable
+] interface IdleDeadline {
+ [CallWith=Document] DOMHighResTimeStamp timeRemaining();
+ [CallWith=Document] readonly attribute boolean didTimeout;
+};
Added: trunk/Source/WebCore/dom/IdleRequestCallback.h (0 => 250816)
--- trunk/Source/WebCore/dom/IdleRequestCallback.h (rev 0)
+++ trunk/Source/WebCore/dom/IdleRequestCallback.h 2019-10-08 06:22:46 UTC (rev 250816)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+#pragma once
+
+#include "ActiveDOMCallback.h"
+#include "CallbackResult.h"
+#include <wtf/RefCounted.h>
+
+namespace WebCore {
+
+class IdleDeadline;
+
+class IdleRequestCallback : public RefCounted<IdleRequestCallback>, public ActiveDOMCallback {
+public:
+ using ActiveDOMCallback::ActiveDOMCallback;
+
+ virtual CallbackResult<void> handleEvent(IdleDeadline&) = 0;
+};
+
+} // namespace WebCore
Added: trunk/Source/WebCore/dom/IdleRequestCallback.idl (0 => 250816)
--- trunk/Source/WebCore/dom/IdleRequestCallback.idl (rev 0)
+++ trunk/Source/WebCore/dom/IdleRequestCallback.idl 2019-10-08 06:22:46 UTC (rev 250816)
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+callback IdleRequestCallback = void (IdleDeadline deadline);
Added: trunk/Source/WebCore/dom/IdleRequestOptions.h (0 => 250816)
--- trunk/Source/WebCore/dom/IdleRequestOptions.h (rev 0)
+++ trunk/Source/WebCore/dom/IdleRequestOptions.h 2019-10-08 06:22:46 UTC (rev 250816)
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+#pragma once
+
+#include <wtf/Optional.h>
+
+namespace WebCore {
+
+struct IdleRequestOptions {
+ unsigned timeout { 0 }; // Used if positive.
+};
+
+} // namespace WebCore
Added: trunk/Source/WebCore/dom/IdleRequestOptions.idl (0 => 250816)
--- trunk/Source/WebCore/dom/IdleRequestOptions.idl (rev 0)
+++ trunk/Source/WebCore/dom/IdleRequestOptions.idl 2019-10-08 06:22:46 UTC (rev 250816)
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+dictionary IdleRequestOptions {
+ unsigned long timeout;
+};
Modified: trunk/Source/WebCore/page/DOMWindow.cpp (250815 => 250816)
--- trunk/Source/WebCore/page/DOMWindow.cpp 2019-10-08 04:56:31 UTC (rev 250815)
+++ trunk/Source/WebCore/page/DOMWindow.cpp 2019-10-08 06:22:46 UTC (rev 250816)
@@ -68,6 +68,7 @@
#include "FrameView.h"
#include "HTTPParsers.h"
#include "History.h"
+#include "IdleRequestOptions.h"
#include "InspectorInstrumentation.h"
#include "JSDOMPromiseDeferred.h"
#include "JSDOMWindowBase.h"
@@ -1781,6 +1782,22 @@
document->cancelAnimationFrame(id);
}
+int DOMWindow::requestIdleCallback(Ref<IdleRequestCallback>&& callback, const IdleRequestOptions& options)
+{
+ auto document = makeRefPtr(this->document());
+ if (!document)
+ return 0;
+ return document->requestIdleCallback(WTFMove(callback), Seconds::fromMilliseconds(options.timeout));
+}
+
+void DOMWindow::cancelIdleCallback(int id)
+{
+ auto document = makeRefPtr(this->document());
+ if (!document)
+ return;
+ return document->cancelIdleCallback(id);
+}
+
void DOMWindow::createImageBitmap(ImageBitmap::Source&& source, ImageBitmapOptions&& options, ImageBitmap::Promise&& promise)
{
auto* document = this->document();
Modified: trunk/Source/WebCore/page/DOMWindow.h (250815 => 250816)
--- trunk/Source/WebCore/page/DOMWindow.h 2019-10-08 04:56:31 UTC (rev 250815)
+++ trunk/Source/WebCore/page/DOMWindow.h 2019-10-08 06:22:46 UTC (rev 250816)
@@ -65,6 +65,7 @@
class EventListener;
class FloatRect;
class History;
+class IdleRequestCallback;
class Location;
class MediaQueryList;
class Navigator;
@@ -75,6 +76,7 @@
class Performance;
class PostMessageTimer;
class RequestAnimationFrameCallback;
+class RequestIdleCallback;
class ScheduledAction;
class Screen;
class Storage;
@@ -88,6 +90,7 @@
class DeviceOrientationController;
#endif
+struct IdleRequestOptions;
struct ImageBitmapOptions;
struct WindowFeatures;
@@ -276,6 +279,9 @@
int webkitRequestAnimationFrame(Ref<RequestAnimationFrameCallback>&&);
void cancelAnimationFrame(int id);
+ int requestIdleCallback(Ref<IdleRequestCallback>&&, const IdleRequestOptions&);
+ void cancelIdleCallback(int id);
+
// ImageBitmap
void createImageBitmap(ImageBitmap::Source&&, ImageBitmapOptions&&, ImageBitmap::Promise&&);
void createImageBitmap(ImageBitmap::Source&&, int sx, int sy, int sw, int sh, ImageBitmapOptions&&, ImageBitmap::Promise&&);
Modified: trunk/Source/WebCore/page/DOMWindow.idl (250815 => 250816)
--- trunk/Source/WebCore/page/DOMWindow.idl 2019-10-08 04:56:31 UTC (rev 250815)
+++ trunk/Source/WebCore/page/DOMWindow.idl 2019-10-08 06:22:46 UTC (rev 250816)
@@ -93,6 +93,9 @@
long requestAnimationFrame(RequestAnimationFrameCallback callback); // FIXME: Should return an unsigned long.
void cancelAnimationFrame(long handle); // FIXME: handle should be an unsigned long.
+ [EnabledBySetting=requestIdleCallback] unsigned long requestIdleCallback(IdleRequestCallback callback, optional IdleRequestOptions options);
+ [EnabledBySetting=requestIdleCallback] void cancelIdleCallback(unsigned long handle);
+
[CallWith=ExecState&IncumbentWindow, DoNotCheckSecurity, ForwardDeclareInHeader, MayThrowException] void postMessage(any message, USVString targetOrigin, optional sequence<object> transfer = []);
// Obsolete members, still part of the HTML specification (https://html.spec.whatwg.org/#Window-partial).
Modified: trunk/Source/WebCore/page/Settings.yaml (250815 => 250816)
--- trunk/Source/WebCore/page/Settings.yaml 2019-10-08 04:56:31 UTC (rev 250815)
+++ trunk/Source/WebCore/page/Settings.yaml 2019-10-08 06:22:46 UTC (rev 250816)
@@ -337,6 +337,8 @@
initial: false
requestAnimationFrameEnabled:
initial: true
+requestIdleCallbackEnabled:
+ initial: false
HTTPSUpgradeEnabled:
initial: false
Modified: trunk/Source/WebKit/ChangeLog (250815 => 250816)
--- trunk/Source/WebKit/ChangeLog 2019-10-08 04:56:31 UTC (rev 250815)
+++ trunk/Source/WebKit/ChangeLog 2019-10-08 06:22:46 UTC (rev 250816)
@@ -1,3 +1,12 @@
+2019-10-07 Ryosuke Niwa <rn...@webkit.org>
+
+ Add IDL for requestIdleCallback
+ https://bugs.webkit.org/show_bug.cgi?id=202653
+
+ Reviewed by Geoffrey Garen.
+
+ * Shared/WebPreferences.yaml:
+
2019-10-07 Kate Cheney <katherine_che...@apple.com>
Domain relationships in the ITP Database should be inserted in a single query and ignore repeat insert attempts. (202604)
Modified: trunk/Source/WebKit/Shared/WebPreferences.yaml (250815 => 250816)
--- trunk/Source/WebKit/Shared/WebPreferences.yaml 2019-10-08 04:56:31 UTC (rev 250815)
+++ trunk/Source/WebKit/Shared/WebPreferences.yaml 2019-10-08 06:22:46 UTC (rev 250816)
@@ -362,6 +362,13 @@
type: bool
defaultValue: true
+RequestIdleCallbackEnabled:
+ type: bool
+ defaultValue: false
+ humanReadableName: "requestIdleCallback"
+ humanReadableDescription: "Enable requestIdleCallback support"
+ category: experimental
+
DiagnosticLoggingEnabled:
type: bool
defaultValue: false
Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (250815 => 250816)
--- trunk/Source/WebKitLegacy/mac/ChangeLog 2019-10-08 04:56:31 UTC (rev 250815)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog 2019-10-08 06:22:46 UTC (rev 250816)
@@ -1,3 +1,17 @@
+2019-10-07 Ryosuke Niwa <rn...@webkit.org>
+
+ Add IDL for requestIdleCallback
+ https://bugs.webkit.org/show_bug.cgi?id=202653
+
+ Reviewed by Geoffrey Garen.
+
+ * WebView/WebPreferenceKeysPrivate.h:
+ * WebView/WebPreferences.mm:
+ (+[WebPreferences initialize]):
+ * WebView/WebPreferencesPrivate.h:
+ * WebView/WebView.mm:
+ (-[WebView _preferencesChanged:]):
+
2019-10-07 Yusuke Suzuki <ysuz...@apple.com>
[JSC] Change signature of HostFunction to (JSGlobalObject*, CallFrame*)
Modified: trunk/Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h (250815 => 250816)
--- trunk/Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h 2019-10-08 04:56:31 UTC (rev 250815)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebPreferenceKeysPrivate.h 2019-10-08 06:22:46 UTC (rev 250816)
@@ -272,5 +272,6 @@
#define WebKitReferrerPolicyAttributeEnabledPreferenceKey @"WebKitReferrerPolicyAttributeEnabled"
#define WebKitResizeObserverEnabledPreferenceKey @"WebKitResizeObserverEnabled"
#define WebKitCoreMathMLEnabledPreferenceKey @"WebKitCoreMathMLEnabled"
+#define WebKitRequestIdleCallbackEnabledPreferenceKey @"WebKitRequestIdleCallbackEnabled"
#define WebKitLinkPreloadResponsiveImagesEnabledPreferenceKey @"WebKitLinkPreloadResponsiveImagesEnabled"
Modified: trunk/Source/WebKitLegacy/mac/WebView/WebPreferences.mm (250815 => 250816)
--- trunk/Source/WebKitLegacy/mac/WebView/WebPreferences.mm 2019-10-08 04:56:31 UTC (rev 250815)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebPreferences.mm 2019-10-08 06:22:46 UTC (rev 250816)
@@ -690,6 +690,7 @@
@NO, WebKitResizeObserverEnabledPreferenceKey,
#endif
@NO, WebKitCoreMathMLEnabledPreferenceKey,
+ @NO, WebKitRequestIdleCallbackEnabledPreferenceKey,
@NO, WebKitLinkPreloadResponsiveImagesEnabledPreferenceKey,
@NO, WebKitCSSShadowPartsEnabledPreferenceKey,
nil];
@@ -3498,6 +3499,16 @@
[self _setBoolValue:flag forKey:WebKitCoreMathMLEnabledPreferenceKey];
}
+- (BOOL)requestIdleCallbackEnabled
+{
+ return [self _boolValueForKey:WebKitRequestIdleCallbackEnabledPreferenceKey];
+}
+
+- (void)setRequestIdleCallbackEnabled:(BOOL)flag
+{
+ [self _setBoolValue:flag forKey:WebKitRequestIdleCallbackEnabledPreferenceKey];
+}
+
- (BOOL)linkPreloadResponsiveImagesEnabled
{
return [self _boolValueForKey:WebKitLinkPreloadResponsiveImagesEnabledPreferenceKey];
Modified: trunk/Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h (250815 => 250816)
--- trunk/Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h 2019-10-08 04:56:31 UTC (rev 250815)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebPreferencesPrivate.h 2019-10-08 06:22:46 UTC (rev 250816)
@@ -612,6 +612,9 @@
- (void)setCoreMathMLEnabled:(BOOL)flag;
- (BOOL)coreMathMLEnabled;
+- (void)setRequestIdleCallbackEnabled:(BOOL)flag;
+- (BOOL)requestIdleCallbackEnabled;
+
- (void)setLinkPreloadResponsiveImagesEnabled:(BOOL)flag;
- (BOOL)linkPreloadResponsiveImagesEnabled;
@@ -652,6 +655,7 @@
@property (nonatomic) BOOL referrerPolicyAttributeEnabled;
@property (nonatomic) BOOL resizeObserverEnabled;
@property (nonatomic) BOOL coreMathMLEnabled;
+@property (nonatomic) BOOL requestIdleCallbackEnabled;
@property (nonatomic) BOOL linkPreloadResponsiveImagesEnabled;
#if TARGET_OS_IPHONE
Modified: trunk/Source/WebKitLegacy/mac/WebView/WebView.mm (250815 => 250816)
--- trunk/Source/WebKitLegacy/mac/WebView/WebView.mm 2019-10-08 04:56:31 UTC (rev 250815)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebView.mm 2019-10-08 06:22:46 UTC (rev 250816)
@@ -3235,6 +3235,7 @@
settings.setMediaCapabilitiesEnabled([preferences mediaCapabilitiesEnabled]);
settings.setCoreMathMLEnabled([preferences coreMathMLEnabled]);
+ settings.setRequestIdleCallbackEnabled([preferences requestIdleCallbackEnabled]);
RuntimeEnabledFeatures::sharedFeatures().setServerTimingEnabled([preferences serverTimingEnabled]);
Modified: trunk/Tools/ChangeLog (250815 => 250816)
--- trunk/Tools/ChangeLog 2019-10-08 04:56:31 UTC (rev 250815)
+++ trunk/Tools/ChangeLog 2019-10-08 06:22:46 UTC (rev 250816)
@@ -1,3 +1,16 @@
+2019-10-07 Ryosuke Niwa <rn...@webkit.org>
+
+ Add IDL for requestIdleCallback
+ https://bugs.webkit.org/show_bug.cgi?id=202653
+
+ Reviewed by Geoffrey Garen.
+
+ * DumpRenderTree/TestOptions.cpp:
+ (TestOptions::TestOptions):
+ * DumpRenderTree/TestOptions.h:
+ * DumpRenderTree/mac/DumpRenderTree.mm:
+ (setWebPreferencesForTestOptions):
+
2019-10-07 Jiewen Tan <jiewen_...@apple.com>
Only wrapping CryptoKeys for IDB during serialization
Modified: trunk/Tools/DumpRenderTree/TestOptions.cpp (250815 => 250816)
--- trunk/Tools/DumpRenderTree/TestOptions.cpp 2019-10-08 04:56:31 UTC (rev 250815)
+++ trunk/Tools/DumpRenderTree/TestOptions.cpp 2019-10-08 06:22:46 UTC (rev 250816)
@@ -123,6 +123,8 @@
enableResizeObserver = parseBooleanTestHeaderValue(value);
else if (key == "experimental:CoreMathMLEnabled")
enableCoreMathML = parseBooleanTestHeaderValue(value);
+ else if (key == "experimental:RequestIdleCallbackEnabled")
+ enableRequestIdleCallback = parseBooleanTestHeaderValue(value);
pairStart = pairEnd + 1;
}
}
Modified: trunk/Tools/DumpRenderTree/TestOptions.h (250815 => 250816)
--- trunk/Tools/DumpRenderTree/TestOptions.h 2019-10-08 04:56:31 UTC (rev 250815)
+++ trunk/Tools/DumpRenderTree/TestOptions.h 2019-10-08 06:22:46 UTC (rev 250816)
@@ -51,6 +51,7 @@
bool adClickAttributionEnabled { false };
bool enableResizeObserver { false };
bool enableCoreMathML { false };
+ bool enableRequestIdleCallback { false };
std::string jscOptions;
std::string additionalSupportedImageTypes;
Modified: trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm (250815 => 250816)
--- trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm 2019-10-08 04:56:31 UTC (rev 250815)
+++ trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm 2019-10-08 06:22:46 UTC (rev 250816)
@@ -1028,6 +1028,7 @@
preferences.adClickAttributionEnabled = options.adClickAttributionEnabled;
preferences.resizeObserverEnabled = options.enableResizeObserver;
preferences.coreMathMLEnabled = options.enableCoreMathML;
+ preferences.requestIdleCallbackEnabled = options.enableRequestIdleCallback;
preferences.privateBrowsingEnabled = options.useEphemeralSession;
preferences.usesPageCache = options.enablePageCache;
}