Chromium Code Reviews| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 81 | 81 |
| 82 namespace PageAgentState { | 82 namespace PageAgentState { |
| 83 static const char pageAgentEnabled[] = "pageAgentEnabled"; | 83 static const char pageAgentEnabled[] = "pageAgentEnabled"; |
| 84 static const char pageAgentScriptExecutionDisabled[] = "pageAgentScriptExecution Disabled"; | 84 static const char pageAgentScriptExecutionDisabled[] = "pageAgentScriptExecution Disabled"; |
| 85 static const char pageAgentScriptsToEvaluateOnLoad[] = "pageAgentScriptsToEvalua teOnLoad"; | 85 static const char pageAgentScriptsToEvaluateOnLoad[] = "pageAgentScriptsToEvalua teOnLoad"; |
| 86 static const char pageAgentScreenWidthOverride[] = "pageAgentScreenWidthOverride "; | 86 static const char pageAgentScreenWidthOverride[] = "pageAgentScreenWidthOverride "; |
| 87 static const char pageAgentScreenHeightOverride[] = "pageAgentScreenHeightOverri de"; | 87 static const char pageAgentScreenHeightOverride[] = "pageAgentScreenHeightOverri de"; |
| 88 static const char pageAgentDeviceScaleFactorOverride[] = "pageAgentDeviceScaleFa ctorOverride"; | 88 static const char pageAgentDeviceScaleFactorOverride[] = "pageAgentDeviceScaleFa ctorOverride"; |
| 89 static const char pageAgentFitWindow[] = "pageAgentFitWindow"; | 89 static const char pageAgentFitWindow[] = "pageAgentFitWindow"; |
| 90 static const char pageAgentShowFPSCounter[] = "pageAgentShowFPSCounter"; | 90 static const char pageAgentShowFPSCounter[] = "pageAgentShowFPSCounter"; |
| 91 static const char pageAgentTextAutosizingOverride[] = "pageAgentTextAutosizingOv erride"; | |
| 91 static const char pageAgentContinuousPaintingEnabled[] = "pageAgentContinuousPai ntingEnabled"; | 92 static const char pageAgentContinuousPaintingEnabled[] = "pageAgentContinuousPai ntingEnabled"; |
| 92 static const char pageAgentShowPaintRects[] = "pageAgentShowPaintRects"; | 93 static const char pageAgentShowPaintRects[] = "pageAgentShowPaintRects"; |
| 93 static const char pageAgentShowDebugBorders[] = "pageAgentShowDebugBorders"; | 94 static const char pageAgentShowDebugBorders[] = "pageAgentShowDebugBorders"; |
| 94 static const char pageAgentShowScrollBottleneckRects[] = "pageAgentShowScrollBot tleneckRects"; | 95 static const char pageAgentShowScrollBottleneckRects[] = "pageAgentShowScrollBot tleneckRects"; |
| 95 static const char touchEventEmulationEnabled[] = "touchEventEmulationEnabled"; | 96 static const char touchEventEmulationEnabled[] = "touchEventEmulationEnabled"; |
| 96 static const char pageAgentEmulatedMedia[] = "pageAgentEmulatedMedia"; | 97 static const char pageAgentEmulatedMedia[] = "pageAgentEmulatedMedia"; |
| 97 static const char showSizeOnResize[] = "showSizeOnResize"; | 98 static const char showSizeOnResize[] = "showSizeOnResize"; |
| 98 static const char showGridOnResize[] = "showGridOnResize"; | 99 static const char showGridOnResize[] = "showGridOnResize"; |
| 99 static const char forceCompositingMode[] = "forceCompositingMode"; | 100 static const char forceCompositingMode[] = "forceCompositingMode"; |
| 100 } | 101 } |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 355 setEmulatedMedia(0, emulatedMedia); | 356 setEmulatedMedia(0, emulatedMedia); |
| 356 bool continuousPaintingEnabled = m_state->getBoolean(PageAgentState::pag eAgentContinuousPaintingEnabled); | 357 bool continuousPaintingEnabled = m_state->getBoolean(PageAgentState::pag eAgentContinuousPaintingEnabled); |
| 357 setContinuousPaintingEnabled(0, continuousPaintingEnabled); | 358 setContinuousPaintingEnabled(0, continuousPaintingEnabled); |
| 358 bool showScrollBottleneckRects = m_state->getBoolean(PageAgentState::pag eAgentShowScrollBottleneckRects); | 359 bool showScrollBottleneckRects = m_state->getBoolean(PageAgentState::pag eAgentShowScrollBottleneckRects); |
| 359 setShowScrollBottleneckRects(0, showScrollBottleneckRects); | 360 setShowScrollBottleneckRects(0, showScrollBottleneckRects); |
| 360 | 361 |
| 361 int currentWidth = static_cast<int>(m_state->getLong(PageAgentState::pag eAgentScreenWidthOverride)); | 362 int currentWidth = static_cast<int>(m_state->getLong(PageAgentState::pag eAgentScreenWidthOverride)); |
| 362 int currentHeight = static_cast<int>(m_state->getLong(PageAgentState::pa geAgentScreenHeightOverride)); | 363 int currentHeight = static_cast<int>(m_state->getLong(PageAgentState::pa geAgentScreenHeightOverride)); |
| 363 double currentDeviceScaleFactor = m_state->getDouble(PageAgentState::pag eAgentDeviceScaleFactorOverride); | 364 double currentDeviceScaleFactor = m_state->getDouble(PageAgentState::pag eAgentDeviceScaleFactorOverride); |
| 364 bool currentFitWindow = m_state->getBoolean(PageAgentState::pageAgentFit Window); | 365 bool currentFitWindow = m_state->getBoolean(PageAgentState::pageAgentFit Window); |
| 365 updateViewMetrics(currentWidth, currentHeight, currentDeviceScaleFactor, currentFitWindow); | 366 bool currentTextAutosizing = m_state->getBoolean(PageAgentState::pageAge ntTextAutosizingOverride); |
| 367 updateViewMetrics(currentWidth, currentHeight, currentDeviceScaleFactor, currentFitWindow, currentTextAutosizing); | |
| 366 updateTouchEventEmulationInPage(m_state->getBoolean(PageAgentState::touc hEventEmulationEnabled)); | 368 updateTouchEventEmulationInPage(m_state->getBoolean(PageAgentState::touc hEventEmulationEnabled)); |
| 367 } | 369 } |
| 368 } | 370 } |
| 369 | 371 |
| 370 void InspectorPageAgent::webViewResized(const IntSize& size) | 372 void InspectorPageAgent::webViewResized(const IntSize& size) |
| 371 { | 373 { |
| 372 int currentWidth = static_cast<int>(m_state->getLong(PageAgentState::pageAge ntScreenWidthOverride)); | 374 int currentWidth = static_cast<int>(m_state->getLong(PageAgentState::pageAge ntScreenWidthOverride)); |
| 373 m_overlay->resize(currentWidth ? size : IntSize()); | 375 m_overlay->resize(currentWidth ? size : IntSize()); |
| 374 } | 376 } |
| 375 | 377 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 391 setShowPaintRects(0, false); | 393 setShowPaintRects(0, false); |
| 392 setShowDebugBorders(0, false); | 394 setShowDebugBorders(0, false); |
| 393 setShowFPSCounter(0, false); | 395 setShowFPSCounter(0, false); |
| 394 setEmulatedMedia(0, String()); | 396 setEmulatedMedia(0, String()); |
| 395 setContinuousPaintingEnabled(0, false); | 397 setContinuousPaintingEnabled(0, false); |
| 396 setShowScrollBottleneckRects(0, false); | 398 setShowScrollBottleneckRects(0, false); |
| 397 setShowViewportSizeOnResize(0, false, 0); | 399 setShowViewportSizeOnResize(0, false, 0); |
| 398 if (m_didForceCompositingMode) | 400 if (m_didForceCompositingMode) |
| 399 setForceCompositingMode(0, false); | 401 setForceCompositingMode(0, false); |
| 400 | 402 |
| 401 if (!deviceMetricsChanged(0, 0, 1, false)) | 403 if (!deviceMetricsChanged(0, 0, 1, false, false)) |
| 402 return; | 404 return; |
| 403 | 405 |
| 404 // When disabling the agent, reset the override values if necessary. | 406 // When disabling the agent, reset the override values if necessary. |
| 405 updateViewMetrics(0, 0, 1, false); | 407 updateViewMetrics(0, 0, 1, false, false); |
| 406 m_state->setLong(PageAgentState::pageAgentScreenWidthOverride, 0); | 408 m_state->setLong(PageAgentState::pageAgentScreenWidthOverride, 0); |
| 407 m_state->setLong(PageAgentState::pageAgentScreenHeightOverride, 0); | 409 m_state->setLong(PageAgentState::pageAgentScreenHeightOverride, 0); |
| 408 m_state->setDouble(PageAgentState::pageAgentDeviceScaleFactorOverride, 1); | 410 m_state->setDouble(PageAgentState::pageAgentDeviceScaleFactorOverride, 1); |
| 409 m_state->setBoolean(PageAgentState::pageAgentFitWindow, false); | 411 m_state->setBoolean(PageAgentState::pageAgentFitWindow, false); |
|
skobes
2013/10/16 19:38:09
Do you also need m_state->setBoolean(PageAgentStat
pdr.
2013/10/18 01:28:44
Nice catch. Fixed.
| |
| 410 } | 412 } |
| 411 | 413 |
| 412 void InspectorPageAgent::addScriptToEvaluateOnLoad(ErrorString*, const String& s ource, String* identifier) | 414 void InspectorPageAgent::addScriptToEvaluateOnLoad(ErrorString*, const String& s ource, String* identifier) |
| 413 { | 415 { |
| 414 RefPtr<JSONObject> scripts = m_state->getObject(PageAgentState::pageAgentScr iptsToEvaluateOnLoad); | 416 RefPtr<JSONObject> scripts = m_state->getObject(PageAgentState::pageAgentScr iptsToEvaluateOnLoad); |
| 415 if (!scripts) { | 417 if (!scripts) { |
| 416 scripts = JSONObject::create(); | 418 scripts = JSONObject::create(); |
| 417 m_state->setObject(PageAgentState::pageAgentScriptsToEvaluateOnLoad, scr ipts); | 419 m_state->setObject(PageAgentState::pageAgentScriptsToEvaluateOnLoad, scr ipts); |
| 418 } | 420 } |
| 419 // Assure we don't override existing ids -- m_lastScriptIdentifier could get out of sync WRT actual | 421 // Assure we don't override existing ids -- m_lastScriptIdentifier could get out of sync WRT actual |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 652 return; | 654 return; |
| 653 | 655 |
| 654 Document* document = frame->document(); | 656 Document* document = frame->document(); |
| 655 if (!document) { | 657 if (!document) { |
| 656 *errorString = "No Document instance to set HTML for"; | 658 *errorString = "No Document instance to set HTML for"; |
| 657 return; | 659 return; |
| 658 } | 660 } |
| 659 DOMPatchSupport::patchDocument(*document, html); | 661 DOMPatchSupport::patchDocument(*document, html); |
| 660 } | 662 } |
| 661 | 663 |
| 662 void InspectorPageAgent::setDeviceMetricsOverride(ErrorString* errorString, int width, int height, double deviceScaleFactor, bool fitWindow) | 664 void InspectorPageAgent::setDeviceMetricsOverride(ErrorString* errorString, int width, int height, double deviceScaleFactor, bool fitWindow, bool textAutosizing ) |
| 663 { | 665 { |
| 664 const static long maxDimension = 10000000; | 666 const static long maxDimension = 10000000; |
| 665 | 667 |
| 666 if (width < 0 || height < 0 || width > maxDimension || height > maxDimension ) { | 668 if (width < 0 || height < 0 || width > maxDimension || height > maxDimension ) { |
| 667 *errorString = "Width and height values must be positive, not greater th an " + String::number(maxDimension); | 669 *errorString = "Width and height values must be positive, not greater th an " + String::number(maxDimension); |
| 668 return; | 670 return; |
| 669 } | 671 } |
| 670 | 672 |
| 671 if (!width ^ !height) { | 673 if (!width ^ !height) { |
| 672 *errorString = "Both width and height must be either zero or non-zero at once"; | 674 *errorString = "Both width and height must be either zero or non-zero at once"; |
| 673 return; | 675 return; |
| 674 } | 676 } |
| 675 | 677 |
| 676 if (deviceScaleFactor <= 0) { | 678 if (deviceScaleFactor <= 0) { |
| 677 *errorString = "deviceScaleFactor must be positive"; | 679 *errorString = "deviceScaleFactor must be positive"; |
| 678 return; | 680 return; |
| 679 } | 681 } |
| 680 | 682 |
| 681 if (!deviceMetricsChanged(width, height, deviceScaleFactor, fitWindow)) | 683 if (!deviceMetricsChanged(width, height, deviceScaleFactor, fitWindow, textA utosizing)) |
| 682 return; | 684 return; |
| 683 | 685 |
| 684 m_state->setLong(PageAgentState::pageAgentScreenWidthOverride, width); | 686 m_state->setLong(PageAgentState::pageAgentScreenWidthOverride, width); |
| 685 m_state->setLong(PageAgentState::pageAgentScreenHeightOverride, height); | 687 m_state->setLong(PageAgentState::pageAgentScreenHeightOverride, height); |
| 686 m_state->setDouble(PageAgentState::pageAgentDeviceScaleFactorOverride, devic eScaleFactor); | 688 m_state->setDouble(PageAgentState::pageAgentDeviceScaleFactorOverride, devic eScaleFactor); |
| 687 m_state->setBoolean(PageAgentState::pageAgentFitWindow, fitWindow); | 689 m_state->setBoolean(PageAgentState::pageAgentFitWindow, fitWindow); |
| 690 m_state->setBoolean(PageAgentState::pageAgentTextAutosizingOverride, textAut osizing); | |
| 688 | 691 |
| 689 updateViewMetrics(width, height, deviceScaleFactor, fitWindow); | 692 updateViewMetrics(width, height, deviceScaleFactor, fitWindow, textAutosizin g); |
| 690 } | 693 } |
| 691 | 694 |
| 692 bool InspectorPageAgent::deviceMetricsChanged(int width, int height, double devi ceScaleFactor, bool fitWindow) | 695 bool InspectorPageAgent::deviceMetricsChanged(int width, int height, double devi ceScaleFactor, bool fitWindow, bool textAutosizing) |
| 693 { | 696 { |
| 694 // These two always fit an int. | 697 // These two always fit an int. |
| 695 int currentWidth = static_cast<int>(m_state->getLong(PageAgentState::pageAge ntScreenWidthOverride)); | 698 int currentWidth = static_cast<int>(m_state->getLong(PageAgentState::pageAge ntScreenWidthOverride)); |
| 696 int currentHeight = static_cast<int>(m_state->getLong(PageAgentState::pageAg entScreenHeightOverride)); | 699 int currentHeight = static_cast<int>(m_state->getLong(PageAgentState::pageAg entScreenHeightOverride)); |
| 697 double currentDeviceScaleFactor = m_state->getDouble(PageAgentState::pageAge ntDeviceScaleFactorOverride, 1); | 700 double currentDeviceScaleFactor = m_state->getDouble(PageAgentState::pageAge ntDeviceScaleFactorOverride, 1); |
| 698 bool currentFitWindow = m_state->getBoolean(PageAgentState::pageAgentFitWind ow); | 701 bool currentFitWindow = m_state->getBoolean(PageAgentState::pageAgentFitWind ow); |
| 702 bool currentTextAutosizing = m_state->getBoolean(PageAgentState::pageAgentTe xtAutosizingOverride); | |
| 699 | 703 |
| 700 return width != currentWidth || height != currentHeight || deviceScaleFactor != currentDeviceScaleFactor || fitWindow != currentFitWindow; | 704 return width != currentWidth || height != currentHeight || deviceScaleFactor != currentDeviceScaleFactor || fitWindow != currentFitWindow || textAutosizing != currentTextAutosizing; |
| 701 } | 705 } |
| 702 | 706 |
| 703 void InspectorPageAgent::setShowPaintRects(ErrorString*, bool show) | 707 void InspectorPageAgent::setShowPaintRects(ErrorString*, bool show) |
| 704 { | 708 { |
| 705 m_state->setBoolean(PageAgentState::pageAgentShowPaintRects, show); | 709 m_state->setBoolean(PageAgentState::pageAgentShowPaintRects, show); |
| 706 m_client->setShowPaintRects(show); | 710 m_client->setShowPaintRects(show); |
| 707 | 711 |
| 708 if (!show && mainFrame() && mainFrame()->view()) | 712 if (!show && mainFrame() && mainFrame()->view()) |
| 709 mainFrame()->view()->invalidate(); | 713 mainFrame()->view()->invalidate(); |
| 710 } | 714 } |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1070 for (Frame* child = frame->tree()->firstChild(); child; child = child->tree( )->nextSibling()) { | 1074 for (Frame* child = frame->tree()->firstChild(); child; child = child->tree( )->nextSibling()) { |
| 1071 if (!childrenArray) { | 1075 if (!childrenArray) { |
| 1072 childrenArray = TypeBuilder::Array<TypeBuilder::Page::FrameResourceT ree>::create(); | 1076 childrenArray = TypeBuilder::Array<TypeBuilder::Page::FrameResourceT ree>::create(); |
| 1073 result->setChildFrames(childrenArray); | 1077 result->setChildFrames(childrenArray); |
| 1074 } | 1078 } |
| 1075 childrenArray->addItem(buildObjectForFrameTree(child)); | 1079 childrenArray->addItem(buildObjectForFrameTree(child)); |
| 1076 } | 1080 } |
| 1077 return result; | 1081 return result; |
| 1078 } | 1082 } |
| 1079 | 1083 |
| 1080 void InspectorPageAgent::updateViewMetrics(int width, int height, double deviceS caleFactor, bool fitWindow) | 1084 void InspectorPageAgent::updateViewMetrics(int width, int height, double deviceS caleFactor, bool fitWindow, bool textAutosizing) |
| 1081 { | 1085 { |
| 1082 m_client->overrideDeviceMetrics(width, height, static_cast<float>(deviceScal eFactor), fitWindow); | 1086 m_client->overrideDeviceMetrics(width, height, static_cast<float>(deviceScal eFactor), fitWindow); |
| 1083 | 1087 |
| 1088 Settings& settings = m_page->settings(); | |
| 1089 if (textAutosizing) { | |
| 1090 // Device metrics do not actually scale the window size (to maintain cri sp rendering) so | |
| 1091 // we need to explicity override the text autosizing window size. | |
|
skobes
2013/10/16 19:38:09
I'm surprised this is needed since screen.width /
pdr.
2013/10/18 01:28:44
You are so right. http://crbug.com/308800 filed. W
| |
| 1092 IntSize textAutosizingWindowSizeOverride = IntSize(width, height); | |
| 1093 textAutosizingWindowSizeOverride.scale((float)(1.0 / deviceScaleFactor)) ; | |
| 1094 settings.setTextAutosizingWindowSizeOverride(textAutosizingWindowSizeOve rride); | |
| 1095 } | |
| 1096 settings.setTextAutosizingEnabledOverride(textAutosizing ? TextAutosizingOve rride::Enabled : TextAutosizingOverride::Disabled); | |
| 1097 | |
| 1084 Document* document = mainFrame()->document(); | 1098 Document* document = mainFrame()->document(); |
| 1085 if (document) | 1099 if (document) |
| 1086 document->styleResolverChanged(RecalcStyleImmediately); | 1100 document->styleResolverChanged(RecalcStyleImmediately); |
| 1087 InspectorInstrumentation::mediaQueryResultChanged(document); | 1101 InspectorInstrumentation::mediaQueryResultChanged(document); |
| 1088 m_overlay->setOverride(InspectorOverlay::DeviceMetricsOverride, width && hei ght); | 1102 m_overlay->setOverride(InspectorOverlay::DeviceMetricsOverride, width && hei ght); |
| 1089 | 1103 |
| 1090 // FIXME: allow metrics override, fps counter and continuous painting at the same time: crbug.com/299837. | 1104 // FIXME: allow metrics override, fps counter and continuous painting at the same time: crbug.com/299837. |
| 1091 bool override = width && height; | 1105 bool override = width && height; |
| 1092 m_client->setShowFPSCounter(m_state->getBoolean(PageAgentState::pageAgentSho wFPSCounter) && !override); | 1106 m_client->setShowFPSCounter(m_state->getBoolean(PageAgentState::pageAgentSho wFPSCounter) && !override); |
| 1093 m_client->setContinuousPaintingEnabled(m_state->getBoolean(PageAgentState::p ageAgentContinuousPaintingEnabled) && !override); | 1107 m_client->setContinuousPaintingEnabled(m_state->getBoolean(PageAgentState::p ageAgentContinuousPaintingEnabled) && !override); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1262 } | 1276 } |
| 1263 | 1277 |
| 1264 void InspectorPageAgent::setShowViewportSizeOnResize(ErrorString*, bool show, co nst bool* showGrid) | 1278 void InspectorPageAgent::setShowViewportSizeOnResize(ErrorString*, bool show, co nst bool* showGrid) |
| 1265 { | 1279 { |
| 1266 m_state->setBoolean(PageAgentState::showSizeOnResize, show); | 1280 m_state->setBoolean(PageAgentState::showSizeOnResize, show); |
| 1267 m_state->setBoolean(PageAgentState::showGridOnResize, showGrid && *showGrid) ; | 1281 m_state->setBoolean(PageAgentState::showGridOnResize, showGrid && *showGrid) ; |
| 1268 } | 1282 } |
| 1269 | 1283 |
| 1270 } // namespace WebCore | 1284 } // namespace WebCore |
| 1271 | 1285 |
| OLD | NEW |