Skip to content

Commit

Permalink
Test entire workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoburns committed Jun 19, 2024
1 parent ea13a1b commit 1f2f6d4
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 32 deletions.
15 changes: 3 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 2 additions & 20 deletions packages/blitz/src/viewport.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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 {
Expand Down
17 changes: 17 additions & 0 deletions packages/dom/src/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand All @@ -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<Document> + AsMut<Document> + Into<Document> {
fn poll(&mut self, _cx: std::task::Context) -> bool {
// Default implementation does nothing
Expand Down
2 changes: 2 additions & 0 deletions packages/dom/src/htmlsink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand All @@ -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);
Expand Down

0 comments on commit 1f2f6d4

Please sign in to comment.