Changeset 198739 in webkit
- Timestamp:
- Mar 28, 2016, 8:57:37 AM (9 years ago)
- Location:
- trunk/Source
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r198738 r198739 1 2016-03-24 Timothy Hatcher <timothy@apple.com> 2 3 Web Automation: Add commands to compute layout of an element 4 5 https://bugs.webkit.org/show_bug.cgi?id=155841 6 rdar://problem/25340075 7 8 Reviewed by Brian Burg. 9 10 * dom/Element.h: Mark scrollIntoViewIfNeeded() method as exported so WK2 can use it. 11 * platform/ScrollView.h: Mark rootViewToContents(IntRect) method as exported so WK2 can use it. 12 1 13 2016-03-18 Timothy Hatcher <timothy@apple.com> 2 14 -
trunk/Source/WebCore/dom/Element.h
r197764 r198739 125 125 126 126 void scrollIntoView(bool alignToTop = true); 127 void scrollIntoViewIfNeeded(bool centerIfNeeded = true);127 WEBCORE_EXPORT void scrollIntoViewIfNeeded(bool centerIfNeeded = true); 128 128 WEBCORE_EXPORT void scrollIntoViewIfNotVisible(bool centerIfNotVisible = true); 129 129 … … 158 158 Ref<ClientRectList> getClientRects(); 159 159 Ref<ClientRect> getBoundingClientRect(); 160 160 161 161 // Returns the absolute bounding box translated into client coordinates. 162 162 WEBCORE_EXPORT IntRect clientRect() const; -
trunk/Source/WebCore/platform/ScrollView.h
r198560 r198739 287 287 WEBCORE_EXPORT IntPoint rootViewToContents(const IntPoint&) const; 288 288 WEBCORE_EXPORT IntPoint contentsToRootView(const IntPoint&) const; 289 IntRect rootViewToContents(const IntRect&) const;289 WEBCORE_EXPORT IntRect rootViewToContents(const IntRect&) const; 290 290 WEBCORE_EXPORT IntRect contentsToRootView(const IntRect&) const; 291 291 -
trunk/Source/WebKit2/ChangeLog
r198738 r198739 1 2016-03-24 Timothy Hatcher <timothy@apple.com> 2 3 Web Automation: Add commands to compute layout of an element 4 5 https://bugs.webkit.org/show_bug.cgi?id=155841 6 rdar://problem/25340075 7 8 Reviewed by Brian Burg. 9 10 * UIProcess/Automation/Automation.json: Added computeElementLayout. 11 12 * UIProcess/Automation/WebAutomationSession.cpp: 13 (WebKit::WebAutomationSession::computeElementLayout): Added. 14 (WebKit::WebAutomationSession::didComputeElementLayout): Added. 15 * UIProcess/Automation/WebAutomationSession.h: 16 * UIProcess/Automation/WebAutomationSession.messages.in: 17 (DidComputeElementLayout): Added. 18 19 * WebProcess/Automation/WebAutomationSessionProxy.cpp: 20 (WebKit::WebAutomationSessionProxy::computeElementLayout): Added. 21 * WebProcess/Automation/WebAutomationSessionProxy.h: 22 * WebProcess/Automation/WebAutomationSessionProxy.messages.in: 23 (ComputeElementLayout): Added. 24 1 25 2016-03-18 Timothy Hatcher <timothy@apple.com> 2 26 -
trunk/Source/WebKit2/UIProcess/Automation/Automation.json
r198738 r198739 3 3 "description": "Automation domain exposes commands for automating user interactions with the browser.", 4 4 "types": [ 5 { 6 "id": "Point", 7 "type": "object", 8 "properties": [ 9 { "name": "x", "type": "number" }, 10 { "name": "y", "type": "number" } 11 ] 12 }, 13 { 14 "id": "Size", 15 "type": "object", 16 "properties": [ 17 { "name": "width", "type": "number" }, 18 { "name": "height", "type": "number" } 19 ] 20 }, 21 { 22 "id": "Rect", 23 "type": "object", 24 "properties": [ 25 { "name": "origin", "$ref": "Point" }, 26 { "name": "size", "$ref": "Size" } 27 ] 28 }, 5 29 { 6 30 "id": "BrowsingContextHandle", … … 153 177 ], 154 178 "async": true 179 }, 180 { 181 "name": "computeElementLayout", 182 "description": "Computes the layout for an element.", 183 "parameters": [ 184 { "name": "browsingContextHandle", "$ref": "BrowsingContextHandle", "description": "The handle for the browsing context the frame is located." }, 185 { "name": "frameHandle", "$ref": "FrameHandle", "description": "The handle for the frame that contains the element." }, 186 { "name": "nodeHandle", "$ref": "NodeHandle", "description": "The handle of the element to use." }, 187 { "name": "scrollIntoViewIfNeeded", "optional": true, "type": "boolean", "description": "If the element should be scrolled into view before computing its layout." }, 188 { "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." } 189 ], 190 "returns": [ 191 { "name": "rect", "$ref": "Rect", "description": "The layout rect for the requested element. Specified in page or viewport coordinates based on the useViewportCoordinates parameter." } 192 ], 193 "async": true 155 194 } 156 195 ] -
trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp
r198738 r198739 418 418 } 419 419 420 void WebAutomationSession::computeElementLayout(Inspector::ErrorString& errorString, const String& browsingContextHandle, const String& frameHandle, const String& nodeHandle, const bool* optionalScrollIntoViewIfNeeded, const bool* optionalUseViewportCoordinates, Ref<ComputeElementLayoutCallback>&& callback) 421 { 422 WebPageProxy* page = webPageProxyForHandle(browsingContextHandle); 423 if (!page) 424 FAIL_WITH_PREDEFINED_ERROR_MESSAGE(WindowNotFound); 425 426 WebFrameProxy* frame = webFrameProxyForHandle(frameHandle, *page); 427 if (!frame) 428 FAIL_WITH_PREDEFINED_ERROR_MESSAGE(FrameNotFound); 429 430 uint64_t callbackID = m_nextComputeElementLayoutCallbackID++; 431 m_computeElementLayoutCallbacks.set(callbackID, WTFMove(callback)); 432 433 bool scrollIntoViewIfNeeded = optionalScrollIntoViewIfNeeded ? *optionalScrollIntoViewIfNeeded : false; 434 bool useViewportCoordinates = optionalUseViewportCoordinates ? *optionalUseViewportCoordinates : false; 435 436 page->process().send(Messages::WebAutomationSessionProxy::ComputeElementLayout(frame->frameID(), nodeHandle, scrollIntoViewIfNeeded, useViewportCoordinates, callbackID), 0); 437 } 438 439 void WebAutomationSession::didComputeElementLayout(uint64_t callbackID, WebCore::IntRect rect, const String& errorType) 440 { 441 auto callback = m_computeElementLayoutCallbacks.take(callbackID); 442 if (!callback) 443 return; 444 445 if (!errorType.isEmpty()) { 446 callback->sendFailure(errorType); 447 return; 448 } 449 450 auto originObject = Inspector::Protocol::Automation::Point::create() 451 .setX(rect.x()) 452 .setY(rect.y()) 453 .release(); 454 455 auto sizeObject = Inspector::Protocol::Automation::Size::create() 456 .setWidth(rect.width()) 457 .setHeight(rect.height()) 458 .release(); 459 460 auto rectObject = Inspector::Protocol::Automation::Rect::create() 461 .setOrigin(WTFMove(originObject)) 462 .setSize(WTFMove(sizeObject)) 463 .release(); 464 465 callback->sendSuccess(WTFMove(rectObject)); 466 } 467 420 468 } // namespace WebKit -
trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.h
r198738 r198739 43 43 class BackendDispatcher; 44 44 class FrontendRouter; 45 } 46 47 namespace WebCore { 48 class IntRect; 45 49 } 46 50 … … 91 95 void resolveChildFrameHandle(Inspector::ErrorString&, const String& browsingContextHandle, const String* optionalFrameHandle, const int* optionalOrdinal, const String* optionalName, const String* optionalNodeHandle, Ref<ResolveChildFrameHandleCallback>&&) override; 92 96 void resolveParentFrameHandle(Inspector::ErrorString&, const String& browsingContextHandle, const String& frameHandle, Ref<ResolveParentFrameHandleCallback>&&) override; 97 void computeElementLayout(Inspector::ErrorString&, const String& browsingContextHandle, const String& frameHandle, const String& nodeHandle, const bool* optionalScrollIntoViewIfNeeded, const bool* useViewportCoordinates, Ref<Inspector::AutomationBackendDispatcherHandler::ComputeElementLayoutCallback>&&) override; 93 98 94 99 private: … … 107 112 void didResolveChildFrame(uint64_t callbackID, uint64_t frameID, const String& errorType); 108 113 void didResolveParentFrame(uint64_t callbackID, uint64_t frameID, const String& errorType); 114 void didComputeElementLayout(uint64_t callbackID, WebCore::IntRect, const String& errorType); 109 115 110 116 WebProcessPool* m_processPool { nullptr }; … … 132 138 HashMap<uint64_t, RefPtr<Inspector::AutomationBackendDispatcherHandler::ResolveParentFrameHandleCallback>> m_resolveParentFrameHandleCallbacks; 133 139 140 uint64_t m_nextComputeElementLayoutCallbackID { 1 }; 141 HashMap<uint64_t, RefPtr<Inspector::AutomationBackendDispatcherHandler::ComputeElementLayoutCallback>> m_computeElementLayoutCallbacks; 142 134 143 #if ENABLE(REMOTE_INSPECTOR) 135 144 Inspector::FrontendChannel* m_remoteChannel { nullptr }; -
trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.messages.in
r198738 r198739 26 26 DidResolveChildFrame(uint64_t callbackID, uint64_t frameID, String errorType) 27 27 DidResolveParentFrame(uint64_t callbackID, uint64_t frameID, String errorType) 28 29 DidComputeElementLayout(uint64_t callbackID, WebCore::IntRect rect, String errorType) 28 30 } -
trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.cpp
r198738 r198739 42 42 #include <WebCore/Frame.h> 43 43 #include <WebCore/FrameTree.h> 44 #include <WebCore/FrameView.h> 44 45 #include <WebCore/HTMLFrameElementBase.h> 45 46 #include <WebCore/JSElement.h> … … 408 409 } 409 410 411 void WebAutomationSessionProxy::computeElementLayout(uint64_t frameID, String nodeHandle, bool scrollIntoViewIfNeeded, bool useViewportCoordinates, uint64_t callbackID) 412 { 413 String frameNotFoundErrorType = Inspector::Protocol::getEnumConstantValue(Inspector::Protocol::Automation::ErrorMessage::FrameNotFound); 414 String nodeNotFoundErrorType = Inspector::Protocol::getEnumConstantValue(Inspector::Protocol::Automation::ErrorMessage::NodeNotFound); 415 416 WebFrame* frame = WebProcess::singleton().webFrame(frameID); 417 if (!frame) { 418 WebProcess::singleton().parentProcessConnection()->send(Messages::WebAutomationSession::DidComputeElementLayout(callbackID, WebCore::IntRect(), frameNotFoundErrorType), 0); 419 return; 420 } 421 422 WebCore::Element* coreElement = elementForNodeHandle(*frame, nodeHandle); 423 if (!coreElement) { 424 WebProcess::singleton().parentProcessConnection()->send(Messages::WebAutomationSession::DidComputeElementLayout(callbackID, WebCore::IntRect(), nodeNotFoundErrorType), 0); 425 return; 426 } 427 428 if (scrollIntoViewIfNeeded) 429 coreElement->scrollIntoViewIfNeeded(false); 430 431 WebCore::IntRect rect = coreElement->clientRect(); 432 433 if (!useViewportCoordinates) { 434 WebCore::Frame* coreFrame = frame->coreFrame(); 435 if (!coreFrame) { 436 WebProcess::singleton().parentProcessConnection()->send(Messages::WebAutomationSession::DidComputeElementLayout(callbackID, WebCore::IntRect(), frameNotFoundErrorType), 0); 437 return; 438 } 439 440 WebCore::FrameView *coreFrameView = coreFrame->view(); 441 if (!coreFrameView) { 442 WebProcess::singleton().parentProcessConnection()->send(Messages::WebAutomationSession::DidComputeElementLayout(callbackID, WebCore::IntRect(), frameNotFoundErrorType), 0); 443 return; 444 } 445 446 rect = coreFrameView->rootViewToContents(rect); 447 } 448 449 WebProcess::singleton().parentProcessConnection()->send(Messages::WebAutomationSession::DidComputeElementLayout(callbackID, rect, emptyString()), 0); 450 } 451 410 452 } // namespace WebKit -
trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.h
r198738 r198739 64 64 void resolveParentFrame(uint64_t frameID, uint64_t callbackID); 65 65 void focusFrame(uint64_t frameID); 66 void computeElementLayout(uint64_t frameID, String nodeHandle, bool scrollIntoViewIfNeeded, bool useViewportCoordinates, uint64_t callbackID); 66 67 67 68 String m_sessionIdentifier; -
trunk/Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.messages.in
r198738 r198739 30 30 31 31 FocusFrame(uint64_t frameID) 32 33 ComputeElementLayout(uint64_t frameID, String nodeHandle, bool scrollIntoViewIfNeeded, bool useViewportCoordinates, uint64_t callbackID) 32 34 }
Note:
See TracChangeset
for help on using the changeset viewer.