DescriptionSupport "await a stable state" and "provide a stable state"
http://whatwg.org/html#await-a-stable-state
http://whatwg.org/html#provide-a-stable-state
The "await a stable state" concept is used extensively in the spec for
HTMLMediaElement and also for HTMLImageElement. Most notably, it is
required to make the media resource selection algorithm work per spec.
Some instances of "provide a stable state" have been deliberately not
been implemented, pending the outcome of two spec bugs:
https://www.w3.org/Bugs/Public/show_bug.cgi?id=24361
https://www.w3.org/Bugs/Public/show_bug.cgi?id=24707
Currently there are no users of StableState::Awaiter, but it is
intended to be used in one of two ways:
1. Let the client class inherit StableState::Awaiter and receive the
callback directly. This will likely be sufficient in most cases.
2. Let a separate StableState::Awaiter subclass keep track of what
callback to invoke. This may be cleaner if there are many reasons
to "await a stable state", as no state bits need to be kept in the
client class itself. The price to pay for this is a WeakPtr or
similar to deal with the client object being deleted before a
stable state has been provided.
Other designs considered:
1. Microtask-like: A set of raw function pointers or closures. This
would require a WeakPtr to the client object even for simple uses.
2. Timer-like: A class intended to be used as a member of the client
class, that binds to a callback on that class. That member would
require memory even when not awaiting a stable state.
Note that the StableState::provide() call sites are untested as of
this commit. Testing them using a LayoutTest requires an actual user
of StableState::await(), which will be introduced shortly.
BUG=340547
Patch Set 1 #
Total comments: 2
Patch Set 2 : more static #Patch Set 3 : simplify, document, test #
Total comments: 1
Patch Set 4 : disallow await during provide #
Total comments: 8
Patch Set 5 : assert more #
Total comments: 9
Patch Set 6 : wrap state into StableStateAwaiters #Patch Set 7 : violate the spec #
Total comments: 4
Patch Set 8 : nits #
Messages
Total messages: 24 (0 generated)
|