Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add distinguishable state for cb and dictionary-like #1353

Merged
merged 5 commits into from
Jan 15, 2024

Conversation

vmpstr
Copy link
Member

@vmpstr vmpstr commented Aug 16, 2023

Fixes #1191

(See WHATWG Working Mode: Changes for more details.)


Preview | Diff

index.bs Outdated Show resolved Hide resolved
@bathos
Copy link
Contributor

bathos commented Aug 16, 2023

This comment only intends to make a design decision implied by this PR explicit to other readers.

The [LTNOAN] annotation causes only nullable types with the annotated callback function as their inner type to have the problematically expanded value space — and more specifically, only when used as an attribute’s type. In every other context, an [LTNOAN]-annotated callback function behaves exactly the same as any other.

This PR will leave all [LTNOAN]-annotated callback functions indistinguishable from dictionary-likes even in contexts where [LTNOAN] is otherwise ignored/meaningless.

That seems like a reasonable call:

  • It’s much simpler than trying to account for all those quirky conditions
  • It’s usually okay (or even desirable) to leave legacy features in the dust when introducing new features

Again, this comment’s just an “FYI” thing in case other folks do see a problem with this approach — as far as I can tell, it works.

Copy link
Contributor

@jeremyroman jeremyroman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me (though my approval isn't significant).

index.bs Outdated
[=union type=] selection, and the possible types are [=callback
function=] and disctionary-like category type, then the type is a
[=callback function=] if the object is [=ECMAScript/callable=].
Otherwise, it is a dictionary-like category type.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For clarity, even though this pull request doesn't change it, the overload resolution algorithm and algorithm "convert an ECMAScript value an to IDL union type" already handle this correctly in the Callable(V) case, as I understand it?

index.bs Outdated
Comment on lines 3506 to 3509
1. A [=callback function=] that does not have
[{{LegacyTreatNonObjectAsNull}}] extended attribute is
distinguishable from a dictionary-like category object based on
whether the object is [=ECMAScript/callable=]. When selecting a
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
1. A [=callback function=] that does not have
[{{LegacyTreatNonObjectAsNull}}] extended attribute is
distinguishable from a dictionary-like category object based on
whether the object is [=ECMAScript/callable=]. When selecting a
1. A [=callback function=] that does not have
[{{LegacyTreatNonObjectAsNull}}] extended attribute is
distinguishable from a dictionary-like type. When selecting a

I think the second sentence clarifies that the Callable algorithm is used, but what's normatively important in this algorithm is that callback functions without LTNOAN are distinguishable from dictionary-like types. (Since this algorithm operates on WebIDL types rather than ECMAScript values, it cannot actually normatively use Callable here.) Separating them with a full stop makes that clearer to me.

As a nit, the normative sentence here should probably discuss the types rather than the objects, for the same reason.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that the ECMAScript value is the ting that can be Callable, and it seems that at least the union resolution will convert a Callable ECMAScript value to a callable type. Otherwise, it will convert it to a dictionary-like type?

I'm not sure what you mean about a full stop separating things though.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no values in this algorithm, only types. So the normative text here should describe dictionary-like WebIDL types, not ECMAScript values (objects or otherwise) Consequently, this algorithm cannot depend on whether the value is [=ECMAScript/callable=] (though it could be noted informatively). The value conversion and overload resolution algorithms already do use [=ECMAScript/callable=] where appropriate.

By a full stop, I mean the punctuation mark, a period (.). I think the first sentence of this bullet point should be the normative text about how, given two WebIDL types, an implementation can tell whether they are distinguishable. Any notes about how that corresponds to value conversion and overload resolution can follow in a separate sentence or parenthetical, if necessary.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I've updated this to explicitly separate normative text from non-normative notes. I don't think a punctuation mark is sufficient to imply a switch from normative to non-normative text.

Let me know if this reads better

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm thanks

Copy link
Member

@domenic domenic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good with a wording nit.

Can we get multi-implementer interest here somehow? In particular, making sure this doesn't break something deep in their binding system, for example.

If the API you intend to use this for has multi-implementer interest, then recruiting those people to come over here and say "yes, no problem with changing Web IDL to accommodate that API" would be perfect.

index.bs Outdated Show resolved Hide resolved
Co-authored-by: Domenic Denicola <[email protected]>
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Oct 24, 2023
This patch does several things:
- Loosens the restriction in IDL checker to allow distinguishing between
  callback types and dictionary like types. This implements the
  following PR: whatwg/webidl#1353

- Uses the loosened restriction to add a behind-the-flag overload of
  startViewTransition that takes a dictionary

- Adds a smoke test for the new syntax

Bug: 1466251
Change-Id: I7b82b49e993e8ad907804d772b4f2c6e0f1ab3e8
@yuki3
Copy link

yuki3 commented Oct 27, 2023

Looks good with a wording nit.

Can we get multi-implementer interest here somehow? In particular, making sure this doesn't break something deep in their binding system, for example.

If the API you intend to use this for has multi-implementer interest, then recruiting those people to come over here and say "yes, no problem with changing Web IDL to accommodate that API" would be perfect.

FWIW, I've implemented the corresponding change in Chromium. It's already been landed.

aarongable pushed a commit to chromium/chromium that referenced this pull request Oct 30, 2023
This patch does several things:
- Loosens the restriction in IDL checker to allow distinguishing between
  callback types and dictionary like types. This implements the
  following PR: whatwg/webidl#1353

- Uses the loosened restriction to add a behind-the-flag overload of
  startViewTransition that takes a dictionary

- Adds a smoke test for the new syntax

Bug: 1466251
Change-Id: I7b82b49e993e8ad907804d772b4f2c6e0f1ab3e8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4973315
Reviewed-by: Xianzhu Wang <[email protected]>
Reviewed-by: David Bokan <[email protected]>
Commit-Queue: Vladimir Levin <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1216984}
@lukewarlow
Copy link
Member

lukewarlow commented Jan 12, 2024

Fwiw I have an implementation of this change within WebKit and it's rather trivial. @keithamus will probably be the one who ends up actually upstreaming it (he's prototyping observerables). Idk what signal is needed here for implementer interest, potentially can just wait and mark this as 2 implementers once the code is merged upstream?

https://github.com/WebKit/WebKit/compare/lukewarlow:callback-dictionary-union - a minimal branch with the changes required

In case anyone looks and wonders about the attribute special casing, WebKit doesn't support that attribute so no need to check it.

@annevk annevk merged commit 857ba61 into whatwg:main Jan 15, 2024
@annevk
Copy link
Member

annevk commented Jan 15, 2024

@vmpstr would you be willing to file the implementation bugs for this and update OP afterwards?

@keithamus
Copy link

keithamus commented Jan 15, 2024

I have filed https://bugs.webkit.org/show_bug.cgi?id=267533 (WebKit) & https://bugzilla.mozilla.org/show_bug.cgi?id=1874665 (Gecko) as I intend to work on these.

@annevk
Copy link
Member

annevk commented Jan 15, 2024

That's great. We'll need bugs for the tooling-related projects as well though. Less worried about browsers as they will get here through downstream features.

@vmpstr vmpstr deleted the cb_dict_distinguish branch January 29, 2024 21:05
@vmpstr
Copy link
Member Author

vmpstr commented Jan 29, 2024

Sorry for the late reply. I'm happy to file implementation bugs, but I don't know which tooling-related projects you mean. Is there a canonical list?

@saschanaz
Copy link
Member

It's in the PR template, the last two ones specifically.

@vmpstr
Copy link
Member Author

vmpstr commented Jan 29, 2024

Ah thanks, I'll file issues and update here when I've done so

keithamus added a commit to keithamus/WebKit that referenced this pull request Jul 13, 2024
https://bugs.webkit.org/show_bug.cgi?id=276572

Reviewed by NOBODY (OOPS!).

This implements the base `Observable` class, as well as the `subscribe`
method. In addition this adds the `Subscriber` internal class allows
Observables to be subscribed to, and some additional machinery such as
`SubscribeOptions`, `SubscriptionObserver` and so on.

