merge mozilla-inbound to mozilla-central a=merge

This commit is contained in:
Carsten "Tomcat" Book 2016-12-08 16:16:48 +01:00
Родитель e3428d6b2f 0772ab2414
Коммит 3e157ac240
123 изменённых файлов: 1208 добавлений и 917 удалений

Просмотреть файл

@ -496,7 +496,9 @@ DocAccessibleParent::RecvGetWindowedPluginIAccessible(
// one that belongs to its child (see HTMLWin32ObjectAccessible).
HWND childWnd = ::GetWindow(reinterpret_cast<HWND>(aHwnd), GW_CHILD);
if (!childWnd) {
return IPC_FAIL(this, "GetWindow failed");
// We're seeing this in the wild - the plugin is windowed but we no longer
// have a window.
return IPC_OK();
}
IAccessible* rawAccPlugin = nullptr;

Просмотреть файл

@ -85,10 +85,7 @@ HTMLWin32ObjectAccessible::HTMLWin32ObjectAccessible(void* aHwnd,
// use its inner child owned by the plugin so that we don't get
// in an infinite loop, where the WM_GETOBJECT's get forwarded
// back to us and create another HTMLWin32ObjectAccessible
HWND childWnd = ::GetWindow((HWND)aHwnd, GW_CHILD);
if (childWnd) {
mHwnd = childWnd;
}
mHwnd = ::GetWindow((HWND)aHwnd, GW_CHILD);
}
}

Просмотреть файл

@ -4810,6 +4810,14 @@
}
break;
}
case "contextual-identity-updated": {
for (let tab of this.tabs) {
if (tab.getAttribute("usercontextid") == aData) {
ContextualIdentityService.setTabStyle(tab);
}
}
break;
}
case "nsPref:changed": {
// This is the only pref observed.
this._findAsYouType = Services.prefs.getBoolPref("accessibility.typeaheadfind");
@ -4826,6 +4834,7 @@
Services.obs.addObserver(this, "live-resize-start", false);
Services.obs.addObserver(this, "live-resize-end", false);
Services.obs.addObserver(this, "contextual-identity-updated", false);
this.mCurrentTab = this.tabContainer.firstChild;
const nsIEventListenerService =
@ -4925,6 +4934,7 @@
<![CDATA[
Services.obs.removeObserver(this, "live-resize-start", false);
Services.obs.removeObserver(this, "live-resize-end", false);
Services.obs.removeObserver(this, "contextual-identity-updated", false);
for (let tab of this.tabs) {
let browser = tab.linkedBrowser;

Просмотреть файл

@ -351,6 +351,19 @@ OriginAttributes::IsFirstPartyEnabled()
return sFirstPartyIsolation;
}
/* static */
bool
OriginAttributes::IsPrivateBrowsing(const nsACString& aOrigin)
{
nsAutoCString dummy;
PrincipalOriginAttributes attrs;
if (NS_WARN_IF(!attrs.PopulateFromOrigin(aOrigin, dummy))) {
return false;
}
return !!attrs.mPrivateBrowsingId;
}
BasePrincipal::BasePrincipal()
{}

Просмотреть файл

@ -68,6 +68,10 @@ public:
// check if "privacy.firstparty.isolate" is enabled.
static bool IsFirstPartyEnabled();
// returns true if the originAttributes suffix has mPrivateBrowsingId value
// different than 0.
static bool IsPrivateBrowsing(const nsACString& aOrigin);
protected:
OriginAttributes() {}
explicit OriginAttributes(const OriginAttributesDictionary& aOther)

Просмотреть файл

@ -6,7 +6,6 @@
#include "AnimationUtils.h"
#include "nsContentUtils.h" // For nsContentUtils::IsCallerChrome
#include "nsDebug.h"
#include "nsIAtom.h"
#include "nsIContent.h"
@ -79,9 +78,9 @@ AnimationUtils::IsCoreAPIEnabled()
}
/* static */ bool
AnimationUtils::IsCoreAPIEnabledForCaller()
AnimationUtils::IsCoreAPIEnabledForCaller(dom::CallerType aCallerType)
{
return IsCoreAPIEnabled() || nsContentUtils::IsCallerChrome();
return IsCoreAPIEnabled() || aCallerType == dom::CallerType::System;
}
} // namespace mozilla

Просмотреть файл

@ -8,6 +8,7 @@
#define mozilla_dom_AnimationUtils_h
#include "mozilla/TimeStamp.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/Nullable.h"
#include "nsStringFwd.h"
@ -71,7 +72,7 @@ public:
* Returns true if the preference to enable the core Web Animations API is
* true or the caller is chrome.
*/
static bool IsCoreAPIEnabledForCaller();
static bool IsCoreAPIEnabledForCaller(dom::CallerType aCallerType);
};
} // namespace mozilla

Просмотреть файл

