-
Notifications
You must be signed in to change notification settings - Fork 2
Engine
The Engine is the core of the Grob browser, implementing the entire web standards processing pipeline. It handles HTML/CSS parsing, DOM tree construction, style calculation, layout, rendering, and integration with JavaScript and network functionality.
The engine is organized as a collection of specialized modules that work together to transform web content into rendered pixels.
HTML Input
↓
[Parser: HTML] → DOM Tree
↓
[Parser: CSS] → Stylesheets
↓
[Style] → Styled DOM with computed styles
↓
[Layout] → Layout tree with calculated dimensions
↓
[Paint] → Rendering instructions
↓
Pixel Output
Purpose: Parse HTML and CSS content
- HTML Parser: Constructs a DOM tree from HTML source
- CSS Parser: Processes stylesheets and CSS rules
- Implements standard parsing algorithms for web content
Purpose: Document Object Model representation
- Represents the hierarchical structure of web documents
- Stores node information (elements, text, attributes)
- Supports DOM tree navigation and manipulation
Purpose: CSS style processing and cascading
- Applies CSS rules to DOM nodes
- Resolves the CSS cascade (specificity, inheritance)
- Computes final style values for layout
Purpose: Calculate element positions and dimensions
- Implements the CSS box model
- Calculates layout for flow, flex, and grid layouts
- Determines positioning of all elements on the page
Purpose: Render styled and laid-out content to pixels
- Converts layout tree to rendering instructions
- Handles drawing of elements, text, and decorations
- Implements z-index and stacking context rules
Purpose: Font loading, management, and rendering
- Loads and caches fonts from the system and web sources
- Manages font metrics (ascent, descent, line height)
- Provides glyph rendering for text display
Purpose: JavaScript engine integration
- Integrates JavaScript runtime
- Handles script execution within the page context
- Provides DOM APIs for JavaScript to interact with content
Purpose: Network and HTTP operations
- Handles HTTP requests for resources (HTML, CSS, images, fonts)
- Manages network timeouts and error handling
- Supports resource caching
Purpose: Platform-specific abstraction layer
- Provides cross-platform abstractions for OS operations
- Handles file system access and resource loading
- Manages platform-specific rendering details
- Initialization: Create engine components (DOM, Layout Engine, Font Manager)
- Parsing: Parse HTML to build DOM tree
- Styling: Apply CSS and calculate computed styles
- Layout: Calculate element positions and dimensions
- Painting: Render content to pixel buffer
- Interaction: Handle user input and update DOM
- Standard Rust libraries
- External crates for parsing, layout calculations, and font rendering
-
Dom: The document tree structure -
LayoutBox: Represents layout information for DOM elements -
Style: Contains computed CSS properties -
Stylesheet: Collection of CSS rules
The modular architecture allows for:
- Replacement of individual components
- Addition of new layout algorithms
- Support for new CSS features
- Integration of different JavaScript engines