Web Inspector: highlight is not updating as one edits CSS properties
authorpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Nov 2012 09:57:24 +0000 (09:57 +0000)
committerpfeldman@chromium.org <pfeldman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Nov 2012 09:57:24 +0000 (09:57 +0000)
https://bugs.webkit.org/show_bug.cgi?id=102191

Reviewed by Alexander Pavlov.

We should update highlight upon layout / style recalculation.

* inspector/InspectorInstrumentation.cpp:
(WebCore):
(WebCore::InspectorInstrumentation::didRecalculateStyleImpl):
* inspector/InspectorPageAgent.cpp:
(WebCore::InspectorPageAgent::InspectorPageAgent):
(WebCore::InspectorPageAgent::enable):
(WebCore::InspectorPageAgent::disable):
(WebCore::InspectorPageAgent::domContentEventFired):
(WebCore::InspectorPageAgent::didPaint):
(WebCore::InspectorPageAgent::didLayout):
(WebCore::InspectorPageAgent::didScroll):
(WebCore):
(WebCore::InspectorPageAgent::didRecalculateStyle):
* inspector/InspectorPageAgent.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@134577 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/inspector/InspectorInstrumentation.cpp
Source/WebCore/inspector/InspectorPageAgent.cpp
Source/WebCore/inspector/InspectorPageAgent.h

index 0235517..91ebfac 100644 (file)
@@ -1,3 +1,27 @@
+2012-11-14  Pavel Feldman  <pfeldman@chromium.org>
+
+        Web Inspector: highlight is not updating as one edits CSS properties
+        https://bugs.webkit.org/show_bug.cgi?id=102191
+
+        Reviewed by Alexander Pavlov.
+
+        We should update highlight upon layout / style recalculation.
+
+        * inspector/InspectorInstrumentation.cpp:
+        (WebCore):
+        (WebCore::InspectorInstrumentation::didRecalculateStyleImpl):
+        * inspector/InspectorPageAgent.cpp:
+        (WebCore::InspectorPageAgent::InspectorPageAgent):
+        (WebCore::InspectorPageAgent::enable):
+        (WebCore::InspectorPageAgent::disable):
+        (WebCore::InspectorPageAgent::domContentEventFired):
+        (WebCore::InspectorPageAgent::didPaint):
+        (WebCore::InspectorPageAgent::didLayout):
+        (WebCore::InspectorPageAgent::didScroll):
+        (WebCore):
+        (WebCore::InspectorPageAgent::didRecalculateStyle):
+        * inspector/InspectorPageAgent.h:
+
 2012-11-14  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r134566.
index ad3536a..29c4039 100644 (file)
@@ -557,6 +557,8 @@ void InspectorInstrumentation::didRecalculateStyleImpl(const InspectorInstrument
         return;
     if (InspectorResourceAgent* resourceAgent = instrumentingAgents->inspectorResourceAgent())
         resourceAgent->didRecalculateStyle();
+    if (InspectorPageAgent* pageAgent = instrumentingAgents->inspectorPageAgent())
+        pageAgent->didRecalculateStyle();
 }
 
 void InspectorInstrumentation::didScheduleStyleRecalculationImpl(InstrumentingAgents* instrumentingAgents, Document* document)
