Title: [230421] releases/WebKitGTK/webkit-2.20/Source/WebKit
- Revision
- 230421
- Author
- carlo...@webkit.org
- Date
- 2018-04-09 06:32:58 -0700 (Mon, 09 Apr 2018)
Log Message
Merge r230088 - Web Automation: clipToViewport is ignored for element screenshots
https://bugs.webkit.org/show_bug.cgi?id=184158
<rdar://problem/39014307>
Reviewed by Timothy Hatcher.
In §19.2 Take Element Screenshot, step 5.2 says that we should clip
the element screenshot rect with the visible viewport rect. We don't
do that right now even though we pass over clipToViewport.
* WebProcess/Automation/WebAutomationSessionProxy.cpp:
(WebKit::snapshotRectForScreenshot):
Clip the rect to viewport if needed.
(WebKit::WebAutomationSessionProxy::takeScreenshot):
This scrollIntoView is misplaced; by this point we have already done
the math to figure out the screenshot rect. Move it before computing the rect.
Modified Paths
Diff
Modified: releases/WebKitGTK/webkit-2.20/Source/WebKit/ChangeLog (230420 => 230421)
--- releases/WebKitGTK/webkit-2.20/Source/WebKit/ChangeLog 2018-04-09 13:00:10 UTC (rev 230420)
+++ releases/WebKitGTK/webkit-2.20/Source/WebKit/ChangeLog 2018-04-09 13:32:58 UTC (rev 230421)
@@ -1,3 +1,23 @@
+2018-03-29 Brian Burg <bb...@apple.com>
+
+ Web Automation: clipToViewport is ignored for element screenshots
+ https://bugs.webkit.org/show_bug.cgi?id=184158
+ <rdar://problem/39014307>
+
+ Reviewed by Timothy Hatcher.
+
+ In §19.2 Take Element Screenshot, step 5.2 says that we should clip
+ the element screenshot rect with the visible viewport rect. We don't
+ do that right now even though we pass over clipToViewport.
+
+ * WebProcess/Automation/WebAutomationSessionProxy.cpp:
+ (WebKit::snapshotRectForScreenshot):
+ Clip the rect to viewport if needed.
+
+ (WebKit::WebAutomationSessionProxy::takeScreenshot):
+ This scrollIntoView is misplaced; by this point we have already done
+ the math to figure out the screenshot rect. Move it before computing the rect.
+
2018-03-29 Carlos Eduardo Ramalho <cadubent...@gmail.com>
[WPE] Floating point exception in WebEventFactory::createWebWheelEvent
Modified: releases/WebKitGTK/webkit-2.20/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp (230420 => 230421)
--- releases/WebKitGTK/webkit-2.20/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp 2018-04-09 13:00:10 UTC (rev 230420)
+++ releases/WebKitGTK/webkit-2.20/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp 2018-04-09 13:32:58 UTC (rev 230421)
@@ -663,12 +663,20 @@
static WebCore::IntRect snapshotRectForScreenshot(WebPage& page, WebCore::Element* element, bool clipToViewport)
{
+ auto* frameView = page.mainFrameView();
+ if (!frameView)
+ return { };
+
if (element) {
if (!element->renderer())
return { };
WebCore::LayoutRect topLevelRect;
- return WebCore::snappedIntRect(element->renderer()->paintingRootRect(topLevelRect));
+ WebCore::IntRect elementRect = WebCore::snappedIntRect(element->renderer()->paintingRootRect(topLevelRect));
+ if (clipToViewport)
+ elementRect.intersect(frameView->visibleContentRect());
+
+ return elementRect;
}
if (auto* frameView = page.mainFrameView())
@@ -705,6 +713,9 @@
}
}
+ if (coreElement && scrollIntoViewIfNeeded)
+ coreElement->scrollIntoViewIfNeeded(false);
+
String screenshotErrorType = Inspector::Protocol::AutomationHelpers::getEnumConstantValue(Inspector::Protocol::Automation::ErrorMessage::ScreenshotError);
WebCore::IntRect snapshotRect = snapshotRectForScreenshot(*page, coreElement, clipToViewport);
if (snapshotRect.isEmpty()) {
@@ -712,9 +723,6 @@
return;
}
- if (coreElement && scrollIntoViewIfNeeded)
- coreElement->scrollIntoViewIfNeeded(false);
-
RefPtr<WebImage> image = page->scaledSnapshotWithOptions(snapshotRect, 1, SnapshotOptionsShareable);
if (!image) {
WebProcess::singleton().parentProcessConnection()->send(Messages::WebAutomationSession::DidTakeScreenshot(callbackID, handle, screenshotErrorType), 0);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes