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

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: Emulator using GC, moved to FrameHost, addressed other comments. 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 3132 matching lines...) Expand 10 before | Expand all | Expand 10 after
3201 DCHECK(page()); 3202 DCHECK(page());
3202 return page()->frameHost().visualViewport().visibleRect().location(); 3203 return page()->frameHost().visualViewport().visibleRect().location();
3203 } 3204 }
3204 3205
3205 WebFloatSize WebViewImpl::visualViewportSize() const 3206 WebFloatSize WebViewImpl::visualViewportSize() const
3206 { 3207 {
3207 DCHECK(page()); 3208 DCHECK(page());
3208 return page()->frameHost().visualViewport().visibleRect().size(); 3209 return page()->frameHost().visualViewport().visibleRect().size();
3209 } 3210 }
3210 3211
3212 void WebViewImpl::setScrollAndScaleOverride(const WebDeviceEmulationParams& para ms)
3213 {
3214 if (!page())
3215 return;
3216
3217 page()->frameHost().setScrollAndScaleOverride(
3218 static_cast<IntPoint>(params.scrollPosition),
3219 static_cast<FloatPoint>(params.visualViewportPosition),
3220 params.visualViewportScale);
3221 }
3222
3223 void WebViewImpl::clearScrollAndScaleOverride()
3224 {
3225 if (!page())
3226 return;
3227
3228 page()->frameHost().clearScrollAndScaleOverride();
3229 resetScrollAndScaleState();
3230 }
3231
3211 void WebViewImpl::scrollAndRescaleViewports(float scaleFactor, 3232 void WebViewImpl::scrollAndRescaleViewports(float scaleFactor,
3212 const IntPoint& mainFrameOrigin, 3233 const IntPoint& mainFrameOrigin,
3213 const FloatPoint& visualViewportOrigin) 3234 const FloatPoint& visualViewportOrigin)
3214 { 3235 {
3215 if (!page()) 3236 if (!page())
3216 return; 3237 return;
3217 3238
3218 if (!mainFrameImpl()) 3239 if (!mainFrameImpl())
3219 return; 3240 return;
3220 3241
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
3336 } else { 3357 } else {
3337 constraints.minimumScale = -1; 3358 constraints.minimumScale = -1;
3338 constraints.maximumScale = -1; 3359 constraints.maximumScale = -1;
3339 } 3360 }
3340 page()->frameHost().setUserAgentPageScaleConstraints(constraints); 3361 page()->frameHost().setUserAgentPageScaleConstraints(constraints);
3341 } 3362 }
3342 3363
3343 IntSize WebViewImpl::mainFrameSize() 3364 IntSize WebViewImpl::mainFrameSize()
3344 { 3365 {
3345 // The frame size should match the viewport size at minimum scale, since the 3366 // The frame size should match the viewport size at minimum scale, since the
3346 // viewport must always be contained by the frame. 3367 // viewport must always be contained by the frame. As ScrollAndScaleEmulator
3368 // may override the minimum scale, it is responsible for this calculation if
3369 // it is active.
3370 if (page() && page()->frameHost().scrollAndScaleEmulator()) {
3371 return page()->frameHost().scrollAndScaleEmulator()->mainFrameSize(m_siz e);
3372 }
3373
3347 FloatSize frameSize(m_size); 3374 FloatSize frameSize(m_size);
3348 frameSize.scale(1 / minimumPageScaleFactor()); 3375 frameSize.scale(1 / minimumPageScaleFactor());
3349 return expandedIntSize(frameSize); 3376 return expandedIntSize(frameSize);
3350 } 3377 }
3351 3378
3352 PageScaleConstraintsSet& WebViewImpl::pageScaleConstraintsSet() const 3379 PageScaleConstraintsSet& WebViewImpl::pageScaleConstraintsSet() const
3353 { 3380 {
3354 return page()->frameHost().pageScaleConstraintsSet(); 3381 return page()->frameHost().pageScaleConstraintsSet();
3355 } 3382 }
3356 3383
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
3827 m_rootLayerScale = rootLayerScale; 3854 m_rootLayerScale = rootLayerScale;
3828 m_rootLayerOffset = rootLayerOffset; 3855 m_rootLayerOffset = rootLayerOffset;
3829 if (mainFrameImpl()) 3856 if (mainFrameImpl())
3830 mainFrameImpl()->setInputEventsTransformForEmulation(m_rootLayerOffset, m_rootLayerScale); 3857 mainFrameImpl()->setInputEventsTransformForEmulation(m_rootLayerOffset, m_rootLayerScale);
3831 updateRootLayerTransform(); 3858 updateRootLayerTransform();
3832 } 3859 }
3833 3860
3834 void WebViewImpl::enableDeviceEmulation(const WebDeviceEmulationParams& params) 3861 void WebViewImpl::enableDeviceEmulation(const WebDeviceEmulationParams& params)
3835 { 3862 {
3836 m_devToolsEmulator->enableDeviceEmulation(params); 3863 m_devToolsEmulator->enableDeviceEmulation(params);
3864 setScrollAndScaleOverride(params);
3837 } 3865 }
3838 3866
3839 void WebViewImpl::disableDeviceEmulation() 3867 void WebViewImpl::disableDeviceEmulation()
3840 { 3868 {
3869 clearScrollAndScaleOverride();
3841 m_devToolsEmulator->disableDeviceEmulation(); 3870 m_devToolsEmulator->disableDeviceEmulation();
3842 } 3871 }
3843 3872
3844 WebAXObject WebViewImpl::accessibilityObject() 3873 WebAXObject WebViewImpl::accessibilityObject()
3845 { 3874 {
3846 if (!mainFrameImpl()) 3875 if (!mainFrameImpl())
3847 return WebAXObject(); 3876 return WebAXObject();
3848 3877
3849 Document* document = mainFrameImpl()->frame()->document(); 3878 Document* document = mainFrameImpl()->frame()->document();
3850 return WebAXObject(toAXObjectCacheImpl(document->axObjectCache())->root()); 3879 return WebAXObject(toAXObjectCacheImpl(document->axObjectCache())->root());
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after
4533 { 4562 {
4534 // TODO(oshima): Investigate if this should return the ScreenInfo's scale fa ctor rather than 4563 // TODO(oshima): Investigate if this should return the ScreenInfo's scale fa ctor rather than
4535 // page's scale factor, which can be 1 in use-zoom-for-dsf mode. 4564 // page's scale factor, which can be 1 in use-zoom-for-dsf mode.
4536 if (!page()) 4565 if (!page())
4537 return 1; 4566 return 1;
4538 4567
4539 return page()->deviceScaleFactor(); 4568 return page()->deviceScaleFactor();
4540 } 4569 }
4541 4570
4542 } // namespace blink 4571 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698