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

Fix crash in DL building #20752

Merged
merged 4 commits into from May 19, 2018
Merged

Fix crash in DL building #20752

merged 4 commits into from May 19, 2018

Conversation

@pyfisch
Copy link
Contributor

pyfisch commented May 5, 2018

Fix one crash and some style changes.

This HTML crashed servo before. Key parts are background-clip: content-box and direction: rtl

<!DOCTYPE html>
<html>
    <style>
        #span1 {
            background-clip: content-box;
        }
        #span2
        {
            direction: rtl;
        }
    </style>
    <span id="span1">Filler Text <span id="span2">txeT relliF</span></span>
</html>

Should I add this as a test? And where do I put this "does-it-crash?" test?

I find always passing rectangles by value a lot easier as it avoids many references and dereferences and I assume that the compiler will always use the faster one either way. If you don't like the change feel free to only merge the first commit.


This change is Reviewable

pyfisch added 3 commits May 5, 2018
Always use border_padding and writing_mode from the same fragment.
Mixing them will trigger a debug assertion if the writing modes are different.

Cleanup and use compute_background_clip
Style change in display_list/builder.rs to reduce
the number of & and * found in the code.
Rect<Au> are basically 4 integers so there is no
need to pass by reference.
@highfive
Copy link

highfive commented May 5, 2018

Heads up! This PR modifies the following files:

  • @emilio: components/layout/display_list/builder.rs, components/layout/fragment.rs, components/layout/display_list/background.rs, components/layout/inline.rs
@highfive
Copy link

highfive commented May 5, 2018

warning Warning warning

  • These commits modify layout code, but no tests are modified. Please consider adding a test!
@pyfisch pyfisch changed the title Backgrounds42 Fix crash in DL building May 5, 2018
@emilio
Copy link
Member

emilio commented May 6, 2018

I find always passing rectangles by value a lot easier as it avoids many references and dereferences and I assume that the compiler will always use the faster one either way. If you don't like the change feel free to only merge the first commit.

This is not true, and rust will memmove a lot of the rects, unfortunately. I suspect it's not a change that matters a lot because the memmove is 2 words in an x64 computer, but...

@emilio
emilio approved these changes May 6, 2018
Copy link
Member

emilio left a comment

Code change itself looks good, but yeah, let's add a WPT test for this so it doesn't regress. tests/wpt/mozilla should work for these situations.

