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
Move root_font_size to the device #17041
Conversation
Heads up! This PR modifies the following files:
|
r? @emilio |
First commit is from #17041 since I don't want to have to fix merge conflicts |
@@ -35,8 +37,13 @@ pub struct Device { | |||
pub pres_context: RawGeckoPresContextOwned, | |||
default_values: Arc<ComputedValues>, | |||
viewport_override: Option<ViewportConstraints>, | |||
/// The font size of the root element | |||
root_font_size: AtomicRefCell<Au>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can just look in pres_context.mDocument.mCachedDocumentElement instead, right?
Also needs the servo side changes |
1e1a502
to
00e09ce
Compare
@@ -35,8 +37,13 @@ pub struct Device { | |||
pub pres_context: RawGeckoPresContextOwned, | |||
default_values: Arc<ComputedValues>, | |||
viewport_override: Option<ViewportConstraints>, | |||
/// The font size of the root element | |||
root_font_size: AtomicIsize, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add comments on how and when is this set, please.
00e09ce
to
f55a199
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With those, r=me
@@ -35,8 +37,15 @@ pub struct Device { | |||
pub pres_context: RawGeckoPresContextOwned, | |||
default_values: Arc<ComputedValues>, | |||
viewport_override: Option<ViewportConstraints>, | |||
/// The font size of the root element | |||
/// This is set when computing the style of the root | |||
/// element, and used for rem units in other elements |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please mention why it's fine to use it like this, that is:
When computing the style of the root element, there can't be any other style being computed at the same time, given we need the style of the parent to compute everything else.
@@ -73,6 +83,16 @@ impl Device { | |||
&self.default_values | |||
} | |||
|
|||
/// Get the font size of the root element (for rem) | |||
pub fn root_font_size(&self) -> Au { | |||
Au::new(self.root_font_size.load(Ordering::AcqRel) as i32) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These can be Relaxed
, per the above comment.
f55a199
to
ce2237e
Compare
@bors-servo r+ p=2 (contains a second PR, better if they both land together) |
📌 Commit ce2237e has been approved by |
🌲 The tree is currently closed for pull requests below priority 1000, this pull request will be tested once the tree is reopened |
@bors-servo r=emilio |
💡 This pull request was already approved, no need to approve it again. |
📌 Commit ce2237e has been approved by |
🌲 The tree is currently closed for pull requests below priority 1000, this pull request will be tested once the tree is reopened |
Move root_font_size to the device ComputedValues is heap allocated, and the number of CVs grows with the number of elements, so we should keep it small. The root_font_size is the same for the document, so we should stash it on the device and use that instead. Gecko actually just manually walks up the tree here, but we can't do that. A simple AtomicRefcell should be enough. Nothing else can be styled in parallel with the root so the refcell should never panic. <!-- 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/17041) <!-- Reviewable:end -->
☀️ 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-msvc-dev |
MozReview-Commit-ID: 7PzklCUmYpU
MozReview-Commit-ID: 7PzklCUmYpU
MozReview-Commit-ID: 7PzklCUmYpU
MozReview-Commit-ID: 7PzklCUmYpU
MozReview-Commit-ID: 7PzklCUmYpU
MozReview-Commit-ID: 7PzklCUmYpU UltraBlame original commit: 4c561f3ab0343437242986179b9010006ef33437
MozReview-Commit-ID: 7PzklCUmYpU UltraBlame original commit: 4c561f3ab0343437242986179b9010006ef33437
MozReview-Commit-ID: 7PzklCUmYpU UltraBlame original commit: 4c561f3ab0343437242986179b9010006ef33437
ComputedValues is heap allocated, and the number of CVs grows with the number of elements, so we should keep it small. The root_font_size is the same for the document, so we should stash it on the device and use that instead.
Gecko actually just manually walks up the tree here, but we can't do that. A simple AtomicRefcell should be enough.
Nothing else can be styled in parallel with the root so the refcell should never panic.
This change is