Title: [294613] trunk
- Revision
- 294613
- Author
- an...@apple.com
- Date
- 2022-05-21 08:15:06 -0700 (Sat, 21 May 2022)
Log Message
Support invalidation for :in-range/:out-of-range
https://bugs.webkit.org/show_bug.cgi?id=238902
<rdar://91718746>
Reviewed by Alan Bujtas.
* LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/input-pseudo-classes-in-has-expected.txt:
* Source/WebCore/html/InputType.cpp:
(WebCore::InputType::setValue):
No need to invalidate style unconditionally on value change anymore.
Use Style::PseudoClassChangeInvalidation for :in-range invalidation.
* Source/WebCore/html/SearchInputType.cpp:
(WebCore::SearchInputType::setValue):
Search cancel button style depends on emptiness of the value so invalidate that specifically.
* Source/WebCore/html/SearchInputType.h:
Canonical link: https://commits.webkit.org/250839@main
Modified Paths
Diff
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/input-pseudo-classes-in-has-expected.txt (294612 => 294613)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/input-pseudo-classes-in-has-expected.txt 2022-05-21 12:38:30 UTC (rev 294612)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/input-pseudo-classes-in-has-expected.txt 2022-05-21 15:15:06 UTC (rev 294613)
@@ -7,6 +7,6 @@
PASS :valid invalidation
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)"
+PASS :out-of-range invalidation
PASS :placeholder-shown invalidation
Modified: trunk/Source/WebCore/html/InputType.cpp (294612 => 294613)
--- trunk/Source/WebCore/html/InputType.cpp 2022-05-21 12:38:30 UTC (rev 294612)
+++ trunk/Source/WebCore/html/InputType.cpp 2022-05-21 15:15:06 UTC (rev 294613)
@@ -59,6 +59,7 @@
#include "NumberInputType.h"
#include "Page.h"
#include "PasswordInputType.h"
+#include "PseudoClassChangeInvalidation.h"
#include "RadioInputType.h"
#include "RangeInputType.h"
#include "RenderElement.h"
@@ -794,11 +795,26 @@
void InputType::setValue(const String& sanitizedValue, bool valueChanged, TextFieldEventBehavior eventBehavior, TextControlSetValueSelection)
{
ASSERT(element());
- element()->setValueInternal(sanitizedValue, eventBehavior);
- if (!valueChanged)
+ if (!valueChanged) {
+ element()->setValueInternal(sanitizedValue, eventBehavior);
return;
- element()->invalidateStyleForSubtree();
+ }
+ bool wasInRange = isInRange(element()->value());
+ bool inRange = isInRange(sanitizedValue);
+
+ bool dummy;
+ auto oldDirection = element()->directionalityIfhasDirAutoAttribute(dummy);
+
+ std::optional<Style::PseudoClassChangeInvalidation> styleInvalidation;
+ if (wasInRange != inRange)
+ emplace(styleInvalidation, *element(), { { CSSSelector::PseudoClassInRange, inRange }, { CSSSelector::PseudoClassOutOfRange, !inRange } });
+
+ element()->setValueInternal(sanitizedValue, eventBehavior);
+
+ if (oldDirection != element()->directionalityIfhasDirAutoAttribute(dummy))
+ element()->invalidateStyleInternal();
+
switch (eventBehavior) {
case DispatchChangeEvent:
element()->dispatchFormControlChangeEvent();
Modified: trunk/Source/WebCore/html/SearchInputType.cpp (294612 => 294613)
--- trunk/Source/WebCore/html/SearchInputType.cpp 2022-05-21 12:38:30 UTC (rev 294612)
+++ trunk/Source/WebCore/html/SearchInputType.cpp 2022-05-21 15:15:06 UTC (rev 294613)
@@ -219,4 +219,14 @@
return width;
}
+void SearchInputType::setValue(const String& sanitizedValue, bool valueChanged, TextFieldEventBehavior eventBehavior, TextControlSetValueSelection selection)
+{
+ bool emptinessChanged = valueChanged && sanitizedValue.isEmpty() != element()->value().isEmpty();
+
+ BaseTextInputType::setValue(sanitizedValue, valueChanged, eventBehavior, selection);
+
+ if (m_cancelButton && emptinessChanged)
+ m_cancelButton->invalidateStyleInternal();
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/html/SearchInputType.h (294612 => 294613)
--- trunk/Source/WebCore/html/SearchInputType.h 2022-05-21 12:38:30 UTC (rev 294612)
+++ trunk/Source/WebCore/html/SearchInputType.h 2022-05-21 15:15:06 UTC (rev 294613)
@@ -59,6 +59,7 @@
void didSetValueByUserEdit() final;
bool sizeShouldIncludeDecoration(int defaultSize, int& preferredSize) const final;
float decorationWidth() const final;
+ void setValue(const String&, bool valueChanged, TextFieldEventBehavior, TextControlSetValueSelection) final;
void searchEventTimerFired();
bool searchEventsShouldBeDispatched() const;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes