summaryrefslogtreecommitdiff
path: root/layout/base
diff options
context:
space:
mode:
authorjanekptacijarabaci <janekptacijarabaci@seznam.cz>2017-05-19 09:04:15 +0200
committerjanekptacijarabaci <janekptacijarabaci@seznam.cz>2017-05-19 09:04:15 +0200
commit114cf25ef704b0639739daa333cb29a2b99bd44b (patch)
tree5b274c1a421ed5a30e8080b976847e655bf1356c /layout/base
parent86a8d6d091c075c6cd8dc3aae140b02d627eb090 (diff)
downloadpalemoon-gre-114cf25ef704b0639739daa333cb29a2b99bd44b.tar.gz
Canvas - CanvasRenderingContext2D.drawImage can throw 0x80040111 (NS_ERROR_NOT_AVAILABLE)
Diffstat (limited to 'layout/base')
-rw-r--r--layout/base/nsLayoutUtils.cpp19
-rw-r--r--layout/base/nsLayoutUtils.h2
2 files changed, 20 insertions, 1 deletions
diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp
index c8ff2670f..d4e758e86 100644
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -6566,11 +6566,25 @@ nsLayoutUtils::SurfaceFromElement(nsIImageLoadingContent* aElement,
nsCOMPtr<imgIRequest> imgRequest;
rv = aElement->GetRequest(nsIImageLoadingContent::CURRENT_REQUEST,
getter_AddRefs(imgRequest));
- if (NS_FAILED(rv) || !imgRequest)
+ if (NS_FAILED(rv)) {
return result;
+ }
+
+ if (!imgRequest) {
+ // There's no image request. This is either because a request for
+ // a non-empty URI failed, or the URI is the empty string.
+ nsCOMPtr<nsIURI> currentURI;
+ aElement->GetCurrentURI(getter_AddRefs(currentURI));
+ if (!currentURI) {
+ // Treat the empty URI as available instead of broken state.
+ result.mHasSize = true;
+ }
+ return result;
+ }
uint32_t status;
imgRequest->GetImageStatus(&status);
+ result.mHasSize = status & imgIRequest::STATUS_SIZE_AVAILABLE;
if ((status & imgIRequest::STATUS_LOAD_COMPLETE) == 0) {
// Spec says to use GetComplete, but that only works on
// nsIDOMHTMLImageElement, and we support all sorts of other stuff
@@ -6691,6 +6705,7 @@ nsLayoutUtils::SurfaceFromElement(HTMLCanvasElement* aElement,
// in case this is being used by -moz-element()
aElement->MarkContextClean();
+ result.mHasSize = true;
result.mSize = size;
result.mPrincipal = aElement->NodePrincipal();
result.mIsWriteOnly = aElement->IsWriteOnly();
@@ -6737,6 +6752,7 @@ nsLayoutUtils::SurfaceFromElement(HTMLVideoElement* aElement,
}
result.mCORSUsed = aElement->GetCORSMode() != CORS_NONE;
+ result.mHasSize = true;
result.mSize = ThebesIntSize(size);
result.mPrincipal = principal.forget();
result.mIsWriteOnly = false;
@@ -7775,6 +7791,7 @@ nsLayoutUtils::SurfaceFromElementResult::SurfaceFromElementResult()
// Use safe default values here
: mIsWriteOnly(true)
, mIsStillLoading(false)
+ , mHasSize(false)
, mCORSUsed(false)
, mIsPremultiplied(true)
{
diff --git a/layout/base/nsLayoutUtils.h b/layout/base/nsLayoutUtils.h
index c3221e8f2..68d7abd1a 100644
--- a/layout/base/nsLayoutUtils.h
+++ b/layout/base/nsLayoutUtils.h
@@ -2027,6 +2027,8 @@ public:
/* Whether the element was still loading. Some consumers need to handle
this case specially. */
bool mIsStillLoading;
+ /* Whether the element has a valid size. */
+ bool mHasSize;
/* Whether the element used CORS when loading. */
bool mCORSUsed;
/* Whether the returned image contains premultiplied pixel data */