| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "web/DevToolsEmulator.h" | 5 #include "web/DevToolsEmulator.h" |
| 6 | 6 |
| 7 #include "core/frame/FrameHost.h" | 7 #include "core/frame/FrameHost.h" |
| 8 #include "core/frame/FrameView.h" | 8 #include "core/frame/FrameView.h" |
| 9 #include "core/frame/Settings.h" | 9 #include "core/frame/Settings.h" |
| 10 #include "core/frame/VisualViewport.h" | 10 #include "core/frame/VisualViewport.h" |
| 11 #include "core/page/Page.h" | 11 #include "core/page/Page.h" |
| 12 #include "core/style/ComputedStyle.h" | 12 #include "core/style/ComputedStyle.h" |
| 13 #include "platform/RuntimeEnabledFeatures.h" | 13 #include "platform/RuntimeEnabledFeatures.h" |
| 14 #include "platform/geometry/FloatRect.h" | 14 #include "platform/geometry/FloatRect.h" |
| 15 #include "platform/geometry/FloatSize.h" | 15 #include "platform/geometry/FloatSize.h" |
| 16 #include "platform/geometry/IntRect.h" | 16 #include "platform/geometry/IntRect.h" |
| 17 #include "platform/geometry/IntSize.h" | 17 #include "platform/geometry/IntSize.h" |
| 18 #include "public/platform/WebLayerTreeView.h" | 18 #include "public/platform/WebLayerTreeView.h" |
| 19 #include "web/WebInputEventConversion.h" | 19 #include "web/WebInputEventConversion.h" |
| 20 #include "web/WebLocalFrameImpl.h" | 20 #include "web/WebLocalFrameImpl.h" |
| 21 #include "web/WebSettingsImpl.h" | 21 #include "web/WebSettingsImpl.h" |
| 22 #include "web/WebViewImpl.h" | 22 #include "web/WebViewImpl.h" |
| 23 #include "wtf/PtrUtil.h" | 23 #include "wtf/PtrUtil.h" |
| 24 | 24 |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 static float calculateDeviceScaleAdjustment(int width, | 27 static float calculateDeviceScaleAdjustment(int width, |
| 28 int height, | 28 int height, |
| 29 float deviceScaleFactor) { | 29 float deviceScaleFactor) { |
| 30 // Chromium on Android uses a device scale adjustment for fonts used in text a
utosizing for | 30 // Chromium on Android uses a device scale adjustment for fonts used in text |
| 31 // improved legibility. This function computes this adjusted value for text au
tosizing. | 31 // autosizing for improved legibility. This function computes this adjusted |
| 32 // value for text autosizing. |
| 32 // For a description of the Android device scale adjustment algorithm, see: | 33 // For a description of the Android device scale adjustment algorithm, see: |
| 33 // chrome/browser/chrome_content_browser_client.cc, GetDeviceScaleAdjustment(.
..) | 34 // chrome/browser/chrome_content_browser_client.cc, |
| 35 // GetDeviceScaleAdjustment(...) |
| 34 if (!width || !height || !deviceScaleFactor) | 36 if (!width || !height || !deviceScaleFactor) |
| 35 return 1; | 37 return 1; |
| 36 | 38 |
| 37 static const float kMinFSM = 1.05f; | 39 static const float kMinFSM = 1.05f; |
| 38 static const int kWidthForMinFSM = 320; | 40 static const int kWidthForMinFSM = 320; |
| 39 static const float kMaxFSM = 1.3f; | 41 static const float kMaxFSM = 1.3f; |
| 40 static const int kWidthForMaxFSM = 800; | 42 static const int kWidthForMaxFSM = 800; |
| 41 | 43 |
| 42 float minWidth = std::min(width, height) / deviceScaleFactor; | 44 float minWidth = std::min(width, height) / deviceScaleFactor; |
| 43 if (minWidth <= kWidthForMinFSM) | 45 if (minWidth <= kWidthForMinFSM) |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 return m_webViewImpl->page()->deviceScaleFactor(); | 338 return m_webViewImpl->page()->deviceScaleFactor(); |
| 337 } | 339 } |
| 338 | 340 |
| 339 void DevToolsEmulator::forceViewport(const WebFloatPoint& position, | 341 void DevToolsEmulator::forceViewport(const WebFloatPoint& position, |
| 340 float scale) { | 342 float scale) { |
| 341 GraphicsLayer* containerLayer = | 343 GraphicsLayer* containerLayer = |
| 342 m_webViewImpl->page()->frameHost().visualViewport().containerLayer(); | 344 m_webViewImpl->page()->frameHost().visualViewport().containerLayer(); |
| 343 if (!m_viewportOverride) { | 345 if (!m_viewportOverride) { |
| 344 m_viewportOverride = ViewportOverride(); | 346 m_viewportOverride = ViewportOverride(); |
| 345 | 347 |
| 346 // Disable clipping on the visual viewport layer, to ensure the whole area i
s painted. | 348 // Disable clipping on the visual viewport layer, to ensure the whole area |
| 349 // is painted. |
| 347 if (containerLayer) { | 350 if (containerLayer) { |
| 348 m_viewportOverride->originalVisualViewportMasking = | 351 m_viewportOverride->originalVisualViewportMasking = |
| 349 containerLayer->masksToBounds(); | 352 containerLayer->masksToBounds(); |
| 350 containerLayer->setMasksToBounds(false); | 353 containerLayer->setMasksToBounds(false); |
| 351 } | 354 } |
| 352 } | 355 } |
| 353 | 356 |
| 354 m_viewportOverride->position = position; | 357 m_viewportOverride->position = position; |
| 355 m_viewportOverride->scale = scale; | 358 m_viewportOverride->scale = scale; |
| 356 | 359 |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 m_lastPinchAnchorCss.reset(); | 517 m_lastPinchAnchorCss.reset(); |
| 515 m_lastPinchAnchorDip.reset(); | 518 m_lastPinchAnchorDip.reset(); |
| 516 } | 519 } |
| 517 return true; | 520 return true; |
| 518 } | 521 } |
| 519 | 522 |
| 520 return false; | 523 return false; |
| 521 } | 524 } |
| 522 | 525 |
| 523 } // namespace blink | 526 } // namespace blink |
| OLD | NEW |