mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Make stylesheets block page load.
This commit is contained in:
parent
7f0706ed42
commit
32a89c9455
10 changed files with 106 additions and 30 deletions
|
@ -72,7 +72,7 @@ use msg::constellation_msg::{ConstellationChan, FocusType, Key, KeyState, KeyMod
|
|||
use msg::constellation_msg::{SUPER, ALT, SHIFT, CONTROL};
|
||||
use net_traits::CookieSource::NonHTTP;
|
||||
use net_traits::ControlMsg::{SetCookiesForUrl, GetCookiesForUrl};
|
||||
use net_traits::{Metadata, LoadResponse};
|
||||
use net_traits::{Metadata, LoadResponse, PendingAsyncLoad};
|
||||
use script_task::Runnable;
|
||||
use script_traits::{MouseButton, UntrustedNodeAddress};
|
||||
use util::opts;
|
||||
|
@ -260,6 +260,7 @@ pub trait DocumentHelpers<'a> {
|
|||
fn cancel_animation_frame(self, ident: i32);
|
||||
/// http://w3c.github.io/animation-timing/#dfn-invoke-callbacks-algorithm
|
||||
fn invoke_animation_callbacks(self);
|
||||
fn prep_async_load(self, load: LoadType) -> PendingAsyncLoad;
|
||||
fn load_async(self, load: LoadType) -> Receiver<LoadResponse>;
|
||||
fn load_sync(self, load: LoadType) -> Result<(Metadata, Vec<u8>), String>;
|
||||
fn finish_load(self, load: LoadType);
|
||||
|
@ -884,6 +885,11 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
|
|||
}
|
||||
}
|
||||
|
||||
fn prep_async_load(self, load: LoadType) -> PendingAsyncLoad {
|
||||
let mut loader = self.loader.borrow_mut();
|
||||
loader.prep_async_load(load)
|
||||
}
|
||||
|
||||
fn load_async(self, load: LoadType) -> Receiver<LoadResponse> {
|
||||
let mut loader = self.loader.borrow_mut();
|
||||
loader.load_async(load)
|
||||
|
|
|
@ -2,15 +2,17 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use document_loader::LoadType;
|
||||
use dom::attr::{Attr, AttrValue};
|
||||
use dom::attr::AttrHelpers;
|
||||
use dom::bindings::codegen::Bindings::HTMLLinkElementBinding;
|
||||
use dom::bindings::codegen::Bindings::HTMLLinkElementBinding::HTMLLinkElementMethods;
|
||||
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||
use dom::bindings::codegen::InheritTypes::HTMLLinkElementDerived;
|
||||
use dom::bindings::codegen::InheritTypes::{ElementCast, HTMLElementCast, NodeCast};
|
||||
use dom::bindings::js::{JS, JSRef, MutNullableHeap, Rootable, Temporary};
|
||||
use dom::bindings::js::{OptionalRootable, RootedReference};
|
||||
use dom::document::Document;
|
||||
use dom::document::{Document, DocumentHelpers};
|
||||
use dom::domtokenlist::DOMTokenList;
|
||||
use dom::element::{AttributeHandlers, Element};
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
|
@ -149,8 +151,10 @@ impl<'a> PrivateHTMLLinkElementHelpers for JSRef<'a, HTMLLinkElement> {
|
|||
let mut css_parser = CssParser::new(&mq_str);
|
||||
let media = parse_media_query_list(&mut css_parser);
|
||||
|
||||
let doc = window.Document().root();
|
||||
let pending = doc.r().prep_async_load(LoadType::Stylesheet(url.clone()));
|
||||
let LayoutChan(ref layout_chan) = window.layout_chan();
|
||||
layout_chan.send(Msg::LoadStylesheet(url, media)).unwrap();
|
||||
layout_chan.send(Msg::LoadStylesheet(url, media, pending)).unwrap();
|
||||
}
|
||||
Err(e) => debug!("Parsing url {} failed: {}", href, e)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue