OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "modules/screen_orientation/ScreenOrientationController.h" | 6 #include "modules/screen_orientation/ScreenOrientationController.h" |
7 | 7 |
8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
9 #include "core/events/Event.h" | 9 #include "core/events/Event.h" |
10 #include "core/frame/DOMWindow.h" | 10 #include "core/frame/DOMWindow.h" |
11 #include "core/frame/Screen.h" | 11 #include "core/frame/Screen.h" |
12 #include "modules/screen_orientation/ScreenOrientationDispatcher.h" | 12 #include "modules/screen_orientation/ScreenOrientationDispatcher.h" |
13 | 13 |
14 namespace WebCore { | 14 namespace WebCore { |
15 | 15 |
16 ScreenOrientationController::~ScreenOrientationController() | 16 ScreenOrientationController::~ScreenOrientationController() |
17 { | 17 { |
18 ScreenOrientationDispatcher::instance().removeController(this); | 18 ScreenOrientationDispatcher::instance().removeController(this); |
19 } | 19 } |
20 | 20 |
21 ScreenOrientationController* ScreenOrientationController::from(Document* documen
t) | 21 ScreenOrientationController& ScreenOrientationController::from(Document& documen
t) |
22 { | 22 { |
23 ScreenOrientationController* controller = static_cast<ScreenOrientationContr
oller*>(DocumentSupplement::from(document, supplementName())); | 23 ScreenOrientationController* controller = static_cast<ScreenOrientationContr
oller*>(DocumentSupplement::from(document, supplementName())); |
24 if (!controller) { | 24 if (!controller) { |
25 controller = new ScreenOrientationController(*document); | 25 controller = new ScreenOrientationController(document); |
26 DocumentSupplement::provideTo(document, supplementName(), adoptPtr(contr
oller)); | 26 DocumentSupplement::provideTo(document, supplementName(), adoptPtr(contr
oller)); |
27 } | 27 } |
28 return controller; | 28 return *controller; |
29 } | 29 } |
30 | 30 |
31 ScreenOrientationController::ScreenOrientationController(Document& document) | 31 ScreenOrientationController::ScreenOrientationController(Document& document) |
32 : m_document(document) | 32 : m_document(document) |
33 , m_orientation(blink::WebScreenOrientationPortraitPrimary) | 33 , m_orientation(blink::WebScreenOrientationPortraitPrimary) |
34 { | 34 { |
35 // FIXME: We should listen for screen orientation change events only when th
e page is visible. | 35 // FIXME: We should listen for screen orientation change events only when th
e page is visible. |
36 ScreenOrientationDispatcher::instance().addController(this); | 36 ScreenOrientationDispatcher::instance().addController(this); |
37 } | 37 } |
38 | 38 |
(...skipping 13 matching lines...) Expand all Loading... |
52 void ScreenOrientationController::didChangeScreenOrientation(blink::WebScreenOri
entation orientation) | 52 void ScreenOrientationController::didChangeScreenOrientation(blink::WebScreenOri
entation orientation) |
53 { | 53 { |
54 if (orientation == m_orientation) | 54 if (orientation == m_orientation) |
55 return; | 55 return; |
56 | 56 |
57 m_orientation = orientation; | 57 m_orientation = orientation; |
58 dispatchOrientationChangeEvent(); | 58 dispatchOrientationChangeEvent(); |
59 } | 59 } |
60 | 60 |
61 } // namespace WebCore | 61 } // namespace WebCore |
OLD | NEW |