Improve stylesheet attribute handling
Currently, a node can only hold one set of stylesheet attributes (a VisualAttributes instance) that is going to be a BLOB in memory if all stylesheet attributes are represented in it, even if they are not needed or could be derived from parent nodes. In reality, the style of the node is determined in parts by the parent nodes styles, the set of rules and the node's own style (via the style HTML attribute).
To improve the handling of stylesheet attributes, the VisualAttributes class should be replaced by a map. The key of each map item is an item of a new enum class for stylesheet attribute names. The value of each map item is either a nullptr (representing unset) or an instance of a class that implements the StylesheetValue interface. There shall be several implementation for the different types of stylesheet values: strings, integers, floats, colours, dimensions and more.
In a node, the „style“ attribute, which holds a VisualAttributes instance as of now, shall be replaced by a vector of (shared or weak) pointers that each point to a stylesheet rule that is applied to the node. The first item in the vector is the less specific rule while the vector's last item is the most specific rule.
To represent the real style of the node, a computed_style attribute is added that includes all stylesheet attributes of all applied rules and stylesheet attributes of the parent nodes, if the attributes are inherited. This way, a reference to the applied rules is given (for a later developer console in the browser) and memory isn't wasted by a huge amount of VisualAttributes instances.
- Add DocumentNode::computed_style of type StylesheetRule
- Replace DocumentNode::style with std::vector<std::(shared_ptr/weak_ptr)>
- Define an enum class for stylesheet attribute names and fill it.
- Define a StylesheetValue interface
- Define StylesheetValueDimension
- Define StylesheetValueString
- Define StylesheetValueColour
- Define more StylesheetValue implementations
- Replace StylesheetRule::attributes with a std::map<(attribute name enum class), std::shared_ptr>
- Change code of MoeNavigatorEngine::determineVisualAttributes
- Change code of CSSParser::convertAttribute
- Update documentation
- Update tests
Deleting a branch is permanent. It CANNOT be undone. Continue?