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

Text with <br> and text-align: justify is positioned wrong #11295

Open
ocerman opened this issue May 20, 2016 · 3 comments
Open

Text with <br> and text-align: justify is positioned wrong #11295

ocerman opened this issue May 20, 2016 · 3 comments

Comments

@ocerman
Copy link

@ocerman ocerman commented May 20, 2016

justify

<!DOCTYPE html>
<html><body>
    <style>
        *{ text-align: justify; }
    </style>
    <div>
    Lorem ipsum<br>
    Lorem ipsum<br>
    Lorem ipsum<br>
    </div>
</body></html> 
@bks
Copy link

@bks bks commented Apr 16, 2017

I can confirm that this bug is still present as of the 2017-04-14 Windows nightly build. I encountered it in the wild, reduced a test case, and then recognized that it was already reported here.

@nox
Copy link
Member

@nox nox commented Oct 1, 2017

This still happens.

@nox nox added the C-reproduced label Oct 1, 2017
@bobthekingofegypt
Copy link
Contributor

@bobthekingofegypt bobthekingofegypt commented Nov 23, 2017

I'm not working on this, but I'm using inline bugs just as a reference point to investigate how the crazy world of layout works.

I made some notes when looking at this one, there are just my impression of what the problem is; if these kind of notes aren't helpful just let me know.

The problem here is that servo is treating <br> as a text fragment that contains a newline which cause the line scanner to wrap to a new line. This means that servo treats this sample as multiline text when chrome and firefox appear to treat each br as a break in the flow.

You can see what chrome is doing when you start to consider the text-align-last property. text-align: justify will justify all lines apart from the last one which will inherit by default the auto(left) alignement from text-align-last.

Setting text-align-last to justify chrome will do this

<!DOCTYPE html>
<html><body>
    <style>
        *{ text-align: justify; text-align-last: justify; }
    </style>
    <div>
    Lorem ipsum<br>
    Lorem ipsum<br>
    Lorem ipsum<br>
    </div>
</body></html>  

Because each line is independant setting the last line to justify aligns them all.

chrome-justify-last

Same with telling chrome to give the br a line height, in servo this will effect all lines of text but chrome it won't as they are not being treated as a set of inline elements. Chrome and firefox appear to differ on how to apply the line height to the rest of the text on that line, chrome doesn't simulating text-align:top type behaviour where firefox treats it like having any other inline element with a line height and sets it to the baseline which will be near center.

<!DOCTYPE html>
<html><body>
    <style>
        *{ text-align: justify; text-align-last: justify; }
    </style>
    <div>
    Lorem ipsum<br style="line-height: 4em">
    Lorem ipsum<br>
    Lorem ipsum<br>
    </div>
</body></html> 

chrome-justify-last line-height

I don't really see anywhere in the specs that this behaviour is defined, br is just a special element.

As for servo, if mimiching chrome and firefox, I thought that attempting to define this behaviour once it gets to the line scanner would be difficult. Thinking that splitting them earlier into three annonymous blocks would be easier, each with their own inlineflow so line-height and text justify would work. I tried looking at {ib} splits, but there is too much stuff I'm not understanding about layout still so I'm going to go back to just looking around layout code for now.

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.

None yet
5 participants
You can’t perform that action at this time.