ported upstream mozilla esr60 changes: bug1515052, bug1539219, bug1547757, bug1555523

This commit is contained in:
Roy Tam 2019-06-22 09:48:24 +08:00
commit bc81a6d5f5
12 changed files with 49 additions and 43 deletions

View file

@ -20,6 +20,7 @@
#include "mozilla/gfx/2D.h" #include "mozilla/gfx/2D.h"
#include "mozilla/LinkedList.h" #include "mozilla/LinkedList.h"
#include "mozilla/UniquePtr.h" #include "mozilla/UniquePtr.h"
#include "mozilla/WeakPtr.h"
#include "nsCycleCollectionNoteChild.h" #include "nsCycleCollectionNoteChild.h"
#include "nsICanvasRenderingContextInternal.h" #include "nsICanvasRenderingContextInternal.h"
#include "nsLayoutUtils.h" #include "nsLayoutUtils.h"
@ -299,6 +300,7 @@ class WebGLContext
, public WebGLContextUnchecked , public WebGLContextUnchecked
, public WebGLRectangleObject , public WebGLRectangleObject
, public nsWrapperCache , public nsWrapperCache
, public SupportsWeakPtr<WebGLContext>
{ {
friend class ScopedDrawHelper; friend class ScopedDrawHelper;
friend class ScopedDrawWithTransformFeedback; friend class ScopedDrawWithTransformFeedback;
@ -342,6 +344,7 @@ public:
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(WebGLContext, NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(WebGLContext,
nsIDOMWebGLRenderingContext) nsIDOMWebGLRenderingContext)
MOZ_DECLARE_WEAKREFERENCE_TYPENAME(WebGLContext)
virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto) override = 0; virtual JSObject* WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto) override = 0;

View file

