OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 , m_injectedScriptManager(injectedScriptManager) | 326 , m_injectedScriptManager(injectedScriptManager) |
327 , m_client(client) | 327 , m_client(client) |
328 , m_frontend(0) | 328 , m_frontend(0) |
329 , m_overlay(overlay) | 329 , m_overlay(overlay) |
330 , m_lastScriptIdentifier(0) | 330 , m_lastScriptIdentifier(0) |
331 , m_enabled(false) | 331 , m_enabled(false) |
332 , m_geolocationOverridden(false) | 332 , m_geolocationOverridden(false) |
333 , m_ignoreScriptsEnabledNotification(false) | 333 , m_ignoreScriptsEnabledNotification(false) |
334 , m_deviceMetricsOverridden(false) | 334 , m_deviceMetricsOverridden(false) |
335 , m_emulateViewportEnabled(false) | 335 , m_emulateViewportEnabled(false) |
| 336 , m_settingsCacheTextAutosizingEnabled(false) |
| 337 , m_settingsCacheFontScaleFactor(1.0) |
336 { | 338 { |
337 } | 339 } |
338 | 340 |
339 void InspectorPageAgent::setFrontend(InspectorFrontend* frontend) | 341 void InspectorPageAgent::setFrontend(InspectorFrontend* frontend) |
340 { | 342 { |
341 m_frontend = frontend->page(); | 343 m_frontend = frontend->page(); |
342 } | 344 } |
343 | 345 |
344 void InspectorPageAgent::clearFrontend() | 346 void InspectorPageAgent::clearFrontend() |
345 { | 347 { |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 } | 777 } |
776 | 778 |
777 void InspectorPageAgent::getScriptExecutionStatus(ErrorString*, PageCommandHandl
er::Result::Enum* status) | 779 void InspectorPageAgent::getScriptExecutionStatus(ErrorString*, PageCommandHandl
er::Result::Enum* status) |
778 { | 780 { |
779 bool disabledByScriptController = false; | 781 bool disabledByScriptController = false; |
780 bool disabledInSettings = false; | 782 bool disabledInSettings = false; |
781 Frame* frame = mainFrame(); | 783 Frame* frame = mainFrame(); |
782 if (frame) { | 784 if (frame) { |
783 disabledByScriptController = !frame->script().canExecuteScripts(NotAbout
ToExecuteScript); | 785 disabledByScriptController = !frame->script().canExecuteScripts(NotAbout
ToExecuteScript); |
784 if (frame->settings()) | 786 if (frame->settings()) |
785 disabledInSettings = !frame->settings()->isScriptEnabled(); | 787 disabledInSettings = !frame->settings()->scriptEnabled(); |
786 } | 788 } |
787 | 789 |
788 if (!disabledByScriptController) { | 790 if (!disabledByScriptController) { |
789 *status = PageCommandHandler::Result::Allowed; | 791 *status = PageCommandHandler::Result::Allowed; |
790 return; | 792 return; |
791 } | 793 } |
792 | 794 |
793 if (disabledInSettings) | 795 if (disabledInSettings) |
794 *status = PageCommandHandler::Result::Disabled; | 796 *status = PageCommandHandler::Result::Disabled; |
795 else | 797 else |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1044 #endif | 1046 #endif |
1045 m_frontend->frameResized(); | 1047 m_frontend->frameResized(); |
1046 } | 1048 } |
1047 | 1049 |
1048 void InspectorPageAgent::didRecalculateStyle() | 1050 void InspectorPageAgent::didRecalculateStyle() |
1049 { | 1051 { |
1050 if (m_enabled) | 1052 if (m_enabled) |
1051 m_overlay->update(); | 1053 m_overlay->update(); |
1052 } | 1054 } |
1053 | 1055 |
1054 void InspectorPageAgent::scriptsEnabled(bool isEnabled) | 1056 void InspectorPageAgent::settingsChanged() |
1055 { | 1057 { |
1056 if (m_ignoreScriptsEnabledNotification) | 1058 Settings* settings = mainFrame()->settings(); |
| 1059 if (!settings) |
1057 return; | 1060 return; |
1058 | 1061 |
1059 m_frontend->scriptsEnabled(isEnabled); | 1062 if (!m_ignoreScriptsEnabledNotification) |
| 1063 m_frontend->scriptsEnabled(settings->scriptEnabled()); |
| 1064 |
| 1065 if (!m_deviceMetricsOverridden) { |
| 1066 m_settingsCacheTextAutosizingEnabled = settings->textAutosizingEnabled()
; |
| 1067 m_settingsCacheFontScaleFactor = settings->deviceScaleAdjustment(); |
| 1068 } |
1060 } | 1069 } |
1061 | 1070 |
1062 PassRefPtr<TypeBuilder::Page::Frame> InspectorPageAgent::buildObjectForFrame(Fra
me* frame) | 1071 PassRefPtr<TypeBuilder::Page::Frame> InspectorPageAgent::buildObjectForFrame(Fra
me* frame) |
1063 { | 1072 { |
1064 RefPtr<TypeBuilder::Page::Frame> frameObject = TypeBuilder::Page::Frame::cre
ate() | 1073 RefPtr<TypeBuilder::Page::Frame> frameObject = TypeBuilder::Page::Frame::cre
ate() |
1065 .setId(frameId(frame)) | 1074 .setId(frameId(frame)) |
1066 .setLoaderId(loaderId(frame->loader().documentLoader())) | 1075 .setLoaderId(loaderId(frame->loader().documentLoader())) |
1067 .setUrl(urlWithoutFragment(frame->document()->url()).string()) | 1076 .setUrl(urlWithoutFragment(frame->document()->url()).string()) |
1068 .setMimeType(frame->loader().documentLoader()->responseMIMEType()) | 1077 .setMimeType(frame->loader().documentLoader()->responseMIMEType()) |
1069 .setSecurityOrigin(frame->document()->securityOrigin()->toRawString()); | 1078 .setSecurityOrigin(frame->document()->securityOrigin()->toRawString()); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1122 } | 1131 } |
1123 return result; | 1132 return result; |
1124 } | 1133 } |
1125 | 1134 |
1126 void InspectorPageAgent::updateViewMetrics(int width, int height, double deviceS
caleFactor, bool emulateViewport, bool fitWindow) | 1135 void InspectorPageAgent::updateViewMetrics(int width, int height, double deviceS
caleFactor, bool emulateViewport, bool fitWindow) |
1127 { | 1136 { |
1128 if (width && height && !m_page->settings().acceleratedCompositingEnabled()) | 1137 if (width && height && !m_page->settings().acceleratedCompositingEnabled()) |
1129 return; | 1138 return; |
1130 | 1139 |
1131 m_deviceMetricsOverridden = width && height; | 1140 m_deviceMetricsOverridden = width && height; |
| 1141 Settings& settings = m_page->settings(); |
| 1142 if (m_deviceMetricsOverridden) { |
| 1143 settings.setTextAutosizingEnabled(overrideTextAutosizing()); |
| 1144 settings.setDeviceScaleAdjustment(overrideFontScaleFactor()); |
| 1145 } else { |
| 1146 settings.setTextAutosizingEnabled(m_settingsCacheTextAutosizingEnabled); |
| 1147 settings.setDeviceScaleAdjustment(m_settingsCacheFontScaleFactor); |
| 1148 } |
| 1149 |
1132 m_emulateViewportEnabled = emulateViewport; | 1150 m_emulateViewportEnabled = emulateViewport; |
1133 m_client->overrideDeviceMetrics(width, height, static_cast<float>(deviceScal
eFactor), emulateViewport, fitWindow); | 1151 m_client->overrideDeviceMetrics(width, height, static_cast<float>(deviceScal
eFactor), emulateViewport, fitWindow); |
1134 | 1152 |
1135 Document* document = mainFrame()->document(); | 1153 Document* document = mainFrame()->document(); |
1136 if (document) { | 1154 if (document) { |
1137 document->styleResolverChanged(RecalcStyleImmediately); | 1155 document->styleResolverChanged(RecalcStyleImmediately); |
1138 document->mediaQueryAffectingValueChanged(); | 1156 document->mediaQueryAffectingValueChanged(); |
1139 } | 1157 } |
1140 InspectorInstrumentation::mediaQueryResultChanged(document); | 1158 InspectorInstrumentation::mediaQueryResultChanged(document); |
1141 | 1159 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1203 } | 1221 } |
1204 | 1222 |
1205 controller->didChangeDeviceOrientation(DeviceOrientationData::create(true, a
lpha, true, beta, true, gamma).get()); | 1223 controller->didChangeDeviceOrientation(DeviceOrientationData::create(true, a
lpha, true, beta, true, gamma).get()); |
1206 } | 1224 } |
1207 | 1225 |
1208 void InspectorPageAgent::clearDeviceOrientationOverride(ErrorString* error) | 1226 void InspectorPageAgent::clearDeviceOrientationOverride(ErrorString* error) |
1209 { | 1227 { |
1210 setDeviceOrientationOverride(error, 0, 0, 0); | 1228 setDeviceOrientationOverride(error, 0, 0, 0); |
1211 } | 1229 } |
1212 | 1230 |
1213 bool InspectorPageAgent::overrideTextAutosizing(bool textAutosizing) | 1231 bool InspectorPageAgent::overrideTextAutosizing() |
1214 { | 1232 { |
1215 if (!m_deviceMetricsOverridden) | |
1216 return textAutosizing; | |
1217 return m_state->getBoolean(PageAgentState::pageAgentTextAutosizingOverride); | 1233 return m_state->getBoolean(PageAgentState::pageAgentTextAutosizingOverride); |
1218 } | 1234 } |
1219 | 1235 |
1220 float InspectorPageAgent::overrideFontScaleFactor(float fontScaleFactor) | 1236 float InspectorPageAgent::overrideFontScaleFactor() |
1221 { | 1237 { |
1222 if (!m_deviceMetricsOverridden) | |
1223 return fontScaleFactor; | |
1224 return static_cast<float>(m_state->getDouble(PageAgentState::fontScaleFactor
)); | 1238 return static_cast<float>(m_state->getDouble(PageAgentState::fontScaleFactor
)); |
1225 } | 1239 } |
1226 | 1240 |
1227 void InspectorPageAgent::setTouchEmulationEnabled(ErrorString*, bool enabled) | 1241 void InspectorPageAgent::setTouchEmulationEnabled(ErrorString*, bool enabled) |
1228 { | 1242 { |
1229 if (m_state->getBoolean(PageAgentState::touchEventEmulationEnabled) == enabl
ed) | 1243 if (m_state->getBoolean(PageAgentState::touchEventEmulationEnabled) == enabl
ed) |
1230 return; | 1244 return; |
1231 updateTouchEventEmulationInPage(enabled); | 1245 updateTouchEventEmulationInPage(enabled); |
1232 } | 1246 } |
1233 | 1247 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1316 } | 1330 } |
1317 | 1331 |
1318 void InspectorPageAgent::setShowViewportSizeOnResize(ErrorString*, bool show, co
nst bool* showGrid) | 1332 void InspectorPageAgent::setShowViewportSizeOnResize(ErrorString*, bool show, co
nst bool* showGrid) |
1319 { | 1333 { |
1320 m_state->setBoolean(PageAgentState::showSizeOnResize, show); | 1334 m_state->setBoolean(PageAgentState::showSizeOnResize, show); |
1321 m_state->setBoolean(PageAgentState::showGridOnResize, showGrid && *showGrid)
; | 1335 m_state->setBoolean(PageAgentState::showGridOnResize, showGrid && *showGrid)
; |
1322 } | 1336 } |
1323 | 1337 |
1324 } // namespace WebCore | 1338 } // namespace WebCore |
1325 | 1339 |
OLD | NEW |