Changeset 142571 in webkit
- Timestamp:
- Feb 11, 2013, 8:23:05 PM (12 years ago)
- Location:
- trunk/Source/WebKit/chromium
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/chromium/ChangeLog
r142569 r142571 1 2013-02-11 Alexandre Elias <aelias@chromium.org> 2 3 [chromium] Apply page scale to all WebInputEvent types 4 https://bugs.webkit.org/show_bug.cgi?id=109370 5 6 Reviewed by James Robinson. 7 8 Previously we only adjusted a few common input event types by page 9 scale, but in fact almost every position and size in WebInputEvents 10 requires it. 11 12 I also took the opportunity to change some WebGestureEvent members to 13 floats (which I checked causes no warnings in Chromium-side code with 14 GCC or Clang). 15 16 New WebInputEventConversionTest: InputEventsScaling 17 18 * public/WebInputEvent.h: 19 (WebKit::WebGestureEvent::WebGestureEvent): 20 * src/WebInputEventConversion.cpp: 21 (WebKit::widgetScaleFactor): 22 (WebKit): 23 (WebKit::PlatformMouseEventBuilder::PlatformMouseEventBuilder): 24 (WebKit::PlatformWheelEventBuilder::PlatformWheelEventBuilder): 25 (WebKit::PlatformGestureEventBuilder::PlatformGestureEventBuilder): 26 (WebKit::PlatformTouchPointBuilder::PlatformTouchPointBuilder): 27 (WebKit::updateWebMouseEventFromWebCoreMouseEvent): 28 (WebKit::WebMouseEventBuilder::WebMouseEventBuilder): 29 (WebKit::addTouchPoints): 30 (WebKit::WebTouchEventBuilder::WebTouchEventBuilder): 31 (WebKit::WebGestureEventBuilder::WebGestureEventBuilder): 32 * src/WebViewImpl.cpp: 33 (WebKit::WebViewImpl::handleGestureEvent): 34 (WebKit::WebViewImpl::hasTouchEventHandlersAt): 35 (WebKit::WebViewImpl::handleInputEvent): 36 * tests/WebInputEventConversionTest.cpp: 37 (WebCore::TEST): 38 (WebCore): 39 1 40 2013-02-11 Sheriff Bot <webkit.review.bot@gmail.com> 2 41 -
trunk/Source/WebKit/chromium/public/WebInputEvent.h
r142057 r142571 408 408 struct { 409 409 int tapCount; 410 int width;411 int height;410 float width; 411 float height; 412 412 } tap; 413 413 414 414 struct { 415 int width;416 int height;415 float width; 416 float height; 417 417 } tapDown; 418 418 419 419 struct { 420 int width;421 int height;420 float width; 421 float height; 422 422 } longPress; 423 423 424 424 struct { 425 int firstFingerWidth;426 int firstFingerHeight;425 float firstFingerWidth; 426 float firstFingerHeight; 427 427 } twoFingerTap; 428 428 … … 444 444 float scale; 445 445 } pinchUpdate; 446 } data; 446 } data; 447 447 448 448 WebGestureEvent(unsigned sizeParam = sizeof(WebGestureEvent)) … … 453 453 , globalY(0) 454 454 { 455 memset(&data, 0, sizeof(data));455 memset(&data, 0, sizeof(data)); 456 456 } 457 457 }; -
trunk/Source/WebKit/chromium/src/WebInputEventConversion.cpp
r142057 r142571 55 55 static const double millisPerSecond = 1000.0; 56 56 57 static float widgetScaleFactor(const Widget* widget) 58 { 59 if (!widget) 60 return 1; 61 62 ScrollView* rootView = widget->root(); 63 if (!rootView) 64 return 1; 65 66 return rootView->visibleContentScaleFactor(); 67 } 68 57 69 // MakePlatformMouseEvent ----------------------------------------------------- 58 70 59 71 PlatformMouseEventBuilder::PlatformMouseEventBuilder(Widget* widget, const WebMouseEvent& e) 60 72 { 73 float scale = widgetScaleFactor(widget); 61 74 // FIXME: widget is always toplevel, unless it's a popup. We may be able 62 75 // to get rid of this once we abstract popups into a WebKit API. 63 m_position = widget->convertFromContainingWindow(IntPoint(e.x , e.y));76 m_position = widget->convertFromContainingWindow(IntPoint(e.x / scale, e.y / scale)); 64 77 m_globalPosition = IntPoint(e.globalX, e.globalY); 65 78 #if ENABLE(POINTER_LOCK) 66 m_movementDelta = IntPoint(e.movementX , e.movementY);79 m_movementDelta = IntPoint(e.movementX / scale, e.movementY / scale); 67 80 #endif 68 81 m_button = static_cast<MouseButton>(e.button); … … 105 118 PlatformWheelEventBuilder::PlatformWheelEventBuilder(Widget* widget, const WebMouseWheelEvent& e) 106 119 { 107 m_position = widget->convertFromContainingWindow(IntPoint(e.x, e.y)); 120 float scale = widgetScaleFactor(widget); 121 m_position = widget->convertFromContainingWindow(IntPoint(e.x / scale, e.y / scale)); 108 122 m_globalPosition = IntPoint(e.globalX, e.globalY); 109 123 m_deltaX = e.deltaX; … … 142 156 PlatformGestureEventBuilder::PlatformGestureEventBuilder(Widget* widget, const WebGestureEvent& e) 143 157 { 158 float scale = widgetScaleFactor(widget); 144 159 switch (e.type) { 145 160 case WebInputEvent::GestureScrollBegin: … … 151 166 case WebInputEvent::GestureScrollUpdate: 152 167 m_type = PlatformEvent::GestureScrollUpdate; 153 m_deltaX = e.data.scrollUpdate.deltaX ;154 m_deltaY = e.data.scrollUpdate.deltaY ;168 m_deltaX = e.data.scrollUpdate.deltaX / scale; 169 m_deltaY = e.data.scrollUpdate.deltaY / scale; 155 170 break; 156 171 case WebInputEvent::GestureScrollUpdateWithoutPropagation: 157 172 m_type = PlatformEvent::GestureScrollUpdateWithoutPropagation; 158 m_deltaX = e.data.scrollUpdate.deltaX ;159 m_deltaY = e.data.scrollUpdate.deltaY ;173 m_deltaX = e.data.scrollUpdate.deltaX / scale; 174 m_deltaY = e.data.scrollUpdate.deltaY / scale; 160 175 break; 161 176 case WebInputEvent::GestureTap: 162 177 m_type = PlatformEvent::GestureTap; 163 m_area = IntSize(e.data.tap.width, e.data.tap.height);178 m_area = expandedIntSize(FloatSize(e.data.tap.width / scale, e.data.tap.height / scale)); 164 179 // FIXME: PlatformGestureEvent deltaX is overloaded - wkb.ug/93123 165 180 m_deltaX = static_cast<int>(e.data.tap.tapCount); … … 167 182 case WebInputEvent::GestureTapDown: 168 183 m_type = PlatformEvent::GestureTapDown; 169 m_area = IntSize(e.data.tapDown.width, e.data.tapDown.height);184 m_area = expandedIntSize(FloatSize(e.data.tapDown.width / scale, e.data.tapDown.height / scale)); 170 185 break; 171 186 case WebInputEvent::GestureTapCancel: … … 177 192 case WebInputEvent::GestureTwoFingerTap: 178 193 m_type = PlatformEvent::GestureTwoFingerTap; 179 m_area = IntSize(e.data.twoFingerTap.firstFingerWidth, e.data.twoFingerTap.firstFingerHeight);194 m_area = expandedIntSize(FloatSize(e.data.twoFingerTap.firstFingerWidth / scale, e.data.twoFingerTap.firstFingerHeight / scale)); 180 195 break; 181 196 case WebInputEvent::GestureLongPress: 182 197 m_type = PlatformEvent::GestureLongPress; 183 m_area = IntSize(e.data.longPress.width, e.data.longPress.height);198 m_area = expandedIntSize(FloatSize(e.data.longPress.width / scale, e.data.longPress.height / scale)); 184 199 break; 185 200 case WebInputEvent::GestureLongTap: 186 201 m_type = PlatformEvent::GestureLongTap; 187 m_area = IntSize(e.data.longPress.width, e.data.longPress.height);202 m_area = expandedIntSize(FloatSize(e.data.longPress.width / scale, e.data.longPress.height / scale)); 188 203 break; 189 204 case WebInputEvent::GesturePinchBegin: … … 201 216 ASSERT_NOT_REACHED(); 202 217 } 203 m_position = widget->convertFromContainingWindow(IntPoint(e.x , e.y));218 m_position = widget->convertFromContainingWindow(IntPoint(e.x / scale, e.y / scale)); 204 219 m_globalPosition = IntPoint(e.globalX, e.globalY); 205 220 m_timestamp = e.timeStampSeconds; … … 363 378 PlatformTouchPointBuilder::PlatformTouchPointBuilder(Widget* widget, const WebTouchPoint& point) 364 379 { 380 float scale = widgetScaleFactor(widget); 365 381 m_id = point.id; 366 382 m_state = toPlatformTouchPointState(point.state); 367 m_pos = widget->convertFromContainingWindow( point.position);383 m_pos = widget->convertFromContainingWindow(IntPoint(point.position.x / scale, point.position.y / scale)); 368 384 m_screenPos = point.screenPosition; 369 m_radiusY = point.radiusY ;370 m_radiusX = point.radiusX ;385 m_radiusY = point.radiusY / scale; 386 m_radiusX = point.radiusX / scale; 371 387 m_rotationAngle = point.rotationAngle; 372 388 m_force = point.force; … … 415 431 static void updateWebMouseEventFromWebCoreMouseEvent(const MouseRelatedEvent& event, const Widget& widget, const WebCore::RenderObject& renderObject, WebMouseEvent& webEvent) 416 432 { 433 float scale = widgetScaleFactor(&widget); 417 434 webEvent.timeStampSeconds = event.timeStamp() / millisPerSecond; 418 435 webEvent.modifiers = getWebInputModifiers(event); 419 436 420 ScrollView* view = widget. parent();437 ScrollView* view = widget.root(); 421 438 IntPoint windowPoint = view->contentsToWindow(IntPoint(event.absoluteLocation().x(), event.absoluteLocation().y())); 422 439 webEvent.globalX = event.screenX(); 423 440 webEvent.globalY = event.screenY(); 424 webEvent.windowX = windowPoint.x() ;425 webEvent.windowY = windowPoint.y() ;441 webEvent.windowX = windowPoint.x() * scale; 442 webEvent.windowY = windowPoint.y() * scale; 426 443 IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteLocation(), renderObject); 427 webEvent.x = localPoint.x() ;428 webEvent.y = localPoint.y() ;444 webEvent.x = localPoint.x() * scale; 445 webEvent.y = localPoint.y() * scale; 429 446 } 430 447 … … 473 490 } 474 491 #if ENABLE(POINTER_LOCK) 475 movementX = event.webkitMovementX(); 476 movementY = event.webkitMovementY(); 492 float scale = widgetScaleFactor(widget); 493 movementX = event.webkitMovementX() * scale; 494 movementY = event.webkitMovementY() * scale; 477 495 #endif 478 496 clickCount = event.detail(); … … 481 499 WebMouseEventBuilder::WebMouseEventBuilder(const Widget* widget, const WebCore::RenderObject* renderObject, const TouchEvent& event) 482 500 { 501 float scale = widgetScaleFactor(widget); 483 502 if (!event.touches()) 484 503 return; … … 508 527 509 528 IntPoint localPoint = convertAbsoluteLocationForRenderObject(touch->absoluteLocation(), *renderObject); 510 x = localPoint.x() ;511 y = localPoint.y() ;529 x = localPoint.x() * scale; 530 y = localPoint.y() * scale; 512 531 } 513 532 … … 563 582 #if ENABLE(TOUCH_EVENTS) 564 583 565 static void addTouchPoints(const AtomicString& touchType, TouchList* touches, WebTouchPoint* touchPoints, unsigned* touchPointsLength, const WebCore::RenderObject* renderObject) 566 { 584 static void addTouchPoints(const Widget* widget, const AtomicString& touchType, TouchList* touches, WebTouchPoint* touchPoints, unsigned* touchPointsLength, const WebCore::RenderObject* renderObject) 585 { 586 float scale = widgetScaleFactor(widget); 567 587 unsigned numberOfTouches = std::min(touches->length(), static_cast<unsigned>(WebTouchEvent::touchesLengthCap)); 568 588 for (unsigned i = 0; i < numberOfTouches; ++i) { … … 573 593 point.screenPosition = WebPoint(touch->screenX(), touch->screenY()); 574 594 point.position = convertAbsoluteLocationForRenderObject(touch->absoluteLocation(), *renderObject); 575 point.radiusX = touch->webkitRadiusX(); 576 point.radiusY = touch->webkitRadiusY(); 595 point.position.x *= scale; 596 point.position.y *= scale; 597 point.radiusX = touch->webkitRadiusX() * scale; 598 point.radiusY = touch->webkitRadiusY() * scale; 577 599 point.rotationAngle = touch->webkitRotationAngle(); 578 600 point.force = touch->webkitForce(); … … 603 625 timeStampSeconds = event.timeStamp() / millisPerSecond; 604 626 605 addTouchPoints( event.type(), event.touches(), touches, &touchesLength, renderObject);606 addTouchPoints( event.type(), event.changedTouches(), changedTouches, &changedTouchesLength, renderObject);607 addTouchPoints( event.type(), event.targetTouches(), targetTouches, &targetTouchesLength, renderObject);627 addTouchPoints(widget, event.type(), event.touches(), touches, &touchesLength, renderObject); 628 addTouchPoints(widget, event.type(), event.changedTouches(), changedTouches, &changedTouchesLength, renderObject); 629 addTouchPoints(widget, event.type(), event.targetTouches(), targetTouches, &targetTouchesLength, renderObject); 608 630 } 609 631 … … 613 635 WebGestureEventBuilder::WebGestureEventBuilder(const Widget* widget, const WebCore::RenderObject* renderObject, const GestureEvent& event) 614 636 { 637 float scale = widgetScaleFactor(widget); 615 638 if (event.type() == eventNames().gesturetapEvent) 616 639 type = GestureTap; … … 623 646 else if (event.type() == eventNames().gesturescrollupdateEvent) { 624 647 type = GestureScrollUpdate; 625 data.scrollUpdate.deltaX = event.deltaX() ;626 data.scrollUpdate.deltaY = event.deltaY() ;648 data.scrollUpdate.deltaX = event.deltaX() * scale; 649 data.scrollUpdate.deltaY = event.deltaY() * scale; 627 650 } 628 651 … … 633 656 globalY = event.screenY(); 634 657 IntPoint localPoint = convertAbsoluteLocationForRenderObject(event.absoluteLocation(), *renderObject); 635 x = localPoint.x() ;636 y = localPoint.y() ;658 x = localPoint.x() * scale; 659 y = localPoint.y() * scale; 637 660 } 638 661 #endif // ENABLE(GESTURE_EVENTS) -
trunk/Source/WebKit/chromium/src/WebViewImpl.cpp
r142197 r142571 756 756 // Instead, assume that the page has been designed with big enough buttons and links. 757 757 if (event.data.tap.width > 0 && !shouldDisableDesktopWorkarounds()) { 758 IntRect boundingBox(event.x - event.data.tap.width / 2, event.y - event.data.tap.height / 2, event.data.tap.width, event.data.tap.height); 758 // FIXME: didTapMultipleTargets should just take a rect instead of 759 // an event. 760 WebGestureEvent scaledEvent; 761 scaledEvent.x = event.x / pageScaleFactor(); 762 scaledEvent.y = event.y / pageScaleFactor(); 763 scaledEvent.data.tap.width = event.data.tap.width / pageScaleFactor(); 764 scaledEvent.data.tap.height = event.data.tap.height / pageScaleFactor(); 765 IntRect boundingBox(scaledEvent.x - scaledEvent.data.tap.width / 2, scaledEvent.y - scaledEvent.data.tap.height / 2, scaledEvent.data.tap.width, scaledEvent.data.tap.height); 759 766 Vector<IntRect> goodTargets; 760 767 findGoodTouchTargets(boundingBox, mainFrameImpl()->frame(), goodTargets); 761 768 // FIXME: replace touch adjustment code when numberOfGoodTargets == 1? 762 769 // Single candidate case is currently handled by: https://bugs.webkit.org/show_bug.cgi?id=85101 763 if (goodTargets.size() >= 2 && m_client && m_client->didTapMultipleTargets( event, goodTargets)) {770 if (goodTargets.size() >= 2 && m_client && m_client->didTapMultipleTargets(scaledEvent, goodTargets)) { 764 771 eventSwallowed = true; 765 772 eventCancelled = true; … … 1355 1362 bool WebViewImpl::hasTouchEventHandlersAt(const WebPoint& point) 1356 1363 { 1364 // FIXME: Implement this. Note that the point must be divided by pageScaleFactor. 1357 1365 return true; 1358 1366 } … … 2084 2092 } 2085 2093 2086 const WebInputEvent* inputEventTransformed = &inputEvent; 2087 if (m_page->settings()->applyPageScaleFactorInCompositor()) { 2088 WebMouseEvent mouseEvent; 2089 WebGestureEvent gestureEvent; 2090 if (WebInputEvent::isMouseEventType(inputEvent.type)) { 2091 mouseEvent = *static_cast<const WebMouseEvent*>(&inputEvent); 2092 mouseEvent.x = mouseEvent.x / pageScaleFactor(); 2093 mouseEvent.y = mouseEvent.y / pageScaleFactor(); 2094 inputEventTransformed = static_cast<const WebInputEvent*>(&mouseEvent); 2095 } else if (WebInputEvent::isGestureEventType(inputEvent.type)) { 2096 gestureEvent = *static_cast<const WebGestureEvent*>(&inputEvent); 2097 gestureEvent.x = gestureEvent.x / pageScaleFactor(); 2098 gestureEvent.y = gestureEvent.y / pageScaleFactor(); 2099 gestureEvent.data.tap.width /= pageScaleFactor(); 2100 gestureEvent.data.tap.height /= pageScaleFactor(); 2101 inputEventTransformed = static_cast<const WebInputEvent*>(&gestureEvent); 2102 } 2103 } 2104 2105 return PageWidgetDelegate::handleInputEvent(m_page.get(), *this, *inputEventTransformed); 2094 return PageWidgetDelegate::handleInputEvent(m_page.get(), *this, inputEvent); 2106 2095 } 2107 2096 -
trunk/Source/WebKit/chromium/tests/WebInputEventConversionTest.cpp
r141346 r142571 33 33 #include "WebInputEventConversion.h" 34 34 35 #include "Frame.h" 36 #include "FrameTestHelpers.h" 37 #include "FrameView.h" 38 #include "GestureEvent.h" 35 39 #include "KeyboardEvent.h" 40 #include "MouseEvent.h" 41 #include "Touch.h" 36 42 #include "TouchEvent.h" 43 #include "TouchList.h" 44 #include "URLTestHelpers.h" 45 #include "WebFrame.h" 46 #include "WebSettings.h" 47 #include "WebViewImpl.h" 37 48 #include <gtest/gtest.h> 38 49 39 using WebKit::WebInputEvent; 40 using WebKit::WebKeyboardEvent; 41 using WebKit::WebKeyboardEventBuilder; 42 using WebKit::WebMouseEventBuilder; 50 using namespace WebKit; 51 using namespace WebCore; 43 52 44 53 namespace { … … 82 91 } 83 92 93 TEST(WebInputEventConversionTest, InputEventsScaling) 94 { 95 const std::string baseURL("http://www.test.com/"); 96 const std::string fileName("fixed_layout.html"); 97 98 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(baseURL.c_str()), WebString::fromUTF8("fixed_layout.html")); 99 WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(FrameTestHelpers::createWebViewAndLoad(baseURL + fileName, true)); 100 webViewImpl->settings()->setApplyDeviceScaleFactorInCompositor(true); 101 webViewImpl->settings()->setApplyPageScaleFactorInCompositor(true); 102 webViewImpl->enableFixedLayoutMode(true); 103 webViewImpl->settings()->setViewportEnabled(true); 104 int pageWidth = 640; 105 int pageHeight = 480; 106 webViewImpl->resize(WebSize(pageWidth, pageHeight)); 107 webViewImpl->layout(); 108 109 webViewImpl->setPageScaleFactor(2, WebPoint()); 110 111 FrameView* view = webViewImpl->page()->mainFrame()->view(); 112 RefPtr<Document> document = webViewImpl->page()->mainFrame()->document(); 113 DOMWindow* domWindow = webViewImpl->page()->mainFrame()->document()->defaultView(); 114 RenderObject* docRenderer = webViewImpl->page()->mainFrame()->document()->renderer(); 115 116 { 117 WebMouseEvent webMouseEvent; 118 webMouseEvent.type = WebInputEvent::MouseMove; 119 webMouseEvent.x = 10; 120 webMouseEvent.y = 10; 121 webMouseEvent.windowX = 10; 122 webMouseEvent.windowY = 10; 123 webMouseEvent.globalX = 10; 124 webMouseEvent.globalY = 10; 125 webMouseEvent.movementX = 10; 126 webMouseEvent.movementY = 10; 127 128 PlatformMouseEventBuilder platformMouseBuilder(view, webMouseEvent); 129 EXPECT_EQ(5, platformMouseBuilder.position().x()); 130 EXPECT_EQ(5, platformMouseBuilder.position().y()); 131 EXPECT_EQ(10, platformMouseBuilder.globalPosition().x()); 132 EXPECT_EQ(10, platformMouseBuilder.globalPosition().y()); 133 EXPECT_EQ(5, platformMouseBuilder.movementDelta().x()); 134 EXPECT_EQ(5, platformMouseBuilder.movementDelta().y()); 135 } 136 137 { 138 WebGestureEvent webGestureEvent; 139 webGestureEvent.type = WebInputEvent::GestureScrollUpdate; 140 webGestureEvent.x = 10; 141 webGestureEvent.y = 10; 142 webGestureEvent.globalX = 10; 143 webGestureEvent.globalY = 10; 144 webGestureEvent.data.scrollUpdate.deltaX = 10; 145 webGestureEvent.data.scrollUpdate.deltaY = 10; 146 147 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent); 148 EXPECT_EQ(5, platformGestureBuilder.position().x()); 149 EXPECT_EQ(5, platformGestureBuilder.position().y()); 150 EXPECT_EQ(10, platformGestureBuilder.globalPosition().x()); 151 EXPECT_EQ(10, platformGestureBuilder.globalPosition().y()); 152 EXPECT_EQ(5, platformGestureBuilder.deltaX()); 153 EXPECT_EQ(5, platformGestureBuilder.deltaY()); 154 } 155 156 { 157 WebGestureEvent webGestureEvent; 158 webGestureEvent.type = WebInputEvent::GestureTap; 159 webGestureEvent.data.tap.width = 10; 160 webGestureEvent.data.tap.height = 10; 161 162 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent); 163 EXPECT_EQ(5, platformGestureBuilder.area().width()); 164 EXPECT_EQ(5, platformGestureBuilder.area().height()); 165 } 166 167 { 168 WebGestureEvent webGestureEvent; 169 webGestureEvent.type = WebInputEvent::GestureTapDown; 170 webGestureEvent.data.tapDown.width = 10; 171 webGestureEvent.data.tapDown.height = 10; 172 173 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent); 174 EXPECT_EQ(5, platformGestureBuilder.area().width()); 175 EXPECT_EQ(5, platformGestureBuilder.area().height()); 176 } 177 178 { 179 WebGestureEvent webGestureEvent; 180 webGestureEvent.type = WebInputEvent::GestureLongPress; 181 webGestureEvent.data.longPress.width = 10; 182 webGestureEvent.data.longPress.height = 10; 183 184 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent); 185 EXPECT_EQ(5, platformGestureBuilder.area().width()); 186 EXPECT_EQ(5, platformGestureBuilder.area().height()); 187 } 188 189 { 190 WebGestureEvent webGestureEvent; 191 webGestureEvent.type = WebInputEvent::GestureTwoFingerTap; 192 webGestureEvent.data.twoFingerTap.firstFingerWidth = 10; 193 webGestureEvent.data.twoFingerTap.firstFingerHeight = 10; 194 195 PlatformGestureEventBuilder platformGestureBuilder(view, webGestureEvent); 196 EXPECT_EQ(5, platformGestureBuilder.area().width()); 197 EXPECT_EQ(5, platformGestureBuilder.area().height()); 198 } 199 200 { 201 WebTouchEvent webTouchEvent; 202 webTouchEvent.type = WebInputEvent::TouchMove; 203 webTouchEvent.touchesLength = 1; 204 webTouchEvent.touches[0].state = WebTouchPoint::StateMoved; 205 webTouchEvent.touches[0].screenPosition.x = 10; 206 webTouchEvent.touches[0].screenPosition.y = 10; 207 webTouchEvent.touches[0].position.x = 10; 208 webTouchEvent.touches[0].position.y = 10; 209 webTouchEvent.touches[0].radiusX = 10; 210 webTouchEvent.touches[0].radiusY = 10; 211 212 PlatformTouchEventBuilder platformTouchBuilder(view, webTouchEvent); 213 EXPECT_EQ(10, platformTouchBuilder.touchPoints()[0].screenPos().x()); 214 EXPECT_EQ(10, platformTouchBuilder.touchPoints()[0].screenPos().y()); 215 EXPECT_EQ(5, platformTouchBuilder.touchPoints()[0].pos().x()); 216 EXPECT_EQ(5, platformTouchBuilder.touchPoints()[0].pos().y()); 217 EXPECT_EQ(5, platformTouchBuilder.touchPoints()[0].radiusX()); 218 EXPECT_EQ(5, platformTouchBuilder.touchPoints()[0].radiusY()); 219 } 220 221 { 222 PlatformMouseEvent platformMouseEvent(IntPoint(10, 10), IntPoint(10, 10), LeftButton, PlatformEvent::MouseMoved, 1, false, false, false, false, 0); 223 RefPtr<MouseEvent> mouseEvent = MouseEvent::create(WebCore::eventNames().mousemoveEvent, domWindow, platformMouseEvent, 0, document); 224 WebMouseEventBuilder webMouseBuilder(view, docRenderer, *mouseEvent); 225 226 EXPECT_EQ(20, webMouseBuilder.x); 227 EXPECT_EQ(20, webMouseBuilder.y); 228 EXPECT_EQ(10, webMouseBuilder.globalX); 229 EXPECT_EQ(10, webMouseBuilder.globalY); 230 EXPECT_EQ(20, webMouseBuilder.windowX); 231 EXPECT_EQ(20, webMouseBuilder.windowY); 232 } 233 234 { 235 PlatformGestureEvent platformGestureEvent(PlatformEvent::GestureScrollUpdate, IntPoint(10, 10), IntPoint(10, 10), 0, IntSize(10, 10), FloatPoint(10, 10), false, false, false, false); 236 RefPtr<GestureEvent> gestureEvent = GestureEvent::create(domWindow, platformGestureEvent); 237 WebGestureEventBuilder webGestureBuilder(view, docRenderer, *gestureEvent); 238 239 EXPECT_EQ(20, webGestureBuilder.x); 240 EXPECT_EQ(20, webGestureBuilder.y); 241 EXPECT_EQ(10, webGestureBuilder.globalX); 242 EXPECT_EQ(10, webGestureBuilder.globalY); 243 EXPECT_EQ(20, webGestureBuilder.data.scrollUpdate.deltaX); 244 EXPECT_EQ(20, webGestureBuilder.data.scrollUpdate.deltaY); 245 } 246 247 { 248 RefPtr<Touch> touch = Touch::create(webViewImpl->page()->mainFrame(), document.get(), 0, 10, 10, 10, 10, 10, 10, 0, 0); 249 RefPtr<TouchList> touchList = TouchList::create(); 250 touchList->append(touch); 251 RefPtr<TouchEvent> touchEvent = TouchEvent::create(touchList.get(), touchList.get(), touchList.get(), WebCore::eventNames().touchmoveEvent, domWindow, 10, 10, 10, 10, false, false, false, false); 252 253 WebTouchEventBuilder webTouchBuilder(view, docRenderer, *touchEvent); 254 ASSERT_EQ(1u, webTouchBuilder.touchesLength); 255 EXPECT_EQ(10, webTouchBuilder.touches[0].screenPosition.x); 256 EXPECT_EQ(10, webTouchBuilder.touches[0].screenPosition.y); 257 EXPECT_EQ(20, webTouchBuilder.touches[0].position.x); 258 EXPECT_EQ(20, webTouchBuilder.touches[0].position.y); 259 EXPECT_EQ(20, webTouchBuilder.touches[0].radiusX); 260 EXPECT_EQ(20, webTouchBuilder.touches[0].radiusY); 261 } 262 263 webViewImpl->close(); 264 } 265 84 266 } // anonymous namespace
Note:
See TracChangeset
for help on using the changeset viewer.