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

Implement overflow:clip #35103

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

longvatrong111
Copy link
Contributor

@longvatrong111 longvatrong111 commented Jan 21, 2025

This PR implements overflow:clip

  • After enable overflow:clip overflow-clip-margin and overflow-clip-box in Stylo, the parser works well
  • Some test cases require overflow-clip-margin compounded with other CSS properties still fail.

Stylo PR: servo/stylo#111

Test cases:
servo/tests/wpt/tests/css/css-overflow/

cc: @xiaochengh


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #___ (GitHub issue number if applicable)
  • There are tests for these changes OR
  • These changes do not require tests because ___

Signed-off-by: batu_hoang <[email protected]>
@longvatrong111 longvatrong111 changed the title WIP: Implement overflow:clip Implement overflow:clip Jan 21, 2025
style_dom = { git = "https://github.com/servo/stylo", package = "dom", branch = "2025-01-02" }
style_traits = { git = "https://github.com/servo/stylo", branch = "2025-01-02", features = ["servo"] }
style_malloc_size_of = { package = "malloc_size_of", git = "https://github.com/servo/stylo", branch = "2025-01-02", features = ["servo"] }
style = { git = "https://github.com/servo/stylo", rev = "f54c445dc4ccd1ce20016636dcb85981a82354eb", features = ["servo"] }
Copy link
Contributor

Choose a reason for hiding this comment

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

why revert?
if you need Clip enum, maybe add feature gecko, instead of revert.

Copy link
Contributor

Choose a reason for hiding this comment

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

rev is not reverting anything, if that's what you mean. It's a git revision: https://git-scm.com/docs/gitrevisions

style_dom = { git = "https://github.com/servo/stylo", package = "dom", branch = "2025-01-02" }
style_traits = { git = "https://github.com/servo/stylo", branch = "2025-01-02", features = ["servo"] }
style_malloc_size_of = { package = "malloc_size_of", git = "https://github.com/servo/stylo", branch = "2025-01-02", features = ["servo"] }
style = { git = "https://github.com/servo/stylo", rev = "f54c445dc4ccd1ce20016636dcb85981a82354eb", features = ["servo"] }
Copy link
Contributor

Choose a reason for hiding this comment

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

rev is not reverting anything, if that's what you mean. It's a git revision: https://git-scm.com/docs/gitrevisions

Comment on lines +1704 to +1707
_ if (style.get_box().overflow_x != StyleOverflow::Visible &&
style.get_box().overflow_x != StyleOverflow::Clip) ||
(style.get_box().overflow_y != StyleOverflow::Visible &&
style.get_box().overflow_y != StyleOverflow::Clip) ||
Copy link
Contributor

Choose a reason for hiding this comment

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

This is legacy layout, so I wouldn't bother with overflow: clip here.

But if you are changing it, then at least use is_scrollable():

Suggested change
_ if (style.get_box().overflow_x != StyleOverflow::Visible &&
style.get_box().overflow_x != StyleOverflow::Clip) ||
(style.get_box().overflow_y != StyleOverflow::Visible &&
style.get_box().overflow_y != StyleOverflow::Clip) ||
_ if style.get_box().overflow_x.is_scrollable() ||
style.get_box().overflow_y.is_scrollable() ||

Or in fact both axes must have the same scrollability, so just checking one should suffice.

Comment on lines +1395 to +1396
if self.style.effective_overflow().x != ComputedOverflow::Clip &&
self.style.effective_overflow().y != ComputedOverflow::Clip
Copy link
Contributor

Choose a reason for hiding this comment

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

Please store self.style.effective_overflow() in a variable.

Comment on lines +205 to +207
let clip_margin = self.style.get_margin().overflow_clip_margin;
clip_rect.size.width += Au::from(clip_margin);
clip_rect.size.height += Au::from(clip_margin);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
let clip_margin = self.style.get_margin().overflow_clip_margin;
clip_rect.size.width += Au::from(clip_margin);
clip_rect.size.height += Au::from(clip_margin);
let clip_margin = Au::from(self.style.get_margin().overflow_clip_margin);
clip_rect.size.width += clip_margin;
clip_rect.size.height += clip_margin;

@@ -190,6 +191,39 @@ impl BoxFragment {
)
}

pub fn clip_overflow(&self, containing_block_rect: &PhysicalRect<Au>) -> PhysicalRect<Au> {
// Area that the box is allowed to paint in.
let mut clip_rect = match self.style.get_box()._servo_overflow_clip_box {
Copy link
Contributor

Choose a reason for hiding this comment

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

If you are enabling overflow-clip-box-inline/block then I would check these here.
Otherwise don't enable them.

@@ -1,2 +1,2 @@
[clip-001.html]
expected: FAIL
expected: PASS

Choose a reason for hiding this comment

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

You can remove this ini file entirely if all subtests pass.

Ditto below.

@mrobinson
Copy link
Member

Some test cases require overflow-clip-margin compounded with other CSS properties still fail.

Is it possible to get a quick rundown on which test cases fail and why? I don't think it is critical to cover every test case, but it would be good to have an understand of what is causing the rest of the tests to fail.

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.

5 participants