Chromium Code Reviews| Index: third_party/WebKit/Source/core/page/FocusController.cpp |
| diff --git a/third_party/WebKit/Source/core/page/FocusController.cpp b/third_party/WebKit/Source/core/page/FocusController.cpp |
| index 28897fcea19a17f418c11d41059ae6d187670d50..361c798d47b6cd79f51b0aff23e24a45bbc24531 100644 |
| --- a/third_party/WebKit/Source/core/page/FocusController.cpp |
| +++ b/third_party/WebKit/Source/core/page/FocusController.cpp |
| @@ -55,6 +55,7 @@ |
| #include "core/html/TextControlElement.h" |
| #include "core/input/EventHandler.h" |
| #include "core/page/ChromeClient.h" |
| +#include "core/page/FocusChangedObserver.h" |
| #include "core/page/FrameTree.h" |
| #include "core/page/Page.h" |
| #include "core/layout/HitTestResult.h" |
| @@ -766,6 +767,8 @@ void FocusController::setFocusedFrame(Frame* frame, bool notifyEmbedder) { |
| // part of dispatching the focus event above. See https://crbug.com/570874. |
| if (m_focusedFrame && m_focusedFrame->client() && notifyEmbedder) |
| m_focusedFrame->client()->frameFocused(); |
| + |
| + notifyFocusChangedObservers(); |
| } |
| void FocusController::focusDocumentView(Frame* frame, bool notifyEmbedder) { |
| @@ -868,6 +871,8 @@ void FocusController::setFocused(bool focused) { |
| dispatchEventsOnWindowAndFocusedElement( |
| toLocalFrame(m_focusedFrame.get())->document(), focused); |
| } |
| + |
| + 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
|
| } |
| bool FocusController::setInitialFocus(WebFocusType type) { |
| @@ -1396,9 +1401,23 @@ bool FocusController::advanceFocusDirectionally(WebFocusType type) { |
| return consumed; |
| } |
| +void FocusController::registerFocusChangedObserver( |
| + FocusChangedObserver* observer) { |
| + DCHECK(observer); |
| + DCHECK(!m_focusChangedObservers.contains(observer)); |
| + m_focusChangedObservers.insert(observer); |
| +} |
| + |
| +void FocusController::notifyFocusChangedObservers() const { |
| + for (auto& it : m_focusChangedObservers) { |
|
jbroman
2017/02/02 16:07:20
nit: const auto&
mthiesse
2017/02/02 17:52:18
Done.
|
| + it->focusedFrameChanged(); |
| + } |
|
jbroman
2017/02/02 16:07:20
super-nit: don't need the braces
mthiesse
2017/02/02 17:52:18
Done.
|
| +} |
| + |
| DEFINE_TRACE(FocusController) { |
| visitor->trace(m_page); |
| visitor->trace(m_focusedFrame); |
| + visitor->trace(m_focusChangedObservers); |
| } |
| } // namespace blink |