Changeset 225501 in webkit
- Timestamp:
- Dec 4, 2017 4:06:25 PM (6 years ago)
- Location:
- trunk/Source
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebDriver/ChangeLog
r225474 r225501 1 2017-12-04 Brian Burg <bburg@apple.com> 2 3 Web Automation: add flag to preserve legacy page screenshot behavior 4 https://bugs.webkit.org/show_bug.cgi?id=180313 5 <rdar://problem/34379930> 6 7 Reviewed by Joseph Pecoraro. 8 9 Set the clipToViewport flag to true when sending Automation.takeScreenshot. 10 This preserves the current behavior for this driver implementation. 11 12 * Session.cpp: 13 (WebDriver::Session::takeScreenshot): 14 1 15 2017-12-04 Carlos Garcia Campos <cgarcia@igalia.com> 2 16 -
trunk/Source/WebDriver/Session.cpp
r225474 r225501 2124 2124 if (elementID) 2125 2125 parameters->setString(ASCIILiteral("nodeHandle"), elementID.value()); 2126 else 2127 parameters->setBoolean(ASCIILiteral("clipToViewport"), true); 2126 2128 if (scrollIntoView.value_or(false)) 2127 2129 parameters->setBoolean(ASCIILiteral("scrollIntoViewIfNeeded"), true); -
trunk/Source/WebKit/ChangeLog
r225499 r225501 1 2017-12-04 Brian Burg <bburg@apple.com> 2 3 Web Automation: add flag to preserve legacy page screenshot behavior 4 https://bugs.webkit.org/show_bug.cgi?id=180313 5 <rdar://problem/34379930> 6 7 Reviewed by Joseph Pecoraro. 8 9 For compatibility with JSON Wire Protocol implemented by Safari, 10 we need to retain the ability to perform whole page contents 11 snapshots using Automation.takeScreenshot. Add an extra flag, 12 clipToViewport, which can be used by W3C-conforming drivers. 13 14 * UIProcess/Automation/Automation.json: Add new flag. 15 * UIProcess/Automation/WebAutomationSession.h: 16 * UIProcess/Automation/WebAutomationSession.cpp: 17 (WebKit::WebAutomationSession::takeScreenshot): 18 * WebProcess/Automation/WebAutomationSessionProxy.h: 19 * WebProcess/Automation/WebAutomationSessionProxy.messages.in: 20 * WebProcess/Automation/WebAutomationSessionProxy.cpp: 21 (WebKit::snapshotRectForScreenshot): 22 (WebKit::WebAutomationSessionProxy::takeScreenshot): 23 If the flag is false, take a screenshot of the whole page contents. 24 1 25 2017-12-04 JF Bastien <jfbastien@apple.com> 2 26 -
trunk/Source/WebKit/UIProcess/Automation/Automation.json
r225448 r225501 416 416 { "name": "frameHandle", "$ref": "FrameHandle", "optional": true, "description": "The handle for the frame that contains the element. The main frame is used if this parameter is empty string or excluded." }, 417 417 { "name": "nodeHandle", "$ref": "NodeHandle", "optional": true, "description": "The handle of the element to take a screenshot of. The browsing context document element is used if this parameter is excluded." }, 418 { "name": "scrollIntoViewIfNeeded", "type": "boolean", "optional": true, "description": "If the element should be scrolled into view before taking the screenshot." } 418 { "name": "scrollIntoViewIfNeeded", "type": "boolean", "optional": true, "description": "If the element should be scrolled into view before taking the screenshot." }, 419 { "name": "clipToViewport", "type": "boolean", "optional": true, "description": "Whether a screenshot of the entire page should be clipped to the visual viewport. A value of 'false' preserves behavior for legacy protocol screenshots." } 419 420 ], 420 421 "returns": [ -
trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp
r225448 r225501 1450 1450 } 1451 1451 1452 void WebAutomationSession::takeScreenshot(ErrorString& errorString, const String& handle, const String* optionalFrameHandle, const String* optionalNodeHandle, const bool* optionalScrollIntoViewIfNeeded, Ref<TakeScreenshotCallback>&& callback)1452 void WebAutomationSession::takeScreenshot(ErrorString& errorString, const String& handle, const String* optionalFrameHandle, const String* optionalNodeHandle, const bool* optionalScrollIntoViewIfNeeded, const bool* optionalClipToViewport, Ref<TakeScreenshotCallback>&& callback) 1453 1453 { 1454 1454 WebPageProxy* page = webPageProxyForHandle(handle); … … 1462 1462 bool scrollIntoViewIfNeeded = optionalScrollIntoViewIfNeeded ? *optionalScrollIntoViewIfNeeded : false; 1463 1463 String nodeHandle = optionalNodeHandle ? *optionalNodeHandle : emptyString(); 1464 bool clipToViewport = optionalClipToViewport ? *optionalClipToViewport : false; 1464 1465 1465 1466 uint64_t callbackID = m_nextScreenshotCallbackID++; 1466 1467 m_screenshotCallbacks.set(callbackID, WTFMove(callback)); 1467 1468 1468 page->process().send(Messages::WebAutomationSessionProxy::TakeScreenshot(page->pageID(), frameID.value(), nodeHandle, scrollIntoViewIfNeeded, c allbackID), 0);1469 page->process().send(Messages::WebAutomationSessionProxy::TakeScreenshot(page->pageID(), frameID.value(), nodeHandle, scrollIntoViewIfNeeded, clipToViewport, callbackID), 0); 1469 1470 } 1470 1471 -
trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.h
r225425 r225501 133 133 void performMouseInteraction(Inspector::ErrorString&, const String& handle, const JSON::Object& requestedPosition, const String& mouseButton, const String& mouseInteraction, const JSON::Array& keyModifiers, Ref<PerformMouseInteractionCallback>&&) final; 134 134 void performKeyboardInteractions(Inspector::ErrorString&, const String& handle, const JSON::Array& interactions, Ref<PerformKeyboardInteractionsCallback>&&) override; 135 void takeScreenshot(Inspector::ErrorString&, const String& handle, const String* optionalFrameHandle, const String* optionalNodeHandle, const bool* optionalScrollIntoViewIfNeeded, Ref<TakeScreenshotCallback>&&) override;135 void takeScreenshot(Inspector::ErrorString&, const String& handle, const String* optionalFrameHandle, const String* optionalNodeHandle, const bool* optionalScrollIntoViewIfNeeded, const bool* optionalClipToViewport, Ref<TakeScreenshotCallback>&&) override; 136 136 void resolveChildFrameHandle(Inspector::ErrorString&, const String& browsingContextHandle, const String* optionalFrameHandle, const int* optionalOrdinal, const String* optionalName, const String* optionalNodeHandle, Ref<ResolveChildFrameHandleCallback>&&) override; 137 137 void resolveParentFrameHandle(Inspector::ErrorString&, const String& browsingContextHandle, const String& frameHandle, Ref<ResolveParentFrameHandleCallback>&&) override; -
trunk/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp
r225367 r225501 663 663 } 664 664 665 static WebCore::IntRect snapshotRectForScreenshot(WebPage& page, WebCore::Element* element )665 static WebCore::IntRect snapshotRectForScreenshot(WebPage& page, WebCore::Element* element, bool clipToViewport) 666 666 { 667 667 if (element) { … … 674 674 675 675 if (auto* frameView = page.mainFrameView()) 676 return frameView->visibleContentRect();676 return clipToViewport ? frameView->visibleContentRect() : WebCore::IntRect(WebCore::IntPoint(0, 0), frameView->contentsSize()); 677 677 678 678 return { }; 679 679 } 680 680 681 void WebAutomationSessionProxy::takeScreenshot(uint64_t pageID, uint64_t frameID, String nodeHandle, bool scrollIntoViewIfNeeded, uint64_t callbackID)681 void WebAutomationSessionProxy::takeScreenshot(uint64_t pageID, uint64_t frameID, String nodeHandle, bool scrollIntoViewIfNeeded, bool clipToViewport, uint64_t callbackID) 682 682 { 683 683 ShareableBitmap::Handle handle; … … 708 708 709 709 String screenshotErrorType = Inspector::Protocol::AutomationHelpers::getEnumConstantValue(Inspector::Protocol::Automation::ErrorMessage::ScreenshotError); 710 WebCore::IntRect snapshotRect = snapshotRectForScreenshot(*page, coreElement );710 WebCore::IntRect snapshotRect = snapshotRectForScreenshot(*page, coreElement, clipToViewport); 711 711 if (snapshotRect.isEmpty()) { 712 712 WebProcess::singleton().parentProcessConnection()->send(Messages::WebAutomationSession::DidTakeScreenshot(callbackID, handle, screenshotErrorType), 0); -
trunk/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.h
r224789 r225501 67 67 void computeElementLayout(uint64_t pageID, uint64_t frameID, String nodeHandle, bool scrollIntoViewIfNeeded, CoordinateSystem, uint64_t callbackID); 68 68 void selectOptionElement(uint64_t pageID, uint64_t frameID, String nodeHandle, uint64_t callbackID); 69 void takeScreenshot(uint64_t pageID, uint64_t frameID, String nodeHandle, bool scrollIntoViewIfNeeded, uint64_t callbackID);69 void takeScreenshot(uint64_t pageID, uint64_t frameID, String nodeHandle, bool scrollIntoViewIfNeeded, bool clipToViewport, uint64_t callbackID); 70 70 void getCookiesForFrame(uint64_t pageID, uint64_t frameID, uint64_t callbackID); 71 71 void deleteCookie(uint64_t pageID, uint64_t frameID, String cookieName, uint64_t callbackID); -
trunk/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.messages.in
r224789 r225501 35 35 SelectOptionElement(uint64_t pageID, uint64_t frameID, String nodeHandle, uint64_t callbackID) 36 36 37 TakeScreenshot(uint64_t pageID, uint64_t frameID, String nodeHandle, bool scrollIntoViewIfNeeded, uint64_t callbackID)37 TakeScreenshot(uint64_t pageID, uint64_t frameID, String nodeHandle, bool scrollIntoViewIfNeeded, bool clipToViewport, uint64_t callbackID) 38 38 39 39 GetCookiesForFrame(uint64_t pageID, uint64_t frameID, uint64_t callbackID)
Note: See TracChangeset
for help on using the changeset viewer.