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

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: Add missing file, fix forbidden include. 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 #include "core/events/KeyboardEvent.h" 49 #include "core/events/KeyboardEvent.h"
50 #include "core/events/UIEventWithKeyState.h" 50 #include "core/events/UIEventWithKeyState.h"
51 #include "core/events/WheelEvent.h" 51 #include "core/events/WheelEvent.h"
52 #include "core/fetch/UniqueIdentifier.h" 52 #include "core/fetch/UniqueIdentifier.h"
53 #include "core/frame/EventHandlerRegistry.h" 53 #include "core/frame/EventHandlerRegistry.h"
54 #include "core/frame/FrameHost.h" 54 #include "core/frame/FrameHost.h"
55 #include "core/frame/FrameView.h" 55 #include "core/frame/FrameView.h"
56 #include "core/frame/LocalFrame.h" 56 #include "core/frame/LocalFrame.h"
57 #include "core/frame/PageScaleConstraintsSet.h" 57 #include "core/frame/PageScaleConstraintsSet.h"
58 #include "core/frame/RemoteFrame.h" 58 #include "core/frame/RemoteFrame.h"
59 #include "core/frame/ScrollAndScaleEmulator.h"
59 #include "core/frame/Settings.h" 60 #include "core/frame/Settings.h"
60 #include "core/frame/SmartClip.h" 61 #include "core/frame/SmartClip.h"
61 #include "core/frame/TopControls.h" 62 #include "core/frame/TopControls.h"
62 #include "core/frame/UseCounter.h" 63 #include "core/frame/UseCounter.h"
63 #include "core/frame/VisualViewport.h" 64 #include "core/frame/VisualViewport.h"
64 #include "core/html/HTMLInputElement.h" 65 #include "core/html/HTMLInputElement.h"
65 #include "core/html/HTMLMediaElement.h" 66 #include "core/html/HTMLMediaElement.h"
66 #include "core/html/HTMLPlugInElement.h" 67 #include "core/html/HTMLPlugInElement.h"
67 #include "core/html/HTMLTextAreaElement.h" 68 #include "core/html/HTMLTextAreaElement.h"
68 #include "core/input/EventHandler.h" 69 #include "core/input/EventHandler.h"
(...skipping 3131 matching lines...) Expand 10 before | Expand all | Expand 10 after
3200 DCHECK(page()); 3201 DCHECK(page());
3201 return page()->frameHost().visualViewport().visibleRect().location(); 3202 return page()->frameHost().visualViewport().visibleRect().location();
3202 } 3203 }
3203 3204
3204 WebFloatSize WebViewImpl::visualViewportSize() const 3205 WebFloatSize WebViewImpl::visualViewportSize() const
3205 { 3206 {
3206 DCHECK(page()); 3207 DCHECK(page());
3207 return page()->frameHost().visualViewport().visibleRect().size(); 3208 return page()->frameHost().visualViewport().visibleRect().size();
3208 } 3209 }
3209 3210
3211 void WebViewImpl::setScrollAndScaleOverride(const WebDeviceEmulationParams& para ms)
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 if (!m_scrollAndScaleEmulator) {
3224 m_scrollAndScaleEmulator = ScrollAndScaleEmulator::create();
3225 }
3226
3227 bool hasChanged = m_scrollAndScaleEmulator->update(
3228 static_cast<IntPoint>(params.scrollPosition),
3229 static_cast<FloatPoint>(params.visualViewportPosition),
3230 params.visualViewportScale);
3231 if (hasChanged) {
3232 view->setScrollAndScaleEmulator(m_scrollAndScaleEmulator);
3233 page()->frameHost().visualViewport().setScrollAndScaleEmulator(m_scrollA ndScaleEmulator);
3234 page()->frameHost().setUserAgentPageScaleConstraints(
3235 m_scrollAndScaleEmulator->pageScaleConstraints());
3236 }
bokan 2016/06/29 15:15:49 My recommendation for the mainFrameSize issue woul
3237 }
3238
3239 void WebViewImpl::clearScrollAndScaleOverride()
3240 {
3241 if (!m_scrollAndScaleEmulator)
3242 return;
3243
3244 if (!page())
3245 return;
3246
3247 if (!mainFrameImpl())
3248 return;
3249
3250 FrameView * view = mainFrameImpl()->frameView();
3251 if (!view)
3252 return;
3253
3254 m_scrollAndScaleEmulator.clear();
3255 view->setScrollAndScaleEmulator(m_scrollAndScaleEmulator);
3256 page()->frameHost().visualViewport().setScrollAndScaleEmulator(m_scrollAndSc aleEmulator);
3257 page()->frameHost().setUserAgentPageScaleConstraints(PageScaleConstraints()) ;
3258
3259 resetScrollAndScaleState();
3260 }
3261
3210 void WebViewImpl::scrollAndRescaleViewports(float scaleFactor, 3262 void WebViewImpl::scrollAndRescaleViewports(float scaleFactor,
3211 const IntPoint& mainFrameOrigin, 3263 const IntPoint& mainFrameOrigin,
3212 const FloatPoint& visualViewportOrigin) 3264 const FloatPoint& visualViewportOrigin)
3213 { 3265 {
3214 if (!page()) 3266 if (!page())
3215 return; 3267 return;
3216 3268
3217 if (!mainFrameImpl()) 3269 if (!mainFrameImpl())
3218 return; 3270 return;
3219 3271
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
3825 m_rootLayerScale = rootLayerScale; 3877 m_rootLayerScale = rootLayerScale;
3826 m_rootLayerOffset = rootLayerOffset; 3878 m_rootLayerOffset = rootLayerOffset;
3827 if (mainFrameImpl()) 3879 if (mainFrameImpl())
3828 mainFrameImpl()->setInputEventsTransformForEmulation(m_rootLayerOffset, m_rootLayerScale); 3880 mainFrameImpl()->setInputEventsTransformForEmulation(m_rootLayerOffset, m_rootLayerScale);
3829 updateRootLayerTransform(); 3881 updateRootLayerTransform();
3830 } 3882 }
3831 3883
3832 void WebViewImpl::enableDeviceEmulation(const WebDeviceEmulationParams& params) 3884 void WebViewImpl::enableDeviceEmulation(const WebDeviceEmulationParams& params)
3833 { 3885 {
3834 m_devToolsEmulator->enableDeviceEmulation(params); 3886 m_devToolsEmulator->enableDeviceEmulation(params);
3887 setScrollAndScaleOverride(params);
3835 } 3888 }
3836 3889
3837 void WebViewImpl::disableDeviceEmulation() 3890 void WebViewImpl::disableDeviceEmulation()
3838 { 3891 {
3892 clearScrollAndScaleOverride();
3839 m_devToolsEmulator->disableDeviceEmulation(); 3893 m_devToolsEmulator->disableDeviceEmulation();
3840 } 3894 }
3841 3895
3842 WebAXObject WebViewImpl::accessibilityObject() 3896 WebAXObject WebViewImpl::accessibilityObject()
3843 { 3897 {
3844 if (!mainFrameImpl()) 3898 if (!mainFrameImpl())
3845 return WebAXObject(); 3899 return WebAXObject();
3846 3900
3847 Document* document = mainFrameImpl()->frame()->document(); 3901 Document* document = mainFrameImpl()->frame()->document();
3848 return WebAXObject(toAXObjectCacheImpl(document->axObjectCache())->root()); 3902 return WebAXObject(toAXObjectCacheImpl(document->axObjectCache())->root());
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
4521 { 4575 {
4522 // TODO(oshima): Investigate if this should return the ScreenInfo's scale fa ctor rather than 4576 // TODO(oshima): Investigate if this should return the ScreenInfo's scale fa ctor rather than
4523 // page's scale factor, which can be 1 in use-zoom-for-dsf mode. 4577 // page's scale factor, which can be 1 in use-zoom-for-dsf mode.
4524 if (!page()) 4578 if (!page())
4525 return 1; 4579 return 1;
4526 4580
4527 return page()->deviceScaleFactor(); 4581 return page()->deviceScaleFactor();
4528 } 4582 }
4529 4583
4530 } // namespace blink 4584 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebViewImpl.h ('k') | third_party/WebKit/public/web/WebDeviceEmulationParams.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698