зеркало из https://github.com/mozilla/gecko-dev.git
Merge mozilla-central to autoland a=merge on a CLOSED TREE
This commit is contained in:
Коммит
98e1446184
|
@ -9,6 +9,7 @@
|
|||
#include "mozilla/dom/ContentChild.h"
|
||||
#include "mozilla/dom/TabChild.h"
|
||||
#include "mozilla/dom/DocGroup.h"
|
||||
#include "mozilla/dom/TimeoutManager.h"
|
||||
#include "mozilla/AbstractThread.h"
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
|
@ -23,6 +24,8 @@ namespace dom {
|
|||
|
||||
static StaticRefPtr<TabGroup> sChromeTabGroup;
|
||||
|
||||
LinkedList<TabGroup>* TabGroup::sTabGroups = nullptr;
|
||||
|
||||
TabGroup::TabGroup(bool aIsChrome)
|
||||
: mLastWindowLeft(false)
|
||||
, mThrottledQueuesInitialized(false)
|
||||
|
@ -31,6 +34,11 @@ TabGroup::TabGroup(bool aIsChrome)
|
|||
, mIsChrome(aIsChrome)
|
||||
, mForegroundCount(0)
|
||||
{
|
||||
if (!sTabGroups) {
|
||||
sTabGroups = new LinkedList<TabGroup>();
|
||||
}
|
||||
sTabGroups->insertBack(this);
|
||||
|
||||
CreateEventTargets(/* aNeedValidation = */ !aIsChrome);
|
||||
|
||||
// Do not throttle runnables from chrome windows. In theory we should
|
||||
|
@ -54,6 +62,15 @@ TabGroup::~TabGroup()
|
|||
MOZ_ASSERT(mDocGroups.IsEmpty());
|
||||
MOZ_ASSERT(mWindows.IsEmpty());
|
||||
MOZ_RELEASE_ASSERT(mLastWindowLeft || mIsChrome);
|
||||
|
||||
LinkedListElement<TabGroup>* listElement =
|
||||
static_cast<LinkedListElement<TabGroup>*>(this);
|
||||
listElement->remove();
|
||||
|
||||
if (sTabGroups->isEmpty()) {
|
||||
delete sTabGroups;
|
||||
sTabGroups = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -323,5 +340,37 @@ TabGroup::Count(bool aActiveOnly) const
|
|||
return count;
|
||||
}
|
||||
|
||||
/*static*/ bool
|
||||
TabGroup::HasOnlyThrottableTabs()
|
||||
{
|
||||
if (!sTabGroups) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (TabGroup* tabGroup = sTabGroups->getFirst(); tabGroup;
|
||||
tabGroup =
|
||||
static_cast<LinkedListElement<TabGroup>*>(tabGroup)->getNext()) {
|
||||
for (auto iter = tabGroup->Iter(); !iter.Done(); iter.Next()) {
|
||||
DocGroup* docGroup = iter.Get()->mDocGroup;
|
||||
for (auto* documentInDocGroup : *docGroup) {
|
||||
if (documentInDocGroup->IsCurrentActiveDocument()) {
|
||||
nsPIDOMWindowInner* win =
|
||||
documentInDocGroup->GetInnerWindow();
|
||||
if (win && win->IsCurrentInnerWindow()) {
|
||||
nsPIDOMWindowOuter* outer = win->GetOuterWindow();
|
||||
if (outer) {
|
||||
TimeoutManager& tm = win->TimeoutManager();
|
||||
if (!tm.BudgetThrottlingEnabled(outer->IsBackground())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -46,7 +46,8 @@ class TabChild;
|
|||
class DocGroup;
|
||||
class TabChild;
|
||||
|
||||
class TabGroup final : public SchedulerGroup
|
||||
class TabGroup final : public SchedulerGroup,
|
||||
public LinkedListElement<TabGroup>
|
||||
{
|
||||
private:
|
||||
class HashEntry : public nsCStringHashKey
|
||||
|
@ -146,6 +147,16 @@ public:
|
|||
return mNumOfIndexedDBDatabases;
|
||||
}
|
||||
|
||||
static LinkedList<TabGroup>* GetTabGroupList()
|
||||
{
|
||||
return sTabGroups;
|
||||
}
|
||||
|
||||
// This returns true if all the window objects in all the TabGroups are
|
||||
// either inactive (for example in bfcache) or are in background tabs which
|
||||
// can be throttled.
|
||||
static bool HasOnlyThrottableTabs();
|
||||
|
||||
private:
|
||||
virtual AbstractThread*
|
||||
AbstractMainThreadForImpl(TaskCategory aCategory) override;
|
||||
|
@ -167,6 +178,8 @@ private:
|
|||
DocGroupMap mDocGroups;
|
||||
nsTArray<nsPIDOMWindowOuter*> mWindows;
|
||||
uint32_t mForegroundCount;
|
||||
|
||||
static LinkedList<TabGroup>* sTabGroups;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -111,6 +111,8 @@ public:
|
|||
nsIEventTarget*
|
||||
EventTarget();
|
||||
|
||||
bool BudgetThrottlingEnabled(bool aIsBackground) const;
|
||||
|
||||
static const uint32_t InvalidFiringId;
|
||||
|
||||
private:
|
||||
|
@ -149,8 +151,6 @@ private:
|
|||
void UpdateBudget(const TimeStamp& aNow,
|
||||
const TimeDuration& aDuration = TimeDuration());
|
||||
|
||||
bool BudgetThrottlingEnabled(bool aIsBackground) const;
|
||||
|
||||
private:
|
||||
struct Timeouts {
|
||||
explicit Timeouts(const TimeoutManager& aManager)
|
||||
|
|
|
@ -16,7 +16,14 @@
|
|||
class nsSMILKeySpline
|
||||
{
|
||||
public:
|
||||
nsSMILKeySpline() { /* caller must call Init later */ }
|
||||
nsSMILKeySpline()
|
||||
: mX1(0)
|
||||
, mY1(0)
|
||||
, mX2(0)
|
||||
, mY2(0)
|
||||
{
|
||||
/* caller must call Init later */\
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new key spline control point description.
|
||||
|
@ -26,6 +33,10 @@ public:
|
|||
*/
|
||||
nsSMILKeySpline(double aX1, double aY1,
|
||||
double aX2, double aY2)
|
||||
: mX1(0)
|
||||
, mY1(0)
|
||||
, mX2(0)
|
||||
, mY2(0)
|
||||
{
|
||||
Init(aX1, aY1, aX2, aY2);
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
nsSMILValue::nsSMILValue(const nsISMILType* aType)
|
||||
: mType(nsSMILNullType::Singleton())
|
||||
{
|
||||
mU.mBool = false;
|
||||
if (!aType) {
|
||||
NS_ERROR("Trying to construct nsSMILValue with null mType pointer");
|
||||
return;
|
||||
|
|
|
@ -230,7 +230,10 @@ private:
|
|||
* want to create the DOMSVGPathSeg items lazily on demand.
|
||||
*/
|
||||
struct ItemProxy {
|
||||
ItemProxy(){}
|
||||
ItemProxy()
|
||||
: mItem(nullptr)
|
||||
, mInternalDataIndex(0)
|
||||
{}
|
||||
ItemProxy(DOMSVGPathSeg *aItem, uint32_t aInternalDataIndex)
|
||||
: mItem(aItem)
|
||||
, mInternalDataIndex(aInternalDataIndex)
|
||||
|
|
|
@ -43,7 +43,9 @@ class SVGAnimatedNumberList
|
|||
friend class DOMSVGNumberList;
|
||||
|
||||
public:
|
||||
SVGAnimatedNumberList() {}
|
||||
SVGAnimatedNumberList()
|
||||
: mIsBaseSet(false)
|
||||
{}
|
||||
|
||||
/**
|
||||
* Because it's so important that mBaseVal and its DOMSVGNumberList wrapper
|
||||
|
|
|
@ -112,7 +112,11 @@ public:
|
|||
{
|
||||
public:
|
||||
SimplePath()
|
||||
: mType(NONE)
|
||||
: mX(0.0)
|
||||
, mY(0.0)
|
||||
, mWidthOrX2(0.0)
|
||||
, mHeightOrY2(0.0)
|
||||
, mType(NONE)
|
||||
{}
|
||||
bool IsPath() const {
|
||||
return mType != NONE;
|
||||
|
|
|
@ -33,10 +33,8 @@ class SVGLength
|
|||
public:
|
||||
|
||||
SVGLength()
|
||||
#ifdef DEBUG
|
||||
: mValue(0.0f)
|
||||
, mUnit(dom::SVGLengthBinding::SVG_LENGTHTYPE_UNKNOWN) // caught by IsValid()
|
||||
#endif
|
||||
{}
|
||||
|
||||
SVGLength(float aValue, uint8_t aUnit)
|
||||
|
|
|
@ -311,6 +311,8 @@ public:
|
|||
|
||||
SVGUserUnitList()
|
||||
: mList(nullptr)
|
||||
, mElement(nullptr)
|
||||
, mAxis(0)
|
||||
{}
|
||||
|
||||
void Init(const SVGLengthList *aList, nsSVGElement *aElement, uint8_t aAxis) {
|
||||
|
|
|
@ -64,7 +64,10 @@ struct MotionSegment
|
|||
// Default constructor just locks us into being a Translation, and leaves
|
||||
// other fields uninitialized (since client is presumably about to set them)
|
||||
MotionSegment()
|
||||
: mSegmentType(eSegmentType_Translation)
|
||||
: mRotateType(eRotateType_Auto),
|
||||
mRotateAngle(0.0),
|
||||
mSegmentType(eSegmentType_Translation),
|
||||
mU{}
|
||||
{ }
|
||||
|
||||
// Constructor for a translation
|
||||
|
|
|
@ -32,7 +32,13 @@ struct nsSVGViewBoxRect
|
|||
float width, height;
|
||||
bool none;
|
||||
|
||||
nsSVGViewBoxRect() : none(true) {}
|
||||
nsSVGViewBoxRect()
|
||||
: x(0.0)
|
||||
, y(0.0)
|
||||
, width(0.0)
|
||||
, height(0.0)
|
||||
, none(true)
|
||||
{}
|
||||
nsSVGViewBoxRect(float aX, float aY, float aWidth, float aHeight) :
|
||||
x(aX), y(aY), width(aWidth), height(aHeight), none(false) {}
|
||||
nsSVGViewBoxRect(const nsSVGViewBoxRect& rhs) :
|
||||
|
|
|
@ -282,8 +282,7 @@ class NodeBuilder
|
|||
}
|
||||
|
||||
if (!funv.isObject() || !funv.toObject().is<JSFunction>()) {
|
||||
ReportValueErrorFlags(cx, JSREPORT_ERROR, JSMSG_NOT_FUNCTION,
|
||||
JSDVG_SEARCH_STACK, funv, nullptr, nullptr, nullptr);
|
||||
ReportValueError(cx, JSMSG_NOT_FUNCTION, JSDVG_SEARCH_STACK, funv, nullptr);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -3362,9 +3361,8 @@ reflect_parse(JSContext* cx, uint32_t argc, Value* vp)
|
|||
|
||||
if (!arg.isNullOrUndefined()) {
|
||||
if (!arg.isObject()) {
|
||||
ReportValueErrorFlags(cx, JSREPORT_ERROR, JSMSG_UNEXPECTED_TYPE,
|
||||
JSDVG_SEARCH_STACK, arg, nullptr,
|
||||
"not an object", nullptr);
|
||||
ReportValueError(cx, JSMSG_UNEXPECTED_TYPE, JSDVG_SEARCH_STACK, arg, nullptr,
|
||||
"not an object");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -3414,9 +3412,8 @@ reflect_parse(JSContext* cx, uint32_t argc, Value* vp)
|
|||
|
||||
if (!prop.isNullOrUndefined()) {
|
||||
if (!prop.isObject()) {
|
||||
ReportValueErrorFlags(cx, JSREPORT_ERROR, JSMSG_UNEXPECTED_TYPE,
|
||||
JSDVG_SEARCH_STACK, prop, nullptr,
|
||||
"not an object", nullptr);
|
||||
ReportValueError(cx, JSMSG_UNEXPECTED_TYPE, JSDVG_SEARCH_STACK, prop, nullptr,
|
||||
"not an object");
|
||||
return false;
|
||||
}
|
||||
builder = &prop.toObject();
|
||||
|
@ -3429,8 +3426,8 @@ reflect_parse(JSContext* cx, uint32_t argc, Value* vp)
|
|||
return false;
|
||||
|
||||
if (!prop.isString()) {
|
||||
ReportValueErrorFlags(cx, JSREPORT_ERROR, JSMSG_UNEXPECTED_TYPE, JSDVG_SEARCH_STACK,
|
||||
prop, nullptr, "not 'script' or 'module'", nullptr);
|
||||
ReportValueError(cx, JSMSG_UNEXPECTED_TYPE, JSDVG_SEARCH_STACK, prop, nullptr,
|
||||
"not 'script' or 'module'");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -270,17 +270,15 @@ PromiseRejectedWithPendingError(JSContext* cx) {
|
|||
return PromiseObject::unforgeableReject(cx, exn);
|
||||
}
|
||||
|
||||
static bool
|
||||
ReportArgTypeError(JSContext* cx, const char* funName, const char* expectedType,
|
||||
HandleValue arg)
|
||||
static void
|
||||
ReportArgTypeError(JSContext* cx, const char* funName, const char* expectedType, HandleValue arg)
|
||||
{
|
||||
UniqueChars bytes = DecompileValueGenerator(cx, JSDVG_SEARCH_STACK, arg, nullptr);
|
||||
if (!bytes)
|
||||
return false;
|
||||
return;
|
||||
|
||||
return JS_ReportErrorFlagsAndNumberLatin1(cx, JSREPORT_ERROR, GetErrorMessage,
|
||||
nullptr, JSMSG_NOT_EXPECTED_TYPE,
|
||||
funName, expectedType, bytes.get());
|
||||
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr, JSMSG_NOT_EXPECTED_TYPE, funName,
|
||||
expectedType, bytes.get());
|
||||
}
|
||||
|
||||
static MOZ_MUST_USE bool
|
||||
|
@ -307,7 +305,7 @@ static MOZ_MUST_USE bool
|
|||
RejectNonGenericMethod(JSContext* cx, const CallArgs& args,
|
||||
const char* className, const char* methodName)
|
||||
{
|
||||
ReportValueError3(cx, JSMSG_INCOMPATIBLE_PROTO, JSDVG_SEARCH_STACK, args.thisv(),
|
||||
ReportValueError(cx, JSMSG_INCOMPATIBLE_PROTO, JSDVG_SEARCH_STACK, args.thisv(),
|
||||
nullptr, className, methodName);
|
||||
|
||||
return ReturnPromiseRejectedWithPendingError(cx, args);
|
||||
|
@ -803,7 +801,7 @@ ReadableStream_cancel(JSContext* cx, unsigned argc, Value* vp)
|
|||
// Step 1: If ! IsReadableStream(this) is false, return a promise rejected
|
||||
// with a TypeError exception.
|
||||
if (!Is<ReadableStream>(args.thisv())) {
|
||||
ReportValueError3(cx, JSMSG_INCOMPATIBLE_PROTO, JSDVG_SEARCH_STACK, args.thisv(),
|
||||
ReportValueError(cx, JSMSG_INCOMPATIBLE_PROTO, JSDVG_SEARCH_STACK, args.thisv(),
|
||||
nullptr, "cancel", "");
|
||||
return ReturnPromiseRejectedWithPendingError(cx, args);
|
||||
}
|
||||
|
|
|
@ -150,8 +150,8 @@ SymbolObject::keyFor(JSContext* cx, unsigned argc, Value* vp)
|
|||
// step 1
|
||||
HandleValue arg = args.get(0);
|
||||
if (!arg.isSymbol()) {
|
||||
ReportValueErrorFlags(cx, JSREPORT_ERROR, JSMSG_UNEXPECTED_TYPE, JSDVG_SEARCH_STACK,
|
||||
arg, nullptr, "not a symbol", nullptr);
|
||||
ReportValueError(cx, JSMSG_UNEXPECTED_TYPE, JSDVG_SEARCH_STACK, arg, nullptr,
|
||||
"not a symbol");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1304,9 +1304,8 @@ SaveStack(JSContext* cx, unsigned argc, Value* vp)
|
|||
if (!ToNumber(cx, args[0], &maxDouble))
|
||||
return false;
|
||||
if (mozilla::IsNaN(maxDouble) || maxDouble < 0 || maxDouble > UINT32_MAX) {
|
||||
ReportValueErrorFlags(cx, JSREPORT_ERROR, JSMSG_UNEXPECTED_TYPE,
|
||||
JSDVG_SEARCH_STACK, args[0], nullptr,
|
||||
"not a valid maximum frame count", NULL);
|
||||
ReportValueError(cx, JSMSG_UNEXPECTED_TYPE, JSDVG_SEARCH_STACK, args[0], nullptr,
|
||||
"not a valid maximum frame count");
|
||||
return false;
|
||||
}
|
||||
uint32_t max = uint32_t(maxDouble);
|
||||
|
@ -1317,9 +1316,8 @@ SaveStack(JSContext* cx, unsigned argc, Value* vp)
|
|||
RootedObject compartmentObject(cx);
|
||||
if (args.length() >= 2) {
|
||||
if (!args[1].isObject()) {
|
||||
ReportValueErrorFlags(cx, JSREPORT_ERROR, JSMSG_UNEXPECTED_TYPE,
|
||||
JSDVG_SEARCH_STACK, args[0], nullptr,
|
||||
"not an object", NULL);
|
||||
ReportValueError(cx, JSMSG_UNEXPECTED_TYPE, JSDVG_SEARCH_STACK, args[0], nullptr,
|
||||
"not an object");
|
||||
return false;
|
||||
}
|
||||
compartmentObject = UncheckedUnwrap(&args[1].toObject());
|
||||
|
@ -3593,16 +3591,14 @@ FindPath(JSContext* cx, unsigned argc, Value* vp)
|
|||
// test is all about object identity, and ToString doesn't preserve that.
|
||||
// Non-GCThing endpoints don't make much sense.
|
||||
if (!args[0].isObject() && !args[0].isString() && !args[0].isSymbol()) {
|
||||
ReportValueErrorFlags(cx, JSREPORT_ERROR, JSMSG_UNEXPECTED_TYPE,
|
||||
JSDVG_SEARCH_STACK, args[0], nullptr,
|
||||
"not an object, string, or symbol", NULL);
|
||||
ReportValueError(cx, JSMSG_UNEXPECTED_TYPE, JSDVG_SEARCH_STACK, args[0], nullptr,
|
||||
"not an object, string, or symbol");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!args[1].isObject() && !args[1].isString() && !args[1].isSymbol()) {
|
||||
ReportValueErrorFlags(cx, JSREPORT_ERROR, JSMSG_UNEXPECTED_TYPE,
|
||||
JSDVG_SEARCH_STACK, args[0], nullptr,
|
||||
"not an object, string, or symbol", NULL);
|
||||
ReportValueError(cx, JSMSG_UNEXPECTED_TYPE, JSDVG_SEARCH_STACK, args[0], nullptr,
|
||||
"not an object, string, or symbol");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -3698,25 +3694,22 @@ ShortestPaths(JSContext* cx, unsigned argc, Value* vp)
|
|||
// test is all about object identity, and ToString doesn't preserve that.
|
||||
// Non-GCThing endpoints don't make much sense.
|
||||
if (!args[0].isObject() && !args[0].isString() && !args[0].isSymbol()) {
|
||||
ReportValueErrorFlags(cx, JSREPORT_ERROR, JSMSG_UNEXPECTED_TYPE,
|
||||
JSDVG_SEARCH_STACK, args[0], nullptr,
|
||||
"not an object, string, or symbol", nullptr);
|
||||
ReportValueError(cx, JSMSG_UNEXPECTED_TYPE, JSDVG_SEARCH_STACK, args[0], nullptr,
|
||||
"not an object, string, or symbol");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!args[1].isObject() || !args[1].toObject().is<ArrayObject>()) {
|
||||
ReportValueErrorFlags(cx, JSREPORT_ERROR, JSMSG_UNEXPECTED_TYPE,
|
||||
JSDVG_SEARCH_STACK, args[1], nullptr,
|
||||
"not an array object", nullptr);
|
||||
ReportValueError(cx, JSMSG_UNEXPECTED_TYPE, JSDVG_SEARCH_STACK, args[1], nullptr,
|
||||
"not an array object");
|
||||
return false;
|
||||
}
|
||||
|
||||
RootedArrayObject objs(cx, &args[1].toObject().as<ArrayObject>());
|
||||
size_t length = objs->getDenseInitializedLength();
|
||||
if (length == 0) {
|
||||
ReportValueErrorFlags(cx, JSREPORT_ERROR, JSMSG_UNEXPECTED_TYPE,
|
||||
JSDVG_SEARCH_STACK, args[1], nullptr,
|
||||
"not a dense array object with one or more elements", nullptr);
|
||||
ReportValueError(cx, JSMSG_UNEXPECTED_TYPE, JSDVG_SEARCH_STACK, args[1], nullptr,
|
||||
"not a dense array object with one or more elements");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -3732,9 +3725,8 @@ ShortestPaths(JSContext* cx, unsigned argc, Value* vp)
|
|||
if (!JS::ToInt32(cx, args[2], &maxNumPaths))
|
||||
return false;
|
||||
if (maxNumPaths <= 0) {
|
||||
ReportValueErrorFlags(cx, JSREPORT_ERROR, JSMSG_UNEXPECTED_TYPE,
|
||||
JSDVG_SEARCH_STACK, args[2], nullptr,
|
||||
"not greater than 0", nullptr);
|
||||
ReportValueError(cx, JSMSG_UNEXPECTED_TYPE, JSDVG_SEARCH_STACK, args[2], nullptr,
|
||||
"not greater than 0");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -97,9 +97,7 @@ GetDeflatedUTF8StringLength(JSContext* maybecx, const CharT* chars,
|
|||
js::gc::AutoSuppressGC suppress(maybecx);
|
||||
char buffer[10];
|
||||
SprintfLiteral(buffer, "0x%x", c);
|
||||
JS_ReportErrorFlagsAndNumberASCII(maybecx, JSREPORT_ERROR,
|
||||
GetErrorMessage,
|
||||
nullptr, JSMSG_BAD_SURROGATE_CHAR,
|
||||
JS_ReportErrorNumberASCII(maybecx, GetErrorMessage, nullptr, JSMSG_BAD_SURROGATE_CHAR,
|
||||
buffer);
|
||||
}
|
||||
return (size_t) -1;
|
||||
|
|
|
@ -7093,7 +7093,7 @@ JSErrorNotes::copy(JSContext* cx)
|
|||
}
|
||||
|
||||
for (auto&& note : *this) {
|
||||
js::UniquePtr<JSErrorNotes::Note> copied(CopyErrorNote(cx, note.get()));
|
||||
UniquePtr<JSErrorNotes::Note> copied = CopyErrorNote(cx, note.get());
|
||||
if (!copied)
|
||||
return nullptr;
|
||||
|
||||
|
|
|
@ -495,13 +495,6 @@ static const unsigned JSFUN_CONSTRUCTOR = 0x400;
|
|||
/* | of all the JSFUN_* flags */
|
||||
static const unsigned JSFUN_FLAGS_MASK = 0x400;
|
||||
|
||||
/*
|
||||
* If set, will allow redefining a non-configurable property, but only on a
|
||||
* non-DOM global. This is a temporary hack that will need to go away in bug
|
||||
* 1105518.
|
||||
*/
|
||||
static const unsigned JSPROP_REDEFINE_NONCONFIGURABLE = 0x1000;
|
||||
|
||||
/*
|
||||
* Resolve hooks and enumerate hooks must pass this flag when calling
|
||||
* JS_Define* APIs to reify lazily-defined properties.
|
||||
|
@ -2112,7 +2105,6 @@ class WrappedPtrOperations<JS::PropertyDescriptor, Wrapper>
|
|||
JSPROP_IGNORE_VALUE |
|
||||
JSPROP_GETTER |
|
||||
JSPROP_SETTER |
|
||||
JSPROP_REDEFINE_NONCONFIGURABLE |
|
||||
JSPROP_RESOLVING |
|
||||
SHADOWABLE)) == 0);
|
||||
MOZ_ASSERT(!hasAll(JSPROP_IGNORE_ENUMERATE | JSPROP_ENUMERATE));
|
||||
|
@ -2134,7 +2126,6 @@ class WrappedPtrOperations<JS::PropertyDescriptor, Wrapper>
|
|||
MOZ_ASSERT_IF(has(JSPROP_RESOLVING), !has(JSPROP_IGNORE_PERMANENT));
|
||||
MOZ_ASSERT_IF(has(JSPROP_RESOLVING), !has(JSPROP_IGNORE_READONLY));
|
||||
MOZ_ASSERT_IF(has(JSPROP_RESOLVING), !has(JSPROP_IGNORE_VALUE));
|
||||
MOZ_ASSERT_IF(has(JSPROP_RESOLVING), !has(JSPROP_REDEFINE_NONCONFIGURABLE));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -2146,7 +2137,6 @@ class WrappedPtrOperations<JS::PropertyDescriptor, Wrapper>
|
|||
JSPROP_READONLY |
|
||||
JSPROP_GETTER |
|
||||
JSPROP_SETTER |
|
||||
JSPROP_REDEFINE_NONCONFIGURABLE |
|
||||
JSPROP_RESOLVING |
|
||||
SHADOWABLE)) == 0);
|
||||
MOZ_ASSERT_IF(isAccessorDescriptor(), has(JSPROP_GETTER) && has(JSPROP_SETTER));
|
||||
|
|
|
@ -2654,8 +2654,7 @@ date_toJSON(JSContext* cx, unsigned argc, Value* vp)
|
|||
|
||||
/* Step 5. */
|
||||
if (!IsCallable(toISO)) {
|
||||
JS_ReportErrorFlagsAndNumberASCII(cx, JSREPORT_ERROR, js::GetErrorMessage, nullptr,
|
||||
JSMSG_BAD_TOISOSTRING_PROP);
|
||||
JS_ReportErrorNumberASCII(cx, js::GetErrorMessage, nullptr, JSMSG_BAD_TOISOSTRING_PROP);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "mozilla/Sprintf.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <utility>
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jsnum.h"
|
||||
|
@ -23,6 +24,7 @@
|
|||
#include "gc/FreeOp.h"
|
||||
#include "gc/Marking.h"
|
||||
#include "js/CharacterEncoding.h"
|
||||
#include "js/UniquePtr.h"
|
||||
#include "js/Wrapper.h"
|
||||
#include "util/StringBuffer.h"
|
||||
#include "vm/ErrorObject.h"
|
||||
|
@ -267,7 +269,7 @@ CopyExtraData(JSContext* cx, uint8_t** cursor, JSErrorNotes::Note* copy, JSError
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
static T*
|
||||
static UniquePtr<T>
|
||||
CopyErrorHelper(JSContext* cx, T* report)
|
||||
{
|
||||
/*
|
||||
|
@ -298,7 +300,7 @@ CopyErrorHelper(JSContext* cx, T* report)
|
|||
if (!cursor)
|
||||
return nullptr;
|
||||
|
||||
T* copy = new (cursor) T();
|
||||
UniquePtr<T> copy(new (cursor) T());
|
||||
cursor += sizeof(T);
|
||||
|
||||
if (report->message()) {
|
||||
|
@ -313,13 +315,10 @@ CopyErrorHelper(JSContext* cx, T* report)
|
|||
cursor += filenameSize;
|
||||
}
|
||||
|
||||
if (!CopyExtraData(cx, &cursor, copy, report)) {
|
||||
/* js_delete calls destructor for T and js_free for pod_calloc. */
|
||||
js_delete(copy);
|
||||
if (!CopyExtraData(cx, &cursor, copy.get(), report))
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(cursor == (uint8_t*)copy + mallocSize);
|
||||
MOZ_ASSERT(cursor == (uint8_t*)copy.get() + mallocSize);
|
||||
|
||||
/* Copy non-pointer members. */
|
||||
copy->lineno = report->lineno;
|
||||
|
@ -329,13 +328,13 @@ CopyErrorHelper(JSContext* cx, T* report)
|
|||
return copy;
|
||||
}
|
||||
|
||||
JSErrorNotes::Note*
|
||||
UniquePtr<JSErrorNotes::Note>
|
||||
js::CopyErrorNote(JSContext* cx, JSErrorNotes::Note* note)
|
||||
{
|
||||
return CopyErrorHelper(cx, note);
|
||||
}
|
||||
|
||||
JSErrorReport*
|
||||
UniquePtr<JSErrorReport>
|
||||
js::CopyErrorReport(JSContext* cx, JSErrorReport* report)
|
||||
{
|
||||
return CopyErrorHelper(cx, report);
|
||||
|
@ -686,12 +685,12 @@ js::ErrorToException(JSContext* cx, JSErrorReport* reportp,
|
|||
if (!CaptureStack(cx, &stack))
|
||||
return;
|
||||
|
||||
js::ScopedJSFreePtr<JSErrorReport> report(CopyErrorReport(cx, reportp));
|
||||
UniquePtr<JSErrorReport> report = CopyErrorReport(cx, reportp);
|
||||
if (!report)
|
||||
return;
|
||||
|
||||
RootedObject errObject(cx, ErrorObject::create(cx, exnType, stack, fileName,
|
||||
lineNumber, columnNumber, &report, messageStr));
|
||||
RootedObject errObject(cx, ErrorObject::create(cx, exnType, stack, fileName, lineNumber,
|
||||
columnNumber, std::move(report), messageStr));
|
||||
if (!errObject)
|
||||
return;
|
||||
|
||||
|
@ -990,7 +989,7 @@ ErrorReport::populateUncaughtExceptionReportUTF8VA(JSContext* cx, va_list ap)
|
|||
JSObject*
|
||||
js::CopyErrorObject(JSContext* cx, Handle<ErrorObject*> err)
|
||||
{
|
||||
js::ScopedJSFreePtr<JSErrorReport> copyReport;
|
||||
UniquePtr<JSErrorReport> copyReport;
|
||||
if (JSErrorReport* errorReport = err->getErrorReport()) {
|
||||
copyReport = CopyErrorReport(cx, errorReport);
|
||||
if (!copyReport)
|
||||
|
@ -1012,7 +1011,7 @@ js::CopyErrorObject(JSContext* cx, Handle<ErrorObject*> err)
|
|||
|
||||
// Create the Error object.
|
||||
return ErrorObject::create(cx, errorType, stack, fileName,
|
||||
lineNumber, columnNumber, ©Report, message);
|
||||
lineNumber, columnNumber, std::move(copyReport), message);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
|
@ -1023,13 +1022,15 @@ JS::CreateError(JSContext* cx, JSExnType type, HandleObject stack, HandleString
|
|||
assertSameCompartment(cx, stack, fileName, message);
|
||||
AssertObjectIsSavedFrameOrWrapper(cx, stack);
|
||||
|
||||
js::ScopedJSFreePtr<JSErrorReport> rep;
|
||||
if (report)
|
||||
js::UniquePtr<JSErrorReport> rep;
|
||||
if (report) {
|
||||
rep = CopyErrorReport(cx, report);
|
||||
if (!rep)
|
||||
return false;
|
||||
}
|
||||
|
||||
RootedObject obj(cx,
|
||||
js::ErrorObject::create(cx, type, stack, fileName,
|
||||
lineNumber, columnNumber, &rep, message));
|
||||
JSObject* obj = js::ErrorObject::create(cx, type, stack, fileName, lineNumber, columnNumber,
|
||||
std::move(rep), message);
|
||||
if (!obj)
|
||||
return false;
|
||||
|
||||
|
|
|
@ -14,15 +14,16 @@
|
|||
#include "jsapi.h"
|
||||
#include "NamespaceImports.h"
|
||||
|
||||
#include "js/UniquePtr.h"
|
||||
#include "vm/JSContext.h"
|
||||
|
||||
namespace js {
|
||||
class ErrorObject;
|
||||
|
||||
JSErrorNotes::Note*
|
||||
UniquePtr<JSErrorNotes::Note>
|
||||
CopyErrorNote(JSContext* cx, JSErrorNotes::Note* note);
|
||||
|
||||
JSErrorReport*
|
||||
UniquePtr<JSErrorReport>
|
||||
CopyErrorReport(JSContext* cx, JSErrorReport* report);
|
||||
|
||||
JSString*
|
||||
|
|
|
@ -230,8 +230,7 @@ ReportInvalidCharacter(JSContext* cx, uint32_t offset)
|
|||
{
|
||||
char buffer[10];
|
||||
SprintfLiteral(buffer, "%u", offset);
|
||||
JS_ReportErrorFlagsAndNumberASCII(cx, JSREPORT_ERROR, GetErrorMessage, nullptr,
|
||||
JSMSG_MALFORMED_UTF8_CHAR, buffer);
|
||||
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_MALFORMED_UTF8_CHAR, buffer);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -245,8 +244,7 @@ ReportTooBigCharacter(JSContext* cx, uint32_t v)
|
|||
{
|
||||
char buffer[10];
|
||||
SprintfLiteral(buffer, "0x%x", v + 0x10000);
|
||||
JS_ReportErrorFlagsAndNumberASCII(cx, JSREPORT_ERROR, GetErrorMessage, nullptr,
|
||||
JSMSG_UTF8_CHAR_TOO_LARGE, buffer);
|
||||
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_UTF8_CHAR_TOO_LARGE, buffer);
|
||||
}
|
||||
|
||||
enum InflateUTF8Action {
|
||||
|
|
|
@ -274,9 +274,8 @@ ValueToIdentifier(JSContext* cx, HandleValue v, MutableHandleId id)
|
|||
return false;
|
||||
if (!JSID_IS_ATOM(id) || !IsIdentifier(JSID_TO_ATOM(id))) {
|
||||
RootedValue val(cx, v);
|
||||
ReportValueErrorFlags(cx, JSREPORT_ERROR, JSMSG_UNEXPECTED_TYPE,
|
||||
JSDVG_SEARCH_STACK, val, nullptr, "not an identifier",
|
||||
nullptr);
|
||||
ReportValueError(cx, JSMSG_UNEXPECTED_TYPE, JSDVG_SEARCH_STACK, val, nullptr,
|
||||
"not an identifier");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -522,13 +521,11 @@ RequireGlobalObject(JSContext* cx, HandleValue dbgobj, HandleObject referent)
|
|||
}
|
||||
|
||||
if (obj->is<GlobalObject>()) {
|
||||
ReportValueErrorFlags(cx, JSREPORT_ERROR, JSMSG_DEBUG_WRAPPER_IN_WAY,
|
||||
JSDVG_SEARCH_STACK, dbgobj, nullptr,
|
||||
ReportValueError(cx, JSMSG_DEBUG_WRAPPER_IN_WAY, JSDVG_SEARCH_STACK, dbgobj, nullptr,
|
||||
isWrapper, isWindowProxy);
|
||||
} else {
|
||||
ReportValueErrorFlags(cx, JSREPORT_ERROR, JSMSG_DEBUG_BAD_REFERENT,
|
||||
JSDVG_SEARCH_STACK, dbgobj, nullptr,
|
||||
"a global object", nullptr);
|
||||
ReportValueError(cx, JSMSG_DEBUG_BAD_REFERENT, JSDVG_SEARCH_STACK, dbgobj, nullptr,
|
||||
"a global object");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -5361,9 +5358,8 @@ DebuggerScript_checkThis(JSContext* cx, const CallArgs& args, const char* fnname
|
|||
return nullptr;
|
||||
|
||||
if (!GetScriptReferent(thisobj).is<ReferentT>()) {
|
||||
ReportValueErrorFlags(cx, JSREPORT_ERROR, JSMSG_DEBUG_BAD_REFERENT,
|
||||
JSDVG_SEARCH_STACK, args.thisv(), nullptr,
|
||||
refname, nullptr);
|
||||
ReportValueError(cx, JSMSG_DEBUG_BAD_REFERENT, JSDVG_SEARCH_STACK, args.thisv(), nullptr,
|
||||
refname);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -7007,9 +7003,8 @@ DebuggerSource_checkThis(JSContext* cx, const CallArgs& args, const char* fnname
|
|||
return nullptr;
|
||||
|
||||
if (!GetSourceReferent(thisobj).is<ReferentT>()) {
|
||||
ReportValueErrorFlags(cx, JSREPORT_ERROR, JSMSG_DEBUG_BAD_REFERENT,
|
||||
JSDVG_SEARCH_STACK, args.thisv(), nullptr,
|
||||
refname, nullptr);
|
||||
ReportValueError(cx, JSMSG_DEBUG_BAD_REFERENT, JSDVG_SEARCH_STACK, args.thisv(), nullptr,
|
||||
refname);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -7092,9 +7087,8 @@ DebuggerSource_getBinary(JSContext* cx, unsigned argc, Value* vp)
|
|||
THIS_DEBUGSOURCE_REFERENT(cx, argc, vp, "(get binary)", args, obj, referent);
|
||||
|
||||
if (!referent.is<WasmInstanceObject*>()) {
|
||||
ReportValueErrorFlags(cx, JSREPORT_ERROR, JSMSG_DEBUG_BAD_REFERENT,
|
||||
JSDVG_SEARCH_STACK, args.thisv(), nullptr,
|
||||
"a wasm source", nullptr);
|
||||
ReportValueError(cx, JSMSG_DEBUG_BAD_REFERENT, JSDVG_SEARCH_STACK, args.thisv(), nullptr,
|
||||
"a wasm source");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -8097,9 +8091,8 @@ DebuggerFrame::requireScriptReferent(JSContext* cx, HandleDebuggerFrame frame)
|
|||
AbstractFramePtr referent = DebuggerFrame::getReferent(frame);
|
||||
if (!referent.hasScript()) {
|
||||
RootedValue frameobj(cx, ObjectValue(*frame));
|
||||
ReportValueErrorFlags(cx, JSREPORT_ERROR, JSMSG_DEBUG_BAD_REFERENT,
|
||||
JSDVG_SEARCH_STACK, frameobj, nullptr,
|
||||
"a script frame", nullptr);
|
||||
ReportValueError(cx, JSMSG_DEBUG_BAD_REFERENT, JSDVG_SEARCH_STACK, frameobj, nullptr,
|
||||
"a script frame");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -10707,13 +10700,11 @@ DebuggerObject::requireGlobal(JSContext* cx, HandleDebuggerObject object)
|
|||
|
||||
RootedValue dbgobj(cx, ObjectValue(*object));
|
||||
if (referent->is<GlobalObject>()) {
|
||||
ReportValueErrorFlags(cx, JSREPORT_ERROR, JSMSG_DEBUG_WRAPPER_IN_WAY,
|
||||
JSDVG_SEARCH_STACK, dbgobj, nullptr,
|
||||
ReportValueError(cx, JSMSG_DEBUG_WRAPPER_IN_WAY, JSDVG_SEARCH_STACK, dbgobj, nullptr,
|
||||
isWrapper, isWindowProxy);
|
||||
} else {
|
||||
ReportValueErrorFlags(cx, JSREPORT_ERROR, JSMSG_DEBUG_BAD_REFERENT,
|
||||
JSDVG_SEARCH_STACK, dbgobj, nullptr,
|
||||
"a global object", nullptr);
|
||||
ReportValueError(cx, JSMSG_DEBUG_BAD_REFERENT, JSDVG_SEARCH_STACK, dbgobj, nullptr,
|
||||
"a global object");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
#include "mozilla/Range.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "jsexn.h"
|
||||
|
||||
#include "js/CallArgs.h"
|
||||
|
@ -38,7 +40,7 @@ js::ErrorObject::assignInitialShape(JSContext* cx, Handle<ErrorObject*> obj)
|
|||
|
||||
/* static */ bool
|
||||
js::ErrorObject::init(JSContext* cx, Handle<ErrorObject*> obj, JSExnType type,
|
||||
ScopedJSFreePtr<JSErrorReport>* errorReport, HandleString fileName,
|
||||
UniquePtr<JSErrorReport> errorReport, HandleString fileName,
|
||||
HandleObject stack, uint32_t lineNumber, uint32_t columnNumber,
|
||||
HandleString message)
|
||||
{
|
||||
|
@ -72,7 +74,7 @@ js::ErrorObject::init(JSContext* cx, Handle<ErrorObject*> obj, JSExnType type,
|
|||
|
||||
MOZ_ASSERT(JSEXN_ERR <= type && type < JSEXN_LIMIT);
|
||||
|
||||
JSErrorReport* report = errorReport ? errorReport->forget() : nullptr;
|
||||
JSErrorReport* report = errorReport.release();
|
||||
obj->initReservedSlot(EXNTYPE_SLOT, Int32Value(type));
|
||||
obj->initReservedSlot(STACK_SLOT, ObjectOrNullValue(stack));
|
||||
obj->setReservedSlot(ERROR_REPORT_SLOT, PrivateValue(report));
|
||||
|
@ -88,7 +90,7 @@ js::ErrorObject::init(JSContext* cx, Handle<ErrorObject*> obj, JSExnType type,
|
|||
/* static */ ErrorObject*
|
||||
js::ErrorObject::create(JSContext* cx, JSExnType errorType, HandleObject stack,
|
||||
HandleString fileName, uint32_t lineNumber, uint32_t columnNumber,
|
||||
ScopedJSFreePtr<JSErrorReport>* report, HandleString message,
|
||||
UniquePtr<JSErrorReport> report, HandleString message,
|
||||
HandleObject protoArg /* = nullptr */)
|
||||
{
|
||||
AssertObjectIsSavedFrameOrWrapper(cx, stack);
|
||||
|
@ -109,7 +111,7 @@ js::ErrorObject::create(JSContext* cx, JSExnType errorType, HandleObject stack,
|
|||
errObject = &obj->as<ErrorObject>();
|
||||
}
|
||||
|
||||
if (!ErrorObject::init(cx, errObject, errorType, report, fileName, stack,
|
||||
if (!ErrorObject::init(cx, errObject, errorType, std::move(report), fileName, stack,
|
||||
lineNumber, columnNumber, message))
|
||||
{
|
||||
return nullptr;
|
||||
|
@ -156,11 +158,11 @@ js::ErrorObject::getOrCreateErrorReport(JSContext* cx)
|
|||
report.initOwnedMessage(utf8.release());
|
||||
|
||||
// Cache and return.
|
||||
JSErrorReport* copy = CopyErrorReport(cx, &report);
|
||||
UniquePtr<JSErrorReport> copy = CopyErrorReport(cx, &report);
|
||||
if (!copy)
|
||||
return nullptr;
|
||||
setReservedSlot(ERROR_REPORT_SLOT, PrivateValue(copy));
|
||||
return copy;
|
||||
setReservedSlot(ERROR_REPORT_SLOT, PrivateValue(copy.get()));
|
||||
return copy.release();
|
||||
}
|
||||
|
||||
static bool
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
|
||||
#include "js/UniquePtr.h"
|
||||
#include "vm/NativeObject.h"
|
||||
#include "vm/SavedStacks.h"
|
||||
#include "vm/Shape.h"
|
||||
|
@ -35,7 +36,7 @@ class ErrorObject : public NativeObject
|
|||
|
||||
static bool
|
||||
init(JSContext* cx, Handle<ErrorObject*> obj, JSExnType type,
|
||||
ScopedJSFreePtr<JSErrorReport>* errorReport, HandleString fileName, HandleObject stack,
|
||||
UniquePtr<JSErrorReport> errorReport, HandleString fileName, HandleObject stack,
|
||||
uint32_t lineNumber, uint32_t columnNumber, HandleString message);
|
||||
|
||||
static const ClassSpec classSpecs[JSEXN_ERROR_LIMIT];
|
||||
|
@ -70,7 +71,7 @@ class ErrorObject : public NativeObject
|
|||
// property.
|
||||
static ErrorObject*
|
||||
create(JSContext* cx, JSExnType type, HandleObject stack, HandleString fileName,
|
||||
uint32_t lineNumber, uint32_t columnNumber, ScopedJSFreePtr<JSErrorReport>* report,
|
||||
uint32_t lineNumber, uint32_t columnNumber, UniquePtr<JSErrorReport> report,
|
||||
HandleString message, HandleObject proto = nullptr);
|
||||
|
||||
/*
|
||||
|
|
|
@ -994,7 +994,7 @@ js::CheckClassHeritageOperation(JSContext* cx, HandleValue heritage)
|
|||
return false;
|
||||
}
|
||||
|
||||
ReportValueError2(cx, JSMSG_BAD_HERITAGE, -1, heritage, nullptr, "not an object or null");
|
||||
ReportValueError(cx, JSMSG_BAD_HERITAGE, -1, heritage, nullptr, "not an object or null");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -895,36 +895,26 @@ js::ReportIsNotDefined(JSContext* cx, HandlePropertyName name)
|
|||
ReportIsNotDefined(cx, id);
|
||||
}
|
||||
|
||||
bool
|
||||
js::ReportIsNullOrUndefined(JSContext* cx, int spindex, HandleValue v,
|
||||
HandleString fallback)
|
||||
void
|
||||
js::ReportIsNullOrUndefined(JSContext* cx, int spindex, HandleValue v)
|
||||
{
|
||||
bool ok;
|
||||
MOZ_ASSERT(v.isNullOrUndefined());
|
||||
|
||||
UniqueChars bytes = DecompileValueGenerator(cx, spindex, v, fallback);
|
||||
UniqueChars bytes = DecompileValueGenerator(cx, spindex, v, nullptr);
|
||||
if (!bytes)
|
||||
return false;
|
||||
return;
|
||||
|
||||
if (strcmp(bytes.get(), js_undefined_str) == 0 ||
|
||||
strcmp(bytes.get(), js_null_str) == 0) {
|
||||
ok = JS_ReportErrorFlagsAndNumberLatin1(cx, JSREPORT_ERROR,
|
||||
GetErrorMessage, nullptr,
|
||||
JSMSG_NO_PROPERTIES,
|
||||
if (strcmp(bytes.get(), js_undefined_str) == 0 || strcmp(bytes.get(), js_null_str) == 0) {
|
||||
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr, JSMSG_NO_PROPERTIES,
|
||||
bytes.get());
|
||||
} else if (v.isUndefined()) {
|
||||
ok = JS_ReportErrorFlagsAndNumberLatin1(cx, JSREPORT_ERROR,
|
||||
GetErrorMessage, nullptr,
|
||||
JSMSG_UNEXPECTED_TYPE,
|
||||
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE,
|
||||
bytes.get(), js_undefined_str);
|
||||
} else {
|
||||
MOZ_ASSERT(v.isNull());
|
||||
ok = JS_ReportErrorFlagsAndNumberLatin1(cx, JSREPORT_ERROR,
|
||||
GetErrorMessage, nullptr,
|
||||
JSMSG_UNEXPECTED_TYPE,
|
||||
JS_ReportErrorNumberLatin1(cx, GetErrorMessage, nullptr, JSMSG_UNEXPECTED_TYPE,
|
||||
bytes.get(), js_null_str);
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -950,18 +940,14 @@ js::ReportValueErrorFlags(JSContext* cx, unsigned flags, const unsigned errorNum
|
|||
int spindex, HandleValue v, HandleString fallback,
|
||||
const char* arg1, const char* arg2)
|
||||
{
|
||||
UniqueChars bytes;
|
||||
bool ok;
|
||||
|
||||
MOZ_ASSERT(js_ErrorFormatString[errorNumber].argCount >= 1);
|
||||
MOZ_ASSERT(js_ErrorFormatString[errorNumber].argCount <= 3);
|
||||
bytes = DecompileValueGenerator(cx, spindex, v, fallback);
|
||||
UniqueChars bytes = DecompileValueGenerator(cx, spindex, v, fallback);
|
||||
if (!bytes)
|
||||
return false;
|
||||
|
||||
ok = JS_ReportErrorFlagsAndNumberLatin1(cx, flags, GetErrorMessage, nullptr, errorNumber,
|
||||
return JS_ReportErrorFlagsAndNumberLatin1(cx, flags, GetErrorMessage, nullptr, errorNumber,
|
||||
bytes.get(), arg1, arg2);
|
||||
return ok;
|
||||
}
|
||||
|
||||
JSObject*
|
||||
|
|
|
@ -1015,8 +1015,8 @@ ReportIsNotDefined(JSContext* cx, HandleId id);
|
|||
/*
|
||||
* Report an attempt to access the property of a null or undefined value (v).
|
||||
*/
|
||||
extern bool
|
||||
ReportIsNullOrUndefined(JSContext* cx, int spindex, HandleValue v, HandleString fallback);
|
||||
extern void
|
||||
ReportIsNullOrUndefined(JSContext* cx, int spindex, HandleValue v);
|
||||
|
||||
extern void
|
||||
ReportMissingArg(JSContext* cx, js::HandleValue v, unsigned arg);
|
||||
|
@ -1031,17 +1031,12 @@ ReportValueErrorFlags(JSContext* cx, unsigned flags, const unsigned errorNumber,
|
|||
int spindex, HandleValue v, HandleString fallback,
|
||||
const char* arg1, const char* arg2);
|
||||
|
||||
#define ReportValueError(cx,errorNumber,spindex,v,fallback) \
|
||||
((void)ReportValueErrorFlags(cx, JSREPORT_ERROR, errorNumber, \
|
||||
spindex, v, fallback, nullptr, nullptr))
|
||||
|
||||
#define ReportValueError2(cx,errorNumber,spindex,v,fallback,arg1) \
|
||||
((void)ReportValueErrorFlags(cx, JSREPORT_ERROR, errorNumber, \
|
||||
spindex, v, fallback, arg1, nullptr))
|
||||
|
||||
#define ReportValueError3(cx,errorNumber,spindex,v,fallback,arg1,arg2) \
|
||||
((void)ReportValueErrorFlags(cx, JSREPORT_ERROR, errorNumber, \
|
||||
spindex, v, fallback, arg1, arg2))
|
||||
inline void
|
||||
ReportValueError(JSContext* cx, const unsigned errorNumber, int spindex, HandleValue v,
|
||||
HandleString fallback, const char* arg1 = nullptr, const char* arg2 = nullptr)
|
||||
{
|
||||
ReportValueErrorFlags(cx, JSREPORT_ERROR, errorNumber, spindex, v, fallback, arg1, arg2);
|
||||
}
|
||||
|
||||
JSObject*
|
||||
CreateErrorNotesArray(JSContext* cx, JSErrorReport* report);
|
||||
|
|
|
@ -116,8 +116,7 @@ AdvanceToActiveCallLinear(JSContext* cx, NonBuiltinScriptFrameIter& iter, Handle
|
|||
void
|
||||
js::ThrowTypeErrorBehavior(JSContext* cx)
|
||||
{
|
||||
JS_ReportErrorFlagsAndNumberASCII(cx, JSREPORT_ERROR, GetErrorMessage, nullptr,
|
||||
JSMSG_THROW_TYPE_ERROR);
|
||||
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_THROW_TYPE_ERROR);
|
||||
}
|
||||
|
||||
static bool
|
||||
|
@ -311,8 +310,7 @@ CallerGetterImpl(JSContext* cx, const CallArgs& args)
|
|||
MOZ_ASSERT(!callerFun->isBuiltin(), "non-builtin iterator returned a builtin?");
|
||||
|
||||
if (callerFun->strict()) {
|
||||
JS_ReportErrorFlagsAndNumberASCII(cx, JSREPORT_ERROR, GetErrorMessage, nullptr,
|
||||
JSMSG_CALLER_IS_STRICT);
|
||||
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_CALLER_IS_STRICT);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -380,8 +378,7 @@ CallerSetterImpl(JSContext* cx, const CallArgs& args)
|
|||
MOZ_ASSERT(!callerFun->isBuiltin(), "non-builtin iterator returned a builtin?");
|
||||
|
||||
if (callerFun->strict()) {
|
||||
JS_ReportErrorFlagsAndNumberASCII(cx, JSREPORT_ERROR, GetErrorMessage, nullptr,
|
||||
JSMSG_CALLER_IS_STRICT);
|
||||
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_CALLER_IS_STRICT);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -2624,33 +2624,6 @@ js::HasOwnDataPropertyPure(JSContext* cx, JSObject* obj, jsid id, bool* result)
|
|||
return true;
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
JSObject::reportReadOnly(JSContext* cx, jsid id, unsigned report)
|
||||
{
|
||||
RootedValue val(cx, IdToValue(id));
|
||||
return ReportValueErrorFlags(cx, report, JSMSG_READ_ONLY,
|
||||
JSDVG_IGNORE_STACK, val, nullptr,
|
||||
nullptr, nullptr);
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
JSObject::reportNotConfigurable(JSContext* cx, jsid id, unsigned report)
|
||||
{
|
||||
RootedValue val(cx, IdToValue(id));
|
||||
return ReportValueErrorFlags(cx, report, JSMSG_CANT_DELETE,
|
||||
JSDVG_IGNORE_STACK, val, nullptr,
|
||||
nullptr, nullptr);
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
JSObject::reportNotExtensible(JSContext* cx, HandleObject obj, unsigned report)
|
||||
{
|
||||
RootedValue val(cx, ObjectValue(*obj));
|
||||
return ReportValueErrorFlags(cx, report, JSMSG_OBJECT_NOT_EXTENSIBLE,
|
||||
JSDVG_IGNORE_STACK, val, nullptr,
|
||||
nullptr, nullptr);
|
||||
}
|
||||
|
||||
bool
|
||||
js::GetPrototypeIfOrdinary(JSContext* cx, HandleObject obj, bool* isOrdinary,
|
||||
MutableHandleObject protop)
|
||||
|
@ -3086,7 +3059,7 @@ ReportCantConvert(JSContext* cx, unsigned errorNumber, HandleObject obj, JSType
|
|||
}
|
||||
|
||||
RootedValue val(cx, ObjectValue(*obj));
|
||||
ReportValueError2(cx, errorNumber, JSDVG_SEARCH_STACK, val, str,
|
||||
ReportValueError(cx, errorNumber, JSDVG_SEARCH_STACK, val, str,
|
||||
hint == JSTYPE_UNDEFINED
|
||||
? "primitive type"
|
||||
: hint == JSTYPE_STRING ? "string" : "number");
|
||||
|
@ -3273,7 +3246,7 @@ js::PrimitiveToObject(JSContext* cx, const Value& v)
|
|||
|
||||
/*
|
||||
* Invokes the ES5 ToObject algorithm on vp, returning the result. If vp might
|
||||
* already be an object, use ToObject. reportCantConvert controls how null and
|
||||
* already be an object, use ToObject. reportScanStack controls how null and
|
||||
* undefined errors are reported.
|
||||
*
|
||||
* Callers must handle the already-object case.
|
||||
|
@ -3286,7 +3259,7 @@ js::ToObjectSlow(JSContext* cx, JS::HandleValue val, bool reportScanStack)
|
|||
|
||||
if (val.isNullOrUndefined()) {
|
||||
if (reportScanStack) {
|
||||
ReportIsNullOrUndefined(cx, JSDVG_SEARCH_STACK, val, nullptr);
|
||||
ReportIsNullOrUndefined(cx, JSDVG_SEARCH_STACK, val);
|
||||
} else {
|
||||
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_CANT_CONVERT_TO,
|
||||
val.isNull() ? "null" : "undefined", "object");
|
||||
|
|
|
@ -480,11 +480,6 @@ class JSObject : public js::gc::Cell
|
|||
MOZ_ALWAYS_INLINE void finalize(js::FreeOp* fop);
|
||||
|
||||
public:
|
||||
static bool reportReadOnly(JSContext* cx, jsid id, unsigned report = JSREPORT_ERROR);
|
||||
static bool reportNotConfigurable(JSContext* cx, jsid id, unsigned report = JSREPORT_ERROR);
|
||||
static bool reportNotExtensible(JSContext* cx, js::HandleObject obj,
|
||||
unsigned report = JSREPORT_ERROR);
|
||||
|
||||
static bool nonNativeSetProperty(JSContext* cx, js::HandleObject obj, js::HandleId id,
|
||||
js::HandleValue v, js::HandleValue receiver,
|
||||
JS::ObjectOpResult& result);
|
||||
|
|
|
@ -967,8 +967,9 @@ ThrowIfNotConstructing(JSContext *cx, const CallArgs &args, const char *builtinN
|
|||
{
|
||||
if (args.isConstructing())
|
||||
return true;
|
||||
return JS_ReportErrorFlagsAndNumberASCII(cx, JSREPORT_ERROR, GetErrorMessage, nullptr,
|
||||
JSMSG_BUILTIN_CTOR_NO_NEW, builtinName);
|
||||
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_BUILTIN_CTOR_NO_NEW,
|
||||
builtinName);
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool
|
||||
|
|
|
@ -1707,18 +1707,8 @@ js::NativeDefineProperty(JSContext* cx, HandleNativeObject obj, HandleId id,
|
|||
return result.succeed();
|
||||
}
|
||||
|
||||
// Non-standard hack: Allow redefining non-configurable properties if
|
||||
// JSPROP_REDEFINE_NONCONFIGURABLE is set _and_ the object is a non-DOM
|
||||
// global. The idea is that a DOM object can never have such a thing on
|
||||
// its proto chain directly on the web, so we should be OK optimizing
|
||||
// access to accessors found on such an object. Bug 1105518 contemplates
|
||||
// removing this hack.
|
||||
bool skipRedefineChecks = (desc.attributes() & JSPROP_REDEFINE_NONCONFIGURABLE) &&
|
||||
obj->is<GlobalObject>() &&
|
||||
!obj->getClass()->isDOMClass();
|
||||
|
||||
// Step 4.
|
||||
if (!IsConfigurable(shapeAttrs) && !skipRedefineChecks) {
|
||||
if (!IsConfigurable(shapeAttrs)) {
|
||||
if (desc.hasConfigurable() && desc.configurable())
|
||||
return result.fail(JSMSG_CANT_REDEFINE_PROP);
|
||||
if (desc.hasEnumerable() && desc.enumerable() != IsEnumerable(shapeAttrs))
|
||||
|
@ -1753,7 +1743,7 @@ js::NativeDefineProperty(JSContext* cx, HandleNativeObject obj, HandleId id,
|
|||
}
|
||||
} else if (desc.isDataDescriptor() != IsDataDescriptor(shapeAttrs)) {
|
||||
// Step 6.
|
||||
if (!IsConfigurable(shapeAttrs) && !skipRedefineChecks)
|
||||
if (!IsConfigurable(shapeAttrs))
|
||||
return result.fail(JSMSG_CANT_REDEFINE_PROP);
|
||||
|
||||
// Fill in desc fields with default values (steps 6.b.i and 6.c.i).
|
||||
|
@ -1763,7 +1753,7 @@ js::NativeDefineProperty(JSContext* cx, HandleNativeObject obj, HandleId id,
|
|||
bool frozen = !IsConfigurable(shapeAttrs) && !IsWritable(shapeAttrs);
|
||||
|
||||
// Step 7.a.i.1.
|
||||
if (frozen && desc.hasWritable() && desc.writable() && !skipRedefineChecks)
|
||||
if (frozen && desc.hasWritable() && desc.writable())
|
||||
return result.fail(JSMSG_CANT_REDEFINE_PROP);
|
||||
|
||||
if (frozen || !desc.hasValue()) {
|
||||
|
@ -1780,13 +1770,13 @@ js::NativeDefineProperty(JSContext* cx, HandleNativeObject obj, HandleId id,
|
|||
MOZ_ASSERT(!cx->helperThread());
|
||||
if (!SameValue(cx, desc.value(), currentValue, &same))
|
||||
return false;
|
||||
if (!same && !skipRedefineChecks)
|
||||
if (!same)
|
||||
return result.fail(JSMSG_CANT_REDEFINE_PROP);
|
||||
}
|
||||
}
|
||||
|
||||
// Step 7.a.i.3.
|
||||
if (frozen && !skipRedefineChecks)
|
||||
if (frozen)
|
||||
return result.succeed();
|
||||
|
||||
// Fill in desc.[[Writable]].
|
||||
|
@ -1802,8 +1792,7 @@ js::NativeDefineProperty(JSContext* cx, HandleNativeObject obj, HandleId id,
|
|||
if (desc.hasSetterObject()) {
|
||||
// Step 8.a.i.
|
||||
if (!IsConfigurable(shapeAttrs) &&
|
||||
desc.setterObject() != prop.shape()->setterObject() &&
|
||||
!skipRedefineChecks)
|
||||
desc.setterObject() != prop.shape()->setterObject())
|
||||
{
|
||||
return result.fail(JSMSG_CANT_REDEFINE_PROP);
|
||||
}
|
||||
|
@ -1814,8 +1803,7 @@ js::NativeDefineProperty(JSContext* cx, HandleNativeObject obj, HandleId id,
|
|||
if (desc.hasGetterObject()) {
|
||||
// Step 8.a.ii.
|
||||
if (!IsConfigurable(shapeAttrs) &&
|
||||
desc.getterObject() != prop.shape()->getterObject() &&
|
||||
!skipRedefineChecks)
|
||||
desc.getterObject() != prop.shape()->getterObject())
|
||||
{
|
||||
return result.fail(JSMSG_CANT_REDEFINE_PROP);
|
||||
}
|
||||
|
|
|
@ -1423,8 +1423,7 @@ js::ParseRegExpFlags(JSContext* cx, JSString* flagStr, RegExpFlag* flagsOut)
|
|||
UniqueChars utf8(JS::CharsToNewUTF8CharsZ(nullptr, range).c_str());
|
||||
if (!utf8)
|
||||
return false;
|
||||
JS_ReportErrorFlagsAndNumberUTF8(cx, JSREPORT_ERROR, GetErrorMessage, nullptr,
|
||||
JSMSG_BAD_REGEXP_FLAG, utf8.get());
|
||||
JS_ReportErrorNumberUTF8(cx, GetErrorMessage, nullptr, JSMSG_BAD_REGEXP_FLAG, utf8.get());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -2906,8 +2906,8 @@ VerifyGlobalNames(JSContext* cx, Handle<GlobalObject*> shg)
|
|||
|
||||
if (nameMissing) {
|
||||
RootedValue value(cx, IdToValue(id));
|
||||
return ReportValueErrorFlags(cx, JSREPORT_ERROR, JSMSG_NO_SUCH_SELF_HOSTED_PROP,
|
||||
JSDVG_IGNORE_STACK, value, nullptr, nullptr, nullptr);
|
||||
ReportValueError(cx, JSMSG_NO_SUCH_SELF_HOSTED_PROP, JSDVG_IGNORE_STACK, value, nullptr);
|
||||
return false;
|
||||
}
|
||||
#endif // DEBUG
|
||||
|
||||
|
|
|
@ -72,8 +72,9 @@ struct DisplayItemClipChain {
|
|||
{}
|
||||
|
||||
DisplayItemClipChain()
|
||||
: mASR(nullptr)
|
||||
#ifdef DEBUG
|
||||
: mOnStack(true)
|
||||
, mOnStack(true)
|
||||
#endif
|
||||
{}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ DottedCornerFinder::DottedCornerFinder(const Bezier& aOuterBezier,
|
|||
mNormalSign((aCorner == C_TL || aCorner == C_BR) ? -1.0f : 1.0f),
|
||||
mC0(aC0), mCn(aCn),
|
||||
mR0(aR0), mRn(aRn), mMaxR(std::max(aR0, aRn)),
|
||||
mCenterCurveOrigin(mC0.x, mCn.y),
|
||||
mCenterCurveOrigin(mC0.x, mCn.y), mCenterCurveR(0.0),
|
||||
mInnerCurveOrigin(mInnerBezier.mPoints[0].x, mInnerBezier.mPoints[3].y),
|
||||
mBestOverlap(0.0f),
|
||||
mHasZeroBorderWidth(false), mHasMore(true),
|
||||
|
|
|
@ -533,6 +533,7 @@ public:
|
|||
PaintedLayerData() :
|
||||
mAnimatedGeometryRoot(nullptr),
|
||||
mASR(nullptr),
|
||||
mClipChain(nullptr),
|
||||
mReferenceFrame(nullptr),
|
||||
mLayer(nullptr),
|
||||
mSolidColor(NS_RGBA(0, 0, 0, 0)),
|
||||
|
@ -1637,7 +1638,8 @@ public:
|
|||
mAnimatedGeometryRootPosition(0, 0),
|
||||
mLastItemCount(0),
|
||||
mContainerLayerFrame(nullptr),
|
||||
mHasExplicitLastPaintOffset(false) {}
|
||||
mHasExplicitLastPaintOffset(false),
|
||||
mDisabledAlpha(false) {}
|
||||
|
||||
NS_INLINE_DECL_REFCOUNTING(PaintedDisplayItemLayerUserData);
|
||||
|
||||
|
@ -1725,6 +1727,7 @@ protected:
|
|||
|
||||
FrameLayerBuilder::FrameLayerBuilder()
|
||||
: mRetainingManager(nullptr)
|
||||
, mDisplayListBuilder(nullptr)
|
||||
, mContainingPaintedLayer(nullptr)
|
||||
, mInactiveLayerClip(nullptr)
|
||||
, mInvalidateAllLayers(false)
|
||||
|
|
|
@ -77,7 +77,10 @@ static int gFrameTreeLockCount = 0;
|
|||
struct InlineBackgroundData
|
||||
{
|
||||
InlineBackgroundData()
|
||||
: mFrame(nullptr), mLineContainer(nullptr)
|
||||
: mFrame(nullptr), mLineContainer(nullptr),
|
||||
mContinuationPoint(0), mUnbrokenMeasure(0),
|
||||
mLineContinuationPoint(0), mPIStartBorderData{},
|
||||
mBidiEnabled(false), mVertical(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,12 @@ public:
|
|||
float aOpacity = 1.0);
|
||||
|
||||
private:
|
||||
nsCSSGradientRenderer() {}
|
||||
nsCSSGradientRenderer()
|
||||
: mPresContext(nullptr)
|
||||
, mGradient(nullptr)
|
||||
, mRadiusX(0.0)
|
||||
, mRadiusY(0.0)
|
||||
{}
|
||||
|
||||
/**
|
||||
* Attempts to paint the tiles for a gradient by painting it once to an
|
||||
|
|
|
@ -323,6 +323,9 @@ struct ActiveScrolledRoot {
|
|||
|
||||
private:
|
||||
ActiveScrolledRoot()
|
||||
: mScrollableFrame(nullptr)
|
||||
, mDepth(0)
|
||||
, mRetained(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -33,8 +33,11 @@ struct CSSSizeOrRatio
|
|||
{
|
||||
CSSSizeOrRatio()
|
||||
: mRatio(0, 0)
|
||||
, mWidth(0)
|
||||
, mHeight(0)
|
||||
, mHasWidth(false)
|
||||
, mHasHeight(false) {}
|
||||
, mHasHeight(false)
|
||||
{}
|
||||
|
||||
bool CanComputeConcreteSize() const
|
||||
{
|
||||
|
|
|
@ -190,7 +190,10 @@ public:
|
|||
float GetStrokeOpacity() const override { return mStrokeOpacity; }
|
||||
|
||||
struct Paint {
|
||||
Paint() : mPaintType(eStyleSVGPaintType_None) {}
|
||||
Paint()
|
||||
: mPaintDefinition{}
|
||||
, mPaintType(eStyleSVGPaintType_None)
|
||||
{}
|
||||
|
||||
void SetPaintServer(nsIFrame* aFrame,
|
||||
const gfxMatrix& aContextMatrix,
|
||||
|
|
|
@ -2439,10 +2439,12 @@ CharIterator::CharIterator(SVGTextFrame* aSVGTextFrame,
|
|||
mFrameForTrimCheck(nullptr),
|
||||
mTrimmedOffset(0),
|
||||
mTrimmedLength(0),
|
||||
mTextRun(nullptr),
|
||||
mTextElementCharIndex(0),
|
||||
mGlyphStartTextElementCharIndex(0),
|
||||
mLengthAdjustScaleFactor(aSVGTextFrame->mLengthAdjustScaleFactor)
|
||||
, mPostReflow(aPostReflow)
|
||||
mGlyphUndisplayedCharacters(0),
|
||||
mLengthAdjustScaleFactor(aSVGTextFrame->mLengthAdjustScaleFactor),
|
||||
mPostReflow(aPostReflow)
|
||||
{
|
||||
if (!AtEnd()) {
|
||||
mSkipCharsIterator = TextFrame()->EnsureTextRun(nsTextFrame::eInflated);
|
||||
|
@ -2772,7 +2774,8 @@ public:
|
|||
mContext(aContext),
|
||||
mFrame(aFrame),
|
||||
mCanvasTM(aCanvasTM),
|
||||
mImgParams(aImgParams)
|
||||
mImgParams(aImgParams),
|
||||
mColor(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче