зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1222475 - use UniquePtr<T[]> instead of nsAutoArrayPtr<T> in dom/; r=baku,bz,terrence
This commit is contained in:
Родитель
42b8a01c15
Коммит
ddc23df5df
|
@ -10,6 +10,9 @@
|
|||
#include "nsContentUtils.h"
|
||||
#include "nsCExternalHandlerService.h"
|
||||
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
USING_ARCHIVEREADER_NAMESPACE
|
||||
|
@ -191,8 +194,8 @@ ArchiveReaderZipEvent::Exec()
|
|||
}
|
||||
|
||||
// Read the name:
|
||||
nsAutoArrayPtr<char> filename(new char[filenameLen + 1]);
|
||||
rv = inputStream->Read(filename, filenameLen, &ret);
|
||||
auto filename = MakeUnique<char[]>(filenameLen + 1);
|
||||
rv = inputStream->Read(filename.get(), filenameLen, &ret);
|
||||
if (NS_FAILED(rv) || ret != filenameLen) {
|
||||
return RunShare(NS_ERROR_UNEXPECTED);
|
||||
}
|
||||
|
@ -201,7 +204,8 @@ ArchiveReaderZipEvent::Exec()
|
|||
|
||||
// We ignore the directories:
|
||||
if (filename[filenameLen - 1] != '/') {
|
||||
mFileList.AppendElement(new ArchiveZipItem(filename, centralStruct, mEncoding));
|
||||
mFileList.AppendElement(new ArchiveZipItem(filename.get(), centralStruct,
|
||||
mEncoding));
|
||||
}
|
||||
|
||||
// Ignore the rest
|
||||
|
|
|
@ -2273,8 +2273,7 @@ nsGonkCameraControl::CreatePoster(Image* aImage, uint32_t aWidth, uint32_t aHeig
|
|||
|
||||
// ARGB is 32 bits / pixel
|
||||
size_t tmpLength = mWidth * mHeight * sizeof(uint32_t);
|
||||
nsAutoArrayPtr<uint8_t> tmp;
|
||||
tmp = new uint8_t[tmpLength];
|
||||
UniquePtr<uint8_t[]> tmp = MakeUnique<uint8_t[]>(tmpLength);
|
||||
|
||||
GrallocImage* nativeImage = static_cast<GrallocImage*>(mImage.get());
|
||||
android::sp<GraphicBuffer> graphicBuffer = nativeImage->GetGraphicBuffer();
|
||||
|
@ -2284,7 +2283,7 @@ nsGonkCameraControl::CreatePoster(Image* aImage, uint32_t aWidth, uint32_t aHeig
|
|||
|
||||
uint32_t stride = mWidth * 4;
|
||||
int err = libyuv::ConvertToARGB(static_cast<uint8_t*>(graphicSrc),
|
||||
srcLength, tmp, stride, 0, 0,
|
||||
srcLength, tmp.get(), stride, 0, 0,
|
||||
mWidth, mHeight, mWidth, mHeight,
|
||||
libyuv::kRotate0, libyuv::FOURCC_NV21);
|
||||
|
||||
|
@ -2307,7 +2306,7 @@ nsGonkCameraControl::CreatePoster(Image* aImage, uint32_t aWidth, uint32_t aHeig
|
|||
}
|
||||
|
||||
nsString opt;
|
||||
nsresult rv = encoder->InitFromData(tmp, tmpLength, mWidth,
|
||||
nsresult rv = encoder->InitFromData(tmp.get(), tmpLength, mWidth,
|
||||
mHeight, stride,
|
||||
imgIEncoder::INPUT_FORMAT_HOSTARGB,
|
||||
opt);
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "mozilla/dom/TextDecoder.h"
|
||||
#include "mozilla/dom/EncodingUtils.h"
|
||||
#include "mozilla/dom/UnionTypes.h"
|
||||
#include "mozilla/UniquePtrExtensions.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include <stdint.h>
|
||||
|
||||
|
@ -65,18 +66,18 @@ TextDecoder::Decode(const char* aInput, const int32_t aLength,
|
|||
}
|
||||
// Need a fallible allocator because the caller may be a content
|
||||
// and the content can specify the length of the string.
|
||||
nsAutoArrayPtr<char16_t> buf(new (fallible) char16_t[outLen + 1]);
|
||||
auto buf = MakeUniqueFallible<char16_t[]>(outLen + 1);
|
||||
if (!buf) {
|
||||
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t length = aLength;
|
||||
rv = mDecoder->Convert(aInput, &length, buf, &outLen);
|
||||
rv = mDecoder->Convert(aInput, &length, buf.get(), &outLen);
|
||||
MOZ_ASSERT(mFatal || rv != NS_ERROR_ILLEGAL_INPUT);
|
||||
buf[outLen] = 0;
|
||||
|
||||
if (!aOutDecodedString.Append(buf, outLen, fallible)) {
|
||||
if (!aOutDecodedString.Append(buf.get(), outLen, fallible)) {
|
||||
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "mozilla/dom/TextEncoder.h"
|
||||
#include "mozilla/dom/EncodingUtils.h"
|
||||
#include "mozilla/UniquePtrExtensions.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
@ -54,18 +55,18 @@ TextEncoder::Encode(JSContext* aCx,
|
|||
}
|
||||
// Need a fallible allocator because the caller may be a content
|
||||
// and the content can specify the length of the string.
|
||||
nsAutoArrayPtr<char> buf(new (fallible) char[maxLen + 1]);
|
||||
auto buf = MakeUniqueFallible<char[]>(maxLen + 1);
|
||||
if (!buf) {
|
||||
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t dstLen = maxLen;
|
||||
rv = mEncoder->Convert(data, &srcLen, buf, &dstLen);
|
||||
rv = mEncoder->Convert(data, &srcLen, buf.get(), &dstLen);
|
||||
|
||||
// Now reset the encoding algorithm state to the default values for encoding.
|
||||
int32_t finishLen = maxLen - dstLen;
|
||||
rv = mEncoder->Finish(buf + dstLen, &finishLen);
|
||||
rv = mEncoder->Finish(&buf[dstLen], &finishLen);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
dstLen += finishLen;
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "mozilla/dom/HTMLFrameSetElementBinding.h"
|
||||
#include "mozilla/dom/EventHandlerBinding.h"
|
||||
#include "nsGlobalWindow.h"
|
||||
#include "mozilla/UniquePtrExtensions.h"
|
||||
|
||||
NS_IMPL_NS_NEW_HTML_ELEMENT(FrameSet)
|
||||
|
||||
|
@ -81,7 +82,7 @@ HTMLFrameSetElement::SetAttr(int32_t aNameSpaceID,
|
|||
*/
|
||||
if (aAttribute == nsGkAtoms::rows && aNameSpaceID == kNameSpaceID_None) {
|
||||
int32_t oldRows = mNumRows;
|
||||
ParseRowCol(aValue, mNumRows, getter_Transfers(mRowSpecs));
|
||||
ParseRowCol(aValue, mNumRows, &mRowSpecs);
|
||||
|
||||
if (mNumRows != oldRows) {
|
||||
mCurrentRowColHint = NS_STYLE_HINT_FRAMECHANGE;
|
||||
|
@ -89,7 +90,7 @@ HTMLFrameSetElement::SetAttr(int32_t aNameSpaceID,
|
|||
} else if (aAttribute == nsGkAtoms::cols &&
|
||||
aNameSpaceID == kNameSpaceID_None) {
|
||||
int32_t oldCols = mNumCols;
|
||||
ParseRowCol(aValue, mNumCols, getter_Transfers(mColSpecs));
|
||||
ParseRowCol(aValue, mNumCols, &mColSpecs);
|
||||
|
||||
if (mNumCols != oldCols) {
|
||||
mCurrentRowColHint = NS_STYLE_HINT_FRAMECHANGE;
|
||||
|
@ -116,19 +117,19 @@ HTMLFrameSetElement::GetRowSpec(int32_t *aNumValues,
|
|||
const nsAttrValue* value = GetParsedAttr(nsGkAtoms::rows);
|
||||
if (value && value->Type() == nsAttrValue::eString) {
|
||||
nsresult rv = ParseRowCol(value->GetStringValue(), mNumRows,
|
||||
getter_Transfers(mRowSpecs));
|
||||
&mRowSpecs);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
if (!mRowSpecs) { // we may not have had an attr or had an empty attr
|
||||
mRowSpecs = new nsFramesetSpec[1];
|
||||
mRowSpecs = MakeUnique<nsFramesetSpec[]>(1);
|
||||
mNumRows = 1;
|
||||
mRowSpecs[0].mUnit = eFramesetUnit_Relative;
|
||||
mRowSpecs[0].mValue = 1;
|
||||
}
|
||||
}
|
||||
|
||||
*aSpecs = mRowSpecs;
|
||||
*aSpecs = mRowSpecs.get();
|
||||
*aNumValues = mNumRows;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -146,19 +147,19 @@ HTMLFrameSetElement::GetColSpec(int32_t *aNumValues,
|
|||
const nsAttrValue* value = GetParsedAttr(nsGkAtoms::cols);
|
||||
if (value && value->Type() == nsAttrValue::eString) {
|
||||
nsresult rv = ParseRowCol(value->GetStringValue(), mNumCols,
|
||||
getter_Transfers(mColSpecs));
|
||||
&mColSpecs);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
if (!mColSpecs) { // we may not have had an attr or had an empty attr
|
||||
mColSpecs = new nsFramesetSpec[1];
|
||||
mColSpecs = MakeUnique<nsFramesetSpec[]>(1);
|
||||
mNumCols = 1;
|
||||
mColSpecs[0].mUnit = eFramesetUnit_Relative;
|
||||
mColSpecs[0].mValue = 1;
|
||||
}
|
||||
}
|
||||
|
||||
*aSpecs = mColSpecs;
|
||||
*aSpecs = mColSpecs.get();
|
||||
*aNumValues = mNumCols;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -205,7 +206,7 @@ HTMLFrameSetElement::GetAttributeChangeHint(const nsIAtom* aAttribute,
|
|||
nsresult
|
||||
HTMLFrameSetElement::ParseRowCol(const nsAString & aValue,
|
||||
int32_t& aNumSpecs,
|
||||
nsFramesetSpec** aSpecs)
|
||||
UniquePtr<nsFramesetSpec[]>* aSpecs)
|
||||
{
|
||||
if (aValue.IsEmpty()) {
|
||||
aNumSpecs = 0;
|
||||
|
@ -233,7 +234,7 @@ HTMLFrameSetElement::ParseRowCol(const nsAString & aValue,
|
|||
commaX = spec.FindChar(sComma, commaX + 1);
|
||||
}
|
||||
|
||||
nsFramesetSpec* specs = new (fallible) nsFramesetSpec[count];
|
||||
auto specs = MakeUniqueFallible<nsFramesetSpec[]>(count);
|
||||
if (!specs) {
|
||||
*aSpecs = nullptr;
|
||||
aNumSpecs = 0;
|
||||
|
@ -327,8 +328,8 @@ HTMLFrameSetElement::ParseRowCol(const nsAString & aValue,
|
|||
|
||||
aNumSpecs = count;
|
||||
// Transfer ownership to caller here
|
||||
*aSpecs = specs;
|
||||
|
||||
*aSpecs = Move(specs);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#define HTMLFrameSetElement_h
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "nsIDOMHTMLFrameSetElement.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
|
||||
|
@ -144,8 +145,8 @@ protected:
|
|||
|
||||
private:
|
||||
nsresult ParseRowCol(const nsAString& aValue,
|
||||
int32_t& aNumSpecs,
|
||||
nsFramesetSpec** aSpecs);
|
||||
int32_t& aNumSpecs,
|
||||
UniquePtr<nsFramesetSpec[]>* aSpecs);
|
||||
|
||||
/**
|
||||
* The number of size specs in our "rows" attr
|
||||
|
@ -163,11 +164,11 @@ private:
|
|||
/**
|
||||
* The parsed representation of the "rows" attribute
|
||||
*/
|
||||
nsAutoArrayPtr<nsFramesetSpec> mRowSpecs; // parsed, non-computed dimensions
|
||||
UniquePtr<nsFramesetSpec[]> mRowSpecs; // parsed, non-computed dimensions
|
||||
/**
|
||||
* The parsed representation of the "cols" attribute
|
||||
*/
|
||||
nsAutoArrayPtr<nsFramesetSpec> mColSpecs; // parsed, non-computed dimensions
|
||||
UniquePtr<nsFramesetSpec[]> mColSpecs; // parsed, non-computed dimensions
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/TextEvents.h"
|
||||
#include "mozilla/TouchEvents.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "mozilla/unused.h"
|
||||
#include "BlobParent.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
@ -2125,25 +2126,25 @@ TabParent::RecvEnableDisableCommands(const nsString& aAction,
|
|||
{
|
||||
nsCOMPtr<nsIRemoteBrowser> remoteBrowser = do_QueryInterface(mFrameElement);
|
||||
if (remoteBrowser) {
|
||||
nsAutoArrayPtr<const char*> enabledCommands, disabledCommands;
|
||||
UniquePtr<const char*[]> enabledCommands, disabledCommands;
|
||||
|
||||
if (aEnabledCommands.Length()) {
|
||||
enabledCommands = new const char* [aEnabledCommands.Length()];
|
||||
enabledCommands = MakeUnique<const char*[]>(aEnabledCommands.Length());
|
||||
for (uint32_t c = 0; c < aEnabledCommands.Length(); c++) {
|
||||
enabledCommands[c] = aEnabledCommands[c].get();
|
||||
}
|
||||
}
|
||||
|
||||
if (aDisabledCommands.Length()) {
|
||||
disabledCommands = new const char* [aDisabledCommands.Length()];
|
||||
disabledCommands = MakeUnique<const char*[]>(aDisabledCommands.Length());
|
||||
for (uint32_t c = 0; c < aDisabledCommands.Length(); c++) {
|
||||
disabledCommands[c] = aDisabledCommands[c].get();
|
||||
}
|
||||
}
|
||||
|
||||
remoteBrowser->EnableDisableCommands(aAction,
|
||||
aEnabledCommands.Length(), enabledCommands,
|
||||
aDisabledCommands.Length(), disabledCommands);
|
||||
aEnabledCommands.Length(), enabledCommands.get(),
|
||||
aDisabledCommands.Length(), disabledCommands.get());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "mozilla/dom/ToJSValue.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "nsIMmsService.h"
|
||||
#include "nsIMobileMessageCallback.h"
|
||||
#include "nsIMobileMessageDatabaseService.h"
|
||||
|
@ -424,7 +425,7 @@ MobileMessageManager::GetMessages(const MobileMessageFilter& aFilter,
|
|||
endDate = aFilter.mEndDate.Value();
|
||||
}
|
||||
|
||||
nsAutoArrayPtr<const char16_t*> ptrNumbers;
|
||||
UniquePtr<const char16_t*[]> ptrNumbers;
|
||||
uint32_t numbersCount = 0;
|
||||
if (!aFilter.mNumbers.IsNull() &&
|
||||
aFilter.mNumbers.Value().Length()) {
|
||||
|
@ -432,7 +433,7 @@ MobileMessageManager::GetMessages(const MobileMessageFilter& aFilter,
|
|||
uint32_t index;
|
||||
|
||||
numbersCount = numbers.Length();
|
||||
ptrNumbers = new const char16_t* [numbersCount];
|
||||
ptrNumbers = MakeUnique<const char16_t*[]>(numbersCount);
|
||||
for (index = 0; index < numbersCount; index++) {
|
||||
ptrNumbers[index] = numbers[index].get();
|
||||
}
|
||||
|
@ -464,7 +465,7 @@ MobileMessageManager::GetMessages(const MobileMessageFilter& aFilter,
|
|||
nsCOMPtr<nsICursorContinueCallback> continueCallback;
|
||||
nsresult rv = dbService->CreateMessageCursor(hasStartDate, startDate,
|
||||
hasEndDate, endDate,
|
||||
ptrNumbers, numbersCount,
|
||||
ptrNumbers.get(), numbersCount,
|
||||
delivery,
|
||||
hasRead, read,
|
||||
hasThreadId, threadId,
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "mozilla/dom/File.h"
|
||||
#include "mozilla/dom/ToJSValue.h"
|
||||
#include "mozilla/dom/mobilemessage/Constants.h" // For MessageType
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsTArrayHelpers.h"
|
||||
#include "xpcpublic.h"
|
||||
|
@ -830,12 +831,12 @@ MobileMessageCursorParent::DoRequest(const CreateMessageCursorRequest& aRequest)
|
|||
const SmsFilterData& filter = aRequest.filter();
|
||||
|
||||
const nsTArray<nsString>& numbers = filter.numbers();
|
||||
nsAutoArrayPtr<const char16_t*> ptrNumbers;
|
||||
UniquePtr<const char16_t*[]> ptrNumbers;
|
||||
uint32_t numbersCount = numbers.Length();
|
||||
if (numbersCount) {
|
||||
uint32_t index;
|
||||
|
||||
ptrNumbers = new const char16_t* [numbersCount];
|
||||
ptrNumbers = MakeUnique<const char16_t*[]>(numbersCount);
|
||||
for (index = 0; index < numbersCount; index++) {
|
||||
ptrNumbers[index] = numbers[index].get();
|
||||
}
|
||||
|
@ -845,7 +846,7 @@ MobileMessageCursorParent::DoRequest(const CreateMessageCursorRequest& aRequest)
|
|||
filter.startDate(),
|
||||
filter.hasEndDate(),
|
||||
filter.endDate(),
|
||||
ptrNumbers, numbersCount,
|
||||
ptrNumbers.get(), numbersCount,
|
||||
filter.delivery(),
|
||||
filter.hasRead(),
|
||||
filter.read(),
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
#include "mozilla/dom/SVGFEConvolveMatrixElement.h"
|
||||
#include "mozilla/dom/SVGFEConvolveMatrixElementBinding.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "mozilla/UniquePtrExtensions.h"
|
||||
#include "DOMSVGAnimatedNumberList.h"
|
||||
#include "nsSVGUtils.h"
|
||||
#include "nsSVGFilterInstance.h"
|
||||
|
@ -203,7 +205,7 @@ SVGFEConvolveMatrixElement::GetPrimitiveDescription(nsSVGFilterInstance* aInstan
|
|||
if (orderX > NS_SVG_OFFSCREEN_MAX_DIMENSION ||
|
||||
orderY > NS_SVG_OFFSCREEN_MAX_DIMENSION)
|
||||
return failureDescription;
|
||||
nsAutoArrayPtr<float> kernel(new (fallible) float[orderX * orderY]);
|
||||
UniquePtr<float[]> kernel = MakeUniqueFallible<float[]>(orderX * orderY);
|
||||
if (!kernel)
|
||||
return failureDescription;
|
||||
for (uint32_t i = 0; i < kmLength; i++) {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "TelephonyChild.h"
|
||||
|
||||
#include "mozilla/dom/telephony/TelephonyDialCallback.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "TelephonyIPCService.h"
|
||||
|
||||
USING_TELEPHONY_NAMESPACE
|
||||
|
@ -212,12 +213,13 @@ TelephonyRequestChild::DoResponse(const DialResponseMMISuccess& aResponse)
|
|||
uint32_t count = info.get_ArrayOfnsString().Length();
|
||||
const nsTArray<nsString>& additionalInformation = info.get_ArrayOfnsString();
|
||||
|
||||
nsAutoArrayPtr<const char16_t*> additionalInfoPtrs(new const char16_t*[count]);
|
||||
auto additionalInfoPtrs = MakeUnique<const char16_t*[]>(count);
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
additionalInfoPtrs[i] = additionalInformation[i].get();
|
||||
}
|
||||
|
||||
callback->NotifyDialMMISuccessWithStrings(statusMessage, count, additionalInfoPtrs);
|
||||
callback->NotifyDialMMISuccessWithStrings(statusMessage, count,
|
||||
additionalInfoPtrs.get());
|
||||
break;
|
||||
}
|
||||
case AdditionalInformation::TArrayOfnsMobileCallForwardingOptions: {
|
||||
|
|
|
@ -17,8 +17,11 @@
|
|||
#include "xptcall.h"
|
||||
#include "txXPathObjectAdaptor.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIClassInfo.h"
|
||||
#include "nsIInterfaceInfo.h"
|
||||
#include "js/RootingAPI.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS(txXPathObjectAdaptor, txIXPathObject)
|
||||
|
||||
|
@ -295,23 +298,38 @@ txXPCOMExtensionFunctionCall::GetParamType(const nsXPTParamInfo &aParam,
|
|||
}
|
||||
}
|
||||
|
||||
class txParamArrayHolder
|
||||
class txParamArrayHolder : public JS::Traceable
|
||||
{
|
||||
public:
|
||||
txParamArrayHolder()
|
||||
: mCount(0)
|
||||
{
|
||||
}
|
||||
txParamArrayHolder(txParamArrayHolder&& rhs)
|
||||
: mArray(mozilla::Move(rhs.mArray))
|
||||
, mCount(rhs.mCount)
|
||||
{
|
||||
rhs.mCount = 0;
|
||||
}
|
||||
~txParamArrayHolder();
|
||||
|
||||
bool Init(uint8_t aCount);
|
||||
operator nsXPTCVariant*() const
|
||||
{
|
||||
return mArray;
|
||||
return mArray.get();
|
||||
}
|
||||
|
||||
static void trace(txParamArrayHolder* holder, JSTracer* trc) { holder->trace(trc); }
|
||||
void trace(JSTracer* trc) {
|
||||
for (uint8_t i = 0; i < mCount; ++i) {
|
||||
if (mArray[i].type == nsXPTType::T_JSVAL) {
|
||||
JS::UnsafeTraceRoot(trc, &mArray[i].val.j, "txParam value");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
nsAutoArrayPtr<nsXPTCVariant> mArray;
|
||||
mozilla::UniquePtr<nsXPTCVariant[]> mArray;
|
||||
uint8_t mCount;
|
||||
};
|
||||
|
||||
|
@ -338,8 +356,12 @@ bool
|
|||
txParamArrayHolder::Init(uint8_t aCount)
|
||||
{
|
||||
mCount = aCount;
|
||||
mArray = new nsXPTCVariant[mCount];
|
||||
memset(mArray, 0, mCount * sizeof(nsXPTCVariant));
|
||||
mArray = mozilla::MakeUnique<nsXPTCVariant[]>(mCount);
|
||||
if (!mArray) {
|
||||
return false;
|
||||
}
|
||||
|
||||
memset(mArray.get(), 0, mCount * sizeof(nsXPTCVariant));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -363,8 +385,8 @@ txXPCOMExtensionFunctionCall::evaluate(txIEvalContext* aContext,
|
|||
uint8_t paramCount = methodInfo->GetParamCount();
|
||||
uint8_t inArgs = paramCount - 1;
|
||||
|
||||
txParamArrayHolder invokeParams;
|
||||
if (!invokeParams.Init(paramCount)) {
|
||||
JS::Rooted<txParamArrayHolder> invokeParams(nsContentUtils::RootingCxForThread());
|
||||
if (!invokeParams.get().Init(paramCount)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
|
@ -385,7 +407,7 @@ txXPCOMExtensionFunctionCall::evaluate(txIEvalContext* aContext,
|
|||
// Create context wrapper.
|
||||
context = new txFunctionEvaluationContext(aContext, mState);
|
||||
|
||||
nsXPTCVariant &invokeParam = invokeParams[0];
|
||||
nsXPTCVariant &invokeParam = invokeParams.get()[0];
|
||||
invokeParam.type = paramInfo.GetType();
|
||||
invokeParam.SetValNeedsCleanup();
|
||||
NS_ADDREF((txIFunctionEvaluationContext*&)invokeParam.val.p = context);
|
||||
|
@ -412,7 +434,7 @@ txXPCOMExtensionFunctionCall::evaluate(txIEvalContext* aContext,
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsXPTCVariant &invokeParam = invokeParams[i];
|
||||
nsXPTCVariant &invokeParam = invokeParams.get()[i];
|
||||
if (paramInfo.IsOut()) {
|
||||
// We don't support out values.
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -500,7 +522,7 @@ txXPCOMExtensionFunctionCall::evaluate(txIEvalContext* aContext,
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsXPTCVariant &returnParam = invokeParams[inArgs];
|
||||
nsXPTCVariant &returnParam = invokeParams.get()[inArgs];
|
||||
returnParam.type = returnInfo.GetType();
|
||||
if (returnType == eSTRING) {
|
||||
nsString *value = new nsString();
|
||||
|
@ -514,7 +536,7 @@ txXPCOMExtensionFunctionCall::evaluate(txIEvalContext* aContext,
|
|||
}
|
||||
}
|
||||
|
||||
rv = NS_InvokeByIndex(mHelper, mMethodIndex, paramCount, invokeParams);
|
||||
rv = NS_InvokeByIndex(mHelper, mMethodIndex, paramCount, invokeParams.get());
|
||||
|
||||
// In case someone is holding on to the txFunctionEvaluationContext which
|
||||
// could thus stay alive longer than this function.
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/EncodingUtils.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using mozilla::dom::EncodingUtils;
|
||||
|
@ -523,9 +524,9 @@ handleNode(nsINode* aNode, txStylesheetCompiler* aCompiler)
|
|||
dom::Element* element = aNode->AsElement();
|
||||
|
||||
uint32_t attsCount = element->GetAttrCount();
|
||||
nsAutoArrayPtr<txStylesheetAttr> atts;
|
||||
UniquePtr<txStylesheetAttr[]> atts;
|
||||
if (attsCount > 0) {
|
||||
atts = new txStylesheetAttr[attsCount];
|
||||
atts = MakeUnique<txStylesheetAttr[]>(attsCount);
|
||||
uint32_t counter;
|
||||
for (counter = 0; counter < attsCount; ++counter) {
|
||||
txStylesheetAttr& att = atts[counter];
|
||||
|
@ -541,7 +542,7 @@ handleNode(nsINode* aNode, txStylesheetCompiler* aCompiler)
|
|||
|
||||
rv = aCompiler->startElement(ni->NamespaceID(),
|
||||
ni->NameAtom(),
|
||||
ni->GetPrefixAtom(), atts,
|
||||
ni->GetPrefixAtom(), atts.get(),
|
||||
attsCount);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/Move.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
||||
#include "txStylesheetCompiler.h"
|
||||
#include "txStylesheetCompileHandlers.h"
|
||||
|
@ -124,9 +125,9 @@ txStylesheetCompiler::startElement(const char16_t *aName,
|
|||
nsresult rv = flushCharacters();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsAutoArrayPtr<txStylesheetAttr> atts;
|
||||
UniquePtr<txStylesheetAttr[]> atts;
|
||||
if (aAttrCount > 0) {
|
||||
atts = new txStylesheetAttr[aAttrCount];
|
||||
atts = MakeUnique<txStylesheetAttr[]>(aAttrCount);
|
||||
}
|
||||
|
||||
bool hasOwnNamespaceMap = false;
|
||||
|
@ -169,7 +170,7 @@ txStylesheetCompiler::startElement(const char16_t *aName,
|
|||
getter_AddRefs(localname), &namespaceID);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return startElementInternal(namespaceID, localname, prefix, atts,
|
||||
return startElementInternal(namespaceID, localname, prefix, atts.get(),
|
||||
aAttrCount);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче