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

Side by Side Diff: third_party/WebKit/Source/modules/shapedetection/ShapeDetector.cpp

Issue 2469873002: [ImageResource 4] Split ImageResource into Resource and Image parts (Closed)
Patch Set: style Created 4 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "modules/shapedetection/ShapeDetector.h" 5 #include "modules/shapedetection/ShapeDetector.h"
6 6
7 #include "core/dom/DOMException.h" 7 #include "core/dom/DOMException.h"
8 #include "core/dom/DOMRect.h" 8 #include "core/dom/DOMRect.h"
9 #include "core/dom/Document.h" 9 #include "core/dom/Document.h"
10 #include "core/fetch/ImageResource.h" 10 #include "core/fetch/ImageResourceContent.h"
11 #include "core/frame/ImageBitmap.h" 11 #include "core/frame/ImageBitmap.h"
12 #include "core/frame/LocalFrame.h" 12 #include "core/frame/LocalFrame.h"
13 #include "core/html/HTMLImageElement.h" 13 #include "core/html/HTMLImageElement.h"
14 #include "core/html/HTMLVideoElement.h" 14 #include "core/html/HTMLVideoElement.h"
15 #include "core/html/canvas/CanvasImageSource.h" 15 #include "core/html/canvas/CanvasImageSource.h"
16 #include "platform/graphics/Image.h" 16 #include "platform/graphics/Image.h"
17 #include "third_party/skia/include/core/SkImage.h" 17 #include "third_party/skia/include/core/SkImage.h"
18 #include "third_party/skia/include/core/SkImageInfo.h" 18 #include "third_party/skia/include/core/SkImageInfo.h"
19 #include "wtf/CheckedNumeric.h" 19 #include "wtf/CheckedNumeric.h"
20 20
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 ScriptPromise ShapeDetector::detectShapesOnImageElement( 144 ScriptPromise ShapeDetector::detectShapesOnImageElement(
145 ScriptPromiseResolver* resolver, 145 ScriptPromiseResolver* resolver,
146 const HTMLImageElement* img) { 146 const HTMLImageElement* img) {
147 ScriptPromise promise = resolver->promise(); 147 ScriptPromise promise = resolver->promise();
148 148
149 if (img->bitmapSourceSize().isZero()) { 149 if (img->bitmapSourceSize().isZero()) {
150 resolver->resolve(HeapVector<Member<DOMRect>>()); 150 resolver->resolve(HeapVector<Member<DOMRect>>());
151 return promise; 151 return promise;
152 } 152 }
153 153
154 ImageResource* const imageResource = img->cachedImage(); 154 ImageResourceContent* const imageResource = img->cachedImage();
155 if (!imageResource || imageResource->errorOccurred()) { 155 if (!imageResource || imageResource->errorOccurred()) {
156 resolver->reject(DOMException::create( 156 resolver->reject(DOMException::create(
157 InvalidStateError, "Failed to load or decode HTMLImageElement.")); 157 InvalidStateError, "Failed to load or decode HTMLImageElement."));
158 return promise; 158 return promise;
159 } 159 }
160 160
161 Image* const blinkImage = imageResource->getImage(); 161 Image* const blinkImage = imageResource->getImage();
162 if (!blinkImage) { 162 if (!blinkImage) {
163 resolver->reject(DOMException::create( 163 resolver->reject(DOMException::create(
164 InvalidStateError, "Failed to get image from resource.")); 164 InvalidStateError, "Failed to get image from resource."));
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 InvalidStateError, 204 InvalidStateError,
205 "Failed to read pixels: Unable to decompress or unsupported format.")); 205 "Failed to read pixels: Unable to decompress or unsupported format."));
206 return promise; 206 return promise;
207 } 207 }
208 208
209 return doDetect(resolver, std::move(sharedBufferHandle), img->naturalWidth(), 209 return doDetect(resolver, std::move(sharedBufferHandle), img->naturalWidth(),
210 img->naturalHeight()); 210 img->naturalHeight());
211 } 211 }
212 212
213 } // namespace blink 213 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698