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

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

Issue 2128563002: Move scheduleAnimation calls from WebViewClient to WebWidgetClient. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 5 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 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 endActiveFlingAnimation(); 736 endActiveFlingAnimation();
737 m_client->cancelScheduledContentIntents(); 737 m_client->cancelScheduledContentIntents();
738 m_positionOnFlingStart = WebPoint(event.x, event.y); 738 m_positionOnFlingStart = WebPoint(event.x, event.y);
739 m_globalPositionOnFlingStart = WebPoint(event.globalX, event.globalY); 739 m_globalPositionOnFlingStart = WebPoint(event.globalX, event.globalY);
740 m_flingModifier = event.modifiers; 740 m_flingModifier = event.modifiers;
741 m_flingSourceDevice = event.sourceDevice; 741 m_flingSourceDevice = event.sourceDevice;
742 DCHECK_NE(m_flingSourceDevice, WebGestureDeviceUninitialized); 742 DCHECK_NE(m_flingSourceDevice, WebGestureDeviceUninitialized);
743 std::unique_ptr<WebGestureCurve> flingCurve = wrapUnique(Platform::curre nt()->createFlingAnimationCurve(event.sourceDevice, WebFloatPoint(event.data.fli ngStart.velocityX, event.data.flingStart.velocityY), WebSize())); 743 std::unique_ptr<WebGestureCurve> flingCurve = wrapUnique(Platform::curre nt()->createFlingAnimationCurve(event.sourceDevice, WebFloatPoint(event.data.fli ngStart.velocityX, event.data.flingStart.velocityY), WebSize()));
744 DCHECK(flingCurve); 744 DCHECK(flingCurve);
745 m_gestureAnimation = WebActiveGestureAnimation::createAtAnimationStart(s td::move(flingCurve), this); 745 m_gestureAnimation = WebActiveGestureAnimation::createAtAnimationStart(s td::move(flingCurve), this);
746 scheduleAnimation(); 746 mainFrameImpl()->frameWidget()->scheduleAnimation();
747 eventResult = WebInputEventResult::HandledSystem; 747 eventResult = WebInputEventResult::HandledSystem;
748 748
749 // Plugins may need to see GestureFlingStart to balance 749 // Plugins may need to see GestureFlingStart to balance
750 // GestureScrollBegin (since the former replaces GestureScrollEnd when 750 // GestureScrollBegin (since the former replaces GestureScrollEnd when
751 // transitioning to a fling). 751 // transitioning to a fling).
752 PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), event); 752 PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), event);
753 // TODO(dtapuska): Why isn't the response used? 753 // TODO(dtapuska): Why isn't the response used?
754 mainFrameImpl()->frame()->eventHandler().handleGestureScrollEvent(platfo rmEvent); 754 mainFrameImpl()->frame()->eventHandler().handleGestureScrollEvent(platfo rmEvent);
755 755
756 m_client->didHandleGestureEvent(event, eventCancelled); 756 m_client->didHandleGestureEvent(event, eventCancelled);
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 TRACE_EVENT0("blink", "WebViewImpl::transferActiveWheelFlingAnimation"); 959 TRACE_EVENT0("blink", "WebViewImpl::transferActiveWheelFlingAnimation");
960 DCHECK(!m_gestureAnimation); 960 DCHECK(!m_gestureAnimation);
961 m_positionOnFlingStart = parameters.point; 961 m_positionOnFlingStart = parameters.point;
962 m_globalPositionOnFlingStart = parameters.globalPoint; 962 m_globalPositionOnFlingStart = parameters.globalPoint;
963 m_flingModifier = parameters.modifiers; 963 m_flingModifier = parameters.modifiers;
964 std::unique_ptr<WebGestureCurve> curve = wrapUnique(Platform::current()->cre ateFlingAnimationCurve(parameters.sourceDevice, WebFloatPoint(parameters.delta), parameters.cumulativeScroll)); 964 std::unique_ptr<WebGestureCurve> curve = wrapUnique(Platform::current()->cre ateFlingAnimationCurve(parameters.sourceDevice, WebFloatPoint(parameters.delta), parameters.cumulativeScroll));
965 DCHECK(curve); 965 DCHECK(curve);
966 m_gestureAnimation = WebActiveGestureAnimation::createWithTimeOffset(std::mo ve(curve), this, parameters.startTime); 966 m_gestureAnimation = WebActiveGestureAnimation::createWithTimeOffset(std::mo ve(curve), this, parameters.startTime);
967 DCHECK_NE(parameters.sourceDevice, WebGestureDeviceUninitialized); 967 DCHECK_NE(parameters.sourceDevice, WebGestureDeviceUninitialized);
968 m_flingSourceDevice = parameters.sourceDevice; 968 m_flingSourceDevice = parameters.sourceDevice;
969 scheduleAnimation(); 969 mainFrameImpl()->frameWidget()->scheduleAnimation();
970 } 970 }
971 971
972 bool WebViewImpl::endActiveFlingAnimation() 972 bool WebViewImpl::endActiveFlingAnimation()
973 { 973 {
974 if (m_gestureAnimation) { 974 if (m_gestureAnimation) {
975 m_gestureAnimation.reset(); 975 m_gestureAnimation.reset();
976 m_flingSourceDevice = WebGestureDeviceUninitialized; 976 m_flingSourceDevice = WebGestureDeviceUninitialized;
977 if (m_layerTreeView) 977 if (m_layerTreeView)
978 m_layerTreeView->didStopFlinging(); 978 m_layerTreeView->didStopFlinging();
979 return true; 979 return true;
(...skipping 988 matching lines...) Expand 10 before | Expand all | Expand 10 after
1968 } 1968 }
1969 1969
1970 void WebViewImpl::beginFrame(double lastFrameTimeMonotonic) 1970 void WebViewImpl::beginFrame(double lastFrameTimeMonotonic)
1971 { 1971 {
1972 TRACE_EVENT1("blink", "WebViewImpl::beginFrame", "frameTime", lastFrameTimeM onotonic); 1972 TRACE_EVENT1("blink", "WebViewImpl::beginFrame", "frameTime", lastFrameTimeM onotonic);
1973 DCHECK(lastFrameTimeMonotonic); 1973 DCHECK(lastFrameTimeMonotonic);
1974 1974
1975 // Create synthetic wheel events as necessary for fling. 1975 // Create synthetic wheel events as necessary for fling.
1976 if (m_gestureAnimation) { 1976 if (m_gestureAnimation) {
1977 if (m_gestureAnimation->animate(lastFrameTimeMonotonic)) 1977 if (m_gestureAnimation->animate(lastFrameTimeMonotonic))
1978 scheduleAnimation(); 1978 mainFrameImpl()->frameWidget()->scheduleAnimation();
1979 else { 1979 else {
1980 DCHECK_NE(m_flingSourceDevice, WebGestureDeviceUninitialized); 1980 DCHECK_NE(m_flingSourceDevice, WebGestureDeviceUninitialized);
1981 WebGestureDevice lastFlingSourceDevice = m_flingSourceDevice; 1981 WebGestureDevice lastFlingSourceDevice = m_flingSourceDevice;
1982 endActiveFlingAnimation(); 1982 endActiveFlingAnimation();
1983 1983
1984 PlatformGestureEvent endScrollEvent(PlatformEvent::GestureScrollEnd, 1984 PlatformGestureEvent endScrollEvent(PlatformEvent::GestureScrollEnd,
1985 m_positionOnFlingStart, m_globalPositionOnFlingStart, 1985 m_positionOnFlingStart, m_globalPositionOnFlingStart,
1986 IntSize(), 0, PlatformEvent::NoModifiers, lastFlingSourceDevice == WebGestureDeviceTouchpad ? PlatformGestureSourceTouchpad : PlatformGestureSou rceTouchscreen); 1986 IntSize(), 0, PlatformEvent::NoModifiers, lastFlingSourceDevice == WebGestureDeviceTouchpad ? PlatformGestureSourceTouchpad : PlatformGestureSou rceTouchscreen);
1987 endScrollEvent.setScrollGestureData(0, 0, ScrollByPrecisePixel, 0, 0 , ScrollInertialPhaseMomentum, false, -1 /* null plugin id */); 1987 endScrollEvent.setScrollGestureData(0, 0, ScrollByPrecisePixel, 0, 0 , ScrollInertialPhaseMomentum, false, -1 /* null plugin id */);
1988 1988
(...skipping 1393 matching lines...) Expand 10 before | Expand all | Expand 10 after
3382 } 3382 }
3383 setPageScaleFactor(newPageScaleFactor); 3383 setPageScaleFactor(newPageScaleFactor);
3384 3384
3385 updateLayerTreeViewport(); 3385 updateLayerTreeViewport();
3386 3386
3387 // Changes to page-scale during layout may require an additional frame. 3387 // Changes to page-scale during layout may require an additional frame.
3388 // We can't update the lifecycle here because we may be in the middle of lay out in the 3388 // We can't update the lifecycle here because we may be in the middle of lay out in the
3389 // caller of this method. 3389 // caller of this method.
3390 // TODO(chrishtr): clean all this up. All layout should happen in one lifecy cle run (crbug.com/578239). 3390 // TODO(chrishtr): clean all this up. All layout should happen in one lifecy cle run (crbug.com/578239).
3391 if (mainFrameImpl()->frameView()->needsLayout()) 3391 if (mainFrameImpl()->frameView()->needsLayout())
3392 scheduleAnimation(); 3392 mainFrameImpl()->frameWidget()->scheduleAnimation();
3393 } 3393 }
3394 3394
3395 void WebViewImpl::updatePageDefinedViewportConstraints(const ViewportDescription & description) 3395 void WebViewImpl::updatePageDefinedViewportConstraints(const ViewportDescription & description)
3396 { 3396 {
3397 // If we're not reading the viewport meta tag, allow GPU rasterization. 3397 // If we're not reading the viewport meta tag, allow GPU rasterization.
3398 if (!settingsImpl()->viewportMetaEnabled()) { 3398 if (!settingsImpl()->viewportMetaEnabled()) {
3399 m_matchesHeuristicsForGpuRasterization = true; 3399 m_matchesHeuristicsForGpuRasterization = true;
3400 if (m_layerTreeView) 3400 if (m_layerTreeView)
3401 m_layerTreeView->heuristicsForGpuRasterizationUpdated(m_matchesHeuri sticsForGpuRasterization); 3401 m_layerTreeView->heuristicsForGpuRasterizationUpdated(m_matchesHeuri sticsForGpuRasterization);
3402 } 3402 }
(...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after
4277 return nullptr; 4277 return nullptr;
4278 4278
4279 return document->layoutViewItem().compositor(); 4279 return document->layoutViewItem().compositor();
4280 } 4280 }
4281 4281
4282 GraphicsLayer* WebViewImpl::rootGraphicsLayer() 4282 GraphicsLayer* WebViewImpl::rootGraphicsLayer()
4283 { 4283 {
4284 return m_rootGraphicsLayer; 4284 return m_rootGraphicsLayer;
4285 } 4285 }
4286 4286
4287 void WebViewImpl::scheduleAnimation() 4287 void WebViewImpl::scheduleAnimationForWidget()
4288 { 4288 {
4289 if (m_layerTreeView) { 4289 if (m_layerTreeView) {
4290 m_layerTreeView->setNeedsBeginFrame(); 4290 m_layerTreeView->setNeedsBeginFrame();
4291 return; 4291 return;
4292 } 4292 }
4293 if (m_client) 4293 if (m_client)
4294 m_client->scheduleAnimation(); 4294 m_client->widgetClient()->scheduleAnimation();
4295 } 4295 }
4296 4296
4297 void WebViewImpl::attachCompositorAnimationTimeline(CompositorAnimationTimeline* timeline) 4297 void WebViewImpl::attachCompositorAnimationTimeline(CompositorAnimationTimeline* timeline)
4298 { 4298 {
4299 if (m_layerTreeView) 4299 if (m_layerTreeView)
4300 m_layerTreeView->attachCompositorAnimationTimeline(timeline->animationTi meline()); 4300 m_layerTreeView->attachCompositorAnimationTimeline(timeline->animationTi meline());
4301 } 4301 }
4302 4302
4303 void WebViewImpl::detachCompositorAnimationTimeline(CompositorAnimationTimeline* timeline) 4303 void WebViewImpl::detachCompositorAnimationTimeline(CompositorAnimationTimeline* timeline)
4304 { 4304 {
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
4570 { 4570 {
4571 // TODO(oshima): Investigate if this should return the ScreenInfo's scale fa ctor rather than 4571 // TODO(oshima): Investigate if this should return the ScreenInfo's scale fa ctor rather than
4572 // page's scale factor, which can be 1 in use-zoom-for-dsf mode. 4572 // page's scale factor, which can be 1 in use-zoom-for-dsf mode.
4573 if (!page()) 4573 if (!page())
4574 return 1; 4574 return 1;
4575 4575
4576 return page()->deviceScaleFactor(); 4576 return page()->deviceScaleFactor();
4577 } 4577 }
4578 4578
4579 } // namespace blink 4579 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698