BaseRenderingContext2D: Use base::CheckMul and simplify code in putImageData()

Follow-up to commit e0b3253a56 ("Fix image conversion truncation issues").
The current code does not build with GCC due to
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89287:

    ../../third_party/blink/renderer/modules/canvas/canvas2d/base_rendering_context_2d.cc: In member function ‘void blink::BaseRenderingContext2D::putImageData(blink::ImageData*, int, int, int, int, int, int, blink::ExceptionState&)’:
    ../../third_party/blink/renderer/modules/canvas/canvas2d/base_rendering_context_2d.cc:1777:44: error: default type conversion can't deduce template argument for ‘template<class Dst, typename std::enable_if<base::internal::IsNumericRangeContained<Dst, long unsigned int, void>::value, void>::type* <anonymous> > constexpr base::internal::StrictNumeric<T>::operator Dst() const [with Dst = Dst; typename std::enable_if<base::internal::IsNumericRangeContained<Dst, T>::value>::type* <anonymous> = <enumerator>; T = long unsigned int]’
             new uint8_t[data_length.ValueOrDie()]);
                                                ^

Work around it by using the more idiomatic base::CheckMul() with
AssignIfValid, so that we can have |data_length| be a size_t again and not
leave it to the compiler to figure out the type we want when creating the
|converted_pixels| array.

Bug: 819294
Change-Id: Id124cc4f3d749b45def4708e21e4badafd708578
Reviewed-on: https://chromium-review.googlesource.com/c/1467201
Auto-Submit: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
Commit-Queue: Kentaro Hara <haraken@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#631472}
1 file changed