import changes from `dev' branch of rmottola/Arctic-Fox:

- Bug 1121855 - Fix camera crash. r=aosmond (6ad4335ae)
- Bug 1139721 - Fix camera memory leaks for onfacedetected events, failed initializations and capabilities. r=mikeh (663bbde8c)
- Bug 1165729 - Check SetCapacity return value in nsSMILAnimationFunction::GetValues. r=dholbert (100ecf2f7)
- Bug 968520 - Add mozilla::fallible to Fallible{Auto,}TArray::SetCapacity calls. r=froydnj (2c120f71a)
- Scrollbar thumbs can overlap scrollbar arrows during APZ scrolling. (bug 1152469, r=botond,mstange) (a2e9ac1bf)
- Bug 1148889 - Treat subclasses of scrollframes as animated geometry roots. r=mstange (434719455)
- Bug 1155025. Make the root layer on fennec have null scroll id with containerless scrolling. r=mstange (eb1bb3acd)
- remove test (63f014d13)
- Bug 1151306 - Add a reftest. r=roc (56c4137ae)
- Bug 1151145 - Add a reftest. r=jrmuizel (9684c3f0a)
- Bug 1150021. Make sure that boxes inside vertical RTL boxes are placed on the right. r=roc (c4b3e7e06)
- Bug 1156129 - Take border radius into account when calculating the bounds of border display items. r=roc (35b70f9a8)
- Bug 1152902 part 2. Add a fast path for the case when a Promise is resolved with another Promise. r=nsm (33a210977)
This commit is contained in:
2020-11-03 11:00:45 +08:00
parent e8cf9871ba
commit 1d6a3196e2
59 changed files with 503 additions and 79 deletions
+1 -1
View File
@@ -747,7 +747,7 @@ nsDOMMutationObserver::HandleMutation()
mozilla::dom::Sequence<mozilla::dom::OwningNonNull<nsDOMMutationRecord> >
mutations;
if (mutations.SetCapacity(mPendingMutationCount)) {
if (mutations.SetCapacity(mPendingMutationCount, mozilla::fallible)) {
// We can't use TakeRecords easily here, because it deals with a
// different type of array, and we want to optimize out any extra copying.
nsRefPtr<nsDOMMutationRecord> current;
+1 -1
View File
@@ -363,7 +363,7 @@ nsJSScriptTimeoutHandler::Init(nsGlobalWindow *aWindow, bool *aIsInterval,
uint32_t argCount = std::max(argc, 2u) - 2;
FallibleTArray<JS::Heap<JS::Value> > args;
if (!args.SetCapacity(argCount)) {
if (!args.SetCapacity(argCount, fallible)) {
// No need to drop here, since we already have a non-null mFunction
return NS_ERROR_OUT_OF_MEMORY;
}
+1 -1
View File
@@ -5537,7 +5537,7 @@ class CGArgumentConverter(CGThing):
rooterDecl +
dedent("""
if (${argc} > ${index}) {
if (!${declName}.SetCapacity(${argc} - ${index})) {
if (!${declName}.SetCapacity(${argc} - ${index}, mozilla::fallible)) {
JS_ReportOutOfMemory(cx);
return false;
}
+1
View File
@@ -323,6 +323,7 @@ CameraCapabilities::CameraCapabilities(nsPIDOMWindow* aWindow,
, mCameraControl(aCameraControl)
{
DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
MOZ_COUNT_CTOR(CameraCapabilities);
if (mCameraControl) {
mListener = new CameraClosedListenerProxy<CameraCapabilities>(this);
mCameraControl->AddListener(mListener);
+9 -4
View File
@@ -306,6 +306,8 @@ nsDOMCameraControl::nsDOMCameraControl(uint32_t aCameraId,
nsDOMCameraControl::~nsDOMCameraControl()
{
DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
/*invoke DOMMediaStream destroy*/
Destroy();
}
JSObject*
@@ -1370,11 +1372,10 @@ nsDOMCameraControl::OnFacesDetected(const nsTArray<ICameraControl::Face>& aFaces
Sequence<OwningNonNull<DOMCameraDetectedFace> > faces;
uint32_t len = aFaces.Length();
if (faces.SetCapacity(len)) {
nsRefPtr<DOMCameraDetectedFace> f;
if (faces.SetCapacity(len, fallible)) {
for (uint32_t i = 0; i < len; ++i) {
f = new DOMCameraDetectedFace(static_cast<DOMMediaStream*>(this), aFaces[i]);
*faces.AppendElement() = f.forget().take();
*faces.AppendElement() =
new DOMCameraDetectedFace(static_cast<DOMMediaStream*>(this), aFaces[i]);
}
}
@@ -1425,6 +1426,10 @@ nsDOMCameraControl::OnUserError(CameraControlListener::UserContext aContext, nsr
switch (aContext) {
case CameraControlListener::kInStartCamera:
promise = mGetCameraPromise.forget();
// If we failed to open the camera, we never actually provided a reference
// for the application to release explicitly. Thus we must clear our handle
// here to ensure everything is freed.
mCameraControl = nullptr;
break;
case CameraControlListener::kInStopCamera:
+10 -8
View File
@@ -2715,7 +2715,8 @@ InsertIndexDataValuesFunction::OnFunctionCall(mozIStorageValueArray* aValues,
}
// Update the array with the new addition.
if (NS_WARN_IF(!indexValues.SetCapacity(indexValues.Length() + 1))) {
if (NS_WARN_IF(!indexValues.SetCapacity(indexValues.Length() + 1,
fallible))) {
IDB_REPORT_INTERNAL_ERR();
return NS_ERROR_OUT_OF_MEMORY;
}
@@ -8029,14 +8030,15 @@ ConvertBlobsToActors(PBackgroundParent* aBackgroundActor,
const uint32_t count = aFiles.Length();
if (NS_WARN_IF(!aActors.SetCapacity(count))) {
if (NS_WARN_IF(!aActors.SetCapacity(count, fallible))) {
return NS_ERROR_OUT_OF_MEMORY;
}
const bool collectFileInfos =
!BackgroundParent::IsOtherProcessActor(aBackgroundActor);
if (collectFileInfos && NS_WARN_IF(!aFileInfos.SetCapacity(count))) {
if (collectFileInfos &&
NS_WARN_IF(!aFileInfos.SetCapacity(count, fallible))) {
return NS_ERROR_OUT_OF_MEMORY;
}
@@ -11294,7 +11296,7 @@ Database::Invalidate()
}
FallibleTArray<nsRefPtr<TransactionBase>> transactions;
if (NS_WARN_IF(!transactions.SetCapacity(count))) {
if (NS_WARN_IF(!transactions.SetCapacity(count, fallible))) {
return false;
}
@@ -11646,7 +11648,7 @@ Database::AllocPBackgroundIDBTransactionParent(
}
FallibleTArray<nsRefPtr<FullObjectStoreMetadata>> fallibleObjectStores;
if (NS_WARN_IF(!fallibleObjectStores.SetCapacity(nameCount))) {
if (NS_WARN_IF(!fallibleObjectStores.SetCapacity(nameCount, fallible))) {
return nullptr;
}
@@ -15627,7 +15629,7 @@ DatabaseOperationBase::IndexDataValuesFromUpdateInfos(
return NS_OK;
}
if (NS_WARN_IF(!aIndexValues.SetCapacity(count))) {
if (NS_WARN_IF(!aIndexValues.SetCapacity(count, fallible))) {
IDB_REPORT_INTERNAL_ERR();
return NS_ERROR_OUT_OF_MEMORY;
}
@@ -20046,7 +20048,7 @@ UpdateIndexDataValuesFunction::OnFunctionCall(mozIStorageValueArray* aValues,
const uint32_t updateInfoCount = updateInfos.Length();
if (NS_WARN_IF(!indexValues.SetCapacity(indexValues.Length() +
updateInfoCount))) {
updateInfoCount, fallible))) {
IDB_REPORT_INTERNAL_ERR();
return NS_ERROR_OUT_OF_MEMORY;
}
@@ -20801,7 +20803,7 @@ ObjectStoreAddOrPutRequestOp::Init(TransactionBase* aTransaction)
if (!files.IsEmpty()) {
const uint32_t count = files.Length();
if (NS_WARN_IF(!mStoredFileInfos.SetCapacity(count))) {
if (NS_WARN_IF(!mStoredFileInfos.SetCapacity(count, fallible))) {
return false;
}
+1 -1
View File
@@ -1221,7 +1221,7 @@ IDBObjectStore::AddOrPut(JSContext* aCx,
const uint32_t count = blobOrFileInfos.Length();
FallibleTArray<DatabaseFileOrMutableFileId> fileActorOrMutableFileIds;
if (NS_WARN_IF(!fileActorOrMutableFileIds.SetCapacity(count))) {
if (NS_WARN_IF(!fileActorOrMutableFileIds.SetCapacity(count, fallible))) {
aRv = NS_ERROR_OUT_OF_MEMORY;
return nullptr;
}
+4 -4
View File
@@ -342,10 +342,10 @@ MobileMessageCursorChild::DoNotifyResult(const nsTArray<MobileMessageData>& aDat
MOZ_ASSERT(length);
AutoFallibleTArray<nsISupports*, 1> autoArray;
NS_ENSURE_TRUE_VOID(autoArray.SetCapacity(length));
NS_ENSURE_TRUE_VOID(autoArray.SetCapacity(length, fallible));
AutoFallibleTArray<nsCOMPtr<nsISupports>, 1> messages;
NS_ENSURE_TRUE_VOID(messages.SetCapacity(length));
NS_ENSURE_TRUE_VOID(messages.SetCapacity(length, fallible));
for (uint32_t i = 0; i < length; i++) {
nsCOMPtr<nsISupports> message = CreateMessageFromMessageData(aDataArray[i]);
@@ -363,10 +363,10 @@ MobileMessageCursorChild::DoNotifyResult(const nsTArray<ThreadData>& aDataArray)
MOZ_ASSERT(length);
AutoFallibleTArray<nsISupports*, 1> autoArray;
NS_ENSURE_TRUE_VOID(autoArray.SetCapacity(length));
NS_ENSURE_TRUE_VOID(autoArray.SetCapacity(length, fallible));
AutoFallibleTArray<nsCOMPtr<nsISupports>, 1> threads;
NS_ENSURE_TRUE_VOID(threads.SetCapacity(length));
NS_ENSURE_TRUE_VOID(threads.SetCapacity(length, fallible));
for (uint32_t i = 0; i < length; i++) {
nsCOMPtr<nsISupports> thread = new MobileMessageThread(aDataArray[i]);
+76 -1
View File
@@ -157,7 +157,7 @@ GetPromise(JSContext* aCx, JS::Handle<JSObject*> aFunc)
}
} // namespace
// Main thread runnable to resolve thenables.
// Runnable to resolve thenables.
// Equivalent to the specification's ResolvePromiseViaThenableTask.
class ThenableResolverTask final : public nsRunnable
{
@@ -188,6 +188,8 @@ protected:
ThreadsafeAutoJSContext cx;
JS::Rooted<JSObject*> wrapper(cx, mPromise->GetWrapper());
MOZ_ASSERT(wrapper); // It was preserved!
// If we ever change which compartment we're working in here, make sure to
// fix the fast-path for resolved-with-a-Promise in ResolveInternal.
JSAutoCompartment ac(cx, wrapper);
JS::Rooted<JSObject*> resolveFunc(cx,
@@ -258,6 +260,48 @@ private:
NS_DECL_OWNINGTHREAD;
};
// Fast version of ThenableResolverTask for use in the cases when we know we're
// calling the canonical Promise.prototype.then on an actual DOM Promise. In
// that case we can just bypass the jumping into and out of JS and call
// AppendCallbacks on that promise directly.
class FastThenableResolverTask final : public nsRunnable
{
public:
FastThenableResolverTask(PromiseCallback* aResolveCallback,
PromiseCallback* aRejectCallback,
Promise* aNextPromise)
: mResolveCallback(aResolveCallback)
, mRejectCallback(aRejectCallback)
, mNextPromise(aNextPromise)
{
MOZ_ASSERT(aResolveCallback);
MOZ_ASSERT(aRejectCallback);
MOZ_ASSERT(aNextPromise);
MOZ_COUNT_CTOR(FastThenableResolverTask);
}
virtual
~FastThenableResolverTask()
{
NS_ASSERT_OWNINGTHREAD(FastThenableResolverTask);
MOZ_COUNT_DTOR(FastThenableResolverTask);
}
protected:
NS_IMETHOD
Run() override
{
NS_ASSERT_OWNINGTHREAD(FastThenableResolverTask);
mNextPromise->AppendCallbacks(mResolveCallback, mRejectCallback);
return NS_OK;
}
private:
nsRefPtr<PromiseCallback> mResolveCallback;
nsRefPtr<PromiseCallback> mRejectCallback;
nsRefPtr<Promise> mNextPromise;
};
// Promise
NS_IMPL_CYCLE_COLLECTION_CLASS(Promise)
@@ -1200,6 +1244,37 @@ Promise::ResolveInternal(JSContext* aCx,
if (then.isObject() && JS::IsCallable(&then.toObject())) {
// This is the then() function of the thenable aValueObj.
JS::Rooted<JSObject*> thenObj(aCx, &then.toObject());
// Add a fast path for the case when we're resolved with an actual
// Promise. This has two requirements:
//
// 1) valueObj is a Promise.
// 2) thenObj is a JSFunction backed by our actual Promise::Then
// implementation.
//
// If those requirements are satisfied, then we know exactly what
// thenObj.call(valueObj) will do, so we can optimize a bit and avoid ever
// entering JS for this stuff.
Promise* nextPromise;
if (PromiseBinding::IsThenMethod(thenObj) &&
NS_SUCCEEDED(UNWRAP_OBJECT(Promise, valueObj, nextPromise))) {
// If we were taking the codepath that involves ThenableResolverTask and
// PromiseInit below, then eventually, in ThenableResolverTask::Run, we
// would create some JSFunctions in the compartment of
// this->GetWrapper() and pass them to the PromiseInit. So by the time
// we'd see the resolution value it would be wrapped into the
// compartment of this->GetWrapper(). The global of that compartment is
// this->GetGlobalJSObject(), so use that as the global for
// ResolvePromiseCallback/RejectPromiseCallback.
JS::Rooted<JSObject*> glob(aCx, GlobalJSObject());
nsRefPtr<PromiseCallback> resolveCb = new ResolvePromiseCallback(this, glob);
nsRefPtr<PromiseCallback> rejectCb = new RejectPromiseCallback(this, glob);
nsRefPtr<FastThenableResolverTask> task =
new FastThenableResolverTask(resolveCb, rejectCb, nextPromise);
DispatchToMicroTask(task);
return;
}
nsRefPtr<PromiseInit> thenCallback =
new PromiseInit(thenObj, mozilla::dom::GetIncumbentGlobal());
nsRefPtr<ThenableResolverTask> task =
+1
View File
@@ -84,6 +84,7 @@ class Promise : public nsISupports,
friend class RejectPromiseCallback;
friend class ResolvePromiseCallback;
friend class ThenableResolverTask;
friend class FastThenableResolverTask;
friend class WrapperPromiseCallback;
public:
+1
View File
@@ -6,3 +6,4 @@
[test_promise_utils.html]
[test_resolve.html]
[test_resolver_return_value.html]
[test_thenable_vs_promise_ordering.html]
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Test for promise resolution ordering with thenables and promises</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
var t = async_test("A promise resolved first (with a thenable) should trigger its callbacks before a promise resolved second (with a promise).");
t.step(function() {
var customThenCalled = false;
var p0 = Promise.resolve();
p0.then = function(resolved, rejected) {
customThenCalled = true;
Promise.prototype.then.call(this, resolved, rejected);
}
var p1 = new Promise(function(r) { r(p0); });
delete p0.then;
var p2 = new Promise(function(r) { r(p0); });
var resolutionOrder = "";
Promise.all([ p1.then(function() { resolutionOrder += "1"; }),
p2.then(function() { resolutionOrder += "2"; }) ])
.then(t.step_func_done(function() {
assert_true(customThenCalled, "Should have called custom then");
assert_equals(resolutionOrder, "12");
}));
});
</script>
+2 -2
View File
@@ -780,10 +780,10 @@ nsSMILAnimationFunction::GetValues(const nsISMILAttr& aSMILAttr,
mValueNeedsReparsingEverySample = true;
}
if (!parseOk)
if (!parseOk || !result.SetCapacity(2, mozilla::fallible)) {
return NS_ERROR_FAILURE;
}
result.SetCapacity(2);
if (!to.IsNull()) {
if (!from.IsNull()) {
result.AppendElement(from);
+1 -1
View File
@@ -255,7 +255,7 @@ DOMSVGLengthList::InsertItemBefore(DOMSVGLength& newItem,
}
// Ensure we have enough memory so we can avoid complex error handling below:
if (!mItems.SetCapacity(mItems.Length() + 1) ||
if (!mItems.SetCapacity(mItems.Length() + 1, fallible) ||
!InternalList().SetCapacity(InternalList().Length() + 1)) {
error.Throw(NS_ERROR_OUT_OF_MEMORY);
return nullptr;
+1 -1
View File
@@ -239,7 +239,7 @@ DOMSVGNumberList::InsertItemBefore(DOMSVGNumber& aItem,
nsRefPtr<DOMSVGNumber> domItem = aItem.HasOwner() ? aItem.Clone() : &aItem;
// Ensure we have enough memory so we can avoid complex error handling below:
if (!mItems.SetCapacity(mItems.Length() + 1) ||
if (!mItems.SetCapacity(mItems.Length() + 1, fallible) ||
!InternalList().SetCapacity(InternalList().Length() + 1)) {
error.Throw(NS_ERROR_OUT_OF_MEMORY);
return nullptr;
+3 -2
View File
@@ -369,8 +369,9 @@ DOMSVGPathSegList::InsertItemBefore(DOMSVGPathSeg& aNewItem,
uint32_t argCount = SVGPathSegUtils::ArgCountForType(domItem->Type());
// Ensure we have enough memory so we can avoid complex error handling below:
if (!mItems.SetCapacity(mItems.Length() + 1) ||
!InternalList().mData.SetCapacity(InternalList().mData.Length() + 1 + argCount)) {
if (!mItems.SetCapacity(mItems.Length() + 1, fallible) ||
!InternalList().mData.SetCapacity(InternalList().mData.Length() + 1 + argCount,
fallible)) {
aError.Throw(NS_ERROR_OUT_OF_MEMORY);
return nullptr;
}
+1 -1
View File
@@ -306,7 +306,7 @@ DOMSVGPointList::InsertItemBefore(nsISVGPoint& aNewItem, uint32_t aIndex,
}
// Ensure we have enough memory so we can avoid complex error handling below:
if (!mItems.SetCapacity(mItems.Length() + 1) ||
if (!mItems.SetCapacity(mItems.Length() + 1, fallible) ||
!InternalList().SetCapacity(InternalList().Length() + 1)) {
aError.Throw(NS_ERROR_OUT_OF_MEMORY);
return nullptr;
+1 -1
View File
@@ -247,7 +247,7 @@ DOMSVGTransformList::InsertItemBefore(SVGTransform& newItem,
}
// Ensure we have enough memory so we can avoid complex error handling below:
if (!mItems.SetCapacity(mItems.Length() + 1) ||
if (!mItems.SetCapacity(mItems.Length() + 1, fallible) ||
!InternalList().SetCapacity(InternalList().Length() + 1)) {
error.Throw(NS_ERROR_OUT_OF_MEMORY);
return nullptr;
+1 -1
View File
@@ -18,7 +18,7 @@ namespace mozilla {
nsresult
SVGLengthList::CopyFrom(const SVGLengthList& rhs)
{
if (!mLengths.SetCapacity(rhs.Length())) {
if (!mLengths.SetCapacity(rhs.Length(), fallible)) {
// Yes, we do want fallible alloc here
return NS_ERROR_OUT_OF_MEMORY;
}
+1 -1
View File
@@ -59,7 +59,7 @@ public:
bool operator==(const SVGLengthList& rhs) const;
bool SetCapacity(uint32_t size) {
return mLengths.SetCapacity(size);
return mLengths.SetCapacity(size, fallible);
}
void Compact() {
+1 -1
View File
@@ -197,7 +197,7 @@ SVGMotionSMILType::Assign(nsSMILValue& aDest, const nsSMILValue& aSrc) const
MotionSegmentArray& dstArr = ExtractMotionSegmentArray(aDest);
// Ensure we have sufficient memory.
if (!dstArr.SetCapacity(srcArr.Length())) {
if (!dstArr.SetCapacity(srcArr.Length(), fallible)) {
return NS_ERROR_OUT_OF_MEMORY;
}
+1 -1
View File
@@ -17,7 +17,7 @@ namespace mozilla {
nsresult
SVGNumberList::CopyFrom(const SVGNumberList& rhs)
{
if (!mNumbers.SetCapacity(rhs.Length())) {
if (!mNumbers.SetCapacity(rhs.Length(), fallible)) {
// Yes, we do want fallible alloc here
return NS_ERROR_OUT_OF_MEMORY;
}
+1 -1
View File
@@ -60,7 +60,7 @@ public:
}
bool SetCapacity(uint32_t size) {
return mNumbers.SetCapacity(size);
return mNumbers.SetCapacity(size, fallible);
}
void Compact() {
+1 -1
View File
@@ -34,7 +34,7 @@ static bool IsMoveto(uint16_t aSegType)
nsresult
SVGPathData::CopyFrom(const SVGPathData& rhs)
{
if (!mData.SetCapacity(rhs.mData.Length())) {
if (!mData.SetCapacity(rhs.mData.Length(), fallible)) {
// Yes, we do want fallible alloc here
return NS_ERROR_OUT_OF_MEMORY;
}
+1 -1
View File
@@ -135,7 +135,7 @@ public:
}
bool SetCapacity(uint32_t aSize) {
return mData.SetCapacity(aSize);
return mData.SetCapacity(aSize, fallible);
}
void Compact() {
+1 -1
View File
@@ -68,7 +68,7 @@ public:
}
bool SetCapacity(uint32_t aSize) {
return mItems.SetCapacity(aSize);
return mItems.SetCapacity(aSize, fallible);
}
void Compact() {
+1 -1
View File
@@ -16,7 +16,7 @@ namespace mozilla {
nsresult
SVGStringList::CopyFrom(const SVGStringList& rhs)
{
if (!mStrings.SetCapacity(rhs.Length())) {
if (!mStrings.SetCapacity(rhs.Length(), fallible)) {
// Yes, we do want fallible alloc here
return NS_ERROR_OUT_OF_MEMORY;
}
+1 -1
View File
@@ -56,7 +56,7 @@ public:
}
bool SetCapacity(uint32_t size) {
return mStrings.SetCapacity(size);
return mStrings.SetCapacity(size, fallible);
}
void Compact() {
+1 -1
View File
@@ -43,7 +43,7 @@ SVGTransformList::CopyFrom(const SVGTransformList& rhs)
nsresult
SVGTransformList::CopyFrom(const nsTArray<nsSVGTransform>& aTransformArray)
{
if (!mItems.SetCapacity(aTransformArray.Length())) {
if (!mItems.SetCapacity(aTransformArray.Length(), fallible)) {
// Yes, we do want fallible alloc here
return NS_ERROR_OUT_OF_MEMORY;
}
+1 -1
View File
@@ -60,7 +60,7 @@ public:
}
bool SetCapacity(uint32_t size) {
return mItems.SetCapacity(size);
return mItems.SetCapacity(size, fallible);
}
void Compact() {
+3 -3
View File
@@ -50,7 +50,7 @@ SVGTransformListSMILType::Assign(nsSMILValue& aDest,
TransformArray* dstTransforms = static_cast<TransformArray*>(aDest.mU.mPtr);
// Before we assign, ensure we have sufficient memory
bool result = dstTransforms->SetCapacity(srcTransforms->Length());
bool result = dstTransforms->SetCapacity(srcTransforms->Length(), fallible);
NS_ENSURE_TRUE(result,NS_ERROR_OUT_OF_MEMORY);
*dstTransforms = *srcTransforms;
@@ -336,7 +336,7 @@ SVGTransformListSMILType::AppendTransforms(const SVGTransformList& aList,
TransformArray& transforms = *static_cast<TransformArray*>(aValue.mU.mPtr);
if (!transforms.SetCapacity(transforms.Length() + aList.Length()))
if (!transforms.SetCapacity(transforms.Length() + aList.Length(), fallible))
return false;
for (uint32_t i = 0; i < aList.Length(); ++i) {
@@ -358,7 +358,7 @@ SVGTransformListSMILType::GetTransforms(const nsSMILValue& aValue,
*static_cast<const TransformArray*>(aValue.mU.mPtr);
aTransforms.Clear();
if (!aTransforms.SetCapacity(smilTransforms.Length()))
if (!aTransforms.SetCapacity(smilTransforms.Length(), fallible))
return false;
for (uint32_t i = 0; i < smilTransforms.Length(); ++i) {
+1 -1
View File
@@ -34,7 +34,7 @@ interface _Promise {
// The [TreatNonCallableAsNull] annotation is required since then() should do
// nothing instead of throwing errors when non-callable arguments are passed.
[NewObject]
[NewObject, MethodIdentityTestable]
Promise<any> then([TreatNonCallableAsNull] optional AnyCallback? fulfillCallback = null,
[TreatNonCallableAsNull] optional AnyCallback? rejectCallback = null);
+1
View File
@@ -208,6 +208,7 @@ Layer::Layer(LayerManager* aManager, void* aImplData) :
mStickyPositionData(nullptr),
mScrollbarTargetId(FrameMetrics::NULL_SCROLL_ID),
mScrollbarDirection(ScrollDirection::NONE),
mScrollbarThumbRatio(0.0f),
mIsScrollbarContainer(false),
mDebugColorIndex(0),
mAnimationGeneration(0)
+8 -2
View File
@@ -1195,13 +1195,16 @@ public:
* If a layer is a scrollbar layer, |aScrollId| holds the scroll identifier
* of the scrollable content that the scrollbar is for.
*/
void SetScrollbarData(FrameMetrics::ViewID aScrollId, ScrollDirection aDir)
void SetScrollbarData(FrameMetrics::ViewID aScrollId, ScrollDirection aDir, float aThumbRatio)
{
if (mScrollbarTargetId != aScrollId ||
mScrollbarDirection != aDir) {
mScrollbarDirection != aDir ||
mScrollbarThumbRatio != aThumbRatio)
{
MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) ScrollbarData", this));
mScrollbarTargetId = aScrollId;
mScrollbarDirection = aDir;
mScrollbarThumbRatio = aThumbRatio;
Mutated();
}
}
@@ -1249,6 +1252,7 @@ public:
const LayerRect& GetStickyScrollRangeInner() { return mStickyPositionData->mInner; }
FrameMetrics::ViewID GetScrollbarTargetContainerId() { return mScrollbarTargetId; }
ScrollDirection GetScrollbarDirection() { return mScrollbarDirection; }
float GetScrollbarThumbRatio() { return mScrollbarThumbRatio; }
bool IsScrollbarContainer() { return mIsScrollbarContainer; }
Layer* GetMaskLayer() const { return mMaskLayer; }
@@ -1707,6 +1711,8 @@ protected:
nsAutoPtr<StickyPositionData> mStickyPositionData;
FrameMetrics::ViewID mScrollbarTargetId;
ScrollDirection mScrollbarDirection;
float mScrollbarThumbRatio; // Ratio of the thumb position to the scroll
// position, in app units.
bool mIsScrollbarContainer;
DebugOnly<uint32_t> mDebugColorIndex;
// If this layer is used for OMTA, then this counter is used to ensure we
@@ -727,13 +727,8 @@ ApplyAsyncTransformToScrollbarForContent(Layer* aScrollbar,
const CSSCoord compositedHeight = (metrics.mCompositionBounds / effectiveZoom).height;
const CSSCoord scrollableHeight = metrics.GetScrollableRect().height;
// The scroll thumb needs to be translated in opposite direction of the
// async scroll. This is because scrolling down, which translates the layer
// content up, should result in moving the scroll thumb down.
// The amount of the translation should be such that the ratio of the
// translation to the size of the scroll port is the same as the ratio of
// the scroll amount of the size of the scrollable rect.
const float ratio = compositedHeight / scrollableHeight;
// The scrollbar thumb ratio is in AppUnits.
const float ratio = aScrollbar->GetScrollbarThumbRatio();
ParentLayerCoord yTranslation = -asyncScrollY * ratio;
// The scroll thumb additionally needs to be translated to compensate for
@@ -779,7 +774,8 @@ ApplyAsyncTransformToScrollbarForContent(Layer* aScrollbar,
const CSSCoord compositedWidth = (metrics.mCompositionBounds / effectiveZoom).width;
const CSSCoord scrollableWidth = metrics.GetScrollableRect().width;
const float ratio = compositedWidth / scrollableWidth;
// The scrollbar thumb ratio is in AppUnits.
const float ratio = aScrollbar->GetScrollbarThumbRatio();
ParentLayerCoord xTranslation = -asyncScrollX * ratio;
const CSSCoord thumbOrigin = (metrics.GetScrollOffset().x / scrollableWidth) * compositedWidth;
+2 -1
View File
@@ -339,7 +339,8 @@ LayerTransactionParent::RecvUpdate(InfallibleTArray<Edit>&& cset,
common.stickyScrollRangeInner());
}
layer->SetScrollbarData(common.scrollbarTargetContainerId(),
static_cast<Layer::ScrollDirection>(common.scrollbarDirection()));
static_cast<Layer::ScrollDirection>(common.scrollbarDirection()),
common.scrollbarThumbRatio());
layer->SetMixBlendMode((gfx::CompositionOp)common.mixBlendMode());
layer->SetForceIsolatedGroup(common.forceIsolatedGroup());
if (PLayerParent* maskLayer = common.maskLayerParent()) {
+1
View File
@@ -215,6 +215,7 @@ struct CommonLayerAttributes {
LayerRect stickyScrollRangeInner;
uint64_t scrollbarTargetContainerId;
uint32_t scrollbarDirection;
float scrollbarThumbRatio;
int8_t mixBlendMode;
bool forceIsolatedGroup;
nullable PLayer maskLayer;
+1
View File
@@ -619,6 +619,7 @@ ShadowLayerForwarder::EndTransaction(InfallibleTArray<EditReply>* aReplies,
}
common.scrollbarTargetContainerId() = mutant->GetScrollbarTargetContainerId();
common.scrollbarDirection() = mutant->GetScrollbarDirection();
common.scrollbarThumbRatio() = mutant->GetScrollbarThumbRatio();
common.mixBlendMode() = (int8_t)mutant->GetMixBlendMode();
common.forceIsolatedGroup() = mutant->GetForceIsolatedGroup();
if (Layer* maskLayer = mutant->GetMaskLayer()) {
+2 -2
View File
@@ -45,8 +45,8 @@ nsConverterInputStream::Init(nsIInputStream* aStream,
mConverter = EncodingUtils::DecoderForEncoding(encoding);
// set up our buffers
if (!mByteData.SetCapacity(aBufferSize) ||
!mUnicharData.SetCapacity(aBufferSize)) {
if (!mByteData.SetCapacity(aBufferSize, mozilla::fallible) ||
!mUnicharData.SetCapacity(aBufferSize, mozilla::fallible)) {
return NS_ERROR_OUT_OF_MEMORY;
}
+1 -1
View File
@@ -520,7 +520,7 @@ struct ParamTraits<FallibleTArray<E> >
memcpy(elements, outdata, pickledLength);
} else {
if (!aResult->SetCapacity(length)) {
if (!aResult->SetCapacity(length, mozilla::fallible)) {
return false;
}
+34 -6
View File
@@ -1229,7 +1229,7 @@ nsDisplayListBuilder::IsAnimatedGeometryRoot(nsIFrame* aFrame, nsIFrame** aParen
return true;
}
if (parentType == nsGkAtoms::scrollFrame) {
if (parentType == nsGkAtoms::scrollFrame || parentType == nsGkAtoms::listControlFrame) {
nsIScrollableFrame* sf = do_QueryFrame(parent);
if (sf->IsScrollingActive(this) && sf->GetScrolledFrame() == aFrame) {
return true;
@@ -1702,7 +1702,11 @@ already_AddRefed<LayerManager> nsDisplayList::PaintRoot(nsDisplayListBuilder* aB
} else if (!gfxPrefs::LayoutUseContainersForRootFrames()) {
// If there is no root scroll frame, and we're using containerless
// scrolling, pick the document element instead.
// On Android we want the root xul document to get a null scroll id
// so that the root content document gets the first non-null scroll id.
#ifndef MOZ_WIDGET_ANDROID
content = document->GetDocumentElement();
#endif
}
root->SetFrameMetrics(
@@ -3402,6 +3406,26 @@ nsDisplayBorder::CalculateBounds(const nsStyleBorder& aStyleBorder)
result.UnionRect(result, nsRect(borderBounds.X(), borderBounds.Y(), border.left, borderBounds.Height()));
}
nscoord radii[8];
if (mFrame->GetBorderRadii(radii)) {
if (border.left > 0 || border.top > 0) {
nsSize cornerSize(radii[NS_CORNER_TOP_LEFT_X], radii[NS_CORNER_TOP_LEFT_Y]);
result.UnionRect(result, nsRect(borderBounds.TopLeft(), cornerSize));
}
if (border.top > 0 || border.right > 0) {
nsSize cornerSize(radii[NS_CORNER_TOP_RIGHT_X], radii[NS_CORNER_TOP_RIGHT_Y]);
result.UnionRect(result, nsRect(borderBounds.TopRight() - nsPoint(cornerSize.width, 0), cornerSize));
}
if (border.right > 0 || border.bottom > 0) {
nsSize cornerSize(radii[NS_CORNER_BOTTOM_RIGHT_X], radii[NS_CORNER_BOTTOM_RIGHT_Y]);
result.UnionRect(result, nsRect(borderBounds.BottomRight() - nsPoint(cornerSize.width, cornerSize.height), cornerSize));
}
if (border.bottom > 0 || border.left > 0) {
nsSize cornerSize(radii[NS_CORNER_BOTTOM_LEFT_X], radii[NS_CORNER_BOTTOM_LEFT_Y]);
result.UnionRect(result, nsRect(borderBounds.BottomLeft() - nsPoint(0, cornerSize.height), cornerSize));
}
}
return result;
}
}
@@ -4162,10 +4186,13 @@ bool nsDisplayBlendContainer::TryMerge(nsDisplayListBuilder* aBuilder, nsDisplay
nsDisplayOwnLayer::nsDisplayOwnLayer(nsDisplayListBuilder* aBuilder,
nsIFrame* aFrame, nsDisplayList* aList,
uint32_t aFlags, ViewID aScrollTarget)
uint32_t aFlags, ViewID aScrollTarget,
float aScrollbarThumbRatio)
: nsDisplayWrapList(aBuilder, aFrame, aList)
, mFlags(aFlags)
, mScrollTarget(aScrollTarget) {
, mScrollTarget(aScrollTarget)
, mScrollbarThumbRatio(aScrollbarThumbRatio)
{
MOZ_COUNT_CTOR(nsDisplayOwnLayer);
}
@@ -4179,16 +4206,17 @@ nsDisplayOwnLayer::~nsDisplayOwnLayer() {
already_AddRefed<Layer>
nsDisplayOwnLayer::BuildLayer(nsDisplayListBuilder* aBuilder,
LayerManager* aManager,
const ContainerLayerParameters& aContainerParameters) {
const ContainerLayerParameters& aContainerParameters)
{
nsRefPtr<ContainerLayer> layer = aManager->GetLayerBuilder()->
BuildContainerLayerFor(aBuilder, aManager, mFrame, this, &mList,
aContainerParameters, nullptr,
FrameLayerBuilder::CONTAINER_ALLOW_PULL_BACKGROUND_COLOR);
if (mFlags & VERTICAL_SCROLLBAR) {
layer->SetScrollbarData(mScrollTarget, Layer::ScrollDirection::VERTICAL);
layer->SetScrollbarData(mScrollTarget, Layer::ScrollDirection::VERTICAL, mScrollbarThumbRatio);
}
if (mFlags & HORIZONTAL_SCROLLBAR) {
layer->SetScrollbarData(mScrollTarget, Layer::ScrollDirection::HORIZONTAL);
layer->SetScrollbarData(mScrollTarget, Layer::ScrollDirection::HORIZONTAL, mScrollbarThumbRatio);
}
if (mFlags & SCROLLBAR_CONTAINER) {
layer->SetIsScrollbarContainer();
+3 -1
View File
@@ -3059,7 +3059,8 @@ public:
*/
nsDisplayOwnLayer(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame,
nsDisplayList* aList, uint32_t aFlags = 0,
ViewID aScrollTarget = mozilla::layers::FrameMetrics::NULL_SCROLL_ID);
ViewID aScrollTarget = mozilla::layers::FrameMetrics::NULL_SCROLL_ID,
float aScrollbarThumbRatio = 0.0f);
#ifdef NS_BUILD_REFCNT_LOGGING
virtual ~nsDisplayOwnLayer();
#endif
@@ -3086,6 +3087,7 @@ public:
protected:
uint32_t mFlags;
ViewID mScrollTarget;
float mScrollbarThumbRatio;
};
/**
+9
View File
@@ -0,0 +1,9 @@
.wide { background: red; width: 800px; height: 30px; display: inline-block;}
#container {
background-color: yellow;
}
#rightBox {
margin-left: 1000px;
}
+20
View File
@@ -0,0 +1,20 @@
<?xml version="1.0"?> <!-- -*- Mode: HTML -*- -->
<?xml-stylesheet type="text/css" href="1150021-1-ref.css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
title="gsg"
>
<vbox id="container">
<vbox id="rightBox">
<html:span>
<html:div class="wide"></html:div><html:div class="wide"></html:div>
</html:span>
</vbox>
</vbox>
</window>
+10
View File
@@ -0,0 +1,10 @@
window { direction: rtl; }
.wide { background: red; width: 800px; height: 30px; display: inline-block;}
#container {
background-color: yellow;
}
#rightBox {
margin-left: 1000px;
}
+20
View File
@@ -0,0 +1,20 @@
<?xml version="1.0"?> <!-- -*- Mode: HTML -*- -->
<?xml-stylesheet type="text/css" href="1150021-1.css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:html="http://www.w3.org/1999/xhtml"
title="gsg"
>
<vbox id="container">
<vbox id="rightBox">
<html:span>
<html:div class="wide"></html:div><html:div class="wide"></html:div>
</html:span>
</vbox>
</vbox>
</window>
+10
View File
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<title>Reference for test for bug 1151145</title>
<div style="height: 300px"></div>
<div style="width: 33em; border: solid white; transform: translate(100px) rotate(20deg);"></div>
<div style="height: 1000px"></div>
+21
View File
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en" class="reftest-wait">
<title>Test for bug 1151145</title>
<div style="height: 300px"></div>
<div style="width: 33em; border: solid white; transform: translate(100px) rotate(20deg);"></div>
<div style="height: 1000px"></div>
<script>
function doTest() {
document.documentElement.scrollTop = 0;
document.documentElement.removeAttribute("class");
}
document.documentElement.scrollTop = 255;
window.addEventListener("MozReftestInvalidate", doTest);
</script>
+30
View File
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<title>The div should have a white filling.</title>
<style>
html, body {
margin: 0;
padding: 0;
}
html {
background-color: white;
}
body {
padding: 10px;
}
div {
width: 50px;
height: 50px;
box-sizing: border-box;
border: 1px solid black;
}
</style>
<div></div>
+41
View File
@@ -0,0 +1,41 @@
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<title>The div shouldn't pull the html element's background color through the body background. There should be no red on this page.</title>
<style>
html, body {
margin: 0;
padding: 0;
height: 100%;
}
html {
background-color: red;
}
body {
transform: translateX(0.1px);
background-color: white;
box-sizing: border-box;
padding: 10px;
}
div {
position: relative;
width: 50px;
height: 50px;
box-sizing: border-box;
border: 1px solid black;
animation: leftFrom0To100 steps(1,end) 20000s alternate infinite;
}
@keyframes leftFrom0To100 {
from { left: 0px; }
to { left: 100px; }
}
</style>
<div></div>
+36
View File
@@ -0,0 +1,36 @@
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<title>The bounds calculation for border display items needs to take the border radius into account</title>
<style>
div {
margin: 10px;
height: 100px;
width: 100px;
box-sizing: border-box;
border-radius: 50px;
}
#one {
border-top: 10px solid blue;
}
#two {
border-top: 1px solid blue;
opacity: 0.5;
border-bottom: 1px solid white;
}
#three {
border-top: 1px solid blue;
mix-blend-mode: overlay;
border-bottom: 1px solid white;
}
</style>
<div id="one"></div>
<div id="two"></div>
<div id="three"></div>
+44
View File
@@ -0,0 +1,44 @@
<!DOCTYPE html>
<html class="reftest-wait">
<meta charset="utf-8">
<title>The bounds calculation for border display items needs to take the border radius into account</title>
<style>
div {
margin: 10px;
height: 100px;
width: 100px;
box-sizing: border-box;
border-radius: 50px;
}
#one {
border-top: 30px solid blue;
}
#two {
border-top: 1px solid blue;
opacity: 0.5;
}
#three {
border-top: 1px solid blue;
mix-blend-mode: overlay;
}
</style>
<div id="one"></div>
<div id="two"></div>
<div id="three"></div>
<script>
window.addEventListener("MozReftestInvalidate", function (e) {
document.getElementById("one").style.borderTopWidth = "10px";
document.documentElement.removeAttribute("class");
});
</script>
+4 -1
View File
@@ -1872,4 +1872,7 @@ fuzzy-if(d2d,36,304) HTTP(..) == 1116480-1-fakeitalic-overflow.html 1116480-1-fa
== 1128354-1.html 1128354-1-ref.html
== 1130231-1-button-padding-rtl.html 1130231-1-button-padding-rtl-ref.html
== 1130231-2-button-padding-rtl.html 1130231-2-button-padding-rtl-ref.html
pref(dom.use_xbl_scopes_for_remote_xul,true) HTTP(..) == 1157127-1.html 1157127-1-ref.html
skip-if(B2G||Mulet) == 1150021-1.xul 1150021-1-ref.xul
== 1151145-1.html 1151145-1-ref.html
== 1151306-1.html 1151306-1-ref.html
== 1156129-1.html 1156129-1-ref.html
+7 -1
View File
@@ -66,6 +66,7 @@
#include "mozilla/Preferences.h"
#include "nsThemeConstants.h"
#include "nsLayoutUtils.h"
#include "nsSliderFrame.h"
#include <algorithm>
// Needed for Print Preview
@@ -1312,6 +1313,7 @@ nsBoxFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
uint32_t flags = 0;
mozilla::layers::FrameMetrics::ViewID scrollTargetId =
mozilla::layers::FrameMetrics::NULL_SCROLL_ID;
float scrollbarThumbRatio = 0.0f;
if (GetContent()->IsXULElement()) {
// forcelayer is only supported on XUL elements with box layout
@@ -1323,6 +1325,9 @@ nsBoxFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
aBuilder->GetScrollbarInfo(&scrollTargetId, &flags);
forceLayer = (scrollTargetId != layers::FrameMetrics::NULL_SCROLL_ID);
nsLayoutUtils::SetScrollbarThumbLayerization(this, forceLayer);
nsSliderFrame* slider = do_QueryFrame(parent);
scrollbarThumbRatio = slider->GetThumbRatio();
}
}
// Check for frames that are marked as a part of the region used
@@ -1369,7 +1374,8 @@ nsBoxFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
// Wrap the list to make it its own layer
aLists.Content()->AppendNewToTop(new (aBuilder)
nsDisplayOwnLayer(aBuilder, this, &masterList, flags, scrollTargetId));
nsDisplayOwnLayer(aBuilder, this, &masterList, flags, scrollTargetId,
scrollbarThumbRatio));
}
}
+8
View File
@@ -1277,5 +1277,13 @@ nsSliderFrame::PageScroll(nscoord aChange)
PageUpDown(aChange);
}
float
nsSliderFrame::GetThumbRatio() const
{
// mRatio is in thumb app units per scrolled css pixels. Convert it to a
// a true unitless ratio.
return mRatio / mozilla::AppUnitsPerCSSPixel();
}
NS_IMPL_ISUPPORTS(nsSliderMediator,
nsIDOMEventListener)
+4
View File
@@ -131,6 +131,10 @@ public:
mozilla::WidgetGUIEvent* aEvent,
nsEventStatus* aEventStatus) override;
// Return the ratio the scrollbar thumb should move in proportion to the
// scrolled frame.
float GetThumbRatio() const;
private:
bool GetScrollToClick();
+13 -1
View File
@@ -400,7 +400,12 @@ nsSprocketLayout::Layout(nsIFrame* aBox, nsBoxLayoutState& aState)
nextY += (childBoxSize->right);
else
nextY -= (childBoxSize->left);
childRect.x = originalClientRect.x;
if (GetFrameDirection(aBox) == NS_STYLE_DIRECTION_LTR) {
childRect.x = originalClientRect.x;
} else {
// keep the right edge of the box the same
childRect.x = clientRect.x + originalClientRect.width - childRect.width;
}
}
// If we encounter a completely bogus box size, we just leave this child completely
@@ -532,6 +537,13 @@ nsSprocketLayout::Layout(nsIFrame* aBox, nsBoxLayoutState& aState)
newChildRect.y = childRect.YMost() - newChildRect.height;
}
if (!(frameState & NS_STATE_IS_HORIZONTAL)) {
if (GetFrameDirection(aBox) != NS_STYLE_DIRECTION_LTR) {
// keep the right edge the same
newChildRect.x = childRect.XMost() - newChildRect.width;
}
}
// If the child resized then recompute its position.
ComputeChildsNextPosition(aBox, x, y, nextX, nextY, newChildRect);
+9 -8
View File
@@ -387,7 +387,7 @@ Dashboard::GetSockets(SocketData *aSocketData)
Sequence<mozilla::dom::SocketElement> &sockets = dict.mSockets.Value();
uint32_t length = socketData->mData.Length();
if (!sockets.SetCapacity(length)) {
if (!sockets.SetCapacity(length, fallible)) {
JS_ReportOutOfMemory(cx);
return NS_ERROR_OUT_OF_MEMORY;
}
@@ -457,7 +457,7 @@ Dashboard::GetHttpConnections(HttpData *aHttpData)
Sequence<HttpConnectionElement> &connections = dict.mConnections.Value();
uint32_t length = httpData->mData.Length();
if (!connections.SetCapacity(length)) {
if (!connections.SetCapacity(length, fallible)) {
JS_ReportOutOfMemory(cx);
return NS_ERROR_OUT_OF_MEMORY;
}
@@ -478,9 +478,10 @@ Dashboard::GetHttpConnections(HttpData *aHttpData)
Sequence<HttpConnInfo> &idle = connection.mIdle.Value();
Sequence<HalfOpenInfoDict> &halfOpens = connection.mHalfOpens.Value();
if (!active.SetCapacity(httpData->mData[i].active.Length()) ||
!idle.SetCapacity(httpData->mData[i].idle.Length()) ||
!halfOpens.SetCapacity(httpData->mData[i].halfOpens.Length())) {
if (!active.SetCapacity(httpData->mData[i].active.Length(), fallible) ||
!idle.SetCapacity(httpData->mData[i].idle.Length(), fallible) ||
!halfOpens.SetCapacity(httpData->mData[i].halfOpens.Length(),
fallible)) {
JS_ReportOutOfMemory(cx);
return NS_ERROR_OUT_OF_MEMORY;
}
@@ -619,7 +620,7 @@ Dashboard::GetWebSocketConnections(WebSocketRequest *aWsRequest)
mozilla::MutexAutoLock lock(mWs.lock);
uint32_t length = mWs.data.Length();
if (!websockets.SetCapacity(length)) {
if (!websockets.SetCapacity(length, fallible)) {
JS_ReportOutOfMemory(cx);
return NS_ERROR_OUT_OF_MEMORY;
}
@@ -692,7 +693,7 @@ Dashboard::GetDNSCacheEntries(DnsData *dnsData)
Sequence<mozilla::dom::DnsCacheEntry> &entries = dict.mEntries.Value();
uint32_t length = dnsData->mData.Length();
if (!entries.SetCapacity(length)) {
if (!entries.SetCapacity(length, fallible)) {
JS_ReportOutOfMemory(cx);
return NS_ERROR_OUT_OF_MEMORY;
}
@@ -702,7 +703,7 @@ Dashboard::GetDNSCacheEntries(DnsData *dnsData)
entry.mHostaddr.Construct();
Sequence<nsString> &addrs = entry.mHostaddr.Value();
if (!addrs.SetCapacity(dnsData->mData[i].hostaddr.Length())) {
if (!addrs.SetCapacity(dnsData->mData[i].hostaddr.Length(), fallible)) {
JS_ReportOutOfMemory(cx);
return NS_ERROR_OUT_OF_MEMORY;
}
+2 -2
View File
@@ -162,8 +162,8 @@ UTF8InputStream::UTF8InputStream() :
nsresult
UTF8InputStream::Init(nsIInputStream* aStream)
{
if (!mByteData.SetCapacity(STRING_BUFFER_SIZE) ||
!mUnicharData.SetCapacity(STRING_BUFFER_SIZE)) {
if (!mByteData.SetCapacity(STRING_BUFFER_SIZE, mozilla::fallible) ||
!mUnicharData.SetCapacity(STRING_BUFFER_SIZE, mozilla::fallible)) {
return NS_ERROR_OUT_OF_MEMORY;
}
mInput = aStream;