Changeset 48257 in webkit


Ignore:
Timestamp:
Sep 10, 2009 10:03:51 AM (15 years ago)
Author:
eric@webkit.org
Message:

2009-09-10 Erik Arvidsson <arv@chromium.org>

Reviewed by Eric Seidel.

Fixes issue where focused elements did not get blur and focus events when the window was blurred and focused.
https://bugs.webkit.org/show_bug.cgi?id=27105

  • fast/events/blur-focus-window-should-blur-focus-element-expected.txt: Added.
  • fast/events/blur-focus-window-should-blur-focus-element.html: Added.
  • fast/events/resources/blur-focus-window-should-blur-focus-element.js: Added. (divElement.onfocus.divElement.onblur.window.onfocus.window.onblur.innerDiv.onfocus.innerDiv.onblur.iframe.onfocus.iframe.onblur): (testNextEvent):
  • fast/events/resources/tabindex-focus-blur-all.js: (test):
  • fast/events/tabindex-focus-blur-all-expected.txt:

2009-09-10 Erik Arvidsson <arv@chromium.org>

Reviewed by Eric Seidel.

Fixes issue where focused elements did not get blur and focus events when the window was blurred and focused.
https://bugs.webkit.org/show_bug.cgi?id=27105

Test: fast/events/blur-focus-window-should-blur-focus-element.html

  • page/FocusController.cpp: (WebCore::dispatchEventsOnWindowAndFocusedNode): (WebCore::FocusController::setFocused): (WebCore::FocusController::setActive):
Location:
trunk
Files:
3 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r48256 r48257  
     12009-09-10  Erik Arvidsson  <arv@chromium.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Fixes issue where focused elements did not get blur and focus events when the window was blurred and focused.
     6        https://bugs.webkit.org/show_bug.cgi?id=27105
     7
     8        * fast/events/blur-focus-window-should-blur-focus-element-expected.txt: Added.
     9        * fast/events/blur-focus-window-should-blur-focus-element.html: Added.
     10        * fast/events/resources/blur-focus-window-should-blur-focus-element.js: Added.
     11        (divElement.onfocus.divElement.onblur.window.onfocus.window.onblur.innerDiv.onfocus.innerDiv.onblur.iframe.onfocus.iframe.onblur):
     12        (testNextEvent):
     13        * fast/events/resources/tabindex-focus-blur-all.js:
     14        (test):
     15        * fast/events/tabindex-focus-blur-all-expected.txt:
     16
    1172009-09-10  Adam Barth  <abarth@webkit.org>
    218
  • trunk/LayoutTests/fast/events/resources/tabindex-focus-blur-all.js

    r48106 r48257  
    5050    homeBase[0].focus();
    5151
    52     var resultSummary = focusCount+" focus / "+blurCount+" blur events dispatched, and should be 335 / 335 ";
     52    var resultSummary = focusCount+" focus / "+blurCount+" blur events dispatched, and should be 329 / 329 ";
    5353    resultSummary += (focusCount==blurCount) ? "<span style='color:green'>PASSED</span><br>" : "<span style='color:red'>FAILED</span><br>";
    5454    resultSummary += "Total of "+failedTestCount+" focus test(s) failed.";
  • trunk/LayoutTests/fast/events/tabindex-focus-blur-all-expected.txt

    r48106 r48257  
    1 329 focus / 329 blur events dispatched, and should be 335 / 335 PASSED
     1329 focus / 329 blur events dispatched, and should be 329 / 329 PASSED
    22Total of 0 focus test(s) failed. PASSED
  • trunk/WebCore/ChangeLog

    r48255 r48257  
     12009-09-10  Erik Arvidsson  <arv@chromium.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Fixes issue where focused elements did not get blur and focus events when the window was blurred and focused.
     6        https://bugs.webkit.org/show_bug.cgi?id=27105
     7
     8        Test: fast/events/blur-focus-window-should-blur-focus-element.html
     9
     10        * page/FocusController.cpp:
     11        (WebCore::dispatchEventsOnWindowAndFocusedNode):
     12        (WebCore::FocusController::setFocused):
     13        (WebCore::FocusController::setActive):
     14
    1152009-09-10  Adam Roben  <aroben@apple.com>
    216
  • trunk/WebCore/page/FocusController.cpp

    r48106 r48257  
    5656using namespace HTMLNames;
    5757
     58static inline void dispatchEventsOnWindowAndFocusedNode(Document* document, bool focused)
     59{
     60    // If we have a focused node we should dispatch blur on it before we blur the window.
     61    // If we have a focused node we should dispatch focus on it after we focus the window.
     62    // https://bugs.webkit.org/show_bug.cgi?id=27105
     63    if (!focused && document->focusedNode())
     64        document->focusedNode()->dispatchBlurEvent();
     65    document->dispatchWindowEvent(focused ? eventNames().focusEvent : eventNames().blurEvent, false, false);
     66    if (focused && document->focusedNode())
     67        document->focusedNode()->dispatchFocusEvent();
     68}
     69
    5870FocusController::FocusController(Page* page)
    5971    : m_page(page)
     
    101113    if (m_focusedFrame && m_focusedFrame->view()) {
    102114        m_focusedFrame->selection()->setFocused(focused);
    103         m_focusedFrame->document()->dispatchWindowEvent(focused ? eventNames().focusEvent : eventNames().blurEvent, false, false);
     115        dispatchEventsOnWindowAndFocusedNode(m_focusedFrame->document(), focused);
    104116    }
    105117}
     
    344356   
    345357    if (m_focusedFrame && isFocused())
    346         m_focusedFrame->document()->dispatchWindowEvent(active ? eventNames().focusEvent : eventNames().blurEvent, false, false);
     358        dispatchEventsOnWindowAndFocusedNode(m_focusedFrame->document(), active);
    347359}
    348360
Note: See TracChangeset for help on using the changeset viewer.