mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-19 15:32:31 +00:00
LibWeb: Add CanvasRenderingContext2D context attribute parsing
Makes `context.getContextAttributes()` work.
This commit is contained in:
parent
4d70f6ce1c
commit
fac0f82031
Notes:
github-actions[bot]
2025-04-29 11:52:34 +00:00
Author: https://github.com/gmta
Commit: fac0f82031
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4506
Reviewed-by: https://github.com/shannonbooth
6 changed files with 81 additions and 17 deletions
|
@ -208,12 +208,12 @@ void HTMLCanvasElement::adjust_computed_style(CSS::ComputedProperties& style)
|
|||
style.set_property(CSS::PropertyID::Display, CSS::DisplayStyleValue::create(CSS::Display::from_short(CSS::Display::Short::None)));
|
||||
}
|
||||
|
||||
HTMLCanvasElement::HasOrCreatedContext HTMLCanvasElement::create_2d_context()
|
||||
JS::ThrowCompletionOr<HTMLCanvasElement::HasOrCreatedContext> HTMLCanvasElement::create_2d_context(JS::Value options)
|
||||
{
|
||||
if (!m_context.has<Empty>())
|
||||
return m_context.has<GC::Ref<CanvasRenderingContext2D>>() ? HasOrCreatedContext::Yes : HasOrCreatedContext::No;
|
||||
|
||||
m_context = CanvasRenderingContext2D::create(realm(), *this);
|
||||
m_context = TRY(CanvasRenderingContext2D::create(realm(), *this, options));
|
||||
return HasOrCreatedContext::Yes;
|
||||
}
|
||||
|
||||
|
@ -244,7 +244,7 @@ JS::ThrowCompletionOr<HTMLCanvasElement::RenderingContext> HTMLCanvasElement::ge
|
|||
// 3. Run the steps in the cell of the following table whose column header matches this canvas element's canvas context mode and whose row header matches contextId:
|
||||
// NOTE: See the spec for the full table.
|
||||
if (type == "2d"sv) {
|
||||
if (create_2d_context() == HasOrCreatedContext::Yes)
|
||||
if (TRY(create_2d_context(options)) == HasOrCreatedContext::Yes)
|
||||
return GC::make_root(*m_context.get<GC::Ref<HTML::CanvasRenderingContext2D>>());
|
||||
|
||||
return Empty {};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue