mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-28 12:45:27 +00:00
servo: Merge #4845 - Moved Location object from Window to Document (from KiChjang:location-in-doc); r=jdm
Fixes #4840 Source-Repo: https://github.com/servo/servo Source-Revision: 5c02f8956d37d39f4482c570621ffa1c61a3f41c
This commit is contained in:
parent
7f6a9f9591
commit
c9aac69d6b
@ -9,7 +9,6 @@ use dom::bindings::codegen::Bindings::DocumentBinding::{DocumentMethods, Documen
|
|||||||
use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
|
use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
|
||||||
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
||||||
use dom::bindings::codegen::Bindings::NodeFilterBinding::NodeFilter;
|
use dom::bindings::codegen::Bindings::NodeFilterBinding::NodeFilter;
|
||||||
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
|
||||||
use dom::bindings::codegen::InheritTypes::{DocumentDerived, EventCast, HTMLElementCast};
|
use dom::bindings::codegen::InheritTypes::{DocumentDerived, EventCast, HTMLElementCast};
|
||||||
use dom::bindings::codegen::InheritTypes::{HTMLHeadElementCast, TextCast, ElementCast};
|
use dom::bindings::codegen::InheritTypes::{HTMLHeadElementCast, TextCast, ElementCast};
|
||||||
use dom::bindings::codegen::InheritTypes::{DocumentTypeCast, HTMLHtmlElementCast, NodeCast};
|
use dom::bindings::codegen::InheritTypes::{DocumentTypeCast, HTMLHtmlElementCast, NodeCast};
|
||||||
@ -86,6 +85,7 @@ pub struct Document {
|
|||||||
window: JS<Window>,
|
window: JS<Window>,
|
||||||
idmap: DOMRefCell<HashMap<Atom, Vec<JS<Element>>>>,
|
idmap: DOMRefCell<HashMap<Atom, Vec<JS<Element>>>>,
|
||||||
implementation: MutNullableJS<DOMImplementation>,
|
implementation: MutNullableJS<DOMImplementation>,
|
||||||
|
location: MutNullableJS<Location>,
|
||||||
content_type: DOMString,
|
content_type: DOMString,
|
||||||
last_modified: DOMRefCell<Option<DOMString>>,
|
last_modified: DOMRefCell<Option<DOMString>>,
|
||||||
encoding_name: DOMRefCell<DOMString>,
|
encoding_name: DOMRefCell<DOMString>,
|
||||||
@ -425,6 +425,7 @@ impl Document {
|
|||||||
window: JS::from_rooted(window),
|
window: JS::from_rooted(window),
|
||||||
idmap: DOMRefCell::new(HashMap::new()),
|
idmap: DOMRefCell::new(HashMap::new()),
|
||||||
implementation: Default::default(),
|
implementation: Default::default(),
|
||||||
|
location: Default::default(),
|
||||||
content_type: match content_type {
|
content_type: match content_type {
|
||||||
Some(string) => string.clone(),
|
Some(string) => string.clone(),
|
||||||
None => match is_html_document {
|
None => match is_html_document {
|
||||||
@ -976,7 +977,8 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
|
|||||||
|
|
||||||
fn Location(self) -> Temporary<Location> {
|
fn Location(self) -> Temporary<Location> {
|
||||||
let window = self.window.root();
|
let window = self.window.root();
|
||||||
window.r().Location()
|
let window = window.r();
|
||||||
|
self.location.or_init(|| Location::new(window, window.page_clone()))
|
||||||
}
|
}
|
||||||
|
|
||||||
// http://dom.spec.whatwg.org/#dom-parentnode-children
|
// http://dom.spec.whatwg.org/#dom-parentnode-children
|
||||||
|
@ -7,6 +7,7 @@ use dom::bindings::codegen::Bindings::EventHandlerBinding::{OnErrorEventHandlerN
|
|||||||
use dom::bindings::codegen::Bindings::FunctionBinding::Function;
|
use dom::bindings::codegen::Bindings::FunctionBinding::Function;
|
||||||
use dom::bindings::codegen::Bindings::WindowBinding;
|
use dom::bindings::codegen::Bindings::WindowBinding;
|
||||||
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||||
|
use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
|
||||||
use dom::bindings::codegen::InheritTypes::EventTargetCast;
|
use dom::bindings::codegen::InheritTypes::EventTargetCast;
|
||||||
use dom::bindings::global::global_object_for_js_object;
|
use dom::bindings::global::global_object_for_js_object;
|
||||||
use dom::bindings::error::Fallible;
|
use dom::bindings::error::Fallible;
|
||||||
@ -57,7 +58,6 @@ pub struct Window {
|
|||||||
script_chan: Box<ScriptChan+Send>,
|
script_chan: Box<ScriptChan+Send>,
|
||||||
control_chan: ScriptControlChan,
|
control_chan: ScriptControlChan,
|
||||||
console: MutNullableJS<Console>,
|
console: MutNullableJS<Console>,
|
||||||
location: MutNullableJS<Location>,
|
|
||||||
navigator: MutNullableJS<Navigator>,
|
navigator: MutNullableJS<Navigator>,
|
||||||
image_cache_task: ImageCacheTask,
|
image_cache_task: ImageCacheTask,
|
||||||
compositor: DOMRefCell<Box<ScriptListener+'static>>,
|
compositor: DOMRefCell<Box<ScriptListener+'static>>,
|
||||||
@ -101,6 +101,10 @@ impl Window {
|
|||||||
&*self.page
|
&*self.page
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn page_clone(&self) -> Rc<Page> {
|
||||||
|
self.page.clone()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_url(&self) -> Url {
|
pub fn get_url(&self) -> Url {
|
||||||
self.page().get_url()
|
self.page().get_url()
|
||||||
}
|
}
|
||||||
@ -200,7 +204,7 @@ impl<'a> WindowMethods for JSRef<'a, Window> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn Location(self) -> Temporary<Location> {
|
fn Location(self) -> Temporary<Location> {
|
||||||
self.location.or_init(|| Location::new(self, self.page.clone()))
|
self.Document().root().r().Location()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn SessionStorage(self) -> Temporary<Storage> {
|
fn SessionStorage(self) -> Temporary<Storage> {
|
||||||
@ -401,7 +405,6 @@ impl Window {
|
|||||||
console: Default::default(),
|
console: Default::default(),
|
||||||
compositor: DOMRefCell::new(compositor),
|
compositor: DOMRefCell::new(compositor),
|
||||||
page: page,
|
page: page,
|
||||||
location: Default::default(),
|
|
||||||
navigator: Default::default(),
|
navigator: Default::default(),
|
||||||
image_cache_task: image_cache_task,
|
image_cache_task: image_cache_task,
|
||||||
browser_context: DOMRefCell::new(None),
|
browser_context: DOMRefCell::new(None),
|
||||||
|
Loading…
Reference in New Issue
Block a user