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

Side by Side Diff: Source/core/page/FocusController.cpp

Issue 238023004: Focusing iframe window should trigger blur event for oldframe's focused element (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 8 months 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
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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 if (newFrame && newFrame->view() && isFocused()) { 255 if (newFrame && newFrame->view() && isFocused()) {
256 newFrame->selection().setFocused(true); 256 newFrame->selection().setFocused(true);
257 newFrame->domWindow()->dispatchEvent(Event::create(EventTypeNames::focus )); 257 newFrame->domWindow()->dispatchEvent(Event::create(EventTypeNames::focus ));
258 } 258 }
259 259
260 m_isChangingFocusedFrame = false; 260 m_isChangingFocusedFrame = false;
261 261
262 m_page->chrome().client().focusedFrameChanged(newFrame.get()); 262 m_page->chrome().client().focusedFrameChanged(newFrame.get());
263 } 263 }
264 264
265 void FocusController::focusDocumentView(PassRefPtr<Frame> frame)
266 {
267 ASSERT(!frame || frame->page() == m_page);
268 if (m_focusedFrame == frame)
269 return;
270
271 RefPtr<LocalFrame> focusedFrame = (m_focusedFrame && m_focusedFrame->isLocal Frame()) ? toLocalFrame(m_focusedFrame.get()) : 0;
272 if (focusedFrame && focusedFrame->view()) {
273 RefPtr<Document> document = focusedFrame->document();
274 Element* focusedElement = document ? document->focusedElement() : 0;
275 if (focusedElement)
276 focusedElement->dispatchBlurEvent(0);
tkent 2014/04/23 02:23:31 We need to dispatch 'focusout' and 'DOMFocusOut' e
gnana 2014/04/23 12:21:51 Done.
277 }
278
279 RefPtr<LocalFrame> newFocusedFrame = (frame && frame->isLocalFrame()) ? toLo calFrame(frame.get()) : 0;
280 if (newFocusedFrame && newFocusedFrame->view()) {
281 RefPtr<Document> document = newFocusedFrame->document();
282 Element* focusedElement = document ? document->focusedElement() : 0;
283 if (focusedElement)
284 focusedElement->dispatchFocusEvent(0, FocusTypePage);
tkent 2014/04/23 02:23:31 We need to dispatch 'focusin' and 'DOMFocusIn' eve
gnana 2014/04/23 12:21:51 Done.
285 }
286
287 setFocusedFrame(frame);
288 }
289
265 Frame* FocusController::focusedOrMainFrame() const 290 Frame* FocusController::focusedOrMainFrame() const
266 { 291 {
267 if (Frame* frame = focusedFrame()) 292 if (Frame* frame = focusedFrame())
268 return frame; 293 return frame;
269 return m_page->mainFrame(); 294 return m_page->mainFrame();
270 } 295 }
271 296
272 void FocusController::setFocused(bool focused) 297 void FocusController::setFocused(bool focused)
273 { 298 {
274 if (isFocused() == focused) 299 if (isFocused() == focused)
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 startingRect = nodeRectInAbsoluteCoordinates(container, true /* ignore b order */); 939 startingRect = nodeRectInAbsoluteCoordinates(container, true /* ignore b order */);
915 container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(type, container); 940 container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(type, container);
916 if (container && container->isDocumentNode()) 941 if (container && container->isDocumentNode())
917 toDocument(container)->updateLayoutIgnorePendingStylesheets(); 942 toDocument(container)->updateLayoutIgnorePendingStylesheets();
918 } while (!consumed && container); 943 } while (!consumed && container);
919 944
920 return consumed; 945 return consumed;
921 } 946 }
922 947
923 } // namespace WebCore 948 } // namespace WebCore
OLDNEW
« Source/core/page/EventHandler.cpp ('K') | « Source/core/page/FocusController.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698