GoSuB Browser Progress, pt33
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
About jaytaph
Codemuser extraordinaire
Joined: | March 24, 2023 |
Following: | 2 |
Followers: | 2 |
Posts: | 51 |
Comments: | 3 |
Upvotes: | 4 |
Previous musings
- (1) December 2024
- (1) November 2024
- (1) October 2024
- (1) September 2024
- (1) July 2024
- (2) February 2024
- (3) January 2024
- (3) December 2023
- (4) November 2023
- (5) October 2023
- (10) September 2023
- (8) August 2023
- (1) June 2023
- (1) May 2023
- (4) April 2023
- (5) March 2023