@ -29,14 +29,7 @@ WebGLExtensionDebugShaders::GetTranslatedShaderSource(const WebGLShader& shader,
{ {
retval.SetIsVoid(true); retval.SetIsVoid(true);
if (mIsLost) { if (mIsLost || !mContext) return;
mContext->ErrorInvalidOperation("%s: Extension is lost.",
"getTranslatedShaderSource");
return;
}
if (mContext->IsContextLost())
return;
if (!mContext->ValidateObject("getShaderTranslatedSource: shader", shader)) if (!mContext->ValidateObject("getShaderTranslatedSource: shader", shader))
return; return;

View file

@ -40,7 +40,7 @@ void
WebGLExtensionDisjointTimerQuery::DeleteQueryEXT(WebGLQuery* query) const WebGLExtensionDisjointTimerQuery::DeleteQueryEXT(WebGLQuery* query) const
{ {
const char funcName[] = "deleteQueryEXT"; const char funcName[] = "deleteQueryEXT";
if (mIsLost) if (mIsLost || !mContext)
return; return;
mContext->DeleteQuery(query, funcName); mContext->DeleteQuery(query, funcName);
@ -50,7 +50,7 @@ bool
WebGLExtensionDisjointTimerQuery::IsQueryEXT(const WebGLQuery* query) const WebGLExtensionDisjointTimerQuery::IsQueryEXT(const WebGLQuery* query) const
{ {
const char funcName[] = "isQueryEXT"; const char funcName[] = "isQueryEXT";
if (mIsLost) if (mIsLost || !mContext)
return false; return false;
return mContext->IsQuery(query, funcName); return mContext->IsQuery(query, funcName);
@ -60,7 +60,7 @@ void
WebGLExtensionDisjointTimerQuery::BeginQueryEXT(GLenum target, WebGLQuery& query) const WebGLExtensionDisjointTimerQuery::BeginQueryEXT(GLenum target, WebGLQuery& query) const
{ {
const char funcName[] = "beginQueryEXT"; const char funcName[] = "beginQueryEXT";
if (mIsLost) if (mIsLost || !mContext)
return; return;
mContext->BeginQuery(target, query, funcName); mContext->BeginQuery(target, query, funcName);
@ -70,7 +70,7 @@ void
WebGLExtensionDisjointTimerQuery::EndQueryEXT(GLenum target) const WebGLExtensionDisjointTimerQuery::EndQueryEXT(GLenum target) const
{ {
const char funcName[] = "endQueryEXT"; const char funcName[] = "endQueryEXT";
if (mIsLost) if (mIsLost || !mContext)
return; return;
mContext->EndQuery(target, funcName); mContext->EndQuery(target, funcName);
@ -80,7 +80,7 @@ void
WebGLExtensionDisjointTimerQuery::QueryCounterEXT(WebGLQuery& query, GLenum target) const WebGLExtensionDisjointTimerQuery::QueryCounterEXT(WebGLQuery& query, GLenum target) const
{ {
const char funcName[] = "queryCounterEXT"; const char funcName[] = "queryCounterEXT";
if (mIsLost) if (mIsLost || !mContext)
return; return;
if (!mContext->ValidateObject(funcName, query)) if (!mContext->ValidateObject(funcName, query))
@ -95,7 +95,7 @@ WebGLExtensionDisjointTimerQuery::GetQueryEXT(JSContext* cx, GLenum target, GLen
{ {
const char funcName[] = "getQueryEXT"; const char funcName[] = "getQueryEXT";
retval.setNull(); retval.setNull();
if (mIsLost) if (mIsLost || !mContext)
return; return;
mContext->GetQuery(cx, target, pname, retval, funcName); mContext->GetQuery(cx, target, pname, retval, funcName);
@ -108,7 +108,7 @@ WebGLExtensionDisjointTimerQuery::GetQueryObjectEXT(JSContext* cx,
{ {
const char funcName[] = "getQueryObjectEXT"; const char funcName[] = "getQueryObjectEXT";
retval.setNull(); retval.setNull();
if (mIsLost) if (mIsLost || !mContext)
return; return;
mContext->GetQueryParameter(cx, query, pname, retval, funcName); mContext->GetQueryParameter(cx, query, pname, retval, funcName);

View file

@ -36,7 +36,9 @@ void
WebGLExtensionDrawBuffers::DrawBuffersWEBGL(const dom::Sequence<GLenum>& buffers) WebGLExtensionDrawBuffers::DrawBuffersWEBGL(const dom::Sequence<GLenum>& buffers)
{ {
if (mIsLost) { if (mIsLost) {
mContext->ErrorInvalidOperation("drawBuffersWEBGL: Extension is lost."); if (mContext) {
mContext->ErrorInvalidOperation("drawBuffersWEBGL: Extension is lost.");
}
return; return;
} }

View file

@ -28,9 +28,11 @@ WebGLExtensionInstancedArrays::DrawArraysInstancedANGLE(GLenum mode,
GLsizei primcount) GLsizei primcount)
{ {
if (mIsLost) { if (mIsLost) {
mContext->ErrorInvalidOperation("%s: Extension is lost.", if (mContext) {
"drawArraysInstancedANGLE"); mContext->ErrorInvalidOperation("%s: Extension is lost.",
return; "drawArraysInstancedANGLE");
return;
}
} }
mContext->DrawArraysInstanced(mode, first, count, primcount); mContext->DrawArraysInstanced(mode, first, count, primcount);
@ -44,9 +46,11 @@ WebGLExtensionInstancedArrays::DrawElementsInstancedANGLE(GLenum mode,
GLsizei primcount) GLsizei primcount)
{ {
if (mIsLost) { if (mIsLost) {
mContext->ErrorInvalidOperation("%s: Extension is lost.", if (mContext) {
"drawElementsInstancedANGLE"); mContext->ErrorInvalidOperation("%s: Extension is lost.",
return; "drawElementsInstancedANGLE");
return;
}
} }
mContext->DrawElementsInstanced(mode, count, type, offset, primcount); mContext->DrawElementsInstanced(mode, count, type, offset, primcount);
@ -57,9 +61,11 @@ WebGLExtensionInstancedArrays::VertexAttribDivisorANGLE(GLuint index,
GLuint divisor) GLuint divisor)
{ {
if (mIsLost) { if (mIsLost) {
mContext->ErrorInvalidOperation("%s: Extension is lost.", if (mContext) {
"vertexAttribDivisorANGLE"); mContext->ErrorInvalidOperation("%s: Extension is lost.",
return; "vertexAttribDivisorANGLE");
return;
}
} }
mContext->VertexAttribDivisor(index, divisor); mContext->VertexAttribDivisor(index, divisor);

View file

@ -22,12 +22,14 @@ WebGLExtensionLoseContext::~WebGLExtensionLoseContext()
void void
WebGLExtensionLoseContext::LoseContext() WebGLExtensionLoseContext::LoseContext()
{ {
if (!mContext) return;
mContext->LoseContext(); mContext->LoseContext();
} }
void void
WebGLExtensionLoseContext::RestoreContext() WebGLExtensionLoseContext::RestoreContext()
{ {
if (!mContext) return;
mContext->RestoreContext(); mContext->RestoreContext();
} }

View file

@ -25,7 +25,7 @@ WebGLExtensionVertexArray::~WebGLExtensionVertexArray()
already_AddRefed<WebGLVertexArray> already_AddRefed<WebGLVertexArray>
WebGLExtensionVertexArray::CreateVertexArrayOES() WebGLExtensionVertexArray::CreateVertexArrayOES()
{ {
if (mIsLost) if (mIsLost || !mContext)
return nullptr; return nullptr;
return mContext->CreateVertexArray(); return mContext->CreateVertexArray();
@ -34,7 +34,7 @@ WebGLExtensionVertexArray::CreateVertexArrayOES()
void void
WebGLExtensionVertexArray::DeleteVertexArrayOES(WebGLVertexArray* array) WebGLExtensionVertexArray::DeleteVertexArrayOES(WebGLVertexArray* array)
{ {
if (mIsLost) if (mIsLost || !mContext)
return; return;
mContext->DeleteVertexArray(array); mContext->DeleteVertexArray(array);
@ -43,7 +43,7 @@ WebGLExtensionVertexArray::DeleteVertexArrayOES(WebGLVertexArray* array)
bool bool
WebGLExtensionVertexArray::IsVertexArrayOES(const WebGLVertexArray* array) WebGLExtensionVertexArray::IsVertexArrayOES(const WebGLVertexArray* array)
{ {
if (mIsLost) if (mIsLost || !mContext)
return false; return false;
return mContext->IsVertexArray(array); return mContext->IsVertexArray(array);
@ -52,7 +52,7 @@ WebGLExtensionVertexArray::IsVertexArrayOES(const WebGLVertexArray* array)
void void
WebGLExtensionVertexArray::BindVertexArrayOES(WebGLVertexArray* array) WebGLExtensionVertexArray::BindVertexArrayOES(WebGLVertexArray* array)
{ {
if (mIsLost) if (mIsLost || !mContext)
return; return;
mContext->BindVertexArray(array); mContext->BindVertexArray(array);

View file

@ -6,6 +6,7 @@
#ifndef WEBGLOBJECTMODEL_H_ #ifndef WEBGLOBJECTMODEL_H_
#define WEBGLOBJECTMODEL_H_ #define WEBGLOBJECTMODEL_H_
#include "mozilla/WeakPtr.h"
#include "nsCycleCollectionNoteChild.h" #include "nsCycleCollectionNoteChild.h"
#include "WebGLTypes.h" #include "WebGLTypes.h"
@ -24,7 +25,7 @@ class WebGLContext;
class WebGLContextBoundObject class WebGLContextBoundObject
{ {
public: public:
WebGLContext* const mContext; const WeakPtr<WebGLContext> mContext;
private: private:
const uint32_t mContextGeneration; const uint32_t mContextGeneration;

View file

@ -2385,9 +2385,14 @@ BackgroundVersionChangeTransactionChild::RecvComplete(const nsresult& aResult)
database->Close(); database->Close();
} }
RefPtr<IDBOpenDBRequest> request = mOpenDBRequest;
MOZ_ASSERT(request);
mTransaction->FireCompleteOrAbortEvents(aResult); mTransaction->FireCompleteOrAbortEvents(aResult);
mOpenDBRequest->SetTransaction(nullptr); request->SetTransaction(nullptr);
request = nullptr;
mOpenDBRequest = nullptr; mOpenDBRequest = nullptr;
NoteComplete(); NoteComplete();

View file

@ -1525,7 +1525,7 @@ void BaseMediaResource::SetLoadInBackground(bool aLoadInBackground) {
NS_WARNING("Null owner in MediaResource::SetLoadInBackground()"); NS_WARNING("Null owner in MediaResource::SetLoadInBackground()");
return; return;
} }
dom::HTMLMediaElement* element = owner->GetMediaElement(); RefPtr<dom::HTMLMediaElement> element = owner->GetMediaElement();
if (!element) { if (!element) {
NS_WARNING("Null element in MediaResource::SetLoadInBackground()"); NS_WARNING("Null element in MediaResource::SetLoadInBackground()");
return; return;

View file

@ -3850,12 +3850,9 @@ public class Tokenizer implements Locator {
tokenHandler.characters( tokenHandler.characters(
Tokenizer.LT_SOLIDUS, 0, 2); Tokenizer.LT_SOLIDUS, 0, 2);
emitStrBuf(); emitStrBuf();
if (c == '\u0000') { cstart = pos; // don't drop the
emitReplacementCharacter(buf, pos); // character
} else { reconsume = true;
cstart = pos; // don't drop the
// character
}
state = transition(state, returnState, reconsume, pos); state = transition(state, returnState, reconsume, pos);
continue stateloop; continue stateloop;
} }

View file

@ -2091,11 +2091,8 @@ nsHtml5Tokenizer::stateLoop(int32_t state, char16_t c, int32_t pos, char16_t* bu
default: { default: {
tokenHandler->characters(nsHtml5Tokenizer::LT_SOLIDUS, 0, 2); tokenHandler->characters(nsHtml5Tokenizer::LT_SOLIDUS, 0, 2);
emitStrBuf(); emitStrBuf();
if (c == '\0') { cstart = pos;
emitReplacementCharacter(buf, pos); reconsume = true;
} else {
cstart = pos;
}
state = P::transition(mViewSource, returnState, reconsume, pos); state = P::transition(mViewSource, returnState, reconsume, pos);
NS_HTML5_CONTINUE(stateloop); NS_HTML5_CONTINUE(stateloop);
} }