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

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

Issue 2782893002: WebMouseEvent coordinates are now fractional & private (Closed)
Patch Set: Rebased + fixed a Mac crack. Created 3 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) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 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 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 RefPtr<WebPagePopupImpl> pagePopup; 489 RefPtr<WebPagePopupImpl> pagePopup;
490 if (event.button == WebMouseEvent::Button::Left) { 490 if (event.button == WebMouseEvent::Button::Left) {
491 pagePopup = m_pagePopup; 491 pagePopup = m_pagePopup;
492 hidePopups(); 492 hidePopups();
493 DCHECK(!m_pagePopup); 493 DCHECK(!m_pagePopup);
494 } 494 }
495 495
496 // Take capture on a mouse down on a plugin so we can send it mouse events. 496 // Take capture on a mouse down on a plugin so we can send it mouse events.
497 // If the hit node is a plugin but a scrollbar is over it don't start mouse 497 // If the hit node is a plugin but a scrollbar is over it don't start mouse
498 // capture because it will interfere with the scrollbar receiving events. 498 // capture because it will interfere with the scrollbar receiving events.
499 IntPoint point(event.x, event.y); 499 IntPoint point(event.positionInWidget().x, event.positionInWidget().y);
500 if (event.button == WebMouseEvent::Button::Left && 500 if (event.button == WebMouseEvent::Button::Left &&
501 m_page->mainFrame()->isLocalFrame()) { 501 m_page->mainFrame()->isLocalFrame()) {
502 point = 502 point =
503 m_page->deprecatedLocalMainFrame()->view()->rootFrameToContents(point); 503 m_page->deprecatedLocalMainFrame()->view()->rootFrameToContents(point);
504 HitTestResult result( 504 HitTestResult result(
505 m_page->deprecatedLocalMainFrame()->eventHandler().hitTestResultAtPoint( 505 m_page->deprecatedLocalMainFrame()->eventHandler().hitTestResultAtPoint(
506 point)); 506 point));
507 result.setToShadowHostIfInRestrictedShadowRoot(); 507 result.setToShadowHostIfInRestrictedShadowRoot();
508 Node* hitNode = result.innerNodeOrImageMapImage(); 508 Node* hitNode = result.innerNodeOrImageMapImage();
509 509
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 WebMouseWheelEvent syntheticWheel(WebInputEvent::MouseWheel, 630 WebMouseWheelEvent syntheticWheel(WebInputEvent::MouseWheel,
631 m_flingModifier, 631 m_flingModifier,
632 WTF::monotonicallyIncreasingTime()); 632 WTF::monotonicallyIncreasingTime());
633 const float tickDivisor = WheelEvent::TickMultiplier; 633 const float tickDivisor = WheelEvent::TickMultiplier;
634 634
635 syntheticWheel.deltaX = delta.width; 635 syntheticWheel.deltaX = delta.width;
636 syntheticWheel.deltaY = delta.height; 636 syntheticWheel.deltaY = delta.height;
637 syntheticWheel.wheelTicksX = delta.width / tickDivisor; 637 syntheticWheel.wheelTicksX = delta.width / tickDivisor;
638 syntheticWheel.wheelTicksY = delta.height / tickDivisor; 638 syntheticWheel.wheelTicksY = delta.height / tickDivisor;
639 syntheticWheel.hasPreciseScrollingDeltas = true; 639 syntheticWheel.hasPreciseScrollingDeltas = true;
640 syntheticWheel.x = m_positionOnFlingStart.x; 640 syntheticWheel.setPositionInWidget(m_positionOnFlingStart.x,
641 syntheticWheel.y = m_positionOnFlingStart.y; 641 m_positionOnFlingStart.y);
642 syntheticWheel.globalX = m_globalPositionOnFlingStart.x; 642 syntheticWheel.setPositionInScreen(m_globalPositionOnFlingStart.x,
643 syntheticWheel.globalY = m_globalPositionOnFlingStart.y; 643 m_globalPositionOnFlingStart.y);
644 644
645 if (handleMouseWheel(*m_page->deprecatedLocalMainFrame(), syntheticWheel) != 645 if (handleMouseWheel(*m_page->deprecatedLocalMainFrame(), syntheticWheel) !=
646 WebInputEventResult::NotHandled) 646 WebInputEventResult::NotHandled)
647 return true; 647 return true;
648 648
649 if (!enableTouchpadScrollLatching) { 649 if (!enableTouchpadScrollLatching) {
650 WebGestureEvent syntheticScrollBegin = createGestureScrollEventFromFling( 650 WebGestureEvent syntheticScrollBegin = createGestureScrollEventFromFling(
651 WebInputEvent::GestureScrollBegin, WebGestureDeviceTouchpad); 651 WebInputEvent::GestureScrollBegin, WebGestureDeviceTouchpad);
652 syntheticScrollBegin.data.scrollBegin.deltaXHint = delta.width; 652 syntheticScrollBegin.data.scrollBegin.deltaXHint = delta.width;
653 syntheticScrollBegin.data.scrollBegin.deltaYHint = delta.height; 653 syntheticScrollBegin.data.scrollBegin.deltaYHint = delta.height;
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
995 DCHECK_EQ(pinchEvent.type(), WebInputEvent::GesturePinchUpdate); 995 DCHECK_EQ(pinchEvent.type(), WebInputEvent::GesturePinchUpdate);
996 996
997 // For pinch gesture events, match typical trackpad behavior on Windows by 997 // For pinch gesture events, match typical trackpad behavior on Windows by
998 // sending fake wheel events with the ctrl modifier set when we see trackpad 998 // sending fake wheel events with the ctrl modifier set when we see trackpad
999 // pinch gestures. Ideally we'd someday get a platform 'pinch' event and 999 // pinch gestures. Ideally we'd someday get a platform 'pinch' event and
1000 // send that instead. 1000 // send that instead.
1001 WebMouseWheelEvent wheelEvent( 1001 WebMouseWheelEvent wheelEvent(
1002 WebInputEvent::MouseWheel, 1002 WebInputEvent::MouseWheel,
1003 pinchEvent.modifiers() | WebInputEvent::ControlKey, 1003 pinchEvent.modifiers() | WebInputEvent::ControlKey,
1004 pinchEvent.timeStampSeconds()); 1004 pinchEvent.timeStampSeconds());
1005 wheelEvent.x = pinchEvent.x; 1005 wheelEvent.setPositionInWidget(pinchEvent.x, pinchEvent.y);
1006 wheelEvent.y = pinchEvent.y; 1006 wheelEvent.setPositionInScreen(pinchEvent.globalX, pinchEvent.globalY);
1007 wheelEvent.globalX = pinchEvent.globalX;
1008 wheelEvent.globalY = pinchEvent.globalY;
1009 wheelEvent.deltaX = 0; 1007 wheelEvent.deltaX = 0;
1010 1008
1011 // The function to convert scales to deltaY values is designed to be 1009 // The function to convert scales to deltaY values is designed to be
1012 // compatible with websites existing use of wheel events, and with existing 1010 // compatible with websites existing use of wheel events, and with existing
1013 // Windows trackpad behavior. In particular, we want: 1011 // Windows trackpad behavior. In particular, we want:
1014 // - deltas should accumulate via addition: f(s1*s2)==f(s1)+f(s2) 1012 // - deltas should accumulate via addition: f(s1*s2)==f(s1)+f(s2)
1015 // - deltas should invert via negation: f(1/s) == -f(s) 1013 // - deltas should invert via negation: f(1/s) == -f(s)
1016 // - zoom in should be positive: f(s) > 0 iff s > 1 1014 // - zoom in should be positive: f(s) > 0 iff s > 1
1017 // - magnitude roughly matches wheels: f(2) > 25 && f(2) < 100 1015 // - magnitude roughly matches wheels: f(2) > 25 && f(2) < 100
1018 // - a formula that's relatively easy to use from JavaScript 1016 // - a formula that's relatively easy to use from JavaScript
(...skipping 3206 matching lines...) Expand 10 before | Expand all | Expand 10 after
4225 if (focusedFrame->localFrameRoot() != mainFrameImpl()->frame()) 4223 if (focusedFrame->localFrameRoot() != mainFrameImpl()->frame())
4226 return nullptr; 4224 return nullptr;
4227 return focusedFrame; 4225 return focusedFrame;
4228 } 4226 }
4229 4227
4230 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const { 4228 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const {
4231 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr; 4229 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr;
4232 } 4230 }
4233 4231
4234 } // namespace blink 4232 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698