~prokop/lebka

1429882a68ddc4643565ceff12252c533f4e60fe — Prokop Randacek 1 year, 6 months ago 7bc67f4
make boxes transparent by default
3 files changed, 95 insertions(+), 41 deletions(-)

M Cargo.lock
M Cargo.toml
M src/sandbox.rs
M Cargo.lock => Cargo.lock +73 -32
@@ 320,6 320,27 @@ dependencies = [
]

[[package]]
name = "errno"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1"
dependencies = [
 "errno-dragonfly",
 "libc",
 "winapi",
]

[[package]]
name = "errno-dragonfly"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf"
dependencies = [
 "cc",
 "libc",
]

[[package]]
name = "fastrand"
version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 664,6 685,16 @@ dependencies = [
]

[[package]]
name = "io-lifetimes"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1abeb7a0dd0f8181267ff8adc397075586500b81b28a73e8a0208b00fc170fb3"
dependencies = [
 "libc",
 "windows-sys 0.45.0",
]

[[package]]
name = "ipnet"
version = "2.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 731,6 762,12 @@ dependencies = [
]

[[package]]
name = "linux-raw-sys"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4"

[[package]]
name = "lock_api"
version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 959,15 996,6 @@ dependencies = [
]

[[package]]
name = "nom8"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae01545c9c7fc4486ab7debaf2aad7003ac19431791868fb2e8066df97fad2f8"
dependencies = [
 "memchr",
]

[[package]]
name = "num-traits"
version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 1145,9 1173,9 @@ checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160"

[[package]]
name = "proc-macro-crate"
version = "1.3.0"
version = "1.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "66618389e4ec1c7afe67d51a9bf34ff9236480f8d51e7489b7d5ab0303c13f34"
checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919"
dependencies = [
 "once_cell",
 "toml_edit",


@@ 1214,15 1242,6 @@ dependencies = [
]

[[package]]
name = "remove_dir_all"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7"
dependencies = [
 "winapi",
]

[[package]]
name = "reqwest"
version = "0.11.14"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 1272,6 1291,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"

[[package]]
name = "rustix"
version = "0.36.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f43abb88211988493c1abb44a70efa56ff0ce98f233b7b276146f1f3f7ba9644"
dependencies = [
 "bitflags",
 "errno",
 "io-lifetimes",
 "libc",
 "linux-raw-sys",
 "windows-sys 0.45.0",
]

[[package]]
name = "rusttype"
version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 1422,9 1455,9 @@ dependencies = [

[[package]]
name = "speedy2d"
version = "1.10.0"
version = "1.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "17fe225cbe32135d73bec0e6a0de2bed1528c00437a77b055d4e3290b212ff1a"
checksum = "4c36e9d2ee392b3e5b0caf1d315c2b1ddf8cb5f3350dce6e875ab1b92df6737d"
dependencies = [
 "backtrace",
 "earcutr",


@@ 1459,16 1492,15 @@ dependencies = [

[[package]]
name = "tempfile"
version = "3.3.0"
version = "3.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4"
checksum = "af18f7ae1acd354b992402e9ec5864359d693cd8a79dcbef59f76891701c1e95"
dependencies = [
 "cfg-if 1.0.0",
 "fastrand",
 "libc",
 "redox_syscall",
 "remove_dir_all",
 "winapi",
 "rustix",
 "windows-sys 0.42.0",
]

[[package]]


@@ 1596,19 1628,19 @@ dependencies = [

[[package]]
name = "toml_datetime"
version = "0.5.1"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4553f467ac8e3d374bc9a177a26801e5d0f9b211aa1673fb137a403afd1c9cf5"
checksum = "3ab8ed2edee10b50132aed5f331333428b011c99402b5a534154ed15746f9622"

[[package]]
name = "toml_edit"
version = "0.18.1"
version = "0.19.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56c59d8dd7d0dcbc6428bf7aa2f0e823e26e43b3c9aca15bbc9475d23e5fa12b"
checksum = "9a1eb0622d28f4b9c90adc4ea4b2b46b47663fde9ac5fafcb14a1369d5508825"
dependencies = [
 "indexmap",
 "nom8",
 "toml_datetime",
 "winnow",
]

[[package]]


@@ 2005,6 2037,15 @@ dependencies = [
]

[[package]]
name = "winnow"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "faf09497b8f8b5ac5d3bb4d05c0a99be20f26fd3d5f2db7b0716e946d5103658"
dependencies = [
 "memchr",
]

[[package]]
name = "winreg"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"

M Cargo.toml => Cargo.toml +3 -3
@@ 7,14 7,14 @@ repository = "https://git.sr.ht/~prokop/lebka"
description = "minimalistic web browser based on lua as the replacement for html+css+js"

[dependencies]
speedy2d  = { version = "1", default-features = false, features = ["windowing"] }
mlua      = { version = "0", default-features = false, features = ["luajit", "async", "vendored"] }
reqwest   = { version = "0", default-features = false, features = ["default-tls"] }
tokio     = { version = "1", default-features = false, features = ["fs", "macros", "rt-multi-thread"] }
speedy2d  = { version = "1", default-features = false, features = ["windowing"] }
thiserror = { version = "1", default-features = false }
tokio     = { version = "1", default-features = false, features = ["fs", "macros", "rt-multi-thread"] }

[dev-dependencies]
test-case  = "3"
test-case = "3"

[profile.release]
lto = true

M src/sandbox.rs => src/sandbox.rs +19 -6
@@ 208,12 208,25 @@ impl Sandbox {
        b.padding_bottom = t.get("b").unwrap_or_default();
        b.padding_right = t.get("r").unwrap_or_default();

        b.background_color = Color::from_rgba(
            t.get("R").unwrap_or_default(),
            t.get("G").unwrap_or_default(),
            t.get("B").unwrap_or_default(),
            t.get("A").unwrap_or(1.0),
        );
        b.background_color = {
            let r = t.get("R");
            let g = t.get("G");
            let b = t.get("B");
            let a = t.get("A");

            // if non of rgba are set, the default trasnparency is 0, else 1
            let a = a.unwrap_or(if r.is_err() && g.is_err() && b.is_err() {
                0.0
            } else {
                1.0
            });

            let r = r.unwrap_or(0.0);
            let g = g.unwrap_or(0.0);
            let b = b.unwrap_or(0.0);

            Color::from_rgba(r, g, b, a)
        };

        Ok(b)
    }