Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Issue 153813002: Support "await a stable state" and "provide a stable state" (Closed)

Created:
6 years, 10 months ago by philipj_slow
Modified:
6 years, 8 months ago
CC:
blink-reviews, dglazkov+blink, adamk+blink_chromium.org, acolwell GONE FROM CHROMIUM, cbiesinger
Visibility:
Public.

Description

Support "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 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+227 lines, -4 lines) Patch
M Source/core/core.gypi View 1 2 3 4 5 6 2 chunks +3 lines, -0 lines 0 comments Download
A Source/core/html/StableState.h View 1 2 3 4 5 1 chunk +38 lines, -0 lines 0 comments Download
A Source/core/html/StableState.cpp View 1 2 3 4 5 6 7 1 chunk +67 lines, -0 lines 0 comments Download
A Source/core/html/StableStateTest.cpp View 1 2 3 4 5 6 7 1 chunk +110 lines, -0 lines 0 comments Download
M Source/core/html/parser/HTMLScriptRunner.cpp View 1 2 3 4 5 6 2 chunks +6 lines, -3 lines 0 comments Download
M Source/web/WebKit.cpp View 1 2 3 4 5 2 chunks +3 lines, -1 line 0 comments Download

Messages

Total messages: 24 (0 generated)
philipj_slow
Depends on https://codereview.chromium.org/153813002 so no trybots. I looked at a bunch of different approaches before ...
6 years, 10 months ago (2014-02-04 13:43:01 UTC) #1
philipj_slow
https://codereview.chromium.org/153813002/diff/1/Source/core/html/StableState.h File Source/core/html/StableState.h (right): https://codereview.chromium.org/153813002/diff/1/Source/core/html/StableState.h#newcode19 Source/core/html/StableState.h:19: void awaitStableState(); I put this here to make the ...
6 years, 10 months ago (2014-02-04 13:45:46 UTC) #2
philipj_slow
https://codereview.chromium.org/153813002/diff/1/Source/core/html/StableState.h File Source/core/html/StableState.h (right): https://codereview.chromium.org/153813002/diff/1/Source/core/html/StableState.h#newcode19 Source/core/html/StableState.h:19: void awaitStableState(); On 2014/02/04 13:45:46, philipj wrote: > I ...
6 years, 10 months ago (2014-02-04 15:10:48 UTC) #3
philipj_slow
Another "provide a stable state" was added to the spec in response to my feedback: ...
6 years, 10 months ago (2014-02-05 03:53:18 UTC) #4
philipj_slow
PTAL. I've massaged the implementation to my liking and written some background in the commit ...
6 years, 10 months ago (2014-02-05 18:46:54 UTC) #5
tkent
I have a question. is ti possible that Code inside StableState::provide dispatches events and arbitrary ...
6 years, 10 months ago (2014-02-06 04:27:45 UTC) #6
philipj_slow
On 2014/02/06 04:27:45, tkent wrote: > I have a question. is ti possible that Code ...
6 years, 10 months ago (2014-02-06 05:20:25 UTC) #7
philipj_slow
I realized that "Calling await() inside the callback has no effect." was only true if ...
6 years, 10 months ago (2014-02-06 05:41:26 UTC) #8
philipj_slow
Aaron, you may be interested in this as well, since I intend to use it ...
6 years, 10 months ago (2014-02-07 06:50:18 UTC) #9
acolwell GONE FROM CHROMIUM
https://codereview.chromium.org/153813002/diff/170001/Source/core/html/StableState.cpp File Source/core/html/StableState.cpp (right): https://codereview.chromium.org/153813002/diff/170001/Source/core/html/StableState.cpp#newcode16 Source/core/html/StableState.cpp:16: DEFINE_STATIC_LOCAL(StableStateAwaiters, stableStateAwaiters, ()); Do we really want this process ...
6 years, 10 months ago (2014-02-07 19:09:30 UTC) #10
philipj_slow
PTAL. I'm going on a short vacation starting Wednesday, so it'd be great to have ...
6 years, 10 months ago (2014-02-09 17:10:17 UTC) #11
acolwell GONE FROM CHROMIUM
This is looking pretty good to me. You should have someone more familiar w/ the ...
6 years, 10 months ago (2014-02-10 22:36:05 UTC) #12
philipj_slow
I'm going to be gone for a few days, so I'll have to put this ...
6 years, 10 months ago (2014-02-11 17:25:21 UTC) #13
philipj_slow
OK, I'm now mostly happy with this. Please let me know if we can remove ...
6 years, 10 months ago (2014-02-17 11:59:24 UTC) #14
philipj_slow
rafaelw, would you mind taking a look at this, since you are familiar with the ...
6 years, 10 months ago (2014-02-18 10:30:54 UTC) #15
acolwell GONE FROM CHROMIUM
lgtm % nits https://codereview.chromium.org/153813002/diff/250001/Source/core/html/StableState.h File Source/core/html/StableState.h (right): https://codereview.chromium.org/153813002/diff/250001/Source/core/html/StableState.h#newcode15 Source/core/html/StableState.h:15: virtual void didAwaitStableState() = 0; On ...
6 years, 10 months ago (2014-02-18 18:47:42 UTC) #16
rafaelw
I'm trying to convince hixie that the await/provide a stable state in the spec should ...
6 years, 10 months ago (2014-02-19 01:19:43 UTC) #17
philipj_slow
https://codereview.chromium.org/153813002/diff/600001/Source/core/html/StableState.cpp File Source/core/html/StableState.cpp (right): https://codereview.chromium.org/153813002/diff/600001/Source/core/html/StableState.cpp#newcode14 Source/core/html/StableState.cpp:14: private: On 2014/02/18 18:47:43, acolwell wrote: > nit: public ...
6 years, 10 months ago (2014-02-19 04:10:56 UTC) #18
philipj_slow
On 2014/02/19 01:19:43, rafaelw wrote: > I'm trying to convince hixie that the await/provide a ...
6 years, 10 months ago (2014-02-19 04:40:59 UTC) #19
rafaelw1
On Tue, Feb 18, 2014 at 8:40 PM, <philipj@opera.com> wrote: > On 2014/02/19 01:19:43, rafaelw ...
6 years, 10 months ago (2014-02-19 05:01:13 UTC) #20
philipj_slow
On 2014/02/19 05:01:13, rafaelw1 wrote: > On Tue, Feb 18, 2014 at 8:40 PM, <mailto:philipj@opera.com> ...
6 years, 10 months ago (2014-02-19 07:17:30 UTC) #21
philipj_slow
I'm closing this until these spec bugs have been resolved: https://www.w3.org/Bugs/Public/show_bug.cgi?id=24361 https://www.w3.org/Bugs/Public/show_bug.cgi?id=24707 https://www.w3.org/Bugs/Public/show_bug.cgi?id=24724 If it ...
6 years, 10 months ago (2014-02-21 04:23:46 UTC) #22
cbiesinger
So, it turns out I'd like to use a stable state concept for https://codereview.chromium.org/200923002/ Could ...
6 years, 8 months ago (2014-04-02 22:48:18 UTC) #23
philipj_slow
6 years, 8 months ago (2014-04-03 19:36:08 UTC) #24
Message was sent while issue was closed.
On 2014/04/02 22:48:18, cbiesinger wrote:
> So, it turns out I'd like to use a stable state concept for
> https://codereview.chromium.org/200923002/
> 
> Could you summarize the current state of stable states and how this CL
relates?

As a result of this CL I filed the above linked spec bugs.
https://www.w3.org/Bugs/Public/show_bug.cgi?id=24724 is the one which is
currently blocking progress, so if you want things to move along you may need to
bribe Hixie. I think it's clear that it stable states will be defined in terms
of microtasks in some manner, but there are different ways to define it that
would have observably different results, so I was just going to wait it out.

Powered by Google App Engine
This is Rietveld 408576698