OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Samsung Electronics | 2 * Copyright (C) 2012 Samsung Electronics |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
8 * | 8 * |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 | 78 |
79 if (!m_pattern.size()) | 79 if (!m_pattern.size()) |
80 return true; | 80 return true; |
81 | 81 |
82 if (m_pattern.size() == 1 && !m_pattern[0]) { | 82 if (m_pattern.size() == 1 && !m_pattern[0]) { |
83 m_pattern.clear(); | 83 m_pattern.clear(); |
84 return true; | 84 return true; |
85 } | 85 } |
86 | 86 |
87 m_timerStart.startOneShot(0); | 87 m_timerStart.startOneShot(0); |
88 m_isVibrating = true; | |
89 return true; | 88 return true; |
90 } | 89 } |
91 | 90 |
92 void NavigatorVibration::cancelVibration() | 91 void NavigatorVibration::cancelVibration() |
93 { | 92 { |
94 m_pattern.clear(); | 93 m_pattern.clear(); |
95 if (m_isVibrating) { | 94 if (m_isVibrating) { |
96 WebKit::Platform::current()->cancelVibration(); | 95 WebKit::Platform::current()->cancelVibration(); |
97 m_isVibrating = false; | 96 m_isVibrating = false; |
98 m_timerStop.stop(); | 97 m_timerStop.stop(); |
99 } | 98 } |
100 } | 99 } |
101 | 100 |
102 void NavigatorVibration::timerStartFired(Timer<NavigatorVibration>* timer) | 101 void NavigatorVibration::timerStartFired(Timer<NavigatorVibration>* timer) |
103 { | 102 { |
104 ASSERT_UNUSED(timer, timer == &m_timerStart); | 103 ASSERT_UNUSED(timer, timer == &m_timerStart); |
105 | 104 |
106 if (m_pattern.size()) { | 105 if (m_pattern.size()) { |
107 m_isVibrating = true; | 106 m_isVibrating = true; |
108 WebKit::Platform::current()->vibrate(m_pattern[0]); | 107 WebKit::Platform::current()->vibrate(m_pattern[0]); |
109 m_timerStop.startOneShot(m_pattern[0] / 1000.0); | 108 m_timerStop.startOneShot(m_pattern[0] / 1000.0); |
110 m_pattern.remove(0); | 109 m_pattern.remove(0); |
111 } | 110 } |
112 } | 111 } |
113 | 112 |
114 void NavigatorVibration::timerStopFired(Timer<NavigatorVibration>* timer) | 113 void NavigatorVibration::timerStopFired(Timer<NavigatorVibration>* timer) |
115 { | 114 { |
116 ASSERT_UNUSED(timer, timer == &m_timerStop); | 115 ASSERT_UNUSED(timer, timer == &m_timerStop); |
117 | 116 |
118 if (m_pattern.isEmpty()) | 117 m_isVibrating = false; |
119 m_isVibrating = false; | |
120 | 118 |
121 if (m_pattern.size()) { | 119 if (m_pattern.size()) { |
122 m_timerStart.startOneShot(m_pattern[0] / 1000.0); | 120 m_timerStart.startOneShot(m_pattern[0] / 1000.0); |
123 m_pattern.remove(0); | 121 m_pattern.remove(0); |
124 } | 122 } |
125 } | 123 } |
126 | 124 |
127 void NavigatorVibration::pageVisibilityChanged() | 125 void NavigatorVibration::pageVisibilityChanged() |
128 { | 126 { |
129 if (page()->visibilityState() != PageVisibilityStateVisible) | 127 if (page()->visibilityState() != PageVisibilityStateVisible) |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 } | 163 } |
166 return navigatorVibration; | 164 return navigatorVibration; |
167 } | 165 } |
168 | 166 |
169 const char* NavigatorVibration::supplementName() | 167 const char* NavigatorVibration::supplementName() |
170 { | 168 { |
171 return "NavigatorVibration"; | 169 return "NavigatorVibration"; |
172 } | 170 } |
173 | 171 |
174 } // namespace WebCore | 172 } // namespace WebCore |
OLD | NEW |