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 row borders in border collapsing logic. #12437

Merged
merged 1 commit into from Aug 31, 2016

Conversation

@gpoesia
Copy link
Contributor

gpoesia commented Jul 13, 2016

Handle table row border when collapsing borders for a table row. The row border is combined with the cell's border using the already implemented conflict resolution logic.

This is a screenshot of the following test:

<!doctype html>
<html><body>
    <style>
      table {
        border-collapse: collapse;
      }
      tr {
        border: 1px solid black;
      }
    </style>
    <table>
      <tr><td>Lorem</td><td>Ipsum</td><td>Sit</td><td>Dolor</td></tr>
      <tr><td>Lorem</td><td>Ipsum</td><td>Sit</td><td>Dolor</td></tr>
      <tr><td>Lorem</td><td>Ipsum</td><td>Sit</td><td>Dolor</td></tr>
      <tr><td>Lorem</td><td>Ipsum</td><td>Sit</td><td>Dolor</td></tr>
    </table>
  </body>
</html>

The top border is missing, but I think that's a different bug, since it also does not show up when the border is in the cells, and not the rows. Also, when debugging the border collapsing structures, they seem ok (the top border seems to be there). I can look at that bug in a separate issue (or in this one too if you prefer).


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #11527 (github issue number if applicable).
  • These changes do not require tests because I didn't find how to automatically test it (will be happy to provide a test if there's infrastructure for this kind of test already in place).

Fixes #11527.


This change is Reviewable

@highfive
Copy link

highfive commented Jul 13, 2016

warning Warning warning

  • These commits modify layout code, but no tests are modified. Please consider adding a test!
@jdm
Copy link
Member

jdm commented Jul 13, 2016

Layout code is usually tested using reference tests. We have documentation on creating them.

@gpoesia
Copy link
Contributor Author

gpoesia commented Jul 14, 2016

@jdm thanks! Sorry for missing that, I'll provide a test soon.
One doubt, though: since this PR still leaves one issue missing (the missing top border, which looks like it is caused by a different issue), what should the test look like? I guess I could investigate this other bug too, amend the PR and add a fully correct test.

@jdm
Copy link
Member

jdm commented Jul 14, 2016

That's a good question. Is there some way to reproduce the problem that doesn't trigger the other bug?

@gpoesia
Copy link
Contributor Author

gpoesia commented Jul 14, 2016

Actually there is, I can put borders in all rows except the topmost. Then with this PR the output is pretty much the same as the one Chrome and Firefox give:

<!doctype html>
<html><body>
    <style>
      table {
        border-collapse: collapse;
      }
      .b {
        border: 1px solid black;
      }
    </style>
    <table>
      <tr><td>Lorem</td><td>Ipsum</td><td>Sit</td><td>Dolor</td></tr>
      <tr class="b"><td>Lorem</td><td>Ipsum</td><td>Sit</td><td>Dolor</td></tr>
      <tr class="b"><td>Lorem</td><td>Ipsum</td><td>Sit</td><td>Dolor</td></tr>
      <tr class="b"><td>Lorem</td><td>Ipsum</td><td>Sit</td><td>Dolor</td></tr>
    </table>
  </body>
</html>

Servo:

Chrome:

Firefox:

Servo from master:

I can make a ref test with this, then.

@gpoesia gpoesia force-pushed the gpoesia:tr_margin_fix branch from faa2b5c to e3d059e Jul 17, 2016
@KiChjang KiChjang closed this Jul 24, 2016
@KiChjang KiChjang reopened this Jul 24, 2016
@KiChjang
Copy link
Member

KiChjang commented Jul 24, 2016

@highfive highfive assigned pcwalton and unassigned KiChjang Jul 24, 2016
@pcwalton
Copy link
Contributor

pcwalton commented Jul 25, 2016

@bors-servo
Copy link
Contributor

bors-servo commented Jul 25, 2016

📌 Commit e3d059e has been approved by pcwalton

