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

Basic support for bidirectional text #6471

Merged
merged 1 commit into from Jul 24, 2015
Merged

Basic support for bidirectional text #6471

merged 1 commit into from Jul 24, 2015

Conversation

@mbrubeck
Copy link
Contributor

mbrubeck commented Jun 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 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.

Review on Reviewable

@hoppipolla-critic-bot
Copy link

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

@@ -272,6 +310,7 @@ impl LineBreaker {
flow: &'a InlineFlow,
layout_context: &LayoutContext)
where I: Iterator<Item=Fragment> {

This comment has been minimized.

@pcwalton

pcwalton Jul 6, 2015

Contributor

nit: remove this newline

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

@pcwalton

pcwalton Jul 6, 2015

Contributor

Can you change this to debug_assert! while you're here?

(range.end().get() - 1, range.begin().get() - 1, -1)
} else {
(range.begin().get(), range.end().get(), 1)
};

This comment has been minimized.

@pcwalton

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.

@pcwalton

pcwalton Jul 6, 2015

Contributor

nit: typo: "concatenated"

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

@pcwalton

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.

@pcwalton

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

@pcwalton
Copy link
Contributor

pcwalton commented Jul 6, 2015

Looks good to me once these issues are addressed.

@mbrubeck mbrubeck force-pushed the mbrubeck:bidi branch 3 times, most recently from 61caa3f to 83c41d2 Jul 6, 2015
@mbrubeck
Copy link
Contributor Author

mbrubeck commented Jul 6, 2015

@mbrubeck
Copy link
Contributor Author

mbrubeck commented Jul 6, 2015

Squashed and rebased, with review comments addressed. Now just waiting on servo/unicode-bidi#4.

@SimonSapin
Copy link
Member

SimonSapin commented Jul 13, 2015

I found some small issues in the unicode-bidi crate, but nothing that should block this.

@bors-servo r=pcwalton

@bors-servo
Copy link
Contributor

bors-servo commented Jul 13, 2015

📌 Commit 83c41d2 has been approved by pcwalton

@bors-servo
Copy link
Contributor

bors-servo commented Jul 13, 2015

Testing commit 83c41d2 with merge 391948c...

bors-servo pushed a commit that referenced this pull request Jul 13, 2015
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
Copy link
Contributor

bors-servo commented Jul 13, 2015

💔 Test failed - mac1

@jdm
Copy link
Member

jdm commented Jul 13, 2015

/html/semantics/forms/the-textarea-element/textarea-newline-bidi.html
---------------------------------------------------------------------
FAIL [Parent]
/html/semantics/grouping-content/the-pre-element/pre-newline-bidi.html
----------------------------------------------------------------------
FAIL [Parent]
/html/semantics/text-level-semantics/the-bdo-element/bdo-override.html
----------------------------------------------------------------------
FAIL [Parent]
/html/semantics/text-level-semantics/the-br-element/br-bidi.html
----------------------------------------------------------------
FAIL [Parent]
@bors-servo
Copy link
Contributor

bors-servo commented Jul 14, 2015

The latest upstream changes (presumably #6619) made this pull request unmergeable. Please resolve the merge conflicts.

@mbrubeck mbrubeck force-pushed the mbrubeck:bidi branch from 83c41d2 to fd9598d Jul 19, 2015
@mbrubeck
Copy link
Contributor Author

mbrubeck commented Jul 19, 2015

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.

@bors-servo
Copy link
Contributor

bors-servo commented Jul 20, 2015

The latest upstream changes (presumably #6648) made this pull request unmergeable. Please resolve the merge conflicts.

@mbrubeck mbrubeck force-pushed the mbrubeck:bidi branch from bd84a87 to 6a43283 Jul 23, 2015
@pcwalton
Copy link
Contributor

pcwalton commented Jul 24, 2015

This looks good. I just had one question.

@mbrubeck
Copy link
Contributor Author

mbrubeck commented Jul 24, 2015

@bors-servo r=pcwalton

@bors-servo
Copy link
Contributor

bors-servo commented Jul 24, 2015

📌 Commit 70dbf03 has been approved by pcwalton

@bors-servo
Copy link
Contributor

bors-servo commented Jul 24, 2015

Testing commit 70dbf03 with merge 51930c8...

bors-servo pushed a commit that referenced this pull request Jul 24, 2015
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
Copy link
Contributor

bors-servo commented Jul 24, 2015

💔 Test failed - mac3

@mbrubeck
Copy link
Contributor Author

mbrubeck commented Jul 24, 2015

@bors-servo r=pcwalton

@bors-servo
Copy link
Contributor

bors-servo commented Jul 24, 2015

📌 Commit dfac8ce has been approved by pcwalton

@bors-servo
Copy link
Contributor

bors-servo commented Jul 24, 2015

Testing commit dfac8ce with merge d3a36fa...

bors-servo pushed a commit that referenced this pull request Jul 24, 2015
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
Copy link
Contributor

bors-servo commented Jul 24, 2015

☀️ Test successful - android, gonk, linux1, linux2, linux3, mac1, mac2, mac3

@bors-servo bors-servo merged commit dfac8ce into servo:master Jul 24, 2015
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@mbrubeck mbrubeck deleted the mbrubeck:bidi branch May 11, 2016
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.