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 "config.h" | 5 #include "config.h" |
6 #include "web/DevToolsEmulator.h" | 6 #include "web/DevToolsEmulator.h" |
7 | 7 |
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/page/Page.h" | 10 #include "core/page/Page.h" |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 m_hidePinchScrollbarsNearMinScale = enabled; | 160 m_hidePinchScrollbarsNearMinScale = enabled; |
161 if (m_webViewImpl->layerTreeView()) | 161 if (m_webViewImpl->layerTreeView()) |
162 m_webViewImpl->layerTreeView()->setHidePinchScrollbarsNearMinScale(enabl
ed); | 162 m_webViewImpl->layerTreeView()->setHidePinchScrollbarsNearMinScale(enabl
ed); |
163 } | 163 } |
164 | 164 |
165 void DevToolsEmulator::enableDeviceEmulation(const WebDeviceEmulationParams& par
ams) | 165 void DevToolsEmulator::enableDeviceEmulation(const WebDeviceEmulationParams& par
ams) |
166 { | 166 { |
167 if (!m_deviceMetricsEnabled) { | 167 if (!m_deviceMetricsEnabled) { |
168 m_deviceMetricsEnabled = true; | 168 m_deviceMetricsEnabled = true; |
169 m_webViewImpl->setBackgroundColorOverride(Color::darkGray); | 169 m_webViewImpl->setBackgroundColorOverride(Color::darkGray); |
170 m_webViewImpl->updateShowFPSCounterAndContinuousPainting(); | 170 m_webViewImpl->updateShowFPSCounter(); |
171 } | 171 } |
172 | 172 |
173 m_webViewImpl->page()->settings().setDeviceScaleAdjustment(calculateDeviceSc
aleAdjustment(params.viewSize.width, params.viewSize.height, params.deviceScaleF
actor)); | 173 m_webViewImpl->page()->settings().setDeviceScaleAdjustment(calculateDeviceSc
aleAdjustment(params.viewSize.width, params.viewSize.height, params.deviceScaleF
actor)); |
174 | 174 |
175 if (params.screenPosition == WebDeviceEmulationParams::Mobile) | 175 if (params.screenPosition == WebDeviceEmulationParams::Mobile) |
176 enableMobileEmulation(); | 176 enableMobileEmulation(); |
177 else | 177 else |
178 disableMobileEmulation(); | 178 disableMobileEmulation(); |
179 | 179 |
180 m_webViewImpl->setCompositorDeviceScaleFactorOverride(params.deviceScaleFact
or); | 180 m_webViewImpl->setCompositorDeviceScaleFactorOverride(params.deviceScaleFact
or); |
181 m_webViewImpl->setRootLayerTransform(WebSize(params.offset.x, params.offset.
y), params.scale); | 181 m_webViewImpl->setRootLayerTransform(WebSize(params.offset.x, params.offset.
y), params.scale); |
182 if (Document* document = m_webViewImpl->mainFrameImpl()->frame()->document()
) { | 182 if (Document* document = m_webViewImpl->mainFrameImpl()->frame()->document()
) { |
183 document->styleResolverChanged(); | 183 document->styleResolverChanged(); |
184 document->mediaQueryAffectingValueChanged(); | 184 document->mediaQueryAffectingValueChanged(); |
185 } | 185 } |
186 } | 186 } |
187 | 187 |
188 void DevToolsEmulator::disableDeviceEmulation() | 188 void DevToolsEmulator::disableDeviceEmulation() |
189 { | 189 { |
190 if (!m_deviceMetricsEnabled) | 190 if (!m_deviceMetricsEnabled) |
191 return; | 191 return; |
192 | 192 |
193 m_deviceMetricsEnabled = false; | 193 m_deviceMetricsEnabled = false; |
194 m_webViewImpl->setBackgroundColorOverride(Color::transparent); | 194 m_webViewImpl->setBackgroundColorOverride(Color::transparent); |
195 m_webViewImpl->updateShowFPSCounterAndContinuousPainting(); | 195 m_webViewImpl->updateShowFPSCounter(); |
196 m_webViewImpl->page()->settings().setDeviceScaleAdjustment(m_embedderDeviceS
caleAdjustment); | 196 m_webViewImpl->page()->settings().setDeviceScaleAdjustment(m_embedderDeviceS
caleAdjustment); |
197 disableMobileEmulation(); | 197 disableMobileEmulation(); |
198 m_webViewImpl->setCompositorDeviceScaleFactorOverride(0.f); | 198 m_webViewImpl->setCompositorDeviceScaleFactorOverride(0.f); |
199 m_webViewImpl->setRootLayerTransform(WebSize(0.f, 0.f), 1.f); | 199 m_webViewImpl->setRootLayerTransform(WebSize(0.f, 0.f), 1.f); |
200 m_webViewImpl->setPageScaleFactor(1.f); | 200 m_webViewImpl->setPageScaleFactor(1.f); |
201 if (Document* document = m_webViewImpl->mainFrameImpl()->frame()->document()
) { | 201 if (Document* document = m_webViewImpl->mainFrameImpl()->frame()->document()
) { |
202 document->styleResolverChanged(); | 202 document->styleResolverChanged(); |
203 document->mediaQueryAffectingValueChanged(); | 203 document->mediaQueryAffectingValueChanged(); |
204 } | 204 } |
205 } | 205 } |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 m_lastPinchAnchorCss.clear(); | 306 m_lastPinchAnchorCss.clear(); |
307 m_lastPinchAnchorDip.clear(); | 307 m_lastPinchAnchorDip.clear(); |
308 } | 308 } |
309 return true; | 309 return true; |
310 } | 310 } |
311 | 311 |
312 return false; | 312 return false; |
313 } | 313 } |
314 | 314 |
315 } // namespace blink | 315 } // namespace blink |
OLD | NEW |