Chromium Code Reviews| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 77 | 77 |
| 78 if (!m_pattern.size()) | 78 if (!m_pattern.size()) |
| 79 return true; | 79 return true; |
| 80 | 80 |
| 81 if (m_pattern.size() == 1 && !m_pattern[0]) { | 81 if (m_pattern.size() == 1 && !m_pattern[0]) { |
| 82 m_pattern.clear(); | 82 m_pattern.clear(); |
| 83 return true; | 83 return true; |
| 84 } | 84 } |
| 85 | 85 |
| 86 m_timerStart.startOneShot(0); | 86 m_timerStart.startOneShot(0); |
| 87 m_isVibrating = true; | |
| 87 return true; | 88 return true; |
| 88 } | 89 } |
| 89 | 90 |
| 90 void NavigatorVibration::cancelVibration() | 91 void NavigatorVibration::cancelVibration() |
| 91 { | 92 { |
| 92 m_pattern.clear(); | 93 m_pattern.clear(); |
| 93 if (m_isVibrating) { | 94 if (m_isVibrating) { |
| 94 WebKit::Platform::current()->cancelVibration(); | 95 WebKit::Platform::current()->cancelVibration(); |
| 95 m_isVibrating = false; | 96 m_isVibrating = false; |
| 96 m_timerStop.stop(); | 97 m_timerStop.stop(); |
| 97 } | 98 } |
| 98 } | 99 } |
| 99 | 100 |
| 100 void NavigatorVibration::suspendVibration() | 101 void NavigatorVibration::suspendVibration() |
| 101 { | 102 { |
| 102 if (!m_isVibrating) | 103 if (!m_isVibrating) |
| 103 return; | 104 return; |
| 104 | 105 |
| 105 m_pattern.insert(0, m_timerStop.nextFireInterval()); | 106 m_pattern.insert(0, m_timerStop.nextFireInterval()); |
| 106 m_timerStop.stop(); | 107 m_timerStop.stop(); |
| 107 cancelVibration(); | 108 cancelVibration(); |
| 108 } | 109 } |
| 109 | 110 |
| 110 void NavigatorVibration::resumeVibration() | 111 void NavigatorVibration::resumeVibration() |
| 111 { | 112 { |
| 112 ASSERT(!m_timerStart.isActive()); | 113 ASSERT(!m_timerStart.isActive()); |
| 113 | 114 |
| 114 m_timerStart.startOneShot(0); | 115 m_timerStart.startOneShot(0); |
| 116 m_isVibrating = true; | |
| 115 } | 117 } |
| 116 | 118 |
| 117 void NavigatorVibration::timerStartFired(Timer<NavigatorVibration>* timer) | 119 void NavigatorVibration::timerStartFired(Timer<NavigatorVibration>* timer) |
| 118 { | 120 { |
| 119 ASSERT_UNUSED(timer, timer == &m_timerStart); | 121 ASSERT_UNUSED(timer, timer == &m_timerStart); |
| 120 | 122 |
| 121 if (m_pattern.size()) { | 123 if (m_pattern.size()) { |
| 122 m_isVibrating = true; | |
| 123 WebKit::Platform::current()->vibrate(m_pattern[0]); | 124 WebKit::Platform::current()->vibrate(m_pattern[0]); |
| 124 m_timerStop.startOneShot(m_pattern[0] / 1000.0); | 125 m_timerStop.startOneShot(m_pattern[0] / 1000.0); |
| 125 m_pattern.remove(0); | 126 m_pattern.remove(0); |
| 126 } | 127 } |
| 127 } | 128 } |
| 128 | 129 |
| 129 void NavigatorVibration::timerStopFired(Timer<NavigatorVibration>* timer) | 130 void NavigatorVibration::timerStopFired(Timer<NavigatorVibration>* timer) |
| 130 { | 131 { |
| 131 ASSERT_UNUSED(timer, timer == &m_timerStop); | 132 ASSERT_UNUSED(timer, timer == &m_timerStop); |
| 132 | 133 |
| 133 m_isVibrating = false; | |
|
Michael van Ouwerkerk
2013/07/03 10:47:55
I think you want to keep this line, but make it co
kihong
2013/07/08 10:14:06
Done.
| |
| 134 | |
| 135 if (m_pattern.size()) { | 134 if (m_pattern.size()) { |
| 136 m_timerStart.startOneShot(m_pattern[0] / 1000.0); | 135 m_timerStart.startOneShot(m_pattern[0] / 1000.0); |
| 137 m_pattern.remove(0); | 136 m_pattern.remove(0); |
| 137 if (m_pattern.isEmpty()) | |
|
Michael van Ouwerkerk
2013/07/03 10:47:55
How would this ever happen? It should not, since t
kihong
2013/07/08 10:14:06
Done.
| |
| 138 m_isVibrating = false; | |
| 138 } | 139 } |
| 139 } | 140 } |
| 140 | 141 |
| 141 bool NavigatorVibration::vibrate(Navigator* navigator, unsigned time) | 142 bool NavigatorVibration::vibrate(Navigator* navigator, unsigned time) |
| 142 { | 143 { |
| 143 VibrationPattern pattern; | 144 VibrationPattern pattern; |
| 144 pattern.append(time); | 145 pattern.append(time); |
| 145 return NavigatorVibration::vibrate(navigator, pattern); | 146 return NavigatorVibration::vibrate(navigator, pattern); |
| 146 } | 147 } |
| 147 | 148 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 165 } | 166 } |
| 166 return navigatorVibration; | 167 return navigatorVibration; |
| 167 } | 168 } |
| 168 | 169 |
| 169 const char* NavigatorVibration::supplementName() | 170 const char* NavigatorVibration::supplementName() |
| 170 { | 171 { |
| 171 return "NavigatorVibration"; | 172 return "NavigatorVibration"; |
| 172 } | 173 } |
| 173 | 174 |
| 174 } // namespace WebCore | 175 } // namespace WebCore |
| OLD | NEW |