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

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: Sync, patch in 2169483002 (+ regression test), add DevTools tests. 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 3173 matching lines...) Expand 10 before | Expand all | Expand 10 after
3242 DCHECK(page()); 3243 DCHECK(page());
3243 return page()->frameHost().visualViewport().visibleRect().location(); 3244 return page()->frameHost().visualViewport().visibleRect().location();
3244 } 3245 }
3245 3246
3246 WebFloatSize WebViewImpl::visualViewportSize() const 3247 WebFloatSize WebViewImpl::visualViewportSize() const
3247 { 3248 {
3248 DCHECK(page()); 3249 DCHECK(page());
3249 return page()->frameHost().visualViewport().visibleRect().size(); 3250 return page()->frameHost().visualViewport().visibleRect().size();
3250 } 3251 }
3251 3252
3253 void WebViewImpl::setScrollAndScaleOverride(const IntPoint& framePosition, const DoublePoint& visualViewportPosition, float pageScale)
3254 {
3255 if (!page())
3256 return;
3257
3258 page()->frameHost().setScrollAndScaleOverride(framePosition, visualViewportP osition, pageScale);
3259 }
3260
3261 void WebViewImpl::clearScrollAndScaleOverride()
3262 {
3263 if (!page())
3264 return;
3265
3266 page()->frameHost().clearScrollAndScaleOverride();
3267 resetScrollAndScaleState();
3268 }
3269
3252 void WebViewImpl::scrollAndRescaleViewports(float scaleFactor, 3270 void WebViewImpl::scrollAndRescaleViewports(float scaleFactor,
3253 const IntPoint& mainFrameOrigin, 3271 const IntPoint& mainFrameOrigin,
3254 const FloatPoint& visualViewportOrigin) 3272 const FloatPoint& visualViewportOrigin)
3255 { 3273 {
3256 if (!page()) 3274 if (!page())
3257 return; 3275 return;
3258 3276
3259 if (!mainFrameImpl()) 3277 if (!mainFrameImpl())
3260 return; 3278 return;
3261 3279
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
3377 } else { 3395 } else {
3378 constraints.minimumScale = -1; 3396 constraints.minimumScale = -1;
3379 constraints.maximumScale = -1; 3397 constraints.maximumScale = -1;
3380 } 3398 }
3381 page()->frameHost().setUserAgentPageScaleConstraints(constraints); 3399 page()->frameHost().setUserAgentPageScaleConstraints(constraints);
3382 } 3400 }
3383 3401
3384 IntSize WebViewImpl::mainFrameSize() 3402 IntSize WebViewImpl::mainFrameSize()
3385 { 3403 {
3386 // The frame size should match the viewport size at minimum scale, since the 3404 // The frame size should match the viewport size at minimum scale, since the
3387 // viewport must always be contained by the frame. 3405 // viewport must always be contained by the frame. As ScrollAndScaleEmulator
3406 // may override the minimum scale, it is responsible for this calculation if
3407 // it is active.
3408 if (page() && page()->frameHost().scrollAndScaleEmulator()) {
3409 return page()->frameHost().scrollAndScaleEmulator()->mainFrameSize(m_siz e);
3410 }
3411
3388 FloatSize frameSize(m_size); 3412 FloatSize frameSize(m_size);
3389 frameSize.scale(1 / minimumPageScaleFactor()); 3413 frameSize.scale(1 / minimumPageScaleFactor());
3390 return expandedIntSize(frameSize); 3414 return expandedIntSize(frameSize);
3391 } 3415 }
3392 3416
3393 PageScaleConstraintsSet& WebViewImpl::pageScaleConstraintsSet() const 3417 PageScaleConstraintsSet& WebViewImpl::pageScaleConstraintsSet() const
3394 { 3418 {
3395 return page()->frameHost().pageScaleConstraintsSet(); 3419 return page()->frameHost().pageScaleConstraintsSet();
3396 } 3420 }
3397 3421
(...skipping 1218 matching lines...) Expand 10 before | Expand all | Expand 10 after
4616 return nullptr; 4640 return nullptr;
4617 return focusedFrame; 4641 return focusedFrame;
4618 } 4642 }
4619 4643
4620 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const 4644 LocalFrame* WebViewImpl::focusedLocalFrameAvailableForIme() const
4621 { 4645 {
4622 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr; 4646 return m_imeAcceptEvents ? focusedLocalFrameInWidget() : nullptr;
4623 } 4647 }
4624 4648
4625 } // namespace blink 4649 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698