servo/components/layout
bors-servo f48dce120d
Auto merge of #20021 - jonleighton:lazy-font-group, r=mbrubeck,glennw
Lazy load fonts in a FontGroup

The first commit message explains this so I'll just copy it here:

---

This is a step towards fixing #17267. To fix that, we need to be able to
try various different fallback fonts in turn, which would become
unweildy with the prior eager-loading strategy.

Prior to this change, FontGroup loaded up all Font instances, including
the fallback font, before any of them were checked for the presence of
the glyphs we're trying to render.

So for the following CSS:

    font-family: Helvetica, Arial;

The FontGroup would contain a Font instance for Helvetica, and a Font
instance for Arial, and a Font instance for the fallback font.

It may be that Helvetica contains glyphs for every character in the
document, and therefore Arial and the fallback font are not needed at
all.

This change makes the strategy lazy, so that we'll only create a Font
for Arial if we cannot find a glyph within Helvetica. I've also
substantially refactored the existing code in the process and added
some documentation along the way.

---

I've added some tests in the second commit, but it required quite a bit of gymnastics to make it possible to write such a test. I'm not sure if the added complexity to the production code is worth it?

On the other hand, having this infrastructure in place may be useful for testing future changes in this area, and also possibly brings us a step closer to extracting a library as discussed in #4901. (What I mean by that is: it reduces coupling between `FontCacheThread` and `FontContext` -- the latter would have a place in such a library, the former wouldn't.)

<!-- 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/20021)
<!-- Reviewable:end -->
2018-02-22 10:49:52 -05:00
..
display_list Allow for build_display_list to be called immutably 2018-02-16 16:01:48 -08:00
tests Merge layout and layout_tests 2018-01-20 15:33:39 +01:00
animation.rs style: Make the TElement type arrive to the cascade function. 2018-01-23 00:57:54 +01:00
block.rs Allow for build_display_list to be called immutably 2018-02-16 16:01:48 -08:00
Cargo.toml Use Rect::inner_rect from euclid 2018-02-08 16:45:27 +01:00
construct.rs style: Move content property out of mako. 2018-02-07 00:11:57 +02:00
context.rs Add test for FontContext/FontGroup functionality 2018-02-22 16:36:09 +01:00
data.rs Bump bitflags to 1.0 in every servo crate 2017-10-30 23:36:06 +01:00
flex.rs Create own file for background calculations in layout 2018-01-06 20:19:32 +01:00
floats.rs Use specific negative assertion for layout floats 2018-01-26 01:55:24 +08:00
flow.rs Add stacking_relative_border_box_for_display_list 2018-02-16 16:01:46 -08:00
flow_list.rs Remove usage of unstable feature conservative_impl_trait in layout 2017-10-13 11:11:06 +02:00
flow_ref.rs order derivable traits lists 2017-08-23 21:38:44 +02:00
fragment.rs Auto merge of #20034 - Manishearth:table-backgrounds, r=mbrubeck 2018-02-21 12:00:03 -05:00
generated_content.rs style: Move content property out of mako. 2018-02-07 00:11:57 +02:00
incremental.rs Turn flow::base and friends into methods 2017-12-14 12:16:45 -06:00
inline.rs Add test for FontContext/FontGroup functionality 2018-02-22 16:36:09 +01:00
layout_debug.rs Use specific assertion for layout layout_debug 2018-01-26 01:01:01 +08:00
lib.rs Share line breaking state across text runs 2018-01-24 12:51:33 +05:30
linked_list.rs Move util::linked_list to layout 2016-06-29 17:23:04 +02:00
list_item.rs Allow floats to impact list item marker position 2018-01-24 12:26:32 +01:00
model.rs Fix some "unnecessary parentheses" warnings 2018-01-22 17:41:25 +01:00
multicol.rs Replace PositiveIntegerOrAuto by ColumnCount 2018-02-22 10:16:46 +01:00
opaque_node.rs Introduce LayoutJS<Node>::opaque() to replace OpaqueNodeMethods::from_jsmanaged(). 2016-06-20 19:08:02 +02:00
parallel.rs Turn flow::base and friends into methods 2017-12-14 12:16:45 -06:00
persistent_list.rs Use try syntax for Option where appropriate 2017-10-20 08:25:35 -07:00
query.rs Auto merge of #20082 - emilio:ignore-existing-styles, r=bholley 2018-02-21 06:09:15 -05:00
sequential.rs Create own file for background calculations in layout 2018-01-06 20:19:32 +01:00
table.rs bail early for initial valued backgrounds 2018-02-21 00:36:35 -08:00
table_caption.rs Create own file for background calculations in layout 2018-01-06 20:19:32 +01:00
table_cell.rs Unconditionally remove repaint damage for table cells/rows/rgs 2018-02-16 16:01:53 -08:00
table_colgroup.rs Add get_column_styles for getting column structure and styles for a table 2018-02-16 16:01:41 -08:00
table_row.rs Unconditionally remove repaint damage for table cells/rows/rgs 2018-02-16 16:01:53 -08:00
table_rowgroup.rs Unconditionally remove repaint damage for table cells/rows/rgs 2018-02-16 16:01:53 -08:00
table_wrapper.rs Create own file for background calculations in layout 2018-01-06 20:19:32 +01:00
text.rs Add test for FontContext/FontGroup functionality 2018-02-22 16:36:09 +01:00
traversal.rs Create own file for background calculations in layout 2018-01-06 20:19:32 +01:00
wrapper.rs style: Move content property out of mako. 2018-02-07 00:11:57 +02:00