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

Side by Side Diff: Source/modules/vibration/NavigatorVibration.cpp

Issue 18478003: Vibration cannot be canceled during pattern vibration. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Adoptation for recently changing of NavigatorVibration. Created 7 years, 5 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
OLDNEW
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
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;
88 return true; 89 return true;
89 } 90 }
90 91
91 void NavigatorVibration::cancelVibration() 92 void NavigatorVibration::cancelVibration()
92 { 93 {
93 m_pattern.clear(); 94 m_pattern.clear();
94 if (m_isVibrating) { 95 if (m_isVibrating) {
95 WebKit::Platform::current()->cancelVibration(); 96 WebKit::Platform::current()->cancelVibration();
96 m_isVibrating = false; 97 m_isVibrating = false;
97 m_timerStop.stop(); 98 m_timerStop.stop();
98 } 99 }
99 } 100 }
100 101
101 void NavigatorVibration::timerStartFired(Timer<NavigatorVibration>* timer) 102 void NavigatorVibration::timerStartFired(Timer<NavigatorVibration>* timer)
102 { 103 {
103 ASSERT_UNUSED(timer, timer == &m_timerStart); 104 ASSERT_UNUSED(timer, timer == &m_timerStart);
104 105
105 if (m_pattern.size()) { 106 if (m_pattern.size()) {
106 m_isVibrating = true;
107 WebKit::Platform::current()->vibrate(m_pattern[0]); 107 WebKit::Platform::current()->vibrate(m_pattern[0]);
108 m_timerStop.startOneShot(m_pattern[0] / 1000.0); 108 m_timerStop.startOneShot(m_pattern[0] / 1000.0);
109 m_pattern.remove(0); 109 m_pattern.remove(0);
110 } 110 }
111 } 111 }
112 112
113 void NavigatorVibration::timerStopFired(Timer<NavigatorVibration>* timer) 113 void NavigatorVibration::timerStopFired(Timer<NavigatorVibration>* timer)
114 { 114 {
115 ASSERT_UNUSED(timer, timer == &m_timerStop); 115 ASSERT_UNUSED(timer, timer == &m_timerStop);
116 116
117 m_isVibrating = false; 117 if (!m_pattern.size())
118 m_isVibrating = false;
118 119
119 if (m_pattern.size()) { 120 if (m_pattern.size()) {
120 m_timerStart.startOneShot(m_pattern[0] / 1000.0); 121 m_timerStart.startOneShot(m_pattern[0] / 1000.0);
121 m_pattern.remove(0); 122 m_pattern.remove(0);
122 } 123 }
123 } 124 }
124 125
125 void NavigatorVibration::pageVisibilityChanged() 126 void NavigatorVibration::pageVisibilityChanged()
126 { 127 {
127 if (page()->visibilityState() != PageVisibilityStateVisible) 128 if (page()->visibilityState() != PageVisibilityStateVisible)
(...skipping 28 matching lines...) Expand all
156 } 157 }
157 return navigatorVibration; 158 return navigatorVibration;
158 } 159 }
159 160
160 const char* NavigatorVibration::supplementName() 161 const char* NavigatorVibration::supplementName()
161 { 162 {
162 return "NavigatorVibration"; 163 return "NavigatorVibration";
163 } 164 }
164 165
165 } // namespace WebCore 166 } // namespace WebCore
OLDNEW
« Source/core/testing/Internals.cpp ('K') | « Source/modules/vibration/NavigatorVibration.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698