@bors-servo
Copy link
Contributor

bors-servo commented Jul 25, 2016

Testing commit e3d059e with merge 10ad5c3...

bors-servo added a commit that referenced this pull request Jul 25, 2016
Handle row borders in border collapsing logic.

<!-- Please describe your changes on the following line: -->
Handle table row border when collapsing borders for a table row. The row border is combined with the cell's border using the already implemented conflict resolution logic.

This is a screenshot of the following test:

```html
<!doctype html>
<html><body>
    <style>
      table {
        border-collapse: collapse;
      }
      tr {
        border: 1px solid black;
      }
    </style>
    <table>
      <tr><td>Lorem</td><td>Ipsum</td><td>Sit</td><td>Dolor</td></tr>
      <tr><td>Lorem</td><td>Ipsum</td><td>Sit</td><td>Dolor</td></tr>
      <tr><td>Lorem</td><td>Ipsum</td><td>Sit</td><td>Dolor</td></tr>
      <tr><td>Lorem</td><td>Ipsum</td><td>Sit</td><td>Dolor</td></tr>
    </table>
  </body>
</html>
```

<img src="https://dl.dropboxusercontent.com/u/10962672/Screenshots%20Servo/servo_tr_border_collapse.png"/>

The top border is missing, but I think that's a different bug, since it also does not show up when the border is in the cells, and not the rows. Also, when debugging the border collapsing structures, they seem ok (the top border seems to be there). I can look at that bug in a separate issue (or in this one too if you prefer).

---
<!-- 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 #11527 (github issue number if applicable).

<!-- Either: -->
- [X] These changes do not require tests because I didn't find how to automatically test it (will be happy to provide a test if there's infrastructure for this kind of test already in place).

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

Fixes #11527.

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

bors-servo commented Jul 26, 2016

💔 Test failed - mac-rel-css

@highfive
Copy link

highfive commented Jul 26, 2016

  ▶ PASS [expected FAIL] /css21_dev/html4/border-bottom-applies-to-004.htm

  ▶ PASS [expected FAIL] /css21_dev/html4/border-bottom-color-applies-to-004.htm

  ▶ PASS [expected FAIL] /css21_dev/html4/border-bottom-width-applies-to-004.htm

  ▶ PASS [expected FAIL] /css21_dev/html4/border-conflict-style-101.htm

  ▶ PASS [expected FAIL] /css21_dev/html4/border-left-applies-to-004.htm

  ▶ PASS [expected FAIL] /css21_dev/html4/border-left-color-applies-to-004.htm

  ▶ PASS [expected FAIL] /css21_dev/html4/border-left-width-applies-to-004.htm

  ▶ PASS [expected FAIL] /css21_dev/html4/border-right-applies-to-004.htm

  ▶ PASS [expected FAIL] /css21_dev/html4/border-right-color-applies-to-004.htm

  ▶ PASS [expected FAIL] /css21_dev/html4/border-right-width-applies-to-004.htm

  ▶ PASS [expected FAIL] /css21_dev/html4/vertical-align-121.htm
@pcwalton
Copy link
Contributor

pcwalton commented Jul 26, 2016

Just needs a few test expectations updates. 11 new passes :)

@johannhof johannhof mentioned this pull request Jul 26, 2016
4 of 4 tasks complete
@gpoesia gpoesia force-pushed the gpoesia:tr_margin_fix branch from e3d059e to 9f9eb12 Jul 28, 2016
@gpoesia
Copy link
Contributor Author

gpoesia commented Jul 28, 2016

Done :)

@jdm
Copy link
Member

jdm commented Jul 28, 2016

@bors-servo: r=pcwalton

@bors-servo
Copy link
Contributor

bors-servo commented Jul 28, 2016

Testing commit 9f9eb12 with merge 65853a7...

bors-servo added a commit that referenced this pull request Jul 28, 2016
Handle row borders in border collapsing logic.

