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

Unified Diff: third_party/WebKit/Source/modules/shapedetection/ShapeDetector.cpp

Issue 2626743002: Shape Detection: resolve with empty results if any input element's dimension is zero (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/shapedetection/shapedetection-security-test.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/shapedetection/ShapeDetector.cpp
diff --git a/third_party/WebKit/Source/modules/shapedetection/ShapeDetector.cpp b/third_party/WebKit/Source/modules/shapedetection/ShapeDetector.cpp
index 241ac7cd5075f7965115e0e04510165fc75d4512..610e4d35c8f1a896a37f1c30a7ff80c781554e0e 100644
--- a/third_party/WebKit/Source/modules/shapedetection/ShapeDetector.cpp
+++ b/third_party/WebKit/Source/modules/shapedetection/ShapeDetector.cpp
@@ -107,6 +107,10 @@ ScriptPromise ShapeDetector::detect(ScriptState* scriptState,
DOMException::create(InvalidStateError, "Invalid element or state."));
return promise;
}
+ if (size.isEmpty()) {
+ resolver->resolve(HeapVector<Member<DOMRect>>());
+ return promise;
+ }
SkPixmap pixmap;
RefPtr<Uint8Array> pixelData;
@@ -150,6 +154,11 @@ ScriptPromise ShapeDetector::detectShapesOnImageData(
ImageData* imageData) {
ScriptPromise promise = resolver->promise();
+ if (imageData->size().isZero()) {
+ resolver->resolve(HeapVector<Member<DOMRect>>());
+ return promise;
+ }
+
uint8_t* const data = imageData->data()->data();
WTF::CheckedNumeric<int> allocationSize = imageData->size().area() * 4;
@@ -167,7 +176,6 @@ ScriptPromise ShapeDetector::detectShapesOnImageElement(
const HTMLImageElement* img) {
ScriptPromise promise = resolver->promise();
- // TODO(mcasas): reconsider this resolve(), https://crbug.com/674306.
if (img->bitmapSourceSize().isZero()) {
resolver->resolve(HeapVector<Member<DOMRect>>());
return promise;
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/shapedetection/shapedetection-security-test.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698