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 upSupport 'vertical-align' and 'line-height'. #764
Conversation
|
This isn't quite correct yet, at least as far as the end result goes. The following test file:
produces It apears that the first line is (maybe?) correctly sized, but the vertical-align is off. The remainder of the lines have incorrect height. |
This comment has been minimized.
This comment has been minimized.
metajack
commented on src/components/main/layout/inline.rs in 3b3f3f8
Aug 23, 2013
|
Factoring this out is great. |
BrendanEich
commented
Aug 23, 2013
|
@dbaron has been writing https://github.com/dbaron/inlines-and-floats It's still under construction but worth a look. /be |
|
@metajack fixed the error! It was a simple mistake. thanks for comment :) |
|
ACID1 Pass ! |
|
@yichoi not quite. The reference image and servo's image show some very minor border issues on right borders: This is unrelated to @june0cho's work, and should be easy to fix. |
|
@BrendanEich Thanks, I added that to https://github.com/mozilla/servo/wiki/General-implementation-and-design-notes |
| } | ||
| text_bounds.translate(&Point2D(text_box.base.position.origin.x, Au(0))) | ||
| } | ||
| // Find the top and bottom of the content area. |
This comment has been minimized.
This comment has been minimized.
metajack
Aug 27, 2013
Contributor
Is this supposed to be a TODO comment? I don't see the code actually doing this.
| @@ -654,80 +665,206 @@ impl InlineFlowData { | |||
| } | |||
| }; | |||
|
|
|||
| // Update the line's y position before setting the box's y position | |||
This comment has been minimized.
This comment has been minimized.
metajack
Aug 27, 2013
Contributor
I don't understand this comment. Can you explain more? Why would the current linebox ever cause a previous linebox to change values?
This comment has been minimized.
This comment has been minimized.
june0cho
Aug 27, 2013
Author
Contributor
My comment was not enough. I meant that the start offset(uppermost) of the current linebox is set by the previous line's height. line_height_offset is updated on Line 866.
| let parent_text_bottom = Au(0); | ||
| do cur_box.with_mut_base |base| { | ||
| //get parent node | ||
| let mut parent = base.node; |
This comment has been minimized.
This comment has been minimized.
metajack
Aug 27, 2013
Contributor
A better idiom here is let parent = match base.node.parent_node() { None => base.node, Some(parent) => parent, }. We should minimize use of mut.
This comment has been minimized.
This comment has been minimized.
| } | ||
| let font_size = match parent.style().font_size() { | ||
| CSSFontSizeLength(Px(length)) => length, | ||
| // todo: this is based on a hard coded font size, should be the parent element's font size |
This comment has been minimized.
This comment has been minimized.
metajack
Aug 27, 2013
Contributor
Isn't there already a function to determine this? We have to know this information to calculate the font size elsewhere.
This comment has been minimized.
This comment has been minimized.
june0cho
Aug 27, 2013
Author
Contributor
I've copied Line 747 ~ Line 750 from box.rs. The font size seems not to be correctly calcuated yet elsewhere as well.
| CSSFontSizeLength(Px(length)) => length, | ||
| // todo: this is based on a hard coded font size, should be the parent element's font size | ||
| CSSFontSizeLength(Em(length)) => length * 16f, | ||
| _ => 16f // px units |
This comment has been minimized.
This comment has been minimized.
metajack
Aug 27, 2013
Contributor
So this fails for % values? Again, I think the other bits that deal with this could be reused here, assuming they actually exist.
This comment has been minimized.
This comment has been minimized.
june0cho
Aug 27, 2013
Author
Contributor
As the above comment, the font size seems not to support % values yet.
| CSSFontSizeLength(Em(length)) => length * 16f, | ||
| _ => 16f // px units | ||
| }; | ||
| parent_text_top = Au::from_frac_px(font_size); |
This comment has been minimized.
This comment has been minimized.
metajack
Aug 27, 2013
Contributor
I don't understand what this is. I thought it was the top of the parent's box, but apparently it's the height of the default linebox? This seems kind of odd.
This comment has been minimized.
This comment has been minimized.
june0cho
Aug 27, 2013
Author
Contributor
parent_text_top is used when vertical-align is 'text-top'. parent_text_top should be the top of parent's content area and content area is defined in http://www.w3.org/TR/CSS2/visudet.html#inline-non-replaced. But since I couldn't find how to extract the em-box of the font, I assumed that the parent_text_top is font-size of parent and parent_text_bottom is 0 (Line 736).
| parent_text_top = Au::from_frac_px(font_size); | ||
| } | ||
|
|
||
| let mut no_update_flag = false; |
This comment has been minimized.
This comment has been minimized.
|
@june0cho I have a lot of questions about this code. I suspect perhaps I am misunderstanding the names of things. Please ping me in IRC. |
|
In the new commit, I applied your comments which are left here and talked in IRC today. |
This comment has been minimized.
This comment has been minimized.
metajack
commented on src/components/main/layout/inline.rs in 729ac0c
Aug 27, 2013
|
Typo: |
This comment has been minimized.
This comment has been minimized.
|
ohhh another same typo exists :( should fix it. |
This comment has been minimized.
This comment has been minimized.
metajack
commented on 729ac0c
Aug 27, 2013
|
r+ |
This comment has been minimized.
This comment has been minimized.
|
saw approval from metajack |
This comment has been minimized.
This comment has been minimized.
|
merging june0cho/servo/verticalalign = 729ac0c into auto |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
fast-forwarding master to auto = 4e68c1a |
This is a modification of the previous PR #741 to support 'vertical-align' and 'line-height'. Added test cases for vertical-align, line-height, and mixed. In the last commit, after applying 'vertical-align' property, the current line-box's height and following line-boxes' heights are being updated. This is because line-box's height was already assigned when the line-box is created. But there may be a better way, though I'm not sure. In Gecko, line-boxes' heights seem to be assigned at one time after 'vertical-align'. @metajack
Fix manifest JSONifier for new iteration API.

june0cho commentedAug 23, 2013
This is a modification of the previous PR #741 to support 'vertical-align' and 'line-height'. Added test cases for vertical-align, line-height, and mixed.
In the last commit, after applying 'vertical-align' property, the current line-box's height and following line-boxes' heights are being updated. This is because line-box's height was already assigned when the line-box is created.
But there may be a better way, though I'm not sure. In Gecko, line-boxes' heights seem to be assigned at one time after 'vertical-align'. @metajack