mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-16 22:42:18 +00:00
LibWeb: Set size of canvas used to take WebDriver screenshots explicitly
The default canvas size is 300x150 pixels. If the element or document we are trying to screenshot for the WebDriver is not at least that size, then we will create a canvas that is wider or taller than the actual element we are painting, resulting in a bunch of transparent pixels falling off the end. This fixes 14 WPT css/CSS2/floats tests that we run in CI, and presumably a ton of other reftests in the WPT test suite.
This commit is contained in:
parent
aee5120078
commit
cb68c6eaf1
Notes:
sideshowbarker
2024-07-17 03:03:44 +09:00
Author: https://github.com/ADKaster
Commit: cb68c6eaf1
Pull-request: https://github.com/SerenityOS/serenity/pull/23284
Reviewed-by: https://github.com/kalenikaliaksandr
Reviewed-by: https://github.com/trflynn89 ✅
1 changed files with 4 additions and 0 deletions
|
@ -61,6 +61,10 @@ Response capture_element_screenshot(Painter const& painter, Page& page, DOM::Ele
|
|||
auto canvas_element = DOM::create_element(element.document(), HTML::TagNames::canvas, Namespace::HTML).release_value_but_fixme_should_propagate_errors();
|
||||
auto& canvas = verify_cast<HTML::HTMLCanvasElement>(*canvas_element);
|
||||
|
||||
// FIXME: Handle DevicePixelRatio in HiDPI mode.
|
||||
MUST(canvas.set_width(rect.width()));
|
||||
MUST(canvas.set_height(rect.height()));
|
||||
|
||||
if (!canvas.create_bitmap(rect.width(), rect.height())) {
|
||||
encoded_string_or_error = Error::from_code(ErrorCode::UnableToCaptureScreen, "Unable to create a screenshot bitmap"sv);
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue