<!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>[211631] trunk</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/211631">211631</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2017-02-03 05:03:33 -0800 (Fri, 03 Feb 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>[GTK] Add initial implementation of resource usage overlay
https://bugs.webkit.org/show_bug.cgi?id=167731

Reviewed by Michael Catanzaro.

.:

Enable RESOURCE_USAGE.

* Source/cmake/OptionsGTK.cmake:

Source/JavaScriptCore:

Also expose nextFireTime() for GTK+ port.

* heap/GCActivityCallback.cpp:
(JSC::GCActivityCallback::scheduleTimer):
(JSC::GCActivityCallback::cancelTimer):
* heap/GCActivityCallback.h:

Source/WebCore:

Add an implementation of ResourceUsageOverlay and ResourceUsageThread for Linux systems.

* PlatformGTK.cmake: Add new new files to compilation.
* page/Page.cpp:
(WebCore::Page::setResourceUsageOverlayVisible): Do not create the page overlay if accelerated compositing is
not enabled.
* page/ResourceUsageOverlay.h:
* page/linux/ResourceUsageOverlayLinux.cpp: Added.
(WebCore::cpuUsageString):
(WebCore::formatByteNumber):
(WebCore::gcTimerString):
(WebCore::ResourceUsageOverlay::platformInitialize):
(WebCore::ResourceUsageOverlay::platformDestroy):
* page/linux/ResourceUsageThreadLinux.cpp: Added.
(WebCore::cpuPeriod):
(WebCore::cpuUsage):
(WebCore::ResourceUsageThread::platformThreadBody):

Source/WebKit2:

Toggle the resource usage overlay visibility by pressing CTRL + Shift + G. Only available when building with
developer mode enabled.

* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(webkitWebViewBaseKeyPressEvent):

Source/WTF:

Enable RESOURCE_USAGE for GTK+ port too.

* wtf/Platform.h:

LayoutTests:

Unskip inpector tests depending on RESOURCE_USAGE.

