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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
324 , m_page(page) | 324 , m_page(page) |
325 , m_injectedScriptManager(injectedScriptManager) | 325 , m_injectedScriptManager(injectedScriptManager) |
326 , m_client(client) | 326 , m_client(client) |
327 , m_frontend(0) | 327 , m_frontend(0) |
328 , m_overlay(overlay) | 328 , m_overlay(overlay) |
329 , m_lastScriptIdentifier(0) | 329 , m_lastScriptIdentifier(0) |
330 , m_enabled(false) | 330 , m_enabled(false) |
331 , m_ignoreScriptsEnabledNotification(false) | 331 , m_ignoreScriptsEnabledNotification(false) |
332 , m_deviceMetricsOverridden(false) | 332 , m_deviceMetricsOverridden(false) |
333 , m_emulateViewportEnabled(false) | 333 , m_emulateViewportEnabled(false) |
334 , m_settingsCacheTextAutosizingEnabled(false) | |
335 , m_settingsCacheFontScaleFactor(1.0) | |
334 { | 336 { |
335 } | 337 } |
336 | 338 |
337 void InspectorPageAgent::setFrontend(InspectorFrontend* frontend) | 339 void InspectorPageAgent::setFrontend(InspectorFrontend* frontend) |
338 { | 340 { |
339 m_frontend = frontend->page(); | 341 m_frontend = frontend->page(); |
340 } | 342 } |
341 | 343 |
342 void InspectorPageAgent::clearFrontend() | 344 void InspectorPageAgent::clearFrontend() |
343 { | 345 { |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
773 } | 775 } |
774 | 776 |
775 void InspectorPageAgent::getScriptExecutionStatus(ErrorString*, PageCommandHandl er::Result::Enum* status) | 777 void InspectorPageAgent::getScriptExecutionStatus(ErrorString*, PageCommandHandl er::Result::Enum* status) |
776 { | 778 { |
777 bool disabledByScriptController = false; | 779 bool disabledByScriptController = false; |
778 bool disabledInSettings = false; | 780 bool disabledInSettings = false; |
779 Frame* frame = mainFrame(); | 781 Frame* frame = mainFrame(); |
780 if (frame) { | 782 if (frame) { |
781 disabledByScriptController = !frame->script().canExecuteScripts(NotAbout ToExecuteScript); | 783 disabledByScriptController = !frame->script().canExecuteScripts(NotAbout ToExecuteScript); |
782 if (frame->settings()) | 784 if (frame->settings()) |
783 disabledInSettings = !frame->settings()->isScriptEnabled(); | 785 disabledInSettings = !frame->settings()->scriptEnabled(); |
784 } | 786 } |
785 | 787 |
786 if (!disabledByScriptController) { | 788 if (!disabledByScriptController) { |
787 *status = PageCommandHandler::Result::Allowed; | 789 *status = PageCommandHandler::Result::Allowed; |
788 return; | 790 return; |
789 } | 791 } |
790 | 792 |
791 if (disabledInSettings) | 793 if (disabledInSettings) |
792 *status = PageCommandHandler::Result::Disabled; | 794 *status = PageCommandHandler::Result::Disabled; |
793 else | 795 else |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1039 #endif | 1041 #endif |
1040 m_frontend->frameResized(); | 1042 m_frontend->frameResized(); |
1041 } | 1043 } |
1042 | 1044 |
1043 void InspectorPageAgent::didRecalculateStyle() | 1045 void InspectorPageAgent::didRecalculateStyle() |
1044 { | 1046 { |
1045 if (m_enabled) | 1047 if (m_enabled) |
1046 m_overlay->update(); | 1048 m_overlay->update(); |
1047 } | 1049 } |
1048 | 1050 |
1049 void InspectorPageAgent::scriptsEnabled(bool isEnabled) | 1051 void InspectorPageAgent::settingsChanged() |
1050 { | 1052 { |
1051 if (m_ignoreScriptsEnabledNotification) | 1053 Settings* settings = mainFrame()->settings(); |
1054 if (!settings) | |
1052 return; | 1055 return; |
1053 | 1056 |
1054 m_frontend->scriptsEnabled(isEnabled); | 1057 if (!m_ignoreScriptsEnabledNotification) |
1058 m_frontend->scriptsEnabled(settings->scriptEnabled()); | |
pfeldman
2014/01/30 16:34:08
We don't want to call scriptsEnabled with the same
| |
1059 | |
1060 if (!m_deviceMetricsOverridden) { | |
1061 m_settingsCacheTextAutosizingEnabled = settings->textAutosizingEnabled() ; | |
pfeldman
2014/01/30 16:34:08
You want to store these unconditionally so that yo
| |
1062 m_settingsCacheFontScaleFactor = settings->deviceScaleAdjustment(); | |
1063 } else { | |
1064 if (settings->textAutosizingEnabled() != overrideTextAutosizing()) { | |
1065 m_settingsCacheTextAutosizingEnabled = settings->textAutosizingEnabl ed(); | |
1066 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
| |
1067 } | |
1068 if (settings->deviceScaleAdjustment() != overrideFontScaleFactor()) { | |
1069 m_settingsCacheFontScaleFactor = settings->deviceScaleAdjustment(); | |
1070 settings->setDeviceScaleAdjustment(overrideFontScaleFactor()); | |
1071 } | |
1072 } | |
1055 } | 1073 } |
1056 | 1074 |
1057 PassRefPtr<TypeBuilder::Page::Frame> InspectorPageAgent::buildObjectForFrame(Fra me* frame) | 1075 PassRefPtr<TypeBuilder::Page::Frame> InspectorPageAgent::buildObjectForFrame(Fra me* frame) |
1058 { | 1076 { |
1059 RefPtr<TypeBuilder::Page::Frame> frameObject = TypeBuilder::Page::Frame::cre ate() | 1077 RefPtr<TypeBuilder::Page::Frame> frameObject = TypeBuilder::Page::Frame::cre ate() |
1060 .setId(frameId(frame)) | 1078 .setId(frameId(frame)) |
1061 .setLoaderId(loaderId(frame->loader().documentLoader())) | 1079 .setLoaderId(loaderId(frame->loader().documentLoader())) |
1062 .setUrl(urlWithoutFragment(frame->document()->url()).string()) | 1080 .setUrl(urlWithoutFragment(frame->document()->url()).string()) |
1063 .setMimeType(frame->loader().documentLoader()->responseMIMEType()) | 1081 .setMimeType(frame->loader().documentLoader()->responseMIMEType()) |
1064 .setSecurityOrigin(frame->document()->securityOrigin()->toRawString()); | 1082 .setSecurityOrigin(frame->document()->securityOrigin()->toRawString()); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1117 } | 1135 } |
1118 return result; | 1136 return result; |
1119 } | 1137 } |
1120 | 1138 |
1121 void InspectorPageAgent::updateViewMetrics(int width, int height, double deviceS caleFactor, bool emulateViewport, bool fitWindow) | 1139 void InspectorPageAgent::updateViewMetrics(int width, int height, double deviceS caleFactor, bool emulateViewport, bool fitWindow) |
1122 { | 1140 { |
1123 if (width && height && !m_page->settings().acceleratedCompositingEnabled()) | 1141 if (width && height && !m_page->settings().acceleratedCompositingEnabled()) |
1124 return; | 1142 return; |
1125 | 1143 |
1126 m_deviceMetricsOverridden = width && height; | 1144 m_deviceMetricsOverridden = width && height; |
1145 Settings& settings = m_page->settings(); | |
1146 if (m_deviceMetricsOverridden) { | |
1147 settings.setTextAutosizingEnabled(overrideTextAutosizing()); | |
1148 settings.setDeviceScaleAdjustment(overrideFontScaleFactor()); | |
1149 } else { | |
1150 settings.setTextAutosizingEnabled(m_settingsCacheTextAutosizingEnabled); | |
1151 settings.setDeviceScaleAdjustment(m_settingsCacheFontScaleFactor); | |
1152 } | |
1153 | |
1127 m_emulateViewportEnabled = emulateViewport; | 1154 m_emulateViewportEnabled = emulateViewport; |
1128 m_client->overrideDeviceMetrics(width, height, static_cast<float>(deviceScal eFactor), emulateViewport, fitWindow); | 1155 m_client->overrideDeviceMetrics(width, height, static_cast<float>(deviceScal eFactor), emulateViewport, fitWindow); |
1129 | 1156 |
1130 Document* document = mainFrame()->document(); | 1157 Document* document = mainFrame()->document(); |
1131 if (document) { | 1158 if (document) { |
1132 document->styleResolverChanged(RecalcStyleImmediately); | 1159 document->styleResolverChanged(RecalcStyleImmediately); |
1133 document->mediaQueryAffectingValueChanged(); | 1160 document->mediaQueryAffectingValueChanged(); |
1134 } | 1161 } |
1135 InspectorInstrumentation::mediaQueryResultChanged(document); | 1162 InspectorInstrumentation::mediaQueryResultChanged(document); |
1136 | 1163 |
(...skipping 18 matching lines...) Expand all Loading... | |
1155 } | 1182 } |
1156 | 1183 |
1157 controller->didChangeDeviceOrientation(DeviceOrientationData::create(true, a lpha, true, beta, true, gamma).get()); | 1184 controller->didChangeDeviceOrientation(DeviceOrientationData::create(true, a lpha, true, beta, true, gamma).get()); |
1158 } | 1185 } |
1159 | 1186 |
1160 void InspectorPageAgent::clearDeviceOrientationOverride(ErrorString* error) | 1187 void InspectorPageAgent::clearDeviceOrientationOverride(ErrorString* error) |
1161 { | 1188 { |
1162 setDeviceOrientationOverride(error, 0, 0, 0); | 1189 setDeviceOrientationOverride(error, 0, 0, 0); |
1163 } | 1190 } |
1164 | 1191 |
1165 bool InspectorPageAgent::overrideTextAutosizing(bool textAutosizing) | 1192 bool InspectorPageAgent::overrideTextAutosizing() |
1166 { | 1193 { |
1167 if (!m_deviceMetricsOverridden) | |
1168 return textAutosizing; | |
1169 return m_state->getBoolean(PageAgentState::pageAgentTextAutosizingOverride); | 1194 return m_state->getBoolean(PageAgentState::pageAgentTextAutosizingOverride); |
1170 } | 1195 } |
1171 | 1196 |
1172 float InspectorPageAgent::overrideFontScaleFactor(float fontScaleFactor) | 1197 float InspectorPageAgent::overrideFontScaleFactor() |
1173 { | 1198 { |
1174 if (!m_deviceMetricsOverridden) | |
1175 return fontScaleFactor; | |
1176 return static_cast<float>(m_state->getDouble(PageAgentState::fontScaleFactor )); | 1199 return static_cast<float>(m_state->getDouble(PageAgentState::fontScaleFactor )); |
1177 } | 1200 } |
1178 | 1201 |
1179 void InspectorPageAgent::setTouchEmulationEnabled(ErrorString*, bool enabled) | 1202 void InspectorPageAgent::setTouchEmulationEnabled(ErrorString*, bool enabled) |
1180 { | 1203 { |
1181 if (m_state->getBoolean(PageAgentState::touchEventEmulationEnabled) == enabl ed) | 1204 if (m_state->getBoolean(PageAgentState::touchEventEmulationEnabled) == enabl ed) |
1182 return; | 1205 return; |
1183 updateTouchEventEmulationInPage(enabled); | 1206 updateTouchEventEmulationInPage(enabled); |
1184 } | 1207 } |
1185 | 1208 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1268 } | 1291 } |
1269 | 1292 |
1270 void InspectorPageAgent::setShowViewportSizeOnResize(ErrorString*, bool show, co nst bool* showGrid) | 1293 void InspectorPageAgent::setShowViewportSizeOnResize(ErrorString*, bool show, co nst bool* showGrid) |
1271 { | 1294 { |
1272 m_state->setBoolean(PageAgentState::showSizeOnResize, show); | 1295 m_state->setBoolean(PageAgentState::showSizeOnResize, show); |
1273 m_state->setBoolean(PageAgentState::showGridOnResize, showGrid && *showGrid) ; | 1296 m_state->setBoolean(PageAgentState::showGridOnResize, showGrid && *showGrid) ; |
1274 } | 1297 } |
1275 | 1298 |
1276 } // namespace WebCore | 1299 } // namespace WebCore |
1277 | 1300 |
OLD | NEW |