Title: [143721] trunk/Source/WebCore
Revision
143721
Author
apav...@chromium.org
Date
2013-02-22 05:41:30 -0800 (Fri, 22 Feb 2013)

Log Message

Web Inspector: InspectorPageAgent::disable() should not update view metrics regardless of the override state
https://bugs.webkit.org/show_bug.cgi?id=110593

Reviewed by Vsevolod Vlasov.

InspectorPageAgent::disable() now checks if the device metrics are overridden before
telling the client to disable the override.

* inspector/InspectorPageAgent.cpp:
(WebCore::InspectorPageAgent::disable):
(WebCore::InspectorPageAgent::setDeviceMetricsOverride):
(WebCore::InspectorPageAgent::deviceMetricsChanged):
* inspector/InspectorPageAgent.h:
(InspectorPageAgent):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (143720 => 143721)


--- trunk/Source/WebCore/ChangeLog	2013-02-22 13:35:54 UTC (rev 143720)
+++ trunk/Source/WebCore/ChangeLog	2013-02-22 13:41:30 UTC (rev 143721)
@@ -1,3 +1,20 @@
+2013-02-22  Alexander Pavlov  <apav...@chromium.org>
+
+        Web Inspector: InspectorPageAgent::disable() should not update view metrics regardless of the override state
+        https://bugs.webkit.org/show_bug.cgi?id=110593
+
+        Reviewed by Vsevolod Vlasov.
+
+        InspectorPageAgent::disable() now checks if the device metrics are overridden before
+        telling the client to disable the override.
+
+        * inspector/InspectorPageAgent.cpp:
+        (WebCore::InspectorPageAgent::disable):
+        (WebCore::InspectorPageAgent::setDeviceMetricsOverride):
+        (WebCore::InspectorPageAgent::deviceMetricsChanged):
+        * inspector/InspectorPageAgent.h:
+        (InspectorPageAgent):
+
 2013-02-22  Zan Dobersek  <zdober...@igalia.com>
 
         Unreviewed, rolling out r143695.

Modified: trunk/Source/WebCore/inspector/InspectorPageAgent.cpp (143720 => 143721)


--- trunk/Source/WebCore/inspector/InspectorPageAgent.cpp	2013-02-22 13:35:54 UTC (rev 143720)
+++ trunk/Source/WebCore/inspector/InspectorPageAgent.cpp	2013-02-22 13:41:30 UTC (rev 143721)
@@ -402,6 +402,7 @@
 {
     m_enabled = false;
     m_state->setBoolean(PageAgentState::pageAgentEnabled, false);
+    m_state->remove(PageAgentState::pageAgentScriptsToEvaluateOnLoad);
     m_instrumentingAgents->setInspectorPageAgent(0);
 
     setScriptExecutionDisabled(0, false);
@@ -411,13 +412,15 @@
     setEmulatedMedia(0, "");
     setContinuousPaintingEnabled(0, false);
 
-    // When disabling the agent, reset the override values.
+    if (!deviceMetricsChanged(0, 0, 1, false))
+        return;
+
+    // When disabling the agent, reset the override values if necessary.
+    updateViewMetrics(0, 0, 1, false);
     m_state->setLong(PageAgentState::pageAgentScreenWidthOverride, 0);
     m_state->setLong(PageAgentState::pageAgentScreenHeightOverride, 0);
     m_state->setDouble(PageAgentState::pageAgentFontScaleFactorOverride, 1);
     m_state->setBoolean(PageAgentState::pageAgentFitWindow, false);
-    m_state->remove(PageAgentState::pageAgentScriptsToEvaluateOnLoad);
-    updateViewMetrics(0, 0, 1, false);
 }
 
 void InspectorPageAgent::addScriptToEvaluateOnLoad(ErrorString*, const String& source, String* identifier)
@@ -717,13 +720,7 @@
         return;
     }
 
-    // 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 currentFontScaleFactor = m_state->getDouble(PageAgentState::pageAgentFontScaleFactorOverride);
-    bool currentFitWindow = m_state->getBoolean(PageAgentState::pageAgentFitWindow);
-
-    if (width == currentWidth && height == currentHeight && fontScaleFactor == currentFontScaleFactor && fitWindow == currentFitWindow)
+    if (!deviceMetricsChanged(width, height, fontScaleFactor, fitWindow))
         return;
 
     m_state->setLong(PageAgentState::pageAgentScreenWidthOverride, width);
@@ -734,6 +731,17 @@
     updateViewMetrics(width, height, fontScaleFactor, fitWindow);
 }
 
+bool InspectorPageAgent::deviceMetricsChanged(int width, int height, double fontScaleFactor, bool fitWindow)
+{
+    // 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 currentFontScaleFactor = m_state->getDouble(PageAgentState::pageAgentFontScaleFactorOverride);
+    bool currentFitWindow = m_state->getBoolean(PageAgentState::pageAgentFitWindow);
+
+    return width != currentWidth || height != currentHeight || fontScaleFactor != currentFontScaleFactor || fitWindow != currentFitWindow;
+}
+
 void InspectorPageAgent::setShowPaintRects(ErrorString*, bool show)
 {
     m_state->setBoolean(PageAgentState::pageAgentShowPaintRects, show);

Modified: trunk/Source/WebCore/inspector/InspectorPageAgent.h (143720 => 143721)


--- trunk/Source/WebCore/inspector/InspectorPageAgent.h	2013-02-22 13:35:54 UTC (rev 143720)
+++ trunk/Source/WebCore/inspector/InspectorPageAgent.h	2013-02-22 13:41:30 UTC (rev 143721)
@@ -180,6 +180,7 @@
 
 private:
     InspectorPageAgent(InstrumentingAgents*, Page*, InspectorAgent*, InspectorCompositeState*, InjectedScriptManager*, InspectorClient*, InspectorOverlay*);
+    bool deviceMetricsChanged(int width, int height, double fontScaleFactor, bool fitWindow);
     void updateViewMetrics(int, int, double, bool);
 #if ENABLE(TOUCH_EVENTS)
     void updateTouchEventEmulationInPage(bool);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to