Changeset 156185 in webkit


Ignore:
Timestamp:
Sep 20, 2013 12:06:52 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

Hiding a focused element should unfocus it and fire a blur event
https://bugs.webkit.org/show_bug.cgi?id=29241

Patch by Arunprasad Rajkumar <ararunprasad@gmail.com> on 2013-09-20
Reviewed by Darin Adler.

Source/WebCore:

Test: fast/dom/HTMLDocument/active-element-gets-unfocusable.html

We check whether the current focus element is really focusable after
the style recalculation and layout change. If it is not focusable then schedule a
timer to reset it asynchronously.

  • dom/Document.cpp:

(WebCore::Document::Document):
(WebCore::Document::recalcStyle): Check isFocusable() on the focus element after
style recalculation.
(WebCore::Document::updateLayout): Check isFocusable() on the focus element after
layout.
(WebCore::Document::resetHiddenFocusElementSoon):
(WebCore::Document::resetHiddenFocusElementTimer):

  • dom/Document.h:

LayoutTests:

  • fast/dom/HTMLDocument/active-element-gets-unfocusable-expected.txt: Added.
  • fast/dom/HTMLDocument/active-element-gets-unfocusable.html: Added.

LayoutTest reused from https://chromium.googlesource.com/chromium/blink/+/c58f636fd18fc27944c42e27d6a92a36867c57e1
with little modification.

Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r156179 r156185  
     12013-09-20  Arunprasad Rajkumar  <ararunprasad@gmail.com>
     2
     3        Hiding a focused element should unfocus it and fire a blur event
     4        https://bugs.webkit.org/show_bug.cgi?id=29241
     5
     6        Reviewed by Darin Adler.
     7
     8        * fast/dom/HTMLDocument/active-element-gets-unfocusable-expected.txt: Added.
     9        * fast/dom/HTMLDocument/active-element-gets-unfocusable.html: Added.
     10
     11        LayoutTest reused from https://chromium.googlesource.com/chromium/blink/+/c58f636fd18fc27944c42e27d6a92a36867c57e1
     12        with little modification.
     13
    1142013-09-20  Alexey Proskuryakov  <ap@apple.com>
    215
  • trunk/Source/WebCore/ChangeLog

    r156183 r156185  
     12013-09-20  Arunprasad Rajkumar  <ararunprasad@gmail.com>
     2
     3        Hiding a focused element should unfocus it and fire a blur event
     4        https://bugs.webkit.org/show_bug.cgi?id=29241
     5
     6        Reviewed by Darin Adler.
     7
     8        Test: fast/dom/HTMLDocument/active-element-gets-unfocusable.html
     9
     10        We check whether the current focus element is really focusable after
     11        the style recalculation and layout change. If it is not focusable then schedule a
     12        timer to reset it asynchronously.
     13
     14        * dom/Document.cpp:
     15        (WebCore::Document::Document):
     16        (WebCore::Document::recalcStyle): Check isFocusable() on the focus element after
     17        style recalculation.
     18        (WebCore::Document::updateLayout): Check isFocusable() on the focus element after
     19        layout.
     20        (WebCore::Document::resetHiddenFocusElementSoon):
     21        (WebCore::Document::resetHiddenFocusElementTimer):
     22        * dom/Document.h:
     23
    1242013-09-20  Alexey Proskuryakov  <ap@apple.com>
    225
  • trunk/Source/WebCore/dom/Document.cpp

    r156038 r156185  
    440440    , m_markers(adoptPtr(new DocumentMarkerController))
    441441    , m_updateFocusAppearanceTimer(this, &Document::updateFocusAppearanceTimerFired)
     442    , m_resetHiddenFocusElementTimer(this, &Document::resetHiddenFocusElementTimer)
    442443    , m_cssTarget(0)
    443444    , m_processingLoadEvent(false)
     
    18281829    if (m_hoveredElement && !m_hoveredElement->renderer())
    18291830        frameView.frame().eventHandler().dispatchFakeMouseMoveEventSoon();
     1831
     1832    // Style change may reset the focus, e.g. display: none, visibility: hidden.
     1833    resetHiddenFocusElementSoon();
    18301834}
    18311835
     
    18661870    if (frameView && renderView() && (frameView->layoutPending() || renderView()->needsLayout()))
    18671871        frameView->layout();
     1872
     1873    // Active focus element's isFocusable() state may change after Layout. e.g. width: 0px or height: 0px.
     1874    resetHiddenFocusElementSoon();
    18681875}
    18691876
     
    46874694}
    46884695
     4696void Document::resetHiddenFocusElementSoon()
     4697{
     4698    if (!m_resetHiddenFocusElementTimer.isActive() && m_focusedElement && !m_focusedElement->isFocusable())
     4699        m_resetHiddenFocusElementTimer.startOneShot(0);
     4700}
     4701
    46894702void Document::updateFocusAppearanceTimerFired(Timer<Document>*)
    46904703{
     
    46964709    if (element->isFocusable())
    46974710        element->updateFocusAppearance(m_updateFocusAppearanceRestoresSelection);
     4711}
     4712
     4713void Document::resetHiddenFocusElementTimer(Timer<Document>*)
     4714{
     4715    if (m_focusedElement && !m_focusedElement->isFocusable())
     4716        setFocusedElement(0);
    46984717}
    46994718
  • trunk/Source/WebCore/dom/Document.h

    r155955 r156185  
    919919    void updateFocusAppearanceSoon(bool restorePreviousSelection);
    920920    void cancelFocusAppearanceUpdate();
    921        
     921
     922    void resetHiddenFocusElementSoon();
     923
    922924    // Extension for manipulating canvas drawing contexts for use in CSS
    923925    CanvasRenderingContext* getCSSCanvasContext(const String& type, const String& name, int width, int height);
     
    12261228    void updateBaseURL();
    12271229
     1230    void resetHiddenFocusElementTimer(Timer<Document>*);
     1231
    12281232    void buildAccessKeyMap(TreeScope* root);
    12291233
     
    13771381   
    13781382    Timer<Document> m_updateFocusAppearanceTimer;
     1383    Timer<Document> m_resetHiddenFocusElementTimer;
    13791384
    13801385    Element* m_cssTarget;
Note: See TracChangeset for help on using the changeset viewer.