[gfx] [layout] [style] Upgrade unicode-bidi to 0.3

This commit is contained in:
Behnam Esfahbod 2017-05-16 11:38:42 -05:00
parent 594479fe15
commit 14c524df4f
10 changed files with 61 additions and 34 deletions

View file

@ -67,6 +67,7 @@ style_derive = {path = "../style_derive"}
style_traits = {path = "../style_traits"}
servo_url = {path = "../url", optional = true}
time = "0.1"
unicode-bidi = {version = "0.3", features = ["with_serde"]}
unicode-segmentation = "1.0"
[target.'cfg(windows)'.dependencies]

View file

@ -83,6 +83,7 @@ extern crate style_derive;
#[macro_use]
extern crate style_traits;
extern crate time;
extern crate unicode_bidi;
#[allow(unused_extern_crates)]
extern crate unicode_segmentation;

View file

@ -10,6 +10,7 @@ use euclid::side_offsets::SideOffsets2D;
use std::cmp::{max, min};
use std::fmt::{self, Debug, Error, Formatter};
use std::ops::{Add, Sub};
use unicode_bidi as bidi;
pub enum BlockFlowDirection {
TopToBottom,
@ -131,9 +132,13 @@ impl WritingMode {
#[inline]
/// The default bidirectional embedding level for this writing mode.
///
/// Returns 0 if the mode is LTR, or 1 otherwise.
pub fn to_bidi_level(&self) -> u8 {
!self.is_bidi_ltr() as u8
/// Returns bidi level 0 if the mode is LTR, or 1 otherwise.
pub fn to_bidi_level(&self) -> bidi::Level {
if self.is_bidi_ltr() {
bidi::Level::ltr()
} else {
bidi::Level::rtl()
}
}
}