Introduce GlobalScope::api_base_url

This commit is contained in:
Anthony Ramine 2016-10-02 01:15:12 +02:00
parent cb02d7911a
commit 3302a53d38
5 changed files with 26 additions and 18 deletions

View file

@ -7,7 +7,6 @@
//! This module contains smart pointers to global scopes, to simplify writing
//! code that works in workers as well as window scopes.
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
use dom::bindings::conversions::root_from_object;
use dom::bindings::error::{ErrorInfo, report_pending_exception};
use dom::bindings::inheritance::Castable;
@ -100,17 +99,6 @@ impl<'a> GlobalRef<'a> {
}
}
/// Get the [base url](https://html.spec.whatwg.org/multipage/#api-base-url)
/// for this global scope.
pub fn api_base_url(&self) -> Url {
match *self {
// https://html.spec.whatwg.org/multipage/#script-settings-for-browsing-contexts:api-base-url
GlobalRef::Window(ref window) => window.Document().base_url(),
// https://html.spec.whatwg.org/multipage/#script-settings-for-workers:api-base-url
GlobalRef::Worker(ref worker) => worker.get_url().clone(),
}
}
/// `ScriptChan` used to send messages to the event loop of this global's
/// thread.
pub fn script_chan(&self) -> Box<ScriptChan + Send> {