Skip to content

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

Merged
bors-servo merged 20 commits into
servo:masterfrom
Manishearth:table-backgrounds
Feb 21, 2018
Merged

bors-servo merged 20 commits into
servo:masterfrom
Manishearth:table-backgrounds

Conversation

@Manishearth

@Manishearth Manishearth commented Feb 13, 2018 •

Copy link
Copy Markdown
Member

Fixes #19788


This change is Reviewable

@highfive

Copy link
Copy Markdown

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 highfive added the S-awaiting-review There is new code that needs to be reviewed. label Feb 13, 2018
@highfive

Copy link
Copy Markdown

warning Warning warning

  • These commits modify layout code, but no tests are modified. Please consider adding a test!

@Manishearth

Manishearth commented Feb 14, 2018 •

Copy link
Copy Markdown
Member Author

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
Copy Markdown
Member Author

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
Copy Markdown
Contributor

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
Copy Markdown
Member Author

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
Copy Markdown
Member Author

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
Copy Markdown
Member Author

Made stuff immutable which lets me handle currentcolor easily

@Manishearth

Copy link
Copy Markdown
Member Author

@bors-servo try

let's see what we get

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Trying commit dc7d706 with merge 2390e18...

bors-servo pushed 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
Copy Markdown
Contributor

💔 Test failed - linux-dev

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-tests-failed The changes caused existing tests to fail. labels Feb 15, 2018
@Manishearth

Copy link
Copy Markdown
Member Author

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
Copy Markdown
Member Author

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
Copy Markdown
Member Author

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Comment thread components/layout/table_cell.rs Outdated
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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

if !self.cell.visible || self.cell.block_flow.fragment.style()
.get_inheritedbox().visibility != Visibility::Visible {
return
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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

@mbrubeck

Copy link
Copy Markdown
Contributor

@bors-servo r+

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

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 1a03cd6 has been approved by mbrubeck

@highfive highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Feb 16, 2018
@jdm

jdm commented Feb 21, 2018

Copy link
Copy Markdown
Member

@bors-servo treeclosed-

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 7de29d0 with merge 97ceaf6...

bors-servo pushed 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 -->
@highfive highfive removed the S-tests-failed The changes caused existing tests to fail. label Feb 21, 2018
@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - linux-rel-wpt

@CYBAI

CYBAI commented Feb 21, 2018

Copy link
Copy Markdown
Member

@bors-servo retry

{"status": "TIMEOUT", "group": "default", "message": null, "stack": null, "subtest": null, "test": "/css/css-color/t421-rgb-values-meaning-b.xht", "line": 49133, "action": "test_result", "expected": "PASS"}

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 7de29d0 with merge f5221ac...

@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - linux-rel-wpt

@Manishearth

Copy link
Copy Markdown
Member Author

That test has a table with lots of per-cell backgrounds, perhaps this PR slows down tables because we build too many display lists? Trying an optimization to fix this.

@Manishearth

Copy link
Copy Markdown
Member Author

@bors-servo r=mbrubeck

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 285313f has been approved by mbrubeck

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 285313f with merge 512e783...

@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - linux-rel-wpt

@ferjm

ferjm commented Feb 21, 2018

Copy link
Copy Markdown
Contributor

@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
Copy Markdown
Contributor

⌛ Testing commit 285313f with merge 96f36f7...

@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - linux-rel-wpt

@CYBAI

CYBAI commented Feb 21, 2018 •

Copy link
Copy Markdown
Member

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
Copy Markdown
Member Author

@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

CYBAI commented Feb 21, 2018 •

Copy link
Copy Markdown
Member

@bors-servo retry

(I guess @Manishearth called wrong bors XD?)

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 285313f with merge 0b4ea01...

@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - linux-rel-css

@Manishearth

Copy link
Copy Markdown
Member Author

@bors-servo retry

  • no space on device

@bors-servo

Copy link
Copy Markdown
Contributor

⚡ Previous build results for android, linux-dev, mac-dev-unit are reusable. Rebuilding only arm32, arm64, linux-rel-css, linux-rel-wpt, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, windows-msvc-dev...

@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - linux-rel-wpt

@Manishearth

Copy link
Copy Markdown
Member Author

@bors-servo retry

  • font intermittent crash

@bors-servo

Copy link
Copy Markdown
Contributor

⚡ Previous build results for android, arm32, arm64, linux-dev, linux-rel-css, mac-dev-unit, mac-rel-wpt1, windows-msvc-dev are reusable. Rebuilding only linux-rel-wpt, mac-rel-css1, mac-rel-css2, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4...

@bors-servo

Copy link
Copy Markdown
Contributor

☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, windows-msvc-dev
Approved by: mbrubeck
Pushing 0b4ea01 to master...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-tests-failed The changes caused existing tests to fail.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants