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

Changeset 154308 in webkit


Ignore:
Timestamp:
Aug 19, 2013, 5:02:56 PM (13 years ago)
Author:
rniwa@webkit.org
Message:

<​https://webkit.org/b/119930> input[type=range]: Fix a crash by changing input type in 'input' event handler

Reviewed by Kent Tamura.

Source/WebCore:

Merge ​https://chromium.googlesource.com/chromium/blink/+/99afc9b55ce176b4f5fe053070e19dbebc1891a5

In SliderThumbElement::setPositionFromPoint, renderer() can be NULL after HTMLInputElement::setValueFromRenderer,
which dispatches 'input' event. Also, make a local vairable 'input' a RefPtr just in case.

Also add null-poinetr checks for the host element as SliderThumbElement only weakly holds onto the host element.

Test: fast/forms/range/range-type-change-oninput.html

  • html/shadow/SliderThumbElement.cpp:

(WebCore::SliderThumbElement::isDisabledFormControl):
(WebCore::SliderThumbElement::matchesReadOnlyPseudoClass):
(WebCore::SliderThumbElement::matchesReadWritePseudoClass):
(WebCore::SliderThumbElement::setPositionFromPoint):
(WebCore::SliderThumbElement::hostInput):

LayoutTests:

Add a regresion test from ​https://chromium.googlesource.com/chromium/blink/+/99afc9b55ce176b4f5fe053070e19dbebc1891a5

  • fast/forms/range/range-type-change-oninput-expected.txt: Added.
  • fast/forms/range/range-type-change-oninput.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r154306 r154308  
     12013-08-19  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        <https://webkit.org/b/119930> input[type=range]: Fix a crash by changing input type in 'input' event handler
     4
     5        Reviewed by Kent Tamura.
     6
     7        Add a regresion test from https://chromium.googlesource.com/chromium/blink/+/99afc9b55ce176b4f5fe053070e19dbebc1891a5
     8
     9        * fast/forms/range/range-type-change-oninput-expected.txt: Added.
     10        * fast/forms/range/range-type-change-oninput.html: Added.
     11
    1122013-08-19  Alexey Proskuryakov  <ap@apple.com>
    213
  • trunk/Source/WebCore/ChangeLog

    r154306 r154308  
     12013-08-19  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        <https://webkit.org/b/119930> input[type=range]: Fix a crash by changing input type in 'input' event handler
     4
     5        Reviewed by Kent Tamura.
     6
     7        Merge https://chromium.googlesource.com/chromium/blink/+/99afc9b55ce176b4f5fe053070e19dbebc1891a5
     8
     9        In SliderThumbElement::setPositionFromPoint, renderer() can be NULL after HTMLInputElement::setValueFromRenderer,
     10        which dispatches 'input' event. Also, make a local vairable 'input' a RefPtr just in case.
     11
     12        Also add null-poinetr checks for the host element as SliderThumbElement only weakly holds onto the host element.
     13
     14        Test: fast/forms/range/range-type-change-oninput.html
     15
     16        * html/shadow/SliderThumbElement.cpp:
     17        (WebCore::SliderThumbElement::isDisabledFormControl):
     18        (WebCore::SliderThumbElement::matchesReadOnlyPseudoClass):
     19        (WebCore::SliderThumbElement::matchesReadWritePseudoClass):
     20        (WebCore::SliderThumbElement::setPositionFromPoint):
     21        (WebCore::SliderThumbElement::hostInput):
     22
    1232013-08-19  Alexey Proskuryakov  <ap@apple.com>
    224
  • trunk/Source/WebCore/html/shadow/SliderThumbElement.cpp

    r154254 r154308  
    230230bool SliderThumbElement::isDisabledFormControl() const
    231231{
    232     return hostInput()->isDisabledFormControl();
     232    HTMLInputElement* input = hostInput();
     233    return !input || input->isDisabledFormControl();
    233234}
    234235
    235236bool SliderThumbElement::matchesReadOnlyPseudoClass() const
    236237{
    237     return hostInput()->matchesReadOnlyPseudoClass();
     238    HTMLInputElement* input = hostInput();
     239    return input && input->matchesReadOnlyPseudoClass();
    238240}
    239241
    240242bool SliderThumbElement::matchesReadWritePseudoClass() const
    241243{
    242     return hostInput()->matchesReadWritePseudoClass();
     244    HTMLInputElement* input = hostInput();
     245    return input && input->matchesReadWritePseudoClass();
    243246}
    244247
    … …  
    256259void SliderThumbElement::setPositionFromPoint(const LayoutPoint& point)
    257260{
    258     HTMLInputElement* input = hostInput();
    259     HTMLElement* trackElement = sliderTrackElementOf(input);
     261    RefPtr<HTMLInputElement> input(hostInput());
     262    HTMLElement* trackElement = sliderTrackElementOf(input.get());
    260263
    261264    if (!input->renderer() || !renderBox() || !trackElement->renderBox())
    … …  
    264267    input->setTextAsOfLastFormControlChangeEvent(input->value());
    265268    LayoutPoint offset = roundedLayoutPoint(input->renderer()->absoluteToLocal(point, UseTransforms));
    266     bool isVertical = hasVerticalAppearance(input);
     269    bool isVertical = hasVerticalAppearance(input.get());
    267270    bool isLeftToRightDirection = renderBox()->style()->isLeftToRightDirection();
    268271    LayoutUnit trackSize;
    … …  
    313316    // FIXME: This is no longer being set from renderer. Consider updating the method name.
    314317    input->setValueFromRenderer(valueString);
    315     renderer()->setNeedsLayout(true);
     318    if (renderer())
     319        renderer()->setNeedsLayout(true);
    316320    input->dispatchFormControlChangeEvent();
    317321}
    … …  
    405409    // Only HTMLInputElement creates SliderThumbElement instances as its shadow nodes.
    406410    // So, shadowHost() must be an HTMLInputElement.
    407     return shadowHost()->toInputElement();
     411    Element* host = shadowHost();
     412    return host ? host->toInputElement() : 0;
    408413}
    409414
Note: See TracChangeset for help on using the changeset viewer.