mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
LibWeb: Make the specificity sort comparator a bit more readable
This commit is contained in:
parent
9ad3e6cd8a
commit
246e0e47ec
Notes:
sideshowbarker
2024-07-19 05:38:41 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/246e0e47ec7
1 changed files with 6 additions and 9 deletions
|
@ -497,15 +497,12 @@ 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];
|
||||
if (a_selector.specificity() < b_selector.specificity())
|
||||
return true;
|
||||
if (!(a_selector.specificity() == b_selector.specificity()))
|
||||
return false;
|
||||
if (a.style_sheet_index < b.style_sheet_index)
|
||||
return true;
|
||||
if (a.style_sheet_index > b.style_sheet_index)
|
||||
return false;
|
||||
return a.rule_index < b.rule_index;
|
||||
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();
|
||||
});
|
||||
|
||||
for (auto& match : matching_rules) {
|
||||
|
|
Loading…
Add table
Reference in a new issue