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

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

Issue 2227563003: Refactoring button field and its type (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix new instances Created 4 years, 4 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 static_assert(PlatformEvent::DispatchType::ListenersNonBlockingPassive == st atic_cast<PlatformEvent::DispatchType>(WebInputEvent::DispatchType::ListenersNon BlockingPassive), 99 static_assert(PlatformEvent::DispatchType::ListenersNonBlockingPassive == st atic_cast<PlatformEvent::DispatchType>(WebInputEvent::DispatchType::ListenersNon BlockingPassive),
100 "Dispatch Types not equal"); 100 "Dispatch Types not equal");
101 static_assert(PlatformEvent::DispatchType::ListenersForcedNonBlockingPassive == static_cast<PlatformEvent::DispatchType>(WebInputEvent::DispatchType::Listen ersForcedNonBlockingPassive), 101 static_assert(PlatformEvent::DispatchType::ListenersForcedNonBlockingPassive == static_cast<PlatformEvent::DispatchType>(WebInputEvent::DispatchType::Listen ersForcedNonBlockingPassive),
102 "Dispatch Types not equal"); 102 "Dispatch Types not equal");
103 103
104 return static_cast<PlatformEvent::DispatchType>(type); 104 return static_cast<PlatformEvent::DispatchType>(type);
105 } 105 }
106 106
107 unsigned toPlatformModifierFrom(WebMouseEvent::Button button) 107 unsigned toPlatformModifierFrom(WebMouseEvent::Button button)
108 { 108 {
109 if (button == WebMouseEvent::ButtonNone) 109 if (button == WebMouseEvent::Button::NoButton)
110 return 0; 110 return 0;
111 111
112 unsigned webMouseButtonToPlatformModifier[] = { 112 unsigned webMouseButtonToPlatformModifier[] = {
113 PlatformEvent::LeftButtonDown, 113 PlatformEvent::LeftButtonDown,
114 PlatformEvent::MiddleButtonDown, 114 PlatformEvent::MiddleButtonDown,
115 PlatformEvent::RightButtonDown 115 PlatformEvent::RightButtonDown
116 }; 116 };
117 117
118 return webMouseButtonToPlatformModifier[button]; 118 return webMouseButtonToPlatformModifier[static_cast<int>(button)];
119 } 119 }
120 120
121 ScrollGranularity toPlatformScrollGranularity(WebGestureEvent::ScrollUnits units ) 121 ScrollGranularity toPlatformScrollGranularity(WebGestureEvent::ScrollUnits units )
122 { 122 {
123 switch (units) { 123 switch (units) {
124 case WebGestureEvent::ScrollUnits::PrecisePixels: 124 case WebGestureEvent::ScrollUnits::PrecisePixels:
125 return ScrollGranularity::ScrollByPrecisePixel; 125 return ScrollGranularity::ScrollByPrecisePixel;
126 case WebGestureEvent::ScrollUnits::Pixels: 126 case WebGestureEvent::ScrollUnits::Pixels:
127 return ScrollGranularity::ScrollByPixel; 127 return ScrollGranularity::ScrollByPixel;
128 case WebGestureEvent::ScrollUnits::Page: 128 case WebGestureEvent::ScrollUnits::Page:
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 // MakePlatformMouseEvent ----------------------------------------------------- 170 // MakePlatformMouseEvent -----------------------------------------------------
171 171
172 // TODO(mustaq): Add tests for this. 172 // TODO(mustaq): Add tests for this.
173 PlatformMouseEventBuilder::PlatformMouseEventBuilder(Widget* widget, const WebMo useEvent& e) 173 PlatformMouseEventBuilder::PlatformMouseEventBuilder(Widget* widget, const WebMo useEvent& e)
174 { 174 {
175 // FIXME: Widget is always toplevel, unless it's a popup. We may be able 175 // FIXME: Widget is always toplevel, unless it's a popup. We may be able
176 // to get rid of this once we abstract popups into a WebKit API. 176 // to get rid of this once we abstract popups into a WebKit API.
177 m_position = widget->convertFromRootFrame(flooredIntPoint(convertHitPointToR ootFrame(widget, IntPoint(e.x, e.y)))); 177 m_position = widget->convertFromRootFrame(flooredIntPoint(convertHitPointToR ootFrame(widget, IntPoint(e.x, e.y))));
178 m_globalPosition = IntPoint(e.globalX, e.globalY); 178 m_globalPosition = IntPoint(e.globalX, e.globalY);
179 m_movementDelta = IntPoint(scaleDeltaToWindow(widget, e.movementX), scaleDel taToWindow(widget, e.movementY)); 179 m_movementDelta = IntPoint(scaleDeltaToWindow(widget, e.movementX), scaleDel taToWindow(widget, e.movementY));
180 m_button = static_cast<MouseButton>(e.button);
181 m_modifiers = e.modifiers; 180 m_modifiers = e.modifiers;
182 181
183 m_timestamp = e.timeStampSeconds; 182 m_timestamp = e.timeStampSeconds;
184 m_clickCount = e.clickCount; 183 m_clickCount = e.clickCount;
185 184
186 m_pointerProperties = static_cast<WebPointerProperties>(e); 185 m_pointerProperties = static_cast<WebPointerProperties>(e);
187 186
188 switch (e.type) { 187 switch (e.type) {
189 case WebInputEvent::MouseMove: 188 case WebInputEvent::MouseMove:
190 case WebInputEvent::MouseEnter: // synthesize a move event 189 case WebInputEvent::MouseEnter: // synthesize a move event
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 else if (event.type() == EventTypeNames::mouseup) 535 else if (event.type() == EventTypeNames::mouseup)
537 type = WebInputEvent::MouseUp; 536 type = WebInputEvent::MouseUp;
538 else if (event.type() == EventTypeNames::contextmenu) 537 else if (event.type() == EventTypeNames::contextmenu)
539 type = WebInputEvent::ContextMenu; 538 type = WebInputEvent::ContextMenu;
540 else 539 else
541 return; // Skip all other mouse events. 540 return; // Skip all other mouse events.
542 541
543 updateWebMouseEventFromCoreMouseEvent(event, widget, layoutItem, *this); 542 updateWebMouseEventFromCoreMouseEvent(event, widget, layoutItem, *this);
544 543
545 switch (event.button()) { 544 switch (event.button()) {
546 case LeftButton: 545 case short(WebPointerProperties::Button::Left):
547 button = WebMouseEvent::ButtonLeft; 546 button = WebMouseEvent::Button::Left;
548 break; 547 break;
549 case MiddleButton: 548 case short(WebPointerProperties::Button::Middle):
550 button = WebMouseEvent::ButtonMiddle; 549 button = WebMouseEvent::Button::Middle;
551 break; 550 break;
552 case RightButton: 551 case short(WebPointerProperties::Button::Right):
553 button = WebMouseEvent::ButtonRight; 552 button = WebMouseEvent::Button::Right;
554 break; 553 break;
555 } 554 }
556 if (event.buttonDown()) { 555 if (event.buttonDown()) {
557 switch (event.button()) { 556 switch (event.button()) {
558 case LeftButton: 557 case short(WebPointerProperties::Button::Left):
559 modifiers |= WebInputEvent::LeftButtonDown; 558 modifiers |= WebInputEvent::LeftButtonDown;
560 break; 559 break;
561 case MiddleButton: 560 case short(WebPointerProperties::Button::Middle):
562 modifiers |= WebInputEvent::MiddleButtonDown; 561 modifiers |= WebInputEvent::MiddleButtonDown;
563 break; 562 break;
564 case RightButton: 563 case short(WebPointerProperties::Button::Right):
565 modifiers |= WebInputEvent::RightButtonDown; 564 modifiers |= WebInputEvent::RightButtonDown;
566 break; 565 break;
567 } 566 }
568 } else 567 } else {
569 button = WebMouseEvent::ButtonNone; 568 button = WebMouseEvent::Button::NoButton;
569 }
570 movementX = event.movementX(); 570 movementX = event.movementX();
571 movementY = event.movementY(); 571 movementY = event.movementY();
572 clickCount = event.detail(); 572 clickCount = event.detail();
573 573
574 pointerType = WebPointerProperties::PointerType::Mouse; 574 pointerType = WebPointerProperties::PointerType::Mouse;
575 } 575 }
576 576
577 // Generate a synthetic WebMouseEvent given a TouchEvent (eg. for emulating a mo use 577 // Generate a synthetic WebMouseEvent given a TouchEvent (eg. for emulating a mo use
578 // with touch input for plugins that don't support touch input). 578 // with touch input for plugins that don't support touch input).
579 WebMouseEventBuilder::WebMouseEventBuilder(const Widget* widget, const LayoutIte m layoutItem, const TouchEvent& event) 579 WebMouseEventBuilder::WebMouseEventBuilder(const Widget* widget, const LayoutIte m layoutItem, const TouchEvent& event)
(...skipping 26 matching lines...) Expand all
606 // FIXME: if view == nullptr, pointInRootFrame will really be pointInRootCon tent. 606 // FIXME: if view == nullptr, pointInRootFrame will really be pointInRootCon tent.
607 IntPoint pointInRootFrame = roundedIntPoint(touch->absoluteLocation()); 607 IntPoint pointInRootFrame = roundedIntPoint(touch->absoluteLocation());
608 if (view) 608 if (view)
609 pointInRootFrame = view->contentsToRootFrame(pointInRootFrame); 609 pointInRootFrame = view->contentsToRootFrame(pointInRootFrame);
610 IntPoint screenPoint = roundedIntPoint(touch->screenLocation()); 610 IntPoint screenPoint = roundedIntPoint(touch->screenLocation());
611 globalX = screenPoint.x(); 611 globalX = screenPoint.x();
612 globalY = screenPoint.y(); 612 globalY = screenPoint.y();
613 windowX = pointInRootFrame.x(); 613 windowX = pointInRootFrame.x();
614 windowY = pointInRootFrame.y(); 614 windowY = pointInRootFrame.y();
615 615
616 button = WebMouseEvent::ButtonLeft; 616 button = WebMouseEvent::Button::Left;
617 modifiers |= WebInputEvent::LeftButtonDown; 617 modifiers |= WebInputEvent::LeftButtonDown;
618 clickCount = (type == MouseDown || type == MouseUp); 618 clickCount = (type == MouseDown || type == MouseUp);
619 619
620 IntPoint localPoint = convertAbsoluteLocationForLayoutObject(touch->absolute Location(), layoutItem); 620 IntPoint localPoint = convertAbsoluteLocationForLayoutObject(touch->absolute Location(), layoutItem);
621 x = localPoint.x(); 621 x = localPoint.x();
622 y = localPoint.y(); 622 y = localPoint.y();
623 623
624 pointerType = WebPointerProperties::PointerType::Touch; 624 pointerType = WebPointerProperties::PointerType::Touch;
625 } 625 }
626 626
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 break; 818 break;
819 case GestureSourceTouchscreen: 819 case GestureSourceTouchscreen:
820 sourceDevice = WebGestureDeviceTouchscreen; 820 sourceDevice = WebGestureDeviceTouchscreen;
821 break; 821 break;
822 case GestureSourceUninitialized: 822 case GestureSourceUninitialized:
823 NOTREACHED(); 823 NOTREACHED();
824 } 824 }
825 } 825 }
826 826
827 } // namespace blink 827 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebFrameWidgetImpl.cpp ('k') | third_party/WebKit/Source/web/WebViewImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698