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

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

Issue 2245063006: Revert of Refactoring button field and its type (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix patch apply 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::Button::NoButton) 109 if (button == WebMouseEvent::ButtonNone)
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[static_cast<int>(button)]; 118 return webMouseButtonToPlatformModifier[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);
180 m_modifiers = e.modifiers; 181 m_modifiers = e.modifiers;
181 182
182 m_timestamp = e.timeStampSeconds; 183 m_timestamp = e.timeStampSeconds;
183 m_clickCount = e.clickCount; 184 m_clickCount = e.clickCount;
184 185
185 m_pointerProperties = static_cast<WebPointerProperties>(e); 186 m_pointerProperties = static_cast<WebPointerProperties>(e);
186 187
187 switch (e.type) { 188 switch (e.type) {
188 case WebInputEvent::MouseMove: 189 case WebInputEvent::MouseMove:
189 case WebInputEvent::MouseEnter: // synthesize a move event 190 case WebInputEvent::MouseEnter: // synthesize a move event
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 else if (event.type() == EventTypeNames::mouseup) 536 else if (event.type() == EventTypeNames::mouseup)
536 type = WebInputEvent::MouseUp; 537 type = WebInputEvent::MouseUp;
537 else if (event.type() == EventTypeNames::contextmenu) 538 else if (event.type() == EventTypeNames::contextmenu)
538 type = WebInputEvent::ContextMenu; 539 type = WebInputEvent::ContextMenu;
539 else 540 else
540 return; // Skip all other mouse events. 541 return; // Skip all other mouse events.
541 542
542 updateWebMouseEventFromCoreMouseEvent(event, widget, layoutItem, *this); 543 updateWebMouseEventFromCoreMouseEvent(event, widget, layoutItem, *this);
543 544
544 switch (event.button()) { 545 switch (event.button()) {
545 case short(WebPointerProperties::Button::Left): 546 case LeftButton:
546 button = WebMouseEvent::Button::Left; 547 button = WebMouseEvent::ButtonLeft;
547 break; 548 break;
548 case short(WebPointerProperties::Button::Middle): 549 case MiddleButton:
549 button = WebMouseEvent::Button::Middle; 550 button = WebMouseEvent::ButtonMiddle;
550 break; 551 break;
551 case short(WebPointerProperties::Button::Right): 552 case RightButton:
552 button = WebMouseEvent::Button::Right; 553 button = WebMouseEvent::ButtonRight;
553 break; 554 break;
554 } 555 }
555 if (event.buttonDown()) { 556 if (event.buttonDown()) {
556 switch (event.button()) { 557 switch (event.button()) {
557 case short(WebPointerProperties::Button::Left): 558 case LeftButton:
558 modifiers |= WebInputEvent::LeftButtonDown; 559 modifiers |= WebInputEvent::LeftButtonDown;
559 break; 560 break;
560 case short(WebPointerProperties::Button::Middle): 561 case MiddleButton:
561 modifiers |= WebInputEvent::MiddleButtonDown; 562 modifiers |= WebInputEvent::MiddleButtonDown;
562 break; 563 break;
563 case short(WebPointerProperties::Button::Right): 564 case RightButton:
564 modifiers |= WebInputEvent::RightButtonDown; 565 modifiers |= WebInputEvent::RightButtonDown;
565 break; 566 break;
566 } 567 }
567 } else { 568 } else
568 button = WebMouseEvent::Button::NoButton; 569 button = WebMouseEvent::ButtonNone;
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::Button::Left; 616 button = WebMouseEvent::ButtonLeft;
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