index cbb643b..3262b1d 100644 (file)
@@ -331,7 +331,8 @@ InspectorPageAgent::InspectorPageAgent(InstrumentingAgents* instrumentingAgents,
     , m_frontend(0)
     , m_overlay(overlay)
     , m_lastScriptIdentifier(0)
-    , m_didLoadEventFire(false)
+    , m_enabled(false)
+    , m_isFirstLayoutAfterOnLoad(false)
     , m_geolocationOverridden(false)
 {
 }
@@ -364,6 +365,7 @@ void InspectorPageAgent::restore()
 
 void InspectorPageAgent::enable(ErrorString*)
 {
+    m_enabled = true;
     m_state->setBoolean(PageAgentState::pageAgentEnabled, true);
     bool scriptExecutionDisabled = m_state->getBoolean(PageAgentState::pageAgentScriptExecutionDisabled);
     setScriptExecutionDisabled(0, scriptExecutionDisabled);
@@ -374,6 +376,7 @@ void InspectorPageAgent::enable(ErrorString*)
 
 void InspectorPageAgent::disable(ErrorString*)
 {
+    m_enabled = false;
     m_state->setBoolean(PageAgentState::pageAgentEnabled, false);
     m_instrumentingAgents->setInspectorPageAgent(0);
 
@@ -788,7 +791,7 @@ void InspectorPageAgent::didClearWindowObjectInWorld(Frame* frame, DOMWrapperWor
 
 void InspectorPageAgent::domContentEventFired()
 {
-    m_didLoadEventFire = true;
+    m_isFirstLayoutAfterOnLoad = true;
     m_frontend->domContentEventFired(currentTime());
 }
 
@@ -894,7 +897,7 @@ void InspectorPageAgent::applyScreenHeightOverride(long* height)
 
 void InspectorPageAgent::didPaint(GraphicsContext* context, const LayoutRect& rect)
 {
-    if (!m_state->getBoolean(PageAgentState::showPaintRects))
+    if (!m_enabled || !m_state->getBoolean(PageAgentState::showPaintRects))
         return;
 
     static int colorSelector = 0;
@@ -911,21 +914,33 @@ void InspectorPageAgent::didPaint(GraphicsContext* context, const LayoutRect& re
 
 void InspectorPageAgent::didLayout()
 {
-    if (!m_didLoadEventFire)
+    bool isFirstLayout = m_isFirstLayoutAfterOnLoad;
+    if (isFirstLayout)
+        m_isFirstLayoutAfterOnLoad = false;
+
+    if (!m_enabled)
         return;
 
-    m_didLoadEventFire = false;
-    int currentWidth = static_cast<int>(m_state->getLong(PageAgentState::pageAgentScreenWidthOverride));
-    int currentHeight = static_cast<int>(m_state->getLong(PageAgentState::pageAgentScreenHeightOverride));
+    if (isFirstLayout) {
+        int currentWidth = static_cast<int>(m_state->getLong(PageAgentState::pageAgentScreenWidthOverride));
+        int currentHeight = static_cast<int>(m_state->getLong(PageAgentState::pageAgentScreenHeightOverride));
 
-    if (currentWidth && currentHeight)
-        m_client->autoZoomPageToFitWidth();
+        if (currentWidth && currentHeight)
+            m_client->autoZoomPageToFitWidth();
+    }
     m_overlay->update();
 }
 
 void InspectorPageAgent::didScroll()
 {
-    m_overlay->update();
+    if (m_enabled)
+        m_overlay->update();
+}
+
+void InspectorPageAgent::didRecalculateStyle()
+{
+    if (m_enabled)
+        m_overlay->update();
 }
 
 PassRefPtr<TypeBuilder::Page::Frame> InspectorPageAgent::buildObjectForFrame(Frame* frame)
index 397e85b..debe90b 100644 (file)
@@ -141,6 +141,7 @@ public:
     void didPaint(GraphicsContext*, const LayoutRect&);
     void didLayout();
     void didScroll();
+    void didRecalculateStyle();
 
     // Inspector Controller API
     virtual void setFrontend(InspectorFrontend*);
@@ -180,7 +181,8 @@ private:
     HashMap<Frame*, String> m_frameToIdentifier;
     HashMap<String, Frame*> m_identifierToFrame;
     HashMap<DocumentLoader*, String> m_loaderToIdentifier;
-    bool m_didLoadEventFire;
+    bool m_enabled;
+    bool m_isFirstLayoutAfterOnLoad;
     bool m_geolocationOverridden;
     RefPtr<GeolocationPosition> m_geolocationPosition;
     RefPtr<GeolocationPosition> m_platformGeolocationPosition;