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

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

Issue 165443003: Pass implementation object to supplemental classes by reference (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 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
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 19 matching lines...) Expand all
30 #include "RuntimeEnabledFeatures.h" 30 #include "RuntimeEnabledFeatures.h"
31 #include "core/dom/Document.h" 31 #include "core/dom/Document.h"
32 #include "core/events/ThreadLocalEventNames.h" 32 #include "core/events/ThreadLocalEventNames.h"
33 #include "core/page/Page.h" 33 #include "core/page/Page.h"
34 #include "modules/device_orientation/DeviceOrientationData.h" 34 #include "modules/device_orientation/DeviceOrientationData.h"
35 #include "modules/device_orientation/DeviceOrientationDispatcher.h" 35 #include "modules/device_orientation/DeviceOrientationDispatcher.h"
36 #include "modules/device_orientation/DeviceOrientationEvent.h" 36 #include "modules/device_orientation/DeviceOrientationEvent.h"
37 37
38 namespace WebCore { 38 namespace WebCore {
39 39
40 DeviceOrientationController::DeviceOrientationController(Document* document) 40 DeviceOrientationController::DeviceOrientationController(Document& document)
41 : DeviceSensorEventController(document) 41 : DeviceSensorEventController(document)
42 , DOMWindowLifecycleObserver(document->domWindow()) 42 , DOMWindowLifecycleObserver(document.domWindow())
43 { 43 {
44 } 44 }
45 45
46 DeviceOrientationController::~DeviceOrientationController() 46 DeviceOrientationController::~DeviceOrientationController()
47 { 47 {
48 stopUpdating(); 48 stopUpdating();
49 } 49 }
50 50
51 void DeviceOrientationController::didChangeDeviceOrientation(DeviceOrientationDa ta* deviceOrientationData) 51 void DeviceOrientationController::didChangeDeviceOrientation(DeviceOrientationDa ta* deviceOrientationData)
52 { 52 {
53 dispatchDeviceEvent(DeviceOrientationEvent::create(EventTypeNames::deviceori entation, deviceOrientationData)); 53 dispatchDeviceEvent(DeviceOrientationEvent::create(EventTypeNames::deviceori entation, deviceOrientationData));
54 } 54 }
55 55
56 const char* DeviceOrientationController::supplementName() 56 const char* DeviceOrientationController::supplementName()
57 { 57 {
58 return "DeviceOrientationController"; 58 return "DeviceOrientationController";
59 } 59 }
60 60
61 DeviceOrientationController* DeviceOrientationController::from(Document* documen t) 61 DeviceOrientationController& DeviceOrientationController::from(Document& documen t)
62 { 62 {
63 DeviceOrientationController* controller = static_cast<DeviceOrientationContr oller*>(DocumentSupplement::from(document, supplementName())); 63 DeviceOrientationController* controller = static_cast<DeviceOrientationContr oller*>(DocumentSupplement::from(document, supplementName()));
64 if (!controller) { 64 if (!controller) {
65 controller = new DeviceOrientationController(document); 65 controller = new DeviceOrientationController(document);
66 DocumentSupplement::provideTo(document, supplementName(), adoptPtr(contr oller)); 66 DocumentSupplement::provideTo(document, supplementName(), adoptPtr(contr oller));
67 } 67 }
68 return controller; 68 return *controller;
69 } 69 }
70 70
71 bool DeviceOrientationController::hasLastData() 71 bool DeviceOrientationController::hasLastData()
72 { 72 {
73 return DeviceOrientationDispatcher::instance().latestDeviceOrientationData() ; 73 return DeviceOrientationDispatcher::instance().latestDeviceOrientationData() ;
74 } 74 }
75 75
76 PassRefPtr<Event> DeviceOrientationController::getLastEvent() 76 PassRefPtr<Event> DeviceOrientationController::getLastEvent()
77 { 77 {
78 return DeviceOrientationEvent::create(EventTypeNames::deviceorientation, 78 return DeviceOrientationEvent::create(EventTypeNames::deviceorientation,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 } 112 }
113 } 113 }
114 114
115 void DeviceOrientationController::didRemoveAllEventListeners(DOMWindow* window) 115 void DeviceOrientationController::didRemoveAllEventListeners(DOMWindow* window)
116 { 116 {
117 stopUpdating(); 117 stopUpdating();
118 m_hasEventListener = false; 118 m_hasEventListener = false;
119 } 119 }
120 120
121 } // namespace WebCore 121 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698