⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 239786 in webkit


Ignore:
Timestamp:
Jan 9, 2019, 2:25:41 PM (8 years ago)
Author:
Alan Bujtas
Message:

[Datalist] Crash when input with datalist is dynamically added.
​https://bugs.webkit.org/show_bug.cgi?id=193012
<rdar://problem/45923457>

Reviewed by Brent Fulgham.

Source/WebCore:

In certain cases (cloning, setAttribute), it's too early to check for the list attribute in createShadowSubtree
to see whether the input needs datalist related items. The list attribute is simply not set yet.
This patch only addresses the obvious crash. m_dataListDropdownIndicator clearly lacks proper lifecycle management (see webkit.org/b/193032).

Test: fast/forms/datalist/datalist-crash-when-dynamic.html

  • html/TextFieldInputType.cpp:

(WebCore::TextFieldInputType::createShadowSubtree):
(WebCore::TextFieldInputType::attributeChanged):
(WebCore::TextFieldInputType::createDataListDropdownIndicator):

  • html/TextFieldInputType.h:

LayoutTests:

  • fast/forms/datalist/datalist-crash-when-dynamic-expected.txt: Added.
  • fast/forms/datalist/datalist-crash-when-dynamic.html: Added.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r239780 r239786  
     12019-01-09  Zalan Bujtas  <zalan@apple.com>
     2
     3        [Datalist] Crash when input with datalist is dynamically added.
     4        https://bugs.webkit.org/show_bug.cgi?id=193012
     5        <rdar://problem/45923457>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        * fast/forms/datalist/datalist-crash-when-dynamic-expected.txt: Added.
     10        * fast/forms/datalist/datalist-crash-when-dynamic.html: Added.
     11
    1122019-01-09  Justin Fan  <justin_fan@apple.com>
    213
  • trunk/Source/WebCore/ChangeLog

    r239780 r239786  
     12019-01-09  Zalan Bujtas  <zalan@apple.com>
     2
     3        [Datalist] Crash when input with datalist is dynamically added.
     4        https://bugs.webkit.org/show_bug.cgi?id=193012
     5        <rdar://problem/45923457>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        In certain cases (cloning, setAttribute), it's too early to check for the list attribute in createShadowSubtree
     10        to see whether the input needs datalist related items. The list attribute is simply not set yet.
     11        This patch only addresses the obvious crash. m_dataListDropdownIndicator clearly lacks proper lifecycle management (see webkit.org/b/193032).
     12
     13        Test: fast/forms/datalist/datalist-crash-when-dynamic.html
     14
     15        * html/TextFieldInputType.cpp:
     16        (WebCore::TextFieldInputType::createShadowSubtree):
     17        (WebCore::TextFieldInputType::attributeChanged):
     18        (WebCore::TextFieldInputType::createDataListDropdownIndicator):
     19        * html/TextFieldInputType.h:
     20
    1212019-01-09  Justin Fan  <justin_fan@apple.com>
    222
  • trunk/Source/WebCore/html/TextFieldInputType.cpp

    r239337 r239786  
    300300bool TextFieldInputType::needsContainer() const
    301301{
    302 #if ENABLE(DATALIST_ELEMENT)
    303     return element()->hasAttributeWithoutSynchronization(listAttr);
    304 #endif
    305302    return false;
    306303}
    … …  
    359356        m_container->appendChild(*m_capsLockIndicator);
    360357    }
    361 
    362358    updateAutoFillButton();
    363 
    364 #if ENABLE(DATALIST_ELEMENT)
    365     m_dataListDropdownIndicator = DataListButtonElement::create(element()->document(), *this);
    366     m_dataListDropdownIndicator->setInlineStyleProperty(CSSPropertyDisplay, CSSValueNone, true);
    367     m_container->appendChild(*m_dataListDropdownIndicator);
    368 #endif
    369359}
    370360
    … …  
    456446    return true;
    457447}
     448
     449#if ENABLE(DATALIST_ELEMENT)
     450void TextFieldInputType::createDataListDropdownIndicator()
     451{
     452    ASSERT(!m_dataListDropdownIndicator);
     453    if (!m_container)
     454        createContainer();
     455    m_dataListDropdownIndicator = DataListButtonElement::create(element()->document(), *this);
     456    m_dataListDropdownIndicator->setInlineStyleProperty(CSSPropertyDisplay, CSSValueNone, true);
     457    m_container->appendChild(*m_dataListDropdownIndicator);
     458}
     459#endif
    458460
    459461// FIXME: The name of this function doesn't make clear the two jobs it does:
    … …  
    833835
    834836    if (!m_dataListDropdownIndicator)
    835         return;
     837        createDataListDropdownIndicator();
    836838
    837839#if !PLATFORM(IOS_FAMILY)
  • trunk/Source/WebCore/html/TextFieldInputType.h

    r235490 r239786  
    125125
    126126#if ENABLE(DATALIST_ELEMENT)
     127    void createDataListDropdownIndicator();
    127128    bool isPresentingAttachedView() const final;
    128129    void listAttributeTargetChanged() final;
  • trunk/Source/WebCore/rendering/RenderThemeMac.mm

    r239604 r239786  
    11461146
    11471147    [listButton setHighlighted:input.isPresentingAttachedView()];
    1148     if (!input.isPresentingAttachedView())
    1149         updatePressedState(listButton, *(input.dataListButtonElement()->renderer()));
     1148    if (!input.isPresentingAttachedView()) {
     1149        ASSERT(input.dataListButtonElement());
     1150        if (auto* buttonElement = input.dataListButtonElement())
     1151            updatePressedState(listButton, *buttonElement->renderer());
     1152    }
    11501153
    11511154    [listButton drawWithFrame:listButtonFrame inView:documentViewFor(o)];
Note: See TracChangeset for help on using the changeset viewer.