mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
Auto merge of #8039 - tschneidereit:script-owns-stylesheets, r=jdm
Move Stylesheet loading and ownership from the layout task into HTML elements Stylesheets for `HTMLLinkElement`s are now loaded by the resource task, triggered by the element in question. Stylesheets are owned by the elements they're associated with, which can be `HTMLStyleElement`, `HTMLLinkElement`, and `HTMLMetaElement` (for `<meta name="viewport">). Additionally, the quirks mode stylesheet (just as the user and user agent stylesheets a couple of commits ago), is implemented as a lazy static, loaded once per process and shared between all documents. This all has various nice consequences: - Stylesheet loading becomes a non-blocking operation. - Stylesheets are removed when the element they're associated with is removed from the document. - It'll be possible to implement the CSSOM APIs that require direct access to the stylesheets (i.e., ~ all of them). - Various subtle correctness issues are fixed. One piece of interesting follow-up work would be to move parsing of external stylesheets to the resource task, too. Right now, it happens in the link element once loading is complete, so blocks the script task. Moving it to the resource task would probably be fairly straight-forward as it doesn't require access to any external state. Depends on #7979 because without that loading stylesheets asynchronously breaks lots of content. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8039) <!-- Reviewable:end -->
This commit is contained in:
commit
7ff3a17524
18 changed files with 461 additions and 333 deletions
|
@ -41,7 +41,6 @@ use net_traits::storage_task::StorageTask;
|
|||
use profile_traits::mem;
|
||||
use std::any::Any;
|
||||
use std::sync::mpsc::{Receiver, Sender};
|
||||
use url::Url;
|
||||
use util::mem::HeapSizeOf;
|
||||
|
||||
/// The address of a node. Layout sends these back. They must be validated via
|
||||
|
@ -90,13 +89,6 @@ pub struct NewLayoutInfo {
|
|||
pub layout_shutdown_chan: Sender<()>,
|
||||
}
|
||||
|
||||
/// `StylesheetLoadResponder` is used to notify a responder that a style sheet
|
||||
/// has loaded.
|
||||
pub trait StylesheetLoadResponder {
|
||||
/// Respond to a loaded style sheet.
|
||||
fn respond(self: Box<Self>);
|
||||
}
|
||||
|
||||
/// Used to determine if a script has any pending asynchronous activity.
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
pub enum ScriptState {
|
||||
|
@ -141,8 +133,6 @@ pub enum ConstellationControlMsg {
|
|||
/// Notifies the script task that a new Web font has been loaded, and thus the page should be
|
||||
/// reflowed.
|
||||
WebFontLoaded(PipelineId),
|
||||
/// Notifies script that a stylesheet has finished loading.
|
||||
StylesheetLoadComplete(PipelineId, Url, Box<StylesheetLoadResponder + Send>),
|
||||
/// Get the current state of the script task for a given pipeline.
|
||||
GetCurrentState(Sender<ScriptState>, PipelineId),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue