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

Box with overflow:hidden cut inner div with absolute position by content edge, not by padding edge #16576

Closed
ocerman opened this issue Apr 23, 2017 · 17 comments

Comments

@ocerman
Copy link

@ocerman ocerman commented Apr 23, 2017

Tested on Windows 8.1 x64

servo-overflow

<html>
	<body>
		<style>
			#box{
				background-color: #080b0c;
				height: 100px;
				overflow: hidden;
				padding: 0 15px;
				position: relative;
			}
			#inside {
				position: absolute;
				right: 0px;
				width: 100px;
				height: 100%;
				background: red;
			}
		</style>
		<div id="box">
			<div id="inside">
			</div>
		</div>
	</body>
</html>
@aacunningham
Copy link
Contributor

@aacunningham aacunningham commented Apr 28, 2017

What's the best way to recreate these manual testcases? Would it be to create a wpt? Or just create a html file and point servo to it?

@jdm
Copy link
Member

@jdm jdm commented Apr 28, 2017

@aacunningham It's easiest to create a local html file and point Servo at it. To submit an actual fix, it's recommended to convert it into a reftest as part of the automated testsuite.

@aacunningham
Copy link
Contributor

@aacunningham aacunningham commented Apr 28, 2017

After reading through some of the spec on block widths, learning some lingo, and reading a bit of code, I think I'd like to take this on. Do I assign myself with highfive or through you, @jdm?

@KiChjang KiChjang added the C-assigned label Apr 28, 2017
@sciguyryan
Copy link

@sciguyryan sciguyryan commented Apr 29, 2017

Is it possible that issue #16559 is also related to this since they do seem to have some traits in common?

@jdm
Copy link
Member

@jdm jdm commented Apr 29, 2017

I am doubtful.

@aacunningham
Copy link
Contributor

@aacunningham aacunningham commented Apr 29, 2017

Same, since that issue seems to apply more to the hover action and not an issue with the rendered width of boxes. I'm about to do some debugging today, but I'm going to start my look in the width calculations for absolute nonreplaced blocks and see where that gets me

Edit: that or look into how overflow is handled, who knows

@jdm
Copy link
Member

@jdm jdm commented Apr 29, 2017

https://github.com/servo/servo/wiki/Getting-started-with-layout may have tips to help you understand the code a bit better.

@jdm
Copy link
Member

@jdm jdm commented Apr 29, 2017

Additionally, we have https://github.com/servo/servo/tree/master/etc/layout_viewer which can help break down what happens in which part of layout for a given testcase.

@aacunningham
Copy link
Contributor

@aacunningham aacunningham commented Apr 29, 2017

Don't think I've read that one yet, thanks!

@jdm
Copy link
Member

@jdm jdm commented Apr 29, 2017

I retract my earlier doubt. @sciguyryan is right; this looks like it's a regression from #16336 as well.

@jdm
Copy link
Member

@jdm jdm commented Apr 29, 2017

@aacunningham
Copy link
Contributor

@aacunningham aacunningham commented Apr 29, 2017

I probably shouldn't have had any doubt since I'm pretty new to this, but also retracted. What's the best way moving forward with this ticket then? Would it make more sense to have a new issue made that's a little more overarching, or is this issue fine? And since mrobinson would know the most about how the regression was introduced, would it make more sense to have them take over, or is it fine if I keep looking into the issue?

@jdm
Copy link
Member

@jdm jdm commented Apr 29, 2017

Clearly the cause of regression is the same, but the fix for both issues might be different, so I don't think it makes sense to file an overarching one. I don't think there's anything wrong with you continuing to investigate this weekend; if you come up with any conclusions then perhaps @mrobinson could provide useful input on Monday.

@aacunningham
Copy link
Contributor

@aacunningham aacunningham commented Apr 29, 2017

Perfect, thanks a lot!

@aacunningham
Copy link
Contributor

@aacunningham aacunningham commented Apr 30, 2017

Alright, here's what I've discovered:

Using -Z dump-display-list, I got this info:

Pre #16336