let (bounds, border_radii) = compute_background_clip(
color_clip,
*absolute_bounds,
style.logical_border_width().to_physical(style.writing_mode),

This comment has been minimized.

@emilio

emilio May 6, 2018

Member

As a followup, let's double-check that computing the background-clip in terms of the padding of a fragment, but the border of another one is the right thing to do. Looks fishy.

This comment has been minimized.

@pyfisch

pyfisch May 6, 2018

Author Contributor

Looks fishy.

It probably is. For block fragments it does not make a difference as it is always the same fragment but for inlines it is probably wrong. However I don't know how to correctly compute border_padding for inlines. I assumed it was padding + border for all four sides but there is more going on.

@pyfisch
Copy link
Contributor Author

pyfisch commented May 6, 2018

Added the test.

@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<title>Assure that different writing modes do not crash background building in Servo</title>

This comment has been minimized.

@emilio

emilio May 7, 2018

Member

This isn't run as a test. This needs a testharness <script> and something like:

async_test(function(t) {
    window.onload = t.step_func_done();
}, "Didn't crash");

This comment has been minimized.

@jdm

jdm May 7, 2018

Member

Can we write it as a reference test instead?

This comment has been minimized.

@pyfisch

pyfisch May 18, 2018

Author Contributor

@jdm How do I best convert this to a reference test as I don't have a reference file?

This comment has been minimized.

@jdm

jdm May 18, 2018

Member

Wouldn't the reference file look like <span>Filler Text Filler Text</span>?

@pyfisch pyfisch force-pushed the pyfisch:backgrounds42 branch from 0ddcf33 to 6bcb70e May 18, 2018
@pyfisch pyfisch force-pushed the pyfisch:backgrounds42 branch from 6bcb70e to 89af7cb May 18, 2018
@pyfisch
Copy link
Contributor Author

pyfisch commented May 18, 2018

Ok. I've added a reference to the test. Can you have a look?

@jdm
Copy link
Member

jdm commented May 18, 2018

@bors-servo r=emilio

@bors-servo
Copy link
Contributor

bors-servo commented May 18, 2018

📌 Commit 89af7cb has been approved by emilio

@highfive highfive assigned emilio and unassigned nox May 18, 2018
@bors-servo
Copy link
Contributor

bors-servo commented May 18, 2018

Testing commit 89af7cb with merge dec24b7...

bors-servo added a commit that referenced this pull request May 18, 2018
Fix crash in DL building

Fix one crash and some style changes.

This HTML crashed servo before. Key parts are `background-clip: content-box` and `direction: rtl`

```html
<!DOCTYPE html>
<html>
    <style>
        #span1 {
            background-clip: content-box;
        }
        #span2
        {
            direction: rtl;
        }
    </style>
    <span id="span1">Filler Text <span id="span2">txeT relliF</span></span>
</html>
```
Should I add this as a test? And where do I put this "does-it-crash?" test?

I find always passing rectangles by value a lot easier as it avoids many references and dereferences and I assume that the compiler will always use the faster one either way. If you don't like the change feel free to only merge the first commit.

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

bors-servo commented May 18, 2018

💔 Test failed - mac-rel-css1

@jdm
Copy link
Member

jdm commented May 18, 2018

bors-servo added a commit that referenced this pull request May 19, 2018
Fix crash in DL building

Fix one crash and some style changes.

This HTML crashed servo before. Key parts are `background-clip: content-box` and `direction: rtl`

```html
<!DOCTYPE html>
<html>
    <style>
        #span1 {
            background-clip: content-box;
        }
        #span2
        {
            direction: rtl;
        }
    </style>
    <span id="span1">Filler Text <span id="span2">txeT relliF</span></span>
</html>
```
Should I add this as a test? And where do I put this "does-it-crash?" test?

I find always passing rectangles by value a lot easier as it avoids many references and dereferences and I assume that the compiler will always use the faster one either way. If you don't like the change feel free to only merge the first commit.

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

bors-servo commented May 19, 2018

Testing commit 89af7cb with merge 131e910...

@bors-servo
Copy link
Contributor

bors-servo commented May 19, 2018

💔 Test failed - mac-rel-wpt1

@jdm
Copy link
Member

jdm commented May 19, 2018

@bors-servo
Copy link
Contributor

bors-servo commented May 19, 2018

Testing commit 89af7cb with merge 6b0f57a...

bors-servo added a commit that referenced this pull request May 19, 2018
Fix crash in DL building

Fix one crash and some style changes.

This HTML crashed servo before. Key parts are `background-clip: content-box` and `direction: rtl`

```html
<!DOCTYPE html>
<html>
    <style>
        #span1 {
            background-clip: content-box;
        }
        #span2
        {
            direction: rtl;
        }
    </style>
    <span id="span1">Filler Text <span id="span2">txeT relliF</span></span>
</html>
```
Should I add this as a test? And where do I put this "does-it-crash?" test?

I find always passing rectangles by value a lot easier as it avoids many references and dereferences and I assume that the compiler will always use the faster one either way. If you don't like the change feel free to only merge the first commit.

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

bors-servo commented May 19, 2018

💔 Test failed - mac-rel-wpt4

@jdm
Copy link
Member

jdm commented May 19, 2018

@bors-servo retry

@bors-servo
Copy link
Contributor

bors-servo commented May 19, 2018

Testing commit 89af7cb with merge ea214e9...

bors-servo added a commit that referenced this pull request May 19, 2018
Fix crash in DL building

Fix one crash and some style changes.

This HTML crashed servo before. Key parts are `background-clip: content-box` and `direction: rtl`

```html
<!DOCTYPE html>
<html>
    <style>
        #span1 {
            background-clip: content-box;
        }
        #span2
        {
            direction: rtl;
        }
    </style>
    <span id="span1">Filler Text <span id="span2">txeT relliF</span></span>
</html>
```
Should I add this as a test? And where do I put this "does-it-crash?" test?

I find always passing rectangles by value a lot easier as it avoids many references and dereferences and I assume that the compiler will always use the faster one either way. If you don't like the change feel free to only merge the first commit.

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

bors-servo commented May 19, 2018

@bors-servo bors-servo merged commit 89af7cb into servo:master May 19, 2018
2 of 3 checks passed
2 of 3 checks passed
continuous-integration/travis-ci/pr The Travis CI build failed
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
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.

None yet

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