зеркало из https://github.com/mozilla/gecko-dev.git
servo: Merge #18578 - Window should own Location, Document shouldn't (from asajeffrey:script-window-owns-location); r=KiChjang
<!-- Please describe your changes on the following line: --> Document shouldn't own location, Window should. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #18438 - [X] These changes do not require tests because it's an intermittent <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: https://github.com/servo/servo Source-Revision: 6a791cd7f26b42a6688099bea203c21fb3c9cc12 --HG-- extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear extra : subtree_revision : 275ce0ac177aff6c59f8b4959f79259031dbbdde
This commit is contained in:
Родитель
3c971f45bd
Коммит
a4f95fc4f9
|
@ -226,7 +226,6 @@ pub struct Document {
|
|||
node: Node,
|
||||
window: JS<Window>,
|
||||
implementation: MutNullableJS<DOMImplementation>,
|
||||
location: MutNullableJS<Location>,
|
||||
content_type: DOMString,
|
||||
last_modified: Option<String>,
|
||||
encoding: Cell<EncodingRef>,
|
||||
|
@ -2222,7 +2221,6 @@ impl Document {
|
|||
window: JS::from_ref(window),
|
||||
has_browsing_context: has_browsing_context == HasBrowsingContext::Yes,
|
||||
implementation: Default::default(),
|
||||
location: Default::default(),
|
||||
content_type: match content_type {
|
||||
Some(string) => string,
|
||||
None => DOMString::from(match is_html_document {
|
||||
|
@ -3438,7 +3436,11 @@ impl DocumentMethods for Document {
|
|||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-document-location
|
||||
fn GetLocation(&self) -> Option<Root<Location>> {
|
||||
self.browsing_context().map(|_| self.location.or_init(|| Location::new(&self.window)))
|
||||
if self.is_fully_active() {
|
||||
Some(self.window.Location())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-parentnode-children
|
||||
|
@ -3815,7 +3817,6 @@ impl DocumentMethods for Document {
|
|||
|
||||
// Step 19.
|
||||
self.implementation.set(None);
|
||||
self.location.set(None);
|
||||
self.images.set(None);
|
||||
self.embeds.set(None);
|
||||
self.links.set(None);
|
||||
|
|
|
@ -183,6 +183,7 @@ pub struct Window {
|
|||
image_cache_chan: Sender<ImageCacheMsg>,
|
||||
window_proxy: MutNullableJS<WindowProxy>,
|
||||
document: MutNullableJS<Document>,
|
||||
location: MutNullableJS<Location>,
|
||||
history: MutNullableJS<History>,
|
||||
custom_element_registry: MutNullableJS<CustomElementRegistry>,
|
||||
performance: MutNullableJS<Performance>,
|
||||
|
@ -568,7 +569,7 @@ impl WindowMethods for Window {
|
|||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-location
|
||||
fn Location(&self) -> Root<Location> {
|
||||
self.Document().GetLocation().unwrap()
|
||||
self.location.or_init(|| Location::new(self))
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-sessionstorage
|
||||
|
@ -1854,6 +1855,7 @@ impl Window {
|
|||
image_cache_chan,
|
||||
image_cache,
|
||||
navigator: Default::default(),
|
||||
location: Default::default(),
|
||||
history: Default::default(),
|
||||
custom_element_registry: Default::default(),
|
||||
window_proxy: Default::default(),
|
||||
|
|
Загрузка…
Ссылка в новой задаче