-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Set vector properties via iterator in stylo #16721
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.
Generally looks reasonable, but I want to know why the take()
business is needed. It adds a fair amount of complexity, which I think should not be needed.
specified_value, | ||
computed, | ||
inherited_style.get_font()); | ||
% if property.is_vector and product == "gecko": |
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.
Can we just make the same API for servo and call collect inside the servo function?
computed, | ||
inherited_style.get_font()); | ||
% if property.is_vector and product == "gecko": | ||
let mut s = context.mutate_style().take_${data.current_style_struct.name_lower}(); |
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.
Why exactly is all this take business needed? I don't see any reason why it should be, right?
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.
(we talked on IRC, and yes, this is needed. can you leave a comment here?)
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 guess we rely on the property that a vector property doesn't access its own style struct to compute itself, don't we? Let's have it clearly documented.
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.
(Well, actually I guess they can use self
, so we'd be good there too).
In general I don't love the complexity this patch introduces overall, but since I don't have a better suggestion right now, other than the other comments...
/// | ||
/// This lets us build arcs that we can mutate before | ||
/// freezing, without needing to change the allocation | ||
pub struct UniqueArc<T: ?Sized>(Arc<T>); |
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.
Let's move this out of here, to keep this as close as the original arc.rs
as possible.
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.
Meh, actually, I guess it's fine, and being here allows using the private member without unsafety or exposing extra stuff, so...
for (servo, gecko) in v.0.into_iter().zip(self.gecko.mTransitions.iter_mut()) { | ||
let v = v.into_iter(); | ||
|
||
if v.len() != 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.
nit: Does ExactSizeIterator
support is_empty
? If so, let's use it here.
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.
Nope, it's unstable
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.
Ok, r=me with the nits and the path for servo being made the same (should be a one-liner in the property code).
v: I) | ||
where I: IntoIterator<Item = longhands::${shorthand}_position_${orientation[0]}::computed_value::single_value::T>, | ||
I::IntoIter: ExactSizeIterator | ||
{ |
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.
Indentations is off here.
pub fn set_${shorthand}_image<I>(&mut self, images: I, cacheable: &mut bool) | ||
where I: IntoIterator<Item = longhands::${shorthand}_image::computed_value::single_value::T>, | ||
I::IntoIter: ExactSizeIterator | ||
{ |
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.
and here (and below)
I::IntoIter: ExactSizeIterator + Clone | ||
{ | ||
let v = v.into_iter(); | ||
debug_assert!(v.len() != 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.
is_empty. also in all the similar use-cases below
/// | ||
/// This lets us build arcs that we can mutate before | ||
/// freezing, without needing to change the allocation | ||
pub struct UniqueArc<T: ?Sized>(Arc<T>); |
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.
Meh, actually, I guess it's fine, and being here allows using the private member without unsafety or exposing extra stuff, so...
7f3eb81
to
ed0b058
Compare
@bors-servo r=emilio |
📌 Commit ed0b058 has been approved by |
🔒 Merge conflict |
MozReview-Commit-ID: I7oOpYhVP5S
MozReview-Commit-ID: GwOw0HaC9S7
@bors-servo r=emilio |
📌 Commit 8bc277b has been approved by |
⌛ Testing commit 8bc277b with merge e2b6e9b0ee64839db4fd3425e7c6f0f6cb29d202... |
💔 Test failed - linux-rel-css |
@bors-servo r=emilio |
📌 Commit 33fb27c has been approved by |
Set vector properties via iterator in stylo https://bugzilla.mozilla.org/show_bug.cgi?id=1360882 Avoids transient allocations <!-- 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/16721) <!-- 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 |
https://bugzilla.mozilla.org/show_bug.cgi?id=1360882
Avoids transient allocations
This change is