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

LibWeb: Support content-visibility css + resolve fixme #267

Merged
merged 2 commits into from
Jul 19, 2024

Conversation

EdwinHoksberg
Copy link
Contributor

No description provided.

@EdwinHoksberg EdwinHoksberg requested a review from AtkinsSJ as a code owner June 24, 2024 10:26
@AtkinsSJ
Copy link
Member

I'll try and look at this later today. I think I spotted a couple of small issues but I've only had time to look through it on my phone. 😅

Comment on lines 785 to 907
"valid-identifiers": [
"visible",
"auto",
"hidden"
]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You already defined an enum for these, so you can use it here:

Suggested change
"valid-identifiers": [
"visible",
"auto",
"hidden"
]
"valid-types": [
"content-visibility"
]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat ✨

@@ -338,7 +338,7 @@ void TreeBuilder::create_layout_tree(DOM::Node& dom_node, TreeBuilder::Context&
VERIFY(!element.needs_style_update());
style = element.computed_css_values();
display = style->display();
if (display.is_none())
if (display.is_none() || element.has_parent_with_content_visibility_hidden())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like the wrong approach. Instead of recursing into the children, then walking back up to the parent, to decide whether to generate layout boxes for them, we could just not consider the children if the current element has content-visibility: hidden.

Further down in this function there's a check for dom_node.has_children(), and that seems like a good place to add a check for style->content_visibility() and skip the children altogether. You might also need to adjust the checks for adding pseudo-elements, as I'm not sure if they're affected by content-visibility.

(Then the whole has_parent_with_content_visibility_hidden() method can be removed.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a lot better yes, I was actually looking for something like that but I totally overlooked that part 😅 Let me know if I implemented it correctly now.
And yes, pseudo elements should also be invisible, I've added the check there too.

padding: 16px;
content-visibility: hidden;
}
</style><div><span>I am not visible
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's worth also testing that text content directly inside the <div> is also hidden. eg:

Suggested change
</style><div><span>I am not visible
</style><div>I am not visible <span>and nor am I

Maybe also have CSS that gives div::before some content just to make sure that doesn't appear in the layout either.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good idea!

@EdwinHoksberg EdwinHoksberg force-pushed the css-content-visibility branch from 3968698 to 35400ee Compare June 27, 2024 20:06
@EdwinHoksberg EdwinHoksberg requested a review from AtkinsSJ June 27, 2024 20:14
Copy link
Member

@AtkinsSJ AtkinsSJ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, sorry for the delay! I've had a busy couple of weeks. 😅

There's a conflict that needs fixing, but otherwise this should be good to go.

@EdwinHoksberg EdwinHoksberg force-pushed the css-content-visibility branch from 35400ee to f498be5 Compare July 18, 2024 20:00
@EdwinHoksberg EdwinHoksberg requested a review from AtkinsSJ July 18, 2024 20:01
@EdwinHoksberg EdwinHoksberg force-pushed the css-content-visibility branch from f498be5 to 360749d Compare July 19, 2024 07:30
Copy link
Member

@AtkinsSJ AtkinsSJ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's gooooo!

@AtkinsSJ AtkinsSJ merged commit 0ae0481 into LadybirdBrowser:master Jul 19, 2024
6 checks passed
@EdwinHoksberg EdwinHoksberg deleted the css-content-visibility branch July 26, 2024 07:13
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.

2 participants