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

Handle table cell backgrounds during display list generation for <table> #20034

Merged
merged 20 commits into from Feb 21, 2018

Conversation

@Manishearth
Copy link
Member

Manishearth commented Feb 13, 2018

Fixes #19788


This change is Reviewable

@highfive
Copy link

highfive commented Feb 13, 2018

Heads up! This PR modifies the following files:

  • @emilio: components/layout/table_colgroup.rs, components/layout/table.rs, components/layout/fragment.rs, components/layout/flow.rs
@highfive
Copy link

highfive commented Feb 13, 2018

warning Warning warning

  • These commits modify layout code, but no tests are modified. Please consider adding a test!
@Manishearth Manishearth force-pushed the Manishearth:table-backgrounds branch from 3b5ea02 to 32ece4d Feb 14, 2018
@Manishearth
Copy link
Member Author

Manishearth commented Feb 14, 2018

Okay, I've gotten something working. Tables with styled columns/colgroups/rowgroups/rows/tables, that use colspan work.

There are a couple of missing pieces:

  • I don't handle currentColor correctly
  • I don't support rowspan (yet)
  • I no longer call build_display_list in TableRowFlow -- this may cause borders to be skipped? I'm not sure about this
  • Backgrounds are positioned relative to the cell, not the region being styled

For the last one, it's a bit tricky. I can handle it for row/rowgroup backgrounds by using the stackingcontext-relative position of the element for drawing the background, and then clipping it with the regular element's position.

But for columns/colgroups, we don't store the positions anywhere. We kinda calculate these during border-collapse layout; so it might be worth adding a layout pass to compute these and store them on ColGroupFlow.

Thoughts?

@Manishearth
Copy link
Member Author

Manishearth commented Feb 14, 2018

Oh, also, a lot of this is made complicated by the fact that build_display_list needs a mutable reference, but looking through the code that may not actually be necessary.

@mbrubeck
Copy link
Contributor

mbrubeck commented Feb 14, 2018

But for columns/colgroups, we don't store the positions anywhere. We kinda calculate these during border-collapse layout; so it might be worth adding a layout pass to compute these and store them on ColGroupFlow.

Yes, seems like this will be necessary (though this can be a follow-up if you want).

Oh, also, a lot of this is made complicated by the fact that build_display_list needs a mutable reference, but looking through the code that may not actually be necessary.

Yeah... many of the individual builder methods only take&self. Some like build_fragment_type_specific_display_items take &mut self but don't actually need it. It should definitely be possible to do most of this without &mut access.

Does Fragment::build_display_list only use mut to unset self.restyle_damage? If so, maybe we could separate the rest of its body into an &self helper function.

I no longer call build_display_list in TableRowFlow -- this may cause borders to be skipped?

Yes, this will need to be addressed. I haven't looked at your code in detail yet, but it seems there's not a clear place to fit this in, since I think row borders should be drawn after the backgrounds but before the cell contents? Or does this even matter – is it possible for the borders and backgrounds to overlap? If not, then we could draw the row borders in separate loop iterating over the rows...

@Manishearth
Copy link
Member Author

Manishearth commented Feb 14, 2018

Does Fragment::build_display_list only use mut to unset self.restyle_damage?

Yes.

I can handle this by explicitly doing the damage (and nothing else) in TableCellFlow's build_display_list

@Manishearth
Copy link
Member Author

Manishearth commented Feb 14, 2018

Or does this even matter – is it possible for the borders and backgrounds to overlap?

I think not -- however, it is possible for the border and content to overlap since content can spill out. Hmm.

@Manishearth
Copy link
Member Author

Manishearth commented Feb 15, 2018

Made stuff immutable which lets me handle currentcolor easily

@Manishearth
Copy link
Member Author

Manishearth commented Feb 15, 2018

@bors-servo try

let's see what we get

@bors-servo
Copy link
Contributor

bors-servo commented Feb 15, 2018

Trying commit dc7d706 with merge 2390e18...

bors-servo added a commit that referenced this pull request Feb 15, 2018
[WIP] Handle table cell backgrounds during display list generation for <table>

Very WIP, currently just contains half the iterator work necessary to do this.

Fixes #19788

<!-- 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/20034)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Feb 15, 2018

💔 Test failed - linux-dev

@Manishearth
Copy link
Member Author

Manishearth commented Feb 15, 2018

Rowspan "done".

Given that we don't actually render rowspans where we should, it's a bit lackluster. But if we did, they would have working backgrounds.

@Manishearth Manishearth changed the title [WIP] Handle table cell backgrounds during display list generation for <table> Handle table cell backgrounds during display list generation for <table> Feb 16, 2018
@Manishearth
Copy link
Member Author

Manishearth commented Feb 16, 2018

Turns out borders are not skipped; table rows don't draw collapsed borders anyway, they delegate to cells!

I'm pushing bg positioning to a different bug.

There's one missing bit -- restyle damage doesn't get correctly applied here. I guess I should propagate it up in layout/incremental.rs?

@Manishearth
Copy link
Member Author

Manishearth commented Feb 16, 2018

So we fail css/cssom-view/elementFromPoint-dynamic-anon-box.html . I thought this was due to restyle damage, but I tried fixing that in incremental.rs and this still occurs.

