diff --git a/dom/base/TabGroup.cpp b/dom/base/TabGroup.cpp index 3f6c903ea22f..5884bb6df7a7 100644 --- a/dom/base/TabGroup.cpp +++ b/dom/base/TabGroup.cpp @@ -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 sChromeTabGroup; +LinkedList* 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(); + } + 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* listElement = + static_cast*>(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*>(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 diff --git a/dom/base/TabGroup.h b/dom/base/TabGroup.h index 153f652dc73e..9ed8eefe5056 100644 --- a/dom/base/TabGroup.h +++ b/dom/base/TabGroup.h @@ -46,7 +46,8 @@ class TabChild; class DocGroup; class TabChild; -class TabGroup final : public SchedulerGroup +class TabGroup final : public SchedulerGroup, + public LinkedListElement { private: class HashEntry : public nsCStringHashKey @@ -146,6 +147,16 @@ public: return mNumOfIndexedDBDatabases; } + static LinkedList* 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 mWindows; uint32_t mForegroundCount; + + static LinkedList* sTabGroups; }; } // namespace dom diff --git a/dom/base/TimeoutManager.h b/dom/base/TimeoutManager.h index 6040f1ec2971..79c356bf096d 100644 --- a/dom/base/TimeoutManager.h +++ b/dom/base/TimeoutManager.h @@ -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) diff --git a/dom/smil/nsSMILKeySpline.h b/dom/smil/nsSMILKeySpline.h index 36c14fec1fef..c651c278fa5c 100644 --- a/dom/smil/nsSMILKeySpline.h +++ b/dom/smil/nsSMILKeySpline.h @@ -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); } diff --git a/dom/smil/nsSMILValue.cpp b/dom/smil/nsSMILValue.cpp index e5f904bb591e..fe67af84f2f9 100644 --- a/dom/smil/nsSMILValue.cpp +++ b/dom/smil/nsSMILValue.cpp @@ -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; diff --git a/dom/svg/DOMSVGPathSegList.h b/dom/svg/DOMSVGPathSegList.h index 5683f5f6dd33..84bb5ef036fb 100644 --- a/dom/svg/DOMSVGPathSegList.h +++ b/dom/svg/DOMSVGPathSegList.h @@ -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) diff --git a/dom/svg/SVGAnimatedNumberList.h b/dom/svg/SVGAnimatedNumberList.h index 6b5e78c79c81..7300b286e51a 100644 --- a/dom/svg/SVGAnimatedNumberList.h +++ b/dom/svg/SVGAnimatedNumberList.h @@ -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 diff --git a/dom/svg/SVGGeometryElement.h b/dom/svg/SVGGeometryElement.h index cef22975dade..54a7ea61412e 100644 --- a/dom/svg/SVGGeometryElement.h +++ b/dom/svg/SVGGeometryElement.h @@ -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; diff --git a/dom/svg/SVGLength.h b/dom/svg/SVGLength.h index 12757aa4fb58..6f4847be184e 100644 --- a/dom/svg/SVGLength.h +++ b/dom/svg/SVGLength.h @@ -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) diff --git a/dom/svg/SVGLengthList.h b/dom/svg/SVGLengthList.h index f9c8bd35613f..f74fb5ba6cf3 100644 --- a/dom/svg/SVGLengthList.h +++ b/dom/svg/SVGLengthList.h @@ -311,6 +311,8 @@ public: SVGUserUnitList() : mList(nullptr) + , mElement(nullptr) + , mAxis(0) {} void Init(const SVGLengthList *aList, nsSVGElement *aElement, uint8_t aAxis) { diff --git a/dom/svg/SVGMotionSMILType.cpp b/dom/svg/SVGMotionSMILType.cpp index 4b29f882a72f..524d4672bd7e 100644 --- a/dom/svg/SVGMotionSMILType.cpp +++ b/dom/svg/SVGMotionSMILType.cpp @@ -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 diff --git a/dom/svg/nsSVGViewBox.h b/dom/svg/nsSVGViewBox.h index edf511e983d3..a0725a92d305 100644 --- a/dom/svg/nsSVGViewBox.h +++ b/dom/svg/nsSVGViewBox.h @@ -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) : diff --git a/js/src/builtin/ReflectParse.cpp b/js/src/builtin/ReflectParse.cpp index 1f052be21706..44a5cf9bf99f 100644 --- a/js/src/builtin/ReflectParse.cpp +++ b/js/src/builtin/ReflectParse.cpp @@ -282,8 +282,7 @@ class NodeBuilder } if (!funv.isObject() || !funv.toObject().is()) { - 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; } diff --git a/js/src/builtin/Stream.cpp b/js/src/builtin/Stream.cpp index 1e6c01ad5f7a..0a0407f581b1 100644 --- a/js/src/builtin/Stream.cpp +++ b/js/src/builtin/Stream.cpp @@ -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,8 +305,8 @@ 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(), - nullptr, className, methodName); + ReportValueError(cx, JSMSG_INCOMPATIBLE_PROTO, JSDVG_SEARCH_STACK, args.thisv(), + nullptr, className, methodName); return ReturnPromiseRejectedWithPendingError(cx, args); } @@ -803,8 +801,8 @@ 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(args.thisv())) { - ReportValueError3(cx, JSMSG_INCOMPATIBLE_PROTO, JSDVG_SEARCH_STACK, args.thisv(), - nullptr, "cancel", ""); + ReportValueError(cx, JSMSG_INCOMPATIBLE_PROTO, JSDVG_SEARCH_STACK, args.thisv(), + nullptr, "cancel", ""); return ReturnPromiseRejectedWithPendingError(cx, args); } diff --git a/js/src/builtin/Symbol.cpp b/js/src/builtin/Symbol.cpp index a6f4314c9fbc..411e7b2528d6 100644 --- a/js/src/builtin/Symbol.cpp +++ b/js/src/builtin/Symbol.cpp @@ -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; } diff --git a/js/src/builtin/TestingFunctions.cpp b/js/src/builtin/TestingFunctions.cpp index 8a28368c3819..fa102fdcb1d4 100644 --- a/js/src/builtin/TestingFunctions.cpp +++ b/js/src/builtin/TestingFunctions.cpp @@ -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()) { - 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()); 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; } diff --git a/js/src/ctypes/CTypes.cpp b/js/src/ctypes/CTypes.cpp index 0bac9d266abe..806ad08847cd 100644 --- a/js/src/ctypes/CTypes.cpp +++ b/js/src/ctypes/CTypes.cpp @@ -97,10 +97,8 @@ 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, - buffer); + JS_ReportErrorNumberASCII(maybecx, GetErrorMessage, nullptr, JSMSG_BAD_SURROGATE_CHAR, + buffer); } return (size_t) -1; } diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index c300848f7682..9f83f5cea4c0 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -7093,7 +7093,7 @@ JSErrorNotes::copy(JSContext* cx) } for (auto&& note : *this) { - js::UniquePtr copied(CopyErrorNote(cx, note.get())); + UniquePtr copied = CopyErrorNote(cx, note.get()); if (!copied) return nullptr; diff --git a/js/src/jsapi.h b/js/src/jsapi.h index 91d585842fc8..b82842ad3fa3 100644 --- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -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 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 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 JSPROP_READONLY | JSPROP_GETTER | JSPROP_SETTER | - JSPROP_REDEFINE_NONCONFIGURABLE | JSPROP_RESOLVING | SHADOWABLE)) == 0); MOZ_ASSERT_IF(isAccessorDescriptor(), has(JSPROP_GETTER) && has(JSPROP_SETTER)); diff --git a/js/src/jsdate.cpp b/js/src/jsdate.cpp index 2a2502656796..5e1a540a7b25 100644 --- a/js/src/jsdate.cpp +++ b/js/src/jsdate.cpp @@ -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; } diff --git a/js/src/jsexn.cpp b/js/src/jsexn.cpp index dafd663091fc..4bd5a96185cc 100644 --- a/js/src/jsexn.cpp +++ b/js/src/jsexn.cpp @@ -14,6 +14,7 @@ #include "mozilla/Sprintf.h" #include +#include #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 -static T* +static UniquePtr CopyErrorHelper(JSContext* cx, T* report) { /* @@ -298,7 +300,7 @@ CopyErrorHelper(JSContext* cx, T* report) if (!cursor) return nullptr; - T* copy = new (cursor) T(); + UniquePtr 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 js::CopyErrorNote(JSContext* cx, JSErrorNotes::Note* note) { return CopyErrorHelper(cx, note); } -JSErrorReport* +UniquePtr 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 report(CopyErrorReport(cx, reportp)); + UniquePtr 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 err) { - js::ScopedJSFreePtr copyReport; + UniquePtr copyReport; if (JSErrorReport* errorReport = err->getErrorReport()) { copyReport = CopyErrorReport(cx, errorReport); if (!copyReport) @@ -1012,7 +1011,7 @@ js::CopyErrorObject(JSContext* cx, Handle 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 rep; - if (report) + js::UniquePtr 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; diff --git a/js/src/jsexn.h b/js/src/jsexn.h index 233bcf6efbfd..f7fc36231701 100644 --- a/js/src/jsexn.h +++ b/js/src/jsexn.h @@ -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 CopyErrorNote(JSContext* cx, JSErrorNotes::Note* note); -JSErrorReport* +UniquePtr CopyErrorReport(JSContext* cx, JSErrorReport* report); JSString* diff --git a/js/src/vm/CharacterEncoding.cpp b/js/src/vm/CharacterEncoding.cpp index fea6dc566500..b041455f867c 100644 --- a/js/src/vm/CharacterEncoding.cpp +++ b/js/src/vm/CharacterEncoding.cpp @@ -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 { diff --git a/js/src/vm/Debugger.cpp b/js/src/vm/Debugger.cpp index 5bdbb6241a89..9bb6b8638b3e 100644 --- a/js/src/vm/Debugger.cpp +++ b/js/src/vm/Debugger.cpp @@ -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()) { - ReportValueErrorFlags(cx, JSREPORT_ERROR, JSMSG_DEBUG_WRAPPER_IN_WAY, - JSDVG_SEARCH_STACK, dbgobj, nullptr, - isWrapper, isWindowProxy); + 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()) { - 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()) { - 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()) { - 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()) { - ReportValueErrorFlags(cx, JSREPORT_ERROR, JSMSG_DEBUG_WRAPPER_IN_WAY, - JSDVG_SEARCH_STACK, dbgobj, nullptr, - isWrapper, isWindowProxy); + 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; } diff --git a/js/src/vm/ErrorObject.cpp b/js/src/vm/ErrorObject.cpp index dfa3526184b6..307ac897ec80 100644 --- a/js/src/vm/ErrorObject.cpp +++ b/js/src/vm/ErrorObject.cpp @@ -9,6 +9,8 @@ #include "mozilla/Range.h" +#include + #include "jsexn.h" #include "js/CallArgs.h" @@ -38,7 +40,7 @@ js::ErrorObject::assignInitialShape(JSContext* cx, Handle obj) /* static */ bool js::ErrorObject::init(JSContext* cx, Handle obj, JSExnType type, - ScopedJSFreePtr* errorReport, HandleString fileName, + UniquePtr errorReport, HandleString fileName, HandleObject stack, uint32_t lineNumber, uint32_t columnNumber, HandleString message) { @@ -72,7 +74,7 @@ js::ErrorObject::init(JSContext* cx, Handle 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 obj, JSExnType type, /* static */ ErrorObject* js::ErrorObject::create(JSContext* cx, JSExnType errorType, HandleObject stack, HandleString fileName, uint32_t lineNumber, uint32_t columnNumber, - ScopedJSFreePtr* report, HandleString message, + UniquePtr 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(); } - 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 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 diff --git a/js/src/vm/ErrorObject.h b/js/src/vm/ErrorObject.h index 2e2427a388d5..0727235dd16a 100644 --- a/js/src/vm/ErrorObject.h +++ b/js/src/vm/ErrorObject.h @@ -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 obj, JSExnType type, - ScopedJSFreePtr* errorReport, HandleString fileName, HandleObject stack, + UniquePtr 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* report, + uint32_t lineNumber, uint32_t columnNumber, UniquePtr report, HandleString message, HandleObject proto = nullptr); /* diff --git a/js/src/vm/Interpreter.cpp b/js/src/vm/Interpreter.cpp index 054d28c54313..85b68ab1f05f 100644 --- a/js/src/vm/Interpreter.cpp +++ b/js/src/vm/Interpreter.cpp @@ -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; } diff --git a/js/src/vm/JSContext.cpp b/js/src/vm/JSContext.cpp index 86d01b7778cc..f0557f4b59b6 100644 --- a/js/src/vm/JSContext.cpp +++ b/js/src/vm/JSContext.cpp @@ -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, - bytes.get()); + 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, - bytes.get(), js_undefined_str); + 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, - bytes.get(), js_null_str); + 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, - bytes.get(), arg1, arg2); - return ok; + return JS_ReportErrorFlagsAndNumberLatin1(cx, flags, GetErrorMessage, nullptr, errorNumber, + bytes.get(), arg1, arg2); } JSObject* diff --git a/js/src/vm/JSContext.h b/js/src/vm/JSContext.h index 8980f5153e46..c760857d7961 100644 --- a/js/src/vm/JSContext.h +++ b/js/src/vm/JSContext.h @@ -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); diff --git a/js/src/vm/JSFunction.cpp b/js/src/vm/JSFunction.cpp index d3c966460bb9..cbe6aff718a3 100644 --- a/js/src/vm/JSFunction.cpp +++ b/js/src/vm/JSFunction.cpp @@ -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; } diff --git a/js/src/vm/JSObject.cpp b/js/src/vm/JSObject.cpp index 543136f1cb1f..437092d1b979 100644 --- a/js/src/vm/JSObject.cpp +++ b/js/src/vm/JSObject.cpp @@ -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,10 +3059,10 @@ ReportCantConvert(JSContext* cx, unsigned errorNumber, HandleObject obj, JSType } RootedValue val(cx, ObjectValue(*obj)); - ReportValueError2(cx, errorNumber, JSDVG_SEARCH_STACK, val, str, - hint == JSTYPE_UNDEFINED - ? "primitive type" - : hint == JSTYPE_STRING ? "string" : "number"); + ReportValueError(cx, errorNumber, JSDVG_SEARCH_STACK, val, str, + hint == JSTYPE_UNDEFINED + ? "primitive type" + : hint == JSTYPE_STRING ? "string" : "number"); return false; } @@ -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"); diff --git a/js/src/vm/JSObject.h b/js/src/vm/JSObject.h index 35656b424d40..d3ab5e775d66 100644 --- a/js/src/vm/JSObject.h +++ b/js/src/vm/JSObject.h @@ -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); diff --git a/js/src/vm/NativeObject-inl.h b/js/src/vm/NativeObject-inl.h index 6be0b1c54937..70b9faddb0f4 100644 --- a/js/src/vm/NativeObject-inl.h +++ b/js/src/vm/NativeObject-inl.h @@ -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 diff --git a/js/src/vm/NativeObject.cpp b/js/src/vm/NativeObject.cpp index 60458e4940bb..1b41456918f4 100644 --- a/js/src/vm/NativeObject.cpp +++ b/js/src/vm/NativeObject.cpp @@ -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() && - !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); } diff --git a/js/src/vm/RegExpObject.cpp b/js/src/vm/RegExpObject.cpp index eba1c05e47b6..68b30b19453a 100644 --- a/js/src/vm/RegExpObject.cpp +++ b/js/src/vm/RegExpObject.cpp @@ -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; } diff --git a/js/src/vm/SelfHosting.cpp b/js/src/vm/SelfHosting.cpp index 5fb2ae435327..02ad7bea7ad4 100644 --- a/js/src/vm/SelfHosting.cpp +++ b/js/src/vm/SelfHosting.cpp @@ -2906,8 +2906,8 @@ VerifyGlobalNames(JSContext* cx, Handle 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 diff --git a/layout/painting/DisplayItemClipChain.h b/layout/painting/DisplayItemClipChain.h index 532c52e1729f..413b8d8c1d60 100644 --- a/layout/painting/DisplayItemClipChain.h +++ b/layout/painting/DisplayItemClipChain.h @@ -72,8 +72,9 @@ struct DisplayItemClipChain { {} DisplayItemClipChain() + : mASR(nullptr) #ifdef DEBUG - : mOnStack(true) + , mOnStack(true) #endif {} diff --git a/layout/painting/DottedCornerFinder.cpp b/layout/painting/DottedCornerFinder.cpp index e3d020e4556b..9c41ac2bb532 100644 --- a/layout/painting/DottedCornerFinder.cpp +++ b/layout/painting/DottedCornerFinder.cpp @@ -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), diff --git a/layout/painting/FrameLayerBuilder.cpp b/layout/painting/FrameLayerBuilder.cpp index 2e8f1dd70601..1fbb84429842 100644 --- a/layout/painting/FrameLayerBuilder.cpp +++ b/layout/painting/FrameLayerBuilder.cpp @@ -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) diff --git a/layout/painting/nsCSSRendering.cpp b/layout/painting/nsCSSRendering.cpp index 6022a97c3ff7..1fe5eff1d053 100644 --- a/layout/painting/nsCSSRendering.cpp +++ b/layout/painting/nsCSSRendering.cpp @@ -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) { } diff --git a/layout/painting/nsCSSRenderingGradients.h b/layout/painting/nsCSSRenderingGradients.h index 9c477ae7ad7e..7fecbb5dc2f6 100644 --- a/layout/painting/nsCSSRenderingGradients.h +++ b/layout/painting/nsCSSRenderingGradients.h @@ -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 diff --git a/layout/painting/nsDisplayList.h b/layout/painting/nsDisplayList.h index 002a87af5d20..c839ceb98fea 100644 --- a/layout/painting/nsDisplayList.h +++ b/layout/painting/nsDisplayList.h @@ -323,6 +323,9 @@ struct ActiveScrolledRoot { private: ActiveScrolledRoot() + : mScrollableFrame(nullptr) + , mDepth(0) + , mRetained(false) { } diff --git a/layout/painting/nsImageRenderer.h b/layout/painting/nsImageRenderer.h index e73ff231977e..57bb0a8f2d0f 100644 --- a/layout/painting/nsImageRenderer.h +++ b/layout/painting/nsImageRenderer.h @@ -33,8 +33,11 @@ struct CSSSizeOrRatio { CSSSizeOrRatio() : mRatio(0, 0) + , mWidth(0) + , mHeight(0) , mHasWidth(false) - , mHasHeight(false) {} + , mHasHeight(false) + {} bool CanComputeConcreteSize() const { diff --git a/layout/svg/SVGContextPaint.h b/layout/svg/SVGContextPaint.h index 9beba95adb68..277d67df5537 100644 --- a/layout/svg/SVGContextPaint.h +++ b/layout/svg/SVGContextPaint.h @@ -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, diff --git a/layout/svg/SVGTextFrame.cpp b/layout/svg/SVGTextFrame.cpp index 8aaafcfae26c..f75fbc24867b 100644 --- a/layout/svg/SVGTextFrame.cpp +++ b/layout/svg/SVGTextFrame.cpp @@ -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) { }