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

Fixing issue #213 (text-align: justify) and issues with non-left alignment on width_overflown lines #1638

Closed
wants to merge 10 commits into from

Conversation

@FremyCompany
Copy link

FremyCompany commented Feb 7, 2014

I guess some changes will be necessary but the functionality itself looks ok. I uploaded test cases here: http://sdrv.ms/1b4QAvZ

@jdm

This comment has been minimized.

Copy link

jdm commented on src/components/gfx/text/text_run.rs in 36c1f8e Feb 6, 2014

Much more elegant: self.iter_slices_for_range(range).all(|(glyphs, _, _)| glyphs.is_whitespace())

@jdm

This comment has been minimized.

Copy link

jdm commented on src/components/main/layout/box_.rs in 36c1f8e Feb 6, 2014

_ => false

@jdm

This comment has been minimized.

Copy link

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.

@jdm

This comment has been minimized.

Copy link

jdm commented on src/components/main/layout/inline.rs in 36c1f8e Feb 6, 2014

No need for (), spaces around >=

@jdm

This comment has been minimized.

Copy link

jdm commented on src/components/main/layout/inline.rs in 36c1f8e Feb 6, 2014

whitespace_width.to_f64().unwrap_or(1.0)

This comment has been minimized.

Copy link

jdm replied Feb 6, 2014

I don't think the f64 in the name adds any useful information.

@jdm

This comment has been minimized.

Copy link

jdm commented on src/components/main/layout/inline.rs in 36c1f8e Feb 6, 2014

Space around +

@jdm

This comment has been minimized.

Copy link

jdm commented on src/components/main/layout/inline.rs in 36c1f8e Feb 6, 2014

No need for ().

@jdm

This comment has been minimized.

Copy link

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.

Copy link
Owner Author

FremyCompany replied Feb 6, 2014

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).

@jdm

This comment has been minimized.

Copy link

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.

Copy link
Owner Author

FremyCompany replied Feb 6, 2014

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.

Copy link

jdm replied Feb 6, 2014

That sounds reasonable to me.

@jdm

This comment has been minimized.

Copy link

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.

@jdm

This comment has been minimized.

Copy link

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;
}
@jdm

This comment has been minimized.

Copy link

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.

@jdm

This comment has been minimized.

Copy link

jdm commented on src/components/main/layout/inline.rs in 36c1f8e Feb 6, 2014

+= new_size.width

This comment has been minimized.

Copy link
Owner Author

FremyCompany replied Feb 6, 2014

I didn't write this line :-)

@FremyCompany

This comment has been minimized.

Copy link
Owner Author

FremyCompany commented on src/components/main/layout/inline.rs in 36c1f8e Feb 6, 2014

just figured out some lines were also commited here:
2d23073

@highfive
Copy link

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
Copy link

highfive commented Feb 7, 2014

warning Warning warning

  • These commits modify layout code, but no reftests are modified. Please consider adding a reftest!
  • @FremyCompany, please confirm that src/test/html/acid1.html and your favourite wikipedia page still render correctly!
@hoppipolla-critic-bot
Copy link

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 git rebase -i or git commit --amend) when updating this pull request.

@larsbergstrom
Copy link
Contributor

larsbergstrom commented Feb 13, 2014

@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 :-)

@FremyCompany
Copy link
Author

FremyCompany commented Feb 13, 2014

Can we use the Ahem font for ref tests? I find it hard to write good ref tests without it.

@SimonSapin
Copy link
Member

SimonSapin commented Feb 13, 2014

@FremyCompany I filed #1685 about making Ahem a requirement. In the meantime, go ahead and use it in your tests.

@FremyCompany
Copy link
Author

FremyCompany commented Feb 15, 2014

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?

@FremyCompany
Copy link
Author

FremyCompany commented Feb 16, 2014

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.

@larsbergstrom
Copy link
Contributor

larsbergstrom commented Feb 28, 2014

@SimonSapin can you look at https://critic.hoppipolla.co.uk/showcomment?chain=2851 (the stylesheet change)?

@metajack
Copy link
Contributor

metajack commented May 2, 2014

@SimonSapin ping!

@SimonSapin SimonSapin mentioned this pull request May 7, 2014
@SimonSapin
Copy link
Member

SimonSapin commented May 7, 2014

@metajack I had already replied a while ago to the issue Lars liked to, but I just filed #2362 about <br>. As far as I can tell there is only two minor issues left, and this will need a rebase.

@jdm
Copy link
Member

jdm commented Feb 21, 2015

I filed #5008 about #1638 (comment). Since #4610 merged, I think the rest of this PR is now duplicated effort, unfortunately.

@jdm jdm closed this Feb 21, 2015
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

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