| 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" |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 | 193 |
| 194 void DevToolsEmulator::enableDeviceEmulation( | 194 void DevToolsEmulator::enableDeviceEmulation( |
| 195 const WebDeviceEmulationParams& params) { | 195 const WebDeviceEmulationParams& params) { |
| 196 if (m_deviceMetricsEnabled && m_emulationParams.viewSize == params.viewSize && | 196 if (m_deviceMetricsEnabled && m_emulationParams.viewSize == params.viewSize && |
| 197 m_emulationParams.screenPosition == params.screenPosition && | 197 m_emulationParams.screenPosition == params.screenPosition && |
| 198 m_emulationParams.deviceScaleFactor == params.deviceScaleFactor && | 198 m_emulationParams.deviceScaleFactor == params.deviceScaleFactor && |
| 199 m_emulationParams.offset == params.offset && | 199 m_emulationParams.offset == params.offset && |
| 200 m_emulationParams.scale == params.scale) { | 200 m_emulationParams.scale == params.scale) { |
| 201 return; | 201 return; |
| 202 } | 202 } |
| 203 | |
| 204 m_emulationParams = params; | 203 m_emulationParams = params; |
| 205 | 204 |
| 206 if (!m_deviceMetricsEnabled) { | 205 if (!m_deviceMetricsEnabled) { |
| 207 m_deviceMetricsEnabled = true; | 206 m_deviceMetricsEnabled = true; |
| 208 if (params.viewSize.width || params.viewSize.height) | 207 if (params.viewSize.width || params.viewSize.height) |
| 209 m_webViewImpl->setBackgroundColorOverride(Color::darkGray); | 208 m_webViewImpl->setBackgroundColorOverride(Color::darkGray); |
| 210 } | 209 } |
| 211 | 210 |
| 212 m_webViewImpl->page()->settings().setDeviceScaleAdjustment( | 211 m_webViewImpl->page()->settings().setDeviceScaleAdjustment( |
| 213 calculateDeviceScaleAdjustment(params.viewSize.width, | 212 calculateDeviceScaleAdjustment(params.viewSize.width, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 227 if (m_webViewImpl->mainFrameImpl()) { | 226 if (m_webViewImpl->mainFrameImpl()) { |
| 228 if (Document* document = | 227 if (Document* document = |
| 229 m_webViewImpl->mainFrameImpl()->frame()->document()) | 228 m_webViewImpl->mainFrameImpl()->frame()->document()) |
| 230 document->mediaQueryAffectingValueChanged(); | 229 document->mediaQueryAffectingValueChanged(); |
| 231 } | 230 } |
| 232 } | 231 } |
| 233 | 232 |
| 234 void DevToolsEmulator::disableDeviceEmulation() { | 233 void DevToolsEmulator::disableDeviceEmulation() { |
| 235 if (!m_deviceMetricsEnabled) | 234 if (!m_deviceMetricsEnabled) |
| 236 return; | 235 return; |
| 237 | |
| 238 m_deviceMetricsEnabled = false; | 236 m_deviceMetricsEnabled = false; |
| 239 m_webViewImpl->setBackgroundColorOverride(Color::transparent); | 237 m_webViewImpl->setBackgroundColorOverride(Color::transparent); |
| 240 m_webViewImpl->page()->settings().setDeviceScaleAdjustment( | 238 m_webViewImpl->page()->settings().setDeviceScaleAdjustment( |
| 241 m_embedderDeviceScaleAdjustment); | 239 m_embedderDeviceScaleAdjustment); |
| 242 disableMobileEmulation(); | 240 disableMobileEmulation(); |
| 243 m_webViewImpl->setCompositorDeviceScaleFactorOverride(0.f); | 241 m_webViewImpl->setCompositorDeviceScaleFactorOverride(0.f); |
| 244 m_webViewImpl->setPageScaleFactor(1.f); | 242 m_webViewImpl->setPageScaleFactor(1.f); |
| 245 updateRootLayerTransform(); | 243 updateRootLayerTransform(); |
| 246 // mainFrameImpl() could be null during cleanup or remote <-> local swap. | 244 // mainFrameImpl() could be null during cleanup or remote <-> local swap. |
| 247 if (m_webViewImpl->mainFrameImpl()) { | 245 if (m_webViewImpl->mainFrameImpl()) { |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 m_lastPinchAnchorCss.reset(); | 517 m_lastPinchAnchorCss.reset(); |
| 520 m_lastPinchAnchorDip.reset(); | 518 m_lastPinchAnchorDip.reset(); |
| 521 } | 519 } |
| 522 return true; | 520 return true; |
| 523 } | 521 } |
| 524 | 522 |
| 525 return false; | 523 return false; |
| 526 } | 524 } |
| 527 | 525 |
| 528 } // namespace blink | 526 } // namespace blink |
| OLD | NEW |