<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[172864] trunk/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/172864">172864</a></dd>
<dt>Author</dt> <dd>simon.fraser@apple.com</dd>
<dt>Date</dt> <dd>2014-08-22 12:07:17 -0700 (Fri, 22 Aug 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Implement paint flashing via GraphicsLayers in the WK2 inspector overlay
https://bugs.webkit.org/show_bug.cgi?id=136136

Reviewed by Sam Weinig, Joseph Pecoraro.
Source/WebCore:

Allow InspectorClient to have a custom implementation of showPaintRect(). For
WebKit2's WebInspectorClient, implement this by creating a set of GraphicsLayers
which are parented in a document overlay, with 0.25s fade-out animations.

Also change InspectorInstrumentation::didPaintImpl() to no longer take a GraphicsContext;
it makes no sense to paint the paint rects directly into the context of the web page.
Now that the paint rects are painted into an overlay, the rectangles need to be converted
to root document coordinates, which is done in InspectorInstrumentation::didPaintImpl().

Remove the generic InspectorOverlay::drawOutline()-based indicators; they will
be reimplemented in a later patch.

* WebCore.exp.in:
* inspector/InspectorClient.h:
(WebCore::InspectorClient::showPaintRect):
* inspector/InspectorInstrumentation.cpp:
(WebCore::InspectorInstrumentation::didPaintImpl):
* inspector/InspectorInstrumentation.h:
(WebCore::InspectorInstrumentation::didPaint):
* inspector/InspectorPageAgent.cpp:
(WebCore::InspectorPageAgent::didPaint):
* inspector/InspectorPageAgent.h:
* page/FrameView.cpp:
(WebCore::FrameView::didPaintContents):
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::paintContents):

Source/WebKit2:

Allow InspectorClient to have a custom implementation of showPaintRect(). For
WebKit2's WebInspectorClient, implement this by creating a set of GraphicsLayers
which are parented in a document overlay, with 0.25s fade-out animations.

Also change InspectorInstrumentation::didPaintImpl() to no longer take a GraphicsContext;
it makes no sense to paint the paint rects directly into the context of the web page.
Now that the paint rects are painted into an overlay, the rectangles need to be converted
to root document coordinates, which is done in InspectorInstrumentation::didPaintImpl().

Remove the generic InspectorOverlay::drawOutline()-based indicators; they will
be reimplemented in a later patch.

