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

Move root_font_size to the device #17041

Merged
merged 2 commits into from May 26, 2017
Merged

Conversation

Manishearth
Copy link
Member

@Manishearth Manishearth commented May 25, 2017

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 Reviewable

@highfive
Copy link

Heads up! This PR modifies the following files:

  • @bholley: components/style/servo/media_queries.rs, components/style/properties/gecko.mako.rs, components/style/properties/longhand/font.mako.rs, components/style/values/specified/length.rs, components/style/properties/properties.mako.rs and 1 more
  • @emilio: components/style/servo/media_queries.rs, components/style/properties/gecko.mako.rs, components/style/properties/longhand/font.mako.rs, components/style/values/specified/length.rs, components/style/properties/properties.mako.rs and 1 more

@highfive
Copy link

warning Warning warning

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

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label May 25, 2017
@Manishearth
Copy link
Member Author

r? @emilio

@Manishearth
Copy link
Member Author

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>,
Copy link
Member

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?

@emilio
Copy link
Member

emilio commented May 25, 2017

Also needs the servo side changes

@@ -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,
Copy link
Member

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.

Copy link
Member

@emilio emilio left a 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
Copy link
Member

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)
Copy link
Member

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.

@Manishearth
Copy link
Member Author

@bors-servo r+ p=2

(contains a second PR, better if they both land together)

@bors-servo
Copy link
Contributor

📌 Commit ce2237e has been approved by Manishearth

@bors-servo
Copy link
Contributor

🌲 The tree is currently closed for pull requests below priority 1000, this pull request will be tested once the tree is reopened

@highfive highfive assigned Manishearth and unassigned emilio May 25, 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-awaiting-review There is new code that needs to be reviewed. labels May 25, 2017
@Manishearth
Copy link
Member Author

@bors-servo r=emilio

@bors-servo
Copy link
Contributor

💡 This pull request was already approved, no need to approve it again.

@bors-servo
Copy link
Contributor

📌 Commit ce2237e has been approved by emilio

@bors-servo
Copy link
Contributor

🌲 The tree is currently closed for pull requests below priority 1000, this pull request will be tested once the tree is reopened

@highfive highfive assigned emilio and unassigned Manishearth May 25, 2017
@bors-servo
Copy link
Contributor

⌛ Testing commit ce2237e with merge a961f6a...

bors-servo pushed a commit that referenced this pull request May 25, 2017
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 -->
@bors-servo
Copy link
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-msvc-dev
Approved by: emilio
Pushing a961f6a to master...

@bors-servo bors-servo merged commit ce2237e into servo:master May 26, 2017
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label May 26, 2017
weilonge pushed a commit to fx-dev-playground/gecko that referenced this pull request May 26, 2017
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request May 26, 2017
aethanyc pushed a commit to aethanyc/gecko-dev that referenced this pull request May 26, 2017
Manishearth pushed a commit to Manishearth/gecko-dev that referenced this pull request May 27, 2017
JerryShih pushed a commit to JerryShih/gecko-dev that referenced this pull request May 30, 2017
@Manishearth Manishearth deleted the root_font_size branch May 7, 2019 22:43
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Oct 1, 2019
MozReview-Commit-ID: 7PzklCUmYpU

UltraBlame original commit: 4c561f3ab0343437242986179b9010006ef33437
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Oct 1, 2019
MozReview-Commit-ID: 7PzklCUmYpU

UltraBlame original commit: 4c561f3ab0343437242986179b9010006ef33437
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Oct 1, 2019
MozReview-Commit-ID: 7PzklCUmYpU

UltraBlame original commit: 4c561f3ab0343437242986179b9010006ef33437
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.

None yet

5 participants