servo: Merge #11798 - Account for the font of empty input fields (from notriddle:input_caret); r=nox
authorMichael Howell <michael@notriddle.com>
Mon, 20 Jun 2016 05:58:23 -0500
changeset 339095 1c4aae44b09b8b6b2c21729be6f99bee8ec7f9c4
parent 339094 e374e94a248128ba02fc9fb4b45488e7f6e95ae0
child 339096 4457104efb112f3644d91f09984339ae843812ef
push id31307
push usergszorc@mozilla.com
push dateSat, 04 Feb 2017 00:59:06 +0000
treeherdermozilla-central@94079d43835f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnox
servo: Merge #11798 - Account for the font of empty input fields (from notriddle:input_caret); r=nox The font of empty fragments is not accounted for in layout. This behavior is incorrect when part of an input field. - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #11653 - [X] There are tests for these changes Source-Repo: https://github.com/servo/servo Source-Revision: 881c02ec894048c3510ee7a7a3b7fde50b2cfac3
servo/components/layout/fragment.rs
--- a/servo/components/layout/fragment.rs
+++ b/servo/components/layout/fragment.rs
@@ -1967,26 +1967,26 @@ impl Fragment {
                                                               .computed_block_size();
                 InlineMetrics {
                     block_size_above_baseline: computed_block_size +
                                                    self.border_padding.block_start,
                     depth_below_baseline: self.border_padding.block_end,
                     ascent: computed_block_size + self.border_padding.block_start,
                 }
             }
-            SpecificFragmentInfo::ScannedText(ref text_fragment) => {
+            SpecificFragmentInfo::ScannedText(ref info) => {
                 // Fragments with no glyphs don't contribute any inline metrics.
                 // TODO: Filter out these fragments during flow construction?
-                if text_fragment.content_size.inline == Au(0) {
+                if info.insertion_point.is_none() && info.content_size.inline == Au(0) {
                     return InlineMetrics::new(Au(0), Au(0), Au(0));
                 }
                 // See CSS 2.1 ยง 10.8.1.
                 let line_height = self.calculate_line_height(layout_context);
                 let font_derived_metrics =
-                    InlineMetrics::from_font_metrics(&text_fragment.run.font_metrics, line_height);
+                    InlineMetrics::from_font_metrics(&info.run.font_metrics, line_height);
                 InlineMetrics {
                     block_size_above_baseline: font_derived_metrics.block_size_above_baseline +
                                                    self.border_padding.block_start,
                     depth_below_baseline: font_derived_metrics.depth_below_baseline +
                         self.border_padding.block_end,
                     ascent: font_derived_metrics.ascent + self.border_padding.block_start,
                 }
             }