Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Unified Diff: third_party/WebKit/Source/core/html/ImageData.cpp

Issue 1822353002: Revert of wtf/CheckedArithmetic.h delegates to base/numerics/safe_math.h. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/html/ImageData.cpp
diff --git a/third_party/WebKit/Source/core/html/ImageData.cpp b/third_party/WebKit/Source/core/html/ImageData.cpp
index 7f7d207fce0c03b79d451e71fb477be64faf5ffe..5909815ff778fe4b73edb20e0e8d706676850b60 100644
--- a/third_party/WebKit/Source/core/html/ImageData.cpp
+++ b/third_party/WebKit/Source/core/html/ImageData.cpp
@@ -34,19 +34,19 @@
#include "core/frame/ImageBitmap.h"
#include "core/imagebitmap/ImageBitmapOptions.h"
#include "platform/RuntimeEnabledFeatures.h"
-#include "wtf/CheckedNumeric.h"
namespace blink {
ImageData* ImageData::create(const IntSize& size)
{
- CheckedNumeric<int> dataSize = 4;
+ Checked<int, RecordOverflow> dataSize = 4;
dataSize *= size.width();
dataSize *= size.height();
- if (!dataSize.IsValid() || dataSize.ValueOrDie() < 0)
+ if (dataSize.hasOverflowed() || dataSize.unsafeGet() < 0)
return nullptr;
- RefPtr<DOMUint8ClampedArray> byteArray = DOMUint8ClampedArray::createOrNull(dataSize.ValueOrDie());
+ RefPtr<DOMUint8ClampedArray> byteArray =
+ DOMUint8ClampedArray::createOrNull(dataSize.unsafeGet());
if (!byteArray)
return nullptr;
@@ -55,14 +55,14 @@
ImageData* ImageData::create(const IntSize& size, PassRefPtr<DOMUint8ClampedArray> byteArray)
{
- CheckedNumeric<int> dataSize = 4;
+ Checked<int, RecordOverflow> dataSize = 4;
dataSize *= size.width();
dataSize *= size.height();
- if (!dataSize.IsValid())
+ if (dataSize.hasOverflowed())
return nullptr;
- if (dataSize.ValueOrDie() < 0
- || static_cast<unsigned>(dataSize.ValueOrDie()) > byteArray->length())
+ if (dataSize.unsafeGet() < 0
+ || static_cast<unsigned>(dataSize.unsafeGet()) > byteArray->length())
return nullptr;
return new ImageData(size, byteArray);
@@ -75,17 +75,18 @@
return nullptr;
}
- CheckedNumeric<unsigned> dataSize = 4;
+ Checked<unsigned, RecordOverflow> dataSize = 4;
dataSize *= width;
dataSize *= height;
- if (!dataSize.IsValid()
+ if (dataSize.hasOverflowed()
|| static_cast<int>(width) < 0
|| static_cast<int>(height) < 0) {
exceptionState.throwDOMException(IndexSizeError, "The requested image size exceeds the supported range.");
return nullptr;
}
- RefPtr<DOMUint8ClampedArray> byteArray = DOMUint8ClampedArray::createOrNull(dataSize.ValueOrDie());
+ RefPtr<DOMUint8ClampedArray> byteArray =
+ DOMUint8ClampedArray::createOrNull(dataSize.unsafeGet());
if (!byteArray) {
exceptionState.throwDOMException(V8GeneralError, "Out of memory at ImageData creation");
return nullptr;

Powered by Google App Engine
This is Rietveld 408576698