diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2015-11-08 01:11:54 +0530 |
---|---|---|
committer | bors-servo <lbergstrom+bors@mozilla.com> | 2015-11-08 01:11:54 +0530 |
commit | 7ff3a17524e0e703e3ac279441729c185444be24 (patch) | |
tree | e5d9a990b55991cc4fea7c3806894cf34a81d9be /components/script/script_task.rs | |
parent | 9a465c58429547b59b8a6e1258eaaea46bf7e5a2 (diff) | |
parent | 543703e3d8d7dde5efd280fb01e42061287c7002 (diff) | |
download | servo-7ff3a17524e0e703e3ac279441729c185444be24.tar.gz servo-7ff3a17524e0e703e3ac279441729c185444be24.zip |
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 -->
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 fcf29605b80..f9919637457 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 |