Title: [290640] trunk/Source/WebCore
Revision
290640
Author
n...@apple.com
Date
2022-03-01 03:24:59 -0800 (Tue, 01 Mar 2022)

Log Message

Explicitly disable style sharing for form controls
https://bugs.webkit.org/show_bug.cgi?id=237236

Reviewed by Antti Koivisto.

There was a typo introduced in bug 153768 and bug 138769, which essentially disables
style sharing completely for form controls. Let's make that explicit.

* style/StyleSharingResolver.cpp:
(WebCore::Style::SharingResolver::canShareStyleWithControl): Removed.
(WebCore::Style::SharingResolver::canShareStyleWithElement const):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (290639 => 290640)


--- trunk/Source/WebCore/ChangeLog	2022-03-01 10:28:38 UTC (rev 290639)
+++ trunk/Source/WebCore/ChangeLog	2022-03-01 11:24:59 UTC (rev 290640)
@@ -1,3 +1,17 @@
+2022-03-01  Tim Nguyen  <n...@apple.com>
+
+        Explicitly disable style sharing for form controls
+        https://bugs.webkit.org/show_bug.cgi?id=237236
+
+        Reviewed by Antti Koivisto.
+
+        There was a typo introduced in bug 153768 and bug 138769, which essentially disables
+        style sharing completely for form controls. Let's make that explicit.
+
+        * style/StyleSharingResolver.cpp:
+        (WebCore::Style::SharingResolver::canShareStyleWithControl): Removed.
+        (WebCore::Style::SharingResolver::canShareStyleWithElement const):
+
 2022-03-01  Cameron McCormack  <hey...@apple.com>
 
         Make input element UA shadow tree creation lazy

Modified: trunk/Source/WebCore/style/StyleSharingResolver.cpp (290639 => 290640)


--- trunk/Source/WebCore/style/StyleSharingResolver.cpp	2022-03-01 10:28:38 UTC (rev 290639)
+++ trunk/Source/WebCore/style/StyleSharingResolver.cpp	2022-03-01 11:24:59 UTC (rev 290640)
@@ -179,33 +179,6 @@
     return nullptr;
 }
 
-static bool canShareStyleWithControl(const HTMLFormControlElement& element, const HTMLFormControlElement& formElement)
-{
-    if (!is<HTMLInputElement>(formElement) || !is<HTMLInputElement>(element))
-        return false;
-
-    auto& thisInputElement = downcast<HTMLInputElement>(formElement);
-    auto& otherInputElement = downcast<HTMLInputElement>(element);
-
-    if (thisInputElement.isAutoFilled() != otherInputElement.isAutoFilled())
-        return false;
-    if (thisInputElement.shouldAppearChecked() != otherInputElement.shouldAppearChecked())
-        return false;
-    if (thisInputElement.isRequired() != otherInputElement.isRequired())
-        return false;
-
-    if (formElement.isDisabledFormControl() != element.isDisabledFormControl())
-        return false;
-
-    if (formElement.isInRange() != element.isInRange())
-        return false;
-
-    if (formElement.isOutOfRange() != element.isOutOfRange())
-        return false;
-
-    return true;
-}
-
 bool SharingResolver::canShareStyleWithElement(const Context& context, const StyledElement& candidateElement) const
 {
     auto& element = context.element;
@@ -255,14 +228,21 @@
     if (!candidateElementId.isNull() && m_ruleSets.features().idsInRules.contains(candidateElementId))
         return false;
 
-    bool isControl = is<HTMLFormControlElement>(candidateElement);
+    if (is<HTMLFormControlElement>(candidateElement) || is<HTMLFormControlElement>(element))
+        return false;
 
-    if (isControl != is<HTMLFormControlElement>(element))
+    // HTMLFormElement can get the :valid/invalid pseudo classes
+    if (candidateElement.matchesValidPseudoClass() != element.matchesValidPseudoClass())
         return false;
 
-    if (isControl && !canShareStyleWithControl(downcast<HTMLFormControlElement>(element), downcast<HTMLFormControlElement>(candidateElement)))
+    // HTMLProgressElement is not a HTMLFormControlElement
+    if (candidateElement.matchesIndeterminatePseudoClass() != element.matchesIndeterminatePseudoClass())
         return false;
 
+    // HTMLOptionElement is not a HTMLFormControlElement
+    if (candidateElement.matchesDefaultPseudoClass() != element.matchesDefaultPseudoClass())
+        return false;
+
     if (candidateElement.hasKeyframeEffects(PseudoId::None))
         return false;
 
@@ -297,18 +277,6 @@
             return false;
     }
 
-    if (candidateElement.matchesValidPseudoClass() != element.matchesValidPseudoClass())
-        return false;
-
-    if (element.matchesInvalidPseudoClass() != element.matchesValidPseudoClass())
-        return false;
-
-    if (candidateElement.matchesIndeterminatePseudoClass() != element.matchesIndeterminatePseudoClass())
-        return false;
-
-    if (candidateElement.matchesDefaultPseudoClass() != element.matchesDefaultPseudoClass())
-        return false;
-
     if (candidateElement.shadowRoot() && !candidateElement.shadowRoot()->styleScope().resolver().ruleSets().authorStyle().hostPseudoClassRules().isEmpty())
         return false;
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to