mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-22 17:24:48 -05:00
LibWeb: Allocate transparent surface based on surface null check
...in HTMLCanvasElement::to_data_url() and HTMLCanvasElement::to_blob(). This fixes the problem when surface is not allocated because context is not initialized yet, even though canvas size is non-zero. Fixes broken WebDriver screenshot endpoint.
This commit is contained in:
parent
f57c6a4328
commit
a6810fec24
Notes:
github-actions[bot]
2024-12-04 15:16:13 +00:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/LadybirdBrowser/ladybird/commit/a6810fec24a Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2757 Reviewed-by: https://github.com/tcl3 ✅
1 changed files with 2 additions and 2 deletions
|
@ -282,7 +282,7 @@ String HTMLCanvasElement::to_data_url(StringView type, JS::Value quality)
|
|||
allocate_painting_surface_if_needed();
|
||||
auto surface = this->surface();
|
||||
auto size = bitmap_size_for_canvas();
|
||||
if (!size.is_empty()) {
|
||||
if (!surface) {
|
||||
// If the context is not initialized yet, we need to allocate transparent surface for serialization
|
||||
auto skia_backend_context = navigable()->traversable_navigable()->skia_backend_context();
|
||||
surface = Gfx::PaintingSurface::create_with_size(skia_backend_context, size, Gfx::BitmapFormat::BGRA8888, Gfx::AlphaType::Premultiplied);
|
||||
|
@ -322,7 +322,7 @@ WebIDL::ExceptionOr<void> HTMLCanvasElement::to_blob(GC::Ref<WebIDL::CallbackTyp
|
|||
allocate_painting_surface_if_needed();
|
||||
auto surface = this->surface();
|
||||
auto size = bitmap_size_for_canvas();
|
||||
if (!size.is_empty()) {
|
||||
if (!surface) {
|
||||
// If the context is not initialized yet, we need to allocate transparent surface for serialization
|
||||
auto skia_backend_context = navigable()->traversable_navigable()->skia_backend_context();
|
||||
surface = Gfx::PaintingSurface::create_with_size(skia_backend_context, size, Gfx::BitmapFormat::BGRA8888, Gfx::AlphaType::Premultiplied);
|
||||
|
|
Loading…
Reference in a new issue