@mbrubeck mbrubeck assigned mbrubeck and unassigned glennw Feb 16, 2018

self.block_flow.build_display_list_for_block(state, border_painting_mode);
fn build_display_list(&mut self, _: &mut DisplayListBuildState) {
// handled in TableCellStyleInfo::build_display_list

This comment has been minimized.

Copy link
@mbrubeck

mbrubeck Feb 16, 2018

Contributor

We'll still need to remove REPAINT damage here, or somewhere.

if self.visible {
// we skip setting the damage in TableCellStyleInfo::build_display_list()
// because we only have immutable access
self.block_flow.fragment.restyle_damage.remove(ServoRestyleDamage::REPAINT);

This comment has been minimized.

Copy link
@mbrubeck

mbrubeck Feb 16, 2018

Contributor

This should probably be unconditional. (I think this was a bug in the old code.)

@Manishearth Manishearth force-pushed the Manishearth:table-backgrounds branch from f15cead to 3dc3683 Feb 16, 2018
if !self.cell.visible || self.cell.block_flow.fragment.style()
.get_inheritedbox().visibility != Visibility::Visible {
return
}

This comment has been minimized.

Copy link
@mbrubeck

mbrubeck Feb 16, 2018

Contributor

I believe for empty cells (cell.visible == false), we should still draw the column and row backgrounds, just not the cell background and contents, per the spec: https://drafts.csswg.org/css2/tables.html#table-layers

This comment has been minimized.

Copy link
@Manishearth

Manishearth Feb 16, 2018

Author Member

I tested this in Firefox, it doesn't work for columns at least. The cell disappears entirely.

This comment has been minimized.

Copy link
@Manishearth

Manishearth Feb 16, 2018

Author Member

Or rows. It only works for the surrounding table, and we still handle that

@mbrubeck
Copy link
Contributor

mbrubeck commented Feb 16, 2018

@bors-servo r+

Thanks especially for factoring these traversals out into iterators. ❤️

@bors-servo
Copy link
Contributor

bors-servo commented Feb 16, 2018

📌 Commit 1a03cd6 has been approved by mbrubeck

@ferjm
Copy link
Member

ferjm commented Feb 21, 2018

@bors-servo retry

{"status": "CRASH", "group": "default", "message": null, "stack": null, "subtest": null, "test": "/WebCryptoAPI/idlharness.https.worker.html", "line": 147751, "action": "test_result", "expected": "OK"}
@bors-servo
Copy link
Contributor

bors-servo commented Feb 21, 2018

Testing commit 285313f with merge 96f36f7...

bors-servo added a commit that referenced this pull request Feb 21, 2018
Handle table cell backgrounds during display list generation for <table>

Fixes #19788

<!-- 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/20034)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Feb 21, 2018

💔 Test failed - linux-rel-wpt

@CYBAI
Copy link
Collaborator

CYBAI commented Feb 21, 2018

Error in linux-rel-nogate

error[E0425]: cannot find value `handle` in this scope
    --> components/script/dom/xmlhttprequest.rs:1068:47
     |
1068 |             self.global().unschedule_callback(handle);
     |                                               ^^^^^^ not found in this scope

error: aborting due to previous error

error: Could not compile `script`.
@Manishearth
Copy link
Member Author

Manishearth commented Feb 21, 2018

@bors retry

new failures, probably intermittents

{"status": "TIMEOUT", "group": "default", "message": null, "stack": null, "subtest": null, "test": "/css/CSS2/floats-clear/clear-float-003.xht", "line": 5420, "action": "test_result", "expected": "PASS"}
{"status": "CRASH", "group": "default", "message": null, "stack": null, "subtest": null, "test": "/html/semantics/selectors/pseudo-classes/checked.html", "line": 139160, "action": "test_result", "expected": "OK"}
@CYBAI
Copy link
Collaborator

CYBAI commented Feb 21, 2018

@bors-servo retry

(I guess @Manishearth called wrong bors XD?)

@bors-servo
Copy link
Contributor

bors-servo commented Feb 21, 2018

Testing commit 285313f with merge 0b4ea01...

bors-servo added a commit that referenced this pull request Feb 21, 2018
Handle table cell backgrounds during display list generation for <table>

Fixes #19788

<!-- 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/20034)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Feb 21, 2018

💔 Test failed - linux-rel-css

@Manishearth
Copy link
Member Author

Manishearth commented Feb 21, 2018

@bors-servo retry

  • no space on device
@bors-servo
Copy link
Contributor

bors-servo commented Feb 21, 2018

@bors-servo
Copy link
Contributor

bors-servo commented Feb 21, 2018

💔 Test failed - linux-rel-wpt

@Manishearth
Copy link
Member Author

Manishearth commented Feb 21, 2018

@bors-servo retry

  • font intermittent crash
@bors-servo
Copy link
Contributor

bors-servo commented Feb 21, 2018

@bors-servo
Copy link
Contributor

bors-servo commented Feb 21, 2018

@bors-servo bors-servo merged commit 285313f into servo:master Feb 21, 2018
3 checks passed
3 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@Manishearth Manishearth deleted the Manishearth:table-backgrounds branch Feb 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

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