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

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: incorporated review comments 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
« no previous file with comments | « Source/core/page/FocusController.h ('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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 if (newFrame && newFrame->view() && isFocused()) { 254 if (newFrame && newFrame->view() && isFocused()) {
255 newFrame->selection().setFocused(true); 255 newFrame->selection().setFocused(true);
256 newFrame->domWindow()->dispatchEvent(Event::create(EventTypeNames::focus )); 256 newFrame->domWindow()->dispatchEvent(Event::create(EventTypeNames::focus ));
257 } 257 }
258 258
259 m_isChangingFocusedFrame = false; 259 m_isChangingFocusedFrame = false;
260 260
261 m_page->chrome().client().focusedFrameChanged(newFrame.get()); 261 m_page->chrome().client().focusedFrameChanged(newFrame.get());
262 } 262 }
263 263
264 void FocusController::focusDocumentView(PassRefPtr<Frame> frame)
265 {
266 ASSERT(!frame || frame->page() == m_page);
267 if (m_focusedFrame == frame)
268 return;
269
270 RefPtr<LocalFrame> focusedFrame = (m_focusedFrame && m_focusedFrame->isLocal Frame()) ? toLocalFrame(m_focusedFrame.get()) : 0;
271 if (focusedFrame && focusedFrame->view()) {
272 RefPtr<Document> document = focusedFrame->document();
273 Element* focusedElement = document ? document->focusedElement() : 0;
274 if (focusedElement) {
275 focusedElement->dispatchBlurEvent(0);
276 if (focusedElement == document->focusedElement()) {
277 focusedElement->dispatchFocusOutEvent(EventTypeNames::focusout, 0);
278 if (focusedElement == document->focusedElement())
279 focusedElement->dispatchFocusOutEvent(EventTypeNames::DOMFoc usOut, 0);
280 }
281 }
282 }
283
284 RefPtr<LocalFrame> newFocusedFrame = (frame && frame->isLocalFrame()) ? toLo calFrame(frame.get()) : 0;
285 if (newFocusedFrame && newFocusedFrame->view()) {
286 RefPtr<Document> document = newFocusedFrame->document();
287 Element* focusedElement = document ? document->focusedElement() : 0;
288 if (focusedElement) {
289 focusedElement->dispatchFocusEvent(0, FocusTypePage);
290 if (focusedElement == document->focusedElement()) {
291 document->focusedElement()->dispatchFocusInEvent(EventTypeNames: :focusin, 0);
292 if (focusedElement == document->focusedElement())
293 document->focusedElement()->dispatchFocusInEvent(EventTypeNa mes::DOMFocusIn, 0);
294 }
295 }
296 }
297
298 setFocusedFrame(frame);
299 }
300
264 Frame* FocusController::focusedOrMainFrame() const 301 Frame* FocusController::focusedOrMainFrame() const
265 { 302 {
266 if (Frame* frame = focusedFrame()) 303 if (Frame* frame = focusedFrame())
267 return frame; 304 return frame;
268 return m_page->mainFrame(); 305 return m_page->mainFrame();
269 } 306 }
270 307
271 void FocusController::setFocused(bool focused) 308 void FocusController::setFocused(bool focused)
272 { 309 {
273 if (isFocused() == focused) 310 if (isFocused() == focused)
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 startingRect = nodeRectInAbsoluteCoordinates(container, true /* ignore b order */); 914 startingRect = nodeRectInAbsoluteCoordinates(container, true /* ignore b order */);
878 container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(type, container); 915 container = scrollableEnclosingBoxOrParentFrameForNodeInDirection(type, container);
879 if (container && container->isDocumentNode()) 916 if (container && container->isDocumentNode())
880 toDocument(container)->updateLayoutIgnorePendingStylesheets(); 917 toDocument(container)->updateLayoutIgnorePendingStylesheets();
881 } while (!consumed && container); 918 } while (!consumed && container);
882 919
883 return consumed; 920 return consumed;
884 } 921 }
885 922
886 } // namespace WebCore 923 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/page/FocusController.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698