* platform/gtk/TestExpectations:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkChangeLog">trunk/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsplatformgtkTestExpectations">trunk/LayoutTests/platform/gtk/TestExpectations</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreheapGCActivityCallbackcpp">trunk/Source/JavaScriptCore/heap/GCActivityCallback.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreheapGCActivityCallbackh">trunk/Source/JavaScriptCore/heap/GCActivityCallback.h</a></li>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFwtfPlatformh">trunk/Source/WTF/wtf/Platform.h</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorePlatformGTKcmake">trunk/Source/WebCore/PlatformGTK.cmake</a></li>
<li><a href="#trunkSourceWebCorepagePagecpp">trunk/Source/WebCore/page/Page.cpp</a></li>
<li><a href="#trunkSourceWebCorepageResourceUsageOverlayh">trunk/Source/WebCore/page/ResourceUsageOverlay.h</a></li>
<li><a href="#trunkSourceWebCorepageResourceUsageThreadh">trunk/Source/WebCore/page/ResourceUsageThread.h</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewBasecpp">trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp</a></li>
<li><a href="#trunkSourcecmakeOptionsGTKcmake">trunk/Source/cmake/OptionsGTK.cmake</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li>trunk/Source/WebCore/page/linux/</li>
<li><a href="#trunkSourceWebCorepagelinuxResourceUsageOverlayLinuxcpp">trunk/Source/WebCore/page/linux/ResourceUsageOverlayLinux.cpp</a></li>
<li><a href="#trunkSourceWebCorepagelinuxResourceUsageThreadLinuxcpp">trunk/Source/WebCore/page/linux/ResourceUsageThreadLinux.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/ChangeLog (211630 => 211631)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/ChangeLog        2017-02-03 12:56:20 UTC (rev 211630)
+++ trunk/ChangeLog        2017-02-03 13:03:33 UTC (rev 211631)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2017-02-03  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
+        [GTK] Add initial implementation of resource usage overlay
+        https://bugs.webkit.org/show_bug.cgi?id=167731
+
+        Reviewed by Michael Catanzaro.
+
+        Enable RESOURCE_USAGE.
+
+        * Source/cmake/OptionsGTK.cmake:
+
</ins><span class="cx"> 2017-02-02  Alex Christensen  &lt;achristensen@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Build fix after r211602
</span></span></pre></div>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (211630 => 211631)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2017-02-03 12:56:20 UTC (rev 211630)
+++ trunk/LayoutTests/ChangeLog        2017-02-03 13:03:33 UTC (rev 211631)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2017-02-03  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
+        [GTK] Add initial implementation of resource usage overlay
+        https://bugs.webkit.org/show_bug.cgi?id=167731
+
+        Reviewed by Michael Catanzaro.
+
+        Unskip inpector tests depending on RESOURCE_USAGE.
+
+        * platform/gtk/TestExpectations:
+
</ins><span class="cx"> 2017-02-03  Antoine Quint  &lt;graouts@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         LayoutTest media/modern-media-controls/tracks-panel/tracks-panel-hide-click-outside.html is a flaky timeout
</span></span></pre></div>
<a id="trunkLayoutTestsplatformgtkTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/gtk/TestExpectations (211630 => 211631)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/gtk/TestExpectations        2017-02-03 12:56:20 UTC (rev 211630)
+++ trunk/LayoutTests/platform/gtk/TestExpectations        2017-02-03 13:03:33 UTC (rev 211631)
</span><span class="lines">@@ -644,9 +644,6 @@
</span><span class="cx"> # Requires ENABLE(SAMPLING_PROFILER)
</span><span class="cx"> webkit.org/b/153466 inspector/sampling-profiler [ Skip ]
</span><span class="cx"> 
</span><del>-# Requires ENABLE(RESOURCE_USAGE).
-inspector/memory [ Skip ]
-
</del><span class="cx"> # This requires a specific font on Mac
</span><span class="cx"> fast/text/hidpi-text-selection-gap-between-words.html [ Skip ]
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (211630 => 211631)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2017-02-03 12:56:20 UTC (rev 211630)
+++ trunk/Source/JavaScriptCore/ChangeLog        2017-02-03 13:03:33 UTC (rev 211631)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2017-02-03  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
+        [GTK] Add initial implementation of resource usage overlay
+        https://bugs.webkit.org/show_bug.cgi?id=167731
+
+        Reviewed by Michael Catanzaro.
+
+        Also expose nextFireTime() for GTK+ port.
+
+        * heap/GCActivityCallback.cpp:
+        (JSC::GCActivityCallback::scheduleTimer):
+        (JSC::GCActivityCallback::cancelTimer):
+        * heap/GCActivityCallback.h:
+
</ins><span class="cx"> 2017-02-03  Csaba Osztrogonác  &lt;ossy@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         [cmake] Unreviewed AArch64 buildfix after r211603.
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreheapGCActivityCallbackcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/heap/GCActivityCallback.cpp (211630 => 211631)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/heap/GCActivityCallback.cpp        2017-02-03 12:56:20 UTC (rev 211630)
+++ trunk/Source/JavaScriptCore/heap/GCActivityCallback.cpp        2017-02-03 13:03:33 UTC (rev 211631)
</span><span class="lines">@@ -123,6 +123,7 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     m_delay = newDelay;
</span><ins>+    m_nextFireTime = WTF::currentTime() + newDelay;
</ins><span class="cx">     if (!m_delay) {
</span><span class="cx">         g_source_set_ready_time(m_timer.get(), 0);
</span><span class="cx">         return;
</span><span class="lines">@@ -141,6 +142,7 @@
</span><span class="cx"> void GCActivityCallback::cancelTimer()
</span><span class="cx"> {
</span><span class="cx">     m_delay = -1;
</span><ins>+    m_nextFireTime = 0;
</ins><span class="cx">     g_source_set_ready_time(m_timer.get(), -1);
</span><span class="cx"> }
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreheapGCActivityCallbackh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/heap/GCActivityCallback.h (211630 => 211631)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/heap/GCActivityCallback.h        2017-02-03 12:56:20 UTC (rev 211630)
+++ trunk/Source/JavaScriptCore/heap/GCActivityCallback.h        2017-02-03 13:03:33 UTC (rev 211631)
</span><span class="lines">@@ -59,7 +59,7 @@
</span><span class="cx"> 
</span><span class="cx">     static bool s_shouldCreateGCTimer;
</span><span class="cx"> 
</span><del>-#if USE(CF) || PLATFORM(EFL)
</del><ins>+#if USE(CF) || USE(GLIB)
</ins><span class="cx">     double nextFireTime() const { return m_nextFireTime; }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (211630 => 211631)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog        2017-02-03 12:56:20 UTC (rev 211630)
+++ trunk/Source/WTF/ChangeLog        2017-02-03 13:03:33 UTC (rev 211631)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2017-02-03  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
+        [GTK] Add initial implementation of resource usage overlay
+        https://bugs.webkit.org/show_bug.cgi?id=167731
+
+        Reviewed by Michael Catanzaro.
+
+        Enable RESOURCE_USAGE for GTK+ port too.
+
+        * wtf/Platform.h:
+
</ins><span class="cx"> 2017-02-02  Andreas Kling  &lt;akling@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [Mac] In-process memory pressure monitor for WebContent processes AKA websam
</span></span></pre></div>
<a id="trunkSourceWTFwtfPlatformh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/Platform.h (211630 => 211631)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/Platform.h        2017-02-03 12:56:20 UTC (rev 211630)
+++ trunk/Source/WTF/wtf/Platform.h        2017-02-03 13:03:33 UTC (rev 211631)
</span><span class="lines">@@ -1110,7 +1110,7 @@
</span><span class="cx"> #define USE_IOSURFACE 1
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#if PLATFORM(COCOA)
</del><ins>+#if PLATFORM(COCOA) || PLATFORM(GTK)
</ins><span class="cx"> #define ENABLE_RESOURCE_USAGE 1
</span><span class="cx"> #endif
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (211630 => 211631)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-02-03 12:56:20 UTC (rev 211630)
+++ trunk/Source/WebCore/ChangeLog        2017-02-03 13:03:33 UTC (rev 211631)
</span><span class="lines">@@ -1,3 +1,28 @@
</span><ins>+2017-02-03  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
+        [GTK] Add initial implementation of resource usage overlay
+        https://bugs.webkit.org/show_bug.cgi?id=167731
+
+        Reviewed by Michael Catanzaro.
+
+        Add an implementation of ResourceUsageOverlay and ResourceUsageThread for Linux systems.
+
+        * PlatformGTK.cmake: Add new new files to compilation.
+        * page/Page.cpp:
+        (WebCore::Page::setResourceUsageOverlayVisible): Do not create the page overlay if accelerated compositing is
+        not enabled.
+        * page/ResourceUsageOverlay.h:
+        * page/linux/ResourceUsageOverlayLinux.cpp: Added.
+        (WebCore::cpuUsageString):
+        (WebCore::formatByteNumber):
+        (WebCore::gcTimerString):
+        (WebCore::ResourceUsageOverlay::platformInitialize):
+        (WebCore::ResourceUsageOverlay::platformDestroy):
+        * page/linux/ResourceUsageThreadLinux.cpp: Added.
+        (WebCore::cpuPeriod):
+        (WebCore::cpuUsage):
+        (WebCore::ResourceUsageThread::platformThreadBody):
+
</ins><span class="cx"> 2017-02-03  Enrique Ocaña González  &lt;eocanha@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [GStreamer] Store preloaded media in webkit's cache
</span></span></pre></div>
<a id="trunkSourceWebCorePlatformGTKcmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/PlatformGTK.cmake (211630 => 211631)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/PlatformGTK.cmake        2017-02-03 12:56:20 UTC (rev 211630)
+++ trunk/Source/WebCore/PlatformGTK.cmake        2017-02-03 13:03:33 UTC (rev 211631)
</span><span class="lines">@@ -62,6 +62,9 @@
</span><span class="cx">     loader/soup/CachedRawResourceSoup.cpp
</span><span class="cx">     loader/soup/SubresourceLoaderSoup.cpp
</span><span class="cx"> 
</span><ins>+    page/linux/ResourceUsageOverlayLinux.cpp
+    page/linux/ResourceUsageThreadLinux.cpp
+
</ins><span class="cx">     platform/KillRingNone.cpp
</span><span class="cx">     platform/StaticPasteboard.cpp
</span><span class="cx">     platform/UserAgentQuirks.cpp
</span></span></pre></div>
<a id="trunkSourceWebCorepagePagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Page.cpp (211630 => 211631)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Page.cpp        2017-02-03 12:56:20 UTC (rev 211630)
+++ trunk/Source/WebCore/page/Page.cpp        2017-02-03 13:03:33 UTC (rev 211631)
</span><span class="lines">@@ -2146,7 +2146,7 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (!m_resourceUsageOverlay)
</del><ins>+    if (!m_resourceUsageOverlay &amp;&amp; m_settings-&gt;acceleratedCompositingEnabled())
</ins><span class="cx">         m_resourceUsageOverlay = std::make_unique&lt;ResourceUsageOverlay&gt;(*this);
</span><span class="cx"> }
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCorepageResourceUsageOverlayh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/ResourceUsageOverlay.h (211630 => 211631)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/ResourceUsageOverlay.h        2017-02-03 12:56:20 UTC (rev 211630)
+++ trunk/Source/WebCore/page/ResourceUsageOverlay.h        2017-02-03 13:03:33 UTC (rev 211631)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> #if ENABLE(RESOURCE_USAGE)
</span><span class="cx"> 
</span><span class="cx"> #include &quot;FloatRect.h&quot;
</span><ins>+#include &quot;GraphicsLayer.h&quot;
</ins><span class="cx"> #include &quot;IntRect.h&quot;
</span><span class="cx"> #include &quot;MainFrame.h&quot;
</span><span class="cx"> #include &quot;PageOverlay.h&quot;
</span><span class="lines">@@ -82,6 +83,11 @@
</span><span class="cx">     RetainPtr&lt;CALayer&gt; m_layer;
</span><span class="cx">     RetainPtr&lt;CALayer&gt; m_containerLayer;
</span><span class="cx"> #endif
</span><ins>+
+#if OS(LINUX)
+    std::unique_ptr&lt;GraphicsLayer&gt; m_paintLayer;
+    std::unique_ptr&lt;GraphicsLayerClient&gt; m_overlayPainter;
+#endif
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorepageResourceUsageThreadh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/ResourceUsageThread.h (211630 => 211631)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/ResourceUsageThread.h        2017-02-03 12:56:20 UTC (rev 211630)
+++ trunk/Source/WebCore/page/ResourceUsageThread.h        2017-02-03 13:03:33 UTC (rev 211631)
</span><span class="lines">@@ -25,7 +25,7 @@
</span><span class="cx"> 
</span><span class="cx"> #pragma once
</span><span class="cx"> 
</span><del>-#if ENABLE(RESOURCE_USAGE)
</del><ins>+#if ENABLE(RESOURCE_USAGE) &amp;&amp; OS(LINUX)
</ins><span class="cx"> 
</span><span class="cx"> #include &quot;ResourceUsageData.h&quot;
</span><span class="cx"> #include &lt;array&gt;
</span><span class="lines">@@ -87,4 +87,4 @@
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><del>-#endif // ENABLE(RESOURCE_USAGE)
</del><ins>+#endif // ENABLE(RESOURCE_USAGE) &amp;&amp; OS(LINUX)
</ins></span></pre></div>
<a id="trunkSourceWebCorepagelinuxResourceUsageOverlayLinuxcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/page/linux/ResourceUsageOverlayLinux.cpp (0 => 211631)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/linux/ResourceUsageOverlayLinux.cpp                                (rev 0)
+++ trunk/Source/WebCore/page/linux/ResourceUsageOverlayLinux.cpp        2017-02-03 13:03:33 UTC (rev 211631)
</span><span class="lines">@@ -0,0 +1,163 @@
</span><ins>+/*
+ * Copyright (C) 2017 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include &quot;config.h&quot;
+#include &quot;ResourceUsageOverlay.h&quot;
+
+#if ENABLE(RESOURCE_USAGE) &amp;&amp; OS(LINUX)
+
+#include &quot;Chrome.h&quot;
+#include &quot;ChromeClient.h&quot;
+#include &quot;CommonVM.h&quot;
+#include &quot;GraphicsContext.h&quot;
+#include &quot;Page.h&quot;
+#include &quot;RenderTheme.h&quot;
+#include &quot;ResourceUsageThread.h&quot;
+#include &lt;runtime/VM.h&gt;
+
+namespace WebCore {
+
+static ResourceUsageData gData;
+
+static String cpuUsageString(float cpuUsage)
+{
+    if (cpuUsage &lt; 0)
+        return ASCIILiteral(&quot;&lt;unknown&gt;&quot;);
+    return String::format(&quot;%.1f%%&quot;, cpuUsage);
+}
+
+static String formatByteNumber(size_t number)
+{
+    if (number &gt;= 1024 * 1048576)
+        return String::format(&quot;%.3f GB&quot;, static_cast&lt;double&gt;(number) / (1024 * 1048576));
+    if (number &gt;= 1048576)
+        return String::format(&quot;%.2f MB&quot;, static_cast&lt;double&gt;(number) / 1048576);
+    if (number &gt;= 1024)
+        return String::format(&quot;%.1f kB&quot;, static_cast&lt;double&gt;(number) / 1024);
+    return String::format(&quot;%lu&quot;, number);
+}
+
+static String gcTimerString(double timerFireDate, double now)
+{
+    if (!timerFireDate)
+        return ASCIILiteral(&quot;[not scheduled]&quot;);
+    return String::format(&quot;%g&quot;, timerFireDate - now);
+}
+
+static const float gFontSize = 14;
+
+class ResourceUsageOverlayPainter final : public GraphicsLayerClient {
+public:
+    ResourceUsageOverlayPainter(ResourceUsageOverlay&amp; overlay)
+        : m_overlay(overlay)
+    {
+        FontCascadeDescription fontDescription;
+        RenderTheme::defaultTheme()-&gt;systemFont(CSSValueMessageBox, fontDescription);
+        fontDescription.setComputedSize(gFontSize);
+        m_textFont = FontCascade(fontDescription, 0, 0);
+        m_textFont.update(nullptr);
+    }
+
+    ~ResourceUsageOverlayPainter()
+    {
+    }
+
+private:
+    void paintContents(const GraphicsLayer*, GraphicsContext&amp; context, GraphicsLayerPaintingPhase, const FloatRect&amp; clip) override
+    {
+        GraphicsContextStateSaver stateSaver(context);
+        context.fillRect(clip, Color(0.0f, 0.0f, 0.0f, 0.8f));
+        context.setFillColor(Color(0.9f, 0.9f, 0.9f, 1.f));
+
+        FloatPoint position = { 10, 20 };
+        String string =  &quot;CPU: &quot; + cpuUsageString(gData.cpu);
+        context.drawText(m_textFont, TextRun(string), position);
+        position.move(0, gFontSize + 2);
+
+        string = &quot;Memory: &quot; + formatByteNumber(gData.totalDirtySize);
+        context.drawText(m_textFont, TextRun(string), position);
+        position.move(0, gFontSize + 2);
+
+        string = &quot;External: &quot; + formatByteNumber(gData.totalExternalSize);
+        context.drawText(m_textFont, TextRun(string), position);
+        position.move(0, gFontSize + 2);
+
+        string = &quot;GC Heap: &quot; + formatByteNumber(gData.categories[MemoryCategory::GCHeap].dirtySize);
+        context.drawText(m_textFont, TextRun(string), position);
+        position.move(0, gFontSize + 2);
+
+        string = &quot;GC owned: &quot; + formatByteNumber(gData.categories[MemoryCategory::GCOwned].dirtySize);
+        context.drawText(m_textFont, TextRun(string), position);
+        position.move(0, gFontSize + 2);
+
+        double now = WTF::currentTime();
+        string = &quot;Eden GC: &quot; + gcTimerString(gData.timeOfNextEdenCollection, now);
+        context.drawText(m_textFont, TextRun(string), position);
+        position.move(0, gFontSize + 2);
+
+        string = &quot;Full GC: &quot; + gcTimerString(gData.timeOfNextFullCollection, now);
+        context.drawText(m_textFont, TextRun(string), position);
+        position.move(0, gFontSize + 2);
+    }
+
+    void notifyFlushRequired(const GraphicsLayer*) override
+    {
+        m_overlay.overlay().page()-&gt;chrome().client().scheduleCompositingLayerFlush();
+    }
+
+    ResourceUsageOverlay&amp; m_overlay;
+    FontCascade m_textFont;
+};
+
+void ResourceUsageOverlay::platformInitialize()
+{
+    m_overlayPainter = std::make_unique&lt;ResourceUsageOverlayPainter&gt;(*this);
+    m_paintLayer = GraphicsLayer::create(overlay().page()-&gt;chrome().client().graphicsLayerFactory(), *m_overlayPainter);
+    m_paintLayer-&gt;setAnchorPoint(FloatPoint3D());
+    m_paintLayer-&gt;setSize({ normalWidth, normalHeight });
+    m_paintLayer-&gt;setBackgroundColor(Color(0.0f, 0.0f, 0.0f, 0.8f));
+    m_paintLayer-&gt;setDrawsContent(true);
+    overlay().layer().addChild(m_paintLayer.get());
+
+    ResourceUsageThread::addObserver(this, [this] (const ResourceUsageData&amp; data) {
+        gData = data;
+        m_paintLayer-&gt;setNeedsDisplay();
+    });
+}
+
+void ResourceUsageOverlay::platformDestroy()
+{
+    ResourceUsageThread::removeObserver(this);
+    if (!m_paintLayer)
+        return;
+
+    m_paintLayer-&gt;removeFromParent();
+    m_paintLayer = nullptr;
+    m_overlayPainter = nullptr;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(RESOURCE_USAGE) &amp;&amp; OS(LINUX)
</ins></span></pre></div>
<a id="trunkSourceWebCorepagelinuxResourceUsageThreadLinuxcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/page/linux/ResourceUsageThreadLinux.cpp (0 => 211631)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/linux/ResourceUsageThreadLinux.cpp                                (rev 0)
+++ trunk/Source/WebCore/page/linux/ResourceUsageThreadLinux.cpp        2017-02-03 13:03:33 UTC (rev 211631)
</span><span class="lines">@@ -0,0 +1,171 @@
</span><ins>+/*
+ * Copyright (C) 2017 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include &quot;config.h&quot;
+#include &quot;ResourceUsageThread.h&quot;
+
+#if ENABLE(RESOURCE_USAGE)
+
+#include &quot;CurrentProcessMemoryStatus.h&quot;
+#include &lt;errno.h&gt;
+#include &lt;fcntl.h&gt;
+#include &lt;heap/GCActivityCallback.h&gt;
+#include &lt;runtime/VM.h&gt;
+#include &lt;stdio.h&gt;
+#include &lt;stdlib.h&gt;
+#include &lt;sys/stat.h&gt;
+#include &lt;sys/types.h&gt;
+#include &lt;unistd.h&gt;
+
+namespace WebCore {
+
+static float cpuPeriod()
+{
+    FILE* file = fopen(&quot;/proc/stat&quot;, &quot;r&quot;);
+    if (!file)
+        return 0;
+
+    static const unsigned statMaxLineLength = 512;
+    char buffer[statMaxLineLength + 1];
+    char* line = fgets(buffer, statMaxLineLength, file);
+    if (!line) {
+        fclose(file);
+        return 0;
+    }
+
+    unsigned long long userTime, niceTime, systemTime, idleTime;
+    unsigned long long ioWait, irq, softIrq, steal, guest, guestnice;
+    ioWait = irq = softIrq = steal = guest = guestnice = 0;
+    sscanf(buffer, &quot;cpu  %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu %16llu&quot;,
+        &amp;userTime, &amp;niceTime, &amp;systemTime, &amp;idleTime, &amp;ioWait, &amp;irq, &amp;softIrq, &amp;steal, &amp;guest, &amp;guestnice);
+
+    // Keep parsing if we still don't know cpuCount.
+    static unsigned cpuCount = 0;
+    if (!cpuCount) {
+        while ((line = fgets(buffer, statMaxLineLength, file))) {
+            if (strlen(line) &gt; 4 &amp;&amp; line[0] == 'c' &amp;&amp; line[1] == 'p' &amp;&amp; line[2] == 'u')
+                cpuCount++;
+            else
+                break;
+        }
+    }
+    fclose(file);
+
+    if (!cpuCount)
+        return 0;
+
+    static unsigned long long previousTotalTime = 0;
+    unsigned long long totalTime = userTime + niceTime + systemTime + irq + softIrq + idleTime + ioWait + steal;
+    unsigned long long period = totalTime &gt; previousTotalTime ? totalTime - previousTotalTime : 0;
+    previousTotalTime = totalTime;
+    return static_cast&lt;float&gt;(period) / cpuCount;
+}
+
+static float cpuUsage()
+{
+    float period = cpuPeriod();
+    if (!period)
+        return -1;
+
+    int fd = open(&quot;/proc/self/stat&quot;, O_RDONLY);
+    if (fd &lt; 0)
+        return -1;
+
+    static const ssize_t maxBufferLength = BUFSIZ - 1;
+    char buffer[BUFSIZ];
+    buffer[0] = '\0';
+
+    ssize_t totalBytesRead = 0;
+    while (totalBytesRead &lt; maxBufferLength) {
+        ssize_t bytesRead = read(fd, buffer + totalBytesRead, maxBufferLength - totalBytesRead);
+        if (bytesRead &lt; 0) {
+            if (errno != EINTR) {
+                close(fd);
+                return -1;
+            }
+            continue;
+        }
+
+        if (!bytesRead)
+            break;
+
+        totalBytesRead += bytesRead;
+    }
+    close(fd);
+    buffer[totalBytesRead] = '\0';
+
+    // Skip pid and process name.
+    char* position = strrchr(buffer, ')');
+    if (!position)
+        return -1;
+
+    // Move after state.
+    position += 4;
+
+    // Skip ppid, pgrp, sid, tty_nr, tty_pgrp, flags, min_flt, cmin_flt, maj_flt, cmaj_flt.
+    unsigned tokensToSkip = 10;
+    while (tokensToSkip--) {
+        while (!isASCIISpace(position[0]))
+            position++;
+        position++;
+    }
+
+    static unsigned long long previousUtime = 0;
+    static unsigned long long previousStime = 0;
+    unsigned long long utime = strtoull(position, &amp;position, 10);
+    unsigned long long stime = strtoull(position, &amp;position, 10);
+    float usage = (utime + stime - (previousUtime + previousStime)) / period * 100.0;
+    previousUtime = utime;
+    previousStime = stime;
+
+    return clampTo&lt;float&gt;(usage, 0, 100);
+}
+
+void ResourceUsageThread::platformThreadBody(JSC::VM* vm, ResourceUsageData&amp; data)
+{
+    data.cpu = cpuUsage();
+
+    ProcessMemoryStatus memoryStatus;
+    currentProcessMemoryStatus(memoryStatus);
+    data.totalDirtySize = memoryStatus.resident - memoryStatus.shared;
+
+    size_t currentGCHeapCapacity = vm-&gt;heap.blockBytesAllocated();
+    size_t currentGCOwnedExtra = vm-&gt;heap.extraMemorySize();
+    size_t currentGCOwnedExternal = vm-&gt;heap.externalMemorySize();
+    RELEASE_ASSERT(currentGCOwnedExternal &lt;= currentGCOwnedExtra);
+
+    data.categories[MemoryCategory::GCHeap].dirtySize = currentGCHeapCapacity;
+    data.categories[MemoryCategory::GCOwned].dirtySize = currentGCOwnedExtra - currentGCOwnedExternal;
+    data.categories[MemoryCategory::GCOwned].externalSize = currentGCOwnedExternal;
+
+    data.totalExternalSize = currentGCOwnedExternal;
+
+    data.timeOfNextEdenCollection = vm-&gt;heap.edenActivityCallback()-&gt;nextFireTime();
+    data.timeOfNextFullCollection = vm-&gt;heap.fullActivityCallback()-&gt;nextFireTime();
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(RESOURCE_USAGE)
</ins></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (211630 => 211631)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2017-02-03 12:56:20 UTC (rev 211630)
+++ trunk/Source/WebKit2/ChangeLog        2017-02-03 13:03:33 UTC (rev 211631)
</span><span class="lines">@@ -1,5 +1,18 @@
</span><span class="cx"> 2017-02-03  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
</span><span class="cx"> 
</span><ins>+        [GTK] Add initial implementation of resource usage overlay
+        https://bugs.webkit.org/show_bug.cgi?id=167731
+
+        Reviewed by Michael Catanzaro.
+
+        Toggle the resource usage overlay visibility by pressing CTRL + Shift + G. Only available when building with
+        developer mode enabled.
+
+        * UIProcess/API/gtk/WebKitWebViewBase.cpp:
+        (webkitWebViewBaseKeyPressEvent):
+
+2017-02-03  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
+
</ins><span class="cx">         REGRESSION(r211486) [GTK] The MiniBrowser doesn't work anymore.
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=167776
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkWebKitWebViewBasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp (211630 => 211631)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp        2017-02-03 12:56:20 UTC (rev 211630)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp        2017-02-03 13:03:33 UTC (rev 211631)
</span><span class="lines">@@ -683,6 +683,15 @@
</span><span class="cx">     WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget);
</span><span class="cx">     WebKitWebViewBasePrivate* priv = webViewBase-&gt;priv;
</span><span class="cx"> 
</span><ins>+#if ENABLE(DEVELOPER_MODE) &amp;&amp; OS(LINUX)
+    if ((keyEvent-&gt;state &amp; (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) &amp;&amp; keyEvent-&gt;keyval == GDK_KEY_G) {
+        auto&amp; preferences = priv-&gt;pageProxy-&gt;preferences();
+        preferences.setResourceUsageOverlayVisible(!preferences.resourceUsageOverlayVisible());
+        priv-&gt;shouldForwardNextKeyEvent = FALSE;
+        return TRUE;
+    }
+#endif
+
</ins><span class="cx">     if (priv-&gt;authenticationDialog)
</span><span class="cx">         return GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)-&gt;key_press_event(widget, keyEvent);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourcecmakeOptionsGTKcmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/cmake/OptionsGTK.cmake (211630 => 211631)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/cmake/OptionsGTK.cmake        2017-02-03 12:56:20 UTC (rev 211630)
+++ trunk/Source/cmake/OptionsGTK.cmake        2017-02-03 13:03:33 UTC (rev 211631)
</span><span class="lines">@@ -171,6 +171,7 @@
</span><span class="cx"> WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MHTML PRIVATE ON)
</span><span class="cx"> WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_NOTIFICATIONS PRIVATE ON)
</span><span class="cx"> WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_PUBLIC_SUFFIX_LIST PRIVATE ON)
</span><ins>+WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_RESOURCE_USAGE PRIVATE ON)
</ins><span class="cx"> WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_SMOOTH_SCROLLING PRIVATE ON)
</span><span class="cx"> WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_USERSELECT_ALL PRIVATE ON)
</span><span class="cx"> WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_USER_MESSAGE_HANDLERS PRIVATE ON)
</span></span></pre>
</div>
</div>

</body>
</html>