Skip to content

Allow windows to share browsing contexts.#15120

Merged
bors-servo merged 2 commits intoservo:masterfrom
asajeffrey:script-windows-share-browsing-contexts
Jan 29, 2017
Merged

Allow windows to share browsing contexts.#15120
bors-servo merged 2 commits intoservo:masterfrom
asajeffrey:script-windows-share-browsing-contexts

Conversation

@asajeffrey
Copy link
Copy Markdown
Contributor

@asajeffrey asajeffrey commented Jan 19, 2017

This PR allows different Window objects in the same browsing context to share a BrowsingContext object.

SpiderMonkey requires a WindowProxy object to be in the same compartment as its Window, so when a WindowProxy changes Window, we have to brain-transplant it. In turn this requires the reflector of a BrowsingContext to be mutable.



This change is Reviewable

@asajeffrey asajeffrey added the A-content/script Related to the script thread label Jan 19, 2017
@highfive
Copy link
Copy Markdown

Heads up! This PR modifies the following files:

  • @fitzgen: components/script/dom/document.rs, components/script/dom/node.rs, components/script/dom/browsingcontext.rs, components/script/dom/xmlhttprequest.rs, components/script/dom/xmldocument.rs, components/script/dom/servoparser/mod.rs, components/script/script_thread.rs, components/script/dom/domparser.rs, components/script/dom/window.rs, components/script/dom/domimplementation.rs
  • @KiChjang: components/script/dom/document.rs, components/script/dom/node.rs, components/script/dom/browsingcontext.rs, components/script/dom/xmlhttprequest.rs, components/script/dom/xmldocument.rs, components/script/dom/servoparser/mod.rs, components/script/script_thread.rs, components/script/dom/domparser.rs, components/script/dom/window.rs, components/script/dom/domimplementation.rs

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Jan 19, 2017
@highfive
Copy link
Copy Markdown

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!

@asajeffrey
Copy link
Copy Markdown
Contributor Author

r? @jdm

@highfive highfive assigned jdm and unassigned emilio Jan 19, 2017
@asajeffrey
Copy link
Copy Markdown
Contributor Author

cc @Ms2ger @cbrewster

@asajeffrey asajeffrey force-pushed the script-windows-share-browsing-contexts branch from 98a3843 to ba006bc Compare January 19, 2017 22:22
@asajeffrey asajeffrey changed the title Allow windows to share browsing contextw. Allow windows to share browsing contexts. Jan 19, 2017
@jdm
Copy link
Copy Markdown
Member

jdm commented Jan 19, 2017

I think my changes in #15118 may make some of the mutable Reflector changes unnecessary (particularly if we modify rust-mozjs to make Heap::set not require &mut self).

@asajeffrey
Copy link
Copy Markdown
Contributor Author

You're right, we could use reflector.rootable() to set the reflector.

@asajeffrey asajeffrey force-pushed the script-windows-share-browsing-contexts branch from ba006bc to 7129af4 Compare January 20, 2017 15:52
@asajeffrey
Copy link
Copy Markdown
Contributor Author

@jdm: I used reflector.rootable() to set the reflector, rather than having the reflector inside a RefCell.

@asajeffrey
Copy link
Copy Markdown
Contributor Author

@asajeffrey
Copy link
Copy Markdown
Contributor Author

@bors-servo
Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #15136) made this pull request unmergeable. Please resolve the merge conflicts.

@highfive highfive added the S-needs-rebase There are merge conflict errors. label Jan 23, 2017
@asajeffrey asajeffrey force-pushed the script-windows-share-browsing-contexts branch 3 times, most recently from 7129af4 to dee9594 Compare January 23, 2017 19:19
@bors-servo
Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #15176) made this pull request unmergeable. Please resolve the merge conflicts.

@highfive highfive added the S-needs-rebase There are merge conflict errors. label Jan 24, 2017
@asajeffrey asajeffrey force-pushed the script-windows-share-browsing-contexts branch from dee9594 to e5254db Compare January 24, 2017 18:17
@asajeffrey asajeffrey removed the S-needs-rebase There are merge conflict errors. label Jan 24, 2017
// Set the window proxy.
SetWindowProxy(cx, window_jsobject, new_window_proxy.handle());

