diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5d1b328b..392b0f00 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,24 +29,15 @@ jobs: - run: sudo apt install libgtk-3-dev - run: cargo build --workspace - - build-features-default: - name: "Build [default features]" - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - - run: sudo apt install libgtk-3-dev - - run: cargo build --workspace - # - run: cargo test - test-features-default: name: "Test [default features]" runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - - run: cargo test + - run: sudo apt install libgtk-3-dev + - run: cargo build --workspace + - run: cargo test --workspace fmt: name: Rustfmt diff --git a/packages/blitz/src/viewport.rs b/packages/blitz/src/viewport.rs index 55095bcf..7dfaab97 100644 --- a/packages/blitz/src/viewport.rs +++ b/packages/blitz/src/viewport.rs @@ -1,7 +1,5 @@ -use style::{ - media_queries::{Device, MediaType}, - servo::media_queries::FontMetricsProvider, -}; +use blitz_dom::document::DummyFontMetricsProvider; +use style::media_queries::{Device, MediaType}; #[derive(Default, Debug)] pub struct Viewport { @@ -14,22 +12,6 @@ pub struct Viewport { pub font_size: f32, } -// TODO: implement a proper font metrics provider -#[derive(Debug, Clone)] -struct DummyFontMetricsProvider; -impl FontMetricsProvider for DummyFontMetricsProvider { - fn query_font_metrics( - &self, - _vertical: bool, - _font: &style::properties::style_structs::Font, - _base_size: style::values::computed::CSSPixelLength, - _in_media_query: bool, - _retrieve_math_scales: bool, - ) -> style::font_metrics::FontMetrics { - Default::default() - } -} - impl Viewport { pub fn new(window_size: (u32, u32)) -> Self { Self { diff --git a/packages/dom/src/document.rs b/packages/dom/src/document.rs index cfda135f..7bbf9a8b 100644 --- a/packages/dom/src/document.rs +++ b/packages/dom/src/document.rs @@ -7,6 +7,7 @@ use slab::Slab; use std::collections::HashMap; use style::invalidation::element::restyle_hints::RestyleHint; use style::selector_parser::ServoElementSnapshot; +use style::servo::media_queries::FontMetricsProvider; use style::servo_arc::Arc as ServoArc; use style::{ dom::{TDocument, TNode}, @@ -20,6 +21,22 @@ use style_traits::dom::ElementState; use taffy::AvailableSpace; use url::Url; +// TODO: implement a proper font metrics provider +#[derive(Debug, Clone)] +pub struct DummyFontMetricsProvider; +impl FontMetricsProvider for DummyFontMetricsProvider { + fn query_font_metrics( + &self, + _vertical: bool, + _font: &style::properties::style_structs::Font, + _base_size: style::values::computed::CSSPixelLength, + _in_media_query: bool, + _retrieve_math_scales: bool, + ) -> style::font_metrics::FontMetrics { + Default::default() + } +} + pub trait DocumentLike: AsRef + AsMut + Into { fn poll(&mut self, _cx: std::task::Context) -> bool { // Default implementation does nothing diff --git a/packages/dom/src/htmlsink.rs b/packages/dom/src/htmlsink.rs index c2b20507..03397648 100644 --- a/packages/dom/src/htmlsink.rs +++ b/packages/dom/src/htmlsink.rs @@ -365,6 +365,7 @@ impl<'b> TreeSink for DocumentHtmlParser<'b> { #[test] fn parses_some_html() { + use crate::document::DummyFontMetricsProvider; use euclid::{Scale, Size2D}; use style::media_queries::{Device, MediaType}; @@ -377,6 +378,7 @@ fn parses_some_html() { selectors::matching::QuirksMode::NoQuirks, viewport_size, device_pixel_ratio, + Box::new(DummyFontMetricsProvider), ); let mut doc = Document::new(device); let sink = DocumentHtmlParser::new(&mut doc);