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 upInherit the clip chain of IFrame #2875
Conversation
|
|
|
Hrm. Weird. It doesn't seem like this should be necessary. I left an explanation here: #2834 (comment) |
|
Do we want to keep this open? |
|
Apologies! I didn't understand what this PR did before, but now I do. I think this is one way that we can fix the issue. Tomorrow I'll take another look at this. |
|
I updated (or, rather reimplemented) the code on latest master. |
|
Thanks for fixing this and sorry again that I didn't understand this the first time! |
| @@ -169,6 +169,9 @@ pub struct DisplayListFlattener<'a> { | |||
| /// The map of all font instances. | |||
| font_instances: FontInstanceMap, | |||
|
|
|||
| /// The map keeping track of the root clip chains associated with pipelines. | |||
| pipeline_clip_chains: FastHashMap<PipelineId, ClipChainIndex>, | |||
This comment has been minimized.
This comment has been minimized.
mrobinson
Jul 18, 2018
Member
If you want to avoid the cost of hashing here, this can just be a stack. You would push ClipChainIndex(0) for the root pipeline and then push again when processing an iframe element.
This comment has been minimized.
This comment has been minimized.
| @@ -539,6 +543,17 @@ impl<'a> DisplayListFlattener<'a> { | |||
| ), | |||
| ); | |||
|
|
|||
| match clip_and_scroll_ids.clip_node_id { | |||
This comment has been minimized.
This comment has been minimized.
mrobinson
Jul 18, 2018
Member
I think what you want to do here is to simply use the newly added clip node. So
self.pipeline_clip_chains.insert(
iframe_pipeline_id,
self.id_to_index_mapper.get_node_index(info.clip_id)
);
This comment has been minimized.
This comment has been minimized.
kvark
Jul 18, 2018
Author
Member
but that's the whole point of the PR - to take clip_and_scroll_ids into account
| .iter() | ||
| .map(|id| self.id_to_index_mapper.get_clip_node_index(*id)) | ||
| .collect(); | ||
| let parent = match info.parent { |
This comment has been minimized.
This comment has been minimized.
mrobinson
Jul 18, 2018
Member
I think you can map_or_else here:
let parent = info.parent.map_or_else(
|| self.pipeline_clip_chains.get(&pipeline_id).cloned(),
|id| self.id_to_index_mapper.get_clip_node_index(*id))
);
This comment has been minimized.
This comment has been minimized.
mrobinson
Jul 18, 2018
Member
Oh, I see that map_or_else won't wok here with parent accepting an Option. Perhaps it makes sense to always fall back to ClipChainIndex(0).
|
Thanks for the review @mrobinson ! Please take another look. |
|
Looking good, though I still think we should always use the newly added clip node. See below for an explanation. |
| @@ -539,6 +543,16 @@ impl<'a> DisplayListFlattener<'a> { | |||
| ), | |||
| ); | |||
|
|
|||
| let clip_chain_index = match clip_and_scroll_ids.clip_node_id { | |||
This comment has been minimized.
This comment has been minimized.
mrobinson
Jul 18, 2018
Member
Here I think you always want to use the newly added clip node which is represented by info.clip_id. This ensures that contents don't escape the iframe at all. Trying to reach for the parent means that the content might escape the iframe and only be contained by whatever clip happens to be the parent here. If Gecko and Servo want to contain the content to the iframe (which I think they always do), they would end up needing to push an extra clip node. I think that info.clip_id is the correct choice here to ensure consistent behavior.
In the future maybe it makes sense that iframes don't automatically clip, in which case we wouldn't push this clip node and we would in that case look at the clipping node of clip_and_scroll_ids in this spot. That would allow clients to allow iframe contents to escape their rectangles, while still avoiding having to push an extra clip node to prevent it.
This comment has been minimized.
This comment has been minimized.
staktrace
Jul 18, 2018
Contributor
I agree that Gecko at least always wants to contain stuff inside the iframe to the iframe clip. If I'm understanding this right, what @mrobinson is suggesting would fix https://bugzilla.mozilla.org/show_bug.cgi?id=1473940
|
Here is a thing. I tested the following variants on @staktrace reduced test case:
And I'm seeing all these producing the same faulty behavior: content is mostly clipped, except when scrolling. I was able to (wasn't easy!) catch a screenshot of it: So, looks like we are back to square one? The behavior was certainly fixed when I first filed the PR. Something has changed now. |
|
It's possible that there are two different bugs here. I'll test the other STR (from bug 1462955) and see if this patch fixes that. |
|
Confirmed that the build from your try push fixes bug 1462955. So I think this is still worth landing. Bug 1458373 is likely a different root cause. |
|
@staktrace thanks for verifying! |
|
@kvark The try push in the previous comment also fixes the bug |
|
Alright, I changed the code according to @mrobinson suggestion, we had a good try push, and I believe all the review concerns are addressed. Let's not hold this patch for too much longer then. |
|
|
Inherit the clip chain of IFrame ~~This is an experiment to fix #2834 on our side by inheriting the clip chains of the iFrames.~~ Fixes #2834 ~~I really don't like the way it turns out... and the old code got me confused because the `info.clip_node_id` was completely ignored in `flatten_iframe`.~~ @mrobinson please take a look, cc @staktrace <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/2875) <!-- Reviewable:end -->
|
|

kvark commentedJul 6, 2018
•
edited
This is an experiment to fix #2834 on our side by inheriting the clip chains of the iFrames.Fixes #2834
I really don't like the way it turns out... and the old code got me confused because theinfo.clip_node_idwas completely ignored inflatten_iframe.@mrobinson please take a look, cc @staktrace
This change is