Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upFixing issue #213 (text-align: justify) and issues with non-left alignment on width_overflown lines #1638
Conversation
This comment has been minimized.
This comment has been minimized.
jdm
commented on src/components/gfx/text/text_run.rs in 36c1f8e
Feb 6, 2014
|
Much more elegant: |
This comment has been minimized.
This comment has been minimized.
jdm
commented on src/components/main/layout/box_.rs in 36c1f8e
Feb 6, 2014
|
_ => false |
This comment has been minimized.
This comment has been minimized.
jdm
commented on src/components/main/layout/inline.rs in 36c1f8e
Feb 6, 2014
|
These should probably be bitfields if we expect to create lots of LineBoxes. |
This comment has been minimized.
This comment has been minimized.
jdm
commented on src/components/main/layout/inline.rs in 36c1f8e
Feb 6, 2014
|
No need for (), spaces around >= |
This comment has been minimized.
This comment has been minimized.
jdm
commented on src/components/main/layout/inline.rs in 36c1f8e
Feb 6, 2014
|
|
This comment has been minimized.
This comment has been minimized.
jdm
replied
Feb 6, 2014
|
I don't think the f64 in the name adds any useful information. |
This comment has been minimized.
This comment has been minimized.
jdm
commented on src/components/main/layout/inline.rs in 36c1f8e
Feb 6, 2014
|
Space around + |
This comment has been minimized.
This comment has been minimized.
jdm
commented on src/components/main/layout/inline.rs in 36c1f8e
Feb 6, 2014
|
No need for (). |
This comment has been minimized.
This comment has been minimized.
jdm
commented on src/components/main/layout/inline.rs in 36c1f8e
Feb 6, 2014
|
This is better an Option value instead of using a magic constant, I think. |
This comment has been minimized.
This comment has been minimized.
|
Well, this is only a temporary fix until I get how to loop in the reverse order, because then you can just use "let mut could_meet_leading_whitespace = true" and set it to false as soon as you see a non-whitespace box (because then you can do this loop and the next one in one single pass). |
This comment has been minimized.
This comment has been minimized.
jdm
commented on src/components/main/layout/inline.rs in 36c1f8e
Feb 6, 2014
|
I think it would be better to create named temporary variables and pass those instead of using these comments. |
This comment has been minimized.
This comment has been minimized.
|
I think I should just create another instace function to Box, which would be split_asap(trim_whitespace_separators) which would provide those values as a default, and rename the "split_to_width_forced" method into "split_to_width_with_params" (and maybe mark it private). |
This comment has been minimized.
This comment has been minimized.
jdm
replied
Feb 6, 2014
|
That sounds reasonable to me. |
This comment has been minimized.
This comment has been minimized.
jdm
commented on src/components/main/layout/box_.rs in 36c1f8e
Feb 6, 2014
|
I think we tend to discourage one-line things like this. |
This comment has been minimized.
This comment has been minimized.
jdm
commented on src/components/main/layout/box_.rs in 36c1f8e
Feb 6, 2014
|
Maybe just if !should_continue && (!trim_whitespace_separator || !glyphs.is_whitespace()) {
break;
} |
This comment has been minimized.
This comment has been minimized.
jdm
commented on 36c1f8e
Feb 6, 2014
|
There are various constructs like if ... {
...something
}where the extra newlines should be compressed. I don't think they tend to help readability much. |
This comment has been minimized.
This comment has been minimized.
jdm
commented on src/components/main/layout/inline.rs in 36c1f8e
Feb 6, 2014
|
+= new_size.width |
This comment has been minimized.
This comment has been minimized.
|
I didn't write this line :-) |
This comment has been minimized.
This comment has been minimized.
|
just figured out some lines were also commited here: |
highfive
commented
Feb 7, 2014
|
Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @larsbergstrom (or someone else) soon. |
highfive
commented
Feb 7, 2014
|
hoppipolla-critic-bot
commented
Feb 7, 2014
|
Critic review: https://critic.hoppipolla.co.uk/r/746 This is an external review system which you may optionally use for the code review of your pull request. In order to help critic track your changes, please do not make in-place history rewrites (e.g. via |
|
@FremyCompany Thanks for this PR! I've commented in critic in detail on the issues to address. I'm excited to see this, though, and am very impressed you managed to jump into this part of the code for your first PR :-) |
|
Can we use the Ahem font for ref tests? I find it hard to write good ref tests without it. |
|
@FremyCompany I filed #1685 about making Ahem a requirement. In the meantime, go ahead and use it in your tests. |
|
I took some time to write an exhaustive test case, and found one remaining issue. The issue is not a regression and is not about "text-align: jusitify" but about "text-align: center" (an maybe "text-align: right" in some cases). Indeed, it seems the default box splitting algorithm accept to break just after a whitespace, generating a box that contains but is not considered as a whitespace, and which is then considered in the alignment. I think the solution would be to add "trim_whitespace_leaders" and "trim_whitespace_traillers" methods to ScannedTextBox and call them once the line alignment has been done (and deduce the size reduction of the line). Does that seem good to you? |
|
I followed the approach state above and got "text-align: right/center" working properly. The work on the more general refactoring is still pending though. |
|
@SimonSapin can you look at https://critic.hoppipolla.co.uk/showcomment?chain=2851 (the stylesheet change)? |
|
@SimonSapin ping! |
|
I filed #5008 about #1638 (comment). Since #4610 merged, I think the rest of this PR is now duplicated effort, unfortunately. |
FremyCompany commentedFeb 7, 2014
I guess some changes will be necessary but the functionality itself looks ok. I uploaded test cases here: http://sdrv.ms/1b4QAvZ