From f3bcaf9f88aad2c423ebcd61121562f9834187d4 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 8 Apr 2024 17:11:27 +0200 Subject: Merging upstream version 115.8.0esr. Signed-off-by: Daniel Baumann --- dom/canvas/CanvasUtils.cpp | 12 +++++------- dom/canvas/ClientWebGLContext.cpp | 12 ++++++------ dom/canvas/HostWebGLContext.h | 9 ++++++--- dom/canvas/WebGLMethodDispatcher.h | 1 + dom/canvas/WebGLQueueParamTraits.h | 19 +++---------------- dom/canvas/WebGLTypes.h | 30 ++++++++++++++---------------- 6 files changed, 35 insertions(+), 48 deletions(-) (limited to 'dom/canvas') 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(target, data, usage); + Run(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(target, srcBuffer, usage); + if (srcBytes) { + Run(target, RawBuffer<>({srcBytes, srcLen}), usage); + } else { + Run(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> { 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(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> { 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{elemCount}; - *out = std::move(temp); - return true; - } - auto data = view.template ReadRange(elemCount); if (!data) return false; *out = std::move(RawBuffer{*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 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& 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& data) + : mBegin(data.begin().get()), mLen(data.length()) { + if (mLen) { + MOZ_ASSERT(mBegin); + } + } ~RawBuffer() = default; - Range Data() const { return {mBegin, mLen}; } - const auto& begin() const { return mBegin; } + Range 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) { -- cgit v1.2.3