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

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 1425 matching lines...) Expand 10 before | Expand all | Expand 10 after
3414 } 3414 }
3415 setPageScaleFactor(newPageScaleFactor); 3415 setPageScaleFactor(newPageScaleFactor);
3416 3416
3417 updateLayerTreeViewport(); 3417 updateLayerTreeViewport();
3418 3418
3419 // Changes to page-scale during layout may require an additional frame. 3419 // Changes to page-scale during layout may require an additional frame.
3420 // We can't update the lifecycle here because we may be in the middle of lay out in the 3420 // We can't update the lifecycle here because we may be in the middle of lay out in the
3421 // caller of this method. 3421 // caller of this method.
3422 // TODO(chrishtr): clean all this up. All layout should happen in one lifecy cle run (crbug.com/578239). 3422 // TODO(chrishtr): clean all this up. All layout should happen in one lifecy cle run (crbug.com/578239).
3423 if (mainFrameImpl()->frameView()->needsLayout()) 3423 if (mainFrameImpl()->frameView()->needsLayout())
3424 scheduleAnimation(); 3424 mainFrameImpl()->frameWidget()->scheduleAnimation();
3425 } 3425 }
3426 3426
3427 void WebViewImpl::updatePageDefinedViewportConstraints(const ViewportDescription & description) 3427 void WebViewImpl::updatePageDefinedViewportConstraints(const ViewportDescription & description)
3428 { 3428 {
3429 // If we're not reading the viewport meta tag, allow GPU rasterization. 3429 // If we're not reading the viewport meta tag, allow GPU rasterization.
3430 if (!settingsImpl()->viewportMetaEnabled()) { 3430 if (!settingsImpl()->viewportMetaEnabled()) {
3431 m_matchesHeuristicsForGpuRasterization = true; 3431 m_matchesHeuristicsForGpuRasterization = true;
3432 if (m_layerTreeView) 3432 if (m_layerTreeView)
3433 m_layerTreeView->heuristicsForGpuRasterizationUpdated(m_matchesHeuri sticsForGpuRasterization); 3433 m_layerTreeView->heuristicsForGpuRasterizationUpdated(m_matchesHeuri sticsForGpuRasterization);
3434 } 3434 }
(...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after
4313 return nullptr; 4313 return nullptr;
4314 4314
4315 return document->layoutViewItem().compositor(); 4315 return document->layoutViewItem().compositor();
4316 } 4316 }
4317 4317
4318 GraphicsLayer* WebViewImpl::rootGraphicsLayer() 4318 GraphicsLayer* WebViewImpl::rootGraphicsLayer()
4319 { 4319 {
4320 return m_rootGraphicsLayer; 4320 return m_rootGraphicsLayer;
4321 } 4321 }
4322 4322
4323 void WebViewImpl::scheduleAnimation() 4323 void WebViewImpl::scheduleAnimationForWidget()
4324 { 4324 {
4325 if (m_layerTreeView) { 4325 if (m_layerTreeView) {
4326 m_layerTreeView->setNeedsBeginFrame(); 4326 m_layerTreeView->setNeedsBeginFrame();
4327 return; 4327 return;
4328 } 4328 }
4329 if (m_client) 4329 if (m_client)
4330 m_client->scheduleAnimation(); 4330 m_client->widgetClient()->scheduleAnimation();
4331 } 4331 }
4332 4332
4333 void WebViewImpl::attachCompositorAnimationTimeline(CompositorAnimationTimeline* timeline) 4333 void WebViewImpl::attachCompositorAnimationTimeline(CompositorAnimationTimeline* timeline)
4334 { 4334 {
4335 if (m_layerTreeView) 4335 if (m_layerTreeView)
4336 m_layerTreeView->attachCompositorAnimationTimeline(timeline->animationTi meline()); 4336 m_layerTreeView->attachCompositorAnimationTimeline(timeline->animationTi meline());
4337 } 4337 }
4338 4338
4339 void WebViewImpl::detachCompositorAnimationTimeline(CompositorAnimationTimeline* timeline) 4339 void WebViewImpl::detachCompositorAnimationTimeline(CompositorAnimationTimeline* timeline)
4340 { 4340 {
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
4614 return nullptr; 4614 return nullptr;
4615 return focusedFrame; 4615 return focusedFrame;
4616 } 4616 }
4617 4617
4618 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const 4618 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const
4619 { 4619 {
4620 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr; 4620 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr;
4621 } 4621 }
4622 4622
4623 } // namespace blink 4623 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebViewImpl.h ('k') | third_party/WebKit/public/web/WebViewClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698