aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout_2020/flow/inline.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2020-02-11 23:05:37 -0500
committerGitHub <noreply@github.com>2020-02-11 23:05:37 -0500
commit6d6d16f7f492e6346f0391e352015226a4444806 (patch)
treed991c986a7f83be25157934e93c248ea86ee4b00 /components/layout_2020/flow/inline.rs
parentbaac1e2c69d3b6e840ced2be4b5e03bb39bd40d5 (diff)
parentd1f8d576f83714fe674a36c5b718341c236312e6 (diff)
downloadservo-6d6d16f7f492e6346f0391e352015226a4444806.tar.gz
servo-6d6d16f7f492e6346f0391e352015226a4444806.zip
Auto merge of #25717 - emilio:gecko-sync, r=emilio,nox
style: Sync changes from mozilla-central. See individual commits for details. https://bugzilla.mozilla.org/show_bug.cgi?id=1614394
Diffstat (limited to 'components/layout_2020/flow/inline.rs')
-rw-r--r--components/layout_2020/flow/inline.rs34
1 files changed, 25 insertions, 9 deletions
diff --git a/components/layout_2020/flow/inline.rs b/components/layout_2020/flow/inline.rs
index ba9453a5b80..58dfb6581db 100644
--- a/components/layout_2020/flow/inline.rs
+++ b/components/layout_2020/flow/inline.rs
@@ -159,8 +159,12 @@ impl InlineFormattingContext {
}
fn add_lengthpercentage(&mut self, lp: LengthPercentage) {
- self.add_length(lp.length_component());
- self.current_line_percentages += lp.percentage_component();
+ if let Some(l) = lp.to_length() {
+ self.add_length(l);
+ }
+ if let Some(p) = lp.to_percentage() {
+ self.current_line_percentages += p;
+ }
}
fn add_length(&mut self, l: Length) {
@@ -601,13 +605,6 @@ impl TextRun {
flags.insert(ShapingFlags::KEEP_ALL_FLAG);
}
- let shaping_options = gfx::font::ShapingOptions {
- letter_spacing,
- word_spacing: inherited_text_style.word_spacing.to_hash_key(),
- script: unicode_script::Script::Common,
- flags,
- };
-
crate::context::with_thread_local_font_context(layout_context, |font_context| {
let font_group = font_context.font_group(font_style);
let font = font_group
@@ -616,6 +613,25 @@ impl TextRun {
.expect("could not find font");
let mut font = font.borrow_mut();
+ let word_spacing = &inherited_text_style.word_spacing;
+ let word_spacing = word_spacing
+ .to_length()
+ .map(|l| l.into())
+ .unwrap_or_else(|| {
+ let space_width = font
+ .glyph_index(' ')
+ .map(|glyph_id| font.glyph_h_advance(glyph_id))
+ .unwrap_or(gfx::font::LAST_RESORT_GLYPH_ADVANCE);
+ word_spacing.to_used_value(Au::from_f64_px(space_width))
+ });
+
+ let shaping_options = gfx::font::ShapingOptions {
+ letter_spacing,
+ word_spacing,
+ script: unicode_script::Script::Common,
+ flags,
+ };
+
let (runs, break_at_start) = gfx::text::text_run::TextRun::break_and_shape(
&mut font,
&self.text,