A web browser built from scratch following the book Web Browser Engineering
This project is a from-scratch implementation of a functional web browser. The goal was to understand the internal components of a browser - from making HTTP requests to HTML parsing, basic CSS styling, adding interactive elements like links and buttons and so on.
- URL parsing
- Retrieving pages through establishing TCP-based connection with server
- HTML parsing and DOM tree construction
- CSS parsing and basic styling
- Layout engine
- Rendering engine using Tkinter
- Support for tabs, scrolling
- Form submission
- Changing DOM and reacting to events
- Support for rendering images
- Zooming
- Cookies and logins
- and so on ...
- Python 3.x
- Tkinter
To browse a webpage (say homepage of browser engineering book):
cd src/
python3 main.py https://browser.engineering/
To browse a local HTML test file:
cd src/
python3 main.py file://test.html
.
├── browser-components.png
├── README.md
└── src
├── browser.py
├── constants.py
├── css_parser.py
├── layout.py
├── layout_tree.py
├── layout_tree_simple.py
├── lexer.py
├── main.py
├── parser.py
├── resume.html
├── test.html
├── url.py
├── user_agent.css
└── utils.py
1 directory, 16 files
A chapter from the book Web Browser Engineering rendered using current browser:
- The browser doesn't support whitespace-only text nodes. Real browser retain such whitespaces to correctly render make up as two. This browser won't. Ignoring whitespaces simplifies complexities, by avoiding a special case for whitespaces only text tags.
- The browser doesn't support parenthesis in CSS property values. This inhibits us from parsing things like
calcandurlfunctions (are supported in real browsers). - Each word that will be rendered by the browser will have a single font for all the letters. Hence the browser cannot accomodate letters with different font in between a word.
- Web Browser Engineering by Pavel Panchekha and Chris Harrelson
