This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
spec:async-algos [2014/05/27 18:19] – [Making Author-Observable Changes to Page State] tabatkins | spec:async-algos [2014/05/28 12:25] – [Writing the Algo] tabatkins | ||
---|---|---|---|
Line 25: | Line 25: | ||
> | > | ||
> 6. Otherwise, font face now represents the loaded font; fulfill font face’s %%[[FontStatusPromise]] with font face and set font face’s status attribute to " | > 6. Otherwise, font face now represents the loaded font; fulfill font face’s %%[[FontStatusPromise]] with font face and set font face’s status attribute to " | ||
+ | |||
+ | **Important Note: The above code is slightly broken for simplicity. | ||
Note how Step 3 is clearly the last synchronous step. If possible, use that exact wording: " | Note how Step 3 is clearly the last synchronous step. If possible, use that exact wording: " | ||
Line 38: | Line 40: | ||
Be careful about making any change to the state of the document within the asynchronous portion of the algorithm. | Be careful about making any change to the state of the document within the asynchronous portion of the algorithm. | ||
- | If you do make any changes, [something about queueing | + | The correct way to make an observable change is in a synchronous block that is explicitly put on a task queue. |
+ | |||
+ | > When the load() method is called, execute these steps: | ||
+ | > | ||
+ | > 1. Let font face be the FontFace object on which this method was called. | ||
+ | > | ||
+ | > 2. If font face’s %%[[Urls]] slot is null, or its status attribute is anything other than " | ||
+ | > | ||
+ | > 3. Otherwise, set font face’s status attribute to " | ||
+ | > | ||
+ | > 4. Using the value of font face’s %%[[Urls]] slot, attempt to load a font as defined in [CSS3-FONTS], | ||
+ | > | ||
+ | > 5. Once the attempt to load either completes with either success or failure, await a stable state, then synchronously execute the following steps: | ||
+ | > | ||
+ | > a. If the attempt to load failed, set font face's status attribute to " | ||
+ | > b. Otherwise, set font face's status attribute to " | ||
+ | |||
+ | The "await a stable state" language ensures that author code has reached a point where other code can run, and that nothing else is in the queue to be run. This ensures that, for example, the promise' | ||
+ | |||
+ | If there is further asynchronous work to be done, explicitly state " | ||
- | Note that fulfilling a promise is not author-observable; they can' | + | Note that fulfilling a promise is not author-observable, because the state of a promise isn' |