Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,24 @@ jobs:
- run: sudo apt-get update && sudo apt-get install -y libfontconfig1-dev
- run: cargo build --workspace

# The text backend feature: Parley, on by default, is required: without it
# blitz-dom must fail to compile.
check-text-backends:
name: "Check text backend features"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: sudo apt-get update && sudo apt-get install -y libfontconfig1-dev
- name: Parley (default)
run: cargo check -p blitz-dom -p blitz-paint -p blitz -p wpt
- name: No backend fails to compile
run: |
if cargo check -p blitz-dom --no-default-features --features svg 2> neither.log; then
echo "blitz-dom built without a text backend"; exit 1
fi
grep -q "Enable the \`parley\` feature" neither.log

# wasm_hello is a standalone workspace; seven_guis and todomvc are workspace
# members with a [lib] crate-type = ["cdylib"] target for wasm.
build-wasm-examples:
Expand All @@ -70,9 +88,9 @@ jobs:
run: cargo build --target wasm32-unknown-unknown
working-directory: examples/wasm_hello
- name: Build seven_guis (wasm)
run: cargo build -p seven_guis --lib --target wasm32-unknown-unknown --no-default-features --features hybrid
run: cargo build -p seven_guis --lib --target wasm32-unknown-unknown --no-default-features --features hybrid,parley
- name: Build todomvc (wasm)
run: cargo build -p todomvc --lib --target wasm32-unknown-unknown --no-default-features --features hybrid
run: cargo build -p todomvc --lib --target wasm32-unknown-unknown --no-default-features --features hybrid,parley

fmt:
name: Rustfmt
Expand All @@ -96,7 +114,7 @@ jobs:
components: clippy
- run: sudo apt-get update && sudo apt-get install -y libfontconfig1-dev
- run: cargo clippy --workspace -- -D warnings
- run: cargo clippy -p blitz-dom --no-default-features --features svg,woff,accessibility,system-fonts,file-input,custom-widget --all-targets -- -D warnings
- run: cargo clippy -p blitz-dom --no-default-features --features parley,svg,woff,accessibility,system-fonts,file-input,custom-widget --all-targets -- -D warnings

