mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Add API base url method to global objects
This commit is contained in:
parent
32e53b80e2
commit
c75079eff3
4 changed files with 12 additions and 11 deletions
|
@ -143,6 +143,17 @@ 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> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue