Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This (draft) PR implements a CSS system that allows to easily fetch properties from a renderer perspective.
We already are able to parse (internal and external) stylesheets into CSS ASTs. These are automatically attached to a document(handle).
From this point, a useragent can generate a render-tree which is a document but without any invisible or unrenderable nodes. This render tree should have for each node its CSS properties so you can easily find any CSS property on that node.
If there are no properties for a specific node, it will check if the queried property is inheritable (like
font
). if so, it will traverse down the nodes to find the property there. If none are found, or the property is not inheritable, it will use the default value for that property as defined.In order to make sure that properties have correct values, we can use the CSS documention's Value Syntax, where many properties are defined. This means that whenever we have a syntax for a property, we can check if any given value that is defined for that property actually matches the syntax (for instance: the
color
does not understand3em
).The system is also able to generate shorthand properties. For instance, "border" is a property that is shorthand for
border-color
,border-size
andborder-style
. These properties are again even shorthand forborder-top-*
,border-right-*
, etc.So when have defined a
border: 1px solid black
, we can fetchborder-bottom-style
, and retrieve the value "solid
".To do or to check:
Future work:
In a later PR, we will change this API to actually return enums that allows to do better matching. For instance,
border-bottom-style
property will return not aCssValue()
, but aCssBorderStyle
enum which could be something like:This way, we have the rust compiler to check if we are forgetting and not handling certain CSS3 values for given properties.