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 upHTML List works #1 #1524
HTML List works #1 #1524
Conversation
highfive
commented
Jan 21, 2014
|
hoppipolla-critic-bot
commented
Jan 21, 2014
|
Critic review: https://critic.hoppipolla.co.uk/r/605 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 |
|
Several suggestions were made yesterday. Since list markers are just text usually, you can use the unicode glyphs for that. Then you can test a list against a set of (Where |
|
@metajack OK. This PR is not acceptable to merge, yet? I think we can just put this base code into mainstream and then add remained stuffs step by step. |
|
Please use the same terminology as the spec:
http://dev.w3.org/csswg/css-lists/#counter |
|
|
||
| // 12.5 Lists | ||
| ${new_style_struct("List")} | ||
| ${single_keyword("list-style-type", "disc circle square decimal decimal-leading-zero lower-roman upper-roman lower-greek lower-latin upper-latin armenian georgian lower-alpha upper-alpha none", inherited=True)} |
This comment has been minimized.
This comment has been minimized.
SimonSapin
Jan 23, 2014
Member
Do not include here values that are not implemented yet (especially if they trigger fail!().) Keep them in a TODO comment instead.
This comment has been minimized.
This comment has been minimized.
| let mut style_type = None; | ||
| let mut style_position = None; | ||
| let mut style_image = None; | ||
| for component_value in iter { |
This comment has been minimized.
This comment has been minimized.
SimonSapin
Jan 23, 2014
Member
This isn’t quite right. Parsing none values in the list-style shorthand is tricky, because you don’t always know what longhand they belong to when you see them. You have to count the number of nones you see and assign them after the fact.
Have a look at the WeasyPrint code for this
| if style_type.is_none() { | ||
| match list_style_type::from_component_value(component_value) { | ||
| Some(s) => { style_type = Some(s); continue }, | ||
| None => () |
This comment has been minimized.
This comment has been minimized.
SimonSapin
Jan 23, 2014
Member
Invalid values should not be silently ignored, but should have the declaration be rejected. (Use return None to do that.)
This comment has been minimized.
This comment has been minimized.
| fn to_roman(&self, number: int) -> ~str; | ||
| } | ||
|
|
||
| impl Roman for HashMap<int, ~str> { |
This comment has been minimized.
This comment has been minimized.
SimonSapin
Jan 23, 2014
Member
This does not need a hashmap and can be done with a list ordered by greater-valued "digits" first. Also, it’d be nice to separate the roman-specific data from the generic "additive system" algorithm described in the spec. Then the same algorithm can be used for other counter styles.
http://dev.w3.org/csswg/css-counter-styles/#additive-system
http://dev.w3.org/csswg/css-counter-styles/#predefined-counters
This comment has been minimized.
This comment has been minimized.
| }; | ||
| match node.with_element(|e: &LayoutElement| {e.get_attr(None, "reversed")}) { | ||
| Some(s) => { | ||
| if s == ~"true" {is_reversed = true;} |
This comment has been minimized.
This comment has been minimized.
SimonSapin
Jan 23, 2014
Member
reversed is a boolean attribute. The spec says:
The presence of a boolean attribute on an element represents the true value, and the absence of the attribute represents the false value.
Note: The values "true" and "false" are not allowed on boolean attributes. To represent a false value, the attribute has to be omitted altogether.
("Not allowed" here is an author requirement, not an implementation requirement)
So you want something like is_reversed = e.get_attr(None, "reversed").is_some()
This comment has been minimized.
This comment has been minimized.
| ol[type="A"] { list-style-type: upper-alpha; } | ||
| ol[type="i"] { list-style-type: lower-roman; } | ||
| ol[type="I"] { list-style-type: upper-roman; } | ||
| ol[type="1"], li[type="1"] { list-style-type: decimal; } |
This comment has been minimized.
This comment has been minimized.
SimonSapin
Jan 23, 2014
Member
This is wrong. <li> elements do not have this type attribute. Only <ol> does.
This comment has been minimized.
This comment has been minimized.
recrack
Jan 23, 2014
Contributor
@SimonSapin
this UA is from http://www.whatwg.org/specs/web-apps/current-work/multipage/rendering.html#decohints
ol[type=1], li[type=1] { list-style-type: decimal; }
ol[type=a], li[type=a] { list-style-type: lower-alpha; }
ol[type=A], li[type=A] { list-style-type: upper-alpha; }
...
This comment has been minimized.
This comment has been minimized.
SimonSapin
Jan 23, 2014
Member
My bad, type on <li> elements is in the spec, I had missed it as it’s in the Obsolete features section. This diff chunk is fine, then.
|
I’m concerned that this uses ad-hoc Rust code specific to lists rather than CSS counters. Was there a reason to not follow the plan I suggested in #1232 (comment) ? That plan is only my opinion and I’m happy to discuss it if you disagree and possibly change my mind, but that conversation did not happen. |
|
@SimonSapin What I'm trying to tell you is that this commit is just a initial work for granting structurally allowance, not perfect commit. (You can see "#1" flag at the title of this issue) I think that we can remove "ad-hoc Rust code specific to lists" in construct.rs if we will complete the works you suggested. I'll be happy if I can get your opinion. |
| @@ -488,16 +492,32 @@ impl BlockFlow { | |||
| box_.position.set(position); | |||
| } | |||
|
|
|||
| /// wrapper of build_display_list. For switching to html list. | |||
| pub fn build_display_list_wrapper<E:ExtraDisplayListData>( | |||
This comment has been minimized.
This comment has been minimized.
metajack
Jan 24, 2014
Contributor
It seems very odd that we'd need custom display list items for list markers. I don't think this is quite right. Can you explain the design decision here?
This comment has been minimized.
This comment has been minimized.
aydinkim
Jan 27, 2014
Author
@metajack
There are 2 resons for making "build_display_list_wrapper"
- To avoid code duplication
The code below is used both block and float function.
I think it is same code. Just purpose of refactoring.
// add box that starts block context
for box_ in self.box_.iter() {
box_.build_display_list(builder, dirty, offset, flow, list)
}
- To add display item which doesn't take effect on box calculation.
To represent display list marker, we had needed a list item. I think that normal list item affects box dimension calculation. but as I checked Firefox& Chrome, list marker does not belong to its own box. It was just a display level item for showing and acts independently. @pcwalton said to me that I should not make any other flow, and use the block flow to make list. So I had added custom list maker at there for avoiding any influence to box calculation. I thought that only difference of block and list is just exist or not of marker for now. (in aspect of appearance)
If it is not proper to design of servo, please let me know.
I'll follow your advice.
|
@SimonSapin r? |
|
@recrack Explanations of why the code does something are better as code comment than github comment, which become hard to find after the review is done. Other than that, I’m sorry but I am not able to do a full review at the moment. @larsbergstrom agreed take over. |
|
I'd like to see this work split into two parts.
http://dev.w3.org/csswg/css-lists/#counter This will reuse code currently in layout/counter-style.rs. The goal of this commit is to have working support for the
http://dev.w3.org/csswg/css-lists/#ua-stylesheet This change will remove the code in layout/construct.rs that handles incrementing or decrementing the counters explicitly, as the style system will now handle tracking the counts as well as the correct marker-style. This change should be able to reuse the changes you made to properties.rs.mako to identify the To insert the marker, rather than writing your own code in the flow and display list builders, please use the approach used for pseudo-element construction in #1496, which should land very soon. I apologize for the delay in my feedback on this PR and will be more involved with these changes going forward. Please do not hesitate to ask me questions, either in a GitHub Issue or on IRC. |
|
In our opinion, this is not a suitable commit for now. We had almost completed the Acid2 works and list spec. is not significant point for that works. We had decided that this works would be abandoned if anyone doesn't mind about this. Next time we might be able to make more better code. |
aydinkim commentedJan 21, 2014
added list sequence calculation
added list style parsing & cascading
added sequence converter (toward roman, alphabet etc)
added list marker
To Do.
support more list style
support more sequence type converter kind
add some TCs
boost up performance
appearance verification