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

Side by Side Diff: third_party/WebKit/Source/modules/device_light/DeviceLightController.cpp

Issue 2845763002: Remove DeviceLightEvent implementation (Closed)
Patch Set: same as previous patch Created 3 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
(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 "modules/device_light/DeviceLightController.h"
6
7 #include "core/dom/Document.h"
8 #include "modules/EventModules.h"
9 #include "modules/device_light/DeviceLightDispatcher.h"
10 #include "modules/device_light/DeviceLightEvent.h"
11 #include "platform/RuntimeEnabledFeatures.h"
12
13 namespace blink {
14
15 DeviceLightController::DeviceLightController(Document& document)
16 : DeviceSingleWindowEventController(document),
17 Supplement<Document>(document) {}
18
19 DeviceLightController::~DeviceLightController() {}
20
21 const char* DeviceLightController::SupplementName() {
22 return "DeviceLightController";
23 }
24
25 DeviceLightController& DeviceLightController::From(Document& document) {
26 DeviceLightController* controller = static_cast<DeviceLightController*>(
27 Supplement<Document>::From(document, SupplementName()));
28 if (!controller) {
29 controller = new DeviceLightController(document);
30 Supplement<Document>::ProvideTo(document, SupplementName(), controller);
31 }
32 return *controller;
33 }
34
35 bool DeviceLightController::HasLastData() {
36 return DeviceLightDispatcher::Instance().LatestDeviceLightData() >= 0;
37 }
38
39 void DeviceLightController::RegisterWithDispatcher() {
40 DeviceLightDispatcher::Instance().AddController(this);
41 }
42
43 void DeviceLightController::UnregisterWithDispatcher() {
44 DeviceLightDispatcher::Instance().RemoveController(this);
45 }
46
47 Event* DeviceLightController::LastEvent() const {
48 return DeviceLightEvent::Create(
49 EventTypeNames::devicelight,
50 DeviceLightDispatcher::Instance().LatestDeviceLightData());
51 }
52
53 bool DeviceLightController::IsNullEvent(Event* event) const {
54 DeviceLightEvent* light_event = ToDeviceLightEvent(event);
55 return light_event->value() == std::numeric_limits<double>::infinity();
56 }
57
58 const AtomicString& DeviceLightController::EventTypeName() const {
59 return EventTypeNames::devicelight;
60 }
61
62 DEFINE_TRACE(DeviceLightController) {
63 DeviceSingleWindowEventController::Trace(visitor);
64 Supplement<Document>::Trace(visitor);
65 }
66
67 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698