summaryrefslogtreecommitdiffstats
path: root/dom/canvas
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-08 15:11:27 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-08 15:11:27 +0000
commitf3bcaf9f88aad2c423ebcd61121562f9834187d4 (patch)
treef22238c29b57707b645a350940e3e9bdf3ce1f5d /dom/canvas
parentAdding debian version 115.7.0esr-1~deb12u1. (diff)
downloadfirefox-esr-f3bcaf9f88aad2c423ebcd61121562f9834187d4.tar.xz
firefox-esr-f3bcaf9f88aad2c423ebcd61121562f9834187d4.zip
Merging upstream version 115.8.0esr.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/canvas')
-rw-r--r--dom/canvas/CanvasUtils.cpp12
-rw-r--r--dom/canvas/ClientWebGLContext.cpp12
-rw-r--r--dom/canvas/HostWebGLContext.h9
-rw-r--r--dom/canvas/WebGLMethodDispatcher.h1
-rw-r--r--dom/canvas/WebGLQueueParamTraits.h19
-rw-r--r--dom/canvas/WebGLTypes.h30
6 files changed, 35 insertions, 48 deletions
diff --git a/dom/canvas/CanvasUtils.cpp b/dom/canvas/CanvasUtils.cpp
index 69f185cc20..9f4d66c011 100644
--- a/dom/canvas/CanvasUtils.cpp
+++ b/dom/canvas/CanvasUtils.cpp
@@ -110,6 +110,11 @@ bool IsImageExtractionAllowed(dom::Document* aDocument, JSContext* aCx,
return true;
}
+ // Allow chrome: and resource: (this especially includes PDF.js)
+ if (subjectPrincipal.SchemeIs("chrome") || subjectPrincipal.SchemeIs("resource")) {
+ return true;
+ }
+
// Allow extension principals.
auto* principal = BasePrincipal::Cast(&subjectPrincipal);
if (principal->AddonPolicy() || principal->ContentScriptAddonPolicy()) {
@@ -126,13 +131,6 @@ bool IsImageExtractionAllowed(dom::Document* aDocument, JSContext* aCx,
return true;
}
- // Don't show canvas prompt for PDF.js
- JS::AutoFilename scriptFile;
- if (JS::DescribeScriptedCaller(aCx, &scriptFile) && scriptFile.get() &&
- strcmp(scriptFile.get(), "resource://pdf.js/build/pdf.js") == 0) {
- return true;
- }
-
// -------------------------------------------------------------------
// Possibly block third parties
diff --git a/dom/canvas/ClientWebGLContext.cpp b/dom/canvas/ClientWebGLContext.cpp
index c32c4813ca..a66307b9b7 100644
--- a/dom/canvas/ClientWebGLContext.cpp
+++ b/dom/canvas/ClientWebGLContext.cpp
@@ -3393,9 +3393,7 @@ void ClientWebGLContext::BufferData(GLenum target, WebGLsizeiptr rawSize,
EnqueueError(LOCAL_GL_OUT_OF_MEMORY, "`size` too large for platform.");
return;
}
-
- const auto data = RawBuffer<>{*size};
- Run<RPROC(BufferData)>(target, data, usage);
+ Run<RPROC(BufferData_SizeOnly)>(target, *size, usage);
}
void ClientWebGLContext::BufferData(
@@ -3429,9 +3427,11 @@ void ClientWebGLContext::RawBufferData(GLenum target, const uint8_t* srcBytes,
size_t srcLen, GLenum usage) {
const FuncScope funcScope(*this, "bufferData");
- const auto srcBuffer =
- srcBytes ? RawBuffer<>({srcBytes, srcLen}) : RawBuffer<>(srcLen);
- Run<RPROC(BufferData)>(target, srcBuffer, usage);
+ if (srcBytes) {
+ Run<RPROC(BufferData)>(target, RawBuffer<>({srcBytes, srcLen}), usage);
+ } else {
+ Run<RPROC(BufferData_SizeOnly)>(target, srcLen, usage);
+ }
}
////
diff --git a/dom/canvas/HostWebGLContext.h b/dom/canvas/HostWebGLContext.h
index 3532603d99..7c31ad30d9 100644
--- a/dom/canvas/HostWebGLContext.h
+++ b/dom/canvas/HostWebGLContext.h
@@ -477,9 +477,12 @@ class HostWebGLContext final : public SupportsWeakPtr {
return GetWebGL2Context()->GetBufferSubData(target, srcByteOffset, dest);
}
- void BufferData(GLenum target, const RawBuffer<>& data, GLenum usage) const {
- const auto& beginOrNull = data.begin();
- mContext->BufferData(target, data.size(), beginOrNull, usage);
+ void BufferData(GLenum target, const RawBuffer<>& srcData, GLenum usage) const {
+ mContext->BufferData(target, srcData.size(), srcData.begin(), usage);
+ }
+
+ void BufferData_SizeOnly(GLenum target, size_t byteSize, GLenum usage) const {
+ mContext->BufferData(target, byteSize, nullptr, usage);
}
void BufferSubData(GLenum target, uint64_t dstByteOffset,
diff --git a/dom/canvas/WebGLMethodDispatcher.h b/dom/canvas/WebGLMethodDispatcher.h
index 804eaa14fe..b48c3e341c 100644
--- a/dom/canvas/WebGLMethodDispatcher.h
+++ b/dom/canvas/WebGLMethodDispatcher.h
@@ -102,6 +102,7 @@ DEFINE_ASYNC(HostWebGLContext::BindBuffer)
DEFINE_ASYNC(HostWebGLContext::BindBufferRange)
DEFINE_ASYNC(HostWebGLContext::CopyBufferSubData)
DEFINE_ASYNC(HostWebGLContext::BufferData)
+DEFINE_ASYNC(HostWebGLContext::BufferData_SizeOnly)
DEFINE_ASYNC(HostWebGLContext::BufferSubData)
DEFINE_ASYNC(HostWebGLContext::BlitFramebuffer)
DEFINE_ASYNC(HostWebGLContext::InvalidateFramebuffer)
diff --git a/dom/canvas/WebGLQueueParamTraits.h b/dom/canvas/WebGLQueueParamTraits.h
index 3c130c4da6..ccb3e423ed 100644
--- a/dom/canvas/WebGLQueueParamTraits.h
+++ b/dom/canvas/WebGLQueueParamTraits.h
@@ -123,15 +123,10 @@ struct QueueParamTraits<RawBuffer<T>> {
const auto& elemCount = in.size();
auto status = view.WriteParam(elemCount);
if (!status) return status;
- if (!elemCount) return status;
-
- const auto& begin = in.begin();
- const bool hasData = static_cast<bool>(begin);
- status = view.WriteParam(hasData);
- if (!status) return status;
- if (!hasData) return status;
+ if (!elemCount) return status;
status = view.WriteFromRange(in.Data());
+
return status;
}
@@ -140,20 +135,12 @@ struct QueueParamTraits<RawBuffer<T>> {
size_t elemCount = 0;
auto status = view.ReadParam(&elemCount);
if (!status) return status;
+
if (!elemCount) {
*out = {};
return true;
}
- uint8_t hasData = 0;
- status = view.ReadParam(&hasData);
- if (!status) return status;
- if (!hasData) {
- auto temp = RawBuffer<T>{elemCount};
- *out = std::move(temp);
- return true;
- }
-
auto data = view.template ReadRange<T>(elemCount);
if (!data) return false;
*out = std::move(RawBuffer<T>{*data});
diff --git a/dom/canvas/WebGLTypes.h b/dom/canvas/WebGLTypes.h
index b06aa8a314..092ab9e127 100644
--- a/dom/canvas/WebGLTypes.h
+++ b/dom/canvas/WebGLTypes.h
@@ -839,33 +839,31 @@ struct VertAttribPointerCalculated final {
} // namespace webgl
-/**
- * Represents a block of memory that it may or may not own. The
- * inner data type must be trivially copyable by memcpy.
- */
+// TODO: s/RawBuffer/Span/
template <typename T = uint8_t>
class RawBuffer final {
const T* mBegin = nullptr;
size_t mLen = 0;
- UniqueBuffer mOwned;
public:
using ElementType = T;
- /**
- * If aTakeData is true, RawBuffer will delete[] the memory when destroyed.
- */
- explicit RawBuffer(const Range<const T>& data, UniqueBuffer&& owned = {})
- : mBegin(data.begin().get()),
- mLen(data.length()),
- mOwned(std::move(owned)) {}
-
- explicit RawBuffer(const size_t len) : mLen(len) {}
+ explicit RawBuffer(const Range<const T>& data)
+ : mBegin(data.begin().get()), mLen(data.length()) {
+ if (mLen) {
+ MOZ_ASSERT(mBegin);
+ }
+ }
~RawBuffer() = default;
- Range<const T> Data() const { return {mBegin, mLen}; }
- const auto& begin() const { return mBegin; }
+ Range<const T> Data() const { return {begin(), mLen}; }
+ const auto& begin() const {
+ if (mLen) {
+ MOZ_RELEASE_ASSERT(mBegin);
+ }
+ return mBegin;
+ }
const auto& size() const { return mLen; }
void Shrink(const size_t newLen) {