Title: [259375] trunk/Source/WebCore
Revision
259375
Author
wenson_hs...@apple.com
Date
2020-04-01 17:35:02 -0700 (Wed, 01 Apr 2020)

Log Message

Remove some PLATFORM(IOS_FAMILY) guards in TextFieldInputType
https://bugs.webkit.org/show_bug.cgi?id=209883

Reviewed by Darin Adler.

Refactor what is currently a compile-time IOS_FAMILY guard into a runtime check behind a private helper method
on TextFieldInputType. This makes the intention behind the iOS-specific logic more self-evident; no change in
behavior.

* html/TextFieldInputType.cpp:
(WebCore::TextFieldInputType::handleFocusEvent):
(WebCore::TextFieldInputType::handleBlurEvent):
(WebCore::TextFieldInputType::createDataListDropdownIndicator):
(WebCore::TextFieldInputType::shouldOnlyShowDataListDropdownButtonWhenFocusedOrEdited const):
(WebCore::TextFieldInputType::didSetValueByUserEdit):
(WebCore::TextFieldInputType::listAttributeTargetChanged):
* html/TextFieldInputType.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (259374 => 259375)


--- trunk/Source/WebCore/ChangeLog	2020-04-02 00:19:56 UTC (rev 259374)
+++ trunk/Source/WebCore/ChangeLog	2020-04-02 00:35:02 UTC (rev 259375)
@@ -1,3 +1,23 @@
+2020-04-01  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        Remove some PLATFORM(IOS_FAMILY) guards in TextFieldInputType
+        https://bugs.webkit.org/show_bug.cgi?id=209883
+
+        Reviewed by Darin Adler.
+
+        Refactor what is currently a compile-time IOS_FAMILY guard into a runtime check behind a private helper method
+        on TextFieldInputType. This makes the intention behind the iOS-specific logic more self-evident; no change in
+        behavior.
+
+        * html/TextFieldInputType.cpp:
+        (WebCore::TextFieldInputType::handleFocusEvent):
+        (WebCore::TextFieldInputType::handleBlurEvent):
+        (WebCore::TextFieldInputType::createDataListDropdownIndicator):
+        (WebCore::TextFieldInputType::shouldOnlyShowDataListDropdownButtonWhenFocusedOrEdited const):
+        (WebCore::TextFieldInputType::didSetValueByUserEdit):
+        (WebCore::TextFieldInputType::listAttributeTargetChanged):
+        * html/TextFieldInputType.h:
+
 2020-04-01  Per Arne Vollan  <pvol...@apple.com>
 
         [Cocoa] UTI from MIME type cache can be removed after r258915

Modified: trunk/Source/WebCore/html/TextFieldInputType.cpp (259374 => 259375)


--- trunk/Source/WebCore/html/TextFieldInputType.cpp	2020-04-02 00:19:56 UTC (rev 259374)
+++ trunk/Source/WebCore/html/TextFieldInputType.cpp	2020-04-02 00:35:02 UTC (rev 259375)
@@ -268,8 +268,8 @@
     ASSERT_UNUSED(oldFocusedNode, oldFocusedNode != element());
     if (RefPtr<Frame> frame = element()->document().frame()) {
         frame->editor().textFieldDidBeginEditing(element());
-#if ENABLE(DATALIST_ELEMENT) && PLATFORM(IOS_FAMILY)
-        if (element()->list() && m_dataListDropdownIndicator)
+#if ENABLE(DATALIST_ELEMENT)
+        if (shouldOnlyShowDataListDropdownButtonWhenFocusedOrEdited() && element()->list() && m_dataListDropdownIndicator)
             m_dataListDropdownIndicator->setInlineStyleProperty(CSSPropertyDisplay, suggestions().size() ? CSSValueBlock : CSSValueNone, true);
 #endif
     }
@@ -280,8 +280,8 @@
     InputType::handleBlurEvent();
     ASSERT(element());
     element()->endEditing();
-#if ENABLE(DATALIST_ELEMENT) && PLATFORM(IOS_FAMILY)
-    if (element()->list() && m_dataListDropdownIndicator)
+#if ENABLE(DATALIST_ELEMENT)
+    if (shouldOnlyShowDataListDropdownButtonWhenFocusedOrEdited() && element()->list() && m_dataListDropdownIndicator)
         m_dataListDropdownIndicator->setInlineStyleProperty(CSSPropertyDisplay, CSSValueNone, true);
 #endif
 }
@@ -448,6 +448,7 @@
 }
 
 #if ENABLE(DATALIST_ELEMENT)
+
 void TextFieldInputType::createDataListDropdownIndicator()
 {
     ASSERT(!m_dataListDropdownIndicator);
@@ -459,10 +460,19 @@
     m_container->appendChild(*m_dataListDropdownIndicator);
     m_dataListDropdownIndicator->setPseudo(AtomString("-webkit-list-button", AtomString::ConstructFromLiteral));
     m_dataListDropdownIndicator->setInlineStyleProperty(CSSPropertyDisplay, CSSValueNone, true);
+}
 
+bool TextFieldInputType::shouldOnlyShowDataListDropdownButtonWhenFocusedOrEdited()
+{
+#if PLATFORM(IOS_FAMILY)
+    return true;
+#else
+    return false;
+#endif
 }
-#endif
 
+#endif // ENABLE(DATALIST_ELEMENT)
+
 static String limitLength(const String& string, unsigned maxNumGraphemeClusters)
 {
     StringView stringView { string };
@@ -667,10 +677,9 @@
     if (RefPtr<Frame> frame = element()->document().frame())
         frame->editor().textDidChangeInTextField(element());
 #if ENABLE(DATALIST_ELEMENT)
-#if PLATFORM(IOS_FAMILY)
-    if (element()->list() && m_dataListDropdownIndicator)
+    if (shouldOnlyShowDataListDropdownButtonWhenFocusedOrEdited() && element()->list() && m_dataListDropdownIndicator)
         m_dataListDropdownIndicator->setInlineStyleProperty(CSSPropertyDisplay, suggestions().size() ? CSSValueBlock : CSSValueNone, true);
-#endif
+
     if (element()->list())
         displaySuggestions(DataListSuggestionActivationType::TextChanged);
 #endif
@@ -833,9 +842,8 @@
     if (!m_dataListDropdownIndicator)
         createDataListDropdownIndicator();
 
-#if !PLATFORM(IOS_FAMILY)
-    m_dataListDropdownIndicator->setInlineStyleProperty(CSSPropertyDisplay, element()->list() ? CSSValueBlock : CSSValueNone, true);
-#endif
+    if (!shouldOnlyShowDataListDropdownButtonWhenFocusedOrEdited())
+        m_dataListDropdownIndicator->setInlineStyleProperty(CSSPropertyDisplay, element()->list() ? CSSValueBlock : CSSValueNone, true);
 }
 
 HTMLElement* TextFieldInputType::dataListButtonElement() const

Modified: trunk/Source/WebCore/html/TextFieldInputType.h (259374 => 259375)


--- trunk/Source/WebCore/html/TextFieldInputType.h	2020-04-02 00:19:56 UTC (rev 259374)
+++ trunk/Source/WebCore/html/TextFieldInputType.h	2020-04-02 00:35:02 UTC (rev 259375)
@@ -136,6 +136,8 @@
     void didSelectDataListOption(const String&) final;
     void didCloseSuggestions() final;
 
+    static bool shouldOnlyShowDataListDropdownButtonWhenFocusedOrEdited();
+
     void dataListButtonElementWasClicked() final;
     RefPtr<DataListButtonElement> m_dataListDropdownIndicator;
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to