Changeset 208745 in webkit


Ignore:
Timestamp:
Nov 15, 2016 12:14:02 PM (7 years ago)
Author:
Brent Fulgham
Message:

Correct handling of changing input type
https://bugs.webkit.org/show_bug.cgi?id=164759
<rdar://problem/29211174>

Reviewed by Darin Adler.

Source/WebCore:

Test: fast/forms/search-cancel-button-change-input.html

It is possible for JavaScript to change the type property of an input field. WebKit
needs to gracefully handle this case.

Add a type traits specialization so we can properly downcast InputType elements.
Use this to only call search functions on actual search input types.

  • html/HTMLInputElement.cpp:

(WebCore::HTMLInputElement::onSearch): Only perform search functions if the
input type is actually a search field.

  • html/InputType.h: Add type traits specialization for 'downcast' template.
  • html/SearchInputType.h: Ditto.

LayoutTests:

  • fast/forms/search-cancel-button-change-input-expected.txt: Added.
  • fast/forms/search-cancel-button-change-input.html: Added.
Location:
trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r208743 r208745  
     12016-11-14  Brent Fulgham  <bfulgham@apple.com>
     2
     3        Correct handling of changing input type
     4        https://bugs.webkit.org/show_bug.cgi?id=164759
     5        <rdar://problem/29211174>
     6
     7        Reviewed by Darin Adler.
     8
     9        * fast/forms/search-cancel-button-change-input-expected.txt: Added.
     10        * fast/forms/search-cancel-button-change-input.html: Added.
     11
    1122016-11-15  Antti Koivisto  <antti@apple.com>
    213
  • trunk/Source/WebCore/ChangeLog

    r208744 r208745  
     12016-11-14  Brent Fulgham  <bfulgham@apple.com>
     2
     3        Correct handling of changing input type
     4        https://bugs.webkit.org/show_bug.cgi?id=164759
     5        <rdar://problem/29211174>
     6
     7        Reviewed by Darin Adler.
     8
     9        Test: fast/forms/search-cancel-button-change-input.html
     10
     11        It is possible for JavaScript to change the type property of an input field. WebKit
     12        needs to gracefully handle this case.
     13
     14        Add a type traits specialization so we can properly downcast InputType elements.
     15        Use this to only call search functions on actual search input types.
     16
     17        * html/HTMLInputElement.cpp:
     18        (WebCore::HTMLInputElement::onSearch): Only perform search functions if the
     19        input type is actually a search field.
     20        * html/InputType.h: Add type traits specialization for 'downcast' template.
     21        * html/SearchInputType.h: Ditto.
     22
    1232016-11-15  Zalan Bujtas  <zalan@apple.com>
    224
  • trunk/Source/WebCore/WebCore.order

    r198074 r208745  
    58355835__ZN7WebCore17MarkupAccumulator13appendOpenTagERN3WTF13StringBuilderEPNS_7ElementEPNS1_7HashMapIPNS1_16AtomicStringImplES8_NS1_7PtrHashIS8_EENS1_10HashTraitsIS8_EESC_EE
    58365836__ZNK7WebCore7Element22nodeNamePreservingCaseEv
    5837 __ZNK7WebCore13QualifiedName8toStringEv
    58385837__ZNK7WebCore7Element13hasAttributesEv
    58395838__ZN7WebCore17MarkupAccumulator22appendCustomAttributesERN3WTF13StringBuilderEPNS_7ElementEPNS1_7HashMapIPNS1_16AtomicStringImplES8_NS1_7PtrHashIS8_EENS1_10HashTraitsIS8_EESC_EE
  • trunk/Source/WebCore/html/HTMLInputElement.cpp

    r208653 r208745  
    14601460void HTMLInputElement::onSearch()
    14611461{
    1462     ASSERT(isSearchField());
     1462    // The type of the input element could have changed during event handling. If we are no longer
     1463    // a search field, don't try to do search things.
     1464    if (!isSearchField())
     1465        return;
     1466
    14631467    if (m_inputType)
    1464         static_cast<SearchInputType*>(m_inputType.get())->stopSearchEventTimer();
     1468        downcast<SearchInputType>(*m_inputType.get()).stopSearchEventTimer();
    14651469    dispatchEvent(Event::create(eventNames().searchEvent, true, false));
    14661470}
  • trunk/Source/WebCore/html/InputType.h

    r208659 r208745  
    323323
    324324} // namespace WebCore
     325
     326#define SPECIALIZE_TYPE_TRAITS_INPUT_TYPE(ToValueTypeName, predicate) \
     327SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToValueTypeName) \
     328static bool isType(const WebCore::InputType& input) { return input.predicate; } \
     329SPECIALIZE_TYPE_TRAITS_END()
  • trunk/Source/WebCore/html/SearchInputType.h

    r208179 r208745  
    7171
    7272} // namespace WebCore
     73
     74SPECIALIZE_TYPE_TRAITS_INPUT_TYPE(SearchInputType, isSearchField())
Note: See TracChangeset for help on using the changeset viewer.