summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb
diff options
context:
space:
mode:
authorTobias Christiansen <tobi@tobyase.de>2021-05-24 23:01:24 +0200
committerLinus Groh <mail@linusgroh.de>2021-05-28 10:45:38 +0100
commitbf9c5ffb3f8e1544fe4168fb59d8eecccf7a001d (patch)
tree5efed55730e044538adc95ba1ff8822bbe813aa2 /Userland/Libraries/LibWeb
parentc4588a2cde68aeb54b24a7a31b60564247e3ebe7 (diff)
downloadserenity-bf9c5ffb3f8e1544fe4168fb59d8eecccf7a001d.zip
LibWeb: StyleResolver: Keep track of specificity of matched selector
This way it gets easier to compare matches.
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r--Userland/Libraries/LibWeb/CSS/StyleResolver.cpp2
-rw-r--r--Userland/Libraries/LibWeb/CSS/StyleResolver.h1
2 files changed, 2 insertions, 1 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/StyleResolver.cpp b/Userland/Libraries/LibWeb/CSS/StyleResolver.cpp
index 0d72b5fce4..bf5720a413 100644
--- a/Userland/Libraries/LibWeb/CSS/StyleResolver.cpp
+++ b/Userland/Libraries/LibWeb/CSS/StyleResolver.cpp
@@ -74,7 +74,7 @@ Vector<MatchingRule> StyleResolver::collect_matching_rules(const DOM::Element& e
size_t selector_index = 0;
for (auto& selector : rule.selectors()) {
if (SelectorEngine::matches(selector, element)) {
- matching_rules.append({ rule, style_sheet_index, rule_index, selector_index });
+ matching_rules.append({ rule, style_sheet_index, rule_index, selector_index, selector.specificity() });
break;
}
++selector_index;
diff --git a/Userland/Libraries/LibWeb/CSS/StyleResolver.h b/Userland/Libraries/LibWeb/CSS/StyleResolver.h
index 4042898b97..6b2e980893 100644
--- a/Userland/Libraries/LibWeb/CSS/StyleResolver.h
+++ b/Userland/Libraries/LibWeb/CSS/StyleResolver.h
@@ -18,6 +18,7 @@ struct MatchingRule {
size_t style_sheet_index { 0 };
size_t rule_index { 0 };
size_t selector_index { 0 };
+ u32 specificity { 0 };
};
class StyleResolver {