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

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

Issue 256593010: Gracefully support Navigator Gamepad methods in a detached state. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Have document supplements keep a reference to their document Created 6 years, 7 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 2010 Apple Inc. All rights reserved. 2 * Copyright 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2012 Samsung Electronics. All rights reserved. 3 * Copyright (C) 2012 Samsung Electronics. All rights reserved.
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 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above copyright 10 * * Redistributions in binary form must reproduce the above copyright
(...skipping 15 matching lines...) Expand all
26 26
27 #include "config.h" 27 #include "config.h"
28 #include "core/frame/DeviceSensorEventController.h" 28 #include "core/frame/DeviceSensorEventController.h"
29 29
30 #include "core/dom/Document.h" 30 #include "core/dom/Document.h"
31 #include "core/frame/DOMWindow.h" 31 #include "core/frame/DOMWindow.h"
32 #include "core/page/Page.h" 32 #include "core/page/Page.h"
33 33
34 namespace WebCore { 34 namespace WebCore {
35 35
36 DeviceSensorEventController::DeviceSensorEventController(Document& document) 36 DeviceSensorEventController::DeviceSensorEventController(Page* page)
37 : PageLifecycleObserver(document.page()) 37 : PageLifecycleObserver(page)
38 , m_hasEventListener(false) 38 , m_hasEventListener(false)
39 , m_document(document)
40 , m_isActive(false) 39 , m_isActive(false)
41 , m_needsCheckingNullEvents(true) 40 , m_needsCheckingNullEvents(true)
42 , m_timer(this, &DeviceSensorEventController::fireDeviceEvent) 41 , m_timer(this, &DeviceSensorEventController::fireDeviceEvent)
43 { 42 {
44 } 43 }
45 44
46 DeviceSensorEventController::~DeviceSensorEventController() 45 DeviceSensorEventController::~DeviceSensorEventController()
47 { 46 {
48 } 47 }
49 48
50 void DeviceSensorEventController::fireDeviceEvent(Timer<DeviceSensorEventControl ler>* timer) 49 void DeviceSensorEventController::fireDeviceEvent(Timer<DeviceSensorEventControl ler>* timer)
51 { 50 {
52 ASSERT_UNUSED(timer, timer == &m_timer); 51 ASSERT_UNUSED(timer, timer == &m_timer);
53 ASSERT(hasLastData()); 52 ASSERT(hasLastData());
54 53
55 m_timer.stop(); 54 m_timer.stop();
56 dispatchDeviceEvent(getLastEvent()); 55 dispatchDeviceEvent(getLastEvent());
57 } 56 }
58 57
59 void DeviceSensorEventController::dispatchDeviceEvent(PassRefPtrWillBeRawPtr<Eve nt> prpEvent) 58 void DeviceSensorEventController::dispatchDeviceEvent(PassRefPtrWillBeRawPtr<Eve nt> prpEvent)
60 { 59 {
61 if (!m_document.domWindow() || m_document.activeDOMObjectsAreSuspended() || m_document.activeDOMObjectsAreStopped()) 60 Document* targetDocument = document();
61
62 if (!targetDocument || !targetDocument->domWindow() || targetDocument->activ eDOMObjectsAreSuspended() || targetDocument->activeDOMObjectsAreStopped())
62 return; 63 return;
63 64
64 RefPtrWillBeRawPtr<Event> event = prpEvent; 65 RefPtrWillBeRawPtr<Event> event = prpEvent;
65 m_document.domWindow()->dispatchEvent(event); 66 targetDocument->domWindow()->dispatchEvent(event);
66 67
67 if (m_needsCheckingNullEvents) { 68 if (m_needsCheckingNullEvents) {
68 if (isNullEvent(event.get())) 69 if (isNullEvent(event.get()))
69 stopUpdating(); 70 stopUpdating();
70 else 71 else
71 m_needsCheckingNullEvents = false; 72 m_needsCheckingNullEvents = false;
72 } 73 }
73 } 74 }
74 75
75 void DeviceSensorEventController::startUpdating() 76 void DeviceSensorEventController::startUpdating()
(...skipping 27 matching lines...) Expand all
103 if (!m_hasEventListener) 104 if (!m_hasEventListener)
104 return; 105 return;
105 106
106 if (page()->visibilityState() == PageVisibilityStateVisible) 107 if (page()->visibilityState() == PageVisibilityStateVisible)
107 startUpdating(); 108 startUpdating();
108 else 109 else
109 stopUpdating(); 110 stopUpdating();
110 } 111 }
111 112
112 } // namespace WebCore 113 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/frame/DeviceSensorEventController.h ('k') | Source/modules/battery/BatteryManager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698