Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(307)

Side by Side Diff: WebCore/page/FocusController.cpp

Issue 427011: Revert WebKit 48257 on the 249 branch.... (Closed) Base URL: svn://chrome-svn/chrome/branches/WebKit/249/
Patch Set: Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « LayoutTests/fast/events/tabindex-focus-blur-all-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Nuanti Ltd. 3 * Copyright (C) 2008 Nuanti Ltd.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 #include "RenderWidget.h" 49 #include "RenderWidget.h"
50 #include "SelectionController.h" 50 #include "SelectionController.h"
51 #include "Settings.h" 51 #include "Settings.h"
52 #include "Widget.h" 52 #include "Widget.h"
53 #include <wtf/Platform.h> 53 #include <wtf/Platform.h>
54 54
55 namespace WebCore { 55 namespace WebCore {
56 56
57 using namespace HTMLNames; 57 using namespace HTMLNames;
58 58
59 static inline void dispatchEventsOnWindowAndFocusedNode(Document* document, bool focused)
60 {
61 // If we have a focused node we should dispatch blur on it before we blur th e window.
62 // If we have a focused node we should dispatch focus on it after we focus t he window.
63 // https://bugs.webkit.org/show_bug.cgi?id=27105
64 if (!focused && document->focusedNode())
65 document->focusedNode()->dispatchBlurEvent();
66 document->dispatchWindowEvent(Event::create(focused ? eventNames().focusEven t : eventNames().blurEvent, false, false));
67 if (focused && document->focusedNode())
68 document->focusedNode()->dispatchFocusEvent();
69 }
70
71 FocusController::FocusController(Page* page) 59 FocusController::FocusController(Page* page)
72 : m_page(page) 60 : m_page(page)
73 , m_isActive(false) 61 , m_isActive(false)
74 , m_isFocused(false) 62 , m_isFocused(false)
75 { 63 {
76 } 64 }
77 65
78 void FocusController::setFocusedFrame(PassRefPtr<Frame> frame) 66 void FocusController::setFocusedFrame(PassRefPtr<Frame> frame)
79 { 67 {
80 if (m_focusedFrame == frame) 68 if (m_focusedFrame == frame)
(...skipping 25 matching lines...) Expand all
106 94
107 void FocusController::setFocused(bool focused) 95 void FocusController::setFocused(bool focused)
108 { 96 {
109 if (isFocused() == focused) 97 if (isFocused() == focused)
110 return; 98 return;
111 99
112 m_isFocused = focused; 100 m_isFocused = focused;
113 101
114 if (m_focusedFrame && m_focusedFrame->view()) { 102 if (m_focusedFrame && m_focusedFrame->view()) {
115 m_focusedFrame->selection()->setFocused(focused); 103 m_focusedFrame->selection()->setFocused(focused);
116 dispatchEventsOnWindowAndFocusedNode(m_focusedFrame->document(), focused ); 104 m_focusedFrame->document()->dispatchWindowEvent(focused ? eventNames().f ocusEvent : eventNames().blurEvent, false, false);
117 } 105 }
118 } 106 }
119 107
120 static Node* deepFocusableNode(FocusDirection direction, Node* node, KeyboardEve nt* event) 108 static Node* deepFocusableNode(FocusDirection direction, Node* node, KeyboardEve nt* event)
121 { 109 {
122 // The node we found might be a HTMLFrameOwnerElement, so descend down the f rame tree until we find either: 110 // The node we found might be a HTMLFrameOwnerElement, so descend down the f rame tree until we find either:
123 // 1) a focusable node, or 111 // 1) a focusable node, or
124 // 2) the deepest-nested HTMLFrameOwnerElement 112 // 2) the deepest-nested HTMLFrameOwnerElement
125 while (node && node->isFrameOwnerElement()) { 113 while (node && node->isFrameOwnerElement()) {
126 HTMLFrameOwnerElement* owner = static_cast<HTMLFrameOwnerElement*>(node) ; 114 HTMLFrameOwnerElement* owner = static_cast<HTMLFrameOwnerElement*>(node) ;
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 if (FrameView* view = m_page->mainFrame()->view()) { 337 if (FrameView* view = m_page->mainFrame()->view()) {
350 if (!view->platformWidget()) { 338 if (!view->platformWidget()) {
351 view->layoutIfNeededRecursive(); 339 view->layoutIfNeededRecursive();
352 view->updateControlTints(); 340 view->updateControlTints();
353 } 341 }
354 } 342 }
355 343
356 focusedOrMainFrame()->selection()->pageActivationChanged(); 344 focusedOrMainFrame()->selection()->pageActivationChanged();
357 345
358 if (m_focusedFrame && isFocused()) 346 if (m_focusedFrame && isFocused())
359 dispatchEventsOnWindowAndFocusedNode(m_focusedFrame->document(), active) ; 347 m_focusedFrame->document()->dispatchWindowEvent(active ? eventNames().fo cusEvent : eventNames().blurEvent, false, false);
360 } 348 }
361 349
362 } // namespace WebCore 350 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/fast/events/tabindex-focus-blur-all-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698