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

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

Issue 2096633002: Adds scroll position/scale emulation to DevTools. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 , m_zoomLevel(0) 412 , m_zoomLevel(0)
413 , m_minimumZoomLevel(zoomFactorToZoomLevel(minTextSizeMultiplier)) 413 , m_minimumZoomLevel(zoomFactorToZoomLevel(minTextSizeMultiplier))
414 , m_maximumZoomLevel(zoomFactorToZoomLevel(maxTextSizeMultiplier)) 414 , m_maximumZoomLevel(zoomFactorToZoomLevel(maxTextSizeMultiplier))
415 , m_zoomFactorForDeviceScaleFactor(0.f) 415 , m_zoomFactorForDeviceScaleFactor(0.f)
416 , m_maximumLegibleScale(1) 416 , m_maximumLegibleScale(1)
417 , m_doubleTapZoomPageScaleFactor(0) 417 , m_doubleTapZoomPageScaleFactor(0)
418 , m_doubleTapZoomPending(false) 418 , m_doubleTapZoomPending(false)
419 , m_enableFakePageScaleAnimationForTesting(false) 419 , m_enableFakePageScaleAnimationForTesting(false)
420 , m_fakePageScaleAnimationPageScaleFactor(0) 420 , m_fakePageScaleAnimationPageScaleFactor(0)
421 , m_fakePageScaleAnimationUseAnchor(false) 421 , m_fakePageScaleAnimationUseAnchor(false)
422 , m_scrollOverrideEnabled(false)
422 , m_doingDragAndDrop(false) 423 , m_doingDragAndDrop(false)
423 , m_ignoreInputEvents(false) 424 , m_ignoreInputEvents(false)
424 , m_compositorDeviceScaleFactorOverride(0) 425 , m_compositorDeviceScaleFactorOverride(0)
425 , m_rootLayerScale(1) 426 , m_rootLayerScale(1)
426 , m_suppressNextKeypressEvent(false) 427 , m_suppressNextKeypressEvent(false)
427 , m_imeAcceptEvents(true) 428 , m_imeAcceptEvents(true)
428 , m_operationsAllowed(WebDragOperationNone) 429 , m_operationsAllowed(WebDragOperationNone)
429 , m_dragOperation(WebDragOperationNone) 430 , m_dragOperation(WebDragOperationNone)
430 , m_devToolsEmulator(nullptr) 431 , m_devToolsEmulator(nullptr)
431 , m_isTransparent(false) 432 , m_isTransparent(false)
(...skipping 1379 matching lines...) Expand 10 before | Expand all | Expand 10 after
1811 // viewport with the top controls shown. 1812 // viewport with the top controls shown.
1812 IntSize ICBSize = m_size; 1813 IntSize ICBSize = m_size;
1813 if (RuntimeEnabledFeatures::inertTopControlsEnabled() && !topControls().shri nkViewport()) 1814 if (RuntimeEnabledFeatures::inertTopControlsEnabled() && !topControls().shri nkViewport())
1814 ICBSize.expand(0, -topControls().height()); 1815 ICBSize.expand(0, -topControls().height());
1815 1816
1816 pageScaleConstraintsSet().didChangeInitialContainingBlockSize(ICBSize); 1817 pageScaleConstraintsSet().didChangeInitialContainingBlockSize(ICBSize);
1817 1818
1818 updatePageDefinedViewportConstraints(mainFrameImpl()->frame()->document()->v iewportDescription()); 1819 updatePageDefinedViewportConstraints(mainFrameImpl()->frame()->document()->v iewportDescription());
1819 updateMainFrameLayoutSize(); 1820 updateMainFrameLayoutSize();
1820 1821
1821 page()->frameHost().visualViewport().setSize(m_size); 1822 if (!(m_scrollOverrideEnabled
1823 && (m_scrollOverrideParams.visualViewportSize.width
1824 || m_scrollOverrideParams.visualViewportSize.height))) {
1825 page()->frameHost().visualViewport().setSize(m_size);
1826 }
1822 1827
1823 if (mainFrameImpl()->frameView()) { 1828 if (mainFrameImpl()->frameView()) {
1824 if (!mainFrameImpl()->frameView()->needsLayout()) 1829 if (!mainFrameImpl()->frameView()->needsLayout())
1825 postLayoutResize(mainFrameImpl()); 1830 postLayoutResize(mainFrameImpl());
1826 } 1831 }
1827 } 1832 }
1828 1833
1829 void WebViewImpl::updateTopControlsState(WebTopControlsState constraint, WebTopC ontrolsState current, bool animate) 1834 void WebViewImpl::updateTopControlsState(WebTopControlsState constraint, WebTopC ontrolsState current, bool animate)
1830 { 1835 {
1831 topControls().updateConstraints(constraint); 1836 topControls().updateConstraints(constraint);
(...skipping 1326 matching lines...) Expand 10 before | Expand all | Expand 10 after
3158 } 3163 }
3159 3164
3160 float WebViewImpl::pageScaleFactor() const 3165 float WebViewImpl::pageScaleFactor() const
3161 { 3166 {
3162 if (!page()) 3167 if (!page())
3163 return 1; 3168 return 1;
3164 3169
3165 return page()->frameHost().visualViewport().scale(); 3170 return page()->frameHost().visualViewport().scale();
3166 } 3171 }
3167 3172
3173 WebPoint WebViewImpl::mainFrameOffset() const
3174 {
3175 if (!page() || !mainFrameImpl())
3176 return WebPoint();
3177
3178 FrameView* view = mainFrameImpl()->frameView();
3179 if (!view)
3180 return WebPoint();
3181
3182 return view->scrollPosition();
3183 }
3184
3168 float WebViewImpl::clampPageScaleFactorToLimits(float scaleFactor) const 3185 float WebViewImpl::clampPageScaleFactorToLimits(float scaleFactor) const
3169 { 3186 {
3170 return pageScaleConstraintsSet().finalConstraints().clampToConstraints(scale Factor); 3187 return pageScaleConstraintsSet().finalConstraints().clampToConstraints(scale Factor);
3171 } 3188 }
3172 3189
3173 void WebViewImpl::setVisualViewportOffset(const WebFloatPoint& offset) 3190 void WebViewImpl::setVisualViewportOffset(const WebFloatPoint& offset)
3174 { 3191 {
3175 DCHECK(page()); 3192 DCHECK(page());
3176 page()->frameHost().visualViewport().setLocation(offset); 3193 page()->frameHost().visualViewport().setLocation(offset);
3177 } 3194 }
3178 3195
3179 WebFloatPoint WebViewImpl::visualViewportOffset() const 3196 WebFloatPoint WebViewImpl::visualViewportOffset() const
3180 { 3197 {
3181 DCHECK(page()); 3198 DCHECK(page());
3182 return page()->frameHost().visualViewport().visibleRect().location(); 3199 return page()->frameHost().visualViewport().visibleRect().location();
3183 } 3200 }
3184 3201
3185 WebFloatSize WebViewImpl::visualViewportSize() const 3202 WebFloatSize WebViewImpl::visualViewportSize() const
3186 { 3203 {
3187 DCHECK(page()); 3204 DCHECK(page());
3188 return page()->frameHost().visualViewport().visibleRect().size(); 3205 return page()->frameHost().visualViewport().visibleRect().size();
3189 } 3206 }
3190 3207
3208 void WebViewImpl::setScrollOverride(const WebDeviceEmulationParams& params)
3209 {
3210 if (m_scrollOverrideEnabled && m_scrollOverrideParams == params)
3211 return;
3212
3213 if (!page())
3214 return;
3215
3216 if (!mainFrameImpl())
3217 return;
3218
3219 FrameView * view = mainFrameImpl()->frameView();
3220 if (!view)
3221 return;
3222
3223 m_scrollOverrideEnabled = true;
3224 m_scrollOverrideParams = params;
3225
3226 view->setScrollOverride(DoublePoint(
3227 m_scrollOverrideParams.scrollPosition.x, m_scrollOverrideParams.scrollPo sition.y));
3228 page()->frameHost().visualViewport().setScaleAndScrollOverride(
3229 m_scrollOverrideParams.visualViewportScale,
3230 FloatPoint(
3231 m_scrollOverrideParams.visualViewportPosition.x,
3232 m_scrollOverrideParams.visualViewportPosition.y));
3233 }
3234
3235 void WebViewImpl::clearScrollOverride()
3236 {
3237 if (!m_scrollOverrideEnabled)
3238 return;
3239
3240 if (!page())
3241 return;
3242
3243 if (!mainFrameImpl())
3244 return;
3245
3246 FrameView * view = mainFrameImpl()->frameView();
3247 if (!view)
3248 return;
3249
3250 m_scrollOverrideEnabled = false;
3251
3252 view->clearScrollOverride();
3253 page()->frameHost().visualViewport().clearScaleAndScrollOverride();
3254
3255 resetScrollAndScaleState();
3256 }
3257
3191 void WebViewImpl::scrollAndRescaleViewports(float scaleFactor, 3258 void WebViewImpl::scrollAndRescaleViewports(float scaleFactor,
3192 const IntPoint& mainFrameOrigin, 3259 const IntPoint& mainFrameOrigin,
3193 const FloatPoint& visualViewportOrigin) 3260 const FloatPoint& visualViewportOrigin)
3194 { 3261 {
3195 if (!page()) 3262 if (!page())
3196 return; 3263 return;
3197 3264
3198 if (!mainFrameImpl()) 3265 if (!mainFrameImpl())
3199 return; 3266 return;
3200 3267
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
3841 m_rootLayerScale = rootLayerScale; 3908 m_rootLayerScale = rootLayerScale;
3842 m_rootLayerOffset = rootLayerOffset; 3909 m_rootLayerOffset = rootLayerOffset;
3843 if (mainFrameImpl()) 3910 if (mainFrameImpl())
3844 mainFrameImpl()->setInputEventsTransformForEmulation(m_rootLayerOffset, m_rootLayerScale); 3911 mainFrameImpl()->setInputEventsTransformForEmulation(m_rootLayerOffset, m_rootLayerScale);
3845 updateRootLayerTransform(); 3912 updateRootLayerTransform();
3846 } 3913 }
3847 3914
3848 void WebViewImpl::enableDeviceEmulation(const WebDeviceEmulationParams& params) 3915 void WebViewImpl::enableDeviceEmulation(const WebDeviceEmulationParams& params)
3849 { 3916 {
3850 m_devToolsEmulator->enableDeviceEmulation(params); 3917 m_devToolsEmulator->enableDeviceEmulation(params);
3918 setScrollOverride(params);
3851 } 3919 }
3852 3920
3853 void WebViewImpl::disableDeviceEmulation() 3921 void WebViewImpl::disableDeviceEmulation()
3854 { 3922 {
3923 clearScrollOverride();
3855 m_devToolsEmulator->disableDeviceEmulation(); 3924 m_devToolsEmulator->disableDeviceEmulation();
3856 } 3925 }
3857 3926
3858 WebAXObject WebViewImpl::accessibilityObject() 3927 WebAXObject WebViewImpl::accessibilityObject()
3859 { 3928 {
3860 if (!mainFrameImpl()) 3929 if (!mainFrameImpl())
3861 return WebAXObject(); 3930 return WebAXObject();
3862 3931
3863 Document* document = mainFrameImpl()->frame()->document(); 3932 Document* document = mainFrameImpl()->frame()->document();
3864 return WebAXObject(toAXObjectCacheImpl(document->axObjectCache())->root()); 3933 return WebAXObject(toAXObjectCacheImpl(document->axObjectCache())->root());
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after
4553 { 4622 {
4554 // TODO(oshima): Investigate if this should return the ScreenInfo's scale fa ctor rather than 4623 // TODO(oshima): Investigate if this should return the ScreenInfo's scale fa ctor rather than
4555 // page's scale factor, which can be 1 in use-zoom-for-dsf mode. 4624 // page's scale factor, which can be 1 in use-zoom-for-dsf mode.
4556 if (!page()) 4625 if (!page())
4557 return 1; 4626 return 1;
4558 4627
4559 return page()->deviceScaleFactor(); 4628 return page()->deviceScaleFactor();
4560 } 4629 }
4561 4630
4562 } // namespace blink 4631 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698