Changeset 156252 in webkit


Ignore:
Timestamp:
Sep 22, 2013 4:19:14 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-22
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

    r156244 r156252  
     12013-09-22  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-22  Darin Adler  <darin@apple.com>
    215
  • trunk/Source/WebCore/ChangeLog

    r156251 r156252  
     12013-09-22  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-22  Sam Weinig  <sam@webkit.org>
    225
  • trunk/Source/WebCore/dom/Document.cpp

    r156231 r156252  
    441441    , m_markers(adoptPtr(new DocumentMarkerController))
    442442    , m_updateFocusAppearanceTimer(this, &Document::updateFocusAppearanceTimerFired)
     443    , m_resetHiddenFocusElementTimer(this, &Document::resetHiddenFocusElementTimer)
    443444    , m_cssTarget(0)
    444445    , m_processingLoadEvent(false)
     
    18291830    if (m_hoveredElement && !m_hoveredElement->renderer())
    18301831        frameView.frame().eventHandler().dispatchFakeMouseMoveEventSoon();
     1832
     1833    // Style change may reset the focus, e.g. display: none, visibility: hidden.
     1834    resetHiddenFocusElementSoon();
    18311835}
    18321836
     
    18671871    if (frameView && renderView() && (frameView->layoutPending() || renderView()->needsLayout()))
    18681872        frameView->layout();
     1873
     1874    // Active focus element's isFocusable() state may change after Layout. e.g. width: 0px or height: 0px.
     1875    resetHiddenFocusElementSoon();
    18691876}
    18701877
     
    46914698}
    46924699
     4700void Document::resetHiddenFocusElementSoon()
     4701{
     4702    if (!m_resetHiddenFocusElementTimer.isActive() && m_focusedElement)
     4703        m_resetHiddenFocusElementTimer.startOneShot(0);
     4704}
     4705
    46934706void Document::updateFocusAppearanceTimerFired(Timer<Document>*)
    46944707{
     
    47004713    if (element->isFocusable())
    47014714        element->updateFocusAppearance(m_updateFocusAppearanceRestoresSelection);
     4715}
     4716
     4717void Document::resetHiddenFocusElementTimer(Timer<Document>*)
     4718{
     4719    if (view() && view()->needsLayout())
     4720        return;
     4721
     4722    if (m_focusedElement && !m_focusedElement->isFocusable())
     4723        setFocusedElement(0);
    47024724}
    47034725
  • trunk/Source/WebCore/dom/Document.h

    r156234 r156252  
    920920    void updateFocusAppearanceSoon(bool restorePreviousSelection);
    921921    void cancelFocusAppearanceUpdate();
    922        
     922
     923    void resetHiddenFocusElementSoon();
     924
    923925    // Extension for manipulating canvas drawing contexts for use in CSS
    924926    CanvasRenderingContext* getCSSCanvasContext(const String& type, const String& name, int width, int height);
     
    12271229    void updateBaseURL();
    12281230
     1231    void resetHiddenFocusElementTimer(Timer<Document>*);
     1232
    12291233    void buildAccessKeyMap(TreeScope* root);
    12301234
     
    13781382   
    13791383    Timer<Document> m_updateFocusAppearanceTimer;
     1384    Timer<Document> m_resetHiddenFocusElementTimer;
    13801385
    13811386    Element* m_cssTarget;
Note: See TracChangeset for help on using the changeset viewer.