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 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 | 323 |
324 InspectorPageAgent::InspectorPageAgent(InstrumentingAgents* instrumentingAgents,
Page* page, InspectorAgent* inspectorAgent, InspectorState* inspectorState, Inj
ectedScriptManager* injectedScriptManager, InspectorClient* client, InspectorOve
rlay* overlay) | 324 InspectorPageAgent::InspectorPageAgent(InstrumentingAgents* instrumentingAgents,
Page* page, InspectorAgent* inspectorAgent, InspectorState* inspectorState, Inj
ectedScriptManager* injectedScriptManager, InspectorClient* client, InspectorOve
rlay* overlay) |
325 : InspectorBaseAgent<InspectorPageAgent>("Page", instrumentingAgents, inspec
torState) | 325 : InspectorBaseAgent<InspectorPageAgent>("Page", instrumentingAgents, inspec
torState) |
326 , m_page(page) | 326 , m_page(page) |
327 , m_inspectorAgent(inspectorAgent) | 327 , m_inspectorAgent(inspectorAgent) |
328 , m_injectedScriptManager(injectedScriptManager) | 328 , m_injectedScriptManager(injectedScriptManager) |
329 , m_client(client) | 329 , m_client(client) |
330 , m_frontend(0) | 330 , m_frontend(0) |
331 , m_overlay(overlay) | 331 , m_overlay(overlay) |
332 , m_lastScriptIdentifier(0) | 332 , m_lastScriptIdentifier(0) |
333 , m_didLoadEventFire(false) | 333 , m_enabled(false) |
| 334 , m_isFirstLayoutAfterOnLoad(false) |
334 , m_geolocationOverridden(false) | 335 , m_geolocationOverridden(false) |
335 { | 336 { |
336 } | 337 } |
337 | 338 |
338 void InspectorPageAgent::setFrontend(InspectorFrontend* frontend) | 339 void InspectorPageAgent::setFrontend(InspectorFrontend* frontend) |
339 { | 340 { |
340 m_frontend = frontend->page(); | 341 m_frontend = frontend->page(); |
341 } | 342 } |
342 | 343 |
343 void InspectorPageAgent::clearFrontend() | 344 void InspectorPageAgent::clearFrontend() |
(...skipping 20 matching lines...) Expand all Loading... |
364 bool currentFitWindow = m_state->getBoolean(PageAgentState::pageAgentFit
Window); | 365 bool currentFitWindow = m_state->getBoolean(PageAgentState::pageAgentFit
Window); |
365 updateViewMetrics(currentWidth, currentHeight, currentFontScaleFactor, c
urrentFitWindow); | 366 updateViewMetrics(currentWidth, currentHeight, currentFontScaleFactor, c
urrentFitWindow); |
366 #if ENABLE(TOUCH_EVENTS) | 367 #if ENABLE(TOUCH_EVENTS) |
367 updateTouchEventEmulationInPage(m_state->getBoolean(PageAgentState::touc
hEventEmulationEnabled)); | 368 updateTouchEventEmulationInPage(m_state->getBoolean(PageAgentState::touc
hEventEmulationEnabled)); |
368 #endif | 369 #endif |
369 } | 370 } |
370 } | 371 } |
371 | 372 |
372 void InspectorPageAgent::enable(ErrorString*) | 373 void InspectorPageAgent::enable(ErrorString*) |
373 { | 374 { |
| 375 m_enabled = true; |
374 m_state->setBoolean(PageAgentState::pageAgentEnabled, true); | 376 m_state->setBoolean(PageAgentState::pageAgentEnabled, true); |
375 m_instrumentingAgents->setInspectorPageAgent(this); | 377 m_instrumentingAgents->setInspectorPageAgent(this); |
376 } | 378 } |
377 | 379 |
378 void InspectorPageAgent::disable(ErrorString*) | 380 void InspectorPageAgent::disable(ErrorString*) |
379 { | 381 { |
| 382 m_enabled = false; |
380 m_state->setBoolean(PageAgentState::pageAgentEnabled, false); | 383 m_state->setBoolean(PageAgentState::pageAgentEnabled, false); |
381 m_instrumentingAgents->setInspectorPageAgent(0); | 384 m_instrumentingAgents->setInspectorPageAgent(0); |
382 | 385 |
383 setScriptExecutionDisabled(0, false); | 386 setScriptExecutionDisabled(0, false); |
384 | 387 |
385 // When disabling the agent, reset the override values. | 388 // When disabling the agent, reset the override values. |
386 m_state->setLong(PageAgentState::pageAgentScreenWidthOverride, 0); | 389 m_state->setLong(PageAgentState::pageAgentScreenWidthOverride, 0); |
387 m_state->setLong(PageAgentState::pageAgentScreenHeightOverride, 0); | 390 m_state->setLong(PageAgentState::pageAgentScreenHeightOverride, 0); |
388 m_state->setDouble(PageAgentState::pageAgentFontScaleFactorOverride, 1); | 391 m_state->setDouble(PageAgentState::pageAgentFontScaleFactorOverride, 1); |
389 m_state->setBoolean(PageAgentState::pageAgentFitWindow, false); | 392 m_state->setBoolean(PageAgentState::pageAgentFitWindow, false); |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 if (it->value->asString(&scriptText)) | 772 if (it->value->asString(&scriptText)) |
770 m_injectedScriptManager->injectScript(scriptText, mainWorldScrip
tState(frame)); | 773 m_injectedScriptManager->injectScript(scriptText, mainWorldScrip
tState(frame)); |
771 } | 774 } |
772 } | 775 } |
773 if (!m_scriptToEvaluateOnLoadOnce.isEmpty()) | 776 if (!m_scriptToEvaluateOnLoadOnce.isEmpty()) |
774 m_injectedScriptManager->injectScript(m_scriptToEvaluateOnLoadOnce, main
WorldScriptState(frame)); | 777 m_injectedScriptManager->injectScript(m_scriptToEvaluateOnLoadOnce, main
WorldScriptState(frame)); |
775 } | 778 } |
776 | 779 |
777 void InspectorPageAgent::domContentEventFired() | 780 void InspectorPageAgent::domContentEventFired() |
778 { | 781 { |
779 m_didLoadEventFire = true; | 782 m_isFirstLayoutAfterOnLoad = true; |
780 m_frontend->domContentEventFired(currentTime()); | 783 m_frontend->domContentEventFired(currentTime()); |
781 } | 784 } |
782 | 785 |
783 void InspectorPageAgent::loadEventFired() | 786 void InspectorPageAgent::loadEventFired() |
784 { | 787 { |
785 m_frontend->loadEventFired(currentTime()); | 788 m_frontend->loadEventFired(currentTime()); |
786 } | 789 } |
787 | 790 |
788 void InspectorPageAgent::frameNavigated(DocumentLoader* loader) | 791 void InspectorPageAgent::frameNavigated(DocumentLoader* loader) |
789 { | 792 { |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
875 | 878 |
876 void InspectorPageAgent::applyScreenHeightOverride(long* height) | 879 void InspectorPageAgent::applyScreenHeightOverride(long* height) |
877 { | 880 { |
878 long heightOverride = m_state->getLong(PageAgentState::pageAgentScreenHeight
Override); | 881 long heightOverride = m_state->getLong(PageAgentState::pageAgentScreenHeight
Override); |
879 if (heightOverride) | 882 if (heightOverride) |
880 *height = heightOverride; | 883 *height = heightOverride; |
881 } | 884 } |
882 | 885 |
883 void InspectorPageAgent::didPaint(GraphicsContext* context, const LayoutRect& re
ct) | 886 void InspectorPageAgent::didPaint(GraphicsContext* context, const LayoutRect& re
ct) |
884 { | 887 { |
885 if (!m_state->getBoolean(PageAgentState::showPaintRects)) | 888 if (!m_enabled || !m_state->getBoolean(PageAgentState::showPaintRects)) |
886 return; | 889 return; |
887 | 890 |
888 static int colorSelector = 0; | 891 static int colorSelector = 0; |
889 const Color colors[] = { | 892 const Color colors[] = { |
890 Color(0xFF, 0, 0, 0x3F), | 893 Color(0xFF, 0, 0, 0x3F), |
891 Color(0xFF, 0, 0xFF, 0x3F), | 894 Color(0xFF, 0, 0xFF, 0x3F), |
892 Color(0, 0, 0xFF, 0x3F), | 895 Color(0, 0, 0xFF, 0x3F), |
893 }; | 896 }; |
894 | 897 |
895 LayoutRect inflatedRect(rect); | 898 LayoutRect inflatedRect(rect); |
896 inflatedRect.inflate(-1); | 899 inflatedRect.inflate(-1); |
897 m_overlay->drawOutline(context, inflatedRect, colors[colorSelector++ % WTF_A
RRAY_LENGTH(colors)]); | 900 m_overlay->drawOutline(context, inflatedRect, colors[colorSelector++ % WTF_A
RRAY_LENGTH(colors)]); |
898 } | 901 } |
899 | 902 |
900 void InspectorPageAgent::didLayout() | 903 void InspectorPageAgent::didLayout() |
901 { | 904 { |
902 if (!m_didLoadEventFire) | 905 bool isFirstLayout = m_isFirstLayoutAfterOnLoad; |
| 906 if (isFirstLayout) |
| 907 m_isFirstLayoutAfterOnLoad = false; |
| 908 |
| 909 if (!m_enabled) |
903 return; | 910 return; |
904 | 911 |
905 m_didLoadEventFire = false; | 912 if (isFirstLayout) { |
906 int currentWidth = static_cast<int>(m_state->getLong(PageAgentState::pageAge
ntScreenWidthOverride)); | 913 int currentWidth = static_cast<int>(m_state->getLong(PageAgentState::pag
eAgentScreenWidthOverride)); |
907 int currentHeight = static_cast<int>(m_state->getLong(PageAgentState::pageAg
entScreenHeightOverride)); | 914 int currentHeight = static_cast<int>(m_state->getLong(PageAgentState::pa
geAgentScreenHeightOverride)); |
908 | 915 |
909 if (currentWidth && currentHeight) | 916 if (currentWidth && currentHeight) |
910 m_client->autoZoomPageToFitWidth(); | 917 m_client->autoZoomPageToFitWidth(); |
| 918 } |
911 m_overlay->update(); | 919 m_overlay->update(); |
912 } | 920 } |
913 | 921 |
914 void InspectorPageAgent::didScroll() | 922 void InspectorPageAgent::didScroll() |
915 { | 923 { |
916 m_overlay->update(); | 924 if (m_enabled) |
| 925 m_overlay->update(); |
| 926 } |
| 927 |
| 928 void InspectorPageAgent::didRecalculateStyle() |
| 929 { |
| 930 if (m_enabled) |
| 931 m_overlay->update(); |
917 } | 932 } |
918 | 933 |
919 PassRefPtr<TypeBuilder::Page::Frame> InspectorPageAgent::buildObjectForFrame(Fra
me* frame) | 934 PassRefPtr<TypeBuilder::Page::Frame> InspectorPageAgent::buildObjectForFrame(Fra
me* frame) |
920 { | 935 { |
921 RefPtr<TypeBuilder::Page::Frame> frameObject = TypeBuilder::Page::Frame::cre
ate() | 936 RefPtr<TypeBuilder::Page::Frame> frameObject = TypeBuilder::Page::Frame::cre
ate() |
922 .setId(frameId(frame)) | 937 .setId(frameId(frame)) |
923 .setLoaderId(loaderId(frame->loader()->documentLoader())) | 938 .setLoaderId(loaderId(frame->loader()->documentLoader())) |
924 .setUrl(frame->document()->url().string()) | 939 .setUrl(frame->document()->url().string()) |
925 .setMimeType(frame->loader()->documentLoader()->responseMIMEType()); | 940 .setMimeType(frame->loader()->documentLoader()->responseMIMEType()); |
926 if (frame->tree()->parent()) | 941 if (frame->tree()->parent()) |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1120 if (!settings) | 1135 if (!settings) |
1121 return; | 1136 return; |
1122 | 1137 |
1123 settings->setShowDebugBorders(visible); | 1138 settings->setShowDebugBorders(visible); |
1124 settings->setShowRepaintCounter(visible); | 1139 settings->setShowRepaintCounter(visible); |
1125 } | 1140 } |
1126 | 1141 |
1127 } // namespace WebCore | 1142 } // namespace WebCore |
1128 | 1143 |
1129 #endif // ENABLE(INSPECTOR) | 1144 #endif // ENABLE(INSPECTOR) |
OLD | NEW |