You are browsing as a guest. Sign up (or log in) to start making projects!

StarBrowser

  • 8 Devlogs
  • 23 Total hours

A Web browser made in rust

Ship #1 Pending review

I made a web browser from scratch in Rust. I made my own networking code, it can fetch HTTP and HTTPS websites, and it can parse the HTML itself. The challenging part was getting the websites to actually show up since everytime I tried to get it to work it kept showing No Response. I was able to fix this by rewriting my client.rs file and changing the way the app connects to websites. I am proud of this whole thing as I was still a sort of ‘intermediate beginner’ to rust but I got the hang of it by watching a bunch of youtube videos at 3am in the morning and learning from w3schools as well as getting documentation from the Mozilla docs. To run the project you just need to run the windows exe. For macOS and Linux I cannot test those executables so I am not 100% sure but the windows exe works. Just make sure that on some websites like google.com you need the www subdomain first. All websites require http:// or https:// at the start. Other websites like github.com dont need the www. I was initially going to add working CSS styling however due to Stardance ending soon and I was on holiday for majority of the time I just didn’t have time.

  • 8 devlogs
  • 23h
Try project → See source code →
Open comments for this post

1h 39m 48s logged

This is a short change, initially I was working on making working CSS styling however I don’t have the time for it so all I did was create a release workflow (which took longer than expected) and I made a README going through all the features and limitations as well as a rundown of the app. I have made 3 executables. One for Windows, Linux and MacOS. All are x86_64 not ARM. I am unable to test the Linux and MacOS executables however the windows one works.

0
0
33
Open comments for this post

4h 6m 14s logged

First in the UI and Rendering architecture I added a 2010 style chrome colour palette. I also implemented new vertex, rect and ui structs with layout_ui() to calculate and position the tab strip, address bat, navi buttons and the content viewport. I also made a new WGSL shader pipeline and vertex buffer for rendering flat colour rectangles. I then added normalise_url(), fetch_page(), navigate(), go_history() and reload(). Then I updated the core State struct, removed the raw display_text stering and replaced it with rectangle pipelines, address input state, focus flags, document title tracking, history stacks, scroll offsets and mouse tracking. I rewrote window_event() and app resume logic to handle the mouse movements, vlivks, wheel scrolling and keyboard typing including Enter backspace and shortcuts with ctrl and alt. I also removed the esc to quit application and it now just refocuses onto the addrtess bar. And render() draws the UI rectabgles first, then the address text, tabs buttons and page text with clipping and scroll offsets on a white background.

I also made a new HTML Parser module. With tokenisation and scanning, it includfes void/raw text element lists, entitity decoding with &amp, &nbdp, etc, character scanning and attribute parsing. parse() constructs the existing HTMLDocument and HTMLNode types from client.rs which handles comments, doctypes, closing tags and script/style. With DOM Utils it includfes is_block_level(), extract_visible_text() which skips , , and tags while infecting liner breaks around block elements and nodewalking and title extraction (find_title()).

I also deleted cssrom.rs whcih I originally had plans for but I just merged them into parser.rs and cascade.rs.

My current limitations are rendering since the pages only display as plain text so no images, hyperlinks, styling or CSS in general. There is also network bliocking where page fetching is synchronus and blocks the UI window while loading.

0
0
28
Open comments for this post

8h 1m 43s logged

I can guarantee you I am not dead even though its been like 3 months. I build about the entire css engine. I can now display the web page’s html onto the app. In the app you can’t scroll down as I still need to implement that but this is progress. A lot of the functionality is there in my code but it is unused since I need to do a whole lot more work on it but this devlog is already 8 hours and I don’t want to go over 10 so I’m making a devlog here.

tokenise.rs is a css level 3 tokeniser and is pretty much the architecture. units.rs is just simple unit and angle conversion. colour.rs is just colour parsing. colours.rs is mostly just the colour-name hex table. selectors.rs is the full selector parser. parser.rs is the component valuesa dn declarations into a Stylesheet model. cascade.rs matches an element against a stylesheet and sorts it by specificity/order. box_model.rs and layout.rs just set the layout of the app’s edges/borders/padding/margin and a block-layout pass decoupled from font types that dont exist in the app natively.

I would write a lot more and style the devlog better but this new stardance thing with the animations everywhere make it almost impossible to type properly and I’m on a gaming laptop

0
0
36
Open comments for this post

2h 39m 26s logged

Added Protocol::connect_tls() method using rustls::StreamOwned<rustls::ClientConnection, TcpStream>.
Created AllowAnyVerifier implementing rustls::client::danger::ServerCertVerifier to accept any certificate
AddedClient::connect_tls() that loads ca-certificates.crt if present otherwise falls back to system certs
TLS now works for HTTP1_1 and HTTP2_0 protocols
New DNSCache struct with Arc<Mutex<HashMap<String, DNSCacheEntry»> thread-safe, TTL-based
DNSCacheEntry stores resolved SocketAddr list + expiry timestamp
resolve_dns() now uses trust_dns_resolver::Resolver::from_system_conf() for proper DNS lookups, with fallback to ToSocketAddrs
parse_url() extracts the host, port, and TLS flag from http:// or https:// URLs
Handles explicit ports (example.com:8080) and defaults (80/443)
connect_to() now calls resolve_and_connect() which uses DNS cache + TLS decision logic
Client now tracks redirect_count
send_request() detects 3xx status codes, reads location header, and follows redirects
HTMLTag -enum of all standard HTML5 tags
HTMLAttribute -name/value pairs
HTMLNode - tag + attributes + children + optional text content
HTMLDocument -doctype + root node
HTMLTag::from_string() - case-insensitive parser for all tags

1
0
4
Open comments for this post

1h 36m 38s logged

I added text rendering to the wgpu window so it displays the HTTP status code instead of just printing it to the console. The window now shows “Status: 200” (or whatever the server returns)

0
0
4
Open comments for this post

2h 14m 11s logged

I added response decoding and support for http0.9 1.0 and 1.1. These guides: browser.engineering, firefox guides and servo were amazing resources for learning how HTTP works and with encoding/decoding requests and responses. I mostly just followed along with how firefox worked and built my way away from it but the code formatting went a bit off in the middle (it was 4:30am I have an exam in 4 hours I was tired)
Next I want to print everything in the UI instead of terminal

0
0
5
Open comments for this post

31m 21s logged

Added the initial browser engine foundataion. I added basic support for http protocol and implemented http request encoding.

0
0
3
Open comments for this post

2h 16m 26s logged

I created the basic app here but it just shows a colour right now. I was following a tutorial on basic rust because I’m still learning it.

0
0
4

Delete project?

Are you sure you want to permanently delete this project? This action cannot be undone.

All devlogs, followers, and associated data will be removed.

Followers

Loading…