mirror of
https://github.com/RGBCube/serenity
synced 2025-07-10 09:47:35 +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
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