Skip to content

Remove usage of opts::get() from style. - #24500

Merged
bors-servo merged 1 commit into
servo:masterfrom
kitlith:style_cfg
Oct 21, 2019
Merged

bors-servo merged 1 commit into
servo:masterfrom
kitlith:style_cfg

Conversation

@kitlith

@kitlith kitlith commented Oct 19, 2019 •

Copy link
Copy Markdown
Contributor

Use AtomicBools to create a global storage for a couple of settings used by an implementation of Default, suggested in #22854 (comment).

I do have one main question: I'm currently setting these statics in Servo::new(), would there be a better place to put this? Same goes with making these pub, is there a better way to go about this?


  • ./mach build -d does not report any errors
    • Seems to be failing in script for unknown/unrelated reasons, experiencing SIGKILL on two different machines. (May be an issue with the latest commit?) Still works fine on CI though.
  • ./mach test-tidy does not report any errors
  • These changes help with Remove uses of opts::get() from as much code as possible #22854

These changes do not require tests because these are cleanup changes.

@highfive

Copy link
Copy Markdown

Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @asajeffrey (or someone else) soon.

@highfive

Copy link
Copy Markdown

Heads up! This PR modifies the following files:

  • @emilio: components/style/context.rs

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Oct 19, 2019
@highfive

Copy link
Copy Markdown

warning Warning warning

  • These commits modify style code, but no tests are modified. Please consider adding a test!

@kitlith

kitlith commented Oct 19, 2019 •

Copy link
Copy Markdown
Contributor Author

sigh. well the build failure is definitely from master, because that's what I was trying to build on the second machine. test-tidy should be fixed now.

edit: and since CI handles everything just fine (dunno why my local env isn't working), the main build should now be fixed too. hopefully.

@emilio emilio left a comment

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 seems ok. @jdm is this the pattern that other code has been following? I guess it does accomplish the "changing opts rebuilds less" bits (assuming we remove the other usage in the crate and the dependency), but the pattern seems somewhat weird.

Comment thread components/servo/lib.rs Resolved
Comment thread components/style/context.rs Outdated

/// A global variable holding the state of
/// `StyleSystemOptions::default().disable_style_sharing_cache`.
/// This is motivated by [issue #22854](https://github.com/servo/servo/issues/22854).

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 don't think this line of the comment is useful, it only makes sense in the context of this PR.

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.

I thought I'd try to leave the issue link for motivation especially because this is an odder pattern than usual, to try and preempt "why not just use opts::get()" for people not familiar with the issue.

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 still think it's not particularly useful. I assume we'd get rid of opts as a dependency of style after changing the other similar uses. Once that's done, if somebody wants to use opts::get() again they need to re-introduce it as a dependency, which makes the consequences of it much more obvious.

Not going to block this patch on removing this comment, but I don't quite see the point of it... Maybe just See #22854 is a good compromise?

Either way this looks ok, mind squashing? Thanks!

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.

K, I'll do that and squash once I'm at a computer.

Comment thread components/style/context.rs Resolved
@jdm

jdm commented Oct 19, 2019

Copy link
Copy Markdown
Member

This is our first time trying this pattern, since we skipped other uses of opts::get inside static functions. I'm in favour.

@kitlith

kitlith commented Oct 20, 2019

Copy link
Copy Markdown
Contributor Author

I just noticed that there's only a single opts::get() left in the style component:

#[cfg(feature = "servo")]
#[inline]
fn is_servo_nonincremental_layout() -> bool {
use servo_config::opts;
opts::get().nonincremental_layout
}

Would you like me to apply the same pattern here and remove opts from the dependency tree of this crate?

@jdm

jdm commented Oct 20, 2019

Copy link
Copy Markdown
Member

Yes please!

@emilio

emilio commented Oct 20, 2019

Copy link
Copy Markdown
Member

That'd indeed be ideal. Do you plan to do this as part of this PR or a new one? (Just to know if I should submit the current PR as is :))

@kitlith

kitlith commented Oct 20, 2019 •

Copy link
Copy Markdown
Contributor Author

I can do that in this PR, but it might take a bit so you can merge if impatient. (I don't mind doing it in a seperate one either, gets me another PR towards hacktoberfest lol, but i'd prefer not to PR spam)

@emilio emilio left a comment

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.

Two PRs doing two different things is not spam, in my book ;)

Anyhow, let's submit this. If you get to push your other changes before it lands then it will just not get merged and we'll review those too. Otherwise new PR is fine :)

@emilio

emilio commented Oct 20, 2019

Copy link
Copy Markdown
Member

@bors-servo r+

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 0dbcc48 has been approved by emilio

@highfive highfive assigned emilio and unassigned asajeffrey Oct 20, 2019
@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. labels Oct 20, 2019
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 0dbcc48 with merge b88cf36...

