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

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

Issue 2668003003: Provide WebVR pose data only to the focused frame. (Closed)
Patch Set: Update to correct copyright notice? Created 3 years, 10 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 #include "core/frame/RemoteFrame.h" 48 #include "core/frame/RemoteFrame.h"
49 #include "core/frame/Settings.h" 49 #include "core/frame/Settings.h"
50 #include "core/html/HTMLAreaElement.h" 50 #include "core/html/HTMLAreaElement.h"
51 #include "core/html/HTMLImageElement.h" 51 #include "core/html/HTMLImageElement.h"
52 #include "core/html/HTMLPlugInElement.h" 52 #include "core/html/HTMLPlugInElement.h"
53 #include "core/html/HTMLShadowElement.h" 53 #include "core/html/HTMLShadowElement.h"
54 #include "core/html/HTMLSlotElement.h" 54 #include "core/html/HTMLSlotElement.h"
55 #include "core/html/TextControlElement.h" 55 #include "core/html/TextControlElement.h"
56 #include "core/input/EventHandler.h" 56 #include "core/input/EventHandler.h"
57 #include "core/page/ChromeClient.h" 57 #include "core/page/ChromeClient.h"
58 #include "core/page/FocusChangedObserver.h"
58 #include "core/page/FrameTree.h" 59 #include "core/page/FrameTree.h"
59 #include "core/page/Page.h" 60 #include "core/page/Page.h"
60 #include "core/layout/HitTestResult.h" 61 #include "core/layout/HitTestResult.h"
61 #include "core/page/SpatialNavigation.h" 62 #include "core/page/SpatialNavigation.h"
62 #include <limits> 63 #include <limits>
63 64
64 namespace blink { 65 namespace blink {
65 66
66 using namespace HTMLNames; 67 using namespace HTMLNames;
67 68
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 newFrame->selection().setFocused(true); 760 newFrame->selection().setFocused(true);
760 newFrame->domWindow()->dispatchEvent(Event::create(EventTypeNames::focus)); 761 newFrame->domWindow()->dispatchEvent(Event::create(EventTypeNames::focus));
761 } 762 }
762 763
763 m_isChangingFocusedFrame = false; 764 m_isChangingFocusedFrame = false;
764 765
765 // Checking client() is necessary, as the frame might have been detached as 766 // Checking client() is necessary, as the frame might have been detached as
766 // part of dispatching the focus event above. See https://crbug.com/570874. 767 // part of dispatching the focus event above. See https://crbug.com/570874.
767 if (m_focusedFrame && m_focusedFrame->client() && notifyEmbedder) 768 if (m_focusedFrame && m_focusedFrame->client() && notifyEmbedder)
768 m_focusedFrame->client()->frameFocused(); 769 m_focusedFrame->client()->frameFocused();
770
771 notifyFocusChangedObservers();
769 } 772 }
770 773
771 void FocusController::focusDocumentView(Frame* frame, bool notifyEmbedder) { 774 void FocusController::focusDocumentView(Frame* frame, bool notifyEmbedder) {
772 DCHECK(!frame || frame->page() == m_page); 775 DCHECK(!frame || frame->page() == m_page);
773 if (m_focusedFrame == frame) 776 if (m_focusedFrame == frame)
774 return; 777 return;
775 778
776 LocalFrame* focusedFrame = (m_focusedFrame && m_focusedFrame->isLocalFrame()) 779 LocalFrame* focusedFrame = (m_focusedFrame && m_focusedFrame->isLocalFrame())
777 ? toLocalFrame(m_focusedFrame.get()) 780 ? toLocalFrame(m_focusedFrame.get())
778 : nullptr; 781 : nullptr;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 setFocusedFrame(m_page->mainFrame()); 864 setFocusedFrame(m_page->mainFrame());
862 865
863 // setFocusedFrame above might reject to update m_focusedFrame, or 866 // setFocusedFrame above might reject to update m_focusedFrame, or
864 // m_focusedFrame might be changed by blur/focus event handlers. 867 // m_focusedFrame might be changed by blur/focus event handlers.
865 if (m_focusedFrame && m_focusedFrame->isLocalFrame() && 868 if (m_focusedFrame && m_focusedFrame->isLocalFrame() &&
866 toLocalFrame(m_focusedFrame.get())->view()) { 869 toLocalFrame(m_focusedFrame.get())->view()) {
867 toLocalFrame(m_focusedFrame.get())->selection().setFocused(focused); 870 toLocalFrame(m_focusedFrame.get())->selection().setFocused(focused);
868 dispatchEventsOnWindowAndFocusedElement( 871 dispatchEventsOnWindowAndFocusedElement(
869 toLocalFrame(m_focusedFrame.get())->document(), focused); 872 toLocalFrame(m_focusedFrame.get())->document(), focused);
870 } 873 }
874
875 notifyFocusChangedObservers();
jbroman 2017/02/02 16:07:20 Won't this possibly notify twice, since setFocused
mthiesse 2017/02/02 17:52:18 Yes, intentionally. We need to call it in setFocus
871 } 876 }
872 877
873 bool FocusController::setInitialFocus(WebFocusType type) { 878 bool FocusController::setInitialFocus(WebFocusType type) {
874 bool didAdvanceFocus = advanceFocus(type, true); 879 bool didAdvanceFocus = advanceFocus(type, true);
875 880
876 // If focus is being set initially, accessibility needs to be informed that 881 // If focus is being set initially, accessibility needs to be informed that
877 // system focus has moved into the web area again, even if focus did not 882 // system focus has moved into the web area again, even if focus did not
878 // change within WebCore. PostNotification is called instead of 883 // change within WebCore. PostNotification is called instead of
879 // handleFocusedUIElementChanged, because this will send the notification even 884 // handleFocusedUIElementChanged, because this will send the notification even
880 // if the element is the same. 885 // if the element is the same.
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
1389 nodeRectInAbsoluteCoordinates(container, true /* ignore border */); 1394 nodeRectInAbsoluteCoordinates(container, true /* ignore border */);
1390 container = 1395 container =
1391 scrollableEnclosingBoxOrParentFrameForNodeInDirection(type, container); 1396 scrollableEnclosingBoxOrParentFrameForNodeInDirection(type, container);
1392 if (container && container->isDocumentNode()) 1397 if (container && container->isDocumentNode())
1393 toDocument(container)->updateStyleAndLayoutIgnorePendingStylesheets(); 1398 toDocument(container)->updateStyleAndLayoutIgnorePendingStylesheets();
1394 } while (!consumed && container); 1399 } while (!consumed && container);
1395 1400
1396 return consumed; 1401 return consumed;
1397 } 1402 }
1398 1403
1404 void FocusController::registerFocusChangedObserver(
1405 FocusChangedObserver* observer) {
1406 DCHECK(observer);
1407 DCHECK(!m_focusChangedObservers.contains(observer));
1408 m_focusChangedObservers.insert(observer);
1409 }
1410
1411 void FocusController::notifyFocusChangedObservers() const {
1412 for (auto& it : m_focusChangedObservers) {
jbroman 2017/02/02 16:07:20 nit: const auto&
mthiesse 2017/02/02 17:52:18 Done.
1413 it->focusedFrameChanged();
1414 }
jbroman 2017/02/02 16:07:20 super-nit: don't need the braces
mthiesse 2017/02/02 17:52:18 Done.
1415 }
1416
1399 DEFINE_TRACE(FocusController) { 1417 DEFINE_TRACE(FocusController) {
1400 visitor->trace(m_page); 1418 visitor->trace(m_page);
1401 visitor->trace(m_focusedFrame); 1419 visitor->trace(m_focusedFrame);
1420 visitor->trace(m_focusChangedObservers);
1402 } 1421 }
1403 1422
1404 } // namespace blink 1423 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698