┌ Display List
│  ├─ Items
│  │  ├─ PushStackingContext(StackingContext at TypedRect(1920px×1043px at (0px,0px)) with overflow TypedRect(1920px×1043px at (0px,0px)): StackingContextId(0)) StackingContext: StackingContextId(0) ScrollRoot: ScrollRootId(0)
│  │  ├─ SolidColor rgba(0, 0, 0, 0) @ TypedRect(1920px×1043px at (0px,0px)) ClippingRegion::Max StackingContext: StackingContextId(0) ScrollRoot: ScrollRootId(0)
│  │  ├─ SolidColor rgba(0, 0, 0, 0) @ TypedRect(1904px×100px at (8px,8px)) ClippingRegion::Max StackingContext: StackingContextId(0) ScrollRoot: ScrollRootId(0)
│  │  ├─ PushStackingContext(StackingContext at TypedRect(1904px×100px at (8px,8px)) with overflow TypedRect(1904px×100px at (0px,0px)): StackingContextId(139840704336464)) StackingContext: StackingContextId(139840704336464) ScrollRoot: ScrollRootId(0)
│  │  ├─ SolidColor rgba(0.03137255, 0.043137256, 0.047058824, 1) @ TypedRect(1904px×100px at (0px,0px)) ClippingRegion::Max StackingContext: StackingContextId(139840704336464) ScrollRoot: ScrollRootId(0)
│  │  ├─ SolidColor rgba(1, 0, 0, 1) @ TypedRect(100px×100px at (1804px,0px)) ClippingRegion(Rect=TypedRect(1904px×100px at (0px,0px)), Complex=[]) StackingContext: StackingContextId(139840704336608) ScrollRoot: ScrollRootId(0)
│  │  ├─ PopStackingContext(StackingContextId(139840704336464) StackingContext: StackingContextId(139840704336464) ScrollRoot: ScrollRootId(0)
│  │  └─ PopStackingContext(StackingContextId(0) StackingContext: StackingContextId(0) ScrollRoot: ScrollRootId(0)

Post #16336

┌ Display List
│  ├─ Items
│  │  ├─ PushStackingContext(StackingContext at TypedRect(1920px×1043px at (0px,0px)) with overflow TypedRect(1920px×1043px at (0px,0px)): StackingContextId(0)) StackingContext: StackingContextId(0) ScrollRoot: ScrollRootId(0)
│  │  ├─ SolidColor rgba(0, 0, 0, 0) @ TypedRect(1920px×1043px at (0px,0px)) ClippingRegion::Max StackingContext: StackingContextId(0) ScrollRoot: ScrollRootId(0)
│  │  ├─ SolidColor rgba(0, 0, 0, 0) @ TypedRect(1904px×100px at (8px,8px)) ClippingRegion::Max StackingContext: StackingContextId(0) ScrollRoot: ScrollRootId(0)
│  │  ├─ PushStackingContext(StackingContext at TypedRect(1904px×100px at (8px,8px)) with overflow TypedRect(1904px×100px at (0px,0px)): StackingContextId(140606955442768)) StackingContext: StackingContextId(140606955442768) ScrollRoot: ScrollRootId(0)
│  │  ├─ PushScrollRoot(ScrollRoot { id: ScrollRootId(140606955442768), parent_id: ScrollRootId(0), clip: ClippingRegion(Rect=TypedRect(1874px×100px at (0px,0px)), Complex=[]), content_rect: TypedRect(1874px×100px at (15px,0px)) } StackingContext: StackingContextId(0) ScrollRoot: ScrollRootId(0)
│  │  ├─ SolidColor rgba(0.03137255, 0.043137256, 0.047058824, 1) @ TypedRect(1904px×100px at (0px,0px)) ClippingRegion::Max StackingContext: StackingContextId(140606955442768) ScrollRoot: ScrollRootId(0)
│  │  ├─ SolidColor rgba(1, 0, 0, 1) @ TypedRect(100px×100px at (1804px,0px)) ClippingRegion::Max StackingContext: StackingContextId(140606955442912) ScrollRoot: ScrollRootId(140606955442768)
│  │  ├─ PopStackingContext(StackingContextId(140606955442768) StackingContext: StackingContextId(140606955442768) ScrollRoot: ScrollRootId(0)
│  │  └─ PopStackingContext(StackingContextId(0) StackingContext: StackingContextId(0) ScrollRoot: ScrollRootId(0)

Diffed the two, found the main difference being that the new code adds a ScrollRoot. I'm not entirely sure what ScrollRoot is, BUT, if it's a representation of the scroll containers referenced in this CSS spec, then it's appropriate to have ScrollRoot added. So correct me if I'm wrong, but I think the issue isn't that ScrollRoot is being added, but that there is something wrong in the calculations for ScrollRoot; Post #16336, ScrollRoot's ClippingRegion is 30px smaller than it should (from the 15px padding).

Going into this, I found that the ClippingRegion for the new ScrollRoot isn't based on the border box but the content box (which is the border box but with the padding added, not sure if those are technical terms, just variable names). So I modified the code that added the padding and the test case is passing now. I'm not sure if that's the correct solution, but it does work. Trying to run tests, but they run pretty slowly on this machine so it might be easier to have the CI systems handle it.

If none of this seems completely crazy, I'll clean up my code, learn how to add a reftest, and push up a PR.

@jdm
Copy link
Member

@jdm jdm commented Apr 30, 2017

Seems plausible! https://github.com/servo/servo/blob/master/tests/wpt/README.md#writing-new-tests has information about adding a new test.

@mrobinson mrobinson self-assigned this Jun 27, 2017
mrobinson added a commit to mrobinson/servo that referenced this issue Jun 30, 2017
The clip for overflow:scroll clip was not including the space for
padding, which could lead to some content being clipped when it
shouldn't. This changes fixes that issue.

Fixes servo#16576.
mrobinson added a commit to mrobinson/servo that referenced this issue Jun 30, 2017
The clip for overflow:scroll clip was not including the space for
padding, which could lead to some content being clipped when it
shouldn't. This changes fixes that issue.

A test is skipped because this fix also stops hiding a failure due to
mispositioned text.

Fixes servo#16576.
@mrobinson
Copy link
Member

@mrobinson mrobinson commented Jun 30, 2017

I have a fix for this at mrobinson@f190445. It's just waiting on the WebRender update.

mrobinson added a commit to mrobinson/servo that referenced this issue Jul 13, 2017
The clip for overflow:scroll clip was not including the space for
padding, which could lead to some content being clipped when it
shouldn't. This changes fixes that issue.

A test is skipped because this fix also stops hiding a failure due to
mispositioned text.

Fixes servo#16576.
mrobinson added a commit to mrobinson/servo that referenced this issue Jul 13, 2017
The clip for overflow:scroll clip was not including the space for
padding, which could lead to some content being clipped when it
shouldn't. This changes fixes that issue.

A test is skipped because this fix also stops hiding a failure due to
mispositioned text.

Fixes servo#16576.
mrobinson added a commit to mrobinson/servo that referenced this issue Jul 13, 2017
The clip for overflow:scroll clip was not including the space for
padding, which could lead to some content being clipped when it
shouldn't. This changes fixes that issue.

A test is skipped because this fix also stops hiding a failure due to
mispositioned text.

Fixes servo#16576.
bors-servo added a commit that referenced this issue Jul 13, 2017
Fix the size and position of overflow:scroll clip

The clip for overflow:scroll clip was not including the space for
padding, which could lead to some content being clipped when it
shouldn't. This changes fixes that issue.

A test is skipped because this fix also stops hiding a failure due to
mispositioned text.

Fixes #16576.

<!-- Please describe your changes on the following line: -->

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #16576 (github issue number if applicable).

<!-- Either: -->
- [x] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- 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/17712)
<!-- Reviewable:end -->
bors-servo added a commit that referenced this issue Jul 13, 2017
Fix the size and position of overflow:scroll clip

The clip for overflow:scroll clip was not including the space for
padding, which could lead to some content being clipped when it
shouldn't. This changes fixes that issue.

A test is skipped because this fix also stops hiding a failure due to
mispositioned text.

Fixes #16576.

<!-- Please describe your changes on the following line: -->

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #16576 (github issue number if applicable).

<!-- Either: -->
- [x] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- 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/17712)
<!-- Reviewable:end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

6 participants
You can’t perform that action at this time.