>>39
I'll use Windows' platform to compare against with Chrome since that's the most "consistent" system (i.e. relatively standard set of libraries available.)
GUI: Chrome's...
chrome is rendered using their own custom UI library (just to be platform-independent). It wouldn't surprise me if several hundred KB of data were taken up just by the gradients everywhere. Making it native Win32 would shave a lot of unnecessary abstraction off.
HTTP client: Windows already has one: WinInet.
html5 compliant parsing algorithm: I have written a tokenizer in less than 12KB of binary. The entire parser won't be that much bigger, probably <64KB.
CSS parser: CSS is simpler than HTML in structure and thus easier to parse. Another thing <64KB.
Layout engine: Here is where OOP concepts make sense: each DOM node is associated with a CSS box object that has positions and other properties. Each one has a virtual draw() method. All the layout engine has to do is assign the positions to the boxes appropriately (the tricky part is doing it dynamically as nodes and CSS properties are changed by either the page loading or JS). The window message loop then triggers the appropriate draw()'s on the boxes visible in the current viewport on WM_PAINT and they'll paint themselves on the window. Other events like mouse clicks etc. (e.g. change the cursor to a middle finger when it goes into the box for the 'a' element, and back to an arrow when it leaves) could also be handled by other virtual methods on the boxes. My (very loose) estimate: <256KB.
JS interpreter: This should be the largest. There's this:
http://code.google.com/p/tiny-js/
which is a little over 128KB (the majority of it is C++ bloat.)
Also this, didn't try to compile it (too many files):
http://code.google.com/p/quad-wheel/
My (again very loose) estimate: ~512KB.
That amounts to a browser with <1MB of binary.
Although inserting elements in certain positions would involve reallocating an array, and could get slow if there are lots of sibling nodes.
Reads will be more often than writes, so I'd go with a dynamic array. If you use exponential reallocation then inserts and deletes occur in amortized constant time. A gap buffer or even a rope (
http://en.wikipedia.org/wiki/Rope_(computer_science) ) might be worth thinking about too.