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

Side by Side Diff: Source/modules/device_orientation/DeviceMotionController.cpp

Issue 26429003: Cleanup: Add toDeviceMotionEvent and toDeviceOrientationEvent. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updated to ToT Created 7 years, 2 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 DeviceMotionDispatcher::instance().addDeviceMotionController(this); 84 DeviceMotionDispatcher::instance().addDeviceMotionController(this);
85 } 85 }
86 86
87 void DeviceMotionController::unregisterWithDispatcher() 87 void DeviceMotionController::unregisterWithDispatcher()
88 { 88 {
89 DeviceMotionDispatcher::instance().removeDeviceMotionController(this); 89 DeviceMotionDispatcher::instance().removeDeviceMotionController(this);
90 } 90 }
91 91
92 bool DeviceMotionController::isNullEvent(Event* event) 92 bool DeviceMotionController::isNullEvent(Event* event)
93 { 93 {
94 ASSERT(event->type() == EventTypeNames::devicemotion); 94 DeviceMotionEvent* motionEvent = toDeviceMotionEvent(event);
95 DeviceMotionEvent* motionEvent = static_cast<DeviceMotionEvent*>(event);
96 return !motionEvent->deviceMotionData()->canProvideEventData(); 95 return !motionEvent->deviceMotionData()->canProvideEventData();
97 } 96 }
98 97
99 void DeviceMotionController::didAddEventListener(DOMWindow*, const AtomicString& eventType) 98 void DeviceMotionController::didAddEventListener(DOMWindow*, const AtomicString& eventType)
100 { 99 {
101 if (eventType == EventTypeNames::devicemotion && RuntimeEnabledFeatures::dev iceMotionEnabled()) { 100 if (eventType == EventTypeNames::devicemotion && RuntimeEnabledFeatures::dev iceMotionEnabled()) {
102 if (page() && page()->visibilityState() == PageVisibilityStateVisible) 101 if (page() && page()->visibilityState() == PageVisibilityStateVisible)
103 startUpdating(); 102 startUpdating();
104 m_hasEventListener = true; 103 m_hasEventListener = true;
105 } 104 }
(...skipping 18 matching lines...) Expand all
124 if (!m_hasEventListener) 123 if (!m_hasEventListener)
125 return; 124 return;
126 125
127 if (page()->visibilityState() == PageVisibilityStateVisible) 126 if (page()->visibilityState() == PageVisibilityStateVisible)
128 startUpdating(); 127 startUpdating();
129 else 128 else
130 stopUpdating(); 129 stopUpdating();
131 } 130 }
132 131
133 } // namespace WebCore 132 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/html/shadow/SpinButtonElement.cpp ('k') | Source/modules/device_orientation/DeviceMotionEvent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698