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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_mac.mm

Issue 2902303002: phase based wheel scroll latching for mac (Closed)
Patch Set: in -> after Created 3 years, 6 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 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/render_widget_host_view_mac.h" 5 #include "content/browser/renderer_host/render_widget_host_view_mac.h"
6 6
7 #import <Carbon/Carbon.h> 7 #import <Carbon/Carbon.h>
8 #import <objc/runtime.h> 8 #import <objc/runtime.h>
9 #include <OpenGL/gl.h> 9 #include <OpenGL/gl.h>
10 #include <QuartzCore/QuartzCore.h> 10 #include <QuartzCore/QuartzCore.h>
(...skipping 1737 matching lines...) Expand 10 before | Expand all | Expand 10 after
1748 1748
1749 if (changed_metrics & DisplayObserver::DISPLAY_METRIC_DEVICE_SCALE_FACTOR) { 1749 if (changed_metrics & DisplayObserver::DISPLAY_METRIC_DEVICE_SCALE_FACTOR) {
1750 RenderWidgetHostImpl* host = 1750 RenderWidgetHostImpl* host =
1751 RenderWidgetHostImpl::From(GetRenderWidgetHost()); 1751 RenderWidgetHostImpl::From(GetRenderWidgetHost());
1752 if (host && host->delegate()) 1752 if (host && host->delegate())
1753 host->delegate()->UpdateDeviceScaleFactor(display.device_scale_factor()); 1753 host->delegate()->UpdateDeviceScaleFactor(display.device_scale_factor());
1754 } 1754 }
1755 1755
1756 UpdateScreenInfo(cocoa_view_); 1756 UpdateScreenInfo(cocoa_view_);
1757 } 1757 }
1758 void RenderWidgetHostViewMac::SendSyntheticWheelEventWithPhaseEnded(
1759 blink::WebMouseWheelEvent wheel_event,
1760 bool should_route_event) {
1761 wheel_event.dispatch_type =
1762 blink::WebInputEvent::DispatchType::kEventNonBlocking;
1763 if (should_route_event) {
1764 render_widget_host_->delegate()
1765 ->GetInputEventRouter()
1766 ->RouteMouseWheelEvent(this, &wheel_event,
1767 ui::LatencyInfo(ui::SourceEventType::WHEEL));
1768 } else {
1769 ProcessMouseWheelEvent(wheel_event,
1770 ui::LatencyInfo(ui::SourceEventType::WHEEL));
1771 }
1772 }
1773
1774 void RenderWidgetHostViewMac::StartMouseWheelEndDispatchTimer(
1775 blink::WebMouseWheelEvent wheel_event,
1776 bool should_route_event) {
1777 mouse_wheel_end_dispatch_timer_.Start(
1778 FROM_HERE,
1779 base::TimeDelta::FromMilliseconds(
1780 kDefaultMouseWheelLatchingTransactionMs),
1781 base::Bind(
1782 &RenderWidgetHostViewMac::SendSyntheticWheelEventWithPhaseEnded,
1783 base::Unretained(this), wheel_event, should_route_event));
1784 }
1758 1785
1759 } // namespace content 1786 } // namespace content
1760 1787
1761 // RenderWidgetHostViewCocoa --------------------------------------------------- 1788 // RenderWidgetHostViewCocoa ---------------------------------------------------
1762 1789
1763 @implementation RenderWidgetHostViewCocoa 1790 @implementation RenderWidgetHostViewCocoa
1764 @synthesize selectedRange = selectedRange_; 1791 @synthesize selectedRange = selectedRange_;
1765 @synthesize suppressNextEscapeKeyUp = suppressNextEscapeKeyUp_; 1792 @synthesize suppressNextEscapeKeyUp = suppressNextEscapeKeyUp_;
1766 @synthesize markedRange = markedRange_; 1793 @synthesize markedRange = markedRange_;
1767 1794
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
2349 if ([event phase] != NSEventPhaseEnded && 2376 if ([event phase] != NSEventPhaseEnded &&
2350 [event phase] != NSEventPhaseCancelled) { 2377 [event phase] != NSEventPhaseCancelled) {
2351 return; 2378 return;
2352 } 2379 }
2353 2380
2354 if (renderWidgetHostView_->render_widget_host_) { 2381 if (renderWidgetHostView_->render_widget_host_) {
2355 // History-swiping is not possible if the logic reaches this point. 2382 // History-swiping is not possible if the logic reaches this point.
2356 WebMouseWheelEvent webEvent = WebMouseWheelEventBuilder::Build( 2383 WebMouseWheelEvent webEvent = WebMouseWheelEventBuilder::Build(
2357 event, self); 2384 event, self);
2358 webEvent.rails_mode = mouseWheelFilter_.UpdateRailsMode(webEvent); 2385 webEvent.rails_mode = mouseWheelFilter_.UpdateRailsMode(webEvent);
2359 ui::LatencyInfo latency_info(ui::SourceEventType::WHEEL); 2386 if (renderWidgetHostView_->WheelScrollLatchingEnabled()) {
2360 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); 2387 renderWidgetHostView_->StartMouseWheelEndDispatchTimer(webEvent, false);
2361 renderWidgetHostView_->render_widget_host_-> 2388 } else {
2362 ForwardWheelEventWithLatencyInfo(webEvent, latency_info); 2389 ui::LatencyInfo latency_info(ui::SourceEventType::WHEEL);
2390 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
2391 renderWidgetHostView_->render_widget_host_
2392 ->ForwardWheelEventWithLatencyInfo(webEvent, latency_info);
2393 }
2363 } 2394 }
2364 2395
2365 if (endWheelMonitor_) { 2396 if (endWheelMonitor_) {
2366 [NSEvent removeMonitor:endWheelMonitor_]; 2397 [NSEvent removeMonitor:endWheelMonitor_];
2367 endWheelMonitor_ = nil; 2398 endWheelMonitor_ = nil;
2368 } 2399 }
2369 } 2400 }
2370 2401
2371 - (void)beginGestureWithEvent:(NSEvent*)event { 2402 - (void)beginGestureWithEvent:(NSEvent*)event {
2372 [responderDelegate_ beginGestureWithEvent:event]; 2403 [responderDelegate_ beginGestureWithEvent:event];
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
2558 return blockEvent; 2589 return blockEvent;
2559 }]; 2590 }];
2560 } 2591 }
2561 2592
2562 // This is responsible for content scrolling! 2593 // This is responsible for content scrolling!
2563 if (renderWidgetHostView_->render_widget_host_) { 2594 if (renderWidgetHostView_->render_widget_host_) {
2564 WebMouseWheelEvent webEvent = WebMouseWheelEventBuilder::Build(event, self); 2595 WebMouseWheelEvent webEvent = WebMouseWheelEventBuilder::Build(event, self);
2565 webEvent.rails_mode = mouseWheelFilter_.UpdateRailsMode(webEvent); 2596 webEvent.rails_mode = mouseWheelFilter_.UpdateRailsMode(webEvent);
2566 ui::LatencyInfo latency_info(ui::SourceEventType::WHEEL); 2597 ui::LatencyInfo latency_info(ui::SourceEventType::WHEEL);
2567 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); 2598 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0);
2599 if (renderWidgetHostView_->WheelScrollLatchingEnabled()) {
2600 if (webEvent.phase == blink::WebMouseWheelEvent::kPhaseEnded) {
tdresser 2017/05/25 15:18:36 Could you add a comment per condition here?
sahel 2017/05/25 16:00:04 Done.
2601 renderWidgetHostView_->StartMouseWheelEndDispatchTimer(
2602 webEvent, renderWidgetHostView_->ShouldRouteEvent(webEvent));
2603 return;
2604 }
2605 if (webEvent.phase == blink::WebMouseWheelEvent::kPhaseBegan) {
2606 // A new scrolling sequence hase started, stop the timer and send its
tdresser 2017/05/25 15:18:36 hase -> has
sahel 2017/05/25 16:00:04 Done.
2607 // wheel end event.
2608 if (renderWidgetHostView_->mouse_wheel_end_dispatch_timer_
2609 .IsRunning()) {
2610 base::Closure task =
2611 renderWidgetHostView_->mouse_wheel_end_dispatch_timer_
2612 .user_task();
2613 renderWidgetHostView_->mouse_wheel_end_dispatch_timer_.Stop();
2614 task.Run();
2615 }
2616
2617 } else if (webEvent.momentum_phase ==
2618 blink::WebMouseWheelEvent::kPhaseBegan) {
2619 renderWidgetHostView_->mouse_wheel_end_dispatch_timer_.Stop();
2620 }
2621 }
2622
2568 if (renderWidgetHostView_->ShouldRouteEvent(webEvent)) { 2623 if (renderWidgetHostView_->ShouldRouteEvent(webEvent)) {
2569 renderWidgetHostView_->render_widget_host_->delegate() 2624 renderWidgetHostView_->render_widget_host_->delegate()
2570 ->GetInputEventRouter() 2625 ->GetInputEventRouter()
2571 ->RouteMouseWheelEvent(renderWidgetHostView_.get(), &webEvent, 2626 ->RouteMouseWheelEvent(renderWidgetHostView_.get(), &webEvent,
2572 latency_info); 2627 latency_info);
2573 } else { 2628 } else {
2574 renderWidgetHostView_->ProcessMouseWheelEvent(webEvent, latency_info); 2629 renderWidgetHostView_->ProcessMouseWheelEvent(webEvent, latency_info);
2575 } 2630 }
2576 } 2631 }
2577 } 2632 }
(...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after
3524 3579
3525 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding 3580 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding
3526 // regions that are not draggable. (See ControlRegionView in 3581 // regions that are not draggable. (See ControlRegionView in
3527 // native_app_window_cocoa.mm). This requires the render host view to be 3582 // native_app_window_cocoa.mm). This requires the render host view to be
3528 // draggable by default. 3583 // draggable by default.
3529 - (BOOL)mouseDownCanMoveWindow { 3584 - (BOOL)mouseDownCanMoveWindow {
3530 return YES; 3585 return YES;
3531 } 3586 }
3532 3587
3533 @end 3588 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698