diff options
author | Andreas Kling <kling@serenityos.org> | 2020-06-14 22:09:35 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-06-14 22:09:35 +0200 |
commit | 246e0e47ec731fdb7c5b930f1c2c55af3dfa84bc (patch) | |
tree | fef33eda0c2deb1722d98601173afc240768497b | |
parent | 9ad3e6cd8ae566b3bbae932d68fd521e49cf7358 (diff) | |
download | serenity-246e0e47ec731fdb7c5b930f1c2c55af3dfa84bc.zip |
LibWeb: Make the specificity sort comparator a bit more readable
-rw-r--r-- | Libraries/LibWeb/CSS/StyleResolver.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/Libraries/LibWeb/CSS/StyleResolver.cpp b/Libraries/LibWeb/CSS/StyleResolver.cpp index 62a8e44ff5..142a100342 100644 --- a/Libraries/LibWeb/CSS/StyleResolver.cpp +++ b/Libraries/LibWeb/CSS/StyleResolver.cpp @@ -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) { |