Changeset 275591 in webkit


Ignore:
Timestamp:
Apr 7, 2021 12:42:44 AM (3 years ago)
Author:
rniwa@webkit.org
Message:

REGRESSION(r274812): Release assert in Document::updateLayout() after calling focus({preventScroll: true}) on a textarea
https://bugs.webkit.org/show_bug.cgi?id=224262

Reviewed by Antti Koivisto.

Source/WebCore:

The regression was caused by Element::focus not updating the selection when preventScroll is set to true.
Fixed it by always updating the selection whenever Element::focus is called.

Test: fast/forms/textarea/textarea-focus-prevent-scroll-crash.html

  • dom/Element.cpp:

(WebCore::Element::focus):
(WebCore::Element::findTargetAndUpdateFocusAppearance): Renamed from revealFocusedElement.

  • dom/Element.h:
  • page/EventHandler.cpp:

(WebCore::EventHandler::dispatchMouseEvent):

LayoutTests:

Added a regression test.

  • fast/forms/textarea/textarea-focus-prevent-scroll-crash-expected.txt: Added.
  • fast/forms/textarea/textarea-focus-prevent-scroll-crash.html: Added.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r275583 r275591  
     12021-04-07  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        REGRESSION(r274812): Release assert in Document::updateLayout() after calling focus({preventScroll: true}) on a textarea
     4        https://bugs.webkit.org/show_bug.cgi?id=224262
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Added a regression test.
     9
     10        * fast/forms/textarea/textarea-focus-prevent-scroll-crash-expected.txt: Added.
     11        * fast/forms/textarea/textarea-focus-prevent-scroll-crash.html: Added.
     12
    1132021-04-06  Sihui Liu  <sihui_liu@apple.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r275590 r275591  
     12021-04-07  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        REGRESSION(r274812): Release assert in Document::updateLayout() after calling focus({preventScroll: true}) on a textarea
     4        https://bugs.webkit.org/show_bug.cgi?id=224262
     5
     6        Reviewed by Antti Koivisto.
     7
     8        The regression was caused by Element::focus not updating the selection when preventScroll is set to true.
     9        Fixed it by always updating the selection whenever Element::focus is called.
     10
     11        Test: fast/forms/textarea/textarea-focus-prevent-scroll-crash.html
     12
     13        * dom/Element.cpp:
     14        (WebCore::Element::focus):
     15        (WebCore::Element::findTargetAndUpdateFocusAppearance): Renamed from revealFocusedElement.
     16        * dom/Element.h:
     17        * page/EventHandler.cpp:
     18        (WebCore::EventHandler::dispatchMouseEvent):
     19
    1202021-04-07  Stephan Szabo  <stephan.szabo@sony.com>
    221
  • trunk/Source/WebCore/dom/Element.cpp

    r275410 r275591  
    30893089    }
    30903090
    3091     if (!options.preventScroll)
    3092         newTarget->revealFocusedElement(options.selectionRestorationMode);
    3093 }
    3094 
    3095 void Element::revealFocusedElement(SelectionRestorationMode selectionMode)
    3096 {
    3097     SelectionRevealMode revealMode = SelectionRevealMode::Reveal;
    3098 
     3091    newTarget->findTargetAndUpdateFocusAppearance(options.selectionRestorationMode, options.preventScroll ? SelectionRevealMode::DoNotReveal : SelectionRevealMode::Reveal);
     3092}
     3093
     3094void Element::findTargetAndUpdateFocusAppearance(SelectionRestorationMode selectionMode, SelectionRevealMode revealMode)
     3095{
    30993096#if PLATFORM(IOS_FAMILY)
    31003097    // Focusing a form element triggers animation in UIKit to scroll to the right position.
    31013098    // Calling updateFocusAppearance() would generate an unnecessary call to ScrollView::setScrollPosition(),
    31023099    // which would jump us around during this animation. See <rdar://problem/6699741>.
    3103     if (is<HTMLFormControlElement>(*this))
     3100    if (revealMode == SelectionRevealMode::Reveal && is<HTMLFormControlElement>(*this))
    31043101        revealMode = SelectionRevealMode::RevealUpToMainFrame;
    31053102#endif
  • trunk/Source/WebCore/dom/Element.h

    r275527 r275591  
    406406    static AXTextStateChangeIntent defaultFocusTextStateChangeIntent() { return AXTextStateChangeIntent(AXTextStateChangeTypeSelectionMove, AXTextSelection { AXTextSelectionDirectionDiscontiguous, AXTextSelectionGranularityUnknown, true }); }
    407407    virtual void focus(const FocusOptions& = { });
    408     void revealFocusedElement(SelectionRestorationMode);
     408    void findTargetAndUpdateFocusAppearance(SelectionRestorationMode, SelectionRevealMode = SelectionRevealMode::Reveal);
    409409    virtual RefPtr<Element> focusAppearanceUpdateTarget();
    410410    virtual void updateFocusAppearance(SelectionRestorationMode, SelectionRevealMode = SelectionRevealMode::Reveal);
  • trunk/Source/WebCore/page/EventHandler.cpp

    r275527 r275591  
    27242724
    27252725    if (element && m_mouseDownDelegatedFocus)
    2726         element->revealFocusedElement(SelectionRestorationMode::SelectAll);
     2726        element->findTargetAndUpdateFocusAppearance(SelectionRestorationMode::SelectAll);
    27272727
    27282728    return true;
Note: See TracChangeset for help on using the changeset viewer.