mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-24 23:23:58 +00:00
LibWeb: Ignore non-finite args in CanvasRenderingContext2D.{scale,translate}()
This commit is contained in:
parent
b962728c4e
commit
7defc521be
Notes:
sideshowbarker
2024-07-19 06:17:09 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/7defc521be2 Pull-request: https://github.com/SerenityOS/serenity/pull/2318
1 changed files with 8 additions and 6 deletions
|
@ -160,13 +160,14 @@ JS::Value CanvasRenderingContext2DWrapper::scale(JS::Interpreter& interpreter)
|
|||
if (!impl)
|
||||
return {};
|
||||
if (interpreter.argument_count() >= 2) {
|
||||
auto sx = interpreter.argument(0).to_double(interpreter);
|
||||
auto sx = interpreter.argument(0).to_number(interpreter);
|
||||
if (interpreter.exception())
|
||||
return {};
|
||||
auto sy = interpreter.argument(1).to_double(interpreter);
|
||||
auto sy = interpreter.argument(1).to_number(interpreter);
|
||||
if (interpreter.exception())
|
||||
return {};
|
||||
impl->scale(sx, sy);
|
||||
if (sx.is_finite_number() && sy.is_finite_number())
|
||||
impl->scale(sx.as_double(), sy.as_double());
|
||||
}
|
||||
return JS::js_undefined();
|
||||
}
|
||||
|
@ -177,13 +178,14 @@ JS::Value CanvasRenderingContext2DWrapper::translate(JS::Interpreter& interprete
|
|||
if (!impl)
|
||||
return {};
|
||||
if (interpreter.argument_count() >= 2) {
|
||||
auto tx = interpreter.argument(0).to_double(interpreter);
|
||||
auto tx = interpreter.argument(0).to_number(interpreter);
|
||||
if (interpreter.exception())
|
||||
return {};
|
||||
auto ty = interpreter.argument(1).to_double(interpreter);
|
||||
auto ty = interpreter.argument(1).to_number(interpreter);
|
||||
if (interpreter.exception())
|
||||
return {};
|
||||
impl->translate(tx, ty);
|
||||
if (tx.is_finite_number() && ty.is_finite_number())
|
||||
impl->translate(tx.as_double(), ty.as_double());
|
||||
}
|
||||
return JS::js_undefined();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue