OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "core/frame/DeviceSingleWindowEventController.h" | 6 #include "core/frame/DeviceSingleWindowEventController.h" |
7 | 7 |
8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
9 #include "core/frame/DOMWindow.h" | 9 #include "core/frame/LocalDOMWindow.h" |
10 #include "core/page/Page.h" | 10 #include "core/page/Page.h" |
11 | 11 |
12 namespace WebCore { | 12 namespace WebCore { |
13 | 13 |
14 DeviceSingleWindowEventController::DeviceSingleWindowEventController(Document& d
ocument) | 14 DeviceSingleWindowEventController::DeviceSingleWindowEventController(Document& d
ocument) |
15 : DeviceEventControllerBase(document.page()) | 15 : DeviceEventControllerBase(document.page()) |
16 , DOMWindowLifecycleObserver(document.domWindow()) | 16 , DOMWindowLifecycleObserver(document.domWindow()) |
17 , m_needsCheckingNullEvents(true) | 17 , m_needsCheckingNullEvents(true) |
18 , m_document(document) | 18 , m_document(document) |
19 { | 19 { |
(...skipping 17 matching lines...) Expand all Loading... |
37 m_document.domWindow()->dispatchEvent(event); | 37 m_document.domWindow()->dispatchEvent(event); |
38 | 38 |
39 if (m_needsCheckingNullEvents) { | 39 if (m_needsCheckingNullEvents) { |
40 if (isNullEvent(event.get())) | 40 if (isNullEvent(event.get())) |
41 stopUpdating(); | 41 stopUpdating(); |
42 else | 42 else |
43 m_needsCheckingNullEvents = false; | 43 m_needsCheckingNullEvents = false; |
44 } | 44 } |
45 } | 45 } |
46 | 46 |
47 void DeviceSingleWindowEventController::didAddEventListener(DOMWindow* window, c
onst AtomicString& eventType) | 47 void DeviceSingleWindowEventController::didAddEventListener(LocalDOMWindow* wind
ow, const AtomicString& eventType) |
48 { | 48 { |
49 if (eventType != eventTypeName()) | 49 if (eventType != eventTypeName()) |
50 return; | 50 return; |
51 | 51 |
52 if (page() && page()->visibilityState() == PageVisibilityStateVisible) | 52 if (page() && page()->visibilityState() == PageVisibilityStateVisible) |
53 startUpdating(); | 53 startUpdating(); |
54 | 54 |
55 m_hasEventListener = true; | 55 m_hasEventListener = true; |
56 } | 56 } |
57 | 57 |
58 void DeviceSingleWindowEventController::didRemoveEventListener(DOMWindow* window
, const AtomicString& eventType) | 58 void DeviceSingleWindowEventController::didRemoveEventListener(LocalDOMWindow* w
indow, const AtomicString& eventType) |
59 { | 59 { |
60 if (eventType != eventTypeName() || window->hasEventListeners(eventTypeName(
))) | 60 if (eventType != eventTypeName() || window->hasEventListeners(eventTypeName(
))) |
61 return; | 61 return; |
62 | 62 |
63 stopUpdating(); | 63 stopUpdating(); |
64 m_hasEventListener = false; | 64 m_hasEventListener = false; |
65 } | 65 } |
66 | 66 |
67 void DeviceSingleWindowEventController::didRemoveAllEventListeners(DOMWindow*) | 67 void DeviceSingleWindowEventController::didRemoveAllEventListeners(LocalDOMWindo
w*) |
68 { | 68 { |
69 stopUpdating(); | 69 stopUpdating(); |
70 m_hasEventListener = false; | 70 m_hasEventListener = false; |
71 } | 71 } |
72 | 72 |
73 } // namespace WebCore | 73 } // namespace WebCore |
OLD | NEW |