Title: [292523] trunk
Revision
292523
Author
n...@apple.com
Date
2022-04-06 21:29:06 -0700 (Wed, 06 Apr 2022)

Log Message

[:has() pseudo-class] Support invalidation for :placeholder-shown
https://bugs.webkit.org/show_bug.cgi?id=238894

Reviewed by Simon Fraser.

LayoutTests/imported/w3c:

* web-platform-tests/css/selectors/invalidation/input-pseudo-classes-in-has-expected.txt:

Source/WebCore:

Test: imported/w3c/web-platform-tests/css/selectors/invalidation/input-pseudo-classes-in-has.html

Use same pattern as other input pseudo classes.

* html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::updatePlaceholderVisibility):

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (292522 => 292523)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2022-04-07 02:44:11 UTC (rev 292522)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2022-04-07 04:29:06 UTC (rev 292523)
@@ -1,3 +1,12 @@
+2022-04-06  Tim Nguyen  <n...@apple.com>
+
+        [:has() pseudo-class] Support invalidation for :placeholder-shown
+        https://bugs.webkit.org/show_bug.cgi?id=238894
+
+        Reviewed by Simon Fraser.
+
+        * web-platform-tests/css/selectors/invalidation/input-pseudo-classes-in-has-expected.txt:
+
 2022-04-06  Oriol Brufau  <obru...@igalia.com>
 
         [css] Turn -webkit-border-image into a shorthand

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/input-pseudo-classes-in-has-expected.txt (292522 => 292523)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/input-pseudo-classes-in-has-expected.txt	2022-04-07 02:44:11 UTC (rev 292522)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/input-pseudo-classes-in-has-expected.txt	2022-04-07 04:29:06 UTC (rev 292523)
@@ -7,5 +7,5 @@
 FAIL :default invalidation with input[type=radio] assert_equals: ancestor should be lightblue expected "rgb(173, 216, 230)" but got "rgb(0, 0, 0)"
 PASS :required invalidation
 FAIL :out-of-range invalidation assert_equals: ancestor should be darkgreen expected "rgb(0, 100, 0)" but got "rgb(0, 0, 0)"
-FAIL :placeholder-shown invalidation assert_equals: ancestor should be navy expected "rgb(0, 0, 128)" but got "rgb(0, 0, 0)"
+PASS :placeholder-shown invalidation
 

Modified: trunk/Source/WebCore/ChangeLog (292522 => 292523)


--- trunk/Source/WebCore/ChangeLog	2022-04-07 02:44:11 UTC (rev 292522)
+++ trunk/Source/WebCore/ChangeLog	2022-04-07 04:29:06 UTC (rev 292523)
@@ -1,3 +1,17 @@
+2022-04-06  Tim Nguyen  <n...@apple.com>
+
+        [:has() pseudo-class] Support invalidation for :placeholder-shown
+        https://bugs.webkit.org/show_bug.cgi?id=238894
+
+        Reviewed by Simon Fraser.
+
+        Test: imported/w3c/web-platform-tests/css/selectors/invalidation/input-pseudo-classes-in-has.html
+
+        Use same pattern as other input pseudo classes.
+
+        * html/HTMLTextFormControlElement.cpp:
+        (WebCore::HTMLTextFormControlElement::updatePlaceholderVisibility):
+
 2022-04-06  Myles C. Maxfield  <mmaxfi...@apple.com>
 
         NBSP characters drawn in fonts that don't support the space character turn into boxes

Modified: trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp (292522 => 292523)


--- trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp	2022-04-07 02:44:11 UTC (rev 292522)
+++ trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp	2022-04-07 04:29:06 UTC (rev 292523)
@@ -49,6 +49,7 @@
 #include "Logging.h"
 #include "NodeTraversal.h"
 #include "Page.h"
+#include "PseudoClassChangeInvalidation.h"
 #include "RenderLineBreak.h"
 #include "RenderTextControlSingleLine.h"
 #include "RenderTheme.h"
@@ -183,13 +184,15 @@
 
 void HTMLTextFormControlElement::updatePlaceholderVisibility()
 {
-    bool placeHolderWasVisible = m_isPlaceholderVisible;
-    m_isPlaceholderVisible = placeholderShouldBeVisible();
-
-    if (placeHolderWasVisible == m_isPlaceholderVisible)
+    bool newIsPlaceholderVisible = placeholderShouldBeVisible();
+    if (m_isPlaceholderVisible == newIsPlaceholderVisible)
         return;
 
-    invalidateStyleForSubtree();
+    Style::PseudoClassChangeInvalidation styleInvalidation(*this, CSSSelector::PseudoClassPlaceholderShown, newIsPlaceholderVisible);
+    m_isPlaceholderVisible = newIsPlaceholderVisible;
+
+    if (RefPtr placeholder = placeholderElement())
+        placeholder->invalidateStyle();
 }
 
 void HTMLTextFormControlElement::setCanShowPlaceholder(bool canShowPlaceholder)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to