@ -133,11 +133,12 @@ KeyframeEffect::SetTarget(const Nullable<ElementOrCSSPseudoElement>& aTarget)
void
KeyframeEffect::SetIterationComposite(
const IterationCompositeOperation& aIterationComposite)
const IterationCompositeOperation& aIterationComposite,
CallerType aCallerType)
{
// Ignore iterationComposite if the Web Animations API is not enabled,
// then the default value 'Replace' will be used.
if (!AnimationUtils::IsCoreAPIEnabledForCaller()) {
if (!AnimationUtils::IsCoreAPIEnabledForCaller(aCallerType)) {
return;
}
@ -156,6 +157,7 @@ KeyframeEffect::SetIterationComposite(
void
KeyframeEffect::SetSpacing(JSContext* aCx,
const nsAString& aSpacing,
CallerType aCallerType,
ErrorResult& aRv)
{
SpacingMode spacingMode = SpacingMode::distribute;
@ -165,6 +167,7 @@ KeyframeEffect::SetSpacing(JSContext* aCx,
spacingMode,
pacedProperty,
invalidPacedProperty,
aCallerType,
aRv);
if (aRv.Failed()) {
return;

Просмотреть файл

@ -8,6 +8,7 @@
#define mozilla_dom_KeyframeEffect_h
#include "nsWrapperCache.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/KeyframeEffectReadOnly.h"
#include "mozilla/AnimationTarget.h" // For (Non)OwningAnimationTarget
#include "mozilla/Maybe.h"
@ -71,9 +72,19 @@ public:
// GetStyleContextForElement.
void SetTarget(const Nullable<ElementOrCSSPseudoElement>& aTarget);
void SetSpacing(JSContext* aCx, const nsAString& aSpacing, ErrorResult& aRv);
void GetSpacing(nsString& aRetVal, CallerType aCallerType)
{
KeyframeEffectReadOnly::GetSpacing(aRetVal);
}
void SetSpacing(JSContext* aCx, const nsAString& aSpacing,
CallerType aCallerType, ErrorResult& aRv);
IterationCompositeOperation IterationComposite(CallerType aCallerType)
{
return KeyframeEffectReadOnly::IterationComposite();
}
void SetIterationComposite(
const IterationCompositeOperation& aIterationComposite);
const IterationCompositeOperation& aIterationComposite,
CallerType aCallerType);
};
} // namespace dom

Просмотреть файл

@ -109,13 +109,14 @@ KeyframeEffectParams::ParseSpacing(const nsAString& aSpacing,
SpacingMode& aSpacingMode,
nsCSSPropertyID& aPacedProperty,
nsAString& aInvalidPacedProperty,
dom::CallerType aCallerType,
ErrorResult& aRv)
{
aInvalidPacedProperty.Truncate();
// Ignore spacing if the core API is not enabled since it is not yet ready to
// ship.
if (!AnimationUtils::IsCoreAPIEnabledForCaller()) {
if (!AnimationUtils::IsCoreAPIEnabledForCaller(aCallerType)) {
aSpacingMode = SpacingMode::distribute;
return;
}

Просмотреть файл

@ -14,6 +14,7 @@
#undef None
#endif
#include "mozilla/dom/KeyframeEffectBinding.h" // IterationCompositeOperation
#include "mozilla/dom/BindingDeclarations.h" // CallerType
namespace mozilla {
@ -54,6 +55,7 @@ struct KeyframeEffectParams
SpacingMode& aSpacingMode,
nsCSSPropertyID& aPacedProperty,
nsAString& aInvalidPacedProperty,
dom::CallerType aCallerType,
ErrorResult& aRv);
dom::IterationCompositeOperation mIterationComposite =

Просмотреть файл

@ -568,6 +568,7 @@ template <class OptionsType>
static KeyframeEffectParams
KeyframeEffectParamsFromUnion(const OptionsType& aOptions,
nsAString& aInvalidPacedProperty,
CallerType aCallerType,
ErrorResult& aRv)
{
KeyframeEffectParams result;
@ -578,10 +579,11 @@ KeyframeEffectParamsFromUnion(const OptionsType& aOptions,
result.mSpacingMode,
result.mPacedProperty,
aInvalidPacedProperty,
aCallerType,
aRv);
// Ignore iterationComposite if the Web Animations API is not enabled,
// then the default value 'Replace' will be used.
if (AnimationUtils::IsCoreAPIEnabledForCaller()) {
if (AnimationUtils::IsCoreAPIEnabledForCaller(aCallerType)) {
result.mIterationComposite = options.mIterationComposite;
// FIXME: Bug 1311620: We don't support additive animation yet.
if (options.mComposite != dom::CompositeOperation::Add) {
@ -639,7 +641,8 @@ KeyframeEffectReadOnly::ConstructKeyframeEffect(
nsAutoString invalidPacedProperty;
KeyframeEffectParams effectOptions =
KeyframeEffectParamsFromUnion(aOptions, invalidPacedProperty, aRv);
KeyframeEffectParamsFromUnion(aOptions, invalidPacedProperty,
aGlobal.CallerType(), aRv);
if (aRv.Failed()) {
return nullptr;
}

Просмотреть файл

@ -24,6 +24,7 @@
// associated RefPtrTraits
#include "mozilla/StyleAnimationValue.h"
#include "mozilla/dom/AnimationEffectReadOnly.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/Element.h"
struct JSContext;

Просмотреть файл

@ -581,7 +581,7 @@ Location::GetPathname(nsAString& aPathname)
result = GetURI(getter_AddRefs(uri));
nsCOMPtr<nsIURL> url(do_QueryInterface(uri));
nsCOMPtr<nsIURIWithQuery> url(do_QueryInterface(uri));
if (url) {
nsAutoCString file;
@ -604,12 +604,12 @@ Location::SetPathname(const nsAString& aPathname)
return rv;
}
rv = uri->SetPath(NS_ConvertUTF16toUTF8(aPathname));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
nsCOMPtr<nsIURIWithQuery> url(do_QueryInterface(uri));
if (url && NS_SUCCEEDED(url->SetFilePath(NS_ConvertUTF16toUTF8(aPathname)))) {
return SetURI(uri);
}
return SetURI(uri);
return NS_OK;
}
NS_IMETHODIMP

Просмотреть файл

@ -84,6 +84,8 @@ struct EnumEntry {
size_t length;
};
enum class CallerType : uint32_t;
class MOZ_STACK_CLASS GlobalObject
{
public:
@ -113,6 +115,10 @@ public:
// a nullptr is returned.
nsIPrincipal* GetSubjectPrincipal() const;
// Get the caller type. Note that this needs to be called before anyone has
// had a chance to mess with the JSContext.
dom::CallerType CallerType() const;
protected:
JS::Rooted<JSObject*> mGlobalJSObject;
JSContext* mCx;

Просмотреть файл

@ -2315,6 +2315,13 @@ GlobalObject::GetSubjectPrincipal() const
return nsJSPrincipals::get(principals);
}
CallerType
GlobalObject::CallerType() const
{
return nsContentUtils::ThreadsafeIsSystemCaller(mCx) ?
dom::CallerType::System : dom::CallerType::NonSystem;
}
static bool
CallOrdinaryHasInstance(JSContext* cx, JS::CallArgs& args)
{

Просмотреть файл

@ -314,7 +314,7 @@ public:
already_AddRefed<WebGLSampler> CreateSampler();
void DeleteSampler(WebGLSampler* sampler);
bool IsSampler(WebGLSampler* sampler);
bool IsSampler(const WebGLSampler* sampler);
void BindSampler(GLuint unit, WebGLSampler* sampler);
void SamplerParameteri(WebGLSampler& sampler, GLenum pname, GLint param);
void SamplerParameterf(WebGLSampler& sampler, GLenum pname, GLfloat param);
@ -326,7 +326,7 @@ public:
// Sync objects - WebGL2ContextSync.cpp
already_AddRefed<WebGLSync> FenceSync(GLenum condition, GLbitfield flags);
bool IsSync(WebGLSync* sync);
bool IsSync(const WebGLSync* sync);
void DeleteSync(WebGLSync* sync);
GLenum ClientWaitSync(const WebGLSync& sync, GLbitfield flags, GLuint64 timeout);
void WaitSync(const WebGLSync& sync, GLbitfield flags, GLint64 timeout);
@ -339,7 +339,7 @@ public:
already_AddRefed<WebGLTransformFeedback> CreateTransformFeedback();
void DeleteTransformFeedback(WebGLTransformFeedback* tf);
bool IsTransformFeedback(WebGLTransformFeedback* tf);
bool IsTransformFeedback(const WebGLTransformFeedback* tf);
void BindTransformFeedback(GLenum target, WebGLTransformFeedback* tf);
void BeginTransformFeedback(GLenum primitiveMode);
void EndTransformFeedback();

Просмотреть файл

@ -19,7 +19,7 @@ WebGL2Context::GetFragDataLocation(const WebGLProgram& prog, const nsAString& na
if (IsContextLost())
return -1;
if (!ValidateObjectRef("getFragDataLocation: program", prog))
if (!ValidateObject("getFragDataLocation: program", prog))
return -1;
return prog.GetFragDataLocation(name);

Просмотреть файл

@ -78,13 +78,7 @@ WebGLContext::DeleteQuery(WebGLQuery* query, const char* funcName)
funcName = "deleteQuery";
}
if (IsContextLost())
return;
if (!query)
return;
if (!ValidateObjectAllowDeleted(funcName, query))
if (!ValidateDeleteObject(funcName, query))
return;
query->DeleteQuery();
@ -97,13 +91,7 @@ WebGLContext::IsQuery(const WebGLQuery* query, const char* funcName)
funcName = "isQuery";
}
if (IsContextLost())
return false;
if (!query)
return false;
if (!ValidateObjectAllowDeleted("isQuery", query))
if (!ValidateIsObject(funcName, query))
return false;
return query->IsQuery();
@ -119,12 +107,9 @@ WebGLContext::BeginQuery(GLenum target, WebGLQuery& query, const char* funcName)
if (IsContextLost())
return;
if (!ValidateObjectAllowDeleted(funcName, &query))
if (!ValidateObject(funcName, query))
return;
if (query.IsDeleted())
return ErrorInvalidOperation("%s: Cannot begin a deleted query.", funcName);
const auto& slot = ValidateQuerySlotByTarget(funcName, target);
if (!slot)
return;
@ -238,12 +223,9 @@ WebGLContext::GetQueryParameter(JSContext*, const WebGLQuery& query, GLenum pnam
if (IsContextLost())
return;
if (!ValidateObjectAllowDeleted(funcName, &query))
if (!ValidateObject(funcName, query))
return;
if (query.IsDeleted())
return ErrorInvalidOperation("%s: Query must not be deleted.", funcName);
query.GetQueryParameter(pname, retval);
}

Просмотреть файл

@ -26,13 +26,7 @@ WebGL2Context::CreateSampler()
void
WebGL2Context::DeleteSampler(WebGLSampler* sampler)
{
if (IsContextLost())
return;
if (!ValidateObjectAllowDeletedOrNull("deleteSampler", sampler))
return;
if (!sampler || sampler->IsDeleted())
if (!ValidateDeleteObject("deleteSampler", sampler))
return;
for (int n = 0; n < mGLMaxTextureUnits; n++) {
@ -47,18 +41,9 @@ WebGL2Context::DeleteSampler(WebGLSampler* sampler)
}
bool
WebGL2Context::IsSampler(WebGLSampler* sampler)
WebGL2Context::IsSampler(const WebGLSampler* sampler)
{
if (IsContextLost())
return false;
if (!sampler)
return false;
if (!ValidateObjectAllowDeleted("isSampler", sampler))
return false;
if (sampler->IsDeleted())
if (!ValidateIsObject("isSampler", sampler))
return false;
MakeContextCurrent();
@ -71,15 +56,12 @@ WebGL2Context::BindSampler(GLuint unit, WebGLSampler* sampler)
if (IsContextLost())
return;
if (!ValidateObjectAllowDeletedOrNull("bindSampler", sampler))
if (sampler && !ValidateObject("bindSampler", *sampler))
return;
if (GLint(unit) >= mGLMaxTextureUnits)
return ErrorInvalidValue("bindSampler: unit must be < %d", mGLMaxTextureUnits);
if (sampler && sampler->IsDeleted())
return ErrorInvalidOperation("bindSampler: binding deleted sampler");
////
gl->MakeCurrent();
@ -96,7 +78,7 @@ WebGL2Context::SamplerParameteri(WebGLSampler& sampler, GLenum pname, GLint para
if (IsContextLost())
return;
if (!ValidateObjectRef(funcName, sampler))
if (!ValidateObject(funcName, sampler))
return;
sampler.SamplerParameter(funcName, pname, paramInt);
@ -109,7 +91,7 @@ WebGL2Context::SamplerParameterf(WebGLSampler& sampler, GLenum pname, GLfloat pa
if (IsContextLost())
return;
if (!ValidateObjectRef(funcName, sampler))
if (!ValidateObject(funcName, sampler))
return;
sampler.SamplerParameter(funcName, pname, WebGLIntOrFloat(paramFloat).AsInt());
@ -125,7 +107,7 @@ WebGL2Context::GetSamplerParameter(JSContext*, const WebGLSampler& sampler, GLen
if (IsContextLost())
return;
if (!ValidateObjectRef(funcName, sampler))
if (!ValidateObject(funcName, sampler))
return;
////

Просмотреть файл

@ -16,43 +16,37 @@ namespace mozilla {
already_AddRefed<WebGLSync>
WebGL2Context::FenceSync(GLenum condition, GLbitfield flags)
{
if (IsContextLost())
return nullptr;
if (IsContextLost())
return nullptr;
if (condition != LOCAL_GL_SYNC_GPU_COMMANDS_COMPLETE) {
ErrorInvalidEnum("fenceSync: condition must be SYNC_GPU_COMMANDS_COMPLETE");
return nullptr;
}
if (condition != LOCAL_GL_SYNC_GPU_COMMANDS_COMPLETE) {
ErrorInvalidEnum("fenceSync: condition must be SYNC_GPU_COMMANDS_COMPLETE");
return nullptr;
}
if (flags != 0) {
ErrorInvalidValue("fenceSync: flags must be 0");
return nullptr;
}
if (flags != 0) {
ErrorInvalidValue("fenceSync: flags must be 0");
return nullptr;
}
MakeContextCurrent();
RefPtr<WebGLSync> globj = new WebGLSync(this, condition, flags);
return globj.forget();
MakeContextCurrent();
RefPtr<WebGLSync> globj = new WebGLSync(this, condition, flags);
return globj.forget();
}
bool
WebGL2Context::IsSync(WebGLSync* sync)
WebGL2Context::IsSync(const WebGLSync* sync)
{
if (IsContextLost())
return false;
if (!ValidateIsObject("isSync", sync))
return false;
return ValidateObjectAllowDeleted("isSync", sync) && !sync->IsDeleted();
return true;
}
void
WebGL2Context::DeleteSync(WebGLSync* sync)
{
if (IsContextLost())
return;
if (!ValidateObjectAllowDeletedOrNull("deleteSync", sync))
return;
if (!sync || sync->IsDeleted())
if (!ValidateDeleteObject("deleteSync", sync))
return;
sync->RequestDelete();
@ -65,7 +59,7 @@ WebGL2Context::ClientWaitSync(const WebGLSync& sync, GLbitfield flags, GLuint64
if (IsContextLost())
return LOCAL_GL_WAIT_FAILED;
if (!ValidateObjectRef(funcName, sync))
if (!ValidateObject(funcName, sync))
return LOCAL_GL_WAIT_FAILED;
if (flags != 0 && flags != LOCAL_GL_SYNC_FLUSH_COMMANDS_BIT) {
@ -84,7 +78,7 @@ WebGL2Context::WaitSync(const WebGLSync& sync, GLbitfield flags, GLint64 timeout
if (IsContextLost())
return;
if (!ValidateObjectRef(funcName, sync))
if (!ValidateObject(funcName, sync))
return;
if (flags != 0) {
@ -110,7 +104,7 @@ WebGL2Context::GetSyncParameter(JSContext*, const WebGLSync& sync, GLenum pname,
if (IsContextLost())
return;
if (!ValidateObjectRef(funcName, sync))
if (!ValidateObject(funcName, sync))
return;
////

Просмотреть файл

@ -32,10 +32,7 @@ void
WebGL2Context::DeleteTransformFeedback(WebGLTransformFeedback* tf)
{
const char funcName[] = "deleteTransformFeedback";
if (IsContextLost())
return;
if (!ValidateObject(funcName, tf))
if (!ValidateDeleteObject(funcName, tf))
return;
if (tf->mIsActive) {
@ -51,15 +48,9 @@ WebGL2Context::DeleteTransformFeedback(WebGLTransformFeedback* tf)
}
bool
WebGL2Context::IsTransformFeedback(WebGLTransformFeedback* tf)
WebGL2Context::IsTransformFeedback(const WebGLTransformFeedback* tf)
{
if (IsContextLost())
return false;
if (!ValidateObjectAllowDeletedOrNull("isTransformFeedback", tf))
return false;
if (!tf || tf->IsDeleted())
if (!ValidateIsObject("isTransformFeedback", tf))
return false;
MakeContextCurrent();
@ -76,12 +67,9 @@ WebGL2Context::BindTransformFeedback(GLenum target, WebGLTransformFeedback* tf)
if (target != LOCAL_GL_TRANSFORM_FEEDBACK)
return ErrorInvalidEnum("%s: `target` must be TRANSFORM_FEEDBACK.", funcName);
if (!ValidateObjectAllowDeletedOrNull(funcName, tf))
if (tf && !ValidateObject(funcName, *tf))
return;
if (tf && tf->IsDeleted())
return ErrorInvalidOperation("%s: TFO already deleted.", funcName);
if (mBoundTransformFeedback->mIsActive &&
!mBoundTransformFeedback->mIsPaused)
{
@ -143,7 +131,7 @@ WebGL2Context::TransformFeedbackVaryings(WebGLProgram& program,
if (IsContextLost())
return;
if (!ValidateObjectRef("transformFeedbackVaryings: program", program))
if (!ValidateObject("transformFeedbackVaryings: program", program))
return;
program.TransformFeedbackVaryings(varyings, bufferMode);
@ -155,7 +143,7 @@ WebGL2Context::GetTransformFeedbackVarying(const WebGLProgram& program, GLuint i
if (IsContextLost())
return nullptr;
if (!ValidateObjectRef("getTransformFeedbackVarying: program", program))
if (!ValidateObject("getTransformFeedbackVarying: program", program))
return nullptr;
return program.GetTransformFeedbackVarying(index);

Просмотреть файл

@ -138,7 +138,7 @@ WebGL2Context::GetUniformIndices(const WebGLProgram& program,
if (IsContextLost())
return;
if (!ValidateObjectRef("getUniformIndices: program", program))
if (!ValidateObject("getUniformIndices: program", program))
return;
if (!uniformNames.Length())
@ -179,7 +179,7 @@ WebGL2Context::GetActiveUniforms(JSContext* cx, const WebGLProgram& program,
if (!ValidateUniformEnum(this, pname, funcName))
return;
if (!ValidateObjectRef("getActiveUniforms: program", program))
if (!ValidateObject("getActiveUniforms: program", program))
return;
const auto& count = uniformIndices.Length();
@ -231,7 +231,7 @@ WebGL2Context::GetUniformBlockIndex(const WebGLProgram& program,
if (IsContextLost())
return 0;
if (!ValidateObjectRef("getUniformBlockIndex: program", program))
if (!ValidateObject("getUniformBlockIndex: program", program))
return 0;
return program.GetUniformBlockIndex(uniformBlockName);
@ -247,7 +247,7 @@ WebGL2Context::GetActiveUniformBlockParameter(JSContext* cx, const WebGLProgram&
if (IsContextLost())
return;
if (!ValidateObjectRef("getActiveUniformBlockParameter: program", program))
if (!ValidateObject("getActiveUniformBlockParameter: program", program))
return;
MakeContextCurrent();
@ -278,7 +278,7 @@ WebGL2Context::GetActiveUniformBlockName(const WebGLProgram& program,
if (IsContextLost())
return;
if (!ValidateObjectRef("getActiveUniformBlockName: program", program))
if (!ValidateObject("getActiveUniformBlockName: program", program))
return;
program.GetActiveUniformBlockName(uniformBlockIndex, retval);
@ -291,7 +291,7 @@ WebGL2Context::UniformBlockBinding(WebGLProgram& program, GLuint uniformBlockInd
if (IsContextLost())
return;
if (!ValidateObjectRef("uniformBlockBinding: program", program))
if (!ValidateObject("uniformBlockBinding: program", program))
return;
program.UniformBlockBinding(uniformBlockIndex, uniformBlockBinding);

Просмотреть файл

@ -13,7 +13,7 @@
namespace mozilla {
WebGLBuffer::WebGLBuffer(WebGLContext* webgl, GLuint buf)
: WebGLContextBoundObject(webgl)
: WebGLRefCountedObject(webgl)
, mGLName(buf)
, mContent(Kind::Undefined)
, mUsage(LOCAL_GL_STATIC_DRAW)

Просмотреть файл

@ -22,7 +22,6 @@ class WebGLBuffer final
: public nsWrapperCache
, public WebGLRefCountedObject<WebGLBuffer>
, public LinkedListElement<WebGLBuffer>
, public WebGLContextBoundObject
{
friend class WebGLContext;
friend class WebGL2Context;

Просмотреть файл

@ -222,7 +222,7 @@ WebGLContext::~WebGLContext()
}
template<typename T>
static void
void
ClearLinkedList(LinkedList<T>& list)
{
while (!list.isEmpty()) {

Просмотреть файл

@ -616,11 +616,11 @@ public:
GetUniformLocation(const WebGLProgram& prog, const nsAString& name);
void Hint(GLenum target, GLenum mode);
bool IsFramebuffer(WebGLFramebuffer* fb);
bool IsProgram(WebGLProgram* prog);
bool IsRenderbuffer(WebGLRenderbuffer* rb);
bool IsShader(WebGLShader* shader);
bool IsVertexArray(WebGLVertexArray* vao);
bool IsFramebuffer(const WebGLFramebuffer* fb);
bool IsProgram(const WebGLProgram* prog);
bool IsRenderbuffer(const WebGLRenderbuffer* rb);
bool IsShader(const WebGLShader* shader);
bool IsVertexArray(const WebGLVertexArray* vao);
void LineWidth(GLfloat width);
void LinkProgram(WebGLProgram& prog);
void PixelStorei(GLenum pname, GLint param);
@ -1628,33 +1628,95 @@ protected:
//////
public:
// Returns false if `object` is null or not valid.
template<class ObjectType>
bool ValidateObject(const char* info, const ObjectType* object);
bool ValidateObjectAllowDeleted(const char* funcName,
const WebGLContextBoundObject& object)
{
if (!object.IsCompatibleWithContext(this)) {
ErrorInvalidOperation("%s: Object from different WebGL context (or older"
" generation of this one) passed as argument.",
funcName);
return false;
}
// Returns false if `object` is not valid.
template<class ObjectType>
bool ValidateObjectRef(const char* info, const ObjectType& object);
return true;
}
// Returns false if `object` is not valid. Considers null to be valid.
template<class ObjectType>
bool ValidateObjectAllowNull(const char* info, const ObjectType* object);
bool ValidateObject(const char* funcName, const WebGLDeletableObject& object,
bool isShaderOrProgram = false)
{
if (!ValidateObjectAllowDeleted(funcName, object))
return false;
// Returns false if `object` is not valid, but considers deleted objects and
// null objects valid.
template<class ObjectType>
bool ValidateObjectAllowDeletedOrNull(const char* info, const ObjectType* object);
if (isShaderOrProgram) {
/* GLES 3.0.5 p45:
* "Commands that accept shader or program object names will generate the
* error INVALID_VALUE if the provided name is not the name of either a
* shader or program object[.]"
* Further, shaders and programs appear to be different from other objects,
* in that their lifetimes are better defined. However, they also appear to
* allow use of objects marked for deletion, and only reject
* actually-destroyed objects.
*/
if (object.IsDeleted()) {
ErrorInvalidValue("%s: Shader or program object argument cannot have been"
" deleted.",
funcName);
return false;
}
} else {
if (object.IsDeleteRequested()) {
ErrorInvalidOperation("%s: Object argument cannot have been marked for"
" deletion.",
funcName);
return false;
}
}
// Returns false if `object` is null or not valid, but considers deleted
// objects valid.
template<class ObjectType>
bool ValidateObjectAllowDeleted(const char* info, const ObjectType* object);
return true;
}
private:
// Like ValidateObject, but only for cases when `object` is known to not be
// null already.
template<class ObjectType>
bool ValidateObjectAssumeNonNull(const char* info, const ObjectType* object);
////
bool ValidateObject(const char* funcName, const WebGLProgram& object);
bool ValidateObject(const char* funcName, const WebGLShader& object);
////
bool ValidateIsObject(const char* funcName,
const WebGLDeletableObject* object) const
{
if (IsContextLost())
return false;
if (!object)
return false;
if (!object->IsCompatibleWithContext(this))
return false;
if (object->IsDeleted())
return false;
return true;
}
bool ValidateDeleteObject(const char* funcName, const WebGLDeletableObject* object) {
if (IsContextLost())
return false;
if (!object)
return false;
if (!ValidateObjectAllowDeleted(funcName, *object))
return false;
if (object->IsDeleteRequested())
return false;
return true;
}
////
private:
// -------------------------------------------------------------------------
@ -1953,82 +2015,6 @@ ToSupports(WebGLContext* webgl)
return static_cast<nsIDOMWebGLRenderingContext*>(webgl);
}
/**
** Template implementations
**/
template<class ObjectType>
inline bool
WebGLContext::ValidateObjectAllowDeletedOrNull(const char* info, const ObjectType* object)
{
if (object && !object->IsCompatibleWithContext(this)) {
ErrorInvalidOperation("%s: object from different WebGL context "
"(or older generation of this one) "
"passed as argument", info);
return false;
}
return true;
}
template<class ObjectType>
inline bool
WebGLContext::ValidateObjectAssumeNonNull(const char* info, const ObjectType* object)
{
MOZ_ASSERT(object);
if (!ValidateObjectAllowDeletedOrNull(info, object))
return false;
if (object->IsDeleted()) {
ErrorInvalidValue("%s: Deleted object passed as argument.", info);
return false;
}
return true;
}
template<class ObjectType>
inline bool
WebGLContext::ValidateObjectAllowNull(const char* info, const ObjectType* object)
{
if (!object)
return true;
return ValidateObjectAssumeNonNull(info, object);
}
template<class ObjectType>
inline bool
WebGLContext::ValidateObjectAllowDeleted(const char* info, const ObjectType* object)
{
if (!object) {
ErrorInvalidValue("%s: null object passed as argument", info);
return false;
}
return ValidateObjectAllowDeletedOrNull(info, object);
}
template<class ObjectType>
inline bool
WebGLContext::ValidateObject(const char* info, const ObjectType* object)
{
if (!object) {
ErrorInvalidValue("%s: null object passed as argument", info);
return false;
}
return ValidateObjectAssumeNonNull(info, object);
}
template<class ObjectType>
inline bool
WebGLContext::ValidateObjectRef(const char* info, const ObjectType& object)
{
return ValidateObjectAssumeNonNull(info, &object);
}
// Returns `value` rounded to the next highest multiple of `multiple`.
// AKA PadToAlignment, StrideForAlignment.
template<typename V, typename M>

Просмотреть файл

@ -119,12 +119,9 @@ WebGLContext::BindBuffer(GLenum target, WebGLBuffer* buffer)
if (IsContextLost())
return;
if (!ValidateObjectAllowDeletedOrNull(funcName, buffer))
if (buffer && !ValidateObject(funcName, *buffer))
return;
if (buffer && buffer->IsDeleted())
return ErrorInvalidOperation("%s: Cannot bind a deleted object.", funcName);
const auto& slot = ValidateBufferSlot(funcName, target);
if (!slot)
return;
@ -183,12 +180,9 @@ WebGLContext::BindBufferBase(GLenum target, GLuint index, WebGLBuffer* buffer)
if (IsContextLost())
return;
if (!ValidateObjectAllowDeletedOrNull(funcName, buffer))
if (buffer && !ValidateObject(funcName, *buffer))
return;
if (buffer && buffer->IsDeleted())
return ErrorInvalidOperation("%s: Cannot bind a deleted object.", funcName);
WebGLRefPtr<WebGLBuffer>* genericBinding;
IndexedBufferBinding* indexedBinding;
if (!ValidateIndexedBufferBinding(funcName, target, index, &genericBinding,
@ -234,12 +228,9 @@ WebGLContext::BindBufferRange(GLenum target, GLuint index, WebGLBuffer* buffer,
if (IsContextLost())
return;
if (!ValidateObjectAllowDeletedOrNull(funcName, buffer))
if (buffer && !ValidateObject(funcName, *buffer))
return;
if (buffer && buffer->IsDeleted())
return ErrorInvalidOperation("%s: Cannot bind a deleted object.", funcName);
if (!ValidateNonNegative(funcName, "offset", offset) ||
!ValidateNonNegative(funcName, "size", size))
{
@ -476,13 +467,7 @@ WebGLContext::CreateBuffer()
void
WebGLContext::DeleteBuffer(WebGLBuffer* buffer)
{
if (IsContextLost())
return;
if (!ValidateObjectAllowDeletedOrNull("deleteBuffer", buffer))
return;
if (!buffer || buffer->IsDeleted())
if (!ValidateDeleteObject("deleteBuffer", buffer))
return;
////
@ -530,13 +515,7 @@ WebGLContext::DeleteBuffer(WebGLBuffer* buffer)
bool
WebGLContext::IsBuffer(WebGLBuffer* buffer)
{
if (IsContextLost())
return false;
if (!ValidateObjectAllowDeleted("isBuffer", buffer))
return false;
if (buffer->IsDeleted())
if (!ValidateIsObject("isBuffer", buffer))
return false;
MakeContextCurrent();

Просмотреть файл

@ -57,6 +57,18 @@
namespace mozilla {
bool
WebGLContext::ValidateObject(const char* funcName, const WebGLProgram& object)
{
return ValidateObject(funcName, object, true);
}
bool
WebGLContext::ValidateObject(const char* funcName, const WebGLShader& object)
{
return ValidateObject(funcName, object, true);
}
using namespace mozilla::dom;
using namespace mozilla::gfx;
using namespace mozilla::gl;
@ -92,8 +104,8 @@ WebGLContext::AttachShader(WebGLProgram& program, WebGLShader& shader)
if (IsContextLost())
return;
if (!ValidateObjectRef("attachShader: program", program) ||
!ValidateObjectRef("attachShader: shader", shader))
if (!ValidateObject("attachShader: program", program) ||
!ValidateObject("attachShader: shader", shader))
{
return;
}
@ -108,7 +120,7 @@ WebGLContext::BindAttribLocation(WebGLProgram& prog, GLuint location,
if (IsContextLost())
return;
if (!ValidateObjectRef("bindAttribLocation: program", prog))
if (!ValidateObject("bindAttribLocation: program", prog))
return;
prog.BindAttribLocation(location, name);
@ -123,12 +135,9 @@ WebGLContext::BindFramebuffer(GLenum target, WebGLFramebuffer* wfb)
if (!ValidateFramebufferTarget(target, "bindFramebuffer"))
return;
if (!ValidateObjectAllowDeletedOrNull("bindFramebuffer", wfb))
if (wfb && !ValidateObject("bindFramebuffer", *wfb))
return;
if (wfb && wfb->IsDeleted())
return ErrorInvalidOperation("bindFramebuffer: Cannot bind a deleted object.");
MakeContextCurrent();
if (!wfb) {
@ -166,12 +175,9 @@ WebGLContext::BindRenderbuffer(GLenum target, WebGLRenderbuffer* wrb)
if (target != LOCAL_GL_RENDERBUFFER)
return ErrorInvalidEnumInfo("bindRenderbuffer: target", target);
if (!ValidateObjectAllowDeletedOrNull("bindRenderbuffer", wrb))
if (wrb && !ValidateObject("bindRenderbuffer", *wrb))
return;
if (wrb && wrb->IsDeleted())
return ErrorInvalidOperation("bindRenderbuffer: Cannot bind a deleted object.");
// Usually, we would now call into glBindRenderbuffer. However, since we have to
// potentially emulate packed-depth-stencil, there's not a specific renderbuffer that
// we know we should bind here.
@ -320,13 +326,7 @@ WebGLContext::CullFace(GLenum face)
void
WebGLContext::DeleteFramebuffer(WebGLFramebuffer* fbuf)
{
if (IsContextLost())
return;
if (!ValidateObjectAllowDeletedOrNull("deleteFramebuffer", fbuf))
return;
if (!fbuf || fbuf->IsDeleted())
if (!ValidateDeleteObject("deleteFramebuffer", fbuf))
return;
fbuf->RequestDelete();
@ -348,13 +348,7 @@ WebGLContext::DeleteFramebuffer(WebGLFramebuffer* fbuf)
void
WebGLContext::DeleteRenderbuffer(WebGLRenderbuffer* rbuf)
{
if (IsContextLost())
return;
if (!ValidateObjectAllowDeletedOrNull("deleteRenderbuffer", rbuf))
return;
if (!rbuf || rbuf->IsDeleted())
if (!ValidateDeleteObject("deleteRenderbuffer", rbuf))
return;
if (mBoundDrawFramebuffer)
@ -374,13 +368,7 @@ WebGLContext::DeleteRenderbuffer(WebGLRenderbuffer* rbuf)
void
WebGLContext::DeleteTexture(WebGLTexture* tex)
{
if (IsContextLost())
return;
if (!ValidateObjectAllowDeletedOrNull("deleteTexture", tex))
return;
if (!tex || tex->IsDeleted())
if (!ValidateDeleteObject("deleteTexture", tex))
return;
if (mBoundDrawFramebuffer)
@ -408,13 +396,7 @@ WebGLContext::DeleteTexture(WebGLTexture* tex)
void
WebGLContext::DeleteProgram(WebGLProgram* prog)
{
if (IsContextLost())
return;
if (!ValidateObjectAllowDeletedOrNull("deleteProgram", prog))
return;
if (!prog || prog->IsDeleted())
if (!ValidateDeleteObject("deleteProgram", prog))
return;
prog->RequestDelete();
@ -423,13 +405,7 @@ WebGLContext::DeleteProgram(WebGLProgram* prog)
void
WebGLContext::DeleteShader(WebGLShader* shader)
{
if (IsContextLost())
return;
if (!ValidateObjectAllowDeletedOrNull("deleteShader", shader))
return;
if (!shader || shader->IsDeleted())
if (!ValidateDeleteObject("deleteShader", shader))
return;
shader->RequestDelete();
@ -443,8 +419,8 @@ WebGLContext::DetachShader(WebGLProgram& program, const WebGLShader& shader)
// It's valid to attempt to detach a deleted shader, since it's still a
// shader.
if (!ValidateObjectRef("detachShader: program", program) ||
!ValidateObjectAllowDeleted("detachShader: shader", &shader))
if (!ValidateObject("detachShader: program", program) ||
!ValidateObjectAllowDeleted("detachShader: shader", shader))
{
return;
}
@ -569,7 +545,7 @@ WebGLContext::GetActiveAttrib(const WebGLProgram& prog, GLuint index)
if (IsContextLost())
return nullptr;
if (!ValidateObjectRef("getActiveAttrib: program", prog))
if (!ValidateObject("getActiveAttrib: program", prog))
return nullptr;
return prog.GetActiveAttrib(index);
@ -581,7 +557,7 @@ WebGLContext::GetActiveUniform(const WebGLProgram& prog, GLuint index)
if (IsContextLost())
return nullptr;
if (!ValidateObjectRef("getActiveUniform: program", prog))
if (!ValidateObject("getActiveUniform: program", prog))
return nullptr;
return prog.GetActiveUniform(index);
@ -595,7 +571,7 @@ WebGLContext::GetAttachedShaders(const WebGLProgram& prog,
if (IsContextLost())
return;
if (!ValidateObjectRef("getAttachedShaders", prog))
if (!ValidateObject("getAttachedShaders", prog))
return;
prog.GetAttachedShaders(&retval.SetValue());
@ -607,7 +583,7 @@ WebGLContext::GetAttribLocation(const WebGLProgram& prog, const nsAString& name)
if (IsContextLost())
return -1;
if (!ValidateObjectRef("getAttribLocation: program", prog))
if (!ValidateObject("getAttribLocation: program", prog))
return -1;
return prog.GetAttribLocation(name);
@ -910,7 +886,7 @@ WebGLContext::GetProgramParameter(const WebGLProgram& prog, GLenum pname)
if (IsContextLost())
return JS::NullValue();
if (!ValidateObjectAllowDeleted("getProgramParameter: program", &prog))
if (!ValidateObjectAllowDeleted("getProgramParameter: program", prog))
return JS::NullValue();
return prog.GetProgramParameter(pname);
@ -924,7 +900,7 @@ WebGLContext::GetProgramInfoLog(const WebGLProgram& prog, nsAString& retval)
if (IsContextLost())
return;
if (!ValidateObjectRef("getProgramInfoLog: program", prog))
if (!ValidateObject("getProgramInfoLog: program", prog))
return;
prog.GetProgramInfoLog(&retval);
@ -937,10 +913,10 @@ WebGLContext::GetUniform(JSContext* js, const WebGLProgram& prog,
if (IsContextLost())
return JS::NullValue();
if (!ValidateObjectRef("getUniform: `program`", prog))
if (!ValidateObject("getUniform: `program`", prog))
return JS::NullValue();
if (!ValidateObjectRef("getUniform: `location`", loc))
if (!ValidateObjectAllowDeleted("getUniform: `location`", loc))
return JS::NullValue();
if (!loc.ValidateForProgram(&prog, "getUniform"))
@ -955,7 +931,7 @@ WebGLContext::GetUniformLocation(const WebGLProgram& prog, const nsAString& name
if (IsContextLost())
return nullptr;
if (!ValidateObjectRef("getUniformLocation: program", prog))
if (!ValidateObject("getUniformLocation: program", prog))
return nullptr;
return prog.GetUniformLocation(name);
@ -995,15 +971,9 @@ WebGLContext::Hint(GLenum target, GLenum mode)
}
bool
WebGLContext::IsFramebuffer(WebGLFramebuffer* fb)
WebGLContext::IsFramebuffer(const WebGLFramebuffer* fb)
{
if (IsContextLost())
return false;
if (!ValidateObjectAllowDeleted("isFramebuffer", fb))
return false;
if (fb->IsDeleted())
if (!ValidateIsObject("isFramebuffer", fb))
return false;
#ifdef ANDROID
@ -1019,37 +989,30 @@ WebGLContext::IsFramebuffer(WebGLFramebuffer* fb)
}
bool
WebGLContext::IsProgram(WebGLProgram* prog)
WebGLContext::IsProgram(const WebGLProgram* prog)
{
if (IsContextLost())
if (!ValidateIsObject("isProgram", prog))
return false;
return ValidateObjectAllowDeleted("isProgram", prog) && !prog->IsDeleted();
return true;
}
bool
WebGLContext::IsRenderbuffer(WebGLRenderbuffer* rb)
WebGLContext::IsRenderbuffer(const WebGLRenderbuffer* rb)
{
if (IsContextLost())
return false;
if (!ValidateObjectAllowDeleted("isRenderBuffer", rb))
return false;
if (rb->IsDeleted())
if (!ValidateIsObject("isRenderbuffer", rb))
return false;
return rb->mHasBeenBound;
}
bool
WebGLContext::IsShader(WebGLShader* shader)
WebGLContext::IsShader(const WebGLShader* shader)
{
if (IsContextLost())
if (!ValidateIsObject("isShader", shader))
return false;
return ValidateObjectAllowDeleted("isShader", shader) &&
!shader->IsDeleted();
return true;
}
void
@ -1058,7 +1021,7 @@ WebGLContext::LinkProgram(WebGLProgram& prog)
if (IsContextLost())
return;
if (!ValidateObjectRef("linkProgram", prog))
if (!ValidateObject("linkProgram", prog))
return;
prog.LinkProgram();
@ -2101,7 +2064,7 @@ WebGLContext::UseProgram(WebGLProgram* prog)
return;
}
if (!ValidateObject("useProgram", prog))
if (!ValidateObject("useProgram", *prog))
return;
if (prog->UseProgram()) {
@ -2116,7 +2079,7 @@ WebGLContext::ValidateProgram(const WebGLProgram& prog)
if (IsContextLost())
return;
if (!ValidateObjectRef("validateProgram", prog))
if (!ValidateObject("validateProgram", prog))
return;
prog.ValidateProgram();
@ -2171,7 +2134,7 @@ WebGLContext::CompileShader(WebGLShader& shader)
if (IsContextLost())
return;
if (!ValidateObjectRef("compileShader", shader))
if (!ValidateObject("compileShader", shader))
return;
shader.CompileShader();
@ -2183,7 +2146,7 @@ WebGLContext::GetShaderParameter(const WebGLShader& shader, GLenum pname)
if (IsContextLost())
return JS::NullValue();
if (!ValidateObjectRef("getShaderParameter: shader", shader))
if (!ValidateObjectAllowDeleted("getShaderParameter: shader", shader))
return JS::NullValue();
return shader.GetShaderParameter(pname);
@ -2197,7 +2160,7 @@ WebGLContext::GetShaderInfoLog(const WebGLShader& shader, nsAString& retval)
if (IsContextLost())
return;
if (!ValidateObjectRef("getShaderInfoLog: shader", shader))
if (!ValidateObject("getShaderInfoLog: shader", shader))
return;
shader.GetShaderInfoLog(&retval);
@ -2259,7 +2222,7 @@ WebGLContext::GetShaderSource(const WebGLShader& shader, nsAString& retval)
if (IsContextLost())
return;
if (!ValidateObjectRef("getShaderSource: shader", shader))
if (!ValidateObject("getShaderSource: shader", shader))
return;
shader.GetShaderSource(&retval);
@ -2271,7 +2234,7 @@ WebGLContext::ShaderSource(WebGLShader& shader, const nsAString& source)
if (IsContextLost())
return;
if (!ValidateObjectRef("shaderSource: shader", shader))
if (!ValidateObject("shaderSource: shader", shader))
return;
shader.ShaderSource(source);

Просмотреть файл

@ -209,7 +209,7 @@ WebGLContext::BindTexture(GLenum rawTarget, WebGLTexture* newTex)
if (IsContextLost())
return;
if (!ValidateObjectAllowDeletedOrNull("bindTexture", newTex))
if (newTex && !ValidateObject("bindTexture", *newTex))
return;
// Need to check rawTarget first before comparing against newTex->Target() as
@ -290,10 +290,7 @@ WebGLContext::GetTexParameter(GLenum rawTexTarget, GLenum pname)
bool
WebGLContext::IsTexture(WebGLTexture* tex)
{
if (IsContextLost())
return false;
if (!ValidateObjectAllowDeleted("isTexture", tex))
if (!ValidateIsObject("isTexture", tex))
return false;
return tex->IsTexture();

Просмотреть файл

@ -207,7 +207,7 @@ WebGLContext::ValidateUniformLocation(WebGLUniformLocation* loc, const char* fun
if (!loc)
return false;
if (!ValidateObject(funcName, loc))
if (!ValidateObjectAllowDeleted(funcName, *loc))
return false;
if (!mCurrentProgram) {

Просмотреть файл

@ -18,20 +18,9 @@ WebGLContext::BindVertexArray(WebGLVertexArray* array)
if (IsContextLost())
return;
if (!ValidateObjectAllowDeletedOrNull("bindVertexArrayObject", array))
if (array && !ValidateObject("bindVertexArrayObject", *array))
return;
if (array && array->IsDeleted()) {
/* http://www.khronos.org/registry/gles/extensions/OES/OES_vertex_array_object.txt
* BindVertexArrayOES fails and an INVALID_OPERATION error is
* generated if array is not a name returned from a previous call to
* GenVertexArraysOES, or if such a name has since been deleted with
* DeleteVertexArraysOES
*/
ErrorInvalidOperation("bindVertexArray: can't bind a deleted array!");
return;
}
InvalidateBufferFetching();
MakeContextCurrent();
@ -68,13 +57,7 @@ WebGLContext::CreateVertexArrayImpl()
void
WebGLContext::DeleteVertexArray(WebGLVertexArray* array)
{
if (IsContextLost())
return;
if (array == nullptr)
return;
if (array->IsDeleted())
if (!ValidateDeleteObject("deleteVertexArray", array))
return;
if (mBoundVertexArray == array)
@ -84,18 +67,9 @@ WebGLContext::DeleteVertexArray(WebGLVertexArray* array)
}
bool
WebGLContext::IsVertexArray(WebGLVertexArray* array)
WebGLContext::IsVertexArray(const WebGLVertexArray* array)
{
if (IsContextLost())
return false;
if (!array)
return false;
if (!ValidateObjectAllowDeleted("isVertexArray", array))
return false;
if (array->IsDeleted())
if (!ValidateIsObject("isVertexArray", array))
return false;
MakeContextCurrent();

Просмотреть файл

@ -38,7 +38,7 @@ WebGLExtensionDebugShaders::GetTranslatedShaderSource(const WebGLShader& shader,
if (mContext->IsContextLost())
return;
if (!mContext->ValidateObjectRef("getShaderTranslatedSource: shader", shader))
if (!mContext->ValidateObject("getShaderTranslatedSource: shader", shader))
return;
shader.GetShaderTranslatedSource(&retval);

Просмотреть файл

@ -83,7 +83,7 @@ WebGLExtensionDisjointTimerQuery::QueryCounterEXT(WebGLQuery& query, GLenum targ
if (mIsLost)
return;
if (!mContext->ValidateObjectRef(funcName, query))
if (!mContext->ValidateObject(funcName, query))
return;
query.QueryCounter(funcName, target);

Просмотреть файл

@ -41,7 +41,7 @@ WebGLExtensionVertexArray::DeleteVertexArrayOES(WebGLVertexArray* array)
}
bool
WebGLExtensionVertexArray::IsVertexArrayOES(WebGLVertexArray* array)
WebGLExtensionVertexArray::IsVertexArrayOES(const WebGLVertexArray* array)
{
if (mIsLost)
return false;

Просмотреть файл

@ -344,7 +344,7 @@ public:
already_AddRefed<WebGLVertexArray> CreateVertexArrayOES();
void DeleteVertexArrayOES(WebGLVertexArray* array);
bool IsVertexArrayOES(WebGLVertexArray* array);
bool IsVertexArrayOES(const WebGLVertexArray* array);
void BindVertexArrayOES(WebGLVertexArray* array);
DECL_WEBGL_EXTENSION_GOOP

Просмотреть файл

@ -604,7 +604,7 @@ WebGLFBAttachPoint::GetParameter(const char* funcName, WebGLContext* webgl, JSCo
// WebGLFramebuffer
WebGLFramebuffer::WebGLFramebuffer(WebGLContext* webgl, GLuint fbo)
: WebGLContextBoundObject(webgl)
: WebGLRefCountedObject(webgl)
, mGLName(fbo)
#ifdef ANDROID
, mIsFB(false)
@ -1301,7 +1301,7 @@ WebGLFramebuffer::FramebufferRenderbuffer(const char* funcName, GLenum attachEnu
}
// `rb`
if (!mContext->ValidateObjectAllowNull("framebufferRenderbuffer: rb", rb))
if (rb && !mContext->ValidateObject("framebufferRenderbuffer: rb", *rb))
return;
// End of validation.
@ -1343,10 +1343,10 @@ WebGLFramebuffer::FramebufferTexture2D(const char* funcName, GLenum attachEnum,
}
// `texture`
if (!mContext->ValidateObjectAllowNull("framebufferTexture2D: texture", tex))
return;
if (tex) {
if (!mContext->ValidateObject("framebufferTexture2D: texture", *tex))
return;
if (!tex->HasEverBeenBound()) {
mContext->ErrorInvalidOperation("%s: `texture` has never been bound.",
funcName);
@ -1419,15 +1419,6 @@ WebGLFramebuffer::FramebufferTextureLayer(const char* funcName, GLenum attachEnu
}
const auto& attach = maybeAttach.value();
// `texture`
if (!mContext->ValidateObjectAllowNull("framebufferTextureLayer: texture", tex))
return;
if (tex && !tex->HasEverBeenBound()) {
mContext->ErrorInvalidOperation("%s: `texture` has never been bound.", funcName);
return;
}
// `level`, `layer`
if (layer < 0)
return mContext->ErrorInvalidValue("%s: `layer` must be >= 0.", funcName);
@ -1435,8 +1426,18 @@ WebGLFramebuffer::FramebufferTextureLayer(const char* funcName, GLenum attachEnu
if (level < 0)
return mContext->ErrorInvalidValue("%s: `level` must be >= 0.", funcName);
// `texture`
TexImageTarget texImageTarget = LOCAL_GL_TEXTURE_3D;
if (tex) {
if (!mContext->ValidateObject("framebufferTextureLayer: texture", *tex))
return;
if (!tex->HasEverBeenBound()) {
mContext->ErrorInvalidOperation("%s: `texture` has never been bound.",
funcName);
return;
}
texImageTarget = tex->Target().get();
switch (texImageTarget.get()) {
case LOCAL_GL_TEXTURE_3D:

Просмотреть файл

@ -132,7 +132,6 @@ class WebGLFramebuffer final
: public nsWrapperCache
, public WebGLRefCountedObject<WebGLFramebuffer>
, public LinkedListElement<WebGLFramebuffer>
, public WebGLContextBoundObject
, public SupportsWeakPtr<WebGLFramebuffer>
{
friend class WebGLContext;

Просмотреть файл

@ -12,8 +12,55 @@
namespace mozilla {
template<typename> class LinkedList;
class WebGLContext;
////
// This class is a mixin for objects that are tied to a specific
// context (which is to say, all of them). They provide initialization
// as well as comparison with the current context.
class WebGLContextBoundObject
{
public:
WebGLContext* const mContext;
private:
const uint32_t mContextGeneration;
public:
explicit WebGLContextBoundObject(WebGLContext* webgl);
bool IsCompatibleWithContext(const WebGLContext* other) const;
};
////
class WebGLDeletableObject : public WebGLContextBoundObject
{
template<typename> friend class WebGLRefCountedObject;
private:
enum DeletionStatus { Default, DeleteRequested, Deleted };
DeletionStatus mDeletionStatus;
////
explicit WebGLDeletableObject(WebGLContext* webgl)
: WebGLContextBoundObject(webgl)
, mDeletionStatus(Default)
{ }
~WebGLDeletableObject() {
MOZ_ASSERT(mDeletionStatus == Deleted,
"Derived class destructor must call DeleteOnce().");
}
public:
bool IsDeleted() const { return mDeletionStatus == Deleted; }
bool IsDeleteRequested() const { return mDeletionStatus != Default; }
};
/* Each WebGL object class WebGLFoo wants to:
* - inherit WebGLRefCountedObject<WebGLFoo>
* - implement a Delete() method
@ -91,22 +138,25 @@ class WebGLContext;
* class, without either method being virtual. This is a common C++ pattern
* known as the "curiously recursive template pattern (CRTP)".
*/
template<typename Derived>
class WebGLRefCountedObject
{
public:
enum DeletionStatus { Default, DeleteRequested, Deleted };
WebGLRefCountedObject()
: mDeletionStatus(Default)
{}
template<typename Derived>
class WebGLRefCountedObject : public WebGLDeletableObject
{
friend class WebGLContext;
template<typename T> friend void ClearLinkedList(LinkedList<T>& list);
private:
nsAutoRefCnt mWebGLRefCnt;
public:
explicit WebGLRefCountedObject(WebGLContext* webgl)
: WebGLDeletableObject(webgl)
{ }
~WebGLRefCountedObject() {
MOZ_ASSERT(mWebGLRefCnt == 0,
"Destroying WebGL object still referenced by other WebGL"
" objects.");
MOZ_ASSERT(mDeletionStatus == Deleted,
"Derived class destructor must call DeleteOnce().");
}
// called by WebGLRefPtr
@ -129,14 +179,7 @@ public:
MaybeDelete();
}
bool IsDeleted() const {
return mDeletionStatus == Deleted;
}
bool IsDeleteRequested() const {
return mDeletionStatus != Default;
}
protected:
void DeleteOnce() {
if (mDeletionStatus != Deleted) {
static_cast<Derived*>(this)->Delete();
@ -152,10 +195,6 @@ private:
DeleteOnce();
}
}
protected:
nsAutoRefCnt mWebGLRefCnt;
DeletionStatus mDeletionStatus;
};
/* This WebGLRefPtr class is meant to be used for references between WebGL
@ -259,21 +298,6 @@ protected:
T* mRawPtr;
};
// This class is a mixin for objects that are tied to a specific
// context (which is to say, all of them). They provide initialization
// as well as comparison with the current context.
class WebGLContextBoundObject
{
public:
explicit WebGLContextBoundObject(WebGLContext* webgl);
bool IsCompatibleWithContext(const WebGLContext* other) const;
WebGLContext* const mContext;
protected:
const uint32_t mContextGeneration;
};
// this class is a mixin for GL objects that have dimensions
// that we need to track.
class WebGLRectangleObject

Просмотреть файл

@ -443,7 +443,7 @@ CreateProgram(gl::GLContext* gl)
}
WebGLProgram::WebGLProgram(WebGLContext* webgl)
: WebGLContextBoundObject(webgl)
: WebGLRefCountedObject(webgl)
, mGLName(CreateProgram(webgl->GL()))
, mNumActiveTFOs(0)
, mNextLink_TransformFeedbackBufferMode(LOCAL_GL_SEPARATE_ATTRIBS)

Просмотреть файл

@ -130,7 +130,6 @@ class WebGLProgram final
: public nsWrapperCache
, public WebGLRefCountedObject<WebGLProgram>
, public LinkedListElement<WebGLProgram>
, public WebGLContextBoundObject
{
friend class WebGLTransformFeedback;

Просмотреть файл

@ -40,7 +40,7 @@ GenQuery(gl::GLContext* gl)
}
WebGLQuery::WebGLQuery(WebGLContext* webgl)
: WebGLContextBoundObject(webgl)
: WebGLRefCountedObject(webgl)
, mGLName(GenQuery(mContext->gl))
, mTarget(0)
, mActiveSlot(nullptr)
@ -211,8 +211,7 @@ WebGLQuery::GetQueryParameter(GLenum pname, JS::MutableHandleValue retval) const
bool
WebGLQuery::IsQuery() const
{
if (IsDeleted())
return false;
MOZ_ASSERT(!IsDeleted());
if (!mTarget)
return false;
@ -223,8 +222,7 @@ WebGLQuery::IsQuery() const
void
WebGLQuery::DeleteQuery()
{
if (IsDeleted())
return;
MOZ_ASSERT(!IsDeleteRequested());
if (mActiveSlot) {
EndQuery();

Просмотреть файл

@ -18,7 +18,6 @@ class WebGLQuery final
: public nsWrapperCache
, public WebGLRefCountedObject<WebGLQuery>
, public LinkedListElement<WebGLQuery>
, public WebGLContextBoundObject
{
friend class AvailableRunnable;
friend class WebGLRefCountedObject<WebGLQuery>;

Просмотреть файл

@ -47,7 +47,7 @@ EmulatePackedDepthStencil(gl::GLContext* gl)
}
WebGLRenderbuffer::WebGLRenderbuffer(WebGLContext* webgl)
: WebGLContextBoundObject(webgl)
: WebGLRefCountedObject(webgl)
, mPrimaryRB( DoCreateRenderbuffer(webgl->gl) )
, mEmulatePackedDepthStencil( EmulatePackedDepthStencil(webgl->gl) )
, mSecondaryRB(0)

Просмотреть файл

@ -23,7 +23,6 @@ class WebGLRenderbuffer final
, public WebGLRefCountedObject<WebGLRenderbuffer>
, public LinkedListElement<WebGLRenderbuffer>
, public WebGLRectangleObject
, public WebGLContextBoundObject
, public WebGLFramebufferAttachable
{
friend class WebGLContext;

Просмотреть файл

@ -12,7 +12,7 @@
namespace mozilla {
WebGLSampler::WebGLSampler(WebGLContext* webgl, GLuint sampler)
: WebGLContextBoundObject(webgl)
: WebGLRefCountedObject(webgl)
, mGLName(sampler)
, mMinFilter(LOCAL_GL_NEAREST_MIPMAP_LINEAR)
, mMagFilter(LOCAL_GL_LINEAR)

Просмотреть файл

@ -17,7 +17,6 @@ class WebGLSampler final
: public nsWrapperCache
, public WebGLRefCountedObject<WebGLSampler>
, public LinkedListElement<WebGLSampler>
, public WebGLContextBoundObject
{
friend class WebGLContext2;
friend class WebGLTexture;

Просмотреть файл

@ -141,7 +141,7 @@ CreateShader(gl::GLContext* gl, GLenum type)
}
WebGLShader::WebGLShader(WebGLContext* webgl, GLenum type)
: WebGLContextBoundObject(webgl)
: WebGLRefCountedObject(webgl)
, mGLName(CreateShader(webgl->GL(), type))
, mType(type)
, mTranslationSuccessful(false)

Просмотреть файл

@ -28,7 +28,6 @@ class WebGLShader final
: public nsWrapperCache
, public WebGLRefCountedObject<WebGLShader>
, public LinkedListElement<WebGLShader>
, public WebGLContextBoundObject
{
friend class WebGLContext;
friend class WebGLProgram;

Просмотреть файл

@ -12,7 +12,7 @@
namespace mozilla {
WebGLSync::WebGLSync(WebGLContext* webgl, GLenum condition, GLbitfield flags)
: WebGLContextBoundObject(webgl)
: WebGLRefCountedObject(webgl)
{
mContext->mSyncs.insertBack(this);
mGLName = mContext->gl->fFenceSync(condition, flags);

Просмотреть файл

@ -16,7 +16,6 @@ class WebGLSync final
: public nsWrapperCache
, public WebGLRefCountedObject<WebGLSync>
, public LinkedListElement<WebGLSync>
, public WebGLContextBoundObject
{
friend class WebGL2Context;

Просмотреть файл

@ -127,7 +127,7 @@ WebGLTexture::WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto) {
}
WebGLTexture::WebGLTexture(WebGLContext* webgl, GLuint tex)
: WebGLContextBoundObject(webgl)
: WebGLRefCountedObject(webgl)
, mGLName(tex)
, mTarget(LOCAL_GL_NONE)
, mFaceCount(0)

Просмотреть файл

@ -57,7 +57,6 @@ class WebGLTexture final
: public nsWrapperCache
, public WebGLRefCountedObject<WebGLTexture>
, public LinkedListElement<WebGLTexture>
, public WebGLContextBoundObject
{
// Friends
friend class WebGLContext;

Просмотреть файл

@ -12,7 +12,7 @@
namespace mozilla {
WebGLTransformFeedback::WebGLTransformFeedback(WebGLContext* webgl, GLuint tf)
: WebGLContextBoundObject(webgl)
: WebGLRefCountedObject(webgl)
, mGLName(tf)
, mIndexedBindings(webgl->mGLMaxTransformFeedbackSeparateAttribs)
, mIsPaused(false)

Просмотреть файл

@ -16,7 +16,6 @@ class WebGLTransformFeedback final
: public nsWrapperCache
, public WebGLRefCountedObject<WebGLTransformFeedback>
, public LinkedListElement<WebGLTransformFeedback>
, public WebGLContextBoundObject
{
friend class ScopedDrawWithTransformFeedback;
friend class WebGLContext;

Просмотреть файл

@ -21,7 +21,7 @@ WebGLVertexArray::WrapObject(JSContext* cx, JS::Handle<JSObject*> givenProto)
}
WebGLVertexArray::WebGLVertexArray(WebGLContext* webgl)
: WebGLContextBoundObject(webgl)
: WebGLRefCountedObject(webgl)
, mGLName(0)
{
mContext->mVertexArrays.insertBack(this);
@ -50,7 +50,7 @@ WebGLVertexArray::Delete()
}
bool
WebGLVertexArray::IsVertexArray()
WebGLVertexArray::IsVertexArray() const
{
return IsVertexArrayImpl();
}

Просмотреть файл

@ -23,7 +23,6 @@ class WebGLVertexArray
: public nsWrapperCache
, public WebGLRefCountedObject<WebGLVertexArray>
, public LinkedListElement<WebGLVertexArray>
, public WebGLContextBoundObject
{
public:
static WebGLVertexArray* Create(WebGLContext* webgl);
@ -44,7 +43,7 @@ public:
// Implement parent classes:
void Delete();
bool IsVertexArray();
bool IsVertexArray() const;
WebGLContext* GetParentObject() const {
return mContext;
@ -67,7 +66,7 @@ protected:
virtual void GenVertexArray() = 0;
virtual void BindVertexArrayImpl() = 0;
virtual void DeleteImpl() = 0;
virtual bool IsVertexArrayImpl() = 0;
virtual bool IsVertexArrayImpl() const = 0;
GLuint mGLName;
nsTArray<WebGLVertexAttribData> mAttribs;

Просмотреть файл

@ -62,7 +62,7 @@ WebGLVertexArrayFake::DeleteImpl()
}
bool
WebGLVertexArrayFake::IsVertexArrayImpl()
WebGLVertexArrayFake::IsVertexArrayImpl() const
{
return mIsVAO;
}

Просмотреть файл

@ -19,7 +19,7 @@ protected:
virtual void BindVertexArrayImpl() override;
virtual void DeleteImpl() override;
virtual void GenVertexArray() override {};
virtual bool IsVertexArrayImpl() override;
virtual bool IsVertexArrayImpl() const override;
private:
explicit WebGLVertexArrayFake(WebGLContext* webgl);

Просмотреть файл

@ -47,7 +47,7 @@ WebGLVertexArrayGL::GenVertexArray()
}
bool
WebGLVertexArrayGL::IsVertexArrayImpl()
WebGLVertexArrayGL::IsVertexArrayImpl() const
{
gl::GLContext* gl = mContext->gl;
if (gl->WorkAroundDriverBugs())

Просмотреть файл

@ -19,7 +19,7 @@ public:
virtual void DeleteImpl() override;
virtual void BindVertexArrayImpl() override;
virtual void GenVertexArray() override;
virtual bool IsVertexArrayImpl() override;
virtual bool IsVertexArrayImpl() const override;
protected:
explicit WebGLVertexArrayGL(WebGLContext* webgl);

Просмотреть файл

@ -9,7 +9,7 @@ TEST_DIRS += [
]
# Change the following line(s) to avoid bug 1081323 (clobber after changing a manifest):
# * Implement ReadPixel with PBOs.
# * Adjust failure errata for webgl-conf.
MOCHITEST_MANIFESTS += [
'test/crash/mochitest.ini',

Просмотреть файл

@ -126,10 +126,10 @@ function runSupportedTest(extensionEnabled) {
function runBindingTestDisabled() {
debug("");
debug("Testing binding enum with extension disabled");
// Use the constant directly as we don't have the extension
var VERTEX_ARRAY_BINDING_OES = 0x85B5;
gl.getParameter(VERTEX_ARRAY_BINDING_OES);
wtu.glErrorShouldBe(gl, gl.INVALID_ENUM, "VERTEX_ARRAY_BINDING_OES should not be queryable if extension is disabled");
}
@ -137,12 +137,12 @@ function runBindingTestDisabled() {
function runBindingTestEnabled() {
debug("");
debug("Testing binding enum with extension enabled");
shouldBe("ext.VERTEX_ARRAY_BINDING_OES", "0x85B5");
gl.getParameter(ext.VERTEX_ARRAY_BINDING_OES);
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "VERTEX_ARRAY_BINDING_OES query should succeed if extension is enabled");
// Default value is null
if (gl.getParameter(ext.VERTEX_ARRAY_BINDING_OES) === null) {
testPassed("Default value of VERTEX_ARRAY_BINDING_OES is null");
@ -179,20 +179,20 @@ function runBindingTestEnabled() {
function runObjectTest() {
debug("");
debug("Testing object creation");
vao = ext.createVertexArrayOES();
wtu.glErrorShouldBe(gl, gl.NO_ERROR, "createVertexArrayOES should not set an error");
shouldBeNonNull("vao");
// Expect false if never bound
shouldBeFalse("ext.isVertexArrayOES(vao)");
ext.bindVertexArrayOES(vao);
shouldBeTrue("ext.isVertexArrayOES(vao)");
ext.bindVertexArrayOES(null);
shouldBeTrue("ext.isVertexArrayOES(vao)");
shouldBeFalse("ext.isVertexArrayOES(null)");
ext.deleteVertexArrayOES(vao);
vao = null;
}
@ -200,57 +200,57 @@ function runObjectTest() {
function runAttributeTests() {
debug("");
debug("Testing attributes work across bindings");
var states = [];
var attrCount = gl.getParameter(gl.MAX_VERTEX_ATTRIBS);
for (var n = 0; n < attrCount; n++) {
gl.bindBuffer(gl.ARRAY_BUFFER, null);
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
var state = {};
states.push(state);
var vao = state.vao = ext.createVertexArrayOES();
ext.bindVertexArrayOES(vao);
var enableArray = (n % 2 == 0);
if (enableArray) {
gl.enableVertexAttribArray(n);
} else {
gl.disableVertexAttribArray(n);
}
if (enableArray) {
var buffer = state.buffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
gl.bufferData(gl.ARRAY_BUFFER, 1024, gl.STATIC_DRAW);
gl.vertexAttribPointer(n, 1 + n % 4, gl.FLOAT, true, n * 4, n * 4);
}
if (enableArray) {
var elbuffer = state.elbuffer = gl.createBuffer();
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, elbuffer);
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, 1024, gl.STATIC_DRAW);
}
ext.bindVertexArrayOES(null);
}
var anyMismatch = false;
for (var n = 0; n < attrCount; n++) {
var state = states[n];
ext.bindVertexArrayOES(state.vao);
var shouldBeEnabled = (n % 2 == 0);
var isEnabled = gl.getVertexAttrib(n, gl.VERTEX_ATTRIB_ARRAY_ENABLED);
if (shouldBeEnabled != isEnabled) {
testFailed("VERTEX_ATTRIB_ARRAY_ENABLED not preserved");
anyMismatch = true;
}
var buffer = gl.getVertexAttrib(n, gl.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING);
if (shouldBeEnabled) {
if (buffer == state.buffer) {
@ -276,7 +276,7 @@ function runAttributeTests() {
anyMismatch = true;
}
}
var elbuffer = gl.getParameter(gl.ELEMENT_ARRAY_BUFFER_BINDING);
if (shouldBeEnabled) {
if (elbuffer == state.elbuffer) {
@ -298,7 +298,7 @@ function runAttributeTests() {
if (!anyMismatch) {
testPassed("All attributes preserved across bindings");
}
for (var n = 0; n < attrCount; n++) {
var state = states[n];
ext.deleteVertexArrayOES(state.vao);
@ -308,41 +308,41 @@ function runAttributeTests() {
function runAttributeValueTests() {
debug("");
debug("Testing that attribute values are not attached to bindings");
var v;
var vao0 = ext.createVertexArrayOES();
var anyFailed = false;
ext.bindVertexArrayOES(null);
gl.vertexAttrib4f(0, 0, 1, 2, 3);
v = gl.getVertexAttrib(0, gl.CURRENT_VERTEX_ATTRIB);
if (!(v[0] == 0 && v[1] == 1 && v[2] == 2 && v[3] == 3)) {
testFailed("Vertex attrib value not round-tripped?");
anyFailed = true;
}
ext.bindVertexArrayOES(vao0);
v = gl.getVertexAttrib(0, gl.CURRENT_VERTEX_ATTRIB);
if (!(v[0] == 0 && v[1] == 1 && v[2] == 2 && v[3] == 3)) {
testFailed("Vertex attrib value reset across bindings");
anyFailed = true;
}
gl.vertexAttrib4f(0, 4, 5, 6, 7);
ext.bindVertexArrayOES(null);
v = gl.getVertexAttrib(0, gl.CURRENT_VERTEX_ATTRIB);
if (!(v[0] == 4 && v[1] == 5 && v[2] == 6 && v[3] == 7)) {
testFailed("Vertex attrib value bound to buffer");
anyFailed = true;
}
if (!anyFailed) {
testPassed("Vertex attribute values are not attached to bindings")
}
ext.bindVertexArrayOES(null);
ext.deleteVertexArrayOES(vao0);
}
@ -350,19 +350,19 @@ function runAttributeValueTests() {
function runDrawTests() {
debug("");
debug("Testing draws with various VAO bindings");
canvas.width = 50; canvas.height = 50;
gl.viewport(0, 0, canvas.width, canvas.height);
var vao0 = ext.createVertexArrayOES();
var vao1 = ext.createVertexArrayOES();
var vao2 = ext.createVertexArrayOES();
var positionLocation = 0;
var colorLocation = 1;
var program = wtu.setupSimpleVertexColorProgram(gl, positionLocation, colorLocation);
function setupQuad(s, colorsInArray) {
var vertexObject = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
@ -393,7 +393,7 @@ function runDrawTests() {
gl.disableVertexAttribArray(colorLocation);
}
};
function verifyDiagonalPixels(s, expectedInside, drawDescription) {
// Tests pixels along a diagonal running from the center of the canvas to the (0, 0) corner.
// Values on the points list indicate relative position along this diagonal.
@ -411,7 +411,7 @@ function runDrawTests() {
var expectedInside = colorsInArray ? 0 : 128;
verifyDiagonalPixels(s, expectedInside, drawDescription);
};
// Setup all bindings
setupQuad(1, true);
ext.bindVertexArrayOES(vao0);
@ -422,7 +422,7 @@ function runDrawTests() {
setupQuad(0.75, false);
gl.vertexAttrib4f(colorLocation, 0.5, 0.5, 0.5, 1);
// Verify drawing
ext.bindVertexArrayOES(null);
verifyDraw("with the default VAO", 1, true);
@ -624,25 +624,31 @@ function runBoundDeleteTests() {
gl.deleteBuffer(colorBuffer);
gl.deleteBuffer(positionBuffer);
// The buffers should not be accessible at this point. Deleted objects that are bound
// in the current context undergo an automatic unbinding
var expectRetained = (ii != 0);
var shouldBeStr = (expectRetained ? "retained" : "cleared");
var boundPositionBuffer = gl.getVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING);
if(boundPositionBuffer == positionBuffer) {
testFailed("Position buffer should be automatically unbound when deleted");
if (expectRetained != (boundPositionBuffer == positionBuffer)) {
testFailed("Position attrib stored buffer should be " + shouldBeStr + ".");
}
var boundColorBuffer = gl.getVertexAttrib(1, gl.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING);
if(boundColorBuffer == colorBuffer) {
testFailed("Color buffer should be automatically unbound when deleted");
if (expectRetained != (boundColorBuffer == colorBuffer)) {
testFailed("Color attrib stored buffer should be " + shouldBeStr + ".");
}
// If retained, everything should still work. If cleared, drawing should now fail.
gl.drawElements(gl.TRIANGLES, 6, gl.UNSIGNED_BYTE, 0);
wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "Draw call should fail with unbound position and color buffers");
var expectedError = (expectRetained ? gl.NO_ERROR : gl.INVALID_OPERATION);
wtu.glErrorShouldBe(gl, expectedError,
"Draw call should " + (expectRetained ? "not " : "") + "fail.");
var isPositionBuffer = gl.isBuffer(positionBuffer);
var isColorBuffer = gl.isBuffer(colorBuffer);
if(isPositionBuffer) testFailed("Position buffer should no longer exist after last ref removed");
if(isColorBuffer) testFailed("Color buffer should no longer exist after last ref removed");
if (!gl.isBuffer(positionBuffer)) {
testFailed("Position buffer should count for isBuffer.");
}
if (!gl.isBuffer(colorBuffer)) {
testFailed("Color buffer should count for isBuffer.");
}
}
}

Просмотреть файл

@ -6028,7 +6028,6 @@ fail-if = (os == 'mac') || (os == 'win') || (os == 'android') || (os == 'linux')
[generated/test_conformance__extensions__oes-vertex-array-object-bufferData.html]
[generated/test_conformance__extensions__oes-vertex-array-object.html]
skip-if = (os == 'mac' && os_version == '10.6')
fail-if = (os == 'win') || (os == 'mac') || (os == 'android') || (os == 'linux')
[generated/test_conformance__extensions__webgl-compressed-texture-atc.html]
[generated/test_conformance__extensions__webgl-compressed-texture-pvrtc.html]
[generated/test_conformance__extensions__webgl-compressed-texture-s3tc.html]

Просмотреть файл

@ -129,7 +129,6 @@ skip-if = (os == 'android' && debug)
# 10.6 crash:
# PROCESS-CRASH | dom/canvas/test/webgl-conf/generated/test_conformance__extensions__oes-vertex-array-object.html | application crashed [@ gleRunVertexSubmitImmediate + 0xf24]
skip-if = (os == 'mac' && os_version == '10.6')
fail-if = (os == 'win') || (os == 'mac') || (os == 'android') || (os == 'linux')
[generated/test_conformance__textures__misc__texture-size.html]
# application crashed [@ mozilla::gl::GLContext::AfterGLCall]
skip-if = (os == 'android') || (os == 'win')

Просмотреть файл

@ -200,7 +200,8 @@ public:
if (track) {
LOG(LogLevel::Debug, ("DOMMediaStream %p MediaStreamTrack %p ended at the source. Marking it ended.",
mStream, track.get()));
track->OverrideEnded();
NS_DispatchToMainThread(NewRunnableMethod(
track, &MediaStreamTrack::OverrideEnded));
}
}
@ -270,7 +271,8 @@ public:
return;
}
mStream->NotifyFinished();
NS_DispatchToMainThread(NewRunnableMethod(
mStream, &DOMMediaStream::NotifyFinished));
}
// The methods below are called on the MediaStreamGraph thread.

Просмотреть файл

@ -1230,10 +1230,10 @@ public:
// We won't need mOnFailure now.
mOnFailure = nullptr;
if (!MediaManager::IsPrivateBrowsing(window)) {
if (!OriginAttributes::IsPrivateBrowsing(mOrigin)) {
// Call GetOriginKey again, this time w/persist = true, to promote
// deviceIds to persistent, in case they're not already. Fire'n'forget.
RefPtr<Pledge<nsCString>> p = media::GetOriginKey(mOrigin, false, true);
RefPtr<Pledge<nsCString>> p = media::GetOriginKey(mOrigin, true);
}
return NS_OK;
}
@ -1934,13 +1934,6 @@ MediaManager::NotifyRecordingStatusChange(nsPIDOMWindowInner* aWindow,
return NS_OK;
}
bool MediaManager::IsPrivateBrowsing(nsPIDOMWindowInner* window)
{
nsCOMPtr<nsIDocument> doc = window->GetDoc();
nsCOMPtr<nsILoadContext> loadContext = doc->GetLoadContext();
return loadContext && loadContext->UsePrivateBrowsing();
}
int MediaManager::AddDeviceChangeCallback(DeviceChangeCallback* aCallback)
{
bool fakeDeviceChangeEventOn = mPrefs.mFakeDeviceChangeEventOn;
@ -2497,7 +2490,6 @@ MediaManager::EnumerateDevicesImpl(uint64_t aWindowId,
// 2. Get the raw devices list
// 3. Anonymize the raw list with the origin-key.
bool privateBrowsing = IsPrivateBrowsing(window);
nsCOMPtr<nsIPrincipal> principal =
nsGlobalWindow::Cast(window)->GetPrincipal();
MOZ_ASSERT(principal);
@ -2512,8 +2504,7 @@ MediaManager::EnumerateDevicesImpl(uint64_t aWindowId,
// thread later once GetOriginKey resolves. Needed variables are "captured"
// (passed by value) safely into the lambda.
RefPtr<Pledge<nsCString>> p = media::GetOriginKey(origin, privateBrowsing,
persist);
RefPtr<Pledge<nsCString>> p = media::GetOriginKey(origin, persist);
p->Then([id, aWindowId, aVideoType, aAudioType,
aFake](const nsCString& aOriginKey) mutable {
MOZ_ASSERT(NS_IsMainThread());

Просмотреть файл

@ -257,7 +257,6 @@ public:
MediaEnginePrefs mPrefs;
typedef nsTArray<RefPtr<MediaDevice>> SourceSet;
static bool IsPrivateBrowsing(nsPIDOMWindowInner* window);
virtual int AddDeviceChangeCallback(DeviceChangeCallback* aCallback) override;
virtual void OnDeviceChange() override;

Просмотреть файл

@ -95,8 +95,7 @@ public:
virtual void Init(PromiseId aPromiseId,
const nsAString& aOrigin,
const nsAString& aTopLevelOrigin,
const nsAString& aName,
bool aInPrivateBrowsing) = 0;
const nsAString& aName) = 0;
virtual void OnSetDecryptorId(uint32_t aId) {}

Просмотреть файл

@ -409,14 +409,10 @@ MediaKeys::Init(ErrorResult& aRv)
return promise.forget();
}
nsIDocument* doc = window->GetExtantDoc();
const bool inPrivateBrowsing = nsContentUtils::IsInPrivateBrowsing(doc);
EME_LOG("MediaKeys[%p]::Create() (%s, %s), %s",
EME_LOG("MediaKeys[%p]::Create() (%s, %s)",
this,
origin.get(),
topLevelOrigin.get(),
(inPrivateBrowsing ? "PrivateBrowsing" : "NonPrivateBrowsing"));
topLevelOrigin.get());
// The CDMProxy's initialization is asynchronous. The MediaKeys is
// refcounted, and its instance is returned to JS by promise once
@ -432,8 +428,7 @@ MediaKeys::Init(ErrorResult& aRv)
mProxy->Init(mCreatePromiseId,
NS_ConvertUTF8toUTF16(origin),
NS_ConvertUTF8toUTF16(topLevelOrigin),
KeySystemToGMPName(mKeySystem),
inPrivateBrowsing);
KeySystemToGMPName(mKeySystem));
return promise.forget();
}

Просмотреть файл

@ -46,16 +46,14 @@ void
MediaDrmCDMProxy::Init(PromiseId aPromiseId,
const nsAString& aOrigin,
const nsAString& aTopLevelOrigin,
const nsAString& aName,
bool aInPrivateBrowsing)
const nsAString& aName)
{
MOZ_ASSERT(NS_IsMainThread());
NS_ENSURE_TRUE_VOID(!mKeys.IsNull());
EME_LOG("MediaDrmCDMProxy::Init (%s, %s) %s",
NS_ConvertUTF16toUTF8(aOrigin).get(),
NS_ConvertUTF16toUTF8(aTopLevelOrigin).get(),
(aInPrivateBrowsing ? "PrivateBrowsing" : "NonPrivateBrowsing"));
NS_ConvertUTF16toUTF8(aTopLevelOrigin).get());
// Create a thread to work with cdm.
if (!mOwnerThread) {

Просмотреть файл

@ -37,8 +37,7 @@ public:
void Init(PromiseId aPromiseId,
const nsAString& aOrigin,
const nsAString& aTopLevelOrigin,
const nsAString& aGMPName,
bool aInPrivateBrowsing) override;
const nsAString& aGMPName) override;
void CreateSession(uint32_t aCreateSessionToken,
MediaKeySessionType aSessionType,

Просмотреть файл

@ -54,16 +54,14 @@ void
GMPCDMProxy::Init(PromiseId aPromiseId,
const nsAString& aOrigin,
const nsAString& aTopLevelOrigin,
const nsAString& aGMPName,
bool aInPrivateBrowsing)
const nsAString& aGMPName)
{
MOZ_ASSERT(NS_IsMainThread());
NS_ENSURE_TRUE_VOID(!mKeys.IsNull());
EME_LOG("GMPCDMProxy::Init (%s, %s) %s",
EME_LOG("GMPCDMProxy::Init (%s, %s)",
NS_ConvertUTF16toUTF8(aOrigin).get(),
NS_ConvertUTF16toUTF8(aTopLevelOrigin).get(),
(aInPrivateBrowsing ? "PrivateBrowsing" : "NonPrivateBrowsing"));
NS_ConvertUTF16toUTF8(aTopLevelOrigin).get());
nsCString pluginVersion;
if (!mOwnerThread) {
@ -93,7 +91,6 @@ GMPCDMProxy::Init(PromiseId aPromiseId,
data->mOrigin = aOrigin;
data->mTopLevelOrigin = aTopLevelOrigin;
data->mGMPName = aGMPName;
data->mInPrivateBrowsing = aInPrivateBrowsing;
data->mCrashHelper = mCrashHelper;
nsCOMPtr<nsIRunnable> task(
NewRunnableMethod<UniquePtr<InitData>&&>(this,
@ -210,7 +207,6 @@ GMPCDMProxy::gmp_Init(UniquePtr<InitData>&& aData)
nsresult rv = mps->GetNodeId(data.mOrigin,
data.mTopLevelOrigin,
data.mGMPName,
data.mInPrivateBrowsing,
Move(callback));
if (NS_FAILED(rv)) {
RejectPromise(data.mPromiseId, NS_ERROR_DOM_INVALID_STATE_ERR,
@ -241,10 +237,9 @@ GMPCDMProxy::gmp_InitGetGMPDecryptor(nsresult aResult,
return;
}
EME_LOG("GMPCDMProxy::gmp_Init (%s, %s) %s NodeId=%s",
EME_LOG("GMPCDMProxy::gmp_Init (%s, %s) NodeId=%s",
NS_ConvertUTF16toUTF8(aData->mOrigin).get(),
NS_ConvertUTF16toUTF8(aData->mTopLevelOrigin).get(),
(aData->mInPrivateBrowsing ? "PrivateBrowsing" : "NonPrivateBrowsing"),
GetNodeId().get());
nsTArray<nsCString> tags;

Просмотреть файл

@ -31,8 +31,7 @@ public:
void Init(PromiseId aPromiseId,
const nsAString& aOrigin,
const nsAString& aTopLevelOrigin,
const nsAString& aGMPName,
bool aInPrivateBrowsing) override;
const nsAString& aGMPName) override;
void OnSetDecryptorId(uint32_t aId) override;
@ -123,7 +122,6 @@ private:
nsString mTopLevelOrigin;
nsString mGMPName;
RefPtr<GMPCrashHelper> mCrashHelper;
bool mInPrivateBrowsing;
};
// GMP thread only.

Просмотреть файл

@ -235,7 +235,6 @@ NS_IMETHODIMP
GeckoMediaPluginServiceChild::GetNodeId(const nsAString& aOrigin,
const nsAString& aTopLevelOrigin,
const nsAString& aGMPName,
bool aInPrivateBrowsing,
UniquePtr<GetNodeIdCallback>&& aCallback)
{
MOZ_ASSERT(NS_GetCurrentThread() == mGMPThread);
@ -245,14 +244,12 @@ GeckoMediaPluginServiceChild::GetNodeId(const nsAString& aOrigin,
nsString origin(aOrigin);
nsString topLevelOrigin(aTopLevelOrigin);
nsString gmpName(aGMPName);
bool pb = aInPrivateBrowsing;
GetServiceChild()->Then(thread, __func__,
[rawCallback, origin, topLevelOrigin, gmpName, pb](GMPServiceChild* child) {
[rawCallback, origin, topLevelOrigin, gmpName](GMPServiceChild* child) {
UniquePtr<GetNodeIdCallback> callback(rawCallback);
nsCString outId;
if (!child->SendGetGMPNodeId(origin, topLevelOrigin,
gmpName,
pb, &outId)) {
gmpName, &outId)) {
callback->Done(NS_ERROR_FAILURE, EmptyCString());
return;
}

Просмотреть файл

@ -32,7 +32,6 @@ public:
NS_IMETHOD GetNodeId(const nsAString& aOrigin,
const nsAString& aTopLevelOrigin,
const nsAString& aGMPName,
bool aInPrivateBrowsingMode,
UniquePtr<GetNodeIdCallback>&& aCallback) override;
NS_DECL_NSIOBSERVER

Просмотреть файл

@ -1388,14 +1388,12 @@ nsresult
GeckoMediaPluginServiceParent::GetNodeId(const nsAString& aOrigin,
const nsAString& aTopLevelOrigin,
const nsAString& aGMPName,
bool aInPrivateBrowsing,
nsACString& aOutId)
{
MOZ_ASSERT(NS_GetCurrentThread() == mGMPThread);
LOGD(("%s::%s: (%s, %s), %s", __CLASS__, __FUNCTION__,
LOGD(("%s::%s: (%s, %s)", __CLASS__, __FUNCTION__,
NS_ConvertUTF16toUTF8(aOrigin).get(),
NS_ConvertUTF16toUTF8(aTopLevelOrigin).get(),
(aInPrivateBrowsing ? "PrivateBrowsing" : "NonPrivateBrowsing")));
NS_ConvertUTF16toUTF8(aTopLevelOrigin).get()));
nsresult rv;
@ -1421,7 +1419,7 @@ GeckoMediaPluginServiceParent::GetNodeId(const nsAString& aOrigin,
const uint32_t hash = AddToHash(HashString(aOrigin),
HashString(aTopLevelOrigin));
if (aInPrivateBrowsing) {
if (OriginAttributes::IsPrivateBrowsing(NS_ConvertUTF16toUTF8(aOrigin))) {
// For PB mode, we store the node id, indexed by the origin pair and GMP name,
// so that if the same origin pair is opened for the same GMP in this session,
// it gets the same node id.
@ -1551,11 +1549,10 @@ NS_IMETHODIMP
GeckoMediaPluginServiceParent::GetNodeId(const nsAString& aOrigin,
const nsAString& aTopLevelOrigin,
const nsAString& aGMPName,
bool aInPrivateBrowsing,
UniquePtr<GetNodeIdCallback>&& aCallback)
{
nsCString nodeId;
nsresult rv = GetNodeId(aOrigin, aTopLevelOrigin, aGMPName, aInPrivateBrowsing, nodeId);
nsresult rv = GetNodeId(aOrigin, aTopLevelOrigin, aGMPName, nodeId);
aCallback->Done(rv, nodeId);
return rv;
}
@ -2010,11 +2007,9 @@ mozilla::ipc::IPCResult
GMPServiceParent::RecvGetGMPNodeId(const nsString& aOrigin,
const nsString& aTopLevelOrigin,
const nsString& aGMPName,
const bool& aInPrivateBrowsing,
nsCString* aID)
{
nsresult rv = mService->GetNodeId(aOrigin, aTopLevelOrigin, aGMPName,
aInPrivateBrowsing, *aID);
nsresult rv = mService->GetNodeId(aOrigin, aTopLevelOrigin, aGMPName, *aID);
if (!NS_SUCCEEDED(rv)) {
return IPC_FAIL_NO_REASON(this);
}

Просмотреть файл

@ -44,7 +44,6 @@ public:
NS_IMETHOD GetNodeId(const nsAString& aOrigin,
const nsAString& aTopLevelOrigin,
const nsAString& aGMPName,
bool aInPrivateBrowsingMode,
UniquePtr<GetNodeIdCallback>&& aCallback) override;
NS_DECL_MOZIGECKOMEDIAPLUGINCHROMESERVICE
@ -90,8 +89,7 @@ private:
size_t* aOutPluginIndex);
nsresult GetNodeId(const nsAString& aOrigin, const nsAString& aTopLevelOrigin,
const nsAString& aGMPName,
bool aInPrivateBrowsing, nsACString& aOutId);
const nsAString& aGMPName, nsACString& aOutId);
void UnloadPlugins();
void CrashPlugins();
@ -250,7 +248,6 @@ public:
mozilla::ipc::IPCResult RecvGetGMPNodeId(const nsString& aOrigin,
const nsString& aTopLevelOrigin,
const nsString& aGMPName,
const bool& aInPrivateBrowsing,
nsCString* aID) override;
void ActorDestroy(ActorDestroyReason aWhy) override;

Просмотреть файл

@ -22,9 +22,7 @@ parent:
ProcessId[] alreadyBridgedTo)
returns (uint32_t pluginId, ProcessId id, nsCString displayName, nsresult aResult);
sync GetGMPNodeId(nsString origin, nsString topLevelOrigin,
nsString gmpName,
bool inPrivateBrowsing)
sync GetGMPNodeId(nsString origin, nsString topLevelOrigin, nsString gmpName)
returns (nsCString id);
};

Просмотреть файл

@ -161,12 +161,11 @@ interface mozIGeckoMediaPluginService : nsISupports
in GetGMPDecryptorCallback callback);
/**
* Gets the NodeId for a (origin, urlbarOrigin, isInprivateBrowsing) tuple.
* Gets the NodeId for a (origin, urlbarOrigin) pair.
*/
[noscript]
void getNodeId(in AString origin,
in AString topLevelOrigin,
in AString gmpName,
in bool inPrivateBrowsingMode,
in GetNodeIdCallback callback);
};

Просмотреть файл

@ -473,12 +473,26 @@ GetNodeId(const nsAString& aOrigin,
nsresult result;
UniquePtr<GetNodeIdCallback> callback(new TestGetNodeIdCallback(nodeId,
result));
PrincipalOriginAttributes attrs;
attrs.mPrivateBrowsingId = aInPBMode ? 1 : 0;
nsAutoCString suffix;
attrs.CreateSuffix(suffix);
nsAutoString origin;
origin.Assign(aOrigin);
origin.Append(NS_ConvertUTF8toUTF16(suffix));
nsAutoString topLevelOrigin;
topLevelOrigin.Assign(aTopLevelOrigin);
topLevelOrigin.Append(NS_ConvertUTF8toUTF16(suffix));
// We rely on the fact that the GetNodeId implementation for
// GeckoMediaPluginServiceParent is synchronous.
nsresult rv = service->GetNodeId(aOrigin,
aTopLevelOrigin,
nsresult rv = service->GetNodeId(origin,
topLevelOrigin,
NS_LITERAL_STRING("gmp-fake"),
aInPBMode,
Move(callback));
EXPECT_TRUE(NS_SUCCEEDED(rv) && NS_SUCCEEDED(result));
return nodeId;

Просмотреть файл

@ -20,7 +20,7 @@ namespace mozilla {
namespace media {
already_AddRefed<Pledge<nsCString>>
GetOriginKey(const nsCString& aOrigin, bool aPrivateBrowsing, bool aPersist)
GetOriginKey(const nsCString& aOrigin, bool aPersist)
{
RefPtr<MediaManager> mgr = MediaManager::GetInstance();
MOZ_ASSERT(mgr);
@ -29,10 +29,9 @@ GetOriginKey(const nsCString& aOrigin, bool aPrivateBrowsing, bool aPersist)
uint32_t id = mgr->mGetOriginKeyPledges.Append(*p);
if (XRE_GetProcessType() == GeckoProcessType_Default) {
mgr->GetNonE10sParent()->RecvGetOriginKey(id, aOrigin, aPrivateBrowsing,
aPersist);
mgr->GetNonE10sParent()->RecvGetOriginKey(id, aOrigin, aPersist);
} else {
Child::Get()->SendGetOriginKey(id, aOrigin, aPrivateBrowsing, aPersist);
Child::Get()->SendGetOriginKey(id, aOrigin, aPersist);
}
return p.forget();
}

Просмотреть файл

@ -25,7 +25,7 @@ namespace media {
// (promise-like objects) with the future value. Use pledge.Then(func) to access.
already_AddRefed<Pledge<nsCString>>
GetOriginKey(const nsCString& aOrigin, bool aPrivateBrowsing, bool aPersist);
GetOriginKey(const nsCString& aOrigin, bool aPersist);
void
SanitizeOriginKeys(const uint64_t& aSinceWhen, bool aOnlyPrivateBrowsing);

Просмотреть файл

@ -369,7 +369,6 @@ bool NonE10s::SendGetOriginKeyResponse(const uint32_t& aRequestId,
template<class Super> mozilla::ipc::IPCResult
Parent<Super>::RecvGetOriginKey(const uint32_t& aRequestId,
const nsCString& aOrigin,
const bool& aPrivateBrowsing,
const bool& aPersist)
{
MOZ_ASSERT(NS_IsMainThread());
@ -395,11 +394,12 @@ Parent<Super>::RecvGetOriginKey(const uint32_t& aRequestId,
RefPtr<Parent<Super>> that(this);
rv = sts->Dispatch(NewRunnableFrom([this, that, id, profileDir, aOrigin,
aPrivateBrowsing, aPersist]() -> nsresult {
aPersist]() -> nsresult {
MOZ_ASSERT(!NS_IsMainThread());
mOriginKeyStore->mOriginKeys.SetProfileDir(profileDir);
nsCString result;
if (aPrivateBrowsing) {
nsAutoCString result;
if (OriginAttributes::IsPrivateBrowsing(aOrigin)) {
mOriginKeyStore->mPrivateBrowsingOriginKeys.GetOriginKey(aOrigin, result);
} else {
mOriginKeyStore->mOriginKeys.GetOriginKey(aOrigin, result, aPersist);

Просмотреть файл

@ -29,7 +29,6 @@ public:
protected:
virtual mozilla::ipc::IPCResult RecvGetOriginKey(const uint32_t& aRequestId,
const nsCString& aOrigin,
const bool& aPrivateBrowsing,
const bool& aPersist) = 0;
virtual mozilla::ipc::IPCResult RecvSanitizeOriginKeys(const uint64_t& aSinceWhen,
const bool& aOnlyPrivateBrowsing) = 0;
@ -52,7 +51,6 @@ public:
virtual mozilla::ipc::IPCResult RecvGetOriginKey(const uint32_t& aRequestId,
const nsCString& aOrigin,
const bool& aPrivateBrowsing,
const bool& aPersist) override;
virtual mozilla::ipc::IPCResult RecvSanitizeOriginKeys(const uint64_t& aSinceWhen,
const bool& aOnlyPrivateBrowsing) override;

Просмотреть файл

@ -18,18 +18,19 @@ parent:
* This is needed by mediaDevices.enumerateDevices() to produce persistent
* deviceIds that wont work cross-origin.
*
* If aPrivateBrowsing is false, a key for this origin is returned from a
* primary pool of temporal in-memory keys and persistent keys read from disk.
* If no key exists, a temporal one is created.
* The origin string must contain the OriginAttributes suffix.
* If this OriginAttributes dictionary has the privateBrowsing flag set to
* false, a key for this origin is returned from a primary pool of temporal
* in-memory keys and persistent keys read from disk. If no key exists, a
* temporal one is created.
* If aPersist is true and key is temporal, the key is promoted to persistent.
* Once persistent, a key cannot become temporal again.
*
* If aPrivateBrowsing is true, a different key for this origin is returned
* from a secondary pool that is never persisted to disk, and aPersist is
* ignored.
* If the OriginAttributes dictionary has the privateBrowsing flag set to
* true, a different key for this origin is returned from a secondary pool
* that is never persisted to disk, and aPersist is ignored.
*/
async GetOriginKey(uint32_t aRequestId, nsCString aOrigin, bool aPrivateBrowsing,
bool aPersist);
async GetOriginKey(uint32_t aRequestId, nsCString aOrigin, bool aPersist);
/**
* Clear per-orgin list of persistent deviceIds stored for enumerateDevices

Просмотреть файл

@ -329,20 +329,22 @@ MediaEngineTabVideoSource::Draw() {
RefPtr<layers::ImageContainer> container =
layers::LayerManager::CreateImageContainer(layers::ImageContainer::ASYNCHRONOUS);
RefPtr<DrawTarget> dt =
Factory::CreateDrawTargetForData(BackendType::CAIRO,
Factory::CreateDrawTargetForData(gfxPlatform::GetPlatform()->GetSoftwareBackend(),
mData.get(),
size,
stride,
SurfaceFormat::B8G8R8X8);
SurfaceFormat::B8G8R8X8,
true);
if (!dt || !dt->IsValid()) {
return;
}
RefPtr<gfxContext> context = gfxContext::CreateOrNull(dt);
MOZ_ASSERT(context); // already checked the draw target above
context->SetMatrix(context->CurrentMatrix().Scale((((float) size.width)/mViewportWidth),
(((float) size.height)/mViewportHeight)));
if (mWindow) {
RefPtr<gfxContext> context = gfxContext::CreateOrNull(dt);
MOZ_ASSERT(context); // already checked the draw target above
context->SetMatrix(context->CurrentMatrix().Scale((((float) size.width)/mViewportWidth),
(((float) size.height)/mViewportHeight)));
nscolor bgColor = NS_RGB(255, 255, 255);
uint32_t renderDocFlags = mScrollWithPage? 0 :
(nsIPresShell::RENDER_IGNORE_VIEWPORT_SCROLLING |
@ -352,6 +354,8 @@ MediaEngineTabVideoSource::Draw() {
nsPresContext::CSSPixelsToAppUnits((float)mViewportWidth),
nsPresContext::CSSPixelsToAppUnits((float)mViewportHeight));
NS_ENSURE_SUCCESS_VOID(presShell->RenderDocument(r, renderDocFlags, bgColor, context));
} else {
dt->ClearRect(Rect(0, 0, size.width, size.height));
}
RefPtr<SourceSurface> surface = dt->Snapshot();

Просмотреть файл

@ -18,3 +18,4 @@ support-files =
[test_worker_url_exceptions.html]
[test_worker_urlSearchParams.html]
[test_unknown_url_origin.html]
[test_bloburl_location.html]

Просмотреть файл

@ -0,0 +1,31 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Test for blobURL in location</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<script type="application/javascript">
var expectedData = null;
onmessage = function(e) {
if (expectedData === null) {
expectedData = e.data;
} else {
is(e.data, expectedData, "Pathname should be not be changed");
SimpleTest.finish();
}
}
var ifr = document.createElement('iframe');
document.body.appendChild(ifr);
ifr.src = "data:html,<script>location=URL.createObjectURL(new%20Blob(['<script>parent.postMessage(location.pathname,\"*\");location.pathname=\"foo\";parent.postMessage(location.pathname,\"*\");<\/s' +'cript>'], {type:\"text/html\"}));<\/script>";
SimpleTest.waitForExplicitFinish();
</script>
</body>
</html>

Просмотреть файл

@ -68,10 +68,11 @@ partial interface KeyframeEffectReadOnly {
Constructor (KeyframeEffectReadOnly source)]
interface KeyframeEffect : KeyframeEffectReadOnly {
inherit attribute (Element or CSSPseudoElement)? target;
[NeedsCallerType]
inherit attribute IterationCompositeOperation iterationComposite;
// Bug 1216844 - implement additive animation
// inherit attribute CompositeOperation composite;
[SetterThrows]
[SetterThrows, NeedsCallerType]
inherit attribute DOMString spacing;
[Throws]
void setKeyframes (object? keyframes);

Просмотреть файл

@ -504,8 +504,7 @@ nsWindowWatcher::CreateChromeWindow(const nsACString& aFeatures,
nsCOMPtr<nsIWebBrowserChrome> newWindowChrome;
nsresult rv =
windowCreator2->CreateChromeWindow2(aParentChrome, aChromeFlags,
0 /* contextFlag */, aOpeningTabParent,
aOpener, &cancel,
aOpeningTabParent, aOpener, &cancel,
getter_AddRefs(newWindowChrome));
if (NS_SUCCEEDED(rv) && cancel) {

Просмотреть файл

@ -26,10 +26,6 @@ interface mozIDOMWindowProxy;
interface nsIWindowCreator2 : nsIWindowCreator {
/**
* Definitions for contextFlags
*/
/** Create a new window. Gecko will/may call this method, if made
available to it, to create new windows.
@param parent Parent window, if any. Null if not. The newly created
@ -37,7 +33,6 @@ interface nsIWindowCreator2 : nsIWindowCreator {
the parent, if any (and if the concept applies
to the underlying OS).
@param chromeFlags Chrome features from nsIWebBrowserChrome
@param contextFlags Flags about the context of the window being created.
@param aOpeningTab The TabParent that is trying to open this new chrome
window. Can be nullptr.
@param aOpener The window which is trying to open this new chrome window.
@ -50,7 +45,6 @@ interface nsIWindowCreator2 : nsIWindowCreator {
*/
nsIWebBrowserChrome createChromeWindow2(in nsIWebBrowserChrome parent,
in uint32_t chromeFlags,
in uint32_t contextFlags,
in nsITabParent aOpeningTab,
in mozIDOMWindowProxy aOpener,
out boolean cancel);

Просмотреть файл

@ -4150,12 +4150,15 @@ class _GenerateProtocolActorCode(ipdl.ast.Visitor):
msgvar, stmts = self.makeMessage(md, errfnSendDtor, actorvar)
sendok, sendstmts = self.sendAsync(md, msgvar, actorvar)
failif = StmtIf(ExprNot(sendok))
failif.addifstmt(StmtReturn.FALSE)
method.addstmts(
stmts
+ self.genVerifyMessage(md.decl.type.verify, md.params,
errfnSendDtor, ExprVar('msg__'))
+ sendstmts
+ [ Whitespace.NL ]
+ [ failif, Whitespace.NL ]
+ self.dtorEpilogue(md, actor.var())
+ [ StmtReturn(sendok) ])

Просмотреть файл

@ -103,6 +103,9 @@ MemoryProtectionExceptionHandler::isDisabled()
// faults it sees are fatal. Just disable this handler in that case, as the
// crash annotations provided here are not critical for ASan builds.
return true;
#elif defined(RELEASE_OR_BETA)
// Disable the exception handler for Beta and Release builds.
return true;
#else
return false;
#endif

Просмотреть файл

@ -73,8 +73,10 @@ class PageProtectingVector final
unprotectedBytes += offsetToPage;
offsetToPage = (pageSize - (uintptr_t(vector.begin()) & pageMask)) & pageMask;
unprotectedBytes -= offsetToPage;
#ifndef RELEASE_OR_BETA
protectionEnabled = vector.capacity() >= protectionLowerBound &&
vector.capacity() >= pageSize + offsetToPage;
#endif
}
void protect() {

Просмотреть файл

@ -488,9 +488,13 @@ js::TenuringTracer::TenuringTracer(JSRuntime* rt, Nursery* nursery)
{
}
/* static */ void
void
js::Nursery::printProfileHeader()
{
if (!enableProfiling_)
return;
fprintf(stderr, "MinorGC: Reason PRate Size ");
#define PRINT_HEADER(name, text) \
fprintf(stderr, " %6s", text);
FOR_EACH_NURSERY_PROFILE_TIME(PRINT_HEADER)
@ -630,11 +634,7 @@ js::Nursery::collect(JSRuntime* rt, JS::gcreason::Reason reason)
TraceMinorGCEnd();
if (enableProfiling_ && totalTime >= profileThreshold_) {
static int printedHeader = 0;
if ((printedHeader++ % 200) == 0) {
fprintf(stderr, "MinorGC: Reason PRate Size ");
printProfileHeader();
}
rt->gc.stats.maybePrintProfileHeaders();
fprintf(stderr, "MinorGC: %20s %5.1f%% %4u ",
JS::gcreason::ExplainReason(reason),

Просмотреть файл

@ -257,6 +257,9 @@ class Nursery
void leaveZealMode();
#endif
/* Print header line for profile times. */
void printProfileHeader();
/* Print total profile times on shutdown. */
void printTotalProfileTimes();
@ -458,7 +461,6 @@ class Nursery
void endProfile(ProfileKey key);
void maybeStartProfile(ProfileKey key);
void maybeEndProfile(ProfileKey key);
static void printProfileHeader();
static void printProfileTimes(const ProfileTimes& times);
friend class TenuringTracer;

Просмотреть файл

@ -1326,9 +1326,23 @@ Statistics::computeMMU(int64_t window) const
return double(window - gcMax) / window;
}
/* static */ void
void
Statistics::maybePrintProfileHeaders()
{
static int printedHeader = 0;
if ((printedHeader++ % 200) == 0) {
printProfileHeader();
runtime->gc.nursery.printProfileHeader();
}
}
void
Statistics::printProfileHeader()
{
if (!enableProfiling_)
return;
fprintf(stderr, "MajorGC: Reason States ");
fprintf(stderr, " %6s", "total");
#define PRINT_PROFILE_HEADER(name, text, phase) \
fprintf(stderr, " %6s", text);
@ -1350,11 +1364,7 @@ Statistics::printSliceProfile()
{
const SliceData& slice = slices.back();
static int printedHeader = 0;
if ((printedHeader++ % 200) == 0) {
fprintf(stderr, "MajorGC: Reason States ");
printProfileHeader();
}
maybePrintProfileHeaders();
fprintf(stderr, "MajorGC: %20s %1d -> %1d ",
ExplainReason(slice.reason), int(slice.initialState), int(slice.finalState));

Просмотреть файл

@ -141,17 +141,17 @@ struct ZoneGCStats
};
#define FOR_EACH_GC_PROFILE_TIME(_) \
_(BeginCallback, "beginCB", PHASE_GC_BEGIN) \
_(WaitBgThread, "waitBG", PHASE_WAIT_BACKGROUND_THREAD) \
_(DiscardCode, "discard", PHASE_MARK_DISCARD_CODE) \
_(RelazifyFunc, "relazify", PHASE_RELAZIFY_FUNCTIONS) \
_(PurgeTables, "purgeTables", PHASE_PURGE_SHAPE_TABLES) \
_(Purge, "purge", PHASE_PURGE) \
_(Mark, "mark", PHASE_MARK) \
_(Sweep, "sweep", PHASE_SWEEP) \
_(Compact, "compact", PHASE_COMPACT) \
_(EndCallback, "endCB", PHASE_GC_END) \
_(Barriers, "barriers", PHASE_BARRIER)
_(BeginCallback, "bgnCB", PHASE_GC_BEGIN) \
_(WaitBgThread, "waitBG", PHASE_WAIT_BACKGROUND_THREAD) \
_(DiscardCode, "discrd", PHASE_MARK_DISCARD_CODE) \
_(RelazifyFunc, "relzfy", PHASE_RELAZIFY_FUNCTIONS) \
_(PurgeTables, "prgTbl", PHASE_PURGE_SHAPE_TABLES) \
_(Purge, "purge", PHASE_PURGE) \
_(Mark, "mark", PHASE_MARK) \
_(Sweep, "sweep", PHASE_SWEEP) \
_(Compact, "cmpct", PHASE_COMPACT) \
_(EndCallback, "endCB", PHASE_GC_END) \
_(Barriers, "brrier", PHASE_BARRIER)
const char* ExplainAbortReason(gc::AbortReason reason);
const char* ExplainInvocationKind(JSGCInvocationKind gckind);
@ -313,6 +313,12 @@ struct Statistics
SliceRange sliceRange() const { return slices.all(); }
size_t slicesLength() const { return slices.length(); }
/* Occasionally print header lines for profiling information. */
void maybePrintProfileHeaders();
/* Print header line for profile times. */
void printProfileHeader();
/* Print total profile times on shutdown. */
void printTotalProfileTimes();
@ -429,7 +435,6 @@ FOR_EACH_GC_PROFILE_TIME(DEFINE_TIME_KEY)
double computeMMU(int64_t resolution) const;
void printSliceProfile();
static void printProfileHeader();
static void printProfileTimes(const ProfileTimes& times);
};

Просмотреть файл

@ -1837,7 +1837,9 @@ ParsePattern(frontend::TokenStream& ts, LifoAlloc& alloc, const CharT* chars, si
bool multiline, bool match_only, bool unicode, bool ignore_case,
bool global, bool sticky, RegExpCompileData* data)
{
if (match_only) {
// We shouldn't strip pattern for exec, or test with global/sticky,
// to reflect correct match position and lastIndex.
if (match_only && !global && !sticky) {
// Try to strip a leading '.*' from the RegExp, but only if it is not
// followed by a '?' (which will affect how the .* is parsed). This
// pattern will affect the captures produced by the RegExp, but not
@ -1849,13 +1851,9 @@ ParsePattern(frontend::TokenStream& ts, LifoAlloc& alloc, const CharT* chars, si
// Try to strip a trailing '.*' from the RegExp, which as above will
// affect the captures but not whether there is a match. Only do this
// when the following conditions are met:
// 1. there are no other meta characters in the RegExp, so that we
// are sure this will not affect how the RegExp is parsed
// 2. global and sticky flags are not set, as lastIndex needs to be
// set properly on global or sticky match
// when there are no other meta characters in the RegExp, so that we
// are sure this will not affect how the RegExp is parsed.
if (length >= 3 && !HasRegExpMetaChars(chars, length - 2) &&
!global && !sticky &&
chars[length - 2] == '.' && chars[length - 1] == '*')
{
length -= 2;

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше