<!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>[198739] 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/198739">198739</a></dd>
<dt>Author</dt> <dd>timothy@apple.com</dd>
<dt>Date</dt> <dd>2016-03-28 08:57:37 -0700 (Mon, 28 Mar 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Web Automation: Add commands to compute layout of an element

https://bugs.webkit.org/show_bug.cgi?id=155841
rdar://problem/25340075

Reviewed by Brian Burg.

Source/WebCore:

* dom/Element.h: Mark scrollIntoViewIfNeeded() method as exported so WK2 can use it.
* platform/ScrollView.h: Mark rootViewToContents(IntRect) method as exported so WK2 can use it.

Source/WebKit2:

* UIProcess/Automation/Automation.json: Added computeElementLayout.

* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::computeElementLayout): Added.
(WebKit::WebAutomationSession::didComputeElementLayout): Added.
* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/Automation/WebAutomationSession.messages.in:
(DidComputeElementLayout): Added.

* WebProcess/Automation/WebAutomationSessionProxy.cpp:
(WebKit::WebAutomationSessionProxy::computeElementLayout): Added.
* WebProcess/Automation/WebAutomationSessionProxy.h:
* WebProcess/Automation/WebAutomationSessionProxy.messages.in:
(ComputeElementLayout): Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoredomElementh">trunk/Source/WebCore/dom/Element.h</a></li>
<li><a href="#trunkSourceWebCoreplatformScrollViewh">trunk/Source/WebCore/platform/ScrollView.h</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAutomationAutomationjson">trunk/Source/WebKit2/UIProcess/Automation/Automation.json</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAutomationWebAutomationSessioncpp">trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAutomationWebAutomationSessionh">trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAutomationWebAutomationSessionmessagesin">trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.messages.in</a></li>
<li><a href="#trunkSourceWebKit2WebProcessAutomationWebAutomationSessionProxycpp">trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessAutomationWebAutomationSessionProxyh">trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessAutomationWebAutomationSessionProxymessagesin">trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.messages.in</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (198738 => 198739)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-03-28 15:57:23 UTC (rev 198738)
+++ trunk/Source/WebCore/ChangeLog        2016-03-28 15:57:37 UTC (rev 198739)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2016-03-24  Timothy Hatcher  &lt;timothy@apple.com&gt;
+
+        Web Automation: Add commands to compute layout of an element
+
+        https://bugs.webkit.org/show_bug.cgi?id=155841
+        rdar://problem/25340075
+
+        Reviewed by Brian Burg.
+
+        * dom/Element.h: Mark scrollIntoViewIfNeeded() method as exported so WK2 can use it.
+        * platform/ScrollView.h: Mark rootViewToContents(IntRect) method as exported so WK2 can use it.
+
</ins><span class="cx"> 2016-03-18  Timothy Hatcher  &lt;timothy@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Web Automation: Add Automation protocol commands to resolve frames as handles
</span></span></pre></div>
<a id="trunkSourceWebCoredomElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Element.h (198738 => 198739)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Element.h        2016-03-28 15:57:23 UTC (rev 198738)
+++ trunk/Source/WebCore/dom/Element.h        2016-03-28 15:57:37 UTC (rev 198739)
</span><span class="lines">@@ -124,7 +124,7 @@
</span><span class="cx">     unsigned findAttributeIndexByName(const AtomicString&amp; name, bool shouldIgnoreAttributeCase) const { return elementData()-&gt;findAttributeIndexByName(name, shouldIgnoreAttributeCase); }
</span><span class="cx"> 
</span><span class="cx">     void scrollIntoView(bool alignToTop = true);
</span><del>-    void scrollIntoViewIfNeeded(bool centerIfNeeded = true);
</del><ins>+    WEBCORE_EXPORT void scrollIntoViewIfNeeded(bool centerIfNeeded = true);
</ins><span class="cx">     WEBCORE_EXPORT void scrollIntoViewIfNotVisible(bool centerIfNotVisible = true);
</span><span class="cx"> 
</span><span class="cx">     void scrollByLines(int lines);
</span><span class="lines">@@ -157,7 +157,7 @@
</span><span class="cx"> 
</span><span class="cx">     Ref&lt;ClientRectList&gt; getClientRects();
</span><span class="cx">     Ref&lt;ClientRect&gt; getBoundingClientRect();
</span><del>-    
</del><ins>+
</ins><span class="cx">     // Returns the absolute bounding box translated into client coordinates.
</span><span class="cx">     WEBCORE_EXPORT IntRect clientRect() const;
</span><span class="cx">     // Returns the absolute bounding box translated into screen coordinates.
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformScrollViewh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ScrollView.h (198738 => 198739)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ScrollView.h        2016-03-28 15:57:23 UTC (rev 198738)
+++ trunk/Source/WebCore/platform/ScrollView.h        2016-03-28 15:57:37 UTC (rev 198739)
</span><span class="lines">@@ -286,7 +286,7 @@
</span><span class="cx"> 
</span><span class="cx">     WEBCORE_EXPORT IntPoint rootViewToContents(const IntPoint&amp;) const;
</span><span class="cx">     WEBCORE_EXPORT IntPoint contentsToRootView(const IntPoint&amp;) const;
</span><del>-    IntRect rootViewToContents(const IntRect&amp;) const;
</del><ins>+    WEBCORE_EXPORT IntRect rootViewToContents(const IntRect&amp;) const;
</ins><span class="cx">     WEBCORE_EXPORT IntRect contentsToRootView(const IntRect&amp;) const;
</span><span class="cx"> 
</span><span class="cx">     IntPoint viewToContents(const IntPoint&amp;) const;
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (198738 => 198739)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-03-28 15:57:23 UTC (rev 198738)
+++ trunk/Source/WebKit2/ChangeLog        2016-03-28 15:57:37 UTC (rev 198739)
</span><span class="lines">@@ -1,3 +1,27 @@
</span><ins>+2016-03-24  Timothy Hatcher  &lt;timothy@apple.com&gt;
+
+        Web Automation: Add commands to compute layout of an element
+
+        https://bugs.webkit.org/show_bug.cgi?id=155841
+        rdar://problem/25340075
+
+        Reviewed by Brian Burg.
+
+        * UIProcess/Automation/Automation.json: Added computeElementLayout.
+
+        * UIProcess/Automation/WebAutomationSession.cpp:
+        (WebKit::WebAutomationSession::computeElementLayout): Added.
+        (WebKit::WebAutomationSession::didComputeElementLayout): Added.
+        * UIProcess/Automation/WebAutomationSession.h:
+        * UIProcess/Automation/WebAutomationSession.messages.in:
+        (DidComputeElementLayout): Added.
+
+        * WebProcess/Automation/WebAutomationSessionProxy.cpp:
+        (WebKit::WebAutomationSessionProxy::computeElementLayout): Added.
+        * WebProcess/Automation/WebAutomationSessionProxy.h:
+        * WebProcess/Automation/WebAutomationSessionProxy.messages.in:
+        (ComputeElementLayout): Added.
+
</ins><span class="cx"> 2016-03-18  Timothy Hatcher  &lt;timothy@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Web Automation: Add Automation protocol commands to resolve frames as handles
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAutomationAutomationjson"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Automation/Automation.json (198738 => 198739)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Automation/Automation.json        2016-03-28 15:57:23 UTC (rev 198738)
+++ trunk/Source/WebKit2/UIProcess/Automation/Automation.json        2016-03-28 15:57:37 UTC (rev 198739)
</span><span class="lines">@@ -3,6 +3,30 @@
</span><span class="cx">     &quot;description&quot;: &quot;Automation domain exposes commands for automating user interactions with the browser.&quot;,
</span><span class="cx">     &quot;types&quot;: [
</span><span class="cx">         {
</span><ins>+            &quot;id&quot;: &quot;Point&quot;,
+            &quot;type&quot;: &quot;object&quot;,
+            &quot;properties&quot;: [
+                { &quot;name&quot;: &quot;x&quot;, &quot;type&quot;: &quot;number&quot; },
+                { &quot;name&quot;: &quot;y&quot;, &quot;type&quot;: &quot;number&quot; }
+            ]
+        },
+        {
+            &quot;id&quot;: &quot;Size&quot;,
+            &quot;type&quot;: &quot;object&quot;,
+            &quot;properties&quot;: [
+                { &quot;name&quot;: &quot;width&quot;, &quot;type&quot;: &quot;number&quot; },
+                { &quot;name&quot;: &quot;height&quot;, &quot;type&quot;: &quot;number&quot; }
+            ]
+        },
+        {
+            &quot;id&quot;: &quot;Rect&quot;,
+            &quot;type&quot;: &quot;object&quot;,
+            &quot;properties&quot;: [
+                { &quot;name&quot;: &quot;origin&quot;, &quot;$ref&quot;: &quot;Point&quot; },
+                { &quot;name&quot;: &quot;size&quot;, &quot;$ref&quot;: &quot;Size&quot; }
+            ]
+        },
+        {
</ins><span class="cx">             &quot;id&quot;: &quot;BrowsingContextHandle&quot;,
</span><span class="cx">             &quot;type&quot;: &quot;string&quot;,
</span><span class="cx">             &quot;description&quot;: &quot;An opaque identifier for a browsing context.&quot;
</span><span class="lines">@@ -152,6 +176,21 @@
</span><span class="cx">                 { &quot;name&quot;: &quot;result&quot;, &quot;$ref&quot;: &quot;FrameHandle&quot;, &quot;description&quot;: &quot;The &lt;code&gt;FrameHandle&lt;/code&gt; for the requested frame.&quot; }
</span><span class="cx">             ],
</span><span class="cx">             &quot;async&quot;: true
</span><ins>+        },
+        {
+            &quot;name&quot;: &quot;computeElementLayout&quot;,
+            &quot;description&quot;: &quot;Computes the layout for an element.&quot;,
+            &quot;parameters&quot;: [
+                { &quot;name&quot;: &quot;browsingContextHandle&quot;, &quot;$ref&quot;: &quot;BrowsingContextHandle&quot;, &quot;description&quot;: &quot;The handle for the browsing context the frame is located.&quot; },
+                { &quot;name&quot;: &quot;frameHandle&quot;, &quot;$ref&quot;: &quot;FrameHandle&quot;, &quot;description&quot;: &quot;The handle for the frame that contains the element.&quot; },
+                { &quot;name&quot;: &quot;nodeHandle&quot;, &quot;$ref&quot;: &quot;NodeHandle&quot;, &quot;description&quot;: &quot;The handle of the element to use.&quot; },
+                { &quot;name&quot;: &quot;scrollIntoViewIfNeeded&quot;, &quot;optional&quot;: true, &quot;type&quot;: &quot;boolean&quot;, &quot;description&quot;: &quot;If the element should be scrolled into view before computing its layout.&quot; },
+                { &quot;name&quot;: &quot;useViewportCoordinates&quot;, &quot;optional&quot;: true, &quot;type&quot;: &quot;boolean&quot;, &quot;description&quot;: &quot;If the result coordinates should be represented as viewport coordinates or not. Defaults to false, which means coordinates should be represented as page coordinates.&quot; }
+            ],
+            &quot;returns&quot;: [
+                { &quot;name&quot;: &quot;rect&quot;, &quot;$ref&quot;: &quot;Rect&quot;, &quot;description&quot;: &quot;The layout rect for the requested element. Specified in page or viewport coordinates based on the useViewportCoordinates parameter.&quot; }
+            ],
+            &quot;async&quot;: true
</ins><span class="cx">         }
</span><span class="cx">     ]
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAutomationWebAutomationSessioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp (198738 => 198739)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp        2016-03-28 15:57:23 UTC (rev 198738)
+++ trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp        2016-03-28 15:57:37 UTC (rev 198739)
</span><span class="lines">@@ -417,4 +417,52 @@
</span><span class="cx">         callback-&gt;sendSuccess(handleForWebFrameID(frameID));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebAutomationSession::computeElementLayout(Inspector::ErrorString&amp; errorString, const String&amp; browsingContextHandle, const String&amp; frameHandle, const String&amp; nodeHandle, const bool* optionalScrollIntoViewIfNeeded, const bool* optionalUseViewportCoordinates, Ref&lt;ComputeElementLayoutCallback&gt;&amp;&amp; callback)
+{
+    WebPageProxy* page = webPageProxyForHandle(browsingContextHandle);
+    if (!page)
+        FAIL_WITH_PREDEFINED_ERROR_MESSAGE(WindowNotFound);
+
+    WebFrameProxy* frame = webFrameProxyForHandle(frameHandle, *page);
+    if (!frame)
+        FAIL_WITH_PREDEFINED_ERROR_MESSAGE(FrameNotFound);
+
+    uint64_t callbackID = m_nextComputeElementLayoutCallbackID++;
+    m_computeElementLayoutCallbacks.set(callbackID, WTFMove(callback));
+
+    bool scrollIntoViewIfNeeded = optionalScrollIntoViewIfNeeded ? *optionalScrollIntoViewIfNeeded : false;
+    bool useViewportCoordinates = optionalUseViewportCoordinates ? *optionalUseViewportCoordinates : false;
+
+    page-&gt;process().send(Messages::WebAutomationSessionProxy::ComputeElementLayout(frame-&gt;frameID(), nodeHandle, scrollIntoViewIfNeeded, useViewportCoordinates, callbackID), 0);
+}
+
+void WebAutomationSession::didComputeElementLayout(uint64_t callbackID, WebCore::IntRect rect, const String&amp; errorType)
+{
+    auto callback = m_computeElementLayoutCallbacks.take(callbackID);
+    if (!callback)
+        return;
+
+    if (!errorType.isEmpty()) {
+        callback-&gt;sendFailure(errorType);
+        return;
+    }
+
+    auto originObject = Inspector::Protocol::Automation::Point::create()
+        .setX(rect.x())
+        .setY(rect.y())
+        .release();
+
+    auto sizeObject = Inspector::Protocol::Automation::Size::create()
+        .setWidth(rect.width())
+        .setHeight(rect.height())
+        .release();
+
+    auto rectObject = Inspector::Protocol::Automation::Rect::create()
+        .setOrigin(WTFMove(originObject))
+        .setSize(WTFMove(sizeObject))
+        .release();
+
+    callback-&gt;sendSuccess(WTFMove(rectObject));
+}
+
</ins><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAutomationWebAutomationSessionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.h (198738 => 198739)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.h        2016-03-28 15:57:23 UTC (rev 198738)
+++ trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.h        2016-03-28 15:57:37 UTC (rev 198739)
</span><span class="lines">@@ -44,6 +44,10 @@
</span><span class="cx"> class FrontendRouter;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+namespace WebCore {
+class IntRect;
+}
+
</ins><span class="cx"> namespace WebKit {
</span><span class="cx"> 
</span><span class="cx"> class WebAutomationSessionClient;
</span><span class="lines">@@ -90,6 +94,7 @@
</span><span class="cx">     void evaluateJavaScriptFunction(Inspector::ErrorString&amp;, const String&amp; browsingContextHandle, const String* optionalFrameHandle, const String&amp; function, const Inspector::InspectorArray&amp; arguments, bool expectsImplicitCallbackArgument, Ref&lt;Inspector::AutomationBackendDispatcherHandler::EvaluateJavaScriptFunctionCallback&gt;&amp;&amp;) override;
</span><span class="cx">     void resolveChildFrameHandle(Inspector::ErrorString&amp;, const String&amp; browsingContextHandle, const String* optionalFrameHandle, const int* optionalOrdinal, const String* optionalName, const String* optionalNodeHandle, Ref&lt;ResolveChildFrameHandleCallback&gt;&amp;&amp;) override;
</span><span class="cx">     void resolveParentFrameHandle(Inspector::ErrorString&amp;, const String&amp; browsingContextHandle, const String&amp; frameHandle, Ref&lt;ResolveParentFrameHandleCallback&gt;&amp;&amp;) override;
</span><ins>+    void computeElementLayout(Inspector::ErrorString&amp;, const String&amp; browsingContextHandle, const String&amp; frameHandle, const String&amp; nodeHandle, const bool* optionalScrollIntoViewIfNeeded, const bool* useViewportCoordinates, Ref&lt;Inspector::AutomationBackendDispatcherHandler::ComputeElementLayoutCallback&gt;&amp;&amp;) override;
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     WebPageProxy* webPageProxyForHandle(const String&amp;);
</span><span class="lines">@@ -106,6 +111,7 @@
</span><span class="cx">     void didEvaluateJavaScriptFunction(uint64_t callbackID, const String&amp; result, const String&amp; errorType);
</span><span class="cx">     void didResolveChildFrame(uint64_t callbackID, uint64_t frameID, const String&amp; errorType);
</span><span class="cx">     void didResolveParentFrame(uint64_t callbackID, uint64_t frameID, const String&amp; errorType);
</span><ins>+    void didComputeElementLayout(uint64_t callbackID, WebCore::IntRect, const String&amp; errorType);
</ins><span class="cx"> 
</span><span class="cx">     WebProcessPool* m_processPool { nullptr };
</span><span class="cx"> 
</span><span class="lines">@@ -131,6 +137,9 @@
</span><span class="cx">     uint64_t m_nextResolveParentFrameCallbackID { 1 };
</span><span class="cx">     HashMap&lt;uint64_t, RefPtr&lt;Inspector::AutomationBackendDispatcherHandler::ResolveParentFrameHandleCallback&gt;&gt; m_resolveParentFrameHandleCallbacks;
</span><span class="cx"> 
</span><ins>+    uint64_t m_nextComputeElementLayoutCallbackID { 1 };
+    HashMap&lt;uint64_t, RefPtr&lt;Inspector::AutomationBackendDispatcherHandler::ComputeElementLayoutCallback&gt;&gt; m_computeElementLayoutCallbacks;
+
</ins><span class="cx"> #if ENABLE(REMOTE_INSPECTOR)
</span><span class="cx">     Inspector::FrontendChannel* m_remoteChannel { nullptr };
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAutomationWebAutomationSessionmessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.messages.in (198738 => 198739)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.messages.in        2016-03-28 15:57:23 UTC (rev 198738)
+++ trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.messages.in        2016-03-28 15:57:37 UTC (rev 198739)
</span><span class="lines">@@ -25,4 +25,6 @@
</span><span class="cx"> 
</span><span class="cx">     DidResolveChildFrame(uint64_t callbackID, uint64_t frameID, String errorType)
</span><span class="cx">     DidResolveParentFrame(uint64_t callbackID, uint64_t frameID, String errorType)
</span><ins>+
+    DidComputeElementLayout(uint64_t callbackID, WebCore::IntRect rect, String errorType)
</ins><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessAutomationWebAutomationSessionProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.cpp (198738 => 198739)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.cpp        2016-03-28 15:57:23 UTC (rev 198738)
+++ trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.cpp        2016-03-28 15:57:37 UTC (rev 198739)
</span><span class="lines">@@ -41,6 +41,7 @@
</span><span class="cx"> #include &lt;WebCore/DOMWindow.h&gt;
</span><span class="cx"> #include &lt;WebCore/Frame.h&gt;
</span><span class="cx"> #include &lt;WebCore/FrameTree.h&gt;
</span><ins>+#include &lt;WebCore/FrameView.h&gt;
</ins><span class="cx"> #include &lt;WebCore/HTMLFrameElementBase.h&gt;
</span><span class="cx"> #include &lt;WebCore/JSElement.h&gt;
</span><span class="cx"> #include &lt;WebCore/MainFrame.h&gt;
</span><span class="lines">@@ -407,4 +408,45 @@
</span><span class="cx">     coreDOMWindow-&gt;focus(true);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebAutomationSessionProxy::computeElementLayout(uint64_t frameID, String nodeHandle, bool scrollIntoViewIfNeeded, bool useViewportCoordinates, uint64_t callbackID)
+{
+    String frameNotFoundErrorType = Inspector::Protocol::getEnumConstantValue(Inspector::Protocol::Automation::ErrorMessage::FrameNotFound);
+    String nodeNotFoundErrorType = Inspector::Protocol::getEnumConstantValue(Inspector::Protocol::Automation::ErrorMessage::NodeNotFound);
+
+    WebFrame* frame = WebProcess::singleton().webFrame(frameID);
+    if (!frame) {
+        WebProcess::singleton().parentProcessConnection()-&gt;send(Messages::WebAutomationSession::DidComputeElementLayout(callbackID, WebCore::IntRect(), frameNotFoundErrorType), 0);
+        return;
+    }
+
+    WebCore::Element* coreElement = elementForNodeHandle(*frame, nodeHandle);
+    if (!coreElement) {
+        WebProcess::singleton().parentProcessConnection()-&gt;send(Messages::WebAutomationSession::DidComputeElementLayout(callbackID, WebCore::IntRect(), nodeNotFoundErrorType), 0);
+        return;
+    }
+
+    if (scrollIntoViewIfNeeded)
+        coreElement-&gt;scrollIntoViewIfNeeded(false);
+
+    WebCore::IntRect rect = coreElement-&gt;clientRect();
+
+    if (!useViewportCoordinates) {
+        WebCore::Frame* coreFrame = frame-&gt;coreFrame();
+        if (!coreFrame) {
+            WebProcess::singleton().parentProcessConnection()-&gt;send(Messages::WebAutomationSession::DidComputeElementLayout(callbackID, WebCore::IntRect(), frameNotFoundErrorType), 0);
+            return;
+        }
+
+        WebCore::FrameView *coreFrameView = coreFrame-&gt;view();
+        if (!coreFrameView) {
+            WebProcess::singleton().parentProcessConnection()-&gt;send(Messages::WebAutomationSession::DidComputeElementLayout(callbackID, WebCore::IntRect(), frameNotFoundErrorType), 0);
+            return;
+        }
+
+        rect = coreFrameView-&gt;rootViewToContents(rect);
+    }
+
+    WebProcess::singleton().parentProcessConnection()-&gt;send(Messages::WebAutomationSession::DidComputeElementLayout(callbackID, rect, emptyString()), 0);
+}
+
</ins><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessAutomationWebAutomationSessionProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.h (198738 => 198739)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.h        2016-03-28 15:57:23 UTC (rev 198738)
+++ trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.h        2016-03-28 15:57:37 UTC (rev 198739)
</span><span class="lines">@@ -63,6 +63,7 @@
</span><span class="cx">     void resolveChildFrameWithName(uint64_t frameID, const String&amp; name, uint64_t callbackID);
</span><span class="cx">     void resolveParentFrame(uint64_t frameID, uint64_t callbackID);
</span><span class="cx">     void focusFrame(uint64_t frameID);
</span><ins>+    void computeElementLayout(uint64_t frameID, String nodeHandle, bool scrollIntoViewIfNeeded, bool useViewportCoordinates, uint64_t callbackID);
</ins><span class="cx"> 
</span><span class="cx">     String m_sessionIdentifier;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessAutomationWebAutomationSessionProxymessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.messages.in (198738 => 198739)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.messages.in        2016-03-28 15:57:23 UTC (rev 198738)
+++ trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.messages.in        2016-03-28 15:57:37 UTC (rev 198739)
</span><span class="lines">@@ -29,4 +29,6 @@
</span><span class="cx">     ResolveParentFrame(uint64_t frameID, uint64_t callbackID)
</span><span class="cx"> 
</span><span class="cx">     FocusFrame(uint64_t frameID)
</span><ins>+
+    ComputeElementLayout(uint64_t frameID, String nodeHandle, bool scrollIntoViewIfNeeded, bool useViewportCoordinates, uint64_t callbackID)
</ins><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>