Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Why browsers are bloated

Name: Anonymous 2014-07-27 0:20

https://github.com/WebKit/webkit/blob/master/Source/WebCore/platform/Scrollbar.cpp
https://github.com/WebKit/webkit/blob/master/Source/WebCore/platform/win/ScrollbarThemeWin.cpp
Let's reinvent the fucking scrollbar, which every goddamn platform with a UI already has, and make it behave subtly different from the native one!

Right-click a native scrollbar in some other app:
- Scroll Here
- Top
- Bottom
- Page Up
- Page Down
- Scroll Up
- Scroll Down

Right-click a scrollbar in Chrome:
- Back
- Forward
- Reload
- Save As...
...

Right-click a scrollbar in Firefox and Opera:
Absolutely fucking nothing happens!

What the fuck!? How did these terminally retarded idiots get involved in creating one of the most important pieces of software to the average user?

Name: Cudder !cXCudderUE 2015-07-13 6:30

>>639,640
That explains why web apps are so fucking slow... and I hate reading source code because it looks like the shit in >>1. But here, for probably the first time on the public Web, is the complexities of attribute storage in the most common browser engines.

WebKit:
https://github.com/WebKit/webkit/blob/master/Source/WebCore/dom/Element.cpp

A resizable array of unsorted(!) structures. Funny that elements themselves don't have attributes, but a secondary element->attribute hash table is used. Code is disturbingly verbose; just count how many function calls you have to go through from setAttribute to when the thing actually gets written to the array. The resizeable array itself is a bloody verbose mess too:

https://github.com/WebKit/webkit/blob/master/Source/WTF/wtf/Vector.h

Gecko:
https://hg.mozilla.org/mozilla-central/file/eab21ec484bb/dom/base/FragmentOrElement.h

One resizeable, unsorted array in each element that holds both children and attributes, with a bit of weird hashtable-like hybrid thing:

https://hg.mozilla.org/mozilla-central/file/eab21ec484bb/dom/base/nsAttrAndChildArray.cpp

Code feels a bit less verbose and is more readable than WebKit.

Trident (version used in IE4, no public link to source available):

Resizeable unsorted array allocated off end of element structure.

NetSurf:

Doubly-linked, doubly-indirect(!) unsorted list.

Dillo:

No attributes stored in element structure itself! Reparses the markup for every attribute retrieval operation. :facepalm:

tl;dr: O(n) except for Gecko which may be O(1) for some cases ("mapped attributes".)

I'll go with an unsorted parallel array for my browser; it's probably not going to be worse than what's out there already(especially those "lightweight" browsers at the end) and likely slightly better cache-wise to use parallel arrays than arrays of structures.

Next part: CSS property-value storage. There are many more KV pairs on average than with attributes, so I expect to see some different data structures.

Newer Posts