Changeset 54082 in webkit


Ignore:
Timestamp:
Jan 29, 2010 3:39:41 PM (14 years ago)
Author:
victorw@chromium.org
Message:
 
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r54078 r54082  
     12010-01-29  Victor Wang  <victorw@chromium.org>
     2
     3        Reviewed by darin@apple.com.
     4
     5        Fix the issue that both main frome and iframe are
     6        focused if window.onblur calls window.focus.
     7        https://bugs.webkit.org/show_bug.cgi?id=31692
     8
     9        The problem is caused by the focused frame in FocusController
     10        is messed up if window.onblur calls window.focus:
     11        When user clicks iframe to switch focus from main frame to iframe,
     12        FocusController::setFocusedFrame fires onblur event, which calls
     13        window.focus and then calls setFocusedFrame again to switch back.
     14        This messes up the old focused frame and new focused frame and
     15        leaves the FocusController confused. As a result, controlls
     16        in both main frame and iframe look like get focused.
     17
     18        To fix it, add a flag to FocusController and do no switch the focused
     19        frame when FocusController is in the middle of changing the focused frame.
     20
     21        * fast/events/change-frame-focus-expected.txt: Added.
     22        * fast/events/change-frame-focus.html: Added.
     23
    1242010-01-28  Jon Honeycutt  <jhoneycutt@apple.com>
    225
  • trunk/WebCore/ChangeLog

    r54081 r54082  
     12010-01-29  Victor Wang  <victorw@chromium.org>
     2
     3        Reviewed by darin@apple.com.
     4
     5        Fix the issue that both main frome and iframe are
     6        focused if window.onblur calls window.focus.
     7        https://bugs.webkit.org/show_bug.cgi?id=31692
     8
     9        The problem is caused by the focused frame in FocusController
     10        is messed up if window.onblur calls window.focus:
     11        When user clicks iframe to switch focus from main frame to iframe,
     12        FocusController::setFocusedFrame fires onblur event, which calls
     13        window.focus and then calls setFocusedFrame again to switch back.
     14        This messes up the old focused frame and new focused frame and
     15        leaves the FocusController confused. As a result, controlls
     16        in both main frame and iframe look like get focused.
     17
     18        To fix it, add a flag to FocusController and do no switch the focused
     19        frame when FocusController is in the middle of changing the focused frame.
     20
     21        Test: fast/events/change-frame-focus.html
     22
     23        * page/FocusController.cpp:
     24        (WebCore::FocusController::FocusController):
     25        (WebCore::FocusController::setFocusedFrame):
     26        * page/FocusController.h:
     27        (WebCore::FocusController::focusedFrame):
     28        (WebCore::FocusController::isActive):
     29        (WebCore::FocusController::isFocused):
     30
    1312010-01-29  Alexey Proskuryakov  <ap@apple.com>
    232
  • trunk/WebCore/page/FocusController.cpp

    r48701 r54082  
    3939#include "ExceptionCode.h"
    4040#include "Frame.h"
     41#include "FrameTree.h"
    4142#include "FrameView.h"
    42 #include "FrameTree.h"
    4343#include "HTMLFrameOwnerElement.h"
    4444#include "HTMLNames.h"
     
    7373    , m_isActive(false)
    7474    , m_isFocused(false)
     75    , m_isChangingFocusedFrame(false)
    7576{
    7677}
     
    7879void FocusController::setFocusedFrame(PassRefPtr<Frame> frame)
    7980{
    80     if (m_focusedFrame == frame)
    81         return;
     81    if (m_focusedFrame == frame || m_isChangingFocusedFrame)
     82        return;
     83
     84    m_isChangingFocusedFrame = true;
    8285
    8386    RefPtr<Frame> oldFrame = m_focusedFrame;
     
    9699        newFrame->document()->dispatchWindowEvent(Event::create(eventNames().focusEvent, false, false));
    97100    }
     101
     102    m_isChangingFocusedFrame = false;
    98103}
    99104
  • trunk/WebCore/page/FocusController.h

    r50810 r54082  
    3434namespace WebCore {
    3535
    36     class Frame;
    37     class KeyboardEvent;
    38     class Node;
    39     class Page;
     36class Frame;
     37class KeyboardEvent;
     38class Node;
     39class Page;
    4040
    41     class FocusController : public Noncopyable {
    42     public:
    43         FocusController(Page*);
     41class FocusController : public Noncopyable {
     42public:
     43    FocusController(Page*);
    4444
    45         void setFocusedFrame(PassRefPtr<Frame>);
    46         Frame* focusedFrame() const { return m_focusedFrame.get(); }
    47         Frame* focusedOrMainFrame();
     45    void setFocusedFrame(PassRefPtr<Frame>);
     46    Frame* focusedFrame() const { return m_focusedFrame.get(); }
     47    Frame* focusedOrMainFrame();
    4848
    49         bool setInitialFocus(FocusDirection, KeyboardEvent*);
    50         bool advanceFocus(FocusDirection, KeyboardEvent*, bool initialFocus = false);
     49    bool setInitialFocus(FocusDirection, KeyboardEvent*);
     50    bool advanceFocus(FocusDirection, KeyboardEvent*, bool initialFocus = false);
    5151       
    52         bool setFocusedNode(Node*, PassRefPtr<Frame>);
     52    bool setFocusedNode(Node*, PassRefPtr<Frame>);
    5353
    54         void setActive(bool);
    55         bool isActive() const { return m_isActive; }
     54    void setActive(bool);
     55    bool isActive() const { return m_isActive; }
    5656
    57         void setFocused(bool);
    58         bool isFocused() const { return m_isFocused; }
     57    void setFocused(bool);
     58    bool isFocused() const { return m_isFocused; }
    5959
    60     private:
    61         Page* m_page;
    62         RefPtr<Frame> m_focusedFrame;
    63         bool m_isActive;
    64         bool m_isFocused;
    65     };
     60private:
     61    Page* m_page;
     62    RefPtr<Frame> m_focusedFrame;
     63    bool m_isActive;
     64    bool m_isFocused;
     65    bool m_isChangingFocusedFrame;
     66};
    6667
    6768} // namespace WebCore
Note: See TracChangeset for help on using the changeset viewer.