OLD | NEW |
---|---|
(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 "config.h" | |
6 #include "ScreenOrientationClientMock.h" | |
7 | |
8 #include "modules/screen_orientation/ScreenOrientationController.h" | |
9 | |
10 namespace WebCore { | |
11 | |
12 ScreenOrientationClientMock::ScreenOrientationClientMock() | |
13 : m_controllerTimer(this, &ScreenOrientationClientMock::controllerTimerFired ) | |
14 , m_controller(0) | |
15 , m_orientation(OrientationPortraitPrimary) | |
16 , m_lockedOrientations(0) | |
17 { | |
18 } | |
19 | |
20 ScreenOrientationClientMock::~ScreenOrientationClientMock() | |
21 { | |
22 } | |
23 | |
24 void ScreenOrientationClientMock::setController(ScreenOrientationController* con troller) | |
25 { | |
26 ASSERT(controller && !m_controller); | |
27 m_controller = controller; | |
28 } | |
29 | |
30 void ScreenOrientationClientMock::setScreenOrientation(ScreenOrientationValue or ientation) | |
31 { | |
32 if (orientation == m_orientation) | |
33 return; | |
34 | |
35 if (!m_lockedOrientations || m_lockedOrientations & orientation) { | |
36 m_orientation = orientation; | |
37 asyncUpdateController(); | |
38 } | |
39 } | |
40 | |
41 void ScreenOrientationClientMock::asyncUpdateController() | |
42 { | |
43 ASSERT(m_controller); | |
44 if (!m_controllerTimer.isActive()) | |
45 m_controllerTimer.startOneShot(0); | |
46 } | |
47 | |
48 void ScreenOrientationClientMock::controllerTimerFired(Timer<ScreenOrientationCl ientMock>* timer) | |
49 { | |
50 ASSERT_UNUSED(timer, timer == &m_controllerTimer); | |
51 ASSERT(m_controller); | |
52 | |
53 m_controller->orientationChanged(m_orientation); | |
54 } | |
55 | |
56 bool ScreenOrientationClientMock::lockOrientation(ScreenOrientationValues orient ations) | |
57 { | |
58 m_lockedOrientations = orientations; | |
mlamouri (slow - plz ping)
2014/02/10 18:20:57
Shouldn't you change the screen orientation asynch
Inactive
2014/02/10 22:25:24
You are right, I fixed it in a later iteration, bu
| |
59 return true; | |
60 } | |
61 | |
62 void ScreenOrientationClientMock::unlockOrientation() | |
63 { | |
64 m_lockedOrientations = 0; | |
65 } | |
66 | |
67 } // namespace WebCore | |
OLD | NEW |