Index: Source/core/inspector/InspectorPageAgent.cpp |
diff --git a/Source/core/inspector/InspectorPageAgent.cpp b/Source/core/inspector/InspectorPageAgent.cpp |
index 64e95846ffb7e262c3effbd040905f649424df3d..be46bf617b477dda5dc61da19ace1b45cbd253cf 100644 |
--- a/Source/core/inspector/InspectorPageAgent.cpp |
+++ b/Source/core/inspector/InspectorPageAgent.cpp |
@@ -38,7 +38,6 @@ |
#include "core/animation/AnimationTimeline.h" |
#include "core/css/StyleSheetContents.h" |
#include "core/css/resolver/StyleResolver.h" |
-#include "core/css/resolver/ViewportStyleResolver.h" |
#include "core/dom/DOMImplementation.h" |
#include "core/dom/Document.h" |
#include "core/fetch/CSSStyleSheetResource.h" |
@@ -437,11 +436,12 @@ InspectorPageAgent::InspectorPageAgent(Page* page, InjectedScriptManager* inject |
, m_originalDeviceSupportsMouse(false) |
, m_originalDeviceSupportsTouch(false) |
, m_originalMaxTouchPoints(0) |
- , m_embedderTextAutosizingEnabled(m_page->settings().textAutosizingEnabled()) |
, m_embedderFontScaleFactor(m_page->settings().deviceScaleAdjustment()) |
+ , m_embedderTextAutosizingEnabled(m_page->settings().textAutosizingEnabled()) |
, m_embedderPreferCompositingToLCDTextEnabled(m_page->settings().preferCompositingToLCDTextEnabled()) |
, m_embedderScriptEnabled(m_page->settings().scriptEnabled()) |
, m_reloading(false) |
+ , m_embedderUseMobileViewport(m_page->settings().useMobileViewportStyle()) |
{ |
} |
@@ -476,6 +476,14 @@ void InspectorPageAgent::setScriptEnabled(bool enabled) |
m_page->settings().setScriptEnabled(enabled); |
} |
+void InspectorPageAgent::setUseMobileViewportStyle(bool enabled) |
+{ |
+ m_embedderUseMobileViewport = enabled; |
+ bool emulateMobileEnabled = m_enabled && m_deviceMetricsOverridden && m_emulateMobileEnabled; |
+ if (!emulateMobileEnabled) |
+ m_page->settings().setUseMobileViewportStyle(enabled); |
+} |
+ |
void InspectorPageAgent::setFrontend(InspectorFrontend* frontend) |
{ |
m_frontend = frontend->page(); |
@@ -1350,10 +1358,12 @@ void InspectorPageAgent::updateViewMetrics(bool enabled, int width, int height, |
m_page->settings().setTextAutosizingEnabled(mobile); |
m_page->settings().setPreferCompositingToLCDTextEnabled(mobile); |
m_page->settings().setDeviceScaleAdjustment(calculateFontScaleFactor(width, height, static_cast<float>(deviceScaleFactor))); |
+ m_page->settings().setUseMobileViewportStyle(mobile); |
} else { |
m_page->settings().setTextAutosizingEnabled(m_embedderTextAutosizingEnabled); |
m_page->settings().setPreferCompositingToLCDTextEnabled(m_embedderPreferCompositingToLCDTextEnabled); |
m_page->settings().setDeviceScaleAdjustment(m_embedderFontScaleFactor); |
+ m_page->settings().setUseMobileViewportStyle(m_embedderUseMobileViewport); |
} |
// FIXME: allow metrics override, fps counter and continuous painting at the same time: crbug.com/299837. |
@@ -1409,19 +1419,6 @@ void InspectorPageAgent::setEmulatedMedia(ErrorString*, const String& media) |
} |
} |
-bool InspectorPageAgent::applyViewportStyleOverride(StyleResolver* resolver) |
-{ |
- if (!m_deviceMetricsOverridden || !m_emulateMobileEnabled) |
- return false; |
- |
- RefPtrWillBeRawPtr<StyleSheetContents> styleSheet = StyleSheetContents::create(CSSParserContext(UASheetMode, 0)); |
- styleSheet->parseString(loadResourceAsASCIIString("viewportAndroid.css")); |
- OwnPtrWillBeRawPtr<RuleSet> ruleSet = RuleSet::create(); |
- ruleSet->addRulesFromSheet(styleSheet.get(), MediaQueryEvaluator("screen")); |
- resolver->viewportStyleResolver()->collectViewportRules(ruleSet.get(), ViewportStyleResolver::UserAgentOrigin); |
- return true; |
-} |
- |
void InspectorPageAgent::applyEmulatedMedia(String* media) |
{ |
String emulatedMedia = m_state->getString(PageAgentState::pageAgentEmulatedMedia); |