Skip to content

Commit

Permalink
Merge with main
Browse files Browse the repository at this point in the history
  • Loading branch information
matthunz committed Jun 20, 2024
2 parents 46a48b4 + 2e99ca1 commit 4fbef32
Show file tree
Hide file tree
Showing 22 changed files with 468 additions and 464 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
on:
pull_request:
push:
branches:
- main

name: CI

env:
RUSTDOCFLAGS: "-D warnings"
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: "sparse"

jobs:

# MSRV check.
# Blitz only guarantees "latest stable". However we have this check here to ensure that we advertise
# our MSRV. We also make an effort not to increase MSRV in patch versions of Blitz.
#
# We only run `cargo build` (not `cargo test`) so as to avoid requiring dev-dependencies to build with the MSRV
# version. Building is likely sufficient as runtime errors varying between rust versions is very unlikely.
build-msrv:
name: "MSRV Build [Rust 1.79]"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.79
- run: sudo apt install libgtk-3-dev libxdo-dev
- run: cargo build --workspace

test-features-default:
name: "Test [default features]"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: sudo apt install libgtk-3-dev libxdo-dev
- run: cargo build --workspace
- run: cargo test --workspace

fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: rustfmt
- run: cargo fmt --all --check

clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
components: clippy
- run: sudo apt install libgtk-3-dev libxdo-dev
- run: cargo clippy --workspace -- -D warnings

doc:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo doc
7 changes: 1 addition & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,14 @@ edition = "2021"
description = "Top level crate for Blitz"
license = "MIT OR Apache-2.0"
keywords = ["dom", "ui", "gui", "react", "wasm"]
rust-version = "1.60.0"
rust-version = "1.70.0"
publish = false

[profile.dev.package."*"]
opt-level = 2

# Need to force specific versions of these dependencies
[dependencies]
# webrender = "0.61.0"
euclid = { version = "0.22", features = ["serde"] }
# mozbuild = "0.1.0"

[dev-dependencies]
blitz = { path = "./packages/blitz" }
blitz-dom = { path = "./packages/dom" }
comrak = { version = "0.21.0", default-features = false }
Expand Down
5 changes: 0 additions & 5 deletions examples/dom_only.rs

This file was deleted.

1 change: 0 additions & 1 deletion examples/font.rs

This file was deleted.

2 changes: 1 addition & 1 deletion examples/tailwind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fn main() {
fn app() -> Element {
rsx! {
style { {CSS} }
for row in 0..3 {
for _row in 0..3 {
div { class: "flex flex-row",
div { id: "cool", "h123456789asdjkahskj\nhiiiii" }
p { class: "cool", "hi" }
Expand Down
8 changes: 0 additions & 8 deletions packages/blitz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ parley = { workspace = true }
tokio = { workspace = true, features = ["full"] }
vello = { workspace = true }
wgpu = { workspace = true }
shipyard = { version = "0.6.2", features = [
"proc",
"std",
], default-features = false }

app_units = "0.7.3"
atomic_refcell = { version = "0.1.13", features = ["serde"] }
Expand All @@ -28,10 +24,6 @@ string_cache = "0.8.7"
futures-util = "0.3.29"
raw-window-handle = "0.6.0"
blitz-dom = { path = "../dom" }
glyphon = "0.5.0"
cosmic-text = "0.11.2"
quadtree_rs = "0.1.3"
askama_escape = "0.10.3"
image = "0.25"

# futures-util = "0.3.29"
Expand Down
13 changes: 8 additions & 5 deletions packages/blitz/src/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,19 +141,22 @@ where
.await
.expect("Error creating surface");

let default_threads = || -> Option<NonZeroUsize> {
#[cfg(target_arch = "macos")]
const DEFAULT_THREADS: Option<NonZeroUsize> = {
#[cfg(target_os = "macos")]
{
Some(NonZeroUsize::new(1)?)
NonZeroUsize::new(1)
}
#[cfg(not(target_os = "macos"))]
{
None
}
None
};

let options = RendererOptions {
surface_format: Some(surface.config.format),
antialiasing_support: AaSupport::all(),
use_cpu: false,
num_init_threads: default_threads(),
num_init_threads: DEFAULT_THREADS,
};

let renderer =
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
6 changes: 2 additions & 4 deletions packages/dioxus-blitz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ hot-reload = []
default = []

[dependencies]
tao = { version = "0.26.1", features = ["serde"] }
winit = "0.30.2"
muda = { version = "0.11.5", features = ["serde"] }
tokio = { workspace = true, features = ["full"] }
dioxus = { workspace = true }
dioxus-ssr = { workspace = true }
dioxus-cli-config = { git = "https://github.com/dioxuslabs/dioxus", rev = "a3aa6ae771a2d0a4d8cb6055c41efc0193b817ef" }
dioxus-hot-reload = { git = "https://github.com/dioxuslabs/dioxus", rev = "a3aa6ae771a2d0a4d8cb6055c41efc0193b817ef" }
dioxus-hot-reload = { git = "https://github.com/dioxuslabs/dioxus", rev = "a3aa6ae771a2d0a4d8cb6055c41efc0193b817ef"}
futures-util = "0.3.30"
vello = { workspace = true }
wgpu = { workspace = true }
Expand Down
35 changes: 17 additions & 18 deletions packages/dioxus-blitz/src/documents/dioxus_document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,30 +48,29 @@ impl AsMut<Document> for DioxusDocument {
&mut self.inner
}
}
impl Into<Document> for DioxusDocument {
fn into(self) -> Document {
self.inner
impl From<DioxusDocument> for Document {
fn from(doc: DioxusDocument) -> Document {
doc.inner
}
}
impl DocumentLike for DioxusDocument {
fn poll(&mut self, mut cx: std::task::Context) -> bool {
loop {
{
let fut = self.vdom.wait_for_work();
pin_mut!(fut);

match fut.poll_unpin(&mut cx) {
std::task::Poll::Ready(_) => {}
std::task::Poll::Pending => return false,
}
}
{
let fut = self.vdom.wait_for_work();
pin_mut!(fut);

self.vdom.render_immediate(&mut MutationWriter {
doc: &mut self.inner,
state: &mut self.vdom_state,
});
return true;
match fut.poll_unpin(&mut cx) {
std::task::Poll::Ready(_) => {}
std::task::Poll::Pending => return false,
}
}

self.vdom.render_immediate(&mut MutationWriter {
doc: &mut self.inner,
state: &mut self.vdom_state,
});

true
}

fn handle_event(&mut self, event: blitz_dom::events::RendererEvent) -> bool {
Expand Down
6 changes: 3 additions & 3 deletions packages/dioxus-blitz/src/documents/html_document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ impl AsMut<Document> for HtmlDocument {
&mut self.inner
}
}
impl Into<Document> for HtmlDocument {
fn into(self) -> Document {
self.inner
impl From<HtmlDocument> for Document {
fn from(doc: HtmlDocument) -> Document {
doc.inner
}
}
impl DocumentLike for HtmlDocument {}
Expand Down
Loading

0 comments on commit 4fbef32

Please sign in to comment.