Chromium Code Reviews| Index: Source/core/inspector/InspectorPageAgent.cpp |
| diff --git a/Source/core/inspector/InspectorPageAgent.cpp b/Source/core/inspector/InspectorPageAgent.cpp |
| index 3a5b287aaf58cb2f451cda2869fb6fc27dcc76f7..26b9bd5119de690e6be1de228742fa0c28e0de3e 100644 |
| --- a/Source/core/inspector/InspectorPageAgent.cpp |
| +++ b/Source/core/inspector/InspectorPageAgent.cpp |
| @@ -88,6 +88,7 @@ static const char pageAgentScreenHeightOverride[] = "pageAgentScreenHeightOverri |
| static const char pageAgentDeviceScaleFactorOverride[] = "pageAgentDeviceScaleFactorOverride"; |
| static const char pageAgentFitWindow[] = "pageAgentFitWindow"; |
| static const char pageAgentShowFPSCounter[] = "pageAgentShowFPSCounter"; |
| +static const char pageAgentTextAutosizingOverride[] = "pageAgentTextAutosizingOverride"; |
| static const char pageAgentContinuousPaintingEnabled[] = "pageAgentContinuousPaintingEnabled"; |
| static const char pageAgentShowPaintRects[] = "pageAgentShowPaintRects"; |
| static const char pageAgentShowDebugBorders[] = "pageAgentShowDebugBorders"; |
| @@ -362,7 +363,8 @@ void InspectorPageAgent::restore() |
| int currentHeight = static_cast<int>(m_state->getLong(PageAgentState::pageAgentScreenHeightOverride)); |
| double currentDeviceScaleFactor = m_state->getDouble(PageAgentState::pageAgentDeviceScaleFactorOverride); |
| bool currentFitWindow = m_state->getBoolean(PageAgentState::pageAgentFitWindow); |
| - updateViewMetrics(currentWidth, currentHeight, currentDeviceScaleFactor, currentFitWindow); |
| + bool currentTextAutosizing = m_state->getBoolean(PageAgentState::pageAgentTextAutosizingOverride); |
| + updateViewMetrics(currentWidth, currentHeight, currentDeviceScaleFactor, currentFitWindow, currentTextAutosizing); |
| updateTouchEventEmulationInPage(m_state->getBoolean(PageAgentState::touchEventEmulationEnabled)); |
| } |
| } |
| @@ -398,15 +400,16 @@ void InspectorPageAgent::disable(ErrorString*) |
| if (m_didForceCompositingMode) |
| setForceCompositingMode(0, false); |
| - if (!deviceMetricsChanged(0, 0, 1, false)) |
| + if (!deviceMetricsChanged(0, 0, 1, false, false)) |
| return; |
| // When disabling the agent, reset the override values if necessary. |
| - updateViewMetrics(0, 0, 1, false); |
| + updateViewMetrics(0, 0, 1, false, false); |
| m_state->setLong(PageAgentState::pageAgentScreenWidthOverride, 0); |
| m_state->setLong(PageAgentState::pageAgentScreenHeightOverride, 0); |
| m_state->setDouble(PageAgentState::pageAgentDeviceScaleFactorOverride, 1); |
| m_state->setBoolean(PageAgentState::pageAgentFitWindow, false); |
| + m_state->setBoolean(PageAgentState::pageAgentTextAutosizingOverride, false); |
| } |
| void InspectorPageAgent::addScriptToEvaluateOnLoad(ErrorString*, const String& source, String* identifier) |
| @@ -659,7 +662,7 @@ void InspectorPageAgent::setDocumentContent(ErrorString* errorString, const Stri |
| DOMPatchSupport::patchDocument(*document, html); |
| } |
| -void InspectorPageAgent::setDeviceMetricsOverride(ErrorString* errorString, int width, int height, double deviceScaleFactor, bool fitWindow) |
| +void InspectorPageAgent::setDeviceMetricsOverride(ErrorString* errorString, int width, int height, double deviceScaleFactor, bool fitWindow, bool textAutosizing) |
| { |
| const static long maxDimension = 10000000; |
| @@ -678,26 +681,28 @@ void InspectorPageAgent::setDeviceMetricsOverride(ErrorString* errorString, int |
| return; |
| } |
| - if (!deviceMetricsChanged(width, height, deviceScaleFactor, fitWindow)) |
| + if (!deviceMetricsChanged(width, height, deviceScaleFactor, fitWindow, textAutosizing)) |
| return; |
| m_state->setLong(PageAgentState::pageAgentScreenWidthOverride, width); |
| m_state->setLong(PageAgentState::pageAgentScreenHeightOverride, height); |
| m_state->setDouble(PageAgentState::pageAgentDeviceScaleFactorOverride, deviceScaleFactor); |
| m_state->setBoolean(PageAgentState::pageAgentFitWindow, fitWindow); |
| + m_state->setBoolean(PageAgentState::pageAgentTextAutosizingOverride, textAutosizing); |
| - updateViewMetrics(width, height, deviceScaleFactor, fitWindow); |
| + updateViewMetrics(width, height, deviceScaleFactor, fitWindow, textAutosizing); |
| } |
| -bool InspectorPageAgent::deviceMetricsChanged(int width, int height, double deviceScaleFactor, bool fitWindow) |
| +bool InspectorPageAgent::deviceMetricsChanged(int width, int height, double deviceScaleFactor, bool fitWindow, bool textAutosizing) |
| { |
| // These two always fit an int. |
| int currentWidth = static_cast<int>(m_state->getLong(PageAgentState::pageAgentScreenWidthOverride)); |
| int currentHeight = static_cast<int>(m_state->getLong(PageAgentState::pageAgentScreenHeightOverride)); |
| double currentDeviceScaleFactor = m_state->getDouble(PageAgentState::pageAgentDeviceScaleFactorOverride, 1); |
| bool currentFitWindow = m_state->getBoolean(PageAgentState::pageAgentFitWindow); |
| + bool currentTextAutosizing = m_state->getBoolean(PageAgentState::pageAgentTextAutosizingOverride); |
| - return width != currentWidth || height != currentHeight || deviceScaleFactor != currentDeviceScaleFactor || fitWindow != currentFitWindow; |
| + return width != currentWidth || height != currentHeight || deviceScaleFactor != currentDeviceScaleFactor || fitWindow != currentFitWindow || textAutosizing != currentTextAutosizing; |
| } |
| void InspectorPageAgent::setShowPaintRects(ErrorString*, bool show) |
| @@ -1077,10 +1082,19 @@ PassRefPtr<TypeBuilder::Page::FrameResourceTree> InspectorPageAgent::buildObject |
| return result; |
| } |
| -void InspectorPageAgent::updateViewMetrics(int width, int height, double deviceScaleFactor, bool fitWindow) |
| +void InspectorPageAgent::updateViewMetrics(int width, int height, double deviceScaleFactor, bool fitWindow, bool textAutosizing) |
| { |
| m_client->overrideDeviceMetrics(width, height, static_cast<float>(deviceScaleFactor), fitWindow); |
| + Settings& settings = m_page->settings(); |
| + if (m_enabled && textAutosizing) { |
| + // FIXME(crbug.com/308800): overriding device metrics results in an incorrect layout width. |
| + // This workaround can be removed once that bug is fixed. |
| + IntSize textAutosizingWindowSizeOverride = IntSize(width, height); |
| + textAutosizingWindowSizeOverride.scale((float)(1.0 / deviceScaleFactor)); |
| + settings.setTextAutosizingWindowSizeOverride(textAutosizingWindowSizeOverride); |
| + } |
| + |
| Document* document = mainFrame()->document(); |
| if (document) |
| document->styleResolverChanged(RecalcStyleImmediately); |
| @@ -1191,6 +1205,13 @@ DeviceOrientationData* InspectorPageAgent::overrideDeviceOrientation(DeviceOrien |
| return deviceOrientation; |
| } |
| +bool InspectorPageAgent::overrideTextAutosizing(bool textAutosizing) |
| +{ |
| + if (m_enabled) |
| + return m_state->getBoolean(PageAgentState::pageAgentTextAutosizingOverride); |
|
skobes
2013/10/18 17:17:07
Does this handle the case where the inspector is e
pfeldman
2013/10/18 17:26:52
Yeah, I guess you are right. It should be
if (m_en
pdr.
2013/10/18 18:46:09
Done.
|
| + return textAutosizing; |
| +} |
| + |
| void InspectorPageAgent::setTouchEmulationEnabled(ErrorString*, bool enabled) |
| { |
| if (m_state->getBoolean(PageAgentState::touchEventEmulationEnabled) == enabled) |