bors-servo pushed a commit that referenced this pull request Oct 20, 2019
Remove usage of opts::get() from style::context.

<!-- Please describe your changes on the following line: -->
Use `AtomicBool`s to create a global storage for a couple of settings used by an implementation of `Default`, suggested in #22854 (comment).

I do have one main question: I'm currently setting these statics in `Servo::new()`, would there be a better place to put this? Same goes with making these `pub`, is there a better way to go about this?

---
<!-- 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
  - Seems to be failing in script for unknown/unrelated reasons, experiencing SIGKILL on two different machines. (May be an issue with the latest commit?) Still works fine on CI though.
- [X] `./mach test-tidy` does not report any errors
- [X] These changes help with #22854

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. -->
@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - status-taskcluster

@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 Oct 21, 2019
@kitlith

kitlith commented Oct 21, 2019 •

Copy link
Copy Markdown
Contributor Author

Uh? I don't think I touched anything related to the tests that changed...

Anyway, I'll get rid of the other usage I mentioned earlier now.

EDIT: Oh! Would it be better for these statics to be #[doc(hidden)]?

@highfive highfive removed the S-tests-failed The changes caused existing tests to fail. label Oct 21, 2019
@kitlith kitlith changed the title Remove usage of opts::get() from style::context. Remove usage of opts::get() from style. Oct 21, 2019
@emilio

emilio commented Oct 21, 2019

Copy link
Copy Markdown
Member

So: we can't remove the dep on servo_config yet because style still relies on pref in a few places. This feels like something that is not as easilly replaced...

Ah, that is a good point... :/

So there's no realistic path to get rid of the dependency for now... Is there any point in removing opts::get() usage then @jdm?

@jdm

jdm commented Oct 21, 2019

Copy link
Copy Markdown
Member

There is! I want to split prefs and options into separate crates in the future, so this work is still useful.

@jdm

jdm commented Oct 21, 2019

Copy link
Copy Markdown
Member

@bors-servo r=emilio
And to clear up the earlier mystery, the test failure was caused by #23290.

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit b162e9e has been approved by emilio

@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. labels Oct 21, 2019
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit b162e9e with merge 07e3b80...

bors-servo pushed a commit that referenced this pull request Oct 21, 2019
Remove usage of opts::get() from style.

<!-- Please describe your changes on the following line: -->
Use `AtomicBool`s to create a global storage for a couple of settings used by an implementation of `Default`, suggested in #22854 (comment).

I do have one main question: I'm currently setting these statics in `Servo::new()`, would there be a better place to put this? Same goes with making these `pub`, is there a better way to go about this?

---
<!-- 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
  - Seems to be failing in script for unknown/unrelated reasons, experiencing SIGKILL on two different machines. (May be an issue with the latest commit?) Still works fine on CI though.
- [X] `./mach test-tidy` does not report any errors
- [X] These changes help with #22854

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. -->
@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - linux-rel-css

@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 Oct 21, 2019
@jdm

jdm commented Oct 21, 2019

Copy link
Copy Markdown
Member
error[E0308]: mismatched types
  --> components/style/traversal.rs:57:40
   |
57 | fn is_servo_nonincremental_layout() -> bool {
   |    ------------------------------      ^^^^ expected bool, found ()
   |    |
   |    implicitly returns `()` as its body has no tail or `return` expression
...
60 |     IS_SERVO_NONINCREMENTAL_LAYOUT.load(Ordering::Relaxed);
   |                                                           - help: consider removing this semicolon
   |
   = note: expected type `bool`
              found type `()`

error: aborting due to previous error

@kitlith

kitlith commented Oct 21, 2019

Copy link
Copy Markdown
Contributor Author

facepalm

@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 Oct 21, 2019
@jdm

jdm commented Oct 21, 2019

Copy link
Copy Markdown
Member

@bors-servo r+

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 0a07a88 has been approved by jdm

@highfive highfive assigned jdm and unassigned emilio Oct 21, 2019
@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. labels Oct 21, 2019
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 0a07a88 with merge 927dfd1...

bors-servo pushed a commit that referenced this pull request Oct 21, 2019
Remove usage of opts::get() from style.

<!-- Please describe your changes on the following line: -->
Use `AtomicBool`s to create a global storage for a couple of settings used by an implementation of `Default`, suggested in #22854 (comment).

I do have one main question: I'm currently setting these statics in `Servo::new()`, would there be a better place to put this? Same goes with making these `pub`, is there a better way to go about this?

---
<!-- 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
  - Seems to be failing in script for unknown/unrelated reasons, experiencing SIGKILL on two different machines. (May be an issue with the latest commit?) Still works fine on CI though.
- [X] `./mach test-tidy` does not report any errors
- [X] These changes help with #22854

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. -->
@bors-servo

Copy link
Copy Markdown
Contributor

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

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants