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

Prefer length and percentage for word spacing #12783

Merged
merged 1 commit into from Aug 9, 2016

Conversation

@wafflespeanut
Copy link
Member

wafflespeanut commented Aug 9, 2016

The goal is to make use of LengthOrPercentage for word spacing in ShapingOptions, but since it makes use of f32 which doesn't implement Hash, we're going for NotNan<f32> from ordered-float, which supports hashing. Instead of implementing Hash for LengthOrPercentage and thereby the inner types like CSSFloat, CalcLengthOrPercentage, etc., we convert it to (Au, NotNan<f32>).


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • There are tests for these changes

This change is Reviewable

@highfive
Copy link

highfive commented Aug 9, 2016

Heads up! This PR modifies the following files:

  • @bholley: components/style/Cargo.toml, components/style/properties/longhand/inherited_text.mako.rs, components/style/lib.rs, components/style/values/computed/mod.rs
@highfive
Copy link

highfive commented Aug 9, 2016

warning Warning warning

  • These commits modify style, layout, and gfx code, but no tests are modified. Please consider adding a test!
@wafflespeanut
Copy link
Member Author

wafflespeanut commented Aug 9, 2016

It requires tests (I guess?)

r? @Manishearth and @SimonSapin

@highfive highfive assigned Manishearth and unassigned cbrewster Aug 9, 2016
@@ -225,7 +226,8 @@ impl Font {

let mut advance = Au::from_f64_px(self.glyph_h_advance(glyph_id));
if character == ' ' {
advance += options.word_spacing;
let (length, percent) = options.word_spacing;
advance = (advance + length) + Au((advance.0 as f32 * percent.into_inner()) as i32);

This comment has been minimized.

@Manishearth

Manishearth Aug 9, 2016

Member

Link to https://www.w3.org/TR/css-text-3/#word-spacing

This looks correct, but I'd like to wait for Simon's review

@@ -403,7 +403,8 @@ 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
let (length, percent) = options.word_spacing;
advance = (advance + length) + Au((advance.0 as f32 * percent.into_inner()) as i32);

This comment has been minimized.

@Manishearth

Manishearth Aug 9, 2016

Member

Ditto about the spec link

@@ -285,23 +285,23 @@
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub enum SpecifiedValue {
Normal,
Specified(specified::Length), // FIXME(SimonSapin) support percentages
LengthOrPercentage(specified::LengthOrPercentage),

This comment has been minimized.

@Manishearth

Manishearth Aug 9, 2016

Member

Don't rename it from Specified, let it be Specified(specified::Lop)

@Manishearth
Copy link
Member

Manishearth commented Aug 9, 2016

LGTM modulo nits.

r=me post @SimonSapin's sign-off

@wafflespeanut wafflespeanut force-pushed the wafflespeanut:word_spacing branch from 2c54092 to ee82ff6 Aug 9, 2016
@Manishearth
Copy link
Member

Manishearth commented Aug 9, 2016

Post IRC discussion we know that your method of calculation is correct.

r=me

needs lockfile updates:

diff --git a/ports/geckolib/Cargo.lock b/ports/geckolib/Cargo.lock
index 405fadd..b60e592 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"
@wafflespeanut wafflespeanut force-pushed the wafflespeanut:word_spacing branch from ee82ff6 to 3b131ee Aug 9, 2016
@wafflespeanut
Copy link
Member Author

wafflespeanut commented Aug 9, 2016

lock file updated :)
@bors-servo r=Manishearth

Thanks! 😄

@bors-servo
Copy link
Contributor

bors-servo commented Aug 9, 2016

📌 Commit 3b131ee has been approved by Manishearth

@bors-servo
Copy link
Contributor

bors-servo commented Aug 9, 2016

Testing commit 3b131ee with merge 178adcd...

bors-servo added a commit that referenced this pull request Aug 9, 2016
Prefer length and percentage for word spacing

<!-- Please describe your changes on the following line: -->
The goal is to make use of `LengthOrPercentage` for word spacing in `ShapingOptions`, but since it makes use of `f32` which doesn't implement `Hash`, we're going for `NotNan<f32>` from [ordered-float](https://github.com/reem/rust-ordered-float/), which supports hashing. Instead of implementing `Hash` for `LengthOrPercentage` and thereby the inner types like `CSSFloat`, `CalcLengthOrPercentage`, etc., we convert it to `(Au, NotNan<f32>)`.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [ ] `./mach test-tidy` does not report any errors

<!-- Either: -->
- [ ] There are tests for these changes

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12783)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Aug 9, 2016

💔 Test failed - linux-dev

@wafflespeanut
Copy link
Member Author

wafflespeanut commented Aug 9, 2016

forgot to update ports/cef/Cargo.lock - sorry

@wafflespeanut wafflespeanut force-pushed the wafflespeanut:word_spacing branch from 3b131ee to a04028e Aug 9, 2016
@wafflespeanut
Copy link
Member Author

wafflespeanut commented Aug 9, 2016

@bors-servo r=Manishearth

@bors-servo
Copy link
Contributor

bors-servo commented Aug 9, 2016

📌 Commit a04028e has been approved by Manishearth

@bors-servo
Copy link
Contributor

bors-servo commented Aug 9, 2016

Testing commit a04028e with merge 6142508...

bors-servo added a commit that referenced this pull request Aug 9, 2016
Prefer length and percentage for word spacing

<!-- Please describe your changes on the following line: -->
The goal is to make use of `LengthOrPercentage` for word spacing in `ShapingOptions`, but since it makes use of `f32` which doesn't implement `Hash`, we're going for `NotNan<f32>` from [ordered-float](https://github.com/reem/rust-ordered-float/), which supports hashing. Instead of implementing `Hash` for `LengthOrPercentage` and thereby the inner types like `CSSFloat`, `CalcLengthOrPercentage`, etc., we convert it to `(Au, NotNan<f32>)`.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors

<!-- Either: -->
- [ ] There are tests for these changes

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12783)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Aug 9, 2016

💔 Test failed - linux-rel

@highfive
Copy link

highfive commented Aug 9, 2016

  ▶ FAIL [expected PASS] /css-transforms-1_dev/html/transform3d-translatez-001.htm
  └   → /css-transforms-1_dev/html/transform3d-translatez-001.htm 902d90a8d198625335e738587fdfe81dcc90392d
/css-transforms-1_dev/html/reference/transform3d-translatez-ref.htm b14318ccfd8a59b7b249d41521e178d617678823
Testing 902d90a8d198625335e738587fdfe81dcc90392d == b14318ccfd8a59b7b249d41521e178d617678823
/css-transforms-1_dev/html/transform3d-translatez-001.htm 902d90a8d198625335e738587fdfe81dcc90392d
/css-transforms-1_dev/html/reference/transform3d-translatez-notref.htm 902d90a8d198625335e738587fdfe81dcc90392d
Testing 902d90a8d198625335e738587fdfe81dcc90392d != 902d90a8d198625335e738587fdfe81dcc90392d
@wafflespeanut
Copy link
Member Author

wafflespeanut commented Aug 9, 2016

@bors-servo
Copy link
Contributor

bors-servo commented Aug 9, 2016

Testing commit a04028e with merge 3b676bc...

bors-servo added a commit that referenced this pull request Aug 9, 2016
Prefer length and percentage for word spacing

<!-- Please describe your changes on the following line: -->
The goal is to make use of `LengthOrPercentage` for word spacing in `ShapingOptions`, but since it makes use of `f32` which doesn't implement `Hash`, we're going for `NotNan<f32>` from [ordered-float](https://github.com/reem/rust-ordered-float/), which supports hashing. Instead of implementing `Hash` for `LengthOrPercentage` and thereby the inner types like `CSSFloat`, `CalcLengthOrPercentage`, etc., we convert it to `(Au, NotNan<f32>)`.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors

<!-- Either: -->
- [ ] There are tests for these changes

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12783)
<!-- Reviewable:end -->
@bors-servo bors-servo mentioned this pull request Aug 9, 2016
4 of 5 tasks complete
@bors-servo
Copy link
Contributor

bors-servo commented Aug 9, 2016

@bors-servo bors-servo merged commit a04028e into servo:master Aug 9, 2016
3 checks passed
3 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@bors-servo bors-servo mentioned this pull request Aug 9, 2016
4 of 5 tasks complete
@wafflespeanut wafflespeanut deleted the wafflespeanut:word_spacing branch Aug 9, 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

5 participants
You can’t perform that action at this time.