Confirmed users
770
edits
Line 488: | Line 488: | ||
} | } | ||
} | } | ||
} | |||
</source> | |||
==HTMLImageElement == | |||
<source lang="cpp"> | |||
nsLayoutUtils::SurfaceFromElementResult | |||
nsLayoutUtils::SurfaceFromElement(nsIImageLoadingContent* aElement, | |||
uint32_t aSurfaceFlags, | |||
DrawTarget* aTarget) | |||
{ | |||
SurfaceFromElementResult result; | |||
nsresult rv; | |||
nsCOMPtr<imgIRequest> imgRequest; | |||
rv = aElement->GetRequest(nsIImageLoadingContent::CURRENT_REQUEST, | |||
getter_AddRefs(imgRequest)); | |||
if (NS_FAILED(rv) || !imgRequest) | |||
return result; | |||
uint32_t status; | |||
imgRequest->GetImageStatus(&status); | |||
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 | |||
// here. Do this for now pending spec clarification. | |||
result.mIsStillLoading = (status & imgIRequest::STATUS_ERROR) == 0; | |||
return result; | |||
} | |||
... | |||
if (!noRasterize || imgContainer->GetType() == imgIContainer::TYPE_RASTER) { | |||
if (aSurfaceFlags & SFE_WANT_IMAGE_SURFACE) { | |||
frameFlags |= imgIContainer::FLAG_WANT_DATA_SURFACE; | |||
} | |||
result.mSourceSurface = imgContainer->GetFrame(whichFrame, frameFlags); | |||
if (!result.mSourceSurface) { | |||
return result; | |||
} | |||
... | |||
} else { | |||
result.mDrawInfo.mImgContainer = imgContainer; | |||
result.mDrawInfo.mWhichFrame = whichFrame; | |||
result.mDrawInfo.mDrawingFlags = frameFlags; | |||
} | |||
... | |||
return result; | |||
} | } | ||
</source> | </source> |