Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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() || !mainFrameImpl()) | |
| 3214 return; | |
| 3215 | |
| 3216 FrameView * view = mainFrameImpl()->frameView(); | |
| 3217 if (!view) | |
| 3218 return; | |
| 3219 | |
| 3220 if (!m_scrollAndScaleEmulator) { | |
| 3221 m_scrollAndScaleEmulator = ScrollAndScaleEmulator::create(); | |
| 3222 | |
| 3223 // Force main thread scrolling, because we do not apply scroll position | |
| 3224 // overrides in the compositor thread. | |
| 3225 m_scrollAndScaleEmulator->disableThreadedScrolling(page()); | |
| 3226 } | |
| 3227 | |
| 3228 bool hasChanged = m_scrollAndScaleEmulator->update( | |
| 3229 static_cast<IntPoint>(params.scrollPosition), | |
| 3230 static_cast<FloatPoint>(params.visualViewportPosition), | |
| 3231 params.visualViewportScale); | |
| 3232 if (hasChanged) { | |
| 3233 view->setScrollAndScaleEmulator(m_scrollAndScaleEmulator); | |
| 3234 page()->frameHost().visualViewport().setScrollAndScaleEmulator(m_scrollA ndScaleEmulator); | |
| 3235 page()->frameHost().setUserAgentPageScaleConstraints(m_scrollAndScaleEmu lator->pageScaleConstraints()); | |
| 3236 } | |
| 3237 } | |
| 3238 | |
| 3239 void WebViewImpl::clearScrollAndScaleOverride() | |
| 3240 { | |
| 3241 if (!m_scrollAndScaleEmulator || !page() || !mainFrameImpl()) | |
| 3242 return; | |
| 3243 | |
| 3244 FrameView * view = mainFrameImpl()->frameView(); | |
| 3245 if (!view) | |
| 3246 return; | |
| 3247 | |
| 3248 m_scrollAndScaleEmulator->restoreThreadedScrolling(page()); | |
| 3249 | |
| 3250 view->setScrollAndScaleEmulator(nullptr); | |
| 3251 page()->frameHost().visualViewport().setScrollAndScaleEmulator(nullptr); | |
| 3252 page()->frameHost().setUserAgentPageScaleConstraints(PageScaleConstraints()) ; | |
| 3253 | |
| 3254 // TODO(eseckler): For some reason, we seem to need this enforce the cleared | |
| 3255 // constraints. Adding it in setScrollAndScaleOverride() makes the override | |
| 3256 // ineffective, though. | |
| 3257 page()->frameHost().pageScaleConstraintsSet().computeFinalConstraints(); | |
|
Eric Seckler
2016/06/30 20:01:28
Not sure why this line is necessary here (otherwis
| |
| 3258 | |
| 3259 m_scrollAndScaleEmulator.clear(); | |
| 3260 resetScrollAndScaleState(); | |
| 3261 } | |
| 3262 | |
| 3210 void WebViewImpl::scrollAndRescaleViewports(float scaleFactor, | 3263 void WebViewImpl::scrollAndRescaleViewports(float scaleFactor, |
| 3211 const IntPoint& mainFrameOrigin, | 3264 const IntPoint& mainFrameOrigin, |
| 3212 const FloatPoint& visualViewportOrigin) | 3265 const FloatPoint& visualViewportOrigin) |
| 3213 { | 3266 { |
| 3214 if (!page()) | 3267 if (!page()) |
| 3215 return; | 3268 return; |
| 3216 | 3269 |
| 3217 if (!mainFrameImpl()) | 3270 if (!mainFrameImpl()) |
| 3218 return; | 3271 return; |
| 3219 | 3272 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3333 constraints.maximumScale = pageScaleConstraintsSet().defaultConstraints( ).maximumScale; | 3386 constraints.maximumScale = pageScaleConstraintsSet().defaultConstraints( ).maximumScale; |
| 3334 } else { | 3387 } else { |
| 3335 constraints.minimumScale = -1; | 3388 constraints.minimumScale = -1; |
| 3336 constraints.maximumScale = -1; | 3389 constraints.maximumScale = -1; |
| 3337 } | 3390 } |
| 3338 page()->frameHost().setUserAgentPageScaleConstraints(constraints); | 3391 page()->frameHost().setUserAgentPageScaleConstraints(constraints); |
| 3339 } | 3392 } |
| 3340 | 3393 |
| 3341 IntSize WebViewImpl::mainFrameSize() | 3394 IntSize WebViewImpl::mainFrameSize() |
| 3342 { | 3395 { |
| 3396 FloatSize frameSize(m_size); | |
| 3397 | |
| 3343 // The frame size should match the viewport size at minimum scale, since the | 3398 // The frame size should match the viewport size at minimum scale, since the |
| 3344 // viewport must always be contained by the frame. | 3399 // viewport must always be contained by the frame. ScrollAndScaleEmulator |
| 3345 FloatSize frameSize(m_size); | 3400 // overrides the minimum scale in the userAgentConstraints. These overrides |
| 3401 // should be ignored for this calculation. | |
| 3402 if (m_scrollAndScaleEmulator) { | |
| 3403 pageScaleConstraintsSet().setUserAgentConstraints(PageScaleConstraints() ); | |
| 3404 pageScaleConstraintsSet().computeFinalConstraints(); | |
| 3405 } | |
| 3346 frameSize.scale(1 / minimumPageScaleFactor()); | 3406 frameSize.scale(1 / minimumPageScaleFactor()); |
| 3407 if (m_scrollAndScaleEmulator) { | |
| 3408 pageScaleConstraintsSet().setUserAgentConstraints(m_scrollAndScaleEmulat or->pageScaleConstraints()); | |
| 3409 pageScaleConstraintsSet().computeFinalConstraints(); | |
| 3410 } | |
| 3411 | |
| 3347 return expandedIntSize(frameSize); | 3412 return expandedIntSize(frameSize); |
| 3348 } | 3413 } |
| 3349 | 3414 |
| 3350 PageScaleConstraintsSet& WebViewImpl::pageScaleConstraintsSet() const | 3415 PageScaleConstraintsSet& WebViewImpl::pageScaleConstraintsSet() const |
| 3351 { | 3416 { |
| 3352 return page()->frameHost().pageScaleConstraintsSet(); | 3417 return page()->frameHost().pageScaleConstraintsSet(); |
| 3353 } | 3418 } |
| 3354 | 3419 |
| 3355 void WebViewImpl::refreshPageScaleFactorAfterLayout() | 3420 void WebViewImpl::refreshPageScaleFactorAfterLayout() |
| 3356 { | 3421 { |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3825 m_rootLayerScale = rootLayerScale; | 3890 m_rootLayerScale = rootLayerScale; |
| 3826 m_rootLayerOffset = rootLayerOffset; | 3891 m_rootLayerOffset = rootLayerOffset; |
| 3827 if (mainFrameImpl()) | 3892 if (mainFrameImpl()) |
| 3828 mainFrameImpl()->setInputEventsTransformForEmulation(m_rootLayerOffset, m_rootLayerScale); | 3893 mainFrameImpl()->setInputEventsTransformForEmulation(m_rootLayerOffset, m_rootLayerScale); |
| 3829 updateRootLayerTransform(); | 3894 updateRootLayerTransform(); |
| 3830 } | 3895 } |
| 3831 | 3896 |
| 3832 void WebViewImpl::enableDeviceEmulation(const WebDeviceEmulationParams& params) | 3897 void WebViewImpl::enableDeviceEmulation(const WebDeviceEmulationParams& params) |
| 3833 { | 3898 { |
| 3834 m_devToolsEmulator->enableDeviceEmulation(params); | 3899 m_devToolsEmulator->enableDeviceEmulation(params); |
| 3900 setScrollAndScaleOverride(params); | |
| 3835 } | 3901 } |
| 3836 | 3902 |
| 3837 void WebViewImpl::disableDeviceEmulation() | 3903 void WebViewImpl::disableDeviceEmulation() |
| 3838 { | 3904 { |
| 3905 clearScrollAndScaleOverride(); | |
| 3839 m_devToolsEmulator->disableDeviceEmulation(); | 3906 m_devToolsEmulator->disableDeviceEmulation(); |
| 3840 } | 3907 } |
| 3841 | 3908 |
| 3842 WebAXObject WebViewImpl::accessibilityObject() | 3909 WebAXObject WebViewImpl::accessibilityObject() |
| 3843 { | 3910 { |
| 3844 if (!mainFrameImpl()) | 3911 if (!mainFrameImpl()) |
| 3845 return WebAXObject(); | 3912 return WebAXObject(); |
| 3846 | 3913 |
| 3847 Document* document = mainFrameImpl()->frame()->document(); | 3914 Document* document = mainFrameImpl()->frame()->document(); |
| 3848 return WebAXObject(toAXObjectCacheImpl(document->axObjectCache())->root()); | 3915 return WebAXObject(toAXObjectCacheImpl(document->axObjectCache())->root()); |
| (...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4521 { | 4588 { |
| 4522 // TODO(oshima): Investigate if this should return the ScreenInfo's scale fa ctor rather than | 4589 // 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. | 4590 // page's scale factor, which can be 1 in use-zoom-for-dsf mode. |
| 4524 if (!page()) | 4591 if (!page()) |
| 4525 return 1; | 4592 return 1; |
| 4526 | 4593 |
| 4527 return page()->deviceScaleFactor(); | 4594 return page()->deviceScaleFactor(); |
| 4528 } | 4595 } |
| 4529 | 4596 |
| 4530 } // namespace blink | 4597 } // namespace blink |
| OLD | NEW |