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

Script: removed a few opts::get() #23539

Merged
merged 1 commit into from Jun 27, 2019

Conversation

@oneturkmen
Copy link
Contributor

oneturkmen commented Jun 8, 2019

I removed only a few opts::get() from the components/script because all other code with "opts::get()" is reused by many other parts within the same component.


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix partially #22854 (GitHub issue number if applicable)
  • These changes do not require tests because these are cleanup changes.

This change is Reviewable

@highfive
Copy link

highfive commented Jun 8, 2019

Heads up! This PR modifies the following files:

  • @asajeffrey: components/script/script_thread.rs, components/script/dom/window.rs, components/constellation/pipeline.rs
  • @cbrewster: components/constellation/pipeline.rs
  • @paulrouget: components/constellation/pipeline.rs
  • @KiChjang: components/script/script_thread.rs, components/script/dom/window.rs, components/script_traits/lib.rs
@highfive
Copy link

highfive commented Jun 8, 2019

warning Warning warning

  • These commits modify script code, but no tests are modified. Please consider adding a test!
@oneturkmen
Copy link
Contributor Author

oneturkmen commented Jun 8, 2019

r? @jdm

@highfive highfive assigned jdm and unassigned Manishearth Jun 8, 2019
@oneturkmen
Copy link
Contributor Author

oneturkmen commented Jun 8, 2019

@jdm could you bors-retry since there's been a network issue again. Thank you!

caused by: failed to make network request

@CYBAI
Copy link
Collaborator

CYBAI commented Jun 8, 2019

@bors-servo try=wpt

@oneturkmen No worries about the Travis failure if it's network issue :) We mainly see the CI result from bors-servo. btw, bors can't retry Travis 😂

@bors-servo
Copy link
Contributor

bors-servo commented Jun 8, 2019

Trying commit 270dff5 with merge d1766fa...

bors-servo added a commit that referenced this pull request Jun 8, 2019
Script: removed a few opts::get()

<!-- Please describe your changes on the following line: -->
I removed only a few opts::get() from the components/script because all other code with "opts::get()" is reused by many other parts within the same component.

---
<!-- 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 *partially* #22854 (GitHub issue number if applicable)

<!-- Either: -->
- [x] These changes do not require tests because these are cleanup changes.

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

bors-servo commented Jun 8, 2019

☀️ Test successful - linux-rel-css, linux-rel-wpt, status-taskcluster
State: approved= try=True

components/script/dom/window.rs Outdated Show resolved Hide resolved
components/script/script_thread.rs Outdated Show resolved Hide resolved
@jdm
Copy link
Member

jdm commented Jun 10, 2019

@oneturkmen Could you show a few examples of what you mean by "all other code with "opts::get()" is reused by many other parts within the same component"?

@servo-wpt-sync
Copy link
Collaborator

servo-wpt-sync commented Jun 16, 2019

Error syncing changes upstream. Logs saved in error-snapshot-1560658517075.

@jdm
Copy link
Member

jdm commented Jun 16, 2019

Looks like the rebase didn't go as planned. I recommend git reset --hard fd174c54ef4fa6574ae782dacccaeccd14abb936; git cherry-pick 270dff58b400ab4e41b11c12f848dbf30bad5f6c and force pushing the result.

@oneturkmen oneturkmen force-pushed the oneturkmen:script-remove-opts-get branch from 25ee27b to 8748634 Jun 16, 2019
@oneturkmen
Copy link
Contributor Author

oneturkmen commented Jun 16, 2019

@jdm sorry for the long delay. I will push the changes for the three bools in a bit.

One example of what I meant would be this opts::get(). It is defined in function new_rt_and_cx_with_parent(...), which is reused (or wrapped) by public functions new_child_runtime() (here) and new_rt_and_cx() (here). And recurringly (if such word exists), they are used, e.g. in script/dom/serviceworkerglobalscope.rs, or script/dom/worklet.rs ... Do I make sense?

Another example is with opts::get() in dom/permissions.rs. The same recurring call pattern exists there.

I hope this clarifies the issue.

@jdm
Copy link
Member

jdm commented Jun 16, 2019

