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

Side by Side Diff: Source/core/frame/DeviceSingleWindowEventController.cpp

Issue 315573002: Generalize and refactor DeviceSensorEvent* architecture to support multi-event type targets. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: add stopUpdating in destructor of BatteryManager. Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "config.h"
6 #include "core/frame/DeviceSingleWindowEventController.h"
7
8 #include "core/dom/Document.h"
9 #include "core/frame/DOMWindow.h"
10 #include "core/page/Page.h"
11
12 namespace WebCore {
13
14 DeviceSingleWindowEventController::DeviceSingleWindowEventController(Document& d ocument)
15 : DeviceEventControllerBase(document.page())
16 , DOMWindowLifecycleObserver(document.domWindow())
17 , m_needsCheckingNullEvents(true)
18 , m_document(document)
19 {
20 }
21
22 DeviceSingleWindowEventController::~DeviceSingleWindowEventController()
23 {
24 }
25
26 void DeviceSingleWindowEventController::didUpdateData()
27 {
28 dispatchDeviceEvent(lastEvent());
29 }
30
31 void DeviceSingleWindowEventController::dispatchDeviceEvent(PassRefPtrWillBeRawP tr<Event> prpEvent)
32 {
33 if (!m_document.domWindow() || m_document.activeDOMObjectsAreSuspended() || m_document.activeDOMObjectsAreStopped())
34 return;
35
36 RefPtrWillBeRawPtr<Event> event = prpEvent;
37 m_document.domWindow()->dispatchEvent(event);
38
39 if (m_needsCheckingNullEvents) {
40 if (isNullEvent(event.get()))
41 stopUpdating();
42 else
43 m_needsCheckingNullEvents = false;
44 }
45 }
46
47 void DeviceSingleWindowEventController::didAddEventListener(DOMWindow* window, c onst AtomicString& eventType)
48 {
49 if (eventType != eventTypeName())
50 return;
51
52 if (page() && page()->visibilityState() == PageVisibilityStateVisible)
53 startUpdating();
54
55 m_hasEventListener = true;
56 }
57
58 void DeviceSingleWindowEventController::didRemoveEventListener(DOMWindow* window , const AtomicString& eventType)
59 {
60 if (eventType != eventTypeName() || window->hasEventListeners(eventTypeName( )))
61 return;
62
63 stopUpdating();
64 m_hasEventListener = false;
65 }
66
67 void DeviceSingleWindowEventController::didRemoveAllEventListeners(DOMWindow*)
68 {
69 stopUpdating();
70 m_hasEventListener = false;
71 }
72
73 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/frame/DeviceSingleWindowEventController.h ('k') | Source/modules/battery/BatteryDispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698