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
style: Move all origin-specific cascade data to PerOriginCascadeData #18017
Conversation
Heads up! This PR modifies the following files:
|
r? @emilio |
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.
Looks pretty straight-forward. r=me with the nits addressed, thanks!
@@ -1635,6 +1635,8 @@ impl CascadeData { | |||
} | |||
} | |||
|
|||
/// Iterator over `PerOriginCascadeData`, from highest level (user) to lowest | |||
/// (user agent). |
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 a comment to note that we rely on that to get animations, and potentially other stuff?
components/selectors/bloom.rs
Outdated
} | ||
} | ||
|
||
pub struct BloomStorageU8 { |
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.
needs docs.
|
||
#[inline] | ||
fn slot_is_empty(&self, index: usize) -> bool { | ||
let bit = 1 << (index % 8); |
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.
nit: maybe create a method for this? presumably not worth the effort.
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.
Yeah, I almost did, then decided it wasn't worth it.
components/selectors/bloom.rs
Outdated
*slot == 0xff | ||
pub trait BloomStorage : Clone + Default { | ||
fn slot_is_empty(&self, index: usize) -> bool; | ||
fn adjust_slot(&mut self, index: usize, increment: bool); |
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.
Could you mention what are these functions expected to do?
I found adjust
to be a little not too descriptive... But I can't think of a better name that isn't super-long, so, maybe something simple like:
Either increment or decrement the slot at `index`.
Would be helpful.
components/selectors/bloom.rs
Outdated
@@ -237,6 +291,10 @@ fn hash2(hash: u32) -> u32 { | |||
fn create_and_insert_some_stuff() { | |||
let mut bf = BloomFilter::new(); | |||
|
|||
assert!(ARRAY_SIZE % 8 == 0, |
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.
I think you can static-assert this with transmute or something like that...
transmute::<[u8; 1 + ARRAY_SIZE % 8], [u8; 1]>(..)
components/style/stylist.rs
Outdated
/// Returns the number of entries in invalidation maps. | ||
pub fn num_invalidations(&self) -> usize { | ||
self.cascade_data.iter_origins() | ||
.map(|d| d.invalidation_map.len()).sum() |
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.
nit: I'd move sum
, and maybe iter_origins
, to its own line, but no huge deal.
components/style/stylist.rs
Outdated
self.style_attribute_dependency | ||
self.cascade_data | ||
.iter_origins() | ||
.map(|d| d.style_attribute_dependency) |
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.
nit: just any(|d| d.style_attribute_dependency)
.
components/style/stylist.rs
Outdated
d.attribute_dependencies | ||
.might_contain_hash(local_name.get_hash()) | ||
}) | ||
.any(|b| b) |
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.
ditto.
components/style/stylist.rs
Outdated
self.cascade_data | ||
.iter_origins() | ||
.map(|d| d.state_dependencies.intersects(state)) | ||
.any(|b| b) |
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.
ditto
components/style/stylist.rs
Outdated
self.cascade_data | ||
.iter_origins() | ||
.map(|d| d.mapped_ids.might_contain_hash(id.get_hash())) | ||
.any(|b| b) |
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.
ditto
components/selectors/bloom.rs
Outdated
#[inline] | ||
fn adjust_slot(&mut self, index: usize, increment: bool) { | ||
let slot = &mut self.counters[index]; | ||
if *slot == 0xff { // full |
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.
Err, this needs to be !=
. Travis is red because of this.
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.
That is probably why my try run is all orange. :-)
@bors-servo r=emilio |
📌 Commit 6cbe552 has been approved by |
style: Move all origin-specific cascade data to PerOriginCascadeData <!-- Please describe your changes on the following line: --> This is a preliminary refactoring in preparation for only rebuilding cascade data for origins that have a change. https://bugzilla.mozilla.org/show_bug.cgi?id=1382925 --- <!-- 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 - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- 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/18017) <!-- Reviewable:end -->
☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, windows-msvc-dev |
This is a preliminary refactoring in preparation for only rebuilding cascade data for origins that have a change. https://bugzilla.mozilla.org/show_bug.cgi?id=1382925
./mach build -d
does not report any errors./mach test-tidy
does not report any errorsThis change is