I think in many cases we can add such options as members of GlobalScope, and then code can either access it transitively through the parent field (https://doc.servo.org/script/dom/index.html#inheritance), or by calling the global() API on a DOM object (https://doc.servo.org/script/dom/bindings/reflector/trait.DomObject.html#method.global), or accessing a GlobalScope object that's already present.

@oneturkmen oneturkmen force-pushed the oneturkmen:script-remove-opts-get branch from 8748634 to aec9552 Jun 16, 2019
@oneturkmen
Copy link
Contributor Author

oneturkmen commented Jun 19, 2019

@jdm I may need your guidance here, if you don't mind.

I am currently trying to remove opts::get().userscripts from components/script/dom/userscripts.rs. The function load_scripts where this opts::get() is defined is used by dom/headelement.rs here.

As you mentioned, I am passing parameters all along through "pub fn new()" and then via "fn new_inherited()" within the same struct implementation. However, I reached the moment where I have to change the signature of Document constructor (i.e. pub fn new()), but it is used in other 10-12 places ... I feel like I am doing something wrong here. Could you give any hint/prompt on how (or where) to look to make change(s)?

@jdm
Copy link
Member

jdm commented Jun 19, 2019

Great, that's a very concrete question I can answer :) I recommend storing a userscripts_path member in Window, and then that code can access it by calling a method that returns it. Since there is only one place that creates Window objects (script_thread.rs), the value can be stored in ScriptThread and passed to the Window::new constructor.

@oneturkmen
Copy link
Contributor Author

oneturkmen commented Jun 19, 2019

@jdm thanks for the answer! do you think I could do the same (if technically possible) for other opts::get()?

Update: never mind. It's a vague question to ask since it really depends on the context, i.e. methods/functions and structs used. If I find something very ambiguous, I will let you know (with another specific question hehe).

@bors-servo
Copy link
Contributor

bors-servo commented Jun 27, 2019

Testing commit 6b578e9 with merge 53e79fc...

bors-servo added a commit that referenced this pull request Jun 27, 2019
Script: removed a few opts::get()

<!-- Please describe your changes on the following line: -->
I removed only a few opts::get() from the components/script because all other code with "opts::get()" is reused by many other parts within the same component.

---
<!-- 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 *partially* #22854 (GitHub issue number if applicable)

<!-- Either: -->
- [x] These changes do not require tests because these are cleanup changes.

<!-- 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/23539)
<!-- Reviewable:end -->
@jdm
Copy link
Member

jdm commented Jun 27, 2019

Non-linux builds reported this error:

error: cannot find macro `pref!` in this scope
   --> components/script/dom/permissions.rs:317:12
    |
317 |         if pref!(dom.permissions.testing.allowed_in_nonsecure_contexts) {
    |            ^^^^
error: aborting due to previous error
@oneturkmen oneturkmen force-pushed the oneturkmen:script-remove-opts-get branch from 6b578e9 to 0da2b74 Jun 27, 2019
@oneturkmen
Copy link
Contributor Author

oneturkmen commented Jun 27, 2019

Non-linux builds reported this error:

error: cannot find macro `pref!` in this scope
   --> components/script/dom/permissions.rs:317:12
    |
317 |         if pref!(dom.permissions.testing.allowed_in_nonsecure_contexts) {
    |            ^^^^
error: aborting due to previous error

Yup, removed.

@jdm
Copy link
Member

jdm commented Jun 27, 2019

@bors-servo
Copy link
Contributor

bors-servo commented Jun 27, 2019

📌 Commit 0da2b74 has been approved by jdm

@bors-servo
Copy link
Contributor

bors-servo commented Jun 27, 2019

Testing commit 0da2b74 with merge 7833332...

bors-servo added a commit that referenced this pull request Jun 27, 2019
Script: removed a few opts::get()

<!-- Please describe your changes on the following line: -->
I removed only a few opts::get() from the components/script because all other code with "opts::get()" is reused by many other parts within the same component.

---
<!-- 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 *partially* #22854 (GitHub issue number if applicable)

<!-- Either: -->
- [x] These changes do not require tests because these are cleanup changes.

<!-- 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/23539)
<!-- Reviewable:end -->
@oneturkmen
Copy link
Contributor Author

oneturkmen commented Jun 27, 2019

Seems that it fails even on warnings (forgot to prefix the unused variable). Pushing changes now.

@oneturkmen oneturkmen force-pushed the oneturkmen:script-remove-opts-get branch from 0da2b74 to 4256928 Jun 27, 2019
@jdm
Copy link
Member

jdm commented Jun 27, 2019

@bors-servo r+
Indeed. Thanks!

@bors-servo
Copy link
Contributor

bors-servo commented Jun 27, 2019

📌 Commit 4256928 has been approved by jdm

@bors-servo
Copy link
Contributor

bors-servo commented Jun 27, 2019

Testing commit 4256928 with merge 61cadfa...

bors-servo added a commit that referenced this pull request Jun 27, 2019
Script: removed a few opts::get()

<!-- Please describe your changes on the following line: -->
I removed only a few opts::get() from the components/script because all other code with "opts::get()" is reused by many other parts within the same component.

---
<!-- 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 *partially* #22854 (GitHub issue number if applicable)

<!-- Either: -->
- [x] These changes do not require tests because these are cleanup changes.

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

bors-servo commented Jun 27, 2019

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

@bors-servo bors-servo merged commit 4256928 into servo:master Jun 27, 2019
4 checks passed
4 checks passed
Taskcluster (pull_request) TaskGroup: success
Details
Travis CI - Pull Request Build Passed
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
homu Test successful
Details
@oneturkmen oneturkmen deleted the oneturkmen:script-remove-opts-get branch Jun 27, 2019
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.

None yet

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