* WebProcess/WebCoreSupport/WebInspectorClient.cpp:
(WebKit::RepaintIndicatorLayerClient::RepaintIndicatorLayerClient):
(WebKit::RepaintIndicatorLayerClient::~RepaintIndicatorLayerClient):
(WebKit::RepaintIndicatorLayerClient::notifyAnimationEnded):
(WebKit::WebInspectorClient::WebInspectorClient):
(WebKit::WebInspectorClient::~WebInspectorClient):
(WebKit::WebInspectorClient::showPaintRect):
(WebKit::WebInspectorClient::animationEndedForLayer):
* WebProcess/WebCoreSupport/WebInspectorClient.h:
(WebKit::WebInspectorClient::WebInspectorClient): Deleted.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCoreexpin">trunk/Source/WebCore/WebCore.exp.in</a></li>
<li><a href="#trunkSourceWebCoreinspectorInspectorClienth">trunk/Source/WebCore/inspector/InspectorClient.h</a></li>
<li><a href="#trunkSourceWebCoreinspectorInspectorInstrumentationcpp">trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp</a></li>
<li><a href="#trunkSourceWebCoreinspectorInspectorInstrumentationh">trunk/Source/WebCore/inspector/InspectorInstrumentation.h</a></li>
<li><a href="#trunkSourceWebCoreinspectorInspectorPageAgentcpp">trunk/Source/WebCore/inspector/InspectorPageAgent.cpp</a></li>
<li><a href="#trunkSourceWebCoreinspectorInspectorPageAgenth">trunk/Source/WebCore/inspector/InspectorPageAgent.h</a></li>
<li><a href="#trunkSourceWebCorepageFrameViewcpp">trunk/Source/WebCore/page/FrameView.cpp</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderLayerBackingcpp">trunk/Source/WebCore/rendering/RenderLayerBacking.cpp</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebCoreSupportWebInspectorClientcpp">trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebCoreSupportWebInspectorClienth">trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (172863 => 172864)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-08-22 18:59:49 UTC (rev 172863)
+++ trunk/Source/WebCore/ChangeLog        2014-08-22 19:07:17 UTC (rev 172864)
</span><span class="lines">@@ -1,3 +1,37 @@
</span><ins>+2014-08-22  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
+        Implement paint flashing via GraphicsLayers in the WK2 inspector overlay
+        https://bugs.webkit.org/show_bug.cgi?id=136136
+
+        Reviewed by Sam Weinig, Joseph Pecoraro.
+
+        Allow InspectorClient to have a custom implementation of showPaintRect(). For
+        WebKit2's WebInspectorClient, implement this by creating a set of GraphicsLayers
+        which are parented in a document overlay, with 0.25s fade-out animations.
+        
+        Also change InspectorInstrumentation::didPaintImpl() to no longer take a GraphicsContext;
+        it makes no sense to paint the paint rects directly into the context of the web page.
+        Now that the paint rects are painted into an overlay, the rectangles need to be converted
+        to root document coordinates, which is done in InspectorInstrumentation::didPaintImpl().
+        
+        Remove the generic InspectorOverlay::drawOutline()-based indicators; they will
+        be reimplemented in a later patch.
+
+        * WebCore.exp.in:
+        * inspector/InspectorClient.h:
+        (WebCore::InspectorClient::showPaintRect):
+        * inspector/InspectorInstrumentation.cpp:
+        (WebCore::InspectorInstrumentation::didPaintImpl):
+        * inspector/InspectorInstrumentation.h:
+        (WebCore::InspectorInstrumentation::didPaint):
+        * inspector/InspectorPageAgent.cpp:
+        (WebCore::InspectorPageAgent::didPaint):
+        * inspector/InspectorPageAgent.h:
+        * page/FrameView.cpp:
+        (WebCore::FrameView::didPaintContents):
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::paintContents):
+
</ins><span class="cx"> 2014-08-22  Commit Queue  &lt;commit-queue@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, rolling out r172844.
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCoreexpin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.exp.in (172863 => 172864)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.exp.in        2014-08-22 18:59:49 UTC (rev 172863)
+++ trunk/Source/WebCore/WebCore.exp.in        2014-08-22 19:07:17 UTC (rev 172864)
</span><span class="lines">@@ -759,6 +759,7 @@
</span><span class="cx"> __ZN7WebCore17HistoryController26saveDocumentAndScrollStateEv
</span><span class="cx"> __ZN7WebCore17HistoryController33restoreScrollPositionAndViewStateEv
</span><span class="cx"> __ZN7WebCore17JSDOMGlobalObject6s_infoE
</span><ins>+__ZN7WebCore17KeyframeValueList6insertEN3WTF10PassOwnPtrIKNS_14AnimationValueEEE
</ins><span class="cx"> __ZN7WebCore17MouseRelatedEvent7offsetXEv
</span><span class="cx"> __ZN7WebCore17MouseRelatedEvent7offsetYEv
</span><span class="cx"> __ZN7WebCore17PlatformCAFilters17setFiltersOnLayerEP7CALayerRKNS_16FilterOperationsE
</span><span class="lines">@@ -1377,6 +1378,8 @@
</span><span class="cx"> __ZN7WebCore8toStringERKN3WTF6VectorINS_11ProxyServerELm0ENS0_15CrashOnOverflowEEE
</span><span class="cx"> __ZN7WebCore8toUInt16EPN3JSC9ExecStateENS0_7JSValueENS_30IntegerConversionConfigurationE
</span><span class="cx"> __ZN7WebCore8toUInt64EPN3JSC9ExecStateENS0_7JSValueENS_30IntegerConversionConfigurationE
</span><ins>+__ZN7WebCore9AnimationC1Ev
+__ZN7WebCore9AnimationD1Ev
</ins><span class="cx"> __ZN7WebCore9DOMWindow30dispatchAllPendingUnloadEventsEv
</span><span class="cx"> __ZN7WebCore9DOMWindow36dispatchAllPendingBeforeUnloadEventsEv
</span><span class="cx"> __ZN7WebCore9FloatRect5scaleEff
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorInspectorClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/InspectorClient.h (172863 => 172864)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/InspectorClient.h        2014-08-22 18:59:49 UTC (rev 172863)
+++ trunk/Source/WebCore/inspector/InspectorClient.h        2014-08-22 19:07:17 UTC (rev 172864)
</span><span class="lines">@@ -34,8 +34,9 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+class FloatRect;
+class Frame;
</ins><span class="cx"> class InspectorController;
</span><del>-class Frame;
</del><span class="cx"> class Page;
</span><span class="cx"> 
</span><span class="cx"> class InspectorClient {
</span><span class="lines">@@ -60,8 +61,9 @@
</span><span class="cx">     virtual bool canClearBrowserCookies() { return false; }
</span><span class="cx">     virtual void clearBrowserCookies() { }
</span><span class="cx"> 
</span><del>-    virtual bool overridesShowPaintRects() { return false; }
</del><ins>+    virtual bool overridesShowPaintRects() const { return false; }
</ins><span class="cx">     virtual void setShowPaintRects(bool) { }
</span><ins>+    virtual void showPaintRect(const FloatRect&amp;) { }
</ins><span class="cx"> 
</span><span class="cx">     virtual bool canShowDebugBorders() { return false; }
</span><span class="cx">     virtual void setShowDebugBorders(bool) { }
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorInspectorInstrumentationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp (172863 => 172864)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp        2014-08-22 18:59:49 UTC (rev 172863)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp        2014-08-22 19:07:17 UTC (rev 172864)
</span><span class="lines">@@ -485,12 +485,13 @@
</span><span class="cx">         timelineAgent-&gt;willPaint(&amp;renderer-&gt;frame());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void InspectorInstrumentation::didPaintImpl(InstrumentingAgents*  instrumentingAgents, RenderObject* renderer, GraphicsContext* context, const LayoutRect&amp; rect)
</del><ins>+void InspectorInstrumentation::didPaintImpl(InstrumentingAgents* instrumentingAgents, RenderObject* renderer, const LayoutRect&amp; rect)
</ins><span class="cx"> {
</span><span class="cx">     if (InspectorTimelineAgent* timelineAgent = instrumentingAgents-&gt;inspectorTimelineAgent())
</span><span class="cx">         timelineAgent-&gt;didPaint(renderer, rect);
</span><ins>+
</ins><span class="cx">     if (InspectorPageAgent* pageAgent = instrumentingAgents-&gt;inspectorPageAgent())
</span><del>-        pageAgent-&gt;didPaint(context, rect);
</del><ins>+        pageAgent-&gt;didPaint(renderer, rect);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void InspectorInstrumentation::willScrollLayerImpl(InstrumentingAgents* instrumentingAgents, Frame* frame)
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorInspectorInstrumentationh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.h (172863 => 172864)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/InspectorInstrumentation.h        2014-08-22 18:59:49 UTC (rev 172863)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.h        2014-08-22 19:07:17 UTC (rev 172864)
</span><span class="lines">@@ -166,7 +166,7 @@
</span><span class="cx">     static void willScrollLayer(Frame*);
</span><span class="cx">     static void didScrollLayer(Frame*);
</span><span class="cx">     static void willPaint(RenderObject*);
</span><del>-    static void didPaint(RenderObject*, GraphicsContext*, const LayoutRect&amp;);
</del><ins>+    static void didPaint(RenderObject*, const LayoutRect&amp;);
</ins><span class="cx">     static InspectorInstrumentationCookie willRecalculateStyle(Document*);
</span><span class="cx">     static void didRecalculateStyle(const InspectorInstrumentationCookie&amp;);
</span><span class="cx">     static void didScheduleStyleRecalculation(Document*);
</span><span class="lines">@@ -364,7 +364,7 @@
</span><span class="cx">     static void willScrollLayerImpl(InstrumentingAgents*, Frame*);
</span><span class="cx">     static void didScrollLayerImpl(InstrumentingAgents*);
</span><span class="cx">     static void willPaintImpl(InstrumentingAgents*, RenderObject*);
</span><del>-    static void didPaintImpl(InstrumentingAgents*, RenderObject*, GraphicsContext*, const LayoutRect&amp;);
</del><ins>+    static void didPaintImpl(InstrumentingAgents*, RenderObject*, const LayoutRect&amp;);
</ins><span class="cx">     static InspectorInstrumentationCookie willRecalculateStyleImpl(InstrumentingAgents*, Frame*);
</span><span class="cx">     static void didRecalculateStyleImpl(const InspectorInstrumentationCookie&amp;);
</span><span class="cx">     static void didScheduleStyleRecalculationImpl(InstrumentingAgents*, Document*);
</span><span class="lines">@@ -1121,15 +1121,14 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-inline void InspectorInstrumentation::didPaint(RenderObject* renderer, GraphicsContext* context, const LayoutRect&amp; rect)
</del><ins>+inline void InspectorInstrumentation::didPaint(RenderObject* renderer, const LayoutRect&amp; rect)
</ins><span class="cx"> {
</span><span class="cx"> #if ENABLE(INSPECTOR)
</span><span class="cx">     FAST_RETURN_IF_NO_FRONTENDS(void());
</span><span class="cx">     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForRenderer(renderer))
</span><del>-        didPaintImpl(instrumentingAgents, renderer, context, rect);
</del><ins>+        didPaintImpl(instrumentingAgents, renderer, rect);
</ins><span class="cx"> #else
</span><span class="cx">     UNUSED_PARAM(renderer);
</span><del>-    UNUSED_PARAM(context);
</del><span class="cx">     UNUSED_PARAM(rect);
</span><span class="cx"> #endif
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorInspectorPageAgentcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/InspectorPageAgent.cpp (172863 => 172864)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/InspectorPageAgent.cpp        2014-08-22 18:59:49 UTC (rev 172863)
+++ trunk/Source/WebCore/inspector/InspectorPageAgent.cpp        2014-08-22 19:07:17 UTC (rev 172864)
</span><span class="lines">@@ -880,21 +880,26 @@
</span><span class="cx">     m_frontendDispatcher-&gt;javascriptDialogClosed();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void InspectorPageAgent::didPaint(GraphicsContext* context, const LayoutRect&amp; rect)
</del><ins>+void InspectorPageAgent::didPaint(RenderObject* renderer, const LayoutRect&amp; rect)
</ins><span class="cx"> {
</span><del>-    if (!m_enabled || m_client-&gt;overridesShowPaintRects() || !m_showPaintRects)
</del><ins>+    if (!m_enabled || !m_showPaintRects)
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    static int colorSelector = 0;
-    const Color colors[] = {
-        Color(0xFF, 0, 0, 0x3F),
-        Color(0xFF, 0, 0xFF, 0x3F),
-        Color(0, 0, 0xFF, 0x3F),
-    };
</del><ins>+    LayoutRect absoluteRect = LayoutRect(renderer-&gt;localToAbsoluteQuad(FloatRect(rect)).boundingBox());
+    FrameView* view = renderer-&gt;document().view();
+    
+    LayoutRect rootRect = absoluteRect;
+    if (!view-&gt;frame().isMainFrame()) {
+        IntRect rootViewRect = view-&gt;contentsToRootView(pixelSnappedIntRect(absoluteRect));
+        rootRect = view-&gt;frame().mainFrame().view()-&gt;rootViewToContents(rootViewRect);
+    }
+    
+    if (m_client-&gt;overridesShowPaintRects()) {
+        m_client-&gt;showPaintRect(rect);
+        return;
+    }
</ins><span class="cx"> 
</span><del>-    LayoutRect inflatedRect(rect);
-    inflatedRect.inflate(-1);
-    m_overlay-&gt;drawOutline(context, inflatedRect, colors[colorSelector++ % WTF_ARRAY_LENGTH(colors)]);
</del><ins>+    // FIXME: the overlay needs to accumulate paint rects and draw them itself.
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void InspectorPageAgent::didLayout()
</span></span></pre></div>
<a id="trunkSourceWebCoreinspectorInspectorPageAgenth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/inspector/InspectorPageAgent.h (172863 => 172864)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/inspector/InspectorPageAgent.h        2014-08-22 18:59:49 UTC (rev 172863)
+++ trunk/Source/WebCore/inspector/InspectorPageAgent.h        2014-08-22 19:07:17 UTC (rev 172864)
</span><span class="lines">@@ -55,12 +55,12 @@
</span><span class="cx"> class DocumentLoader;
</span><span class="cx"> class Frame;
</span><span class="cx"> class Frontend;
</span><del>-class GraphicsContext;
</del><span class="cx"> class InspectorClient;
</span><span class="cx"> class InspectorOverlay;
</span><span class="cx"> class InstrumentingAgents;
</span><span class="cx"> class URL;
</span><span class="cx"> class Page;
</span><ins>+class RenderObject;
</ins><span class="cx"> class SharedBuffer;
</span><span class="cx"> class TextResourceDecoder;
</span><span class="cx"> 
</span><span class="lines">@@ -140,7 +140,7 @@
</span><span class="cx">     void willRunJavaScriptDialog(const String&amp; message);
</span><span class="cx">     void didRunJavaScriptDialog();
</span><span class="cx">     void applyEmulatedMedia(String*);
</span><del>-    void didPaint(GraphicsContext*, const LayoutRect&amp;);
</del><ins>+    void didPaint(RenderObject*, const LayoutRect&amp;);
</ins><span class="cx">     void didLayout();
</span><span class="cx">     void didScroll();
</span><span class="cx">     void didRecalculateStyle();
</span></span></pre></div>
<a id="trunkSourceWebCorepageFrameViewcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/FrameView.cpp (172863 => 172864)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/FrameView.cpp        2014-08-22 18:59:49 UTC (rev 172863)
+++ trunk/Source/WebCore/page/FrameView.cpp        2014-08-22 19:07:17 UTC (rev 172864)
</span><span class="lines">@@ -3669,7 +3669,7 @@
</span><span class="cx">         sCurrentPaintTimeStamp = 0;
</span><span class="cx"> 
</span><span class="cx">     if (!context-&gt;paintingDisabled()) {
</span><del>-        InspectorInstrumentation::didPaint(renderView(), context, dirtyRect);
</del><ins>+        InspectorInstrumentation::didPaint(renderView(), dirtyRect);
</ins><span class="cx">         // FIXME: should probably not fire milestones for snapshot painting. https://bugs.webkit.org/show_bug.cgi?id=117623
</span><span class="cx">         firePaintRelatedMilestonesIfNeeded();
</span><span class="cx">     }
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderLayerBackingcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.cpp (172863 => 172864)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderLayerBacking.cpp        2014-08-22 18:59:49 UTC (rev 172863)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.cpp        2014-08-22 19:07:17 UTC (rev 172864)
</span><span class="lines">@@ -2198,7 +2198,7 @@
</span><span class="cx">         // We have to use the same root as for hit testing, because both methods can compute and cache clipRects.
</span><span class="cx">         paintIntoLayer(graphicsLayer, &amp;context, dirtyRect, PaintBehaviorNormal, paintingPhase);
</span><span class="cx"> 
</span><del>-        InspectorInstrumentation::didPaint(&amp;renderer(), &amp;context, dirtyRect);
</del><ins>+        InspectorInstrumentation::didPaint(&amp;renderer(), dirtyRect);
</ins><span class="cx">     } else if (graphicsLayer == layerForHorizontalScrollbar()) {
</span><span class="cx">         paintScrollbar(m_owningLayer.horizontalScrollbar(), context, dirtyRect);
</span><span class="cx">     } else if (graphicsLayer == layerForVerticalScrollbar()) {
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (172863 => 172864)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-08-22 18:59:49 UTC (rev 172863)
+++ trunk/Source/WebKit2/ChangeLog        2014-08-22 19:07:17 UTC (rev 172864)
</span><span class="lines">@@ -1,3 +1,33 @@
</span><ins>+2014-08-22  Simon Fraser  &lt;simon.fraser@apple.com&gt;
+
+        Implement paint flashing via GraphicsLayers in the WK2 inspector overlay
+        https://bugs.webkit.org/show_bug.cgi?id=136136
+
+        Reviewed by Sam Weinig, Joseph Pecoraro.
+        
+        Allow InspectorClient to have a custom implementation of showPaintRect(). For
+        WebKit2's WebInspectorClient, implement this by creating a set of GraphicsLayers
+        which are parented in a document overlay, with 0.25s fade-out animations.
+        
+        Also change InspectorInstrumentation::didPaintImpl() to no longer take a GraphicsContext;
+        it makes no sense to paint the paint rects directly into the context of the web page.
+        Now that the paint rects are painted into an overlay, the rectangles need to be converted
+        to root document coordinates, which is done in InspectorInstrumentation::didPaintImpl().
+        
+        Remove the generic InspectorOverlay::drawOutline()-based indicators; they will
+        be reimplemented in a later patch.
+
+        * WebProcess/WebCoreSupport/WebInspectorClient.cpp:
+        (WebKit::RepaintIndicatorLayerClient::RepaintIndicatorLayerClient):
+        (WebKit::RepaintIndicatorLayerClient::~RepaintIndicatorLayerClient):
+        (WebKit::RepaintIndicatorLayerClient::notifyAnimationEnded):
+        (WebKit::WebInspectorClient::WebInspectorClient):
+        (WebKit::WebInspectorClient::~WebInspectorClient):
+        (WebKit::WebInspectorClient::showPaintRect):
+        (WebKit::WebInspectorClient::animationEndedForLayer):
+        * WebProcess/WebCoreSupport/WebInspectorClient.h:
+        (WebKit::WebInspectorClient::WebInspectorClient): Deleted.
+
</ins><span class="cx"> 2014-08-22  Jon Lee  &lt;jonlee@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Fix iOS build due to r172832 and move RUBBER_BANDING out of FeatureDefines.h
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebCoreSupportWebInspectorClientcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.cpp (172863 => 172864)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.cpp        2014-08-22 18:59:49 UTC (rev 172863)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.cpp        2014-08-22 19:07:17 UTC (rev 172864)
</span><span class="lines">@@ -28,10 +28,12 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(INSPECTOR)
</span><span class="cx"> 
</span><ins>+#include &quot;DrawingArea.h&quot;
</ins><span class="cx"> #include &quot;WebInspector.h&quot;
</span><span class="cx"> #include &quot;WebPage.h&quot;
</span><span class="cx"> #include &lt;WebCore/InspectorController.h&gt;
</span><span class="cx"> #include &lt;WebCore/Page.h&gt;
</span><ins>+#include &lt;wtf/CurrentTime.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> #include &lt;WebCore/InspectorOverlay.h&gt;
</span><span class="lines">@@ -41,6 +43,39 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><ins>+class RepaintIndicatorLayerClient final : public GraphicsLayerClient {
+public:
+    RepaintIndicatorLayerClient(WebInspectorClient&amp; inspectorClient)
+        : m_inspectorClient(inspectorClient)
+    {
+    }
+    virtual ~RepaintIndicatorLayerClient() { }
+private:
+    virtual void notifyAnimationEnded(const GraphicsLayer* layer, const String&amp;) override
+    {
+        m_inspectorClient.animationEndedForLayer(layer);
+    }
+    
+    WebInspectorClient&amp; m_inspectorClient;
+};
+
+WebInspectorClient::WebInspectorClient(WebPage* page)
+    : m_page(page)
+    , m_highlightOverlay(nullptr)
+{
+}
+
+WebInspectorClient::~WebInspectorClient()
+{
+    for (auto layer : m_paintRectLayers) {
+        layer-&gt;removeFromParent();
+        delete layer;
+    }
+
+    if (m_paintRectOverlay)
+        m_page-&gt;uninstallPageOverlay(m_paintRectOverlay.get());
+}
+
</ins><span class="cx"> void WebInspectorClient::inspectorDestroyed()
</span><span class="cx"> {
</span><span class="cx">     closeInspectorFrontend();
</span><span class="lines">@@ -100,6 +135,48 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebInspectorClient::showPaintRect(const FloatRect&amp; rect)
+{
+    if (!m_paintRectOverlay) {
+        m_paintRectOverlay = PageOverlay::create(this, PageOverlay::OverlayType::Document);
+        m_page-&gt;installPageOverlay(m_paintRectOverlay, PageOverlay::FadeMode::DoNotFade);
+    }
+
+    if (!m_paintIndicatorLayerClient)
+        m_paintIndicatorLayerClient = std::make_unique&lt;RepaintIndicatorLayerClient&gt;(*this);
+
+    std::unique_ptr&lt;GraphicsLayer&gt; paintLayer = GraphicsLayer::create(m_page-&gt;drawingArea()-&gt;graphicsLayerFactory(), *m_paintIndicatorLayerClient);
+    
+    paintLayer-&gt;setAnchorPoint(FloatPoint3D());
+    paintLayer-&gt;setPosition(rect.location());
+    paintLayer-&gt;setSize(rect.size());
+    paintLayer-&gt;setBackgroundColor(Color(1.0f, 0.0f, 0.0f, 0.2f));
+
+    KeyframeValueList fadeKeyframes(AnimatedPropertyOpacity);
+    OwnPtr&lt;AnimationValue&gt; intialValue = FloatAnimationValue::create(0, 1);
+    fadeKeyframes.insert(intialValue.release());
+
+    OwnPtr&lt;AnimationValue&gt; finalValue = FloatAnimationValue::create(0.25, 0);
+    fadeKeyframes.insert(finalValue.release());
+    
+    RefPtr&lt;Animation&gt; opacityAnimation = Animation::create();
+    opacityAnimation-&gt;setDuration(0.25);
+
+    paintLayer-&gt;addAnimation(fadeKeyframes, FloatSize(), opacityAnimation.get(), ASCIILiteral(&quot;opacity&quot;), 0);
+    
+    m_paintRectLayers.add(paintLayer.get());
+
+    GraphicsLayer* overlayRootLayer = m_paintRectOverlay-&gt;layer();
+    overlayRootLayer-&gt;addChild(paintLayer.release());
+}
+
+void WebInspectorClient::animationEndedForLayer(const GraphicsLayer* layer)
+{
+    const_cast&lt;GraphicsLayer*&gt;(layer)-&gt;removeFromParent();
+    m_paintRectLayers.remove(const_cast&lt;GraphicsLayer*&gt;(layer));
+    delete layer;
+}
+
</ins><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx"> void WebInspectorClient::showInspectorIndication()
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebCoreSupportWebInspectorClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.h (172863 => 172864)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.h        2014-08-22 18:59:49 UTC (rev 172863)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.h        2014-08-22 19:07:17 UTC (rev 172864)
</span><span class="lines">@@ -32,23 +32,24 @@
</span><span class="cx"> 
</span><span class="cx"> #include &lt;WebCore/InspectorClient.h&gt;
</span><span class="cx"> #include &lt;WebCore/InspectorForwarding.h&gt;
</span><ins>+#include &lt;wtf/HashSet.h&gt;
</ins><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> class GraphicsContext;
</span><ins>+class GraphicsLayer;
</ins><span class="cx"> class IntRect;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><span class="cx"> class WebPage;
</span><ins>+class RepaintIndicatorLayerClient;
</ins><span class="cx"> 
</span><span class="cx"> class WebInspectorClient : public WebCore::InspectorClient, public WebCore::InspectorFrontendChannel, private PageOverlay::Client {
</span><ins>+friend class RepaintIndicatorLayerClient;
</ins><span class="cx"> public:
</span><del>-    WebInspectorClient(WebPage* page)
-        : m_page(page)
-        , m_highlightOverlay(0)
-    {
-    }
</del><ins>+    WebInspectorClient(WebPage*);
+    virtual ~WebInspectorClient();
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     virtual void inspectorDestroyed() override;
</span><span class="lines">@@ -68,6 +69,9 @@
</span><span class="cx">     virtual void didSetSearchingForNode(bool) override;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+    virtual bool overridesShowPaintRects() const override { return true; }
+    virtual void showPaintRect(const WebCore::FloatRect&amp;) override;
+
</ins><span class="cx">     virtual bool sendMessageToFrontend(const String&amp;) override;
</span><span class="cx"> 
</span><span class="cx">     virtual bool supportsFrameInstrumentation();
</span><span class="lines">@@ -79,8 +83,14 @@
</span><span class="cx">     virtual void drawRect(PageOverlay*, WebCore::GraphicsContext&amp;, const WebCore::IntRect&amp;) override;
</span><span class="cx">     virtual bool mouseEvent(PageOverlay*, const WebMouseEvent&amp;) override;
</span><span class="cx"> 
</span><ins>+    void animationEndedForLayer(const WebCore::GraphicsLayer*);
+
</ins><span class="cx">     WebPage* m_page;
</span><span class="cx">     PageOverlay* m_highlightOverlay;
</span><ins>+    
+    RefPtr&lt;PageOverlay&gt; m_paintRectOverlay;
+    std::unique_ptr&lt;RepaintIndicatorLayerClient&gt; m_paintIndicatorLayerClient;
+    HashSet&lt;WebCore::GraphicsLayer*&gt; m_paintRectLayers; // Ideally this would be HashSet&lt;std::unique_ptr&lt;GraphicsLayer&gt;&gt; but that doesn't work yet. webkit.org/b/136166
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre>
</div>
</div>

</body>
</html>