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

Side by Side Diff: third_party/WebKit/Source/web/WebInputEventConversion.cpp

Issue 1878493002: ASSERT_NOT_REACHED() -> NOTREACHED() in web. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 ScrollGranularity toPlatformScrollGranularity(WebGestureEvent::ScrollUnits units ) 108 ScrollGranularity toPlatformScrollGranularity(WebGestureEvent::ScrollUnits units )
109 { 109 {
110 switch (units) { 110 switch (units) {
111 case WebGestureEvent::ScrollUnits::PrecisePixels: 111 case WebGestureEvent::ScrollUnits::PrecisePixels:
112 return ScrollGranularity::ScrollByPrecisePixel; 112 return ScrollGranularity::ScrollByPrecisePixel;
113 case WebGestureEvent::ScrollUnits::Pixels: 113 case WebGestureEvent::ScrollUnits::Pixels:
114 return ScrollGranularity::ScrollByPixel; 114 return ScrollGranularity::ScrollByPixel;
115 case WebGestureEvent::ScrollUnits::Page: 115 case WebGestureEvent::ScrollUnits::Page:
116 return ScrollGranularity::ScrollByPage; 116 return ScrollGranularity::ScrollByPage;
117 default: 117 default:
118 ASSERT_NOT_REACHED(); 118 NOTREACHED();
119 return ScrollGranularity::ScrollByPrecisePixel; 119 return ScrollGranularity::ScrollByPrecisePixel;
120 } 120 }
121 } 121 }
122 122
123 WebGestureEvent::ScrollUnits toWebGestureScrollUnits(ScrollGranularity granulari ty) 123 WebGestureEvent::ScrollUnits toWebGestureScrollUnits(ScrollGranularity granulari ty)
124 { 124 {
125 switch (granularity) { 125 switch (granularity) {
126 case ScrollGranularity::ScrollByPrecisePixel: 126 case ScrollGranularity::ScrollByPrecisePixel:
127 return WebGestureEvent::ScrollUnits::PrecisePixels; 127 return WebGestureEvent::ScrollUnits::PrecisePixels;
128 case ScrollGranularity::ScrollByPixel: 128 case ScrollGranularity::ScrollByPixel:
129 return WebGestureEvent::ScrollUnits::Pixels; 129 return WebGestureEvent::ScrollUnits::Pixels;
130 case ScrollGranularity::ScrollByPage: 130 case ScrollGranularity::ScrollByPage:
131 return WebGestureEvent::ScrollUnits::Page; 131 return WebGestureEvent::ScrollUnits::Page;
132 default: 132 default:
133 ASSERT_NOT_REACHED(); 133 NOTREACHED();
134 return WebGestureEvent::ScrollUnits::PrecisePixels; 134 return WebGestureEvent::ScrollUnits::PrecisePixels;
135 } 135 }
136 } 136 }
137 137
138 } // namespace 138 } // namespace
139 139
140 // MakePlatformMouseEvent ----------------------------------------------------- 140 // MakePlatformMouseEvent -----------------------------------------------------
141 141
142 // TODO(mustaq): Add tests for this. 142 // TODO(mustaq): Add tests for this.
143 PlatformMouseEventBuilder::PlatformMouseEventBuilder(Widget* widget, const WebMo useEvent& e) 143 PlatformMouseEventBuilder::PlatformMouseEventBuilder(Widget* widget, const WebMo useEvent& e)
(...skipping 25 matching lines...) Expand all
169 m_type = PlatformEvent::MouseReleased; 169 m_type = PlatformEvent::MouseReleased;
170 170
171 // The MouseEvent spec requires that buttons indicates the state 171 // The MouseEvent spec requires that buttons indicates the state
172 // immediately after the event takes place. To ensure consistency 172 // immediately after the event takes place. To ensure consistency
173 // between platforms here, we explicitly clear the button that is 173 // between platforms here, we explicitly clear the button that is
174 // in the process of being released. 174 // in the process of being released.
175 m_modifiers &= ~toPlatformModifierFrom(e.button); 175 m_modifiers &= ~toPlatformModifierFrom(e.button);
176 break; 176 break;
177 177
178 default: 178 default:
179 ASSERT_NOT_REACHED(); 179 NOTREACHED();
180 } 180 }
181 } 181 }
182 182
183 // PlatformWheelEventBuilder -------------------------------------------------- 183 // PlatformWheelEventBuilder --------------------------------------------------
184 184
185 PlatformWheelEventBuilder::PlatformWheelEventBuilder(Widget* widget, const WebMo useWheelEvent& e) 185 PlatformWheelEventBuilder::PlatformWheelEventBuilder(Widget* widget, const WebMo useWheelEvent& e)
186 { 186 {
187 m_position = widget->convertFromRootFrame(flooredIntPoint(convertHitPointToR ootFrame(widget, FloatPoint(e.x, e.y)))); 187 m_position = widget->convertFromRootFrame(flooredIntPoint(convertHitPointToR ootFrame(widget, FloatPoint(e.x, e.y))));
188 m_globalPosition = IntPoint(e.globalX, e.globalY); 188 m_globalPosition = IntPoint(e.globalX, e.globalY);
189 m_deltaX = scaleDeltaToWindow(widget, e.deltaX); 189 m_deltaX = scaleDeltaToWindow(widget, e.deltaX);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 m_type = PlatformEvent::GestureShowPress; 264 m_type = PlatformEvent::GestureShowPress;
265 m_area = expandedIntSize(scaleSizeToWindow(widget, FloatSize(e.data.show Press.width, e.data.showPress.height))); 265 m_area = expandedIntSize(scaleSizeToWindow(widget, FloatSize(e.data.show Press.width, e.data.showPress.height)));
266 break; 266 break;
267 case WebInputEvent::GestureTapCancel: 267 case WebInputEvent::GestureTapCancel:
268 m_type = PlatformEvent::GestureTapDownCancel; 268 m_type = PlatformEvent::GestureTapDownCancel;
269 break; 269 break;
270 case WebInputEvent::GestureDoubleTap: 270 case WebInputEvent::GestureDoubleTap:
271 // DoubleTap gesture is now handled as PlatformEvent::GestureTap with ta p_count = 2. So no 271 // DoubleTap gesture is now handled as PlatformEvent::GestureTap with ta p_count = 2. So no
272 // need to convert to a Platfrom DoubleTap gesture. But in WebViewImpl:: handleGestureEvent 272 // need to convert to a Platfrom DoubleTap gesture. But in WebViewImpl:: handleGestureEvent
273 // all WebGestureEvent are converted to PlatformGestureEvent, for comple teness and not reach 273 // all WebGestureEvent are converted to PlatformGestureEvent, for comple teness and not reach
274 // the ASSERT_NOT_REACHED() at the end, convert the DoubleTap to a NoTyp e. 274 // the NOTREACHED() at the end, convert the DoubleTap to a NoType.
275 m_type = PlatformEvent::NoType; 275 m_type = PlatformEvent::NoType;
276 break; 276 break;
277 case WebInputEvent::GestureTwoFingerTap: 277 case WebInputEvent::GestureTwoFingerTap:
278 m_type = PlatformEvent::GestureTwoFingerTap; 278 m_type = PlatformEvent::GestureTwoFingerTap;
279 m_area = expandedIntSize(scaleSizeToWindow(widget, FloatSize(e.data.twoF ingerTap.firstFingerWidth, e.data.twoFingerTap.firstFingerHeight))); 279 m_area = expandedIntSize(scaleSizeToWindow(widget, FloatSize(e.data.twoF ingerTap.firstFingerWidth, e.data.twoFingerTap.firstFingerHeight)));
280 break; 280 break;
281 case WebInputEvent::GestureLongPress: 281 case WebInputEvent::GestureLongPress:
282 m_type = PlatformEvent::GestureLongPress; 282 m_type = PlatformEvent::GestureLongPress;
283 m_area = expandedIntSize(scaleSizeToWindow(widget, FloatSize(e.data.long Press.width, e.data.longPress.height))); 283 m_area = expandedIntSize(scaleSizeToWindow(widget, FloatSize(e.data.long Press.width, e.data.longPress.height)));
284 break; 284 break;
285 case WebInputEvent::GestureLongTap: 285 case WebInputEvent::GestureLongTap:
286 m_type = PlatformEvent::GestureLongTap; 286 m_type = PlatformEvent::GestureLongTap;
287 m_area = expandedIntSize(scaleSizeToWindow(widget, FloatSize(e.data.long Press.width, e.data.longPress.height))); 287 m_area = expandedIntSize(scaleSizeToWindow(widget, FloatSize(e.data.long Press.width, e.data.longPress.height)));
288 break; 288 break;
289 case WebInputEvent::GesturePinchBegin: 289 case WebInputEvent::GesturePinchBegin:
290 m_type = PlatformEvent::GesturePinchBegin; 290 m_type = PlatformEvent::GesturePinchBegin;
291 break; 291 break;
292 case WebInputEvent::GesturePinchEnd: 292 case WebInputEvent::GesturePinchEnd:
293 m_type = PlatformEvent::GesturePinchEnd; 293 m_type = PlatformEvent::GesturePinchEnd;
294 break; 294 break;
295 case WebInputEvent::GesturePinchUpdate: 295 case WebInputEvent::GesturePinchUpdate:
296 m_type = PlatformEvent::GesturePinchUpdate; 296 m_type = PlatformEvent::GesturePinchUpdate;
297 m_data.m_pinchUpdate.m_scale = e.data.pinchUpdate.scale; 297 m_data.m_pinchUpdate.m_scale = e.data.pinchUpdate.scale;
298 break; 298 break;
299 default: 299 default:
300 ASSERT_NOT_REACHED(); 300 NOTREACHED();
301 } 301 }
302 m_position = widget->convertFromRootFrame(flooredIntPoint(convertHitPointToR ootFrame(widget, FloatPoint(e.x, e.y)))); 302 m_position = widget->convertFromRootFrame(flooredIntPoint(convertHitPointToR ootFrame(widget, FloatPoint(e.x, e.y))));
303 m_globalPosition = IntPoint(e.globalX, e.globalY); 303 m_globalPosition = IntPoint(e.globalX, e.globalY);
304 m_timestamp = e.timeStampSeconds; 304 m_timestamp = e.timeStampSeconds;
305 m_modifiers = e.modifiers; 305 m_modifiers = e.modifiers;
306 switch (e.sourceDevice) { 306 switch (e.sourceDevice) {
307 case WebGestureDeviceTouchpad: 307 case WebGestureDeviceTouchpad:
308 m_source = PlatformGestureSourceTouchpad; 308 m_source = PlatformGestureSourceTouchpad;
309 break; 309 break;
310 case WebGestureDeviceTouchscreen: 310 case WebGestureDeviceTouchscreen:
311 m_source = PlatformGestureSourceTouchscreen; 311 m_source = PlatformGestureSourceTouchscreen;
312 break; 312 break;
313 case WebGestureDeviceUninitialized: 313 case WebGestureDeviceUninitialized:
314 ASSERT_NOT_REACHED(); 314 NOTREACHED();
315 } 315 }
316 } 316 }
317 317
318 // MakePlatformKeyboardEvent -------------------------------------------------- 318 // MakePlatformKeyboardEvent --------------------------------------------------
319 319
320 inline PlatformEvent::EventType toPlatformKeyboardEventType(WebInputEvent::Type type) 320 inline PlatformEvent::EventType toPlatformKeyboardEventType(WebInputEvent::Type type)
321 { 321 {
322 switch (type) { 322 switch (type) {
323 case WebInputEvent::KeyUp: 323 case WebInputEvent::KeyUp:
324 return PlatformEvent::KeyUp; 324 return PlatformEvent::KeyUp;
325 case WebInputEvent::KeyDown: 325 case WebInputEvent::KeyDown:
326 return PlatformEvent::KeyDown; 326 return PlatformEvent::KeyDown;
327 case WebInputEvent::RawKeyDown: 327 case WebInputEvent::RawKeyDown:
328 return PlatformEvent::RawKeyDown; 328 return PlatformEvent::RawKeyDown;
329 case WebInputEvent::Char: 329 case WebInputEvent::Char:
330 return PlatformEvent::Char; 330 return PlatformEvent::Char;
331 default: 331 default:
332 ASSERT_NOT_REACHED(); 332 NOTREACHED();
333 } 333 }
334 return PlatformEvent::KeyDown; 334 return PlatformEvent::KeyDown;
335 } 335 }
336 336
337 PlatformKeyboardEventBuilder::PlatformKeyboardEventBuilder(const WebKeyboardEven t& e) 337 PlatformKeyboardEventBuilder::PlatformKeyboardEventBuilder(const WebKeyboardEven t& e)
338 { 338 {
339 m_type = toPlatformKeyboardEventType(e.type); 339 m_type = toPlatformKeyboardEventType(e.type);
340 m_text = String(e.text); 340 m_text = String(e.text);
341 m_unmodifiedText = String(e.unmodifiedText); 341 m_unmodifiedText = String(e.unmodifiedText);
342 m_keyIdentifier = String(e.keyIdentifier); 342 m_keyIdentifier = String(e.keyIdentifier);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 switch (type) { 387 switch (type) {
388 case WebInputEvent::TouchStart: 388 case WebInputEvent::TouchStart:
389 return PlatformEvent::TouchStart; 389 return PlatformEvent::TouchStart;
390 case WebInputEvent::TouchMove: 390 case WebInputEvent::TouchMove:
391 return PlatformEvent::TouchMove; 391 return PlatformEvent::TouchMove;
392 case WebInputEvent::TouchEnd: 392 case WebInputEvent::TouchEnd:
393 return PlatformEvent::TouchEnd; 393 return PlatformEvent::TouchEnd;
394 case WebInputEvent::TouchCancel: 394 case WebInputEvent::TouchCancel:
395 return PlatformEvent::TouchCancel; 395 return PlatformEvent::TouchCancel;
396 default: 396 default:
397 ASSERT_NOT_REACHED(); 397 NOTREACHED();
398 } 398 }
399 return PlatformEvent::TouchStart; 399 return PlatformEvent::TouchStart;
400 } 400 }
401 401
402 inline PlatformTouchPoint::TouchState toPlatformTouchPointState(const WebTouchPo int::State state) 402 inline PlatformTouchPoint::TouchState toPlatformTouchPointState(const WebTouchPo int::State state)
403 { 403 {
404 switch (state) { 404 switch (state) {
405 case WebTouchPoint::StateReleased: 405 case WebTouchPoint::StateReleased:
406 return PlatformTouchPoint::TouchReleased; 406 return PlatformTouchPoint::TouchReleased;
407 case WebTouchPoint::StatePressed: 407 case WebTouchPoint::StatePressed:
408 return PlatformTouchPoint::TouchPressed; 408 return PlatformTouchPoint::TouchPressed;
409 case WebTouchPoint::StateMoved: 409 case WebTouchPoint::StateMoved:
410 return PlatformTouchPoint::TouchMoved; 410 return PlatformTouchPoint::TouchMoved;
411 case WebTouchPoint::StateStationary: 411 case WebTouchPoint::StateStationary:
412 return PlatformTouchPoint::TouchStationary; 412 return PlatformTouchPoint::TouchStationary;
413 case WebTouchPoint::StateCancelled: 413 case WebTouchPoint::StateCancelled:
414 return PlatformTouchPoint::TouchCancelled; 414 return PlatformTouchPoint::TouchCancelled;
415 case WebTouchPoint::StateUndefined: 415 case WebTouchPoint::StateUndefined:
416 ASSERT_NOT_REACHED(); 416 NOTREACHED();
417 } 417 }
418 return PlatformTouchPoint::TouchReleased; 418 return PlatformTouchPoint::TouchReleased;
419 } 419 }
420 420
421 inline WebTouchPoint::State toWebTouchPointState(const AtomicString& type) 421 inline WebTouchPoint::State toWebTouchPointState(const AtomicString& type)
422 { 422 {
423 if (type == EventTypeNames::touchend) 423 if (type == EventTypeNames::touchend)
424 return WebTouchPoint::StateReleased; 424 return WebTouchPoint::StateReleased;
425 if (type == EventTypeNames::touchcancel) 425 if (type == EventTypeNames::touchcancel)
426 return WebTouchPoint::StateCancelled; 426 return WebTouchPoint::StateCancelled;
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 { 703 {
704 if (event.type() == EventTypeNames::touchstart) 704 if (event.type() == EventTypeNames::touchstart)
705 type = TouchStart; 705 type = TouchStart;
706 else if (event.type() == EventTypeNames::touchmove) 706 else if (event.type() == EventTypeNames::touchmove)
707 type = TouchMove; 707 type = TouchMove;
708 else if (event.type() == EventTypeNames::touchend) 708 else if (event.type() == EventTypeNames::touchend)
709 type = TouchEnd; 709 type = TouchEnd;
710 else if (event.type() == EventTypeNames::touchcancel) 710 else if (event.type() == EventTypeNames::touchcancel)
711 type = TouchCancel; 711 type = TouchCancel;
712 else { 712 else {
713 ASSERT_NOT_REACHED(); 713 NOTREACHED();
714 type = Undefined; 714 type = Undefined;
715 return; 715 return;
716 } 716 }
717 717
718 timeStampSeconds = event.platformTimeStamp(); 718 timeStampSeconds = event.platformTimeStamp();
719 modifiers = event.modifiers(); 719 modifiers = event.modifiers();
720 cancelable = event.cancelable(); 720 cancelable = event.cancelable();
721 movedBeyondSlopRegion = event.causesScrollingIfUncanceled(); 721 movedBeyondSlopRegion = event.causesScrollingIfUncanceled();
722 722
723 // Currently touches[] is empty, add stationary points as-is. 723 // Currently touches[] is empty, add stationary points as-is.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 y = localPoint.y(); 778 y = localPoint.y();
779 779
780 switch (event.source()) { 780 switch (event.source()) {
781 case GestureSourceTouchpad: 781 case GestureSourceTouchpad:
782 sourceDevice = WebGestureDeviceTouchpad; 782 sourceDevice = WebGestureDeviceTouchpad;
783 break; 783 break;
784 case GestureSourceTouchscreen: 784 case GestureSourceTouchscreen:
785 sourceDevice = WebGestureDeviceTouchscreen; 785 sourceDevice = WebGestureDeviceTouchscreen;
786 break; 786 break;
787 case GestureSourceUninitialized: 787 case GestureSourceUninitialized:
788 ASSERT_NOT_REACHED(); 788 NOTREACHED();
789 } 789 }
790 } 790 }
791 791
792 } // namespace blink 792 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebIDBKey.cpp ('k') | third_party/WebKit/Source/web/WebLocalFrameImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698