فهرست منبع

LibWeb: Account for all simple-selectors when calculating specificity

This fixes the Acid2 blue nose when hovering. :^)
Sam Atkins 3 سال پیش
والد
کامیت
b76ee0e30d
1فایلهای تغییر یافته به همراه7 افزوده شده و 0 حذف شده
  1. 7 0
      Userland/Libraries/LibWeb/CSS/Selector.cpp

+ 7 - 0
Userland/Libraries/LibWeb/CSS/Selector.cpp

@@ -32,6 +32,7 @@ Optional<Selector::PseudoElement> Selector::pseudo_element() const
     return {};
     return {};
 }
 }
 
 
+// https://www.w3.org/TR/selectors-4/#specificity-rules
 u32 Selector::specificity() const
 u32 Selector::specificity() const
 {
 {
     if (m_specificity.has_value())
     if (m_specificity.has_value())
@@ -48,9 +49,12 @@ u32 Selector::specificity() const
                 ++ids;
                 ++ids;
                 break;
                 break;
             case SimpleSelector::Type::Class:
             case SimpleSelector::Type::Class:
+            case SimpleSelector::Type::Attribute:
+            case SimpleSelector::Type::PseudoClass:
                 ++classes;
                 ++classes;
                 break;
                 break;
             case SimpleSelector::Type::TagName:
             case SimpleSelector::Type::TagName:
+            case SimpleSelector::Type::PseudoElement:
                 ++tag_names;
                 ++tag_names;
                 break;
                 break;
             default:
             default:
@@ -180,6 +184,9 @@ String Selector::SimpleSelector::serialize() const
             VERIFY_NOT_REACHED();
             VERIFY_NOT_REACHED();
         }
         }
         break;
         break;
+    case Selector::SimpleSelector::Type::PseudoElement:
+        // Note: Pseudo-elements are dealt with in Selector::serialize()
+        break;
     default:
     default:
         dbgln("FIXME: Unsupported simple selector serialization for type {}", to_underlying(type));
         dbgln("FIXME: Unsupported simple selector serialization for type {}", to_underlying(type));
         break;
         break;