<!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 <timothy@apple.com>
+
+ 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 <timothy@apple.com>
</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& name, bool shouldIgnoreAttributeCase) const { return elementData()->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<ClientRectList> getClientRects();
</span><span class="cx"> Ref<ClientRect> 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&) const;
</span><span class="cx"> WEBCORE_EXPORT IntPoint contentsToRootView(const IntPoint&) const;
</span><del>- IntRect rootViewToContents(const IntRect&) const;
</del><ins>+ WEBCORE_EXPORT IntRect rootViewToContents(const IntRect&) const;
</ins><span class="cx"> WEBCORE_EXPORT IntRect contentsToRootView(const IntRect&) const;
</span><span class="cx">
</span><span class="cx"> IntPoint viewToContents(const IntPoint&) 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 <timothy@apple.com>
+
+ 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 <timothy@apple.com>
</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"> "description": "Automation domain exposes commands for automating user interactions with the browser.",
</span><span class="cx"> "types": [
</span><span class="cx"> {
</span><ins>+ "id": "Point",
+ "type": "object",
+ "properties": [
+ { "name": "x", "type": "number" },
+ { "name": "y", "type": "number" }
+ ]
+ },
+ {
+ "id": "Size",
+ "type": "object",
+ "properties": [
+ { "name": "width", "type": "number" },
+ { "name": "height", "type": "number" }
+ ]
+ },
+ {
+ "id": "Rect",
+ "type": "object",
+ "properties": [
+ { "name": "origin", "$ref": "Point" },
+ { "name": "size", "$ref": "Size" }
+ ]
+ },
+ {
</ins><span class="cx"> "id": "BrowsingContextHandle",
</span><span class="cx"> "type": "string",
</span><span class="cx"> "description": "An opaque identifier for a browsing context."
</span><span class="lines">@@ -152,6 +176,21 @@
</span><span class="cx"> { "name": "result", "$ref": "FrameHandle", "description": "The <code>FrameHandle</code> for the requested frame." }
</span><span class="cx"> ],
</span><span class="cx"> "async": true
</span><ins>+ },
+ {
+ "name": "computeElementLayout",
+ "description": "Computes the layout for an element.",
+ "parameters": [
+ { "name": "browsingContextHandle", "$ref": "BrowsingContextHandle", "description": "The handle for the browsing context the frame is located." },
+ { "name": "frameHandle", "$ref": "FrameHandle", "description": "The handle for the frame that contains the element." },
+ { "name": "nodeHandle", "$ref": "NodeHandle", "description": "The handle of the element to use." },
+ { "name": "scrollIntoViewIfNeeded", "optional": true, "type": "boolean", "description": "If the element should be scrolled into view before computing its layout." },
+ { "name": "useViewportCoordinates", "optional": true, "type": "boolean", "description": "If the result coordinates should be represented as viewport coordinates or not. Defaults to false, which means coordinates should be represented as page coordinates." }
+ ],
+ "returns": [
+ { "name": "rect", "$ref": "Rect", "description": "The layout rect for the requested element. Specified in page or viewport coordinates based on the useViewportCoordinates parameter." }
+ ],
+ "async": 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->sendSuccess(handleForWebFrameID(frameID));
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void WebAutomationSession::computeElementLayout(Inspector::ErrorString& errorString, const String& browsingContextHandle, const String& frameHandle, const String& nodeHandle, const bool* optionalScrollIntoViewIfNeeded, const bool* optionalUseViewportCoordinates, Ref<ComputeElementLayoutCallback>&& 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->process().send(Messages::WebAutomationSessionProxy::ComputeElementLayout(frame->frameID(), nodeHandle, scrollIntoViewIfNeeded, useViewportCoordinates, callbackID), 0);
+}
+
+void WebAutomationSession::didComputeElementLayout(uint64_t callbackID, WebCore::IntRect rect, const String& errorType)
+{
+ auto callback = m_computeElementLayoutCallbacks.take(callbackID);
+ if (!callback)
+ return;
+
+ if (!errorType.isEmpty()) {
+ callback->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->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&, const String& browsingContextHandle, const String* optionalFrameHandle, const String& function, const Inspector::InspectorArray& arguments, bool expectsImplicitCallbackArgument, Ref<Inspector::AutomationBackendDispatcherHandler::EvaluateJavaScriptFunctionCallback>&&) override;
</span><span class="cx"> void resolveChildFrameHandle(Inspector::ErrorString&, const String& browsingContextHandle, const String* optionalFrameHandle, const int* optionalOrdinal, const String* optionalName, const String* optionalNodeHandle, Ref<ResolveChildFrameHandleCallback>&&) override;
</span><span class="cx"> void resolveParentFrameHandle(Inspector::ErrorString&, const String& browsingContextHandle, const String& frameHandle, Ref<ResolveParentFrameHandleCallback>&&) override;
</span><ins>+ void computeElementLayout(Inspector::ErrorString&, const String& browsingContextHandle, const String& frameHandle, const String& nodeHandle, const bool* optionalScrollIntoViewIfNeeded, const bool* useViewportCoordinates, Ref<Inspector::AutomationBackendDispatcherHandler::ComputeElementLayoutCallback>&&) override;
</ins><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> WebPageProxy* webPageProxyForHandle(const String&);
</span><span class="lines">@@ -106,6 +111,7 @@
</span><span class="cx"> void didEvaluateJavaScriptFunction(uint64_t callbackID, const String& result, const String& errorType);
</span><span class="cx"> void didResolveChildFrame(uint64_t callbackID, uint64_t frameID, const String& errorType);
</span><span class="cx"> void didResolveParentFrame(uint64_t callbackID, uint64_t frameID, const String& errorType);
</span><ins>+ void didComputeElementLayout(uint64_t callbackID, WebCore::IntRect, const String& 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<uint64_t, RefPtr<Inspector::AutomationBackendDispatcherHandler::ResolveParentFrameHandleCallback>> m_resolveParentFrameHandleCallbacks;
</span><span class="cx">
</span><ins>+ uint64_t m_nextComputeElementLayoutCallbackID { 1 };
+ HashMap<uint64_t, RefPtr<Inspector::AutomationBackendDispatcherHandler::ComputeElementLayoutCallback>> 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 <WebCore/DOMWindow.h>
</span><span class="cx"> #include <WebCore/Frame.h>
</span><span class="cx"> #include <WebCore/FrameTree.h>
</span><ins>+#include <WebCore/FrameView.h>
</ins><span class="cx"> #include <WebCore/HTMLFrameElementBase.h>
</span><span class="cx"> #include <WebCore/JSElement.h>
</span><span class="cx"> #include <WebCore/MainFrame.h>
</span><span class="lines">@@ -407,4 +408,45 @@
</span><span class="cx"> coreDOMWindow->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()->send(Messages::WebAutomationSession::DidComputeElementLayout(callbackID, WebCore::IntRect(), frameNotFoundErrorType), 0);
+ return;
+ }
+
+ WebCore::Element* coreElement = elementForNodeHandle(*frame, nodeHandle);
+ if (!coreElement) {
+ WebProcess::singleton().parentProcessConnection()->send(Messages::WebAutomationSession::DidComputeElementLayout(callbackID, WebCore::IntRect(), nodeNotFoundErrorType), 0);
+ return;
+ }
+
+ if (scrollIntoViewIfNeeded)
+ coreElement->scrollIntoViewIfNeeded(false);
+
+ WebCore::IntRect rect = coreElement->clientRect();
+
+ if (!useViewportCoordinates) {
+ WebCore::Frame* coreFrame = frame->coreFrame();
+ if (!coreFrame) {
+ WebProcess::singleton().parentProcessConnection()->send(Messages::WebAutomationSession::DidComputeElementLayout(callbackID, WebCore::IntRect(), frameNotFoundErrorType), 0);
+ return;
+ }
+
+ WebCore::FrameView *coreFrameView = coreFrame->view();
+ if (!coreFrameView) {
+ WebProcess::singleton().parentProcessConnection()->send(Messages::WebAutomationSession::DidComputeElementLayout(callbackID, WebCore::IntRect(), frameNotFoundErrorType), 0);
+ return;
+ }
+
+ rect = coreFrameView->rootViewToContents(rect);
+ }
+
+ WebProcess::singleton().parentProcessConnection()->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& 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>