we (web engine): Experimental web browser project to understand the limits of Claude

CSS resource loading: support #74

open opened by pierrelf.com

Phase 8 — Resource Loading + Character Encoding + Real Page Loading#

Implement loading of external CSS stylesheets referenced by <link rel="stylesheet"> elements.

Requirements#

  • After HTML parsing, scan the DOM for <link rel="stylesheet" href="..."> elements
  • Resolve the href attribute against the document's base URL
  • Fetch the stylesheet using the ResourceLoader
  • Parse the fetched CSS text using the css crate parser
  • Merge external stylesheet rules with inline <style> rules in proper cascade order
  • Handle @import rules (fetch and parse imported stylesheets, with depth limit to prevent cycles)
  • Respect media attribute on <link> (basic: screen, all)
  • Handle type="text/css" attribute (default if omitted)

Integration Points#

  • html crate: extract <link> elements from DOM after tree building
  • url crate: resolve relative URLs
  • encoding crate: decode CSS text with correct encoding
  • css crate: parse stylesheet text
  • style crate: merge rules into cascade

Acceptance Criteria#

  • External stylesheets are fetched and parsed
  • Rules from external sheets participate in cascade with correct origin/order
  • Relative URLs in href are resolved correctly
  • @import is followed (with cycle/depth protection, max depth 5)
  • Missing/failed stylesheet loads are handled gracefully (no crash)
  • No external dependencies, no unsafe
  • Unit tests with mock/constructed scenarios

Dependencies#

Depends on: Resource loader, CSS parser (already complete)

sign up or login to add to the discussion
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:meotu43t6usg4qdwzenk4s2t/sh.tangled.repo.issue/3mhkt6vtv3q2g