| 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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 | 310 |
| 311 InspectorPageAgent::InspectorPageAgent(InstrumentingAgents* instrumentingAgents,
Page* page, InspectorCompositeState* inspectorState, InjectedScriptManager* inj
ectedScriptManager, InspectorClient* client, InspectorOverlay* overlay) | 311 InspectorPageAgent::InspectorPageAgent(InstrumentingAgents* instrumentingAgents,
Page* page, InspectorCompositeState* inspectorState, InjectedScriptManager* inj
ectedScriptManager, InspectorClient* client, InspectorOverlay* overlay) |
| 312 : InspectorBaseAgent<InspectorPageAgent>("Page", instrumentingAgents, inspec
torState) | 312 : InspectorBaseAgent<InspectorPageAgent>("Page", instrumentingAgents, inspec
torState) |
| 313 , m_page(page) | 313 , m_page(page) |
| 314 , m_injectedScriptManager(injectedScriptManager) | 314 , m_injectedScriptManager(injectedScriptManager) |
| 315 , m_client(client) | 315 , m_client(client) |
| 316 , m_frontend(0) | 316 , m_frontend(0) |
| 317 , m_overlay(overlay) | 317 , m_overlay(overlay) |
| 318 , m_lastScriptIdentifier(0) | 318 , m_lastScriptIdentifier(0) |
| 319 , m_enabled(false) | 319 , m_enabled(false) |
| 320 , m_isFirstLayoutAfterOnLoad(false) | |
| 321 , m_geolocationOverridden(false) | 320 , m_geolocationOverridden(false) |
| 322 , m_ignoreScriptsEnabledNotification(false) | 321 , m_ignoreScriptsEnabledNotification(false) |
| 323 , m_didForceCompositingMode(false) | 322 , m_didForceCompositingMode(false) |
| 324 { | 323 { |
| 325 } | 324 } |
| 326 | 325 |
| 327 void InspectorPageAgent::setFrontend(InspectorFrontend* frontend) | 326 void InspectorPageAgent::setFrontend(InspectorFrontend* frontend) |
| 328 { | 327 { |
| 329 m_frontend = frontend->page(); | 328 m_frontend = frontend->page(); |
| 330 } | 329 } |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 } | 710 } |
| 712 | 711 |
| 713 void InspectorPageAgent::setShowDebugBorders(ErrorString*, bool show) | 712 void InspectorPageAgent::setShowDebugBorders(ErrorString*, bool show) |
| 714 { | 713 { |
| 715 m_state->setBoolean(PageAgentState::pageAgentShowDebugBorders, show); | 714 m_state->setBoolean(PageAgentState::pageAgentShowDebugBorders, show); |
| 716 m_client->setShowDebugBorders(show); | 715 m_client->setShowDebugBorders(show); |
| 717 } | 716 } |
| 718 | 717 |
| 719 void InspectorPageAgent::setShowFPSCounter(ErrorString*, bool show) | 718 void InspectorPageAgent::setShowFPSCounter(ErrorString*, bool show) |
| 720 { | 719 { |
| 720 // FIXME: allow metrics override, fps counter and continuous painting at the
same time: crbug.com/299837. |
| 721 bool viewMetricsOverride = m_state->getLong(PageAgentState::pageAgentScreenW
idthOverride); |
| 721 m_state->setBoolean(PageAgentState::pageAgentShowFPSCounter, show); | 722 m_state->setBoolean(PageAgentState::pageAgentShowFPSCounter, show); |
| 722 m_client->setShowFPSCounter(show); | 723 m_client->setShowFPSCounter(show && !viewMetricsOverride); |
| 723 | 724 |
| 724 updateOverridesTopOffset(); | 725 updateOverridesTopOffset(); |
| 725 } | 726 } |
| 726 | 727 |
| 727 void InspectorPageAgent::setContinuousPaintingEnabled(ErrorString*, bool enabled
) | 728 void InspectorPageAgent::setContinuousPaintingEnabled(ErrorString*, bool enabled
) |
| 728 { | 729 { |
| 730 bool viewMetricsOverride = m_state->getLong(PageAgentState::pageAgentScreenW
idthOverride); |
| 729 m_state->setBoolean(PageAgentState::pageAgentContinuousPaintingEnabled, enab
led); | 731 m_state->setBoolean(PageAgentState::pageAgentContinuousPaintingEnabled, enab
led); |
| 730 m_client->setContinuousPaintingEnabled(enabled); | 732 m_client->setContinuousPaintingEnabled(enabled && !viewMetricsOverride); |
| 731 | 733 |
| 732 updateOverridesTopOffset(); | 734 updateOverridesTopOffset(); |
| 733 } | 735 } |
| 734 | 736 |
| 735 void InspectorPageAgent::setShowScrollBottleneckRects(ErrorString*, bool show) | 737 void InspectorPageAgent::setShowScrollBottleneckRects(ErrorString*, bool show) |
| 736 { | 738 { |
| 737 m_state->setBoolean(PageAgentState::pageAgentShowScrollBottleneckRects, show
); | 739 m_state->setBoolean(PageAgentState::pageAgentShowScrollBottleneckRects, show
); |
| 738 m_client->setShowScrollBottleneckRects(show); | 740 m_client->setShowScrollBottleneckRects(show); |
| 739 } | 741 } |
| 740 | 742 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 796 } | 798 } |
| 797 if (!m_scriptToEvaluateOnLoadOnce.isEmpty()) | 799 if (!m_scriptToEvaluateOnLoadOnce.isEmpty()) |
| 798 frame->script()->executeScript(m_scriptToEvaluateOnLoadOnce); | 800 frame->script()->executeScript(m_scriptToEvaluateOnLoadOnce); |
| 799 } | 801 } |
| 800 | 802 |
| 801 void InspectorPageAgent::domContentLoadedEventFired(Frame* frame) | 803 void InspectorPageAgent::domContentLoadedEventFired(Frame* frame) |
| 802 { | 804 { |
| 803 if (frame->page()->mainFrame() != frame) | 805 if (frame->page()->mainFrame() != frame) |
| 804 return; | 806 return; |
| 805 | 807 |
| 806 m_isFirstLayoutAfterOnLoad = true; | |
| 807 m_frontend->domContentEventFired(currentTime()); | 808 m_frontend->domContentEventFired(currentTime()); |
| 808 if (m_state->getBoolean(PageAgentState::forceCompositingMode)) | 809 if (m_state->getBoolean(PageAgentState::forceCompositingMode)) |
| 809 setForceCompositingMode(0, true); | 810 setForceCompositingMode(0, true); |
| 810 } | 811 } |
| 811 | 812 |
| 812 void InspectorPageAgent::loadEventFired(Frame* frame) | 813 void InspectorPageAgent::loadEventFired(Frame* frame) |
| 813 { | 814 { |
| 814 if (frame->page()->mainFrame() != frame) | 815 if (frame->page()->mainFrame() != frame) |
| 815 return; | 816 return; |
| 816 m_frontend->loadEventFired(currentTime()); | 817 m_frontend->loadEventFired(currentTime()); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 965 void InspectorPageAgent::willRunJavaScriptDialog(const String& message) | 966 void InspectorPageAgent::willRunJavaScriptDialog(const String& message) |
| 966 { | 967 { |
| 967 m_frontend->javascriptDialogOpening(message); | 968 m_frontend->javascriptDialogOpening(message); |
| 968 } | 969 } |
| 969 | 970 |
| 970 void InspectorPageAgent::didRunJavaScriptDialog() | 971 void InspectorPageAgent::didRunJavaScriptDialog() |
| 971 { | 972 { |
| 972 m_frontend->javascriptDialogClosed(); | 973 m_frontend->javascriptDialogClosed(); |
| 973 } | 974 } |
| 974 | 975 |
| 975 void InspectorPageAgent::applyScreenWidthOverride(long* width) | |
| 976 { | |
| 977 long widthOverride = m_state->getLong(PageAgentState::pageAgentScreenWidthOv
erride); | |
| 978 if (widthOverride) | |
| 979 *width = widthOverride; | |
| 980 } | |
| 981 | |
| 982 bool InspectorPageAgent::shouldApplyScreenWidthOverride() | |
| 983 { | |
| 984 long width = 0; | |
| 985 applyScreenWidthOverride(&width); | |
| 986 return !!width; | |
| 987 } | |
| 988 | |
| 989 void InspectorPageAgent::applyScreenHeightOverride(long* height) | |
| 990 { | |
| 991 long heightOverride = m_state->getLong(PageAgentState::pageAgentScreenHeight
Override); | |
| 992 if (heightOverride) | |
| 993 *height = heightOverride; | |
| 994 } | |
| 995 | |
| 996 bool InspectorPageAgent::shouldApplyScreenHeightOverride() | |
| 997 { | |
| 998 long height = 0; | |
| 999 applyScreenHeightOverride(&height); | |
| 1000 return !!height; | |
| 1001 } | |
| 1002 | |
| 1003 void InspectorPageAgent::didPaint(RenderObject*, GraphicsContext* context, const
LayoutRect& rect) | 976 void InspectorPageAgent::didPaint(RenderObject*, GraphicsContext* context, const
LayoutRect& rect) |
| 1004 { | 977 { |
| 1005 if (!m_enabled || m_client->overridesShowPaintRects() || !m_state->getBoolea
n(PageAgentState::pageAgentShowPaintRects)) | 978 if (!m_enabled || m_client->overridesShowPaintRects() || !m_state->getBoolea
n(PageAgentState::pageAgentShowPaintRects)) |
| 1006 return; | 979 return; |
| 1007 | 980 |
| 1008 static int colorSelector = 0; | 981 static int colorSelector = 0; |
| 1009 const Color colors[] = { | 982 const Color colors[] = { |
| 1010 Color(0xFF, 0, 0, 0x3F), | 983 Color(0xFF, 0, 0, 0x3F), |
| 1011 Color(0xFF, 0, 0xFF, 0x3F), | 984 Color(0xFF, 0, 0xFF, 0x3F), |
| 1012 Color(0, 0, 0xFF, 0x3F), | 985 Color(0, 0, 0xFF, 0x3F), |
| 1013 }; | 986 }; |
| 1014 | 987 |
| 1015 LayoutRect inflatedRect(rect); | 988 LayoutRect inflatedRect(rect); |
| 1016 inflatedRect.inflate(-1); | 989 inflatedRect.inflate(-1); |
| 1017 m_overlay->drawOutline(context, inflatedRect, colors[colorSelector++ % WTF_A
RRAY_LENGTH(colors)]); | 990 m_overlay->drawOutline(context, inflatedRect, colors[colorSelector++ % WTF_A
RRAY_LENGTH(colors)]); |
| 1018 } | 991 } |
| 1019 | 992 |
| 1020 void InspectorPageAgent::didLayout(RenderObject*) | 993 void InspectorPageAgent::didLayout(RenderObject*) |
| 1021 { | 994 { |
| 1022 bool isFirstLayout = m_isFirstLayoutAfterOnLoad; | |
| 1023 if (isFirstLayout) | |
| 1024 m_isFirstLayoutAfterOnLoad = false; | |
| 1025 | |
| 1026 if (!m_enabled) | 995 if (!m_enabled) |
| 1027 return; | 996 return; |
| 1028 | |
| 1029 if (isFirstLayout) { | |
| 1030 int currentWidth = static_cast<int>(m_state->getLong(PageAgentState::pag
eAgentScreenWidthOverride)); | |
| 1031 int currentHeight = static_cast<int>(m_state->getLong(PageAgentState::pa
geAgentScreenHeightOverride)); | |
| 1032 | |
| 1033 if (currentWidth && currentHeight) | |
| 1034 m_client->autoZoomPageToFitWidth(); | |
| 1035 } | |
| 1036 m_overlay->update(); | 997 m_overlay->update(); |
| 1037 } | 998 } |
| 1038 | 999 |
| 1039 void InspectorPageAgent::didScroll() | 1000 void InspectorPageAgent::didScroll() |
| 1040 { | 1001 { |
| 1041 if (m_enabled) | 1002 if (m_enabled) |
| 1042 m_overlay->update(); | 1003 m_overlay->update(); |
| 1043 } | 1004 } |
| 1044 | 1005 |
| 1045 void InspectorPageAgent::didResizeMainFrame() | 1006 void InspectorPageAgent::didResizeMainFrame() |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1118 | 1079 |
| 1119 void InspectorPageAgent::updateViewMetrics(int width, int height, double fontSca
leFactor, bool fitWindow) | 1080 void InspectorPageAgent::updateViewMetrics(int width, int height, double fontSca
leFactor, bool fitWindow) |
| 1120 { | 1081 { |
| 1121 m_client->overrideDeviceMetrics(width, height, static_cast<float>(fontScaleF
actor), fitWindow); | 1082 m_client->overrideDeviceMetrics(width, height, static_cast<float>(fontScaleF
actor), fitWindow); |
| 1122 | 1083 |
| 1123 Document* document = mainFrame()->document(); | 1084 Document* document = mainFrame()->document(); |
| 1124 if (document) | 1085 if (document) |
| 1125 document->styleResolverChanged(RecalcStyleImmediately); | 1086 document->styleResolverChanged(RecalcStyleImmediately); |
| 1126 InspectorInstrumentation::mediaQueryResultChanged(document); | 1087 InspectorInstrumentation::mediaQueryResultChanged(document); |
| 1127 m_overlay->setOverride(InspectorOverlay::DeviceMetricsOverride, width && hei
ght); | 1088 m_overlay->setOverride(InspectorOverlay::DeviceMetricsOverride, width && hei
ght); |
| 1089 |
| 1090 // FIXME: allow metrics override, fps counter and continuous painting at the
same time: crbug.com/299837. |
| 1091 bool override = width && height; |
| 1092 m_client->setShowFPSCounter(m_state->getBoolean(PageAgentState::pageAgentSho
wFPSCounter) && !override); |
| 1093 m_client->setContinuousPaintingEnabled(m_state->getBoolean(PageAgentState::p
ageAgentContinuousPaintingEnabled) && !override); |
| 1094 updateOverridesTopOffset(); |
| 1128 } | 1095 } |
| 1129 | 1096 |
| 1130 void InspectorPageAgent::updateTouchEventEmulationInPage(bool enabled) | 1097 void InspectorPageAgent::updateTouchEventEmulationInPage(bool enabled) |
| 1131 { | 1098 { |
| 1132 m_state->setBoolean(PageAgentState::touchEventEmulationEnabled, enabled); | 1099 m_state->setBoolean(PageAgentState::touchEventEmulationEnabled, enabled); |
| 1133 if (mainFrame() && mainFrame()->settings()) | 1100 if (mainFrame() && mainFrame()->settings()) |
| 1134 mainFrame()->settings()->setTouchEventEmulationEnabled(enabled); | 1101 mainFrame()->settings()->setTouchEventEmulationEnabled(enabled); |
| 1135 m_overlay->setOverride(InspectorOverlay::TouchOverride, enabled); | 1102 m_overlay->setOverride(InspectorOverlay::TouchOverride, enabled); |
| 1136 } | 1103 } |
| 1137 | 1104 |
| 1138 void InspectorPageAgent::updateOverridesTopOffset() | 1105 void InspectorPageAgent::updateOverridesTopOffset() |
| 1139 { | 1106 { |
| 1140 static const int continousPaintingGraphHeight = 92; | 1107 static const int continousPaintingGraphHeight = 92; |
| 1141 static const int fpsGraphHeight = 73; | 1108 static const int fpsGraphHeight = 73; |
| 1142 int topOffset = 0; | 1109 int topOffset = 0; |
| 1143 if (m_state->getBoolean(PageAgentState::pageAgentContinuousPaintingEnabled)) | 1110 if (m_state->getBoolean(PageAgentState::pageAgentContinuousPaintingEnabled)) |
| 1144 topOffset = continousPaintingGraphHeight; | 1111 topOffset = continousPaintingGraphHeight; |
| 1145 else if (m_state->getBoolean(PageAgentState::pageAgentShowFPSCounter)) | 1112 else if (m_state->getBoolean(PageAgentState::pageAgentShowFPSCounter)) |
| 1146 topOffset = fpsGraphHeight; | 1113 topOffset = fpsGraphHeight; |
| 1147 m_overlay->setOverridesTopOffset(topOffset); | 1114 // FIXME: allow metrics override, fps counter and continuous painting at the
same time: crbug.com/299837. |
| 1115 bool setOffset = false; |
| 1116 if (setOffset) |
| 1117 m_overlay->setOverridesTopOffset(topOffset); |
| 1148 } | 1118 } |
| 1149 | 1119 |
| 1150 void InspectorPageAgent::setGeolocationOverride(ErrorString* error, const double
* latitude, const double* longitude, const double* accuracy) | 1120 void InspectorPageAgent::setGeolocationOverride(ErrorString* error, const double
* latitude, const double* longitude, const double* accuracy) |
| 1151 { | 1121 { |
| 1152 GeolocationController* controller = GeolocationController::from(m_page); | 1122 GeolocationController* controller = GeolocationController::from(m_page); |
| 1153 GeolocationPosition* position = 0; | 1123 GeolocationPosition* position = 0; |
| 1154 if (!controller) { | 1124 if (!controller) { |
| 1155 *error = "Internal error: unable to override geolocation"; | 1125 *error = "Internal error: unable to override geolocation"; |
| 1156 return; | 1126 return; |
| 1157 } | 1127 } |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1292 } | 1262 } |
| 1293 | 1263 |
| 1294 void InspectorPageAgent::setShowViewportSizeOnResize(ErrorString*, bool show, co
nst bool* showGrid) | 1264 void InspectorPageAgent::setShowViewportSizeOnResize(ErrorString*, bool show, co
nst bool* showGrid) |
| 1295 { | 1265 { |
| 1296 m_state->setBoolean(PageAgentState::showSizeOnResize, show); | 1266 m_state->setBoolean(PageAgentState::showSizeOnResize, show); |
| 1297 m_state->setBoolean(PageAgentState::showGridOnResize, showGrid && *showGrid)
; | 1267 m_state->setBoolean(PageAgentState::showGridOnResize, showGrid && *showGrid)
; |
| 1298 } | 1268 } |
| 1299 | 1269 |
| 1300 } // namespace WebCore | 1270 } // namespace WebCore |
| 1301 | 1271 |
| OLD | NEW |