use std::cell::RefCell; use we_html::parse_html; use we_layout::layout; use we_platform::appkit; use we_platform::cg::BitmapContext; use we_render::Renderer; use we_style::computed::{extract_stylesheets, resolve_styles}; use we_text::font::{self, Font}; /// Default HTML page shown when no file argument is provided. const DEFAULT_HTML: &str = r#" we browser

Hello from we!

This is a from-scratch web browser engine written in pure Rust.

Zero external crate dependencies. Every subsystem is implemented in Rust.

Features

HTML5 tokenizer, DOM tree, block layout, CSS cascade, and software rendering.

"#; /// Browser state kept in thread-local storage so the resize handler can /// access it. All AppKit callbacks run on the main thread. struct BrowserState { html: String, font: Font, bitmap: Box, view: appkit::BitmapView, } thread_local! { static STATE: RefCell> = const { RefCell::new(None) }; } /// Re-run the full pipeline: parse → extract CSS → resolve styles → layout → render → copy to bitmap. fn render_page(html: &str, font: &Font, bitmap: &mut BitmapContext) { let width = bitmap.width() as u32; let height = bitmap.height() as u32; if width == 0 || height == 0 { return; } // Parse HTML into DOM. let doc = parse_html(html); // Extract CSS from