mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Support @font-face in user and user agent stylesheets.
This commit is contained in:
parent
9317a30b91
commit
4833204653
2 changed files with 20 additions and 6 deletions
|
@ -297,6 +297,14 @@ impl<'a> DerefMut for RWGuard<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn add_font_face_rules(stylesheet: &Stylesheet, device: &Device, font_cache_task: &FontCacheTask) {
|
||||||
|
for font_face in stylesheet.effective_rules(&device).font_face() {
|
||||||
|
for source in font_face.sources.iter() {
|
||||||
|
font_cache_task.add_web_font(font_face.family.clone(), source.clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl LayoutTask {
|
impl LayoutTask {
|
||||||
/// Creates a new `LayoutTask` structure.
|
/// Creates a new `LayoutTask` structure.
|
||||||
fn new(id: PipelineId,
|
fn new(id: PipelineId,
|
||||||
|
@ -336,6 +344,11 @@ impl LayoutTask {
|
||||||
let image_cache_receiver =
|
let image_cache_receiver =
|
||||||
ROUTER.route_ipc_receiver_to_new_mpsc_receiver(ipc_image_cache_receiver);
|
ROUTER.route_ipc_receiver_to_new_mpsc_receiver(ipc_image_cache_receiver);
|
||||||
|
|
||||||
|
let stylist = box Stylist::new(device);
|
||||||
|
for user_or_user_agent_stylesheet in stylist.stylesheets() {
|
||||||
|
add_font_face_rules(user_or_user_agent_stylesheet, &stylist.device, &font_cache_task);
|
||||||
|
}
|
||||||
|
|
||||||
LayoutTask {
|
LayoutTask {
|
||||||
id: id,
|
id: id,
|
||||||
url: url,
|
url: url,
|
||||||
|
@ -362,7 +375,7 @@ impl LayoutTask {
|
||||||
constellation_chan: constellation_chan,
|
constellation_chan: constellation_chan,
|
||||||
screen_size: screen_size,
|
screen_size: screen_size,
|
||||||
stacking_context: None,
|
stacking_context: None,
|
||||||
stylist: box Stylist::new(device),
|
stylist: stylist,
|
||||||
parallel_traversal: parallel_traversal,
|
parallel_traversal: parallel_traversal,
|
||||||
dirty: Rect::zero(),
|
dirty: Rect::zero(),
|
||||||
generation: 0,
|
generation: 0,
|
||||||
|
@ -735,11 +748,7 @@ impl LayoutTask {
|
||||||
let mut rw_data = self.lock_rw_data(possibly_locked_rw_data);
|
let mut rw_data = self.lock_rw_data(possibly_locked_rw_data);
|
||||||
|
|
||||||
if mq.evaluate(&rw_data.stylist.device) {
|
if mq.evaluate(&rw_data.stylist.device) {
|
||||||
for font_face in sheet.effective_rules(&rw_data.stylist.device).font_face() {
|
add_font_face_rules(&sheet, &rw_data.stylist.device, &self.font_cache_task);
|
||||||
for source in font_face.sources.iter() {
|
|
||||||
self.font_cache_task.add_web_font(font_face.family.clone(), source.clone());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
rw_data.stylist.add_stylesheet(sheet);
|
rw_data.stylist.add_stylesheet(sheet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,6 +84,11 @@ impl Stylist {
|
||||||
stylist
|
stylist
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn stylesheets(&self) -> &[Stylesheet] {
|
||||||
|
&self.stylesheets
|
||||||
|
}
|
||||||
|
|
||||||
pub fn constrain_viewport(&self) -> Option<ViewportConstraints> {
|
pub fn constrain_viewport(&self) -> Option<ViewportConstraints> {
|
||||||
let cascaded_rule = self.stylesheets.iter()
|
let cascaded_rule = self.stylesheets.iter()
|
||||||
.flat_map(|s| s.effective_rules(&self.device).viewport())
|
.flat_map(|s| s.effective_rules(&self.device).viewport())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue