summaryrefslogtreecommitdiffstats
path: root/dom/canvas/WebGLTextureUpload.cpp
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@wolfbeast.com>2019-02-14 11:46:21 +0100
committerwolfbeast <mcwerewolf@wolfbeast.com>2019-02-14 11:46:21 +0100
commit91799767e1c575dce6cdb1528f1f10a1fd62e35f (patch)
tree48d925ea0d3123ef18d8a810724b3cdf7ad3b734 /dom/canvas/WebGLTextureUpload.cpp
parent0e80d10f4a10496a6657df210ff45a89fba68a75 (diff)
downloadUXP-91799767e1c575dce6cdb1528f1f10a1fd62e35f.tar
UXP-91799767e1c575dce6cdb1528f1f10a1fd62e35f.tar.gz
UXP-91799767e1c575dce6cdb1528f1f10a1fd62e35f.tar.lz
UXP-91799767e1c575dce6cdb1528f1f10a1fd62e35f.tar.xz
UXP-91799767e1c575dce6cdb1528f1f10a1fd62e35f.zip
Implement origin-clean algorithm for ImageBitmap.
This resolves #973.
Diffstat (limited to 'dom/canvas/WebGLTextureUpload.cpp')
-rw-r--r--dom/canvas/WebGLTextureUpload.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/dom/canvas/WebGLTextureUpload.cpp b/dom/canvas/WebGLTextureUpload.cpp
index 612d5889d..3839b5d5e 100644
--- a/dom/canvas/WebGLTextureUpload.cpp
+++ b/dom/canvas/WebGLTextureUpload.cpp
@@ -12,6 +12,7 @@
#include "GLBlitHelper.h"
#include "GLContext.h"
#include "mozilla/gfx/2D.h"
+#include "mozilla/dom/HTMLCanvasElement.h"
#include "mozilla/dom/HTMLVideoElement.h"
#include "mozilla/dom/ImageBitmap.h"
#include "mozilla/dom/ImageData.h"
@@ -214,9 +215,18 @@ FromPboOffset(WebGLContext* webgl, const char* funcName, TexImageTarget target,
static UniquePtr<webgl::TexUnpackBlob>
FromImageBitmap(WebGLContext* webgl, const char* funcName, TexImageTarget target,
uint32_t width, uint32_t height, uint32_t depth,
- const dom::ImageBitmap& imageBitmap)
+ const dom::ImageBitmap& imageBitmap, ErrorResult* aRv)
{
+ if (imageBitmap.IsWriteOnly()) {
+ aRv->Throw(NS_ERROR_DOM_SECURITY_ERR);
+ return nullptr;
+ }
+
UniquePtr<dom::ImageBitmapCloneData> cloneData = Move(imageBitmap.ToCloneData());
+ if (!cloneData) {
+ return nullptr;
+ }
+
const RefPtr<gfx::DataSourceSurface> surf = cloneData->mSurface;
////
@@ -293,6 +303,14 @@ WebGLContext::FromDomElem(const char* funcName, TexImageTarget target, uint32_t
uint32_t height, uint32_t depth, const dom::Element& elem,
ErrorResult* const out_error)
{
+ if (elem.IsHTMLElement(nsGkAtoms::canvas)) {
+ const dom::HTMLCanvasElement* canvas = static_cast<const dom::HTMLCanvasElement*>(&elem);
+ if (canvas->IsWriteOnly()) {
+ out_error->Throw(NS_ERROR_DOM_SECURITY_ERR);
+ return nullptr;
+ }
+ }
+
uint32_t flags = nsLayoutUtils::SFE_WANT_IMAGE_SURFACE |
nsLayoutUtils::SFE_USE_ELEMENT_SIZE_IF_VECTOR;
@@ -412,7 +430,7 @@ WebGLContext::From(const char* funcName, TexImageTarget target, GLsizei rawWidth
if (src.mImageBitmap) {
return FromImageBitmap(this, funcName, target, width, height, depth,
- *(src.mImageBitmap));
+ *(src.mImageBitmap), src.mOut_error);
}
if (src.mImageData) {