diff options
author | Till Schneidereit <till@tillschneidereit.net> | 2015-10-06 15:55:28 +0200 |
---|---|---|
committer | Till Schneidereit <till@tillschneidereit.net> | 2015-11-07 18:11:29 +0100 |
commit | 543703e3d8d7dde5efd280fb01e42061287c7002 (patch) | |
tree | 3b36ac6d5b08f842035f7f9b2eed16b94aeb0d28 /components/script/script_task.rs | |
parent | 068e6a8e9f926fa6e8649b934ee9ffe2ef7b78de (diff) | |
download | servo-543703e3d8d7dde5efd280fb01e42061287c7002.tar.gz servo-543703e3d8d7dde5efd280fb01e42061287c7002.zip |
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.
Diffstat (limited to 'components/script/script_task.rs')
-rw-r--r-- | components/script/script_task.rs | 13 |
1 files changed, 1 insertions, 12 deletions
diff --git a/components/script/script_task.rs b/components/script/script_task.rs index dda6faaa85b..c343dd677f6 100644 --- a/components/script/script_task.rs +++ b/components/script/script_task.rs @@ -20,7 +20,7 @@ use devtools; use devtools_traits::ScriptToDevtoolsControlMsg; use devtools_traits::{DevtoolScriptControlMsg, DevtoolsPageInfo}; -use document_loader::{DocumentLoader, LoadType}; +use document_loader::DocumentLoader; use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::DocumentBinding::{DocumentMethods, DocumentReadyState}; use dom::bindings::conversions::{FromJSValConvertible, StringificationBehavior}; @@ -1001,10 +1001,6 @@ impl ScriptTask { self.handle_tick_all_animations(pipeline_id), ConstellationControlMsg::WebFontLoaded(pipeline_id) => self.handle_web_font_loaded(pipeline_id), - ConstellationControlMsg::StylesheetLoadComplete(id, url, responder) => { - responder.respond(); - self.handle_resource_loaded(id, LoadType::Stylesheet(url)); - } ConstellationControlMsg::GetCurrentState(sender, pipeline_id) => { let state = self.handle_get_current_state(pipeline_id); sender.send(state).unwrap(); @@ -1153,13 +1149,6 @@ impl ScriptTask { panic!("Page rect message sent to nonexistent pipeline"); } - /// Handle a request to load a page in a new child frame of an existing page. - fn handle_resource_loaded(&self, pipeline: PipelineId, load: LoadType) { - let page = get_page(&self.root_page(), pipeline); - let doc = page.document(); - doc.finish_load(load); - } - /// Get the current state of a given pipeline. fn handle_get_current_state(&self, pipeline_id: PipelineId) -> ScriptState { // Check if the main page load is still pending |