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

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

Issue 1163433003: Remove WebViewImpl helper methods for setting scroll offset. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 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 /* 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 3123 matching lines...) Expand 10 before | Expand all | Expand 10 after
3134 { 3134 {
3135 ASSERT(page()); 3135 ASSERT(page());
3136 3136
3137 scaleFactor = clampPageScaleFactorToLimits(scaleFactor); 3137 scaleFactor = clampPageScaleFactorToLimits(scaleFactor);
3138 if (scaleFactor == pageScaleFactor()) 3138 if (scaleFactor == pageScaleFactor())
3139 return; 3139 return;
3140 3140
3141 page()->frameHost().pinchViewport().setScale(scaleFactor); 3141 page()->frameHost().pinchViewport().setScale(scaleFactor);
3142 } 3142 }
3143 3143
3144 void WebViewImpl::setMainFrameScrollOffset(const WebPoint& origin)
3145 {
3146 updateLayoutViewportScrollPosition(DoublePoint(origin.x, origin.y), false);
3147 }
3148
3149 float WebViewImpl::deviceScaleFactor() const 3144 float WebViewImpl::deviceScaleFactor() const
3150 { 3145 {
3151 if (!page()) 3146 if (!page())
3152 return 1; 3147 return 1;
3153 3148
3154 return page()->deviceScaleFactor(); 3149 return page()->deviceScaleFactor();
3155 } 3150 }
3156 3151
3157 void WebViewImpl::setDeviceScaleFactor(float scaleFactor) 3152 void WebViewImpl::setDeviceScaleFactor(float scaleFactor)
3158 { 3153 {
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
3396 return pageScaleConstraintsSet().finalConstraints().minimumScale; 3391 return pageScaleConstraintsSet().finalConstraints().minimumScale;
3397 } 3392 }
3398 3393
3399 float WebViewImpl::maximumPageScaleFactor() const 3394 float WebViewImpl::maximumPageScaleFactor() const
3400 { 3395 {
3401 return pageScaleConstraintsSet().finalConstraints().maximumScale; 3396 return pageScaleConstraintsSet().finalConstraints().maximumScale;
3402 } 3397 }
3403 3398
3404 void WebViewImpl::resetScrollAndScaleState() 3399 void WebViewImpl::resetScrollAndScaleState()
3405 { 3400 {
3406 updateLayoutViewportScrollPosition(IntPoint(), true);
3407 page()->frameHost().pinchViewport().reset(); 3401 page()->frameHost().pinchViewport().reset();
3408 3402
3409 if (!page()->mainFrame()->isLocalFrame()) 3403 if (!page()->mainFrame()->isLocalFrame())
3410 return; 3404 return;
3411 3405
3406 if (FrameView* frameView = toLocalFrame(page()->mainFrame())->view()) {
3407 ScrollableArea* scrollableArea = frameView->layoutViewportScrollableArea ();
3408
3409 if (scrollableArea->scrollPositionDouble() != DoublePoint::zero())
3410 scrollableArea->notifyScrollPositionChanged(DoublePoint::zero());
3411 }
3412
3412 // Clear out the values for the current history item. This will prevent the history item from clobbering the 3413 // Clear out the values for the current history item. This will prevent the history item from clobbering the
3413 // value determined during page scale initialization, which may be less than 1. 3414 // value determined during page scale initialization, which may be less than 1.
3414 page()->deprecatedLocalMainFrame()->loader().clearScrollPositionAndViewState (); 3415 page()->deprecatedLocalMainFrame()->loader().clearScrollPositionAndViewState ();
3415 pageScaleConstraintsSet().setNeedsReset(true); 3416 pageScaleConstraintsSet().setNeedsReset(true);
3416 3417
3417 // Clobber saved scales and scroll offsets. 3418 // Clobber saved scales and scroll offsets.
3418 if (FrameView* view = page()->deprecatedLocalMainFrame()->document()->view() ) 3419 if (FrameView* view = page()->deprecatedLocalMainFrame()->document()->view() )
3419 view->cacheCurrentScrollPosition(); 3420 view->cacheCurrentScrollPosition();
3420 } 3421 }
3421 3422
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after
4241 if (WebDevToolsAgentImpl* devTools = mainFrameDevToolsAgentImpl()) 4242 if (WebDevToolsAgentImpl* devTools = mainFrameDevToolsAgentImpl())
4242 devTools->layerTreeViewChanged(m_layerTreeView); 4243 devTools->layerTreeViewChanged(m_layerTreeView);
4243 4244
4244 m_page->settings().setAcceleratedCompositingEnabled(m_layerTreeView != 0); 4245 m_page->settings().setAcceleratedCompositingEnabled(m_layerTreeView != 0);
4245 4246
4246 // FIXME: only unittests, click to play, Android priting, and printing (for headers and footers) 4247 // FIXME: only unittests, click to play, Android priting, and printing (for headers and footers)
4247 // make this assert necessary. We should make them not hit this code and the n delete allowsBrokenNullLayerTreeView. 4248 // make this assert necessary. We should make them not hit this code and the n delete allowsBrokenNullLayerTreeView.
4248 ASSERT(m_layerTreeView || !m_client || m_client->allowsBrokenNullLayerTreeVi ew()); 4249 ASSERT(m_layerTreeView || !m_client || m_client->allowsBrokenNullLayerTreeVi ew());
4249 } 4250 }
4250 4251
4251 void WebViewImpl::updateLayoutViewportScrollPosition(const DoublePoint& scrollPo sition, bool programmaticScroll)
4252 {
4253 if (!page()->mainFrame()->isLocalFrame())
4254 return;
4255
4256 // FIXME(305811): Refactor for OOPI.
4257 FrameView* frameView = page()->deprecatedLocalMainFrame()->view();
4258 if (!frameView)
4259 return;
4260
4261 ScrollableArea* scrollableArea = frameView->layoutViewportScrollableArea();
4262 if (scrollableArea->scrollPositionDouble() == scrollPosition)
4263 return;
4264
4265 scrollableArea->notifyScrollPositionChanged(scrollPosition);
4266 if (!programmaticScroll)
4267 frameView->setWasScrolledByUser(true);
4268 }
4269
4270 void WebViewImpl::applyViewportDeltas( 4252 void WebViewImpl::applyViewportDeltas(
4271 const WebFloatSize& pinchViewportDelta, 4253 const WebFloatSize& pinchViewportDelta,
4272 const WebFloatSize& outerViewportDelta, 4254 const WebFloatSize& outerViewportDelta,
4273 const WebFloatSize& elasticOverscrollDelta, 4255 const WebFloatSize& elasticOverscrollDelta,
4274 float pageScaleDelta, 4256 float pageScaleDelta,
4275 float topControlsShownRatioDelta) 4257 float topControlsShownRatioDelta)
4276 { 4258 {
4277 if (!mainFrameImpl()) 4259 if (!mainFrameImpl())
4278 return; 4260 return;
4279 FrameView* frameView = mainFrameImpl()->frameView(); 4261 FrameView* frameView = mainFrameImpl()->frameView();
4280 if (!frameView) 4262 if (!frameView)
4281 return; 4263 return;
4282 4264
4283 topControls().setShownRatio(topControls().shownRatio() + topControlsShownRat ioDelta); 4265 topControls().setShownRatio(topControls().shownRatio() + topControlsShownRat ioDelta);
4284 4266
4285 FloatPoint pinchViewportOffset = page()->frameHost().pinchViewport().visible Rect().location(); 4267 FloatPoint pinchViewportOffset = page()->frameHost().pinchViewport().visible Rect().location();
4286 pinchViewportOffset.move(pinchViewportDelta.width, pinchViewportDelta.height ); 4268 pinchViewportOffset.move(pinchViewportDelta.width, pinchViewportDelta.height );
4287 setPageScaleFactorAndLocation(pageScaleFactor() * pageScaleDelta, pinchViewp ortOffset); 4269 setPageScaleFactorAndLocation(pageScaleFactor() * pageScaleDelta, pinchViewp ortOffset);
4288 4270
4289 if (pageScaleDelta != 1) 4271 if (pageScaleDelta != 1)
4290 m_doubleTapZoomPending = false; 4272 m_doubleTapZoomPending = false;
4291 4273
4292 frameView->setElasticOverscroll(elasticOverscrollDelta + frameView->elasticO verscroll()); 4274 frameView->setElasticOverscroll(elasticOverscrollDelta + frameView->elasticO verscroll());
4293 4275
4294 updateLayoutViewportScrollPosition(frameView->layoutViewportScrollableArea() ->scrollPositionDouble() + 4276 ScrollableArea* layoutViewport = frameView->layoutViewportScrollableArea();
skobes 2015/06/03 16:57:57 It's confusing to use both "layout viewport" and "
bokan 2015/06/03 17:04:58 Done.
4295 DoubleSize(outerViewportDelta.width, outerViewportDelta.height), /* prog rammaticScroll */ false); 4277
4278 DoublePoint layoutViewportPosition = layoutViewport->scrollPositionDouble()
4279 + DoubleSize(outerViewportDelta.width, outerViewportDelta.height);
4280
4281 if (layoutViewport->scrollPositionDouble() != layoutViewportPosition) {
4282 layoutViewport->notifyScrollPositionChanged(layoutViewportPosition);
4283 frameView->setWasScrolledByUser(true);
4284 }
4296 } 4285 }
4297 4286
4298 void WebViewImpl::recordFrameTimingEvent(FrameTimingEventType eventType, int64_t FrameId, const WebVector<WebFrameTimingEvent>& events) 4287 void WebViewImpl::recordFrameTimingEvent(FrameTimingEventType eventType, int64_t FrameId, const WebVector<WebFrameTimingEvent>& events)
4299 { 4288 {
4300 Frame* frame = m_page ? m_page->mainFrame() : 0; 4289 Frame* frame = m_page ? m_page->mainFrame() : 0;
4301 4290
4302 while (frame && frame->frameID() != FrameId) { 4291 while (frame && frame->frameID() != FrameId) {
4303 frame = frame->tree().traverseNext(); 4292 frame = frame->tree().traverseNext();
4304 } 4293 }
4305 4294
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
4468 { 4457 {
4469 WebGLRenderingContext::forceNextWebGLContextCreationToFail(); 4458 WebGLRenderingContext::forceNextWebGLContextCreationToFail();
4470 } 4459 }
4471 4460
4472 void WebViewImpl::forceNextDrawingBufferCreationToFail() 4461 void WebViewImpl::forceNextDrawingBufferCreationToFail()
4473 { 4462 {
4474 DrawingBuffer::forceNextDrawingBufferCreationToFail(); 4463 DrawingBuffer::forceNextDrawingBufferCreationToFail();
4475 } 4464 }
4476 4465
4477 } // namespace blink 4466 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698