aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRavi Shankar <wafflespeanut@gmail.com>2016-08-09 11:16:53 +0530
committerRavi Shankar <wafflespeanut@gmail.com>2016-08-09 17:53:40 +0530
commita04028eede04654ac020119043b853e77cae5307 (patch)
tree8a1455326bf32bceb9aedbeaad45257c735f8990
parent7ed9134e5a8401380253f75d4a7ce43ab5027241 (diff)
downloadservo-a04028eede04654ac020119043b853e77cae5307.tar.gz
servo-a04028eede04654ac020119043b853e77cae5307.zip
Prefer length and percentage for word spacing
-rw-r--r--components/gfx/Cargo.toml1
-rw-r--r--components/gfx/font.rs7
-rw-r--r--components/gfx/lib.rs1
-rw-r--r--components/gfx/text/shaping/harfbuzz.rs4
-rw-r--r--components/layout/Cargo.toml1
-rw-r--r--components/layout/lib.rs1
-rw-r--r--components/layout/text.rs5
-rw-r--r--components/servo/Cargo.lock25
-rw-r--r--components/style/Cargo.toml1
-rw-r--r--components/style/lib.rs1
-rw-r--r--components/style/properties/longhand/inherited_text.mako.rs11
-rw-r--r--components/style/values/computed/mod.rs10
-rw-r--r--ports/cef/Cargo.lock25
-rw-r--r--ports/geckolib/Cargo.lock50
-rw-r--r--python/tidy/servo_tidy/tidy.py2
15 files changed, 135 insertions, 10 deletions
diff --git a/components/gfx/Cargo.toml b/components/gfx/Cargo.toml
index 450c957886d..62e5927e404 100644
--- a/components/gfx/Cargo.toml
+++ b/components/gfx/Cargo.toml
@@ -28,6 +28,7 @@ log = "0.3.5"
mime = "0.2"
msg = {path = "../msg"}
net_traits = {path = "../net_traits"}
+ordered-float = "0.2.2"
plugins = {path = "../plugins"}
profile_traits = {path = "../profile_traits"}
rand = "0.3"
diff --git a/components/gfx/font.rs b/components/gfx/font.rs
index e92fff1c58f..7e1cf5236d5 100644
--- a/components/gfx/font.rs
+++ b/components/gfx/font.rs
@@ -5,6 +5,7 @@
use app_units::Au;
use euclid::{Point2D, Rect, Size2D};
use font_template::FontTemplateDescriptor;
+use ordered_float::NotNaN;
use platform::font::{FontHandle, FontTable};
use platform::font_context::FontContextHandle;
use platform::font_template::FontTemplateData;
@@ -157,7 +158,7 @@ pub struct ShapingOptions {
/// NB: You will probably want to set the `IGNORE_LIGATURES_SHAPING_FLAG` if this is non-null.
pub letter_spacing: Option<Au>,
/// Spacing to add between each word. Corresponds to the CSS 2.1 `word-spacing` property.
- pub word_spacing: Au,
+ pub word_spacing: (Au, NotNaN<f32>),
/// The Unicode script property of the characters in this run.
pub script: Script,
/// Various flags.
@@ -225,7 +226,9 @@ impl Font {
let mut advance = Au::from_f64_px(self.glyph_h_advance(glyph_id));
if character == ' ' {
- advance += options.word_spacing;
+ // https://drafts.csswg.org/css-text-3/#word-spacing-property
+ let (length, percent) = options.word_spacing;
+ advance = (advance + length) + Au((advance.0 as f32 * percent.into_inner()) as i32);
}
if let Some(letter_spacing) = options.letter_spacing {
advance += letter_spacing;
diff --git a/components/gfx/lib.rs b/components/gfx/lib.rs
index 58c92f304d9..b16ae9c555b 100644
--- a/components/gfx/lib.rs
+++ b/components/gfx/lib.rs
@@ -60,6 +60,7 @@ extern crate log;
extern crate mime;
extern crate msg;
extern crate net_traits;
+extern crate ordered_float;
#[macro_use]
extern crate profile_traits;
extern crate rand;
diff --git a/components/gfx/text/shaping/harfbuzz.rs b/components/gfx/text/shaping/harfbuzz.rs
index 5106418be61..ba5f281c04d 100644
--- a/components/gfx/text/shaping/harfbuzz.rs
+++ b/components/gfx/text/shaping/harfbuzz.rs
@@ -403,7 +403,9 @@ impl Shaper {
// applied. The effect of the property on other word-separator characters is undefined."
// We elect to only space the two required code points.
if character == ' ' || character == '\u{a0}' {
- advance = advance + options.word_spacing
+ // https://drafts.csswg.org/css-text-3/#word-spacing-property
+ let (length, percent) = options.word_spacing;
+ advance = (advance + length) + Au((advance.0 as f32 * percent.into_inner()) as i32);
}
advance
diff --git a/components/layout/Cargo.toml b/components/layout/Cargo.toml
index 7471c12a5f7..e7c26675e58 100644
--- a/components/layout/Cargo.toml
+++ b/components/layout/Cargo.toml
@@ -26,6 +26,7 @@ libc = "0.2"
log = "0.3.5"
msg = {path = "../msg"}
net_traits = {path = "../net_traits"}
+ordered-float = "0.2.2"
plugins = {path = "../plugins"}
profile_traits = {path = "../profile_traits"}
range = {path = "../range"}
diff --git a/components/layout/lib.rs b/components/layout/lib.rs
index b6f10c7fa89..65066b638e0 100644
--- a/components/layout/lib.rs
+++ b/components/layout/lib.rs
@@ -35,6 +35,7 @@ extern crate libc;
extern crate log;
extern crate msg;
extern crate net_traits;
+extern crate ordered_float;
#[macro_use]
#[no_link]
extern crate plugins as servo_plugins;
diff --git a/components/layout/text.rs b/components/layout/text.rs
index 85e0f620290..1cfbe0de13d 100644
--- a/components/layout/text.rs
+++ b/components/layout/text.rs
@@ -17,6 +17,7 @@ use gfx::text::text_run::TextRun;
use gfx::text::util::{self, CompressionMode};
use inline::{FIRST_FRAGMENT_OF_ELEMENT, InlineFragments, LAST_FRAGMENT_OF_ELEMENT};
use linked_list::split_off_head;
+use ordered_float::NotNaN;
use range::Range;
use std::borrow::ToOwned;
use std::collections::LinkedList;
@@ -164,7 +165,9 @@ impl TextRunScanner {
};
text_transform = inherited_text_style.text_transform;
letter_spacing = inherited_text_style.letter_spacing.0;
- word_spacing = inherited_text_style.word_spacing.0.unwrap_or(Au(0));
+ word_spacing = inherited_text_style.word_spacing.0
+ .map(|lop| lop.to_hash_key())
+ .unwrap_or((Au(0), NotNaN::new(0.0).unwrap()));
text_rendering = inherited_text_style.text_rendering;
}
diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock
index 6a1927a08a7..77079e74a5f 100644
--- a/components/servo/Cargo.lock
+++ b/components/servo/Cargo.lock
@@ -766,6 +766,7 @@ dependencies = [
"mime 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"msg 0.0.1",
"net_traits 0.0.1",
+ "ordered-float 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"plugins 0.0.1",
"profile_traits 0.0.1",
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1124,6 +1125,7 @@ dependencies = [
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"msg 0.0.1",
"net_traits 0.0.1",
+ "ordered-float 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"plugins 0.0.1",
"profile_traits 0.0.1",
"range 0.0.1",
@@ -1607,6 +1609,15 @@ dependencies = [
]
[[package]]
+name = "ordered-float"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "num 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
+ "unreachable 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
name = "osmesa-sys"
version = "0.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2193,6 +2204,7 @@ dependencies = [
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
+ "ordered-float 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"plugins 0.0.1",
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2363,6 +2375,14 @@ dependencies = [
[[package]]
name = "unreachable"
+version = "0.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "void 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "unreachable"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
@@ -2455,6 +2475,11 @@ dependencies = [
[[package]]
name = "void"
+version = "0.0.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "void"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/components/style/Cargo.toml b/components/style/Cargo.toml
index d0e5daddb04..c2fd71dbb3a 100644
--- a/components/style/Cargo.toml
+++ b/components/style/Cargo.toml
@@ -34,6 +34,7 @@ lazy_static = "0.2"
log = "0.3.5"
matches = "0.1"
num-traits = "0.1.32"
+ordered-float = "0.2.2"
rand = "0.3"
rustc-serialize = "0.3"
selectors = "0.7"
diff --git a/components/style/lib.rs b/components/style/lib.rs
index aa1f91b6c83..e6d87d3e916 100644
--- a/components/style/lib.rs
+++ b/components/style/lib.rs
@@ -57,6 +57,7 @@ extern crate log;
#[macro_use]
extern crate matches;
extern crate num_traits;
+extern crate ordered_float;
extern crate rand;
extern crate rustc_serialize;
extern crate selectors;
diff --git a/components/style/properties/longhand/inherited_text.mako.rs b/components/style/properties/longhand/inherited_text.mako.rs
index abf15d3fd04..c166fc47700 100644
--- a/components/style/properties/longhand/inherited_text.mako.rs
+++ b/components/style/properties/longhand/inherited_text.mako.rs
@@ -285,7 +285,7 @@
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub enum SpecifiedValue {
Normal,
- Specified(specified::Length), // FIXME(SimonSapin) support percentages
+ Specified(specified::LengthOrPercentage),
}
impl ToCss for SpecifiedValue {
@@ -298,10 +298,10 @@
}
pub mod computed_value {
- use app_units::Au;
+ use values::computed::LengthOrPercentage;
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
- pub struct T(pub Option<Au>);
+ pub struct T(pub Option<LengthOrPercentage>);
}
impl ToCss for computed_value::T {
@@ -326,7 +326,7 @@
match *self {
SpecifiedValue::Normal => computed_value::T(None),
SpecifiedValue::Specified(l) =>
- computed_value::T(Some(l.to_computed_value(context)))
+ computed_value::T(Some(l.to_computed_value(context))),
}
}
}
@@ -335,7 +335,8 @@
if input.try(|input| input.expect_ident_matching("normal")).is_ok() {
Ok(SpecifiedValue::Normal)
} else {
- specified::Length::parse_non_negative(input).map(SpecifiedValue::Specified)
+ specified::LengthOrPercentage::parse_non_negative(input)
+ .map(SpecifiedValue::Specified)
}
}
</%helpers:longhand>
diff --git a/components/style/values/computed/mod.rs b/components/style/values/computed/mod.rs
index 49b3f2e7285..9864cd67983 100644
--- a/components/style/values/computed/mod.rs
+++ b/components/style/values/computed/mod.rs
@@ -4,6 +4,7 @@
use app_units::Au;
use euclid::size::Size2D;
+use ordered_float::NotNaN;
use properties::ComputedValues;
use std::fmt;
use super::LocalToCss;
@@ -241,6 +242,15 @@ impl LengthOrPercentage {
Length(_) | Percentage(_) | Calc(_) => false
}
}
+
+ pub fn to_hash_key(&self) -> (Au, NotNaN<f32>) {
+ use self::LengthOrPercentage::*;
+ match *self {
+ Length(l) => (l, NotNaN::new(0.0).unwrap()),
+ Percentage(p) => (Au(0), NotNaN::new(p).unwrap()),
+ Calc(c) => (c.length(), NotNaN::new(c.percentage()).unwrap()),
+ }
+ }
}
impl fmt::Debug for LengthOrPercentage {
diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock
index 76b49f1f76a..2b1e36d7804 100644
--- a/ports/cef/Cargo.lock
+++ b/ports/cef/Cargo.lock
@@ -684,6 +684,7 @@ dependencies = [
"mime 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"msg 0.0.1",
"net_traits 0.0.1",
+ "ordered-float 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"plugins 0.0.1",
"profile_traits 0.0.1",
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1033,6 +1034,7 @@ dependencies = [
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"msg 0.0.1",
"net_traits 0.0.1",
+ "ordered-float 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"plugins 0.0.1",
"profile_traits 0.0.1",
"range 0.0.1",
@@ -1481,6 +1483,15 @@ dependencies = [
]
[[package]]
+name = "ordered-float"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "num 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
+ "unreachable 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
name = "osmesa-sys"
version = "0.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2078,6 +2089,7 @@ dependencies = [
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
+ "ordered-float 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"plugins 0.0.1",
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2232,6 +2244,14 @@ dependencies = [
[[package]]
name = "unreachable"
+version = "0.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "void 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "unreachable"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
@@ -2317,6 +2337,11 @@ dependencies = [
[[package]]
name = "void"
+version = "0.0.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "void"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/ports/geckolib/Cargo.lock b/ports/geckolib/Cargo.lock
index 405fadd6627..b60e592f554 100644
--- a/ports/geckolib/Cargo.lock
+++ b/ports/geckolib/Cargo.lock
@@ -215,6 +215,33 @@ dependencies = [
]
[[package]]
+name = "num"
+version = "0.1.32"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "num-integer 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
+ "num-iter 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
+ "num-traits 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "num-integer"
+version = "0.1.32"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "num-traits 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "num-iter"
+version = "0.1.32"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "num-integer 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
+ "num-traits 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
name = "num-traits"
version = "0.1.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -228,6 +255,15 @@ dependencies = [
]
[[package]]
+name = "ordered-float"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "num 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
+ "unreachable 0.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
name = "quickersort"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -325,6 +361,7 @@ dependencies = [
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.1.32 (registry+https://github.com/rust-lang/crates.io-index)",
+ "ordered-float 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
"selectors 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -388,6 +425,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "unreachable"
+version = "0.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "void 0.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "unreachable"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
@@ -427,6 +472,11 @@ dependencies = [
[[package]]
name = "void"
+version = "0.0.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
+name = "void"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/python/tidy/servo_tidy/tidy.py b/python/tidy/servo_tidy/tidy.py
index 3433e8265ed..81c360aa190 100644
--- a/python/tidy/servo_tidy/tidy.py
+++ b/python/tidy/servo_tidy/tidy.py
@@ -261,7 +261,7 @@ def check_lock(file_name, contents):
raise StopIteration
# package names to be neglected (as named by cargo)
- exceptions = ["lazy_static"]
+ exceptions = ["lazy_static", "unreachable", "void"]
import toml
content = toml.loads(contents)