diff --git a/Libraries/LibWeb/CSS/StyleResolver.cpp b/Libraries/LibWeb/CSS/StyleResolver.cpp index 9fa9591510f19f..5baf531a82f9c7 100644 --- a/Libraries/LibWeb/CSS/StyleResolver.cpp +++ b/Libraries/LibWeb/CSS/StyleResolver.cpp @@ -24,6 +24,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include #include @@ -439,6 +440,13 @@ NonnullRefPtr StyleResolver::resolve_style(const Element& eleme element.apply_presentational_hints(*style); auto matching_rules = collect_matching_rules(element); + + // FIXME: We need to look at the specificity of the matching *selector*, not just the matched *rule*! + // FIXME: It's really awkward that NonnullRefPtrVector cannot be quick_sort()'ed + quick_sort(reinterpret_cast>&>(matching_rules), [&](auto& a, auto& b) { + return a->selectors().first().specificity() < b->selectors().first().specificity(); + }); + for (auto& rule : matching_rules) { for (auto& property : rule.declaration().properties()) { set_property_expanding_shorthands(style, property.property_id, property.value); diff --git a/Libraries/LibWeb/CSS/StyleRule.h b/Libraries/LibWeb/CSS/StyleRule.h index 2b857080570a44..ec98ae59201952 100644 --- a/Libraries/LibWeb/CSS/StyleRule.h +++ b/Libraries/LibWeb/CSS/StyleRule.h @@ -33,6 +33,9 @@ namespace Web { class StyleRule : public RefCounted { + AK_MAKE_NONCOPYABLE(StyleRule); + AK_MAKE_NONMOVABLE(StyleRule); + public: static NonnullRefPtr create(Vector&& selectors, NonnullRefPtr&& declaration) {