mirror of
https://github.com/servo/servo.git
synced 2025-06-10 09:33:13 +00:00
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:
parent
da392e3524
commit
40a72f3e83
2 changed files with 56 additions and 29 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue