Decouple media load blockers from their resource URL

A media element can delay the document's load event without having a resource URL,
and it can even block it while being inserted into a different document AFAIK.
This commit is contained in:
Anthony Ramine 2017-09-25 12:32:48 +02:00
parent da392e3524
commit 40a72f3e83
2 changed files with 56 additions and 29 deletions

View file

@ -20,18 +20,18 @@ pub enum LoadType {
Subframe(ServoUrl),
Stylesheet(ServoUrl),
PageSource(ServoUrl),
Media(ServoUrl),
Media,
}
impl LoadType {
fn url(&self) -> &ServoUrl {
fn url(&self) -> Option<&ServoUrl> {
match *self {
LoadType::Image(ref url) |
LoadType::Script(ref url) |
LoadType::Subframe(ref url) |
LoadType::Stylesheet(ref url) |
LoadType::Media(ref url) |
LoadType::PageSource(ref url) => url,
LoadType::PageSource(ref url) => Some(url),
LoadType::Media => None,
}
}
}
@ -68,7 +68,7 @@ impl LoadBlocker {
/// Return the url associated with this load.
pub fn url(&self) -> Option<&ServoUrl> {
self.load.as_ref().map(LoadType::url)
self.load.as_ref().and_then(LoadType::url)
}
}