mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
fonts: Add support for WOFF2 and properly load web fonts from @imports (#31879)
This change also makes two fixes that are necessary to get WOFF2 fonts working: 1. It adds support for loading web fonts from stylesheets included via @import rules. 2. It ensure that when web fonts are loaded synchronusly they invalidate the font cache. This led to incorrect font rendering when running tests before. Fixes #31598.
This commit is contained in:
parent
b55d0a2053
commit
8dece05980
100 changed files with 196 additions and 218 deletions
|
@ -32,8 +32,10 @@ use script_traits::{
|
|||
ConstellationControlMsg, InitialScriptState, LayoutControlMsg, LayoutMsg, LoadData,
|
||||
UntrustedNodeAddress, WebrenderIpcSender, WindowSizeData,
|
||||
};
|
||||
use servo_arc::Arc as ServoArc;
|
||||
use servo_url::{ImmutableOrigin, ServoUrl};
|
||||
use style::data::ElementData;
|
||||
use style::stylesheets::Stylesheet;
|
||||
use webrender_api::ImageKey;
|
||||
|
||||
#[derive(MallocSizeOf)]
|
||||
|
@ -203,6 +205,22 @@ pub trait Layout {
|
|||
|
||||
/// The currently laid out Epoch that this Layout has finished.
|
||||
fn current_epoch(&self) -> Epoch;
|
||||
|
||||
/// Load all fonts from the given stylesheet, returning the number of fonts that
|
||||
/// need to be loaded.
|
||||
fn load_web_fonts_from_stylesheet(&self, stylesheet: ServoArc<Stylesheet>);
|
||||
|
||||
/// Add a stylesheet to this Layout. This will add it to the Layout's `Stylist` as well as
|
||||
/// loading all web fonts defined in the stylesheet. The second stylesheet is the insertion
|
||||
/// point (if it exists, the sheet needs to be inserted before it).
|
||||
fn add_stylesheet(
|
||||
&mut self,
|
||||
stylesheet: ServoArc<Stylesheet>,
|
||||
before_stylsheet: Option<ServoArc<Stylesheet>>,
|
||||
);
|
||||
|
||||
/// Removes a stylesheet from the Layout.
|
||||
fn remove_stylesheet(&mut self, stylesheet: ServoArc<Stylesheet>);
|
||||
}
|
||||
|
||||
/// This trait is part of `script_layout_interface` because it depends on both `script_traits`
|
||||
|
|
|
@ -9,7 +9,6 @@ use malloc_size_of_derive::MallocSizeOf;
|
|||
use msg::constellation_msg::BrowsingContextId;
|
||||
use profile_traits::mem::ReportsChan;
|
||||
use script_traits::{Painter, ScrollState, WindowSizeData};
|
||||
use servo_arc::Arc as ServoArc;
|
||||
use servo_atoms::Atom;
|
||||
use servo_url::ImmutableOrigin;
|
||||
use style::animation::DocumentAnimationSet;
|
||||
|
@ -18,21 +17,12 @@ use style::dom::OpaqueNode;
|
|||
use style::invalidation::element::restyle_hints::RestyleHint;
|
||||
use style::properties::PropertyId;
|
||||
use style::selector_parser::{PseudoElement, RestyleDamage, Snapshot};
|
||||
use style::stylesheets::Stylesheet;
|
||||
|
||||
use crate::rpc::LayoutRPC;
|
||||
use crate::{PendingImage, TrustedNodeAddress};
|
||||
|
||||
/// Asynchronous messages that script can send to layout.
|
||||
pub enum Msg {
|
||||
/// Adds the given stylesheet to the document. The second stylesheet is the
|
||||
/// insertion point (if it exists, the sheet needs to be inserted before
|
||||
/// it).
|
||||
AddStylesheet(ServoArc<Stylesheet>, Option<ServoArc<Stylesheet>>),
|
||||
|
||||
/// Removes a stylesheet from the document.
|
||||
RemoveStylesheet(ServoArc<Stylesheet>),
|
||||
|
||||
/// Change the quirks mode.
|
||||
SetQuirksMode(QuirksMode),
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue