Chromium Code Reviews| Index: Source/web/WebDevToolsAgentImpl.cpp |
| =================================================================== |
| --- Source/web/WebDevToolsAgentImpl.cpp (revision 157211) |
| +++ Source/web/WebDevToolsAgentImpl.cpp (working copy) |
| @@ -34,11 +34,13 @@ |
| #include "InspectorBackendDispatcher.h" |
| #include "InspectorFrontend.h" |
| #include "InspectorProtocolVersion.h" |
| +#include "RuntimeEnabledFeatures.h" |
| #include "WebDataSource.h" |
| #include "WebDevToolsAgentClient.h" |
| #include "WebFrameImpl.h" |
| #include "WebInputEventConversion.h" |
| #include "WebMemoryUsageInfo.h" |
| +#include "WebSettings.h" |
| #include "WebViewClient.h" |
| #include "WebViewImpl.h" |
| #include "bindings/v8/PageScriptDebugServer.h" |
| @@ -53,6 +55,7 @@ |
| #include "core/page/FrameView.h" |
| #include "core/page/Page.h" |
| #include "core/page/PageGroup.h" |
| +#include "core/page/Settings.h" |
| #include "core/platform/JSONValues.h" |
| #include "core/platform/graphics/GraphicsContext.h" |
| #include "core/platform/network/ResourceError.h" |
| @@ -187,6 +190,7 @@ |
| OwnPtr<WebDevToolsAgent::MessageDescriptor> m_descriptor; |
| }; |
| +// FIXME: remove DeviceMetricsSupport. |
|
pfeldman
2013/09/19 12:46:05
Do it right away.
|
| class DeviceMetricsSupport { |
| public: |
| DeviceMetricsSupport(WebViewImpl* webView) |
| @@ -358,6 +362,7 @@ |
| , m_client(client) |
| , m_webViewImpl(webViewImpl) |
| , m_attached(false) |
| + , m_deviceMetricsEnabled(false) |
|
pfeldman
2013/09/19 12:46:05
You need to initialize all booleans here.
dgozman
2013/09/19 13:59:38
Done.
|
| { |
| ASSERT(m_hostId > 0); |
| ClientMessageLoopAdapter::ensureClientMessageLoopCreated(m_client); |
| @@ -448,7 +453,8 @@ |
| bool WebDevToolsAgentImpl::metricsOverridden() |
| { |
| - return !!m_metricsSupport; |
| + // FIXME: cleanup usages of this function and remove it. |
|
pfeldman
2013/09/19 12:46:05
ditto
|
| + return false; |
| } |
| void WebDevToolsAgentImpl::webViewResized(const WebSize& size) |
| @@ -487,24 +493,58 @@ |
| void WebDevToolsAgentImpl::overrideDeviceMetrics(int width, int height, float fontScaleFactor, bool fitWindow) |
| { |
| + // FIXME: enable viewport after UI problems with pageScaleFactor will be fixed. |
| + bool enableViewport = false; |
| + |
| + bool needReload = false; |
| if (!width && !height) { |
| - if (m_metricsSupport) |
| - m_metricsSupport.clear(); |
| - if (InspectorController* ic = inspectorController()) |
| - ic->webViewResized(IntSize()); |
| - return; |
| - } |
| + if (m_deviceMetricsEnabled) { |
| + needReload = true; |
| + RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(m_isOverlayScrollbarsEnabled); |
| + if (enableViewport) { |
| + RuntimeEnabledFeatures::setCSSViewportEnabled(m_isCSSViewportEnabled); |
| + m_webViewImpl->enableFixedLayoutMode(false); |
| + m_webViewImpl->settings()->setViewportEnabled(false); |
| + m_webViewImpl->page()->settings().setTextAutosizingEnabled(false); |
| + m_webViewImpl->setIgnoreViewportTagScaleLimits(false); |
| + m_webViewImpl->setPageScaleFactorLimits(1.f, 1.f); |
|
apavlov
2013/09/19 12:47:57
Is the float literal notation really required here
dgozman
2013/09/19 13:59:38
Done.
|
| + } |
| + m_webViewImpl->client()->emulateDevice(false /* enabled */, IntSize(), IntRect(), 1.0f, false); |
| + } |
| + m_deviceMetricsEnabled = false; |
| + } else { |
| + if (!m_deviceMetricsEnabled) { |
| + needReload = true; |
| - if (!m_metricsSupport) |
| - m_metricsSupport = adoptPtr(new DeviceMetricsSupport(m_webViewImpl)); |
| + m_isOverlayScrollbarsEnabled = RuntimeEnabledFeatures::overlayScrollbarsEnabled(); |
| + RuntimeEnabledFeatures::setOverlayScrollbarsEnabled(true); |
| - m_metricsSupport->setDeviceMetrics(width, height, fontScaleFactor, fitWindow); |
| - if (InspectorController* ic = inspectorController()) { |
| - WebSize size = m_webViewImpl->size(); |
| - ic->webViewResized(IntSize(size.width, size.height)); |
| + if (enableViewport) { |
| + m_isCSSViewportEnabled = RuntimeEnabledFeatures::cssViewportEnabled(); |
| + RuntimeEnabledFeatures::setCSSViewportEnabled(true); |
| + // FIXME: save and restore next two values. |
|
apavlov
2013/09/19 12:47:57
Guess this comment should note that this should be
dgozman
2013/09/19 13:59:38
Nice catch! Thanks.
|
| + m_webViewImpl->enableFixedLayoutMode(true); |
| + m_webViewImpl->settings()->setViewportEnabled(true); |
| + m_webViewImpl->page()->settings().setTextAutosizingEnabled(true); |
|
apavlov
2013/09/19 12:47:57
This one is dubious. Text autosizing should be ena
dgozman
2013/09/19 13:59:38
Safari, Firefox and IE has this functionality. Add
|
| + m_webViewImpl->setIgnoreViewportTagScaleLimits(fontScaleFactor > 1.f); |
| + m_webViewImpl->setPageScaleFactorLimits(-1.f, -1.f); |
| + } |
| + } |
| + if (enableViewport) |
| + m_webViewImpl->page()->settings().setTextAutosizingFontScaleFactor(fontScaleFactor); |
| + |
| + m_webViewImpl->client()->emulateDevice(true /* enabled */, IntSize(width, height), IntRect(0, 0, width, height), 2.0f, fitWindow); |
| + m_deviceMetricsEnabled = true; |
| } |
| + if (needReload && m_webViewImpl->mainFrameImpl()) |
| + m_webViewImpl->mainFrameImpl()->reload(false /* ignoreCache */); |
| } |
| +void WebDevToolsAgentImpl::setDeviceEmulationScales(bool enabled, float deviceScaleFactor, float rootLayerScale) |
| +{ |
| + m_webViewImpl->setDeviceEmulationScales(enabled, deviceScaleFactor, rootLayerScale); |
| +} |
| + |
| void WebDevToolsAgentImpl::autoZoomPageToFitWidth() |
| { |
| if (m_metricsSupport) |