diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2020-02-11 23:05:37 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-11 23:05:37 -0500 |
commit | 6d6d16f7f492e6346f0391e352015226a4444806 (patch) | |
tree | d991c986a7f83be25157934e93c248ea86ee4b00 /components/layout_2020 | |
parent | baac1e2c69d3b6e840ced2be4b5e03bb39bd40d5 (diff) | |
parent | d1f8d576f83714fe674a36c5b718341c236312e6 (diff) | |
download | servo-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')
-rw-r--r-- | components/layout_2020/flow/inline.rs | 34 | ||||
-rw-r--r-- | components/layout_2020/sizing.rs | 12 | ||||
-rw-r--r-- | components/layout_2020/style_ext.rs | 2 |
3 files changed, 34 insertions, 14 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, diff --git a/components/layout_2020/sizing.rs b/components/layout_2020/sizing.rs index dc7513a7859..f5dac929b84 100644 --- a/components/layout_2020/sizing.rs +++ b/components/layout_2020/sizing.rs @@ -117,12 +117,12 @@ impl BoxContentSizes { .auto_is(Length::zero); let max_inline_size = match style.max_box_size().inline { MaxSize::None => None, - MaxSize::LengthPercentage(ref lp) => lp.as_length(), + MaxSize::LengthPercentage(ref lp) => lp.to_length(), }; let clamp = |l: Length| l.clamp_between_extremums(min_inline_size, max_inline_size); // Percentages for 'width' are treated as 'auto' - let inline_size = inline_size.map(|lp| lp.as_length()); + let inline_size = inline_size.map(|lp| lp.to_length()); // The (inner) min/max-content are only used for 'auto' let mut outer = match inline_size.non_auto().flatten() { None => { @@ -148,8 +148,12 @@ impl BoxContentSizes { let margin = style.margin(); pbm_lengths += border.inline_sum(); let mut add = |x: LengthPercentage| { - pbm_lengths += x.length_component(); - pbm_percentages += x.percentage_component(); + if let Some(l) = x.to_length() { + pbm_lengths += l; + } + if let Some(p) = x.to_percentage() { + pbm_percentages += p; + } }; add(padding.inline_start); add(padding.inline_end); diff --git a/components/layout_2020/style_ext.rs b/components/layout_2020/style_ext.rs index f6fb8d4000a..30b384f3884 100644 --- a/components/layout_2020/style_ext.rs +++ b/components/layout_2020/style_ext.rs @@ -59,7 +59,7 @@ impl ComputedValuesExt for ComputedValues { } else { &position.height }; - matches!(size, Size::LengthPercentage(lp) if lp.0.as_length().is_some()) + matches!(size, Size::LengthPercentage(lp) if lp.0.to_length().is_some()) } fn inline_box_offsets_are_both_non_auto(&self) -> bool { |