<!-- Please describe your changes on the following line: -->
Handle table row border when collapsing borders for a table row. The row border is combined with the cell's border using the already implemented conflict resolution logic.

This is a screenshot of the following test:

```html
<!doctype html>
<html><body>
    <style>
      table {
        border-collapse: collapse;
      }
      tr {
        border: 1px solid black;
      }
    </style>
    <table>
      <tr><td>Lorem</td><td>Ipsum</td><td>Sit</td><td>Dolor</td></tr>
      <tr><td>Lorem</td><td>Ipsum</td><td>Sit</td><td>Dolor</td></tr>
      <tr><td>Lorem</td><td>Ipsum</td><td>Sit</td><td>Dolor</td></tr>
      <tr><td>Lorem</td><td>Ipsum</td><td>Sit</td><td>Dolor</td></tr>
    </table>
  </body>
</html>
```

<img src="https://dl.dropboxusercontent.com/u/10962672/Screenshots%20Servo/servo_tr_border_collapse.png"/>

The top border is missing, but I think that's a different bug, since it also does not show up when the border is in the cells, and not the rows. Also, when debugging the border collapsing structures, they seem ok (the top border seems to be there). I can look at that bug in a separate issue (or in this one too if you prefer).

---
<!-- 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 #11527 (github issue number if applicable).

<!-- Either: -->
- [X] These changes do not require tests because I didn't find how to automatically test it (will be happy to provide a test if there's infrastructure for this kind of test already in place).

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

Fixes #11527.

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

bors-servo commented Jul 28, 2016

💔 Test failed - linux-rel

@jdm
Copy link
Member

jdm commented Jul 28, 2016

This failure looks suspicious:

  ▶ FAIL [expected PASS] /_mozilla/css/border_collapse_simple_a.html
  └   → /_mozilla/css/border_collapse_simple_a.html e0dbf4c95e91bbc8314511a55f42ea1be552c274
/_mozilla/css/border_collapse_simple_ref.html c14395ed4b2c80aee21c9bd21c8b4b734fec07e5
Testing e0dbf4c95e91bbc8314511a55f42ea1be552c274 == c14395ed4b2c80aee21c9bd21c8b4b734fec07e5

The other one is #12580.

@gpoesia
Copy link
Contributor Author

gpoesia commented Jul 29, 2016

Hmm, @pcwalton do you know if the FIXME in that test is related to this PR?

<!DOCTYPE html>
<html>
<head>
<!--
    Tests that border collapse override and border collapse positioning works. All border widths
    are even numbers to avoid subpixel rounding issues (the handling of which is not spec'd).

    FIXME(pcwalton): This is currently offset by -2px in block and inline directions because we
    don't correctly handle collapsed borders when calculating `table_border_padding` in
    `table_wrapper.rs`.
-->
<link rel=match href=border_collapse_simple_ref.html>
<style>
html, body {
    margin: 0;
}
html {
    padding: 0;
}
body {
    /* See `FIXME` above. */
    padding: 2px;
}
...

It looks like the difference is indeed a small padding added by the PR. I'll take a look.

@pcwalton
Copy link
Contributor

pcwalton commented Jul 29, 2016

@gpoesia If you can fix the test by removing the 2px, then feel free to do that.

@gpoesia
Copy link
Contributor Author

gpoesia commented Aug 8, 2016

Came back from vacations and started looking deeper into this. There are some problems which are not related to the padding. The left border width (TableFlow::collapsed_inline_direction_border_widths_for_table[0]) is not calculated properly, and if I fix that manually for this test (in the code) the leftmost column width is slightly (and erroneously) increased. I have some clues and will keep debugging that the next few days.

@gpoesia gpoesia force-pushed the gpoesia:tr_margin_fix branch from 9f9eb12 to 3b0aafe Aug 10, 2016
@gpoesia
Copy link
Contributor Author

gpoesia commented Aug 10, 2016

I think I've fixed one of the issues, but a second one remains: the cells in the left column apparently have a slightly larger width than they should (2px). Still not sure why this is so.

As another note, I've noticed that even if I remove the 2px padding, the a and ref versions of the failing test do not match in Firefox either. It's visually noticeable if you open them in different tabs and switch: cell 0,0 in "ref" is slightly smaller (apparently by those same 2px) in both inline and block directions. I tried modifying the test so that they matched in Firefox, but then the cell 0,0 in servo with this PR is smaller (but only in the block direction; inline is fine).

@pcwalton: any idea of what might be going on?

@pcwalton
Copy link
Contributor

pcwalton commented Aug 17, 2016

If the test is failing in Firefox as well, feel free to just rewrite the test to test it some other way.

@gpoesia gpoesia force-pushed the gpoesia:tr_margin_fix branch from 3b0aafe to bf105fa Aug 29, 2016
@gpoesia
Copy link
Contributor Author

gpoesia commented Aug 29, 2016

I've modified the test and it passes now, but it diverges slightly from Firefox (one cell's width in the block direction is 2px smaller; the widths in the inline direction are all identical, differently from the previous version of the test).