This also includes a fix to IDL generation to correctly generate callback
function + dictionary unions (whatwg/webidl#1353).

This does not implement any of the prototype methods on Observable,
(other than subscribe) such as `takeUntil`, `filter`, `finally` and so
on.

* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-constructor.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-constructor.window-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-takeUntil.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-takeUntil.any.worker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-takeUntil.window-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-toArray.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-toArray.any.worker-expected.txt:
* Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml:
* Source/WebCore/CMakeLists.txt:
* Source/WebCore/DerivedSources-input.xcfilelist:
* Source/WebCore/DerivedSources-output.xcfilelist:
* Source/WebCore/DerivedSources.make:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/bindings/IDLTypes.h:
* Source/WebCore/bindings/js/JSDOMConvertUnion.h:
* Source/WebCore/bindings/js/WebCoreBuiltinNames.h:
* Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:
(AreTypesDistinguishableForOverloadResolution):
* Source/WebCore/bindings/scripts/test/JS/JSTestCallbackWithFunctionOrDict.cpp: Added.
(WebCore::JSTestCallbackWithFunctionOrDict::JSTestCallbackWithFunctionOrDict):
(WebCore::JSTestCallbackWithFunctionOrDict::~JSTestCallbackWithFunctionOrDict):
(WebCore::JSTestCallbackWithFunctionOrDict::handleEvent):
(WebCore::JSTestCallbackWithFunctionOrDict::visitJSFunction):
(WebCore::toJS):
* Source/WebCore/bindings/scripts/test/JS/JSTestCallbackWithFunctionOrDict.h: Added.
(WebCore::toJS):
* Source/WebCore/bindings/scripts/test/SupplementalDependencies.dep:
* Source/WebCore/bindings/scripts/test/TestCallbackOrDict.idl: Added.
* Source/WebCore/dom/Observable.cpp: Added.
(WebCore::Observable::create):
(WebCore::Observable::subscribe):
(WebCore::Observable::makeSubscriber):
(WebCore::Observable::Observable):
* Source/WebCore/dom/Observable.h: Added.
* Source/WebCore/dom/Observable.idl: Added.
* Source/WebCore/dom/SubscribeOptions.h: Added.
* Source/WebCore/dom/SubscribeOptions.idl: Added.
* Source/WebCore/dom/Subscriber.cpp: Added.
(WebCore::Subscriber::create):
(WebCore::Subscriber::Subscriber):
(WebCore::Subscriber::next):
(WebCore::Subscriber::error):
(WebCore::Subscriber::complete):
(WebCore::Subscriber::addTeardown):
(WebCore::Subscriber::close):
(WebCore::Subscriber::abort):
(WebCore::Subscriber::closeAndTeardown):
* Source/WebCore/dom/Subscriber.h: Added.
* Source/WebCore/dom/Subscriber.idl: Added.
* Source/WebCore/dom/SubscriberCallback.cpp: Added.
* Source/WebCore/dom/SubscriberCallback.h: Added.
* Source/WebCore/dom/SubscriberCallback.idl: Added.
* Source/WebCore/dom/SubscriptionObserver.h: Added.
* Source/WebCore/dom/SubscriptionObserver.idl: Added.
* Source/WebCore/dom/SubscriptionObserverCallback.h: Added.
* Source/WebCore/dom/SubscriptionObserverCallback.idl: Added.
keithamus added a commit to keithamus/WebKit that referenced this pull request Jul 13, 2024
https://bugs.webkit.org/show_bug.cgi?id=276572

Reviewed by NOBODY (OOPS!).

This implements the base `Observable` class, as well as the `subscribe`
method. In addition this adds the `Subscriber` internal class allows
Observables to be subscribed to, and some additional machinery such as
`SubscribeOptions`, `SubscriptionObserver` and so on.

This also includes a fix to IDL generation to correctly generate callback
function + dictionary unions (whatwg/webidl#1353).

This does not implement any of the prototype methods on Observable,
(other than subscribe) such as `takeUntil`, `filter`, `finally` and so
on.

* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-constructor.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-constructor.window-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-takeUntil.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-takeUntil.any.worker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-takeUntil.window-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-toArray.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-toArray.any.worker-expected.txt:
* Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml:
* Source/WebCore/CMakeLists.txt:
* Source/WebCore/DerivedSources-input.xcfilelist:
* Source/WebCore/DerivedSources-output.xcfilelist:
* Source/WebCore/DerivedSources.make:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/bindings/IDLTypes.h:
* Source/WebCore/bindings/js/JSDOMConvertUnion.h:
* Source/WebCore/bindings/js/WebCoreBuiltinNames.h:
* Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:
(AreTypesDistinguishableForOverloadResolution):
* Source/WebCore/bindings/scripts/test/JS/JSTestCallbackWithFunctionOrDict.cpp: Added.
(WebCore::JSTestCallbackWithFunctionOrDict::JSTestCallbackWithFunctionOrDict):
(WebCore::JSTestCallbackWithFunctionOrDict::~JSTestCallbackWithFunctionOrDict):
(WebCore::JSTestCallbackWithFunctionOrDict::handleEvent):
(WebCore::JSTestCallbackWithFunctionOrDict::visitJSFunction):
(WebCore::toJS):
* Source/WebCore/bindings/scripts/test/JS/JSTestCallbackWithFunctionOrDict.h: Added.
(WebCore::toJS):
* Source/WebCore/bindings/scripts/test/SupplementalDependencies.dep:
* Source/WebCore/bindings/scripts/test/TestCallbackOrDict.idl: Added.
* Source/WebCore/dom/Observable.cpp: Added.
(WebCore::Observable::create):
(WebCore::Observable::subscribe):
(WebCore::Observable::makeSubscriber):
(WebCore::Observable::Observable):
* Source/WebCore/dom/Observable.h: Added.
* Source/WebCore/dom/Observable.idl: Added.
* Source/WebCore/dom/SubscribeOptions.h: Added.
* Source/WebCore/dom/SubscribeOptions.idl: Added.
* Source/WebCore/dom/Subscriber.cpp: Added.
(WebCore::Subscriber::create):
(WebCore::Subscriber::Subscriber):
(WebCore::Subscriber::next):
(WebCore::Subscriber::error):
(WebCore::Subscriber::complete):
(WebCore::Subscriber::addTeardown):
(WebCore::Subscriber::close):
(WebCore::Subscriber::abort):
(WebCore::Subscriber::closeAndTeardown):
* Source/WebCore/dom/Subscriber.h: Added.
* Source/WebCore/dom/Subscriber.idl: Added.
* Source/WebCore/dom/SubscriberCallback.cpp: Added.
* Source/WebCore/dom/SubscriberCallback.h: Added.
* Source/WebCore/dom/SubscriberCallback.idl: Added.
* Source/WebCore/dom/SubscriptionObserver.h: Added.
* Source/WebCore/dom/SubscriptionObserver.idl: Added.
* Source/WebCore/dom/SubscriptionObserverCallback.h: Added.
* Source/WebCore/dom/SubscriptionObserverCallback.idl: Added.
keithamus added a commit to keithamus/WebKit that referenced this pull request Jul 13, 2024
https://bugs.webkit.org/show_bug.cgi?id=276572

Reviewed by NOBODY (OOPS!).

This implements the base `Observable` class, as well as the `subscribe`
method. In addition this adds the `Subscriber` internal class allows
Observables to be subscribed to, and some additional machinery such as
`SubscribeOptions`, `SubscriptionObserver` and so on.

This also includes a fix to IDL generation to correctly generate callback
function + dictionary unions (whatwg/webidl#1353).

This does not implement any of the prototype methods on Observable,
(other than subscribe) such as `takeUntil`, `filter`, `finally` and so
on.

* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-constructor.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-constructor.window-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-takeUntil.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-takeUntil.any.worker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-takeUntil.window-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-toArray.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-toArray.any.worker-expected.txt:
* Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml:
* Source/WebCore/CMakeLists.txt:
* Source/WebCore/DerivedSources-input.xcfilelist:
* Source/WebCore/DerivedSources-output.xcfilelist:
* Source/WebCore/DerivedSources.make:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/bindings/IDLTypes.h:
* Source/WebCore/bindings/js/JSDOMConvertUnion.h:
* Source/WebCore/bindings/js/WebCoreBuiltinNames.h:
* Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:
(AreTypesDistinguishableForOverloadResolution):
* Source/WebCore/bindings/scripts/test/JS/JSTestCallbackWithFunctionOrDict.cpp: Added.
(WebCore::JSTestCallbackWithFunctionOrDict::JSTestCallbackWithFunctionOrDict):
(WebCore::JSTestCallbackWithFunctionOrDict::~JSTestCallbackWithFunctionOrDict):
(WebCore::JSTestCallbackWithFunctionOrDict::handleEvent):
(WebCore::JSTestCallbackWithFunctionOrDict::visitJSFunction):
(WebCore::toJS):
* Source/WebCore/bindings/scripts/test/JS/JSTestCallbackWithFunctionOrDict.h: Added.
(WebCore::toJS):
* Source/WebCore/bindings/scripts/test/SupplementalDependencies.dep:
* Source/WebCore/bindings/scripts/test/TestCallbackOrDict.idl: Added.
* Source/WebCore/dom/Observable.cpp: Added.
(WebCore::Observable::create):
(WebCore::Observable::subscribe):
(WebCore::Observable::makeSubscriber):
(WebCore::Observable::Observable):
* Source/WebCore/dom/Observable.h: Added.
* Source/WebCore/dom/Observable.idl: Added.
* Source/WebCore/dom/SubscribeOptions.h: Added.
* Source/WebCore/dom/SubscribeOptions.idl: Added.
* Source/WebCore/dom/Subscriber.cpp: Added.
(WebCore::Subscriber::create):
(WebCore::Subscriber::Subscriber):
(WebCore::Subscriber::next):
(WebCore::Subscriber::error):
(WebCore::Subscriber::complete):
(WebCore::Subscriber::addTeardown):
(WebCore::Subscriber::close):
(WebCore::Subscriber::abort):
(WebCore::Subscriber::closeAndTeardown):
* Source/WebCore/dom/Subscriber.h: Added.
* Source/WebCore/dom/Subscriber.idl: Added.
* Source/WebCore/dom/SubscriberCallback.cpp: Added.
* Source/WebCore/dom/SubscriberCallback.h: Added.
* Source/WebCore/dom/SubscriberCallback.idl: Added.
* Source/WebCore/dom/SubscriptionObserver.h: Added.
* Source/WebCore/dom/SubscriptionObserver.idl: Added.
* Source/WebCore/dom/SubscriptionObserverCallback.h: Added.
* Source/WebCore/dom/SubscriptionObserverCallback.idl: Added.
keithamus added a commit to keithamus/WebKit that referenced this pull request Jul 13, 2024
https://bugs.webkit.org/show_bug.cgi?id=276572

Reviewed by NOBODY (OOPS!).

This implements the base `Observable` class, as well as the `subscribe`
method. In addition this adds the `Subscriber` internal class allows
Observables to be subscribed to, and some additional machinery such as
`SubscribeOptions`, `SubscriptionObserver` and so on.

This also includes a fix to IDL generation to correctly generate callback
function + dictionary unions (whatwg/webidl#1353).

This does not implement any of the prototype methods on Observable,
(other than subscribe) such as `takeUntil`, `filter`, `finally` and so
on.

* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-constructor.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-constructor.window-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-takeUntil.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-takeUntil.any.worker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-takeUntil.window-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-toArray.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-toArray.any.worker-expected.txt:
* Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml:
* Source/WebCore/CMakeLists.txt:
* Source/WebCore/DerivedSources-input.xcfilelist:
* Source/WebCore/DerivedSources-output.xcfilelist:
* Source/WebCore/DerivedSources.make:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/bindings/IDLTypes.h:
* Source/WebCore/bindings/js/JSDOMConvertUnion.h:
* Source/WebCore/bindings/js/WebCoreBuiltinNames.h:
* Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:
(AreTypesDistinguishableForOverloadResolution):
* Source/WebCore/bindings/scripts/test/JS/JSTestCallbackWithFunctionOrDict.cpp: Added.
(WebCore::JSTestCallbackWithFunctionOrDict::JSTestCallbackWithFunctionOrDict):
(WebCore::JSTestCallbackWithFunctionOrDict::~JSTestCallbackWithFunctionOrDict):
(WebCore::JSTestCallbackWithFunctionOrDict::handleEvent):
(WebCore::JSTestCallbackWithFunctionOrDict::visitJSFunction):
(WebCore::toJS):
* Source/WebCore/bindings/scripts/test/JS/JSTestCallbackWithFunctionOrDict.h: Added.
(WebCore::toJS):
* Source/WebCore/bindings/scripts/test/SupplementalDependencies.dep:
* Source/WebCore/bindings/scripts/test/TestCallbackOrDict.idl: Added.
* Source/WebCore/dom/Observable.cpp: Added.
(WebCore::Observable::create):
(WebCore::Observable::subscribe):
(WebCore::Observable::makeSubscriber):
(WebCore::Observable::Observable):
* Source/WebCore/dom/Observable.h: Added.
* Source/WebCore/dom/Observable.idl: Added.
* Source/WebCore/dom/SubscribeOptions.h: Added.
* Source/WebCore/dom/SubscribeOptions.idl: Added.
* Source/WebCore/dom/Subscriber.cpp: Added.
(WebCore::Subscriber::create):
(WebCore::Subscriber::Subscriber):
(WebCore::Subscriber::next):
(WebCore::Subscriber::error):
(WebCore::Subscriber::complete):
(WebCore::Subscriber::addTeardown):
(WebCore::Subscriber::close):
(WebCore::Subscriber::abort):
(WebCore::Subscriber::closeAndTeardown):
* Source/WebCore/dom/Subscriber.h: Added.
* Source/WebCore/dom/Subscriber.idl: Added.
* Source/WebCore/dom/SubscriberCallback.cpp: Added.
* Source/WebCore/dom/SubscriberCallback.h: Added.
* Source/WebCore/dom/SubscriberCallback.idl: Added.
* Source/WebCore/dom/SubscriptionObserver.h: Added.
* Source/WebCore/dom/SubscriptionObserver.idl: Added.
* Source/WebCore/dom/SubscriptionObserverCallback.h: Added.
* Source/WebCore/dom/SubscriptionObserverCallback.idl: Added.
keithamus added a commit to keithamus/WebKit that referenced this pull request Jul 14, 2024
https://bugs.webkit.org/show_bug.cgi?id=276572

Reviewed by NOBODY (OOPS!).

This implements the base `Observable` class, as well as the `subscribe`
method. In addition this adds the `Subscriber` internal class allows
Observables to be subscribed to, and some additional machinery such as
`SubscribeOptions`, `SubscriptionObserver` and so on.

This also includes a fix to IDL generation to correctly generate callback
function + dictionary unions (whatwg/webidl#1353).

This does not implement any of the prototype methods on Observable,
(other than subscribe) such as `takeUntil`, `filter`, `finally` and so
on.

* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-constructor.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-constructor.window-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-takeUntil.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-takeUntil.any.worker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-takeUntil.window-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-toArray.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-toArray.any.worker-expected.txt:
* Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml:
* Source/WebCore/CMakeLists.txt:
* Source/WebCore/DerivedSources-input.xcfilelist:
* Source/WebCore/DerivedSources-output.xcfilelist:
* Source/WebCore/DerivedSources.make:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/bindings/IDLTypes.h:
* Source/WebCore/bindings/js/JSDOMConvertUnion.h:
* Source/WebCore/bindings/js/WebCoreBuiltinNames.h:
* Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:
(AreTypesDistinguishableForOverloadResolution):
* Source/WebCore/bindings/scripts/test/JS/JSTestCallbackWithFunctionOrDict.cpp: Added.
(WebCore::JSTestCallbackWithFunctionOrDict::JSTestCallbackWithFunctionOrDict):
(WebCore::JSTestCallbackWithFunctionOrDict::~JSTestCallbackWithFunctionOrDict):
(WebCore::JSTestCallbackWithFunctionOrDict::handleEvent):
(WebCore::JSTestCallbackWithFunctionOrDict::visitJSFunction):
(WebCore::toJS):
* Source/WebCore/bindings/scripts/test/JS/JSTestCallbackWithFunctionOrDict.h: Added.
(WebCore::toJS):
* Source/WebCore/bindings/scripts/test/SupplementalDependencies.dep:
* Source/WebCore/bindings/scripts/test/TestCallbackOrDict.idl: Added.
* Source/WebCore/dom/Observable.cpp: Added.
(WebCore::Observable::create):
(WebCore::Observable::subscribe):
(WebCore::Observable::makeSubscriber):
(WebCore::Observable::Observable):
* Source/WebCore/dom/Observable.h: Added.
* Source/WebCore/dom/Observable.idl: Added.
* Source/WebCore/dom/SubscribeOptions.h: Added.
* Source/WebCore/dom/SubscribeOptions.idl: Added.
* Source/WebCore/dom/Subscriber.cpp: Added.
(WebCore::Subscriber::create):
(WebCore::Subscriber::Subscriber):
(WebCore::Subscriber::next):
(WebCore::Subscriber::error):
(WebCore::Subscriber::complete):
(WebCore::Subscriber::addTeardown):
(WebCore::Subscriber::close):
(WebCore::Subscriber::abort):
(WebCore::Subscriber::closeAndTeardown):
* Source/WebCore/dom/Subscriber.h: Added.
* Source/WebCore/dom/Subscriber.idl: Added.
* Source/WebCore/dom/SubscriberCallback.cpp: Added.
* Source/WebCore/dom/SubscriberCallback.h: Added.
* Source/WebCore/dom/SubscriberCallback.idl: Added.
* Source/WebCore/dom/SubscriptionObserver.h: Added.
* Source/WebCore/dom/SubscriptionObserver.idl: Added.
* Source/WebCore/dom/SubscriptionObserverCallback.h: Added.
* Source/WebCore/dom/SubscriptionObserverCallback.idl: Added.
keithamus added a commit to keithamus/WebKit that referenced this pull request Jul 14, 2024
https://bugs.webkit.org/show_bug.cgi?id=276572

Reviewed by NOBODY (OOPS!).

This implements the base `Observable` class, as well as the `subscribe`
method. In addition this adds the `Subscriber` internal class allows
Observables to be subscribed to, and some additional machinery such as
`SubscribeOptions`, `SubscriptionObserver` and so on.

This also includes a fix to IDL generation to correctly generate callback
function + dictionary unions (whatwg/webidl#1353).

This does not implement any of the prototype methods on Observable,
(other than subscribe) such as `takeUntil`, `filter`, `finally` and so
on.

* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-constructor.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-constructor.window-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-takeUntil.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-takeUntil.any.worker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-takeUntil.window-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-toArray.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-toArray.any.worker-expected.txt:
* Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml:
* Source/WebCore/CMakeLists.txt:
* Source/WebCore/DerivedSources-input.xcfilelist:
* Source/WebCore/DerivedSources-output.xcfilelist:
* Source/WebCore/DerivedSources.make:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/bindings/IDLTypes.h:
* Source/WebCore/bindings/js/JSDOMConvertUnion.h:
* Source/WebCore/bindings/js/JSSubscriberCustom.cpp: Added.
(WebCore::JSSubscriber::visitAdditionalChildren):
* Source/WebCore/bindings/js/WebCoreBuiltinNames.h:
* Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:
(AreTypesDistinguishableForOverloadResolution):
* Source/WebCore/bindings/scripts/test/JS/JSTestCallbackWithFunctionOrDict.cpp: Added.
(WebCore::JSTestCallbackWithFunctionOrDict::JSTestCallbackWithFunctionOrDict):
(WebCore::JSTestCallbackWithFunctionOrDict::~JSTestCallbackWithFunctionOrDict):
(WebCore::JSTestCallbackWithFunctionOrDict::handleEvent):
(WebCore::JSTestCallbackWithFunctionOrDict::visitJSFunction):
(WebCore::toJS):
* Source/WebCore/bindings/scripts/test/JS/JSTestCallbackWithFunctionOrDict.h: Added.
(WebCore::toJS):
* Source/WebCore/bindings/scripts/test/SupplementalDependencies.dep:
* Source/WebCore/bindings/scripts/test/TestCallbackOrDict.idl: Added.
* Source/WebCore/dom/Observable.cpp: Added.
(WebCore::Observable::create):
(WebCore::Observable::subscribe):
(WebCore::Observable::makeSubscriber):
(WebCore::Observable::Observable):
* Source/WebCore/dom/Observable.h: Added.
* Source/WebCore/dom/Observable.idl: Added.
* Source/WebCore/dom/SubscribeOptions.h: Added.
* Source/WebCore/dom/SubscribeOptions.idl: Added.
* Source/WebCore/dom/Subscriber.cpp: Added.
(WebCore::Subscriber::create):
(WebCore::Subscriber::Subscriber):
(WebCore::Subscriber::next):
(WebCore::Subscriber::error):
(WebCore::Subscriber::complete):
(WebCore::Subscriber::addTeardown):
(WebCore::Subscriber::close):
(WebCore::Subscriber::abort):
(WebCore::Subscriber::closeAndTeardown):
* Source/WebCore/dom/Subscriber.h: Added.
* Source/WebCore/dom/Subscriber.idl: Added.
* Source/WebCore/dom/SubscriberCallback.cpp: Added.
* Source/WebCore/dom/SubscriberCallback.h: Added.
* Source/WebCore/dom/SubscriberCallback.idl: Added.
* Source/WebCore/dom/SubscriptionObserver.h: Added.
* Source/WebCore/dom/SubscriptionObserver.idl: Added.
* Source/WebCore/dom/SubscriptionObserverCallback.h: Added.
* Source/WebCore/dom/SubscriptionObserverCallback.idl: Added.
keithamus added a commit to keithamus/WebKit that referenced this pull request Jul 14, 2024
https://bugs.webkit.org/show_bug.cgi?id=276572

Reviewed by NOBODY (OOPS!).

This implements the base `Observable` class, as well as the `subscribe`
method. In addition this adds the `Subscriber` internal class allows
Observables to be subscribed to, and some additional machinery such as
`SubscribeOptions`, `SubscriptionObserver` and so on.

This also includes a fix to IDL generation to correctly generate callback
function + dictionary unions (whatwg/webidl#1353).

This does not implement any of the prototype methods on Observable,
(other than subscribe) such as `takeUntil`, `filter`, `finally` and so
on.

* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-constructor.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-constructor.any.worker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-constructor.window-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-takeUntil.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-takeUntil.any.worker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-takeUntil.window-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-toArray.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-toArray.any.worker-expected.txt:
* Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml:
* Source/WebCore/CMakeLists.txt:
* Source/WebCore/DerivedSources-input.xcfilelist:
* Source/WebCore/DerivedSources-output.xcfilelist:
* Source/WebCore/DerivedSources.make:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/bindings/IDLTypes.h:
* Source/WebCore/bindings/js/JSDOMConvertUnion.h:
* Source/WebCore/bindings/js/JSSubscriberCustom.cpp: Added.
(WebCore::JSSubscriber::visitAdditionalChildren):
* Source/WebCore/bindings/js/WebCoreBuiltinNames.h:
* Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:
(AreTypesDistinguishableForOverloadResolution):
* Source/WebCore/bindings/scripts/test/JS/JSTestCallbackWithFunctionOrDict.cpp: Added.
(WebCore::JSTestCallbackWithFunctionOrDict::JSTestCallbackWithFunctionOrDict):
(WebCore::JSTestCallbackWithFunctionOrDict::~JSTestCallbackWithFunctionOrDict):
(WebCore::JSTestCallbackWithFunctionOrDict::handleEvent):
(WebCore::JSTestCallbackWithFunctionOrDict::visitJSFunction):
(WebCore::toJS):
* Source/WebCore/bindings/scripts/test/JS/JSTestCallbackWithFunctionOrDict.h: Added.
(WebCore::toJS):
* Source/WebCore/bindings/scripts/test/SupplementalDependencies.dep:
* Source/WebCore/bindings/scripts/test/TestCallbackOrDict.idl: Added.
* Source/WebCore/dom/Observable.cpp: Added.
(WebCore::Observable::create):
(WebCore::Observable::subscribe):
(WebCore::Observable::makeSubscriber):
(WebCore::Observable::Observable):
* Source/WebCore/dom/Observable.h: Added.
* Source/WebCore/dom/Observable.idl: Added.
* Source/WebCore/dom/SubscribeOptions.h: Added.
* Source/WebCore/dom/SubscribeOptions.idl: Added.
* Source/WebCore/dom/Subscriber.cpp: Added.
(WebCore::Subscriber::create):
(WebCore::Subscriber::Subscriber):
(WebCore::Subscriber::next):
(WebCore::Subscriber::error):
(WebCore::Subscriber::complete):
(WebCore::Subscriber::addTeardown):
(WebCore::Subscriber::close):
(WebCore::Subscriber::isInactiveDocument const):
* Source/WebCore/dom/Subscriber.h: Added.
* Source/WebCore/dom/Subscriber.idl: Added.
* Source/WebCore/dom/SubscriberCallback.h: Added.
* Source/WebCore/dom/SubscriberCallback.idl: Added.
* Source/WebCore/dom/SubscriptionObserver.h: Added.
* Source/WebCore/dom/SubscriptionObserver.idl: Added.
* Source/WebCore/dom/SubscriptionObserverCallback.h: Added.
* Source/WebCore/dom/SubscriptionObserverCallback.idl: Added.
keithamus added a commit to keithamus/WebKit that referenced this pull request Jul 14, 2024
https://bugs.webkit.org/show_bug.cgi?id=276572

Reviewed by NOBODY (OOPS!).

This implements the base `Observable` class, as well as the `subscribe`
method. In addition this adds the `Subscriber` internal class allows
Observables to be subscribed to, and some additional machinery such as
`SubscribeOptions`, `SubscriptionObserver` and so on.

This also includes a fix to IDL generation to correctly generate callback
function + dictionary unions (whatwg/webidl#1353).

This does not implement any of the prototype methods on Observable,
(other than subscribe) such as `takeUntil`, `filter`, `finally` and so
on.

* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-constructor.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-constructor.any.worker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-constructor.window-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-takeUntil.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-takeUntil.any.worker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-takeUntil.window-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-toArray.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-toArray.any.worker-expected.txt:
* Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml:
* Source/WebCore/CMakeLists.txt:
* Source/WebCore/DerivedSources-input.xcfilelist:
* Source/WebCore/DerivedSources-output.xcfilelist:
* Source/WebCore/DerivedSources.make:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/bindings/IDLTypes.h:
* Source/WebCore/bindings/js/JSDOMConvertUnion.h:
* Source/WebCore/bindings/js/JSSubscriberCustom.cpp: Added.
(WebCore::JSSubscriber::visitAdditionalChildren):
* Source/WebCore/bindings/js/WebCoreBuiltinNames.h:
* Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:
(AreTypesDistinguishableForOverloadResolution):
* Source/WebCore/bindings/scripts/test/JS/JSTestCallbackWithFunctionOrDict.cpp: Added.
(WebCore::JSTestCallbackWithFunctionOrDict::JSTestCallbackWithFunctionOrDict):
(WebCore::JSTestCallbackWithFunctionOrDict::~JSTestCallbackWithFunctionOrDict):
(WebCore::JSTestCallbackWithFunctionOrDict::handleEvent):
(WebCore::JSTestCallbackWithFunctionOrDict::visitJSFunction):
(WebCore::toJS):
* Source/WebCore/bindings/scripts/test/JS/JSTestCallbackWithFunctionOrDict.h: Added.
(WebCore::toJS):
* Source/WebCore/bindings/scripts/test/SupplementalDependencies.dep:
* Source/WebCore/bindings/scripts/test/TestCallbackOrDict.idl: Added.
* Source/WebCore/dom/Observable.cpp: Added.
(WebCore::Observable::create):
(WebCore::Observable::subscribe):
(WebCore::Observable::makeSubscriber):
(WebCore::Observable::Observable):
* Source/WebCore/dom/Observable.h: Added.
* Source/WebCore/dom/Observable.idl: Added.
* Source/WebCore/dom/SubscribeOptions.h: Added.
* Source/WebCore/dom/SubscribeOptions.idl: Added.
* Source/WebCore/dom/Subscriber.cpp: Added.
(WebCore::Subscriber::create):
(WebCore::Subscriber::Subscriber):
(WebCore::Subscriber::next):
(WebCore::Subscriber::error):
(WebCore::Subscriber::complete):
(WebCore::Subscriber::addTeardown):
(WebCore::Subscriber::close):
(WebCore::Subscriber::isInactiveDocument const):
* Source/WebCore/dom/Subscriber.h: Added.
* Source/WebCore/dom/Subscriber.idl: Added.
* Source/WebCore/dom/SubscriberCallback.h: Added.
* Source/WebCore/dom/SubscriberCallback.idl: Added.
* Source/WebCore/dom/SubscriptionObserver.h: Added.
* Source/WebCore/dom/SubscriptionObserver.idl: Added.
* Source/WebCore/dom/SubscriptionObserverCallback.h: Added.
* Source/WebCore/dom/SubscriptionObserverCallback.idl: Added.
keithamus added a commit to keithamus/WebKit that referenced this pull request Jul 14, 2024
https://bugs.webkit.org/show_bug.cgi?id=276572

Reviewed by NOBODY (OOPS!).

This implements the base `Observable` class, as well as the `subscribe`
method. In addition this adds the `Subscriber` internal class allows
Observables to be subscribed to, and some additional machinery such as
`SubscribeOptions`, `SubscriptionObserver` and so on.

This also includes a fix to IDL generation to correctly generate callback
function + dictionary unions (whatwg/webidl#1353).

This does not implement any of the prototype methods on Observable,
(other than subscribe) such as `takeUntil`, `filter`, `finally` and so
on.

* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-constructor.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-constructor.any.worker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-constructor.window-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-takeUntil.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-takeUntil.any.worker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-takeUntil.window-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-toArray.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-toArray.any.worker-expected.txt:
* Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml:
* Source/WebCore/CMakeLists.txt:
* Source/WebCore/DerivedSources-input.xcfilelist:
* Source/WebCore/DerivedSources-output.xcfilelist:
* Source/WebCore/DerivedSources.make:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/bindings/IDLTypes.h:
* Source/WebCore/bindings/js/JSDOMConvertUnion.h:
* Source/WebCore/bindings/js/JSSubscriberCustom.cpp: Added.
(WebCore::JSSubscriber::visitAdditionalChildren):
* Source/WebCore/bindings/js/WebCoreBuiltinNames.h:
* Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:
(AreTypesDistinguishableForOverloadResolution):
* Source/WebCore/bindings/scripts/test/JS/JSTestCallbackWithFunctionOrDict.cpp: Added.
(WebCore::JSTestCallbackWithFunctionOrDict::JSTestCallbackWithFunctionOrDict):
(WebCore::JSTestCallbackWithFunctionOrDict::~JSTestCallbackWithFunctionOrDict):
(WebCore::JSTestCallbackWithFunctionOrDict::handleEvent):
(WebCore::JSTestCallbackWithFunctionOrDict::visitJSFunction):
(WebCore::toJS):
* Source/WebCore/bindings/scripts/test/JS/JSTestCallbackWithFunctionOrDict.h: Added.
(WebCore::toJS):
* Source/WebCore/bindings/scripts/test/SupplementalDependencies.dep:
* Source/WebCore/bindings/scripts/test/TestCallbackOrDict.idl: Added.
* Source/WebCore/dom/Observable.cpp: Added.
(WebCore::Observable::create):
(WebCore::Observable::subscribe):
(WebCore::Observable::makeSubscriber):
(WebCore::Observable::Observable):
* Source/WebCore/dom/Observable.h: Added.
* Source/WebCore/dom/Observable.idl: Added.
* Source/WebCore/dom/SubscribeOptions.h: Added.
* Source/WebCore/dom/SubscribeOptions.idl: Added.
* Source/WebCore/dom/Subscriber.cpp: Added.
(WebCore::Subscriber::create):
(WebCore::Subscriber::Subscriber):
(WebCore::Subscriber::next):
(WebCore::Subscriber::error):
(WebCore::Subscriber::complete):
(WebCore::Subscriber::addTeardown):
(WebCore::Subscriber::followSignal):
(WebCore::Subscriber::close):
(WebCore::Subscriber::isInactiveDocument const):
* Source/WebCore/dom/Subscriber.h: Added.
* Source/WebCore/dom/Subscriber.idl: Added.
* Source/WebCore/dom/SubscriberCallback.h: Added.
* Source/WebCore/dom/SubscriberCallback.idl: Added.
* Source/WebCore/dom/SubscriptionObserver.h: Added.
* Source/WebCore/dom/SubscriptionObserver.idl: Added.
* Source/WebCore/dom/SubscriptionObserverCallback.h: Added.
* Source/WebCore/dom/SubscriptionObserverCallback.idl: Added.
keithamus added a commit to keithamus/WebKit that referenced this pull request Jul 15, 2024
https://bugs.webkit.org/show_bug.cgi?id=276572

Reviewed by NOBODY (OOPS!).

This implements the base `Observable` class, as well as the `subscribe`
method. In addition this adds the `Subscriber` internal class allows
Observables to be subscribed to, and some additional machinery such as
`SubscribeOptions`, `SubscriptionObserver` and so on.

This also includes a fix to IDL generation to correctly generate callback
function + dictionary unions (whatwg/webidl#1353).

This does not implement any of the prototype methods on Observable,
(other than subscribe) such as `takeUntil`, `filter`, `finally` and so
on.

* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-constructor.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-constructor.any.worker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-constructor.window-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-takeUntil.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-takeUntil.any.worker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-takeUntil.window-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-toArray.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-toArray.any.worker-expected.txt:
* Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml:
* Source/WebCore/CMakeLists.txt:
* Source/WebCore/DerivedSources-input.xcfilelist:
* Source/WebCore/DerivedSources-output.xcfilelist:
* Source/WebCore/DerivedSources.make:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/bindings/IDLTypes.h:
* Source/WebCore/bindings/js/JSDOMConvertUnion.h:
* Source/WebCore/bindings/js/JSSubscriberCustom.cpp: Added.
(WebCore::JSSubscriber::visitAdditionalChildren):
* Source/WebCore/bindings/js/WebCoreBuiltinNames.h:
* Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:
(AreTypesDistinguishableForOverloadResolution):
* Source/WebCore/bindings/scripts/test/JS/JSTestCallbackWithFunctionOrDict.cpp: Added.
(WebCore::JSTestCallbackWithFunctionOrDict::JSTestCallbackWithFunctionOrDict):
(WebCore::JSTestCallbackWithFunctionOrDict::~JSTestCallbackWithFunctionOrDict):
(WebCore::JSTestCallbackWithFunctionOrDict::handleEvent):
(WebCore::JSTestCallbackWithFunctionOrDict::visitJSFunction):
(WebCore::toJS):
* Source/WebCore/bindings/scripts/test/JS/JSTestCallbackWithFunctionOrDict.h: Added.
(WebCore::toJS):
* Source/WebCore/bindings/scripts/test/SupplementalDependencies.dep:
* Source/WebCore/bindings/scripts/test/TestCallbackOrDict.idl: Added.
* Source/WebCore/dom/Observable.cpp: Added.
(WebCore::Observable::create):
(WebCore::Observable::subscribe):
(WebCore::Observable::makeSubscriber):
(WebCore::Observable::Observable):
* Source/WebCore/dom/Observable.h: Added.
* Source/WebCore/dom/Observable.idl: Added.
* Source/WebCore/dom/SubscribeOptions.h: Added.
* Source/WebCore/dom/SubscribeOptions.idl: Added.
* Source/WebCore/dom/Subscriber.cpp: Added.
(WebCore::Subscriber::create):
(WebCore::Subscriber::Subscriber):
(WebCore::Subscriber::next):
(WebCore::Subscriber::error):
(WebCore::Subscriber::complete):
(WebCore::Subscriber::addTeardown):
(WebCore::Subscriber::followSignal):
(WebCore::Subscriber::close):
(WebCore::Subscriber::isInactiveDocument const):
* Source/WebCore/dom/Subscriber.h: Added.
* Source/WebCore/dom/Subscriber.idl: Added.
* Source/WebCore/dom/SubscriberCallback.h: Added.
* Source/WebCore/dom/SubscriberCallback.idl: Added.
* Source/WebCore/dom/SubscriptionObserver.h: Added.
* Source/WebCore/dom/SubscriptionObserver.idl: Added.
* Source/WebCore/dom/SubscriptionObserverCallback.h: Added.
* Source/WebCore/dom/SubscriptionObserverCallback.idl: Added.
keithamus added a commit to keithamus/WebKit that referenced this pull request Jul 15, 2024
https://bugs.webkit.org/show_bug.cgi?id=276572

Reviewed by NOBODY (OOPS!).

This implements the base `Observable` class, as well as the `subscribe`
method. In addition this adds the `Subscriber` internal class allows
Observables to be subscribed to, and some additional machinery such as
`SubscribeOptions`, `SubscriptionObserver` and so on.

This also includes a fix to IDL generation to correctly generate callback
function + dictionary unions (whatwg/webidl#1353).

This does not implement any of the prototype methods on Observable,
(other than subscribe) such as `takeUntil`, `filter`, `finally` and so
on.

* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-constructor.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-constructor.any.worker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-constructor.window-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-takeUntil.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-takeUntil.any.worker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-takeUntil.window-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-toArray.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-toArray.any.worker-expected.txt:
* Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml:
* Source/WebCore/CMakeLists.txt:
* Source/WebCore/DerivedSources-input.xcfilelist:
* Source/WebCore/DerivedSources-output.xcfilelist:
* Source/WebCore/DerivedSources.make:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/bindings/IDLTypes.h:
* Source/WebCore/bindings/js/JSDOMConvertUnion.h:
* Source/WebCore/bindings/js/JSSubscriberCustom.cpp: Added.
(WebCore::JSSubscriber::visitAdditionalChildren):
* Source/WebCore/bindings/js/WebCoreBuiltinNames.h:
* Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:
(AreTypesDistinguishableForOverloadResolution):
* Source/WebCore/bindings/scripts/test/JS/JSTestCallbackWithFunctionOrDict.cpp: Added.
(WebCore::JSTestCallbackWithFunctionOrDict::JSTestCallbackWithFunctionOrDict):
(WebCore::JSTestCallbackWithFunctionOrDict::~JSTestCallbackWithFunctionOrDict):
(WebCore::JSTestCallbackWithFunctionOrDict::handleEvent):
(WebCore::JSTestCallbackWithFunctionOrDict::visitJSFunction):
(WebCore::toJS):
* Source/WebCore/bindings/scripts/test/JS/JSTestCallbackWithFunctionOrDict.h: Added.
(WebCore::toJS):
* Source/WebCore/bindings/scripts/test/SupplementalDependencies.dep:
* Source/WebCore/bindings/scripts/test/TestCallbackOrDict.idl: Added.
* Source/WebCore/dom/Observable.cpp: Added.
(WebCore::Observable::create):
(WebCore::Observable::subscribe):
(WebCore::Observable::makeSubscriber):
(WebCore::Observable::Observable):
* Source/WebCore/dom/Observable.h: Added.
* Source/WebCore/dom/Observable.idl: Added.
* Source/WebCore/dom/SubscribeOptions.h: Added.
* Source/WebCore/dom/SubscribeOptions.idl: Added.
* Source/WebCore/dom/Subscriber.cpp: Added.
(WebCore::Subscriber::create):
(WebCore::Subscriber::Subscriber):
(WebCore::Subscriber::next):
(WebCore::Subscriber::error):
(WebCore::Subscriber::complete):
(WebCore::Subscriber::addTeardown):
(WebCore::Subscriber::followSignal):
(WebCore::Subscriber::close):
(WebCore::Subscriber::isInactiveDocument const):
* Source/WebCore/dom/Subscriber.h: Added.
* Source/WebCore/dom/Subscriber.idl: Added.
* Source/WebCore/dom/SubscriberCallback.h: Added.
* Source/WebCore/dom/SubscriberCallback.idl: Added.
* Source/WebCore/dom/SubscriptionObserver.h: Added.
* Source/WebCore/dom/SubscriptionObserver.idl: Added.
* Source/WebCore/dom/SubscriptionObserverCallback.h: Added.
* Source/WebCore/dom/SubscriptionObserverCallback.idl: Added.
keithamus added a commit to keithamus/WebKit that referenced this pull request Jul 15, 2024
https://bugs.webkit.org/show_bug.cgi?id=276572

Reviewed by NOBODY (OOPS!).

This implements the base `Observable` class, as well as the `subscribe`
method. In addition this adds the `Subscriber` internal class allows
Observables to be subscribed to, and some additional machinery such as
`SubscribeOptions`, `SubscriptionObserver` and so on.

This also includes a fix to IDL generation to correctly generate callback
function + dictionary unions (whatwg/webidl#1353).

This does not implement any of the prototype methods on Observable,
(other than subscribe) such as `takeUntil`, `filter`, `finally` and so
on.

* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-constructor.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-constructor.any.worker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-constructor.window-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-takeUntil.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-takeUntil.any.worker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-takeUntil.window-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-toArray.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-toArray.any.worker-expected.txt:
* Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml:
* Source/WebCore/CMakeLists.txt:
* Source/WebCore/DerivedSources-input.xcfilelist:
* Source/WebCore/DerivedSources-output.xcfilelist:
* Source/WebCore/DerivedSources.make:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/bindings/IDLTypes.h:
* Source/WebCore/bindings/js/JSDOMConvertUnion.h:
* Source/WebCore/bindings/js/JSSubscriberCustom.cpp: Added.
(WebCore::JSSubscriber::visitAdditionalChildren):
* Source/WebCore/bindings/js/WebCoreBuiltinNames.h:
* Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:
(AreTypesDistinguishableForOverloadResolution):
* Source/WebCore/bindings/scripts/test/JS/JSTestCallbackWithFunctionOrDict.cpp: Added.
(WebCore::JSTestCallbackWithFunctionOrDict::JSTestCallbackWithFunctionOrDict):
(WebCore::JSTestCallbackWithFunctionOrDict::~JSTestCallbackWithFunctionOrDict):
(WebCore::JSTestCallbackWithFunctionOrDict::handleEvent):
(WebCore::JSTestCallbackWithFunctionOrDict::visitJSFunction):
(WebCore::toJS):
* Source/WebCore/bindings/scripts/test/JS/JSTestCallbackWithFunctionOrDict.h: Added.
(WebCore::toJS):
* Source/WebCore/bindings/scripts/test/SupplementalDependencies.dep:
* Source/WebCore/bindings/scripts/test/TestCallbackOrDict.idl: Added.
* Source/WebCore/dom/Observable.cpp: Added.
(WebCore::Observable::create):
(WebCore::Observable::subscribe):
(WebCore::Observable::makeSubscriber):
(WebCore::Observable::Observable):
* Source/WebCore/dom/Observable.h: Added.
* Source/WebCore/dom/Observable.idl: Added.
* Source/WebCore/dom/SubscribeOptions.h: Added.
* Source/WebCore/dom/SubscribeOptions.idl: Added.
* Source/WebCore/dom/Subscriber.cpp: Added.
(WebCore::Subscriber::create):
(WebCore::Subscriber::Subscriber):
(WebCore::Subscriber::next):
(WebCore::Subscriber::error):
(WebCore::Subscriber::complete):
(WebCore::Subscriber::addTeardown):
(WebCore::Subscriber::followSignal):
(WebCore::Subscriber::close):
(WebCore::Subscriber::isInactiveDocument const):
* Source/WebCore/dom/Subscriber.h: Added.
* Source/WebCore/dom/Subscriber.idl: Added.
* Source/WebCore/dom/SubscriberCallback.h: Added.
* Source/WebCore/dom/SubscriberCallback.idl: Added.
* Source/WebCore/dom/SubscriptionObserver.h: Added.
* Source/WebCore/dom/SubscriptionObserver.idl: Added.
* Source/WebCore/dom/SubscriptionObserverCallback.h: Added.
* Source/WebCore/dom/SubscriptionObserverCallback.idl: Added.
keithamus added a commit to keithamus/WebKit that referenced this pull request Jul 16, 2024
https://bugs.webkit.org/show_bug.cgi?id=276572

Reviewed by NOBODY (OOPS!).

This implements the base `Observable` class, as well as the `subscribe`
method. In addition this adds the `Subscriber` internal class allows
Observables to be subscribed to, and some additional machinery such as
`SubscribeOptions`, `SubscriptionObserver` and so on.

This also includes a fix to IDL generation to correctly generate callback
function + dictionary unions (whatwg/webidl#1353).

This does not implement any of the prototype methods on Observable,
(other than subscribe) such as `takeUntil`, `filter`, `finally` and so
on.

* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-constructor.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-constructor.any.worker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-constructor.window-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-takeUntil.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-takeUntil.any.worker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-takeUntil.window-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-toArray.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-toArray.any.worker-expected.txt:
* Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml:
* Source/WebCore/CMakeLists.txt:
* Source/WebCore/DerivedSources-input.xcfilelist:
* Source/WebCore/DerivedSources-output.xcfilelist:
* Source/WebCore/DerivedSources.make:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/bindings/IDLTypes.h:
* Source/WebCore/bindings/js/JSDOMConvertUnion.h:
* Source/WebCore/bindings/js/JSSubscriberCustom.cpp: Added.
(WebCore::JSSubscriber::visitAdditionalChildren):
* Source/WebCore/bindings/js/WebCoreBuiltinNames.h:
* Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:
(AreTypesDistinguishableForOverloadResolution):
* Source/WebCore/bindings/scripts/test/JS/JSTestCallbackWithFunctionOrDict.cpp: Added.
(WebCore::JSTestCallbackWithFunctionOrDict::JSTestCallbackWithFunctionOrDict):
(WebCore::JSTestCallbackWithFunctionOrDict::~JSTestCallbackWithFunctionOrDict):
(WebCore::JSTestCallbackWithFunctionOrDict::handleEvent):
(WebCore::JSTestCallbackWithFunctionOrDict::visitJSFunction):
(WebCore::toJS):
* Source/WebCore/bindings/scripts/test/JS/JSTestCallbackWithFunctionOrDict.h: Added.
(WebCore::toJS):
* Source/WebCore/bindings/scripts/test/SupplementalDependencies.dep:
* Source/WebCore/bindings/scripts/test/TestCallbackOrDict.idl: Added.
* Source/WebCore/dom/Observable.cpp: Added.
(WebCore::Observable::create):
(WebCore::Observable::subscribe):
(WebCore::Observable::makeSubscriber):
(WebCore::Observable::Observable):
* Source/WebCore/dom/Observable.h: Added.
* Source/WebCore/dom/Observable.idl: Added.
* Source/WebCore/dom/SubscribeOptions.h: Added.
* Source/WebCore/dom/SubscribeOptions.idl: Added.
* Source/WebCore/dom/Subscriber.cpp: Added.
(WebCore::Subscriber::create):
(WebCore::Subscriber::Subscriber):
(WebCore::Subscriber::next):
(WebCore::Subscriber::error):
(WebCore::Subscriber::complete):
(WebCore::Subscriber::addTeardown):
(WebCore::Subscriber::followSignal):
(WebCore::Subscriber::close):
(WebCore::Subscriber::isInactiveDocument const):
(WebCore::Subscriber::reportErrorObject):
* Source/WebCore/dom/Subscriber.h: Added.
* Source/WebCore/dom/Subscriber.idl: Added.
* Source/WebCore/dom/SubscriberCallback.h: Added.
* Source/WebCore/dom/SubscriberCallback.idl: Added.
* Source/WebCore/dom/SubscriptionObserver.h: Added.
* Source/WebCore/dom/SubscriptionObserver.idl: Added.
* Source/WebCore/dom/SubscriptionObserverCallback.h: Added.
* Source/WebCore/dom/SubscriptionObserverCallback.idl: Added.
keithamus added a commit to keithamus/WebKit that referenced this pull request Jul 16, 2024
https://bugs.webkit.org/show_bug.cgi?id=276572

Reviewed by NOBODY (OOPS!).

This implements the base `Observable` class, as well as the `subscribe`
method. In addition this adds the `Subscriber` internal class allows
Observables to be subscribed to, and some additional machinery such as
`SubscribeOptions`, `SubscriptionObserver` and so on.

This also includes a fix to IDL generation to correctly generate callback
function + dictionary unions (whatwg/webidl#1353).

This does not implement any of the prototype methods on Observable,
(other than subscribe) such as `takeUntil`, `filter`, `finally` and so
on.

* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-constructor.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-constructor.any.worker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-constructor.window-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-takeUntil.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-takeUntil.any.worker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-takeUntil.window-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-toArray.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-toArray.any.worker-expected.txt:
* Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml:
* Source/WebCore/CMakeLists.txt:
* Source/WebCore/DerivedSources-input.xcfilelist:
* Source/WebCore/DerivedSources-output.xcfilelist:
* Source/WebCore/DerivedSources.make:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/bindings/IDLTypes.h:
* Source/WebCore/bindings/js/JSDOMConvertUnion.h:
* Source/WebCore/bindings/js/JSSubscriberCustom.cpp: Added.
(WebCore::JSSubscriber::visitAdditionalChildren):
* Source/WebCore/bindings/js/WebCoreBuiltinNames.h:
* Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:
(AreTypesDistinguishableForOverloadResolution):
* Source/WebCore/bindings/scripts/test/JS/JSTestCallbackWithFunctionOrDict.cpp: Added.
(WebCore::JSTestCallbackWithFunctionOrDict::JSTestCallbackWithFunctionOrDict):
(WebCore::JSTestCallbackWithFunctionOrDict::~JSTestCallbackWithFunctionOrDict):
(WebCore::JSTestCallbackWithFunctionOrDict::handleEvent):
(WebCore::JSTestCallbackWithFunctionOrDict::visitJSFunction):
(WebCore::toJS):
* Source/WebCore/bindings/scripts/test/JS/JSTestCallbackWithFunctionOrDict.h: Added.
(WebCore::toJS):
* Source/WebCore/bindings/scripts/test/SupplementalDependencies.dep:
* Source/WebCore/bindings/scripts/test/TestCallbackOrDict.idl: Added.
* Source/WebCore/dom/Observable.cpp: Added.
(WebCore::Observable::create):
(WebCore::Observable::subscribe):
(WebCore::Observable::makeSubscriber):
(WebCore::Observable::Observable):
* Source/WebCore/dom/Observable.h: Added.
* Source/WebCore/dom/Observable.idl: Added.
* Source/WebCore/dom/SubscribeOptions.h: Added.
* Source/WebCore/dom/SubscribeOptions.idl: Added.
* Source/WebCore/dom/Subscriber.cpp: Added.
(WebCore::Subscriber::create):
(WebCore::Subscriber::Subscriber):
(WebCore::Subscriber::next):
(WebCore::Subscriber::error):
(WebCore::Subscriber::complete):
(WebCore::Subscriber::addTeardown):
(WebCore::Subscriber::followSignal):
(WebCore::Subscriber::close):
(WebCore::Subscriber::isInactiveDocument const):
(WebCore::Subscriber::reportErrorObject):
* Source/WebCore/dom/Subscriber.h: Added.
* Source/WebCore/dom/Subscriber.idl: Added.
* Source/WebCore/dom/SubscriberCallback.h: Added.
* Source/WebCore/dom/SubscriberCallback.idl: Added.
* Source/WebCore/dom/SubscriptionObserver.h: Added.
* Source/WebCore/dom/SubscriptionObserver.idl: Added.
* Source/WebCore/dom/SubscriptionObserverCallback.h: Added.
* Source/WebCore/dom/SubscriptionObserverCallback.idl: Added.
webkit-commit-queue pushed a commit to keithamus/WebKit that referenced this pull request Jul 17, 2024
https://bugs.webkit.org/show_bug.cgi?id=276572

Reviewed by Ryan Reno.

This implements the base `Observable` class, as well as the `subscribe`
method. In addition this adds the `Subscriber` internal class allows
Observables to be subscribed to, and some additional machinery such as
`SubscribeOptions`, `SubscriptionObserver` and so on.

This also includes a fix to IDL generation to correctly generate callback
function + dictionary unions (whatwg/webidl#1353).

This does not implement any of the prototype methods on Observable,
(other than subscribe) such as `takeUntil`, `filter`, `finally` and so
on.

* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-constructor.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-constructor.any.worker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-constructor.window-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-takeUntil.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-takeUntil.any.worker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-takeUntil.window-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-toArray.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/dom/observable/tentative/observable-toArray.any.worker-expected.txt:
* Source/WTF/Scripts/Preferences/UnifiedWebPreferences.yaml:
* Source/WebCore/CMakeLists.txt:
* Source/WebCore/DerivedSources-input.xcfilelist:
* Source/WebCore/DerivedSources-output.xcfilelist:
* Source/WebCore/DerivedSources.make:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/bindings/IDLTypes.h:
* Source/WebCore/bindings/js/JSDOMConvertUnion.h:
* Source/WebCore/bindings/js/JSSubscriberCustom.cpp: Added.
(WebCore::JSSubscriber::visitAdditionalChildren):
* Source/WebCore/bindings/js/WebCoreBuiltinNames.h:
* Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:
(AreTypesDistinguishableForOverloadResolution):
* Source/WebCore/bindings/scripts/test/JS/JSTestCallbackWithFunctionOrDict.cpp: Added.
(WebCore::JSTestCallbackWithFunctionOrDict::JSTestCallbackWithFunctionOrDict):
(WebCore::JSTestCallbackWithFunctionOrDict::~JSTestCallbackWithFunctionOrDict):
(WebCore::JSTestCallbackWithFunctionOrDict::handleEvent):
(WebCore::JSTestCallbackWithFunctionOrDict::visitJSFunction):
(WebCore::toJS):
* Source/WebCore/bindings/scripts/test/JS/JSTestCallbackWithFunctionOrDict.h: Added.
(WebCore::toJS):
* Source/WebCore/bindings/scripts/test/SupplementalDependencies.dep:
* Source/WebCore/bindings/scripts/test/TestCallbackOrDict.idl: Added.
* Source/WebCore/dom/Observable.cpp: Added.
(WebCore::Observable::create):
(WebCore::Observable::subscribe):
(WebCore::Observable::makeSubscriber):
(WebCore::Observable::Observable):
* Source/WebCore/dom/Observable.h: Added.
* Source/WebCore/dom/Observable.idl: Added.
* Source/WebCore/dom/SubscribeOptions.h: Added.
* Source/WebCore/dom/SubscribeOptions.idl: Added.
* Source/WebCore/dom/Subscriber.cpp: Added.
(WebCore::Subscriber::create):
(WebCore::Subscriber::Subscriber):
(WebCore::Subscriber::next):
(WebCore::Subscriber::error):
(WebCore::Subscriber::complete):
(WebCore::Subscriber::addTeardown):
(WebCore::Subscriber::followSignal):
(WebCore::Subscriber::close):
(WebCore::Subscriber::isInactiveDocument const):
(WebCore::Subscriber::reportErrorObject):
* Source/WebCore/dom/Subscriber.h: Added.
* Source/WebCore/dom/Subscriber.idl: Added.
* Source/WebCore/dom/SubscriberCallback.h: Added.
* Source/WebCore/dom/SubscriberCallback.idl: Added.
* Source/WebCore/dom/SubscriptionObserver.h: Added.
* Source/WebCore/dom/SubscriptionObserver.idl: Added.
* Source/WebCore/dom/SubscriptionObserverCallback.h: Added.
* Source/WebCore/dom/SubscriptionObserverCallback.idl: Added.

Canonical link: https://commits.webkit.org/281040@main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Allow dictionaries and callbacks to be distinguishable
9 participants