ci-scripts:
name: "Test CI scripts"
Expand Down
2 changes: 0 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ dioxus-native-dom = { version = "0.7.0", path = "./packages/dioxus-native-dom",
debug_timer = { version = "0.1.2", path = "./packages/debug_timer" }
accesskit_xplat = { version = "0.2", path = "./packages/accesskit_xplat", default-features = false }
browser-persistence = { path = "./apps/browser/persistence" }
blitz-test-harness = { path = "./packages/blitz-test-harness" }
blitz-test-harness = { path = "./packages/blitz-test-harness", default-features = false }

# Servo dependencies
style = { version = "0.22.0", package = "stylo" }
Expand Down Expand Up @@ -257,13 +257,16 @@ publish = false
log-times = ["log-frame-times", "log-phase-times"]
log-frame-times = ["dioxus-native/log-frame-times"]
log-phase-times = ["dioxus-native/log-phase-times"]
# The text backend, which is Parley: on by default, and required.
default = ["parley"]
parley = ["blitz-dom/parley", "blitz-paint/parley", "dioxus-native/parley"]

[dev-dependencies]
anyrender = { workspace = true }
anyrender_vello = { workspace = true }
anyrender_vello_cpu = { workspace = true, features = ["multithreading"] }
anyrender_vello_hybrid = { workspace = true }
blitz-dom = { workspace = true, features = ["default"] }
blitz-dom = { workspace = true, features = ["svg", "woff", "accessibility", "system-fonts", "file-input", "custom-widget", "text-transform-icu"] }
blitz-html = { workspace = true }
blitz-traits = { workspace = true }
blitz-paint = { workspace = true }
Expand Down
4 changes: 3 additions & 1 deletion apps/browser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ name = "blitz"
path = "src/main.rs"

[features]
default = ["hybrid", "cookies", "cache", "screenshot", "apple-font-embolden", "scrollbars"]
default = ["hybrid", "cookies", "cache", "screenshot", "apple-font-embolden", "scrollbars", "parley"]
android-defaults = ["skia", "cookies"]

screenshot = ["dep:anyrender_vello_cpu", "dep:blitz-paint", "dep:png", "dep:peniko", "dep:rfd"]
Expand Down Expand Up @@ -41,6 +41,8 @@ mimalloc = ["dep:mimalloc"]
font-embolden = ["dioxus-native/font-embolden"]
apple-font-embolden = ["dioxus-native/apple-font-embolden"]
writing-mode = ["blitz-dom/writing-mode", "dioxus-native/writing-mode"]
# The text backend, which is Parley: on by default, and required.
parley = ["dioxus-native/parley", "blitz-dom/parley", "blitz-html/parley", "blitz-paint?/parley", "blitz-vibey-script?/parley"]

[dependencies]
dioxus-native = { workspace = true, features = [
Expand Down
6 changes: 2 additions & 4 deletions apps/browser/src/document_loader.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use std::sync::{Arc, Mutex};

use blitz_dom::text::TextFonts as _;
use blitz_dom::{DocumentConfig, FontContext};
use blitz_html::{HtmlDocument, HtmlProvider};
use blitz_traits::{
net::{AbortController, AbortSignal, Request, Url},
shell::ShellProvider,
};
use dioxus_native::{SubDocumentAttr, prelude::*};
use linebender_resource_handle::Blob;

use crate::StdNetProvider;
use crate::favicon::favicon_candidate;
Expand Down Expand Up @@ -67,9 +67,7 @@ pub fn make_doc_config(
impl DocumentLoader {
pub fn new(net_provider: Arc<StdNetProvider>, history: SyncStore<History>) -> Self {
let mut font_ctx = FontContext::default();
font_ctx
.collection
.register_fonts(Blob::new(Arc::new(blitz_dom::BULLET_FONT) as _), None);
font_ctx.add_fonts(blitz_dom::BULLET_FONT);

Self {
font_ctx,
Expand Down
10 changes: 6 additions & 4 deletions apps/readme/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ repository.workspace = true
publish = true

[features]
default = ["hybrid", "comrak", "floats", "scrollbars"]
default = ["hybrid", "comrak", "floats", "scrollbars", "parley"]
# The text backend, which is Parley: on by default, and required.
parley = ["blitz-dom/parley", "blitz-html/parley", "blitz-paint/parley", "blitz-shell/parley"]

# Renderers
gpu = ["dep:anyrender_vello"]
Expand Down Expand Up @@ -43,11 +45,11 @@ tracing = ["dep:tracing-subscriber", "blitz-shell/tracing", "blitz-net/tracing",

[dependencies]
blitz-traits = { workspace = true }
blitz-dom = { workspace = true, features = ["default", "parallel-construct"] }
blitz-dom = { workspace = true, features = ["svg", "woff", "accessibility", "system-fonts", "file-input", "custom-widget", "text-transform-icu", "parallel-construct"] }
blitz-html = { workspace = true }
blitz-paint = { workspace = true, features = ["default"] }
blitz-paint = { workspace = true, features = ["svg"] }
blitz-net = { workspace = true, features = ["cookies"] }
blitz-shell = { workspace = true, features = ["default"] }
blitz-shell = { workspace = true, features = ["accessibility", "clipboard", "file-dialog"] }
anyrender_vello = { workspace = true, optional = true }
anyrender_skia = { workspace = true, optional = true }
anyrender_vello_cpu = { workspace = true, features = ["multithreading"], optional = true }
Expand Down
4 changes: 3 additions & 1 deletion examples/counter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ publish = false
crate-type = ["cdylib"]

[features]
default = ["hybrid"]
default = ["hybrid", "parley"]
# The text backend, which is Parley: on by default, and required.
parley = ["dioxus-native/parley", "blitz-dom/parley", "blitz-paint/parley"]
system-fonts = ["blitz-dom/system-fonts"]
vello = ["dioxus-native/vello"]
cpu = ["cpu-pixels"]
Expand Down
4 changes: 3 additions & 1 deletion examples/seven_guis/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ path = "src/main.rs"
crate-type = ["cdylib", "rlib"]

[features]
default = ["hybrid"]
default = ["hybrid", "parley"]
# The text backend, which is Parley: on by default, and required.
parley = ["dioxus-native/parley"]
vello = ["dioxus-native/vello"]
hybrid = ["dioxus-native/vello-hybrid"]
skia = ["dioxus-native/skia"]
Expand Down
4 changes: 3 additions & 1 deletion examples/todomvc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ path = "src/main.rs"
crate-type = ["cdylib"]

[features]
default = ["hybrid"]
default = ["hybrid", "parley"]
# The text backend, which is Parley: on by default, and required.
parley = ["dioxus-native/parley"]
vello = ["dioxus-native/vello"]
hybrid = ["dioxus-native/vello-hybrid"]
skia = ["dioxus-native/skia"]
Expand Down
4 changes: 3 additions & 1 deletion examples/transparent/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ license.workspace = true
publish = false

[features]
default = ["hybrid"]
default = ["hybrid", "parley"]
# The text backend, which is Parley: on by default, and required.
parley = ["dioxus-native/parley", "blitz-dom/parley", "blitz-paint/parley"]
system-fonts = ["blitz-dom/system-fonts"]
vello = ["dioxus-native/vello"]
cpu = ["cpu-pixels"]
Expand Down
3 changes: 2 additions & 1 deletion examples/wasm_hello/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ crate-type = ["cdylib"]

[dependencies]
anyrender_vello_hybrid = { workspace = true, features = ["webgl"] }
blitz-dom = { workspace = true, features = ["woff"] }
# This example builds Parley's font context itself.
blitz-dom = { workspace = true, features = ["woff", "parley"] }
blitz-html = { workspace = true }
blitz-shell = { workspace = true, default-features = false, features = ["tracing"]}

Expand Down
4 changes: 3 additions & 1 deletion examples/wgpu_texture/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ license = "MIT"
publish = false

[features]
default = ["vello-hybrid"]
default = ["vello-hybrid", "parley"]
# The text backend, which is Parley: on by default, and required.
parley = ["dioxus-native/parley", "blitz-dom/parley", "blitz-paint/parley", "blitz-html/parley", "blitz-shell/parley"]
vello = ["dep:anyrender_vello", "dioxus-native/vello"]
vello-hybrid = ["dep:anyrender_vello_hybrid", "dioxus-native/vello-hybrid"]

Expand Down
13 changes: 9 additions & 4 deletions packages/blitz-dom/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,21 @@ default = [
"system-fonts",
"file-input",
"custom-widget",
"text-transform-icu"
"text-transform-icu",
"parley",
]
# The text backend that lays out, edits and reads back text: Parley. It must be
# enabled.
parley = ["dep:parley"]
custom-widget = ["dep:anyrender", "accessibility"]
tracing = ["dep:tracing"]
svg = ["dep:usvg", "dep:svgtypes"]
# WOFF decoding (using the "wuff" crate which is pure Rust)
woff = ["dep:wuff"]
accessibility = ["accesskit"]
system-fonts = ["parley/system"]
system-fonts = ["parley?/system"]
# complex-scripts: enable dictionary-based line-breaking
complex-scripts = ["parley/complex-scripts"]
complex-scripts = ["parley?/complex-scripts"]
# text-transform-icu: language-aware, Unicode-complete case mapping for `text-transform`
# (otherwise falls back to the standard library's case mapping)
text-transform-icu = ["dep:icu_casemap", "dep:writeable"]
Expand Down Expand Up @@ -69,7 +73,8 @@ anyrender = { workspace = true, optional = true }

# Linebender/Fontations dependencies
accesskit = { workspace = true, optional = true }
parley = { workspace = true }
# blitz-paint casts Parley's glyph coordinates with bytemuck.
parley = { workspace = true, optional = true, features = ["bytemuck"] }
skrifa = { workspace = true }
linebender_resource_handle = { workspace = true }
color = { workspace = true }
Expand Down
8 changes: 8 additions & 0 deletions packages/blitz-dom/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//! Reads the text backend feature into the `text_parley` cfg, which the code reads in its place.

fn main() {
println!("cargo::rustc-check-cfg=cfg(text_parley)");
if std::env::var_os("CARGO_FEATURE_PARLEY").is_some() {
println!("cargo::rustc-cfg=text_parley");
}
}
7 changes: 5 additions & 2 deletions packages/blitz-dom/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::HtmlParserProvider;
use crate::text::FontContext;
use blitz_traits::{
navigation::NavigationProvider,
net::{AbortSignal, NetProvider},
shell::{ShellProvider, Viewport},
};
use parley::FontContext;
use std::sync::Arc;
use style::media_queries::MediaType;

Expand Down Expand Up @@ -45,7 +45,10 @@ pub struct DocumentConfig {
pub shell_provider: Option<Arc<dyn ShellProvider>>,
/// HTML parser provider. Used to parse HTML for setInnerHTML
pub html_parser_provider: Option<Arc<dyn HtmlParserProvider>>,
/// Parley `FontContext`
/// The fonts the document lays out text with. Defaults to the platform's fonts, where Blitz
/// is built to read them (`system-fonts`), and Blitz's bullet font. Clones share loaded
/// fonts, so hand a clone of one to every document rather than listing the platform's fonts
/// for each.
pub font_ctx: Option<FontContext>,
/// The CSS media type used to evaluate `@media` rules.
/// Defaults to [`MediaType::screen`].
Expand Down
45 changes: 2 additions & 43 deletions packages/blitz-dom/src/debug.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use blitz_traits::node_id::NodeId;
use parley::layout::PositionedLayoutItem;

use crate::BaseDocument;
use crate::layout::TaffyDebugTree;
use crate::text::InlineText as _;

impl BaseDocument {
pub fn print_taffy_tree(&self) {
Expand Down Expand Up @@ -42,48 +42,7 @@ impl BaseDocument {
.as_ref()
.unwrap();

println!(
"Size: {}x{}",
inline_layout.layout.width(),
inline_layout.layout.height()
);
println!("Text content: {:?}", inline_layout.text);
println!("Inline Boxes:");
for ibox in inline_layout.layout.inline_boxes() {
print!("(id: {}) ", ibox.id);
}
println!();
println!("Lines:");
for (i, line) in inline_layout.layout.lines().enumerate() {
let metrics = line.metrics();
let x = metrics.inline_min_coord;
let y = metrics.block_min_coord;
let w = metrics.inline_max_coord - metrics.inline_min_coord;
let h = metrics.block_max_coord - metrics.block_min_coord;
println!("Line {i}: x:{x} y:{y} width:{w} height:{h}");
for item in line.items() {
print!(" ");
match item {
PositionedLayoutItem::GlyphRun(run) => {
print!(
"RUN (x: {}, w: {}) ",
run.offset().round(),
run.run().advance()
)
}
PositionedLayoutItem::InlineBox(ibox) => print!(
"BOX {:?} (id: {} x: {} y: {} w: {}, h: {})",
ibox.kind,
ibox.id,
ibox.x.round(),
ibox.y.round(),
ibox.width.round(),
ibox.height.round()
),
}
println!();
}
}
inline_layout.debug_print();
}

let layout = node.final_layout();
Expand Down
Loading
Loading