Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(476)

Unified Diff: Source/core/inspector/InspectorPageAgent.cpp

Issue 146683003: Settings should not call into inspector (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase & incorporated review comments Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/inspector/InspectorPageAgent.h ('k') | Source/core/page/Page.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/inspector/InspectorPageAgent.cpp
diff --git a/Source/core/inspector/InspectorPageAgent.cpp b/Source/core/inspector/InspectorPageAgent.cpp
index c1d6981e267a15ad5347ee3cea975d821f76439b..0bffef1de2b9a951fccef500cddb0a183c71dcf0 100644
--- a/Source/core/inspector/InspectorPageAgent.cpp
+++ b/Source/core/inspector/InspectorPageAgent.cpp
@@ -331,6 +331,8 @@ InspectorPageAgent::InspectorPageAgent(Page* page, InjectedScriptManager* inject
, m_ignoreScriptsEnabledNotification(false)
, m_deviceMetricsOverridden(false)
, m_emulateViewportEnabled(false)
+ , m_settingsCacheTextAutosizingEnabled(false)
+ , m_settingsCacheFontScaleFactor(1.0)
{
}
@@ -780,7 +782,7 @@ void InspectorPageAgent::getScriptExecutionStatus(ErrorString*, PageCommandHandl
if (frame) {
disabledByScriptController = !frame->script().canExecuteScripts(NotAboutToExecuteScript);
if (frame->settings())
- disabledInSettings = !frame->settings()->isScriptEnabled();
+ disabledInSettings = !frame->settings()->scriptEnabled();
}
if (!disabledByScriptController) {
@@ -1046,12 +1048,28 @@ void InspectorPageAgent::didRecalculateStyle()
m_overlay->update();
}
-void InspectorPageAgent::scriptsEnabled(bool isEnabled)
+void InspectorPageAgent::settingsChanged()
{
- if (m_ignoreScriptsEnabledNotification)
+ Settings* settings = mainFrame()->settings();
+ if (!settings)
return;
- m_frontend->scriptsEnabled(isEnabled);
+ if (!m_ignoreScriptsEnabledNotification)
+ m_frontend->scriptsEnabled(settings->scriptEnabled());
pfeldman 2014/01/30 16:34:08 We don't want to call scriptsEnabled with the same
+
+ if (!m_deviceMetricsOverridden) {
+ m_settingsCacheTextAutosizingEnabled = settings->textAutosizingEnabled();
pfeldman 2014/01/30 16:34:08 You want to store these unconditionally so that yo
+ m_settingsCacheFontScaleFactor = settings->deviceScaleAdjustment();
+ } else {
+ if (settings->textAutosizingEnabled() != overrideTextAutosizing()) {
+ m_settingsCacheTextAutosizingEnabled = settings->textAutosizingEnabled();
+ settings->setTextAutosizingEnabled(overrideTextAutosizing());
pfeldman 2014/01/30 16:34:08 So upon setTextAutosizingEnabled("A"), you will ac
gnana 2014/01/31 14:21:09 After Placing InspectorInstrumentation::overrideTe
+ }
+ if (settings->deviceScaleAdjustment() != overrideFontScaleFactor()) {
+ m_settingsCacheFontScaleFactor = settings->deviceScaleAdjustment();
+ settings->setDeviceScaleAdjustment(overrideFontScaleFactor());
+ }
+ }
}
PassRefPtr<TypeBuilder::Page::Frame> InspectorPageAgent::buildObjectForFrame(Frame* frame)
@@ -1124,6 +1142,15 @@ void InspectorPageAgent::updateViewMetrics(int width, int height, double deviceS
return;
m_deviceMetricsOverridden = width && height;
+ Settings& settings = m_page->settings();
+ if (m_deviceMetricsOverridden) {
+ settings.setTextAutosizingEnabled(overrideTextAutosizing());
+ settings.setDeviceScaleAdjustment(overrideFontScaleFactor());
+ } else {
+ settings.setTextAutosizingEnabled(m_settingsCacheTextAutosizingEnabled);
+ settings.setDeviceScaleAdjustment(m_settingsCacheFontScaleFactor);
+ }
+
m_emulateViewportEnabled = emulateViewport;
m_client->overrideDeviceMetrics(width, height, static_cast<float>(deviceScaleFactor), emulateViewport, fitWindow);
@@ -1162,17 +1189,13 @@ void InspectorPageAgent::clearDeviceOrientationOverride(ErrorString* error)
setDeviceOrientationOverride(error, 0, 0, 0);
}
-bool InspectorPageAgent::overrideTextAutosizing(bool textAutosizing)
+bool InspectorPageAgent::overrideTextAutosizing()
{
- if (!m_deviceMetricsOverridden)
- return textAutosizing;
return m_state->getBoolean(PageAgentState::pageAgentTextAutosizingOverride);
}
-float InspectorPageAgent::overrideFontScaleFactor(float fontScaleFactor)
+float InspectorPageAgent::overrideFontScaleFactor()
{
- if (!m_deviceMetricsOverridden)
- return fontScaleFactor;
return static_cast<float>(m_state->getDouble(PageAgentState::fontScaleFactor));
}
« no previous file with comments | « Source/core/inspector/InspectorPageAgent.h ('k') | Source/core/page/Page.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698