Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upincremental restyle: Hoist more stuff to Element #13951
Conversation
highfive
commented
Oct 28, 2016
|
Heads up! This PR modifies the following files:
|
highfive
commented
Oct 28, 2016
|
@bors-servo try |
incremental restyle: Hoist more stuff to Element The patch here hoists pseudo-element handling onto ThreadSafeLayoutElement. I have another patch which hoists stuff from TNode to TElement, but want to make sure this patch passes try first. <!-- 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/13951) <!-- Reviewable:end -->
|
|
|
The next patch is 99% done but I may not finish it tonight. r? @emilio on this one. |
incremental restyle: Hoist most styling functionality from TNode to TElement This is a continuation of the work in #13951. I'm separating it out into a separate PR since the aforementioned patch has a green try run and this one doesn't yet. <!-- 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/13956) <!-- Reviewable:end -->
|
r=me |
| fn debug_id(self) -> usize; | ||
|
|
||
| /// Returns an iterator over this node's children. | ||
| fn children(&self) -> LayoutIterator<Self::ChildrenIterator>; | ||
|
|
||
| /// If this is an element, accesses the element data. Fails if this is not an element node. | ||
| /// Returns a ThreadSafeLayoutElement this is an element, None otherwise. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
|
||
| /// Returns true if this node contributes content. This is used in the implementation of | ||
| /// `empty_cells` per CSS 2.1 § 17.6.1.1. | ||
| fn is_content(&self) -> bool { |
This comment has been minimized.
This comment has been minimized.
emilio
Oct 28, 2016
Member
Now this can be written just as self.get_pseudo_element_type() == PseudoElementType::Normal, or self.type_id().is_some().
Not a big deal, but maybe worth doing.
This comment has been minimized.
This comment has been minimized.
| } | ||
| } | ||
|
|
||
| fn selected_style(&self) -> Arc<ServoComputedValues> { |
This comment has been minimized.
This comment has been minimized.
emilio
Oct 28, 2016
Member
I think having the context parameter here was sort of intended for consistency, but it's fine too.
This comment has been minimized.
This comment has been minimized.
bholley
Oct 28, 2016
Author
Contributor
Yeah I was kinda on the fence about it, but decided to opt for removal, since we can always add it back if we need it.
| @@ -757,46 +779,48 @@ impl<'ln> ServoThreadSafeLayoutNode<'ln> { | |||
| } | |||
| } | |||
|
|
|||
| // NB: The implementation here is a bit tricky because elements implementing | |||
| // pseudos are supposed to return false for is_element(). | |||
This comment has been minimized.
This comment has been minimized.
emilio
Oct 28, 2016
Member
Yeah, I'd like this to change. In every other browser a pseudo-element is represented as an Element. Of course, not in the scope of this PR.
This comment has been minimized.
This comment has been minimized.
bholley
Oct 28, 2016
Author
Contributor
Well, other browser elements put NAC in the DOM, which Servo explicitly avoids doing. But yeah, we might be able to make the intra-layout abstraction cleaner. Agreed on out of scope.
| /// The pseudo-element type, with (optionally), | ||
| /// an specified display value to override the stylesheet. | ||
| /// The pseudo-element type, with (optionally) | ||
| /// a specified display value to override the stylesheet. |
This comment has been minimized.
This comment has been minimized.
emilio
Oct 28, 2016
Member
arrg, Bobby the dictionary strikes again to correct my typos! :P
Thanks for doing this.
This comment has been minimized.
This comment has been minimized.
| let layout_node = match *pseudo { | ||
| Some(PseudoElement::Before) => layout_node.get_before_pseudo(), | ||
| Some(PseudoElement::After) => layout_node.get_after_pseudo(), | ||
| let layout_el = requested_node.to_threadsafe().as_element().unwrap(); |
This comment has been minimized.
This comment has been minimized.
emilio
Oct 28, 2016
Member
Probably worth making this function take an Element directly. Can be a followup if it's too much pain.
This comment has been minimized.
This comment has been minimized.
bholley
Oct 28, 2016
Author
Contributor
Turns out to be kinda hard to do because LayoutElement doesn't exist until #13956, and the opaque representations are all Node-y. We can do it later.
| self.pseudo == PseudoElementType::Normal | ||
| } | ||
|
|
||
| fn is_text_node(&self) -> bool { |
This comment has been minimized.
This comment has been minimized.
emilio
Oct 28, 2016
Member
Probably we should panic here (or similar) given we're doing a totally unnecessary check.
This comment has been minimized.
This comment has been minimized.
bholley
Oct 28, 2016
Author
Contributor
I think we can actually just remove this trait impl entirely.
| false | ||
| } | ||
|
|
||
| fn needs_layout(&self) -> bool { true } |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| } | ||
|
|
||
| fn needs_layout(&self) -> bool { | ||
| self.pseudo != PseudoElementType::Normal || | ||
| self.node.is_element() || self.node.is_text_node() | ||
| self.node.is_text_node() || self.node.is_element() |
This comment has been minimized.
This comment has been minimized.
emilio
Oct 28, 2016
Member
We shouldn't be creating ThreadSafeLayoutNodes for other kind of nodes now right? So this function can pretty much go away I think.
This comment has been minimized.
This comment has been minimized.
bholley
Oct 28, 2016
Author
Contributor
We still can. The iterator returned by children() operates on nodes of type Self, and then filters them using needs_layout before returning them. So if there's a comment node, we'll still create a ServoThreadSafeLayoutNode for it, just not return it to the traversal code.
So I think we need this.
incremental restyle: Hoist most styling functionality from TNode to TElement This is a continuation of the work in #13951. I'm separating it out into a separate PR since the aforementioned patch has a green try run and this one doesn't yet. <!-- 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/13956) <!-- Reviewable:end -->
incremental restyle: Hoist most styling functionality from TNode to TElement This is a continuation of the work in #13951. I'm separating it out into a separate PR since the aforementioned patch has a green try run and this one doesn't yet. <!-- 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/13956) <!-- Reviewable:end -->
|
@bors-servo r=emilio p=1 |
|
|
incremental restyle: Hoist more stuff to Element The patch here hoists pseudo-element handling onto ThreadSafeLayoutElement. I have another patch which hoists stuff from TNode to TElement, but want to make sure this patch passes try first. <!-- 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/13951) <!-- Reviewable:end -->
|
@bors-servo force clean retry |
incremental restyle: Hoist more stuff to Element The patch here hoists pseudo-element handling onto ThreadSafeLayoutElement. I have another patch which hoists stuff from TNode to TElement, but want to make sure this patch passes try first. <!-- 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/13951) <!-- Reviewable:end -->
incremental restyle: Hoist most styling functionality from TNode to TElement This is a continuation of the work in #13951. I'm separating it out into a separate PR since the aforementioned patch has a green try run and this one doesn't yet. <!-- 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/13956) <!-- Reviewable:end -->
|
|
|
|
|
@bors-servo retry |
incremental restyle: Hoist more stuff to Element The patch here hoists pseudo-element handling onto ThreadSafeLayoutElement. I have another patch which hoists stuff from TNode to TElement, but want to make sure this patch passes try first. <!-- 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/13951) <!-- Reviewable:end -->
|
|
|
@bors-servo retry
|
incremental restyle: Hoist more stuff to Element The patch here hoists pseudo-element handling onto ThreadSafeLayoutElement. I have another patch which hoists stuff from TNode to TElement, but want to make sure this patch passes try first. <!-- 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/13951) <!-- Reviewable:end -->
incremental restyle: Hoist most styling functionality from TNode to TElement This is a continuation of the work in #13951. I'm separating it out into a separate PR since the aforementioned patch has a green try run and this one doesn't yet. <!-- 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/13956) <!-- Reviewable:end -->
|
|
incremental restyle: Hoist most styling functionality from TNode to TElement This is a continuation of the work in #13951. I'm separating it out into a separate PR since the aforementioned patch has a green try run and this one doesn't yet. <!-- 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/13956) <!-- Reviewable:end -->
incremental restyle: Hoist most styling functionality from TNode to TElement This is a continuation of the work in #13951. I'm separating it out into a separate PR since the aforementioned patch has a green try run and this one doesn't yet. <!-- 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/13956) <!-- Reviewable:end -->
incremental restyle: Hoist most styling functionality from TNode to TElement This is a continuation of the work in #13951. I'm separating it out into a separate PR since the aforementioned patch has a green try run and this one doesn't yet. <!-- 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/13956) <!-- Reviewable:end -->
incremental restyle: Hoist most styling functionality from TNode to TElement This is a continuation of the work in #13951. I'm separating it out into a separate PR since the aforementioned patch has a green try run and this one doesn't yet. <!-- 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/13956) <!-- Reviewable:end -->
incremental restyle: Hoist most styling functionality from TNode to TElement This is a continuation of the work in #13951. I'm separating it out into a separate PR since the aforementioned patch has a green try run and this one doesn't yet. <!-- 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/13956) <!-- Reviewable:end -->
incremental restyle: Hoist most styling functionality from TNode to TElement This is a continuation of the work in #13951. I'm separating it out into a separate PR since the aforementioned patch has a green try run and this one doesn't yet. <!-- 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/13956) <!-- Reviewable:end -->
incremental restyle: Hoist most styling functionality from TNode to TElement This is a continuation of the work in #13951. I'm separating it out into a separate PR since the aforementioned patch has a green try run and this one doesn't yet. <!-- 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/13956) <!-- Reviewable:end -->
incremental restyle: Hoist most styling functionality from TNode to TElement This is a continuation of the work in #13951. I'm separating it out into a separate PR since the aforementioned patch has a green try run and this one doesn't yet. <!-- 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/13956) <!-- Reviewable:end -->
bholley commentedOct 28, 2016
•
edited by larsbergstrom
The patch here hoists pseudo-element handling onto ThreadSafeLayoutElement. I have another patch which hoists stuff from TNode to TElement, but want to make sure this patch passes try first.
This change is