Giter VIP home page Giter VIP logo

br-ow-ser's Introduction

br-ow-ser

Overview

Welcome to br-ow-ser, a toy browser project created for learning purposes. This project is designed to help me explore the fundamentals of web browsers, including HTML parsing, CSS parsing, a layout engine, render tree, a painting engine and more. The goal is to provide a simplified implementation to aid in understanding the core concepts behind browsers.

Disclaimer

This project is not intended for production use. It's a study project meant to deepen your understanding of browser internals.

This project intentionally omits considerations for real-world complexities, such as:

  • Practical Usability
  • Adherence to Industry Standards
  • Performance Optimization
  • Interoperability Concerns

This intentional exclusion allows for a focused exploration of fundamental concepts without the constraints imposed by real-world implementation challenges.

Features

  • HTML Parsing: Converts HTML strings into a Document Object Model (DOM) tree. This parser works for a few subset of HTML syntax:

    • Balanced tags;
    • Attributes with quoted values;
    • Text nodes;
    • Comments;
    • Processing Instruction;
    • Error handling (Non-well-formed markup).
  • CSS Parsing: Parses CSS strings to handle styling and layout. This parser works for a few subset of CSS syntax:

    • Selector (Simple Selector);
  • Render Tree: Combines information from the DOM tree and layout engine for rendering.

  • Layout Engine: Determines the size and position of each element on the page.

  • Painting Engine: Draws the render tree on the screen.

  • JavaScript Engine: Comprising parsers, interpreters, and compilers.

Installation

Ensure you have Rust installed on your machine. If not, you can install it by following the instructions at Rust Installation Guide.

  1. Clone the repository:

    git clone https://github.com/andraderaul/br-ow-ser.git
    cd br-ow-ser
  2. Building and Running with Optimizations:

    • For optimized builds, use cargo build --release to build and cargo run --release to run.
  3. Customizing Input Files:

    • By default, br-ow-ser loads test.html and test.css from the examples directory.
    • To specify custom HTML and CSS files, use the --html and --css arguments:
      ./target/debug/br-ow-ser --html examples/custom.html --css examples/custom.css
  4. Output Configuration:

    • The rendered page is saved as output.png by default.
    • To change the output filename, use the -o option:
      ./target/debug/br-ow-ser --html examples/test.html --css examples/test.css -o custom_output.png
    • To switch to PDF output, add --format pdf:
      ./target/debug/br-ow-ser --html examples/test.html --css examples/test.css -o custom_output.pdf --format pdf

What I learned in this journey

In this journey, I delved into several key aspects:

  1. Rust Programming: Explored Rust, leveraging its performance and safety features.

  2. Web Development Basics: Covered core concepts like HTML, CSS, and the Document Object Model (DOM).

  3. Toy Rendering Engine Features:

    • HTML and CSS Parsing
    • Layout Engines
    • Render Trees
    • Painting Engines
  4. HTML Parser in Rust: Developed an HTML parser in Rust, enabling the processing of HTML documents.

  5. CSS Parser in Rust: Developed a CSS parser in Rust, including rules, selectors, and unit conversions.

  6. Styling the DOM: Explored styling elements in the DOM using specified CSS values, considering selector matching and specificity.

  7. Unit Conversions: Extended unit conversions to support various units such as pixels, percentages, em, and rem.

  8. Testing: Emphasized the importance of testing, creating tests for different value types and scenarios.

Acknowledgments

br-ow-ser's People

Contributors

andraderaul avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.