mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-24 23:23:58 +00:00
LibWeb: Let HTMLCanvasElement.getContext() return null for unknown types
Currently we would assert. Also make it case sensitive.
This commit is contained in:
parent
50c0944767
commit
abb33d425e
Notes:
sideshowbarker
2024-07-19 06:17:58 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/abb33d425e1 Pull-request: https://github.com/SerenityOS/serenity/pull/2314 Reviewed-by: https://github.com/awesomekling
2 changed files with 8 additions and 10 deletions
|
@ -74,15 +74,13 @@ JS::Value HTMLCanvasElementWrapper::get_context(JS::Interpreter& interpreter)
|
|||
auto* impl = impl_from(interpreter);
|
||||
if (!impl)
|
||||
return {};
|
||||
auto& arguments = interpreter.call_frame().arguments;
|
||||
if (arguments.size() >= 1) {
|
||||
auto string = arguments[0].to_string(interpreter);
|
||||
if (interpreter.exception())
|
||||
return {};
|
||||
auto* context = impl->get_context(string);
|
||||
return wrap(interpreter.heap(), *context);
|
||||
}
|
||||
return JS::js_undefined();
|
||||
auto context_type = interpreter.call_frame().arguments[0].to_string(interpreter);
|
||||
if (interpreter.exception())
|
||||
return {};
|
||||
if (context_type != "2d")
|
||||
return JS::js_null();
|
||||
auto* context = impl->get_context(context_type);
|
||||
return wrap(interpreter.heap(), *context);
|
||||
}
|
||||
|
||||
JS::Value HTMLCanvasElementWrapper::width_getter(JS::Interpreter& interpreter)
|
||||
|
|
|
@ -76,7 +76,7 @@ RefPtr<LayoutNode> HTMLCanvasElement::create_layout_node(const StyleProperties*
|
|||
|
||||
CanvasRenderingContext2D* HTMLCanvasElement::get_context(String type)
|
||||
{
|
||||
ASSERT(type.to_lowercase() == "2d");
|
||||
ASSERT(type == "2d");
|
||||
if (!m_context)
|
||||
m_context = CanvasRenderingContext2D::create(*this);
|
||||
return m_context;
|
||||
|
|
Loading…
Reference in a new issue