void WebDevToolsAgentImpl::setDeviceMetricsOverride(int width, int height, float deviceScaleFactor, bool emulateViewport, bool fitWindow) { if (!m_deviceMetricsEnabled) { m_deviceMetricsEnabled = true; m_webViewImpl->setBackgroundColorOverride(Color::darkGray); } if (emulateViewport) enableViewportEmulation(); else disableViewportEmulation(); WebDeviceEmulationParams params; params.screenPosition = emulateViewport ? WebDeviceEmulationParams::Mobile : WebDeviceEmulationParams::Desktop; params.deviceScaleFactor = deviceScaleFactor; params.viewSize = WebSize(width, height); params.fitToView = fitWindow; params.viewInsets = WebSize(0, 0); m_client->enableDeviceEmulation(params); }
void WebDevToolsAgentImpl::overrideDeviceMetrics(int width, int height, float deviceScaleFactor, bool emulateViewport, bool fitWindow) { if (!width && !height) { if (m_deviceMetricsEnabled) { m_deviceMetricsEnabled = false; m_webViewImpl->setBackgroundColorOverride(Color::transparent); RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(m_isOverlayScrollbarsEnabled); disableViewportEmulation(); m_client->disableDeviceEmulation(); } } else { if (!m_deviceMetricsEnabled) { m_deviceMetricsEnabled = true; m_webViewImpl->setBackgroundColorOverride(Color::darkGray); m_isOverlayScrollbarsEnabled = RuntimeEnabledFeatures::overlayScrollbarsEnabled(); RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(true); } if (emulateViewport) enableViewportEmulation(); else disableViewportEmulation(); m_client->enableDeviceEmulation(IntRect(10, 10, width, height), IntRect(0, 0, width, height), deviceScaleFactor, fitWindow); } }