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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 105 |
106 namespace { | 106 namespace { |
107 | 107 |
108 KURL urlWithoutFragment(const KURL& url) | 108 KURL urlWithoutFragment(const KURL& url) |
109 { | 109 { |
110 KURL result = url; | 110 KURL result = url; |
111 result.removeFragmentIdentifier(); | 111 result.removeFragmentIdentifier(); |
112 return result; | 112 return result; |
113 } | 113 } |
114 | 114 |
| 115 bool anyDeviceMetricsOverrideEnabled(int width, int height, double deviceScaleFa
ctor) |
| 116 { |
| 117 return width || height || deviceScaleFactor; |
| 118 } |
| 119 |
115 } | 120 } |
116 | 121 |
117 static bool decodeBuffer(const char* buffer, unsigned size, const String& textEn
codingName, String* result) | 122 static bool decodeBuffer(const char* buffer, unsigned size, const String& textEn
codingName, String* result) |
118 { | 123 { |
119 if (buffer) { | 124 if (buffer) { |
120 WTF::TextEncoding encoding(textEncodingName); | 125 WTF::TextEncoding encoding(textEncodingName); |
121 if (!encoding.isValid()) | 126 if (!encoding.isValid()) |
122 encoding = WindowsLatin1Encoding(); | 127 encoding = WindowsLatin1Encoding(); |
123 *result = encoding.decode(buffer, size); | 128 *result = encoding.decode(buffer, size); |
124 return true; | 129 return true; |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 m_deviceMetricsOverridden = false; | 421 m_deviceMetricsOverridden = false; |
417 | 422 |
418 setShowPaintRects(0, false); | 423 setShowPaintRects(0, false); |
419 setShowDebugBorders(0, false); | 424 setShowDebugBorders(0, false); |
420 setShowFPSCounter(0, false); | 425 setShowFPSCounter(0, false); |
421 setEmulatedMedia(0, String()); | 426 setEmulatedMedia(0, String()); |
422 setContinuousPaintingEnabled(0, false); | 427 setContinuousPaintingEnabled(0, false); |
423 setShowScrollBottleneckRects(0, false); | 428 setShowScrollBottleneckRects(0, false); |
424 setShowViewportSizeOnResize(0, false, 0); | 429 setShowViewportSizeOnResize(0, false, 0); |
425 | 430 |
426 if (!deviceMetricsChanged(0, 0, 1, false, false, 1, false)) | 431 if (!deviceMetricsChanged(0, 0, 0, false, false, 1, false)) |
427 return; | 432 return; |
428 | 433 |
429 // When disabling the agent, reset the override values if necessary. | 434 // When disabling the agent, reset the override values if necessary. |
430 updateViewMetrics(0, 0, 1, false, false, m_embedderFontScaleFactor, m_embedd
erTextAutosizingEnabled); | 435 updateViewMetrics(0, 0, 0, false, false, m_embedderFontScaleFactor, m_embedd
erTextAutosizingEnabled); |
431 m_state->setLong(PageAgentState::pageAgentScreenWidthOverride, 0); | 436 m_state->setLong(PageAgentState::pageAgentScreenWidthOverride, 0); |
432 m_state->setLong(PageAgentState::pageAgentScreenHeightOverride, 0); | 437 m_state->setLong(PageAgentState::pageAgentScreenHeightOverride, 0); |
433 m_state->setDouble(PageAgentState::pageAgentDeviceScaleFactorOverride, 1); | 438 m_state->setDouble(PageAgentState::pageAgentDeviceScaleFactorOverride, 0); |
434 m_state->setBoolean(PageAgentState::pageAgentEmulateViewport, false); | 439 m_state->setBoolean(PageAgentState::pageAgentEmulateViewport, false); |
435 m_state->setBoolean(PageAgentState::pageAgentFitWindow, false); | 440 m_state->setBoolean(PageAgentState::pageAgentFitWindow, false); |
436 m_state->setDouble(PageAgentState::fontScaleFactor, 1); | 441 m_state->setDouble(PageAgentState::fontScaleFactor, 1); |
437 m_state->setBoolean(PageAgentState::pageAgentTextAutosizingOverride, false); | 442 m_state->setBoolean(PageAgentState::pageAgentTextAutosizingOverride, false); |
438 } | 443 } |
439 | 444 |
440 void InspectorPageAgent::addScriptToEvaluateOnLoad(ErrorString*, const String& s
ource, String* identifier) | 445 void InspectorPageAgent::addScriptToEvaluateOnLoad(ErrorString*, const String& s
ource, String* identifier) |
441 { | 446 { |
442 RefPtr<JSONObject> scripts = m_state->getObject(PageAgentState::pageAgentScr
iptsToEvaluateOnLoad); | 447 RefPtr<JSONObject> scripts = m_state->getObject(PageAgentState::pageAgentScr
iptsToEvaluateOnLoad); |
443 if (!scripts) { | 448 if (!scripts) { |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 if (width < 0 || height < 0 || width > maxDimension || height > maxDimension
) { | 692 if (width < 0 || height < 0 || width > maxDimension || height > maxDimension
) { |
688 *errorString = "Width and height values must be positive, not greater th
an " + String::number(maxDimension); | 693 *errorString = "Width and height values must be positive, not greater th
an " + String::number(maxDimension); |
689 return; | 694 return; |
690 } | 695 } |
691 | 696 |
692 if (!width ^ !height) { | 697 if (!width ^ !height) { |
693 *errorString = "Both width and height must be either zero or non-zero at
once"; | 698 *errorString = "Both width and height must be either zero or non-zero at
once"; |
694 return; | 699 return; |
695 } | 700 } |
696 | 701 |
697 if (deviceScaleFactor <= 0) { | 702 if (deviceScaleFactor < 0) { |
698 *errorString = "deviceScaleFactor must be positive"; | 703 *errorString = "deviceScaleFactor must be non-negative"; |
699 return; | 704 return; |
700 } | 705 } |
701 | 706 |
702 if (fontScaleFactor <= 0) { | 707 if (fontScaleFactor <= 0) { |
703 *errorString = "fontScaleFactor must be positive"; | 708 *errorString = "fontScaleFactor must be positive"; |
704 return; | 709 return; |
705 } | 710 } |
706 | 711 |
707 Settings& settings = m_page->settings(); | 712 Settings& settings = m_page->settings(); |
708 if (width && height && !settings.acceleratedCompositingEnabled()) { | 713 if (anyDeviceMetricsOverrideEnabled(width, height, deviceScaleFactor) && !se
ttings.acceleratedCompositingEnabled()) { |
709 if (errorString) | 714 if (errorString) |
710 *errorString = "Compositing mode is not supported"; | 715 *errorString = "Compositing mode is not supported"; |
711 return; | 716 return; |
712 } | 717 } |
713 | 718 |
714 if (!deviceMetricsChanged(width, height, deviceScaleFactor, emulateViewport,
fitWindow, fontScaleFactor, textAutosizing)) | 719 if (!deviceMetricsChanged(width, height, deviceScaleFactor, emulateViewport,
fitWindow, fontScaleFactor, textAutosizing)) |
715 return; | 720 return; |
716 | 721 |
717 m_state->setLong(PageAgentState::pageAgentScreenWidthOverride, width); | 722 m_state->setLong(PageAgentState::pageAgentScreenWidthOverride, width); |
718 m_state->setLong(PageAgentState::pageAgentScreenHeightOverride, height); | 723 m_state->setLong(PageAgentState::pageAgentScreenHeightOverride, height); |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1120 childrenArray = TypeBuilder::Array<TypeBuilder::Page::FrameResourceT
ree>::create(); | 1125 childrenArray = TypeBuilder::Array<TypeBuilder::Page::FrameResourceT
ree>::create(); |
1121 result->setChildFrames(childrenArray); | 1126 result->setChildFrames(childrenArray); |
1122 } | 1127 } |
1123 childrenArray->addItem(buildObjectForFrameTree(child)); | 1128 childrenArray->addItem(buildObjectForFrameTree(child)); |
1124 } | 1129 } |
1125 return result; | 1130 return result; |
1126 } | 1131 } |
1127 | 1132 |
1128 void InspectorPageAgent::updateViewMetrics(int width, int height, double deviceS
caleFactor, bool emulateViewport, bool fitWindow, double fontScaleFactor, bool t
extAutosizingEnabled) | 1133 void InspectorPageAgent::updateViewMetrics(int width, int height, double deviceS
caleFactor, bool emulateViewport, bool fitWindow, double fontScaleFactor, bool t
extAutosizingEnabled) |
1129 { | 1134 { |
1130 if (width && height && !m_page->settings().acceleratedCompositingEnabled()) | 1135 bool enabled = anyDeviceMetricsOverrideEnabled(width, height, deviceScaleFac
tor); |
| 1136 if (enabled && !m_page->settings().acceleratedCompositingEnabled()) |
1131 return; | 1137 return; |
1132 | 1138 |
1133 m_deviceMetricsOverridden = width && height; | 1139 m_deviceMetricsOverridden = enabled; |
1134 m_emulateViewportEnabled = emulateViewport; | 1140 m_emulateViewportEnabled = emulateViewport; |
1135 m_client->overrideDeviceMetrics(width, height, static_cast<float>(deviceScal
eFactor), emulateViewport, fitWindow); | 1141 m_client->overrideDeviceMetrics(width, height, static_cast<float>(deviceScal
eFactor), emulateViewport, fitWindow); |
1136 | 1142 |
1137 Document* document = mainFrame()->document(); | 1143 Document* document = mainFrame()->document(); |
1138 if (document) { | 1144 if (document) { |
1139 document->styleResolverChanged(RecalcStyleImmediately); | 1145 document->styleResolverChanged(RecalcStyleImmediately); |
1140 document->mediaQueryAffectingValueChanged(); | 1146 document->mediaQueryAffectingValueChanged(); |
1141 } | 1147 } |
1142 InspectorInstrumentation::mediaQueryResultChanged(document); | 1148 InspectorInstrumentation::mediaQueryResultChanged(document); |
1143 | 1149 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1220 } | 1226 } |
1221 | 1227 |
1222 void InspectorPageAgent::setShowViewportSizeOnResize(ErrorString*, bool show, co
nst bool* showGrid) | 1228 void InspectorPageAgent::setShowViewportSizeOnResize(ErrorString*, bool show, co
nst bool* showGrid) |
1223 { | 1229 { |
1224 m_state->setBoolean(PageAgentState::showSizeOnResize, show); | 1230 m_state->setBoolean(PageAgentState::showSizeOnResize, show); |
1225 m_state->setBoolean(PageAgentState::showGridOnResize, showGrid && *showGrid)
; | 1231 m_state->setBoolean(PageAgentState::showGridOnResize, showGrid && *showGrid)
; |
1226 } | 1232 } |
1227 | 1233 |
1228 } // namespace WebCore | 1234 } // namespace WebCore |
1229 | 1235 |
OLD | NEW |