// Create a new reflector.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update the reflector.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. Done.

// Transfer ownership of this browsing context from the old window proxy to the new one.
SetProxyExtra(new_window_proxy.get(), 0, &PrivateValue(self as *const _ as *const _));

// Set the window proxy.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is redundant given the function name. How about Notify the JS engine that the window proxy has changed.?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -184,12 +184,12 @@ pub struct Document {
node: Node,
window: JS<Window>,
/// https://html.spec.whatwg.org/multipage/#concept-document-bc
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment doesn't belong any more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. Done.


pub fn new(window: &Window,
browsing_context: Option<&BrowsingContext>,
has_browsing_context: bool,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I lean towards a self-documenting enum here, given that every caller passes a boolean literal.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

/// The documents for pipelines managed by this thread
documents: DOMRefCell<Documents>,
/// The browsing contexts known by this thread
/// TODO: this map grows, but never shrinks.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should file an issue about this and mention it here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. It's #15258.

@jdm jdm added the S-needs-code-changes Changes have not yet been made that were requested by a reviewer. label Jan 26, 2017
@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-needs-squash Some (or all) of the commits in the PR should be combined. labels Jan 27, 2017
@asajeffrey asajeffrey removed the S-blocked-on-external Something, somewhere else, needs to happen before this PR can be merged. label Jan 27, 2017
@bors-servo
Copy link
Copy Markdown
Contributor

⌛ Testing commit 2e863a9 with merge 4f1d6ba...

@bors-servo
Copy link
Copy Markdown
Contributor

💔 Test failed - mac-dev-unit

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Jan 27, 2017
@asajeffrey
Copy link
Copy Markdown
Contributor Author

That would be caused by it picking up the old version of rust-mozjs. Wait for servo/rust-mozjs#329 to land...

@asajeffrey asajeffrey added the S-blocked-on-external Something, somewhere else, needs to happen before this PR can be merged. label Jan 27, 2017
@bors-servo
Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #14971) made this pull request unmergeable. Please resolve the merge conflicts.

@highfive highfive added the S-needs-rebase There are merge conflict errors. label Jan 28, 2017
@asajeffrey asajeffrey force-pushed the script-windows-share-browsing-contexts branch from 2e863a9 to 403499a Compare January 29, 2017 03:57
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-tests-failed The changes caused existing tests to fail. labels Jan 29, 2017
@asajeffrey
Copy link
Copy Markdown
Contributor Author

servo/rust-mozjs#329 has landed. Rebased. @bors-servo: r=jdm

@bors-servo
Copy link
Copy Markdown
Contributor

📌 Commit 403499a has been approved by jdm

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. S-needs-rebase There are merge conflict errors. labels Jan 29, 2017
@asajeffrey asajeffrey removed the S-blocked-on-external Something, somewhere else, needs to happen before this PR can be merged. label Jan 29, 2017
@bors-servo
Copy link
Copy Markdown
Contributor

⌛ Testing commit 403499a with merge 67c1826...

bors-servo pushed a commit that referenced this pull request Jan 29, 2017
…xts, r=jdm

Allow windows to share browsing contexts.

<!-- Please describe your changes on the following line: -->

This PR allows different `Window` objects in the same browsing context to share a `BrowsingContext` object.

SpiderMonkey requires a `WindowProxy` object to be in the same compartment as its `Window`, so when a `WindowProxy` changes `Window`, we have to brain-transplant it. In turn this requires the reflector of a `BrowsingContext` to be mutable.

---
<!-- 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 #13608 and #14843
- [X] These changes do not require tests because an existing test catches this (`/html/browsers/the-window-object/Window-document.html` is now `PASS`)

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15120)
<!-- Reviewable:end -->
@bors-servo
Copy link
Copy Markdown
Contributor

☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css, mac-rel-wpt1, mac-rel-wpt2, windows-gnu-dev, windows-msvc-dev

@bors-servo bors-servo merged commit 403499a into servo:master Jan 29, 2017
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Jan 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-content/script Related to the script thread

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Transplant WindowProxy objects

6 participants