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..c0a5200b607c3b2d165c0bc3dfcd1dc017d5be50 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,11 +400,11 @@ 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); | 
| @@ -659,7 +661,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 +680,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 +1081,20 @@ 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 (textAutosizing) { | 
| + // Device metrics do not actually scale the window size (to maintain crisp rendering) so | 
| + // 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
 
 | 
| + IntSize textAutosizingWindowSizeOverride = IntSize(width, height); | 
| + textAutosizingWindowSizeOverride.scale((float)(1.0 / deviceScaleFactor)); | 
| + settings.setTextAutosizingWindowSizeOverride(textAutosizingWindowSizeOverride); | 
| + } | 
| + settings.setTextAutosizingEnabledOverride(textAutosizing ? TextAutosizingOverride::Enabled : TextAutosizingOverride::Disabled); | 
| + | 
| Document* document = mainFrame()->document(); | 
| if (document) | 
| document->styleResolverChanged(RecalcStyleImmediately); |