@pcwalton what do you think would be the most appropriate to do? I can keep debugging why the collapsing in the block direction is still a little different from Firefox. Do you have any tips on what I could look for?

@pcwalton
Copy link
Contributor

pcwalton commented Aug 29, 2016

Let's just file a FIXME and get this landed.

@gpoesia gpoesia force-pushed the gpoesia:tr_margin_fix branch from bf105fa to a3af230 Aug 31, 2016
@gpoesia
Copy link
Contributor Author

gpoesia commented Aug 31, 2016

All right, just did that.

@notriddle
Copy link
Contributor

notriddle commented Aug 31, 2016

@bors-servo r=pcwalton

@bors-servo
Copy link
Contributor

bors-servo commented Aug 31, 2016

📌 Commit a3af230 has been approved by pcwalton

@bors-servo
Copy link
Contributor

bors-servo commented Aug 31, 2016

Testing commit a3af230 with merge f5a546a...

bors-servo added a commit that referenced this pull request Aug 31, 2016
Handle row borders in border collapsing logic.

<!-- Please describe your changes on the following line: -->
Handle table row border when collapsing borders for a table row. The row border is combined with the cell's border using the already implemented conflict resolution logic.

This is a screenshot of the following test:

```html
<!doctype html>
<html><body>
    <style>
      table {
        border-collapse: collapse;
      }
      tr {
        border: 1px solid black;
      }
    </style>
    <table>
      <tr><td>Lorem</td><td>Ipsum</td><td>Sit</td><td>Dolor</td></tr>
      <tr><td>Lorem</td><td>Ipsum</td><td>Sit</td><td>Dolor</td></tr>
      <tr><td>Lorem</td><td>Ipsum</td><td>Sit</td><td>Dolor</td></tr>
      <tr><td>Lorem</td><td>Ipsum</td><td>Sit</td><td>Dolor</td></tr>
    </table>
  </body>
</html>
```

<img src="https://dl.dropboxusercontent.com/u/10962672/Screenshots%20Servo/servo_tr_border_collapse.png"/>

The top border is missing, but I think that's a different bug, since it also does not show up when the border is in the cells, and not the rows. Also, when debugging the border collapsing structures, they seem ok (the top border seems to be there). I can look at that bug in a separate issue (or in this one too if you prefer).

---
<!-- 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 #11527 (github issue number if applicable).

<!-- Either: -->
- [X] These changes do not require tests because I didn't find how to automatically test it (will be happy to provide a test if there's infrastructure for this kind of test already in place).

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

Fixes #11527.

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

bors-servo commented Aug 31, 2016

@bors-servo bors-servo merged commit a3af230 into servo:master Aug 31, 2016
2 of 3 checks passed
2 of 3 checks passed
continuous-integration/appveyor/pr AppVeyor build failed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
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.

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