mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:28:12 +00:00
LibWeb: Compress specificity into a 32-bit unsigned int
Instead of storing the three-part specificy for every selector, just mash them together into a 32-bit value instead. This saves both space and time, and matches the behavior of other browser engines.
This commit is contained in:
parent
8be74ea65c
commit
49dd4b7e8a
4 changed files with 6 additions and 68 deletions
|
@ -497,12 +497,14 @@ NonnullRefPtr<StyleProperties> StyleResolver::resolve_style(const Element& eleme
|
|||
quick_sort(matching_rules, [&](MatchingRule& a, MatchingRule& b) {
|
||||
auto& a_selector = a.rule->selectors()[a.selector_index];
|
||||
auto& b_selector = b.rule->selectors()[b.selector_index];
|
||||
auto a_specificity = a_selector.specificity();
|
||||
auto b_specificity = b_selector.specificity();
|
||||
if (a_selector.specificity() == b_selector.specificity()) {
|
||||
if (a.style_sheet_index == b.style_sheet_index)
|
||||
return a.rule_index < b.rule_index;
|
||||
return a.style_sheet_index < b.style_sheet_index;
|
||||
}
|
||||
return a_selector.specificity() < b_selector.specificity();
|
||||
return a_specificity < b_specificity;
|
||||
});
|
||||
|
||||
for (auto& match : matching_rules) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue