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 upBasic support for bidirectional text #6471
Conversation
hoppipolla-critic-bot
commented
Jun 26, 2015
|
Critic review: https://critic.hoppipolla.co.uk/r/5384 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 |
| @@ -272,6 +310,7 @@ impl LineBreaker { | |||
| flow: &'a InlineFlow, | |||
| layout_context: &LayoutContext) | |||
| where I: Iterator<Item=Fragment> { | |||
|
|
|||
This comment has been minimized.
This comment has been minimized.
| @@ -612,7 +651,7 @@ impl LineBreaker { | |||
| line_flush_mode: LineFlushMode) { | |||
| let indentation = self.indentation_for_pending_fragment(); | |||
| if self.pending_line_is_empty() { | |||
| assert!(self.new_fragments.len() <= (u16::MAX as usize)); | |||
| assert!(self.new_fragments.len() <= (isize::MAX as usize)); | |||
This comment has been minimized.
This comment has been minimized.
| (range.end().get() - 1, range.begin().get() - 1, -1) | ||
| } else { | ||
| (range.begin().get(), range.end().get(), 1) | ||
| }; |
This comment has been minimized.
This comment has been minimized.
pcwalton
Jul 6, 2015
Contributor
I wonder if you can just create the iterator inside the then and else branches instead of creating all these temporaries.
| use util::geometry::Au; | ||
| use util::linked_list::split_off_head; | ||
| use util::logical_geometry::{LogicalSize, WritingMode}; | ||
| use util::range::{Range, RangeIndex}; | ||
|
|
||
| /// Returns the concatened text of a list of unscanned text fragments. |
This comment has been minimized.
This comment has been minimized.
| @@ -350,7 +389,7 @@ impl LineBreaker { | |||
| fn flush_current_line(&mut self) { | |||
| debug!("LineBreaker: flushing line {}: {:?}", self.lines.len(), self.pending_line); | |||
| self.strip_trailing_whitespace_from_pending_line_if_necessary(); | |||
| self.lines.push(self.pending_line); | |||
| self.lines.push(self.pending_line.clone()); | |||
This comment has been minimized.
This comment has been minimized.
pcwalton
Jul 6, 2015
Contributor
I'm a bit worried about the performance implications of doing this, now that there's a vec (possibly) inside the line. It'd probably be better to have reset_line() swap out the current line and return the old one. What do you think?
|
|
||
| #[inline] | ||
| pub fn to_bidi_level(&self) -> u8 { | ||
| if self.is_bidi_ltr() { 0 } else { 1 } |
This comment has been minimized.
This comment has been minimized.
pcwalton
Jul 6, 2015
Contributor
Could probably be (!self.is_bidi_ltr()) as u8, which may codegen better. (LLVM is not very good at simplifying branches.)
|
Looks good to me once these issues are addressed. |
61caa3f
to
83c41d2
|
Review status: 0 of 18 files reviewed at latest revision, 6 unresolved discussions, all commit checks successful. components/layout/inline.rs, line 313 [r6] (raw file): components/layout/inline.rs, line 392 [r6] (raw file): components/layout/inline.rs, line 654 [r6] (raw file): components/layout/inline.rs, line 979 [r6] (raw file): components/layout/text.rs, line 32 [r6] (raw file): components/util/logical_geometry.rs, line 91 [r6] (raw file): Comments from the review on Reviewable.io |
|
Squashed and rebased, with review comments addressed. Now just waiting on servo/unicode-bidi#4. |
|
I found some small issues in the unicode-bidi crate, but nothing that should block this. @bors-servo r=pcwalton |
|
|
Basic support for bidirectional text This re-orders text according to the Unicode bidirectional layout algorithm, using the [unicode-bidi](https://github.com/mbrubeck/unicode-bidi) crate. It uses the natural order of the text based on Unicode character properties and the CSS `direction` property. This does not yet support the CSS `unicode-bidi` property or the HTML `dir` attribute, but these should be straightforward to add. r? @pcwalton. Also depends on servo/unicode-bidi#4. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6471) <!-- Reviewable:end -->
|
|
|
|
|
|
The test failures were caused by a failure to force paragraph breaks in preformatted text. This patch fixes the problem. Depends on servo/unicode-bidi#12. r? @pcwalton This could use some further optimization (see the FIXME comment), but I want to wait a bit to work out how this fits in with other changes to fragmentation and text run construction. |
|
|
|
This looks good. I just had one question. |
|
@bors-servo r=pcwalton |
|
|
|
|
Basic support for bidirectional text This re-orders text according to the Unicode bidirectional layout algorithm, using the [unicode-bidi](https://github.com/mbrubeck/unicode-bidi) crate. It uses the natural order of the text based on Unicode character properties and the CSS `direction` property. This does not yet support the CSS `unicode-bidi` property or the HTML `dir` attribute, but these should be straightforward to add. r? @pcwalton. Also depends on servo/unicode-bidi#4. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6471) <!-- Reviewable:end -->
|
|
|
@bors-servo r=pcwalton |
|
|
Basic support for bidirectional text This re-orders text according to the Unicode bidirectional layout algorithm, using the [unicode-bidi](https://github.com/mbrubeck/unicode-bidi) crate. It uses the natural order of the text based on Unicode character properties and the CSS `direction` property. This does not yet support the CSS `unicode-bidi` property or the HTML `dir` attribute, but these should be straightforward to add. r? @pcwalton. Also depends on servo/unicode-bidi#4. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6471) <!-- Reviewable:end -->
mbrubeck commentedJun 26, 2015
This re-orders text according to the Unicode bidirectional layout algorithm, using the unicode-bidi crate. It uses the natural order of the text based on Unicode character properties and the CSS
directionproperty.This does not yet support the CSS
unicode-bidiproperty or the HTMLdirattribute, but these should be straightforward to add.r? @pcwalton. Also depends on servo/unicode-bidi#4.