Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enter dom compartment wrapper #23344

Merged
merged 1 commit into from Jun 29, 2019
Merged

Conversation

@KaczuH
Copy link

KaczuH commented May 8, 2019

I'm still not sure if the changes are entirely correct.
Replaced occurrences:
JSAutoCompartment::new(global.get_cx(), global.reflector().get_jsobject().get()); with fn enter_compartment(object: &DomObject) -> JSAutoCompartment

There are still occurrences of JSAutoCompartment that i was unable to replace. Could anyone give me a hint if it is possible?

→ rg -Fi --type rust "JSAutoCompartment::"
components/script/compartments.rs
38:    JSAutoCompartment::new(

components/script/dom/create.rs
159:                                let _ac = JSAutoCompartment::new(

components/script/dom/eventtarget.rs
527:                let _ac = JSAutoCompartment::new(cx, self.reflector().get_jsobject().get());

components/script/dom/windowproxy.rs
223:            let _ac = JSAutoCompartment::new(cx, window_jsobject.get());

components/script/dom/customelementregistry.rs
337:            let _ac = JSAutoCompartment::new(cx, proto_object.get());
349:            let _ac = JSAutoCompartment::new(cx, constructor.get());
538:            let _ac = JSAutoCompartment::new(cx, self.constructor.callback());
668:        let _ac = JSAutoCompartment::new(cx, constructor.callback());

components/script/dom/window.rs
2216:            let _ac = JSAutoCompartment::new(cx, obj.get());

components/script/dom/paintworkletglobalscope.rs
254:        let _ac = JSAutoCompartment::new(cx, self.worklet_global.reflector().get_jsobject().get());

components/script/dom/globalscope.rs
544:                let _ac = JSAutoCompartment::new(cx, globalhandle.get());

components/script/dom/websocket.rs
573:            let _ac = JSAutoCompartment::new(cx, ws.reflector().get_jsobject().get());

components/script/dom/workerglobalscope.rs
397:                        let _ac = JSAutoCompartment::new(

components/script/dom/promise.rs
144:        let _ac = JSAutoCompartment::new(cx, global.reflector().get_jsobject().get());
156:        let _ac = JSAutoCompartment::new(cx, global.reflector().get_jsobject().get());

components/script/dom/bindings/htmlconstructor.rs
118:        let _ac = JSAutoCompartment::new(window.get_cx(), callee.get());

components/script/dom/bindings/utils.rs
411:    let _ac = JSAutoCompartment::new(cx, obj.get());

components/script/dom/bindings/callback.rs
276:                let _ac = JSAutoCompartment::new(

components/script/dom/bindings/interface.rs
163:    let _ac = JSAutoCompartment::new(cx, rval.get());

  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #23266
  • These changes do not require tests because no logic was changed only some code extracted to wrapper function

This change is Reviewable

@jdm
Copy link
Member

jdm commented May 8, 2019

This is what I expected. Any call site that already has access to a *mut JSContext to pass doesn't make sense to replace with this helper.

@jdm jdm self-assigned this May 8, 2019
@bors-servo
Copy link
Contributor

bors-servo commented May 11, 2019

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

@KaczuH KaczuH force-pushed the KaczuH:enter_dom_compartment_wrapper branch from fde71b3 to 9fcb884 May 18, 2019
@KaczuH
Copy link
Author

KaczuH commented May 18, 2019

Rebase done.

@jdm
Copy link
Member

jdm commented May 19, 2019

I will review this on Tuesday. Sorry for the delay!

@@ -324,7 +324,7 @@ impl CustomElementRegistryMethods for CustomElementRegistry {
// Steps 10.1 - 10.2
rooted!(in(cx) let mut prototype = UndefinedValue());
{
let _ac = JSAutoRealm::new(cx, constructor.get());
let _ac = enter_realm(&*self);

This comment has been minimized.

@jdm

jdm May 23, 2019

Member

This is not an equivalent change, so we should revert it.

@@ -506,7 +507,7 @@ impl EventTarget {

let scopechain = AutoObjectVectorWrapper::new(cx);

let _ac = JSAutoRealm::new(cx, window.reflector().get_jsobject().get());
let _ac = enter_realm(&*document);

This comment has been minimized.

@jdm

jdm May 23, 2019

Member

Let's keep using window here instead of document.

@@ -148,7 +149,7 @@ impl WindowProxy {
((*get_object_class(window_jsobject.get())).flags & JSCLASS_IS_GLOBAL),
0
);
let _ac = JSAutoRealm::new(cx, window_jsobject.get());
let _ac = enter_realm(window);

This comment has been minimized.

@jdm

jdm May 23, 2019

Member

Let's revert the changes in this file. We already have the cx and JSObject values, so calling this method to reacquire them is redundant.

@bors-servo
Copy link
Contributor

bors-servo commented Jun 2, 2019

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

@jdm
Copy link
Member

jdm commented Jun 24, 2019

@KaczuH Are you planning to finish this work?

@KaczuH KaczuH force-pushed the KaczuH:enter_dom_compartment_wrapper branch from 9fcb884 to 097a3a2 Jun 29, 2019
@KaczuH
Copy link
Author

KaczuH commented Jun 29, 2019

All changes are now applied, sorry for long wait

@jdm jdm removed the S-needs-rebase label Jun 29, 2019
@jdm
Copy link
Member

jdm commented Jun 29, 2019

Looks good! Could you squash the commits together into one?

Revert some unnecessary changes

Fix fmt errors
@KaczuH KaczuH force-pushed the KaczuH:enter_dom_compartment_wrapper branch from c202455 to adb4024 Jun 29, 2019
@KaczuH
Copy link
Author

KaczuH commented Jun 29, 2019

@jdm squash done :)

@jdm
Copy link
Member

jdm commented Jun 29, 2019

@bors-servo r+
Thanks!

@bors-servo
Copy link
Contributor

bors-servo commented Jun 29, 2019

📌 Commit adb4024 has been approved by jdm

@bors-servo
Copy link
Contributor

bors-servo commented Jun 29, 2019

Testing commit adb4024 with merge 23c49bb...

bors-servo added a commit that referenced this pull request Jun 29, 2019
Enter dom compartment wrapper

I'm still not sure if the changes are entirely correct.
Replaced occurrences:
 `JSAutoCompartment::new(global.get_cx(), global.reflector().get_jsobject().get());` with `fn enter_compartment(object: &DomObject) -> JSAutoCompartment`

There are still occurrences of `JSAutoCompartment` that i was unable to replace. Could anyone give me a hint if it is possible?
```
→ rg -Fi --type rust "JSAutoCompartment::"
components/script/compartments.rs
38:    JSAutoCompartment::new(

components/script/dom/create.rs
159:                                let _ac = JSAutoCompartment::new(

components/script/dom/eventtarget.rs
527:                let _ac = JSAutoCompartment::new(cx, self.reflector().get_jsobject().get());

components/script/dom/windowproxy.rs
223:            let _ac = JSAutoCompartment::new(cx, window_jsobject.get());

components/script/dom/customelementregistry.rs
337:            let _ac = JSAutoCompartment::new(cx, proto_object.get());
349:            let _ac = JSAutoCompartment::new(cx, constructor.get());
538:            let _ac = JSAutoCompartment::new(cx, self.constructor.callback());
668:        let _ac = JSAutoCompartment::new(cx, constructor.callback());

components/script/dom/window.rs
2216:            let _ac = JSAutoCompartment::new(cx, obj.get());

components/script/dom/paintworkletglobalscope.rs
254:        let _ac = JSAutoCompartment::new(cx, self.worklet_global.reflector().get_jsobject().get());

components/script/dom/globalscope.rs
544:                let _ac = JSAutoCompartment::new(cx, globalhandle.get());

components/script/dom/websocket.rs
573:            let _ac = JSAutoCompartment::new(cx, ws.reflector().get_jsobject().get());

components/script/dom/workerglobalscope.rs
397:                        let _ac = JSAutoCompartment::new(

components/script/dom/promise.rs
144:        let _ac = JSAutoCompartment::new(cx, global.reflector().get_jsobject().get());
156:        let _ac = JSAutoCompartment::new(cx, global.reflector().get_jsobject().get());

components/script/dom/bindings/htmlconstructor.rs
118:        let _ac = JSAutoCompartment::new(window.get_cx(), callee.get());

components/script/dom/bindings/utils.rs
411:    let _ac = JSAutoCompartment::new(cx, obj.get());

components/script/dom/bindings/callback.rs
276:                let _ac = JSAutoCompartment::new(

components/script/dom/bindings/interface.rs
163:    let _ac = JSAutoCompartment::new(cx, rval.get());
```

---
<!-- 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  #23266

<!-- Either: -->
- [X] These changes do not require tests because no logic was changed only some code extracted to wrapper function

<!-- 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. -->

<!-- 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/23344)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Jun 29, 2019

☀️ Test successful - linux-rel-css, linux-rel-wpt, status-taskcluster
Approved by: jdm
Pushing 23c49bb to master...

@bors-servo bors-servo merged commit adb4024 into servo:master Jun 29, 2019
3 checks passed
3 checks passed
Travis CI - Pull Request Build Passed
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
homu Test successful
Details
@bors-servo bors-servo mentioned this pull request Jun 29, 2019
0 of 5 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

4 participants
You can’t perform that action at this time.