GoSuB Browser Progress, pt33

Created at 2024-02-13 12:12:19 (10 months ago)

Last week I've spend some work on the stylesheets. We are currently able to convert a CST tree into a stylesheet structure that can be used for selector matching. When we have finished generating our document, we also have all the stylesheets (either external, or internal) loaded, so we can create a css map for all the nodes.

For each element, it will check if it matches a selector, and if so, it will add all the declarations for that rule to the element. This result in a list of "declared values" for a node. Once we have done this for all elements in the document tree, we can find the cascaded value: the value that ultimately will win, which is based on origin, size, specificity etc.

With this information, we can fetch the correct cascaded value (this is not the final value, but close enough for now), and do things with it. We have a visitor that will actually check the background color and color properties of the css for each node, and prints that particular node in the correct color (simply on a terminal with help of 256 color ansi sequences for now). We also understand css names like "red", "rebeccapurple", "teal" etc.

Furthermore, we also can remove elements that are not renderable from the list (head, script style tags etc). And in theory we can remove all elements that have a display:none as well.

So happy days! We are finally at a point we can do pipeline stuff. My plan is to simplify the current codebase so it makes a bit more sense, and also try to see if we can generate a layout based on a small subset of css properties like 'width' etc.

Also I'm trying to do some streaming on Twitch whenever i'm busy developing. So take a look at https://twitch.tv/jaytaph

rust css gosub

About jaytaph

Codemuser extraordinaire

avatar Loves building crazy and insane stuff. Happiest when left alone. All I wanted was a Pepsi, just a Pepsi.
Joined:March 24, 2023
Following:2
Followers:2
Posts:51
Comments:3
Upvotes:4
RSS feed