author | Nathan Froyd <froydnj@mozilla.com> |
Fri, 30 Oct 2015 14:35:28 -0400 | |
changeset 306772 | 469fc8555c437105e4bdeea57e1645525bd83cdc |
parent 306771 | cf7d1833cf8ed760c6484c2c89aa2f089632844d |
child 306773 | c5c5874b08f3bc150536123d86050db2913200eb |
child 306800 | 11486a275847896bf97beff11d6c07ffea3611e9 |
push id | 1040 |
push user | raliiev@mozilla.com |
push date | Mon, 29 Feb 2016 17:11:22 +0000 |
treeherder | mozilla-release@8c3167321162 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | roc |
bugs | 1220392 |
milestone | 45.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/widget/gtk/nsWindow.cpp +++ b/widget/gtk/nsWindow.cpp @@ -2317,30 +2317,30 @@ nsWindow::OnExposeEvent(cairo_t *cr) void nsWindow::UpdateAlpha(gfxPattern* aPattern, nsIntRect aBoundsRect) { // We need to create our own buffer to force the stride to match the // expected stride. int32_t stride = GetAlignedStride<4>(BytesPerPixel(SurfaceFormat::A8) * aBoundsRect.width); int32_t bufferSize = stride * aBoundsRect.height; - nsAutoArrayPtr<uint8_t> imageBuffer(new (std::nothrow) uint8_t[bufferSize]); + UniquePtr<uint8_t[]> imageBuffer(new (std::nothrow) uint8_t[bufferSize]); RefPtr<DrawTarget> drawTarget = gfxPlatform::GetPlatform()-> - CreateDrawTargetForData(imageBuffer, aBoundsRect.Size(), + CreateDrawTargetForData(imageBuffer.get(), aBoundsRect.Size(), stride, SurfaceFormat::A8); if (drawTarget) { Matrix transform = Matrix::Translation(-aBoundsRect.x, -aBoundsRect.y); drawTarget->SetTransform(transform); drawTarget->FillRect(Rect(aBoundsRect.x, aBoundsRect.y, aBoundsRect.width, aBoundsRect.height), *aPattern->GetPattern(drawTarget), DrawOptions(1.0, CompositionOp::OP_SOURCE)); } - UpdateTranslucentWindowAlphaInternal(aBoundsRect, imageBuffer, stride); + UpdateTranslucentWindowAlphaInternal(aBoundsRect, imageBuffer.get(), stride); } gboolean nsWindow::OnConfigureEvent(GtkWidget *aWidget, GdkEventConfigure *aEvent) { // These events are only received on toplevel windows. // // GDK ensures that the coordinates are the client window top-left wrt the
--- a/widget/nsBaseWidget.cpp +++ b/widget/nsBaseWidget.cpp @@ -687,26 +687,26 @@ nsTransparencyMode nsBaseWidget::GetTran return eTransparencyOpaque; } bool nsBaseWidget::IsWindowClipRegionEqual(const nsTArray<nsIntRect>& aRects) { return mClipRects && mClipRectCount == aRects.Length() && - memcmp(mClipRects, aRects.Elements(), sizeof(nsIntRect)*mClipRectCount) == 0; + memcmp(mClipRects.get(), aRects.Elements(), sizeof(nsIntRect)*mClipRectCount) == 0; } void nsBaseWidget::StoreWindowClipRegion(const nsTArray<nsIntRect>& aRects) { mClipRectCount = aRects.Length(); - mClipRects = new nsIntRect[mClipRectCount]; + mClipRects = MakeUnique<nsIntRect[]>(mClipRectCount); if (mClipRects) { - memcpy(mClipRects, aRects.Elements(), sizeof(nsIntRect)*mClipRectCount); + memcpy(mClipRects.get(), aRects.Elements(), sizeof(nsIntRect)*mClipRectCount); } } void nsBaseWidget::GetWindowClipRegion(nsTArray<nsIntRect>* aRects) { if (mClipRects) { aRects->AppendElements(mClipRects.get(), mClipRectCount);
--- a/widget/nsBaseWidget.h +++ b/widget/nsBaseWidget.h @@ -504,17 +504,17 @@ protected: SetAllowedTouchBehaviorCallback mSetAllowedTouchBehaviorCallback; RefPtr<WidgetShutdownObserver> mShutdownObserver; RefPtr<TextEventDispatcher> mTextEventDispatcher; nsCursor mCursor; nsBorderStyle mBorderStyle; nsIntRect mBounds; nsIntRect* mOriginalBounds; // When this pointer is null, the widget is not clipped - nsAutoArrayPtr<nsIntRect> mClipRects; + mozilla::UniquePtr<nsIntRect[]> mClipRects; uint32_t mClipRectCount; nsSizeMode mSizeMode; nsPopupLevel mPopupLevel; nsPopupType mPopupType; SizeConstraints mSizeConstraints; bool mUpdateCursor; bool mUseAttachedEvents;
--- a/widget/nsPrimitiveHelpers.cpp +++ b/widget/nsPrimitiveHelpers.cpp @@ -54,21 +54,21 @@ nsPrimitiveHelpers :: CreatePrimitiveFor NS_ADDREF(*aPrimitive = primitive); } } else { nsCOMPtr<nsISupportsString> primitive = do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID); if (primitive ) { if (aDataLen % 2) { - nsAutoArrayPtr<char> buffer(new char[aDataLen + 1]); + auto buffer = MakeUnique<char[]>(aDataLen + 1); if (!MOZ_LIKELY(buffer)) return; - memcpy(buffer, aDataBuff, aDataLen); + memcpy(buffer.get(), aDataBuff, aDataLen); buffer[aDataLen] = 0; const char16_t* start = reinterpret_cast<const char16_t*>(buffer.get()); // recall that length takes length as characters, not bytes primitive->SetData(Substring(start, start + (aDataLen + 1) / 2)); } else { const char16_t* start = reinterpret_cast<const char16_t*>(aDataBuff); // recall that length takes length as characters, not bytes primitive->SetData(Substring(start, start + (aDataLen / 2)));
--- a/widget/nsTransferable.cpp +++ b/widget/nsTransferable.cpp @@ -178,32 +178,33 @@ DataStruct::ReadCache(nsISupports** aDat int64_t fileSize; int64_t max32 = 0xFFFFFFFF; cacheFile->GetFileSize(&fileSize); if (fileSize > max32) return NS_ERROR_OUT_OF_MEMORY; uint32_t size = uint32_t(fileSize); // create new memory for the large clipboard data - nsAutoArrayPtr<char> data(new char[size]); + auto data = MakeUnique<char[]>(size); if ( !data ) return NS_ERROR_OUT_OF_MEMORY; // now read it all in nsCOMPtr<nsIInputStream> inStr; NS_NewLocalFileInputStream( getter_AddRefs(inStr), cacheFile); if (!cacheFile) return NS_ERROR_FAILURE; - nsresult rv = inStr->Read(data, fileSize, aDataLen); + nsresult rv = inStr->Read(data.get(), fileSize, aDataLen); // make sure we got all the data ok if (NS_SUCCEEDED(rv) && *aDataLen == size) { - nsPrimitiveHelpers::CreatePrimitiveForData ( mFlavor.get(), data, fileSize, aData ); + nsPrimitiveHelpers::CreatePrimitiveForData(mFlavor.get(), data.get(), + fileSize, aData); return *aData ? NS_OK : NS_ERROR_FAILURE; } // zero the return params *aData = nullptr; *aDataLen = 0; }
--- a/widget/windows/LSPAnnotator.cpp +++ b/widget/windows/LSPAnnotator.cpp @@ -61,17 +61,17 @@ LSPAnnotationGatherer::Run() // Get the size of the buffer we need if (SOCKET_ERROR != WSCEnumProtocols(nullptr, nullptr, &size, &err) || err != WSAENOBUFS) { // Er, what? NS_NOTREACHED("WSCEnumProtocols suceeded when it should have failed ..."); return NS_ERROR_FAILURE; } - nsAutoArrayPtr<char> byteArray(new char[size]); + auto byteArray = MakeUnique<char[]>(size); WSAPROTOCOL_INFOW* providers = reinterpret_cast<WSAPROTOCOL_INFOW*>(byteArray.get()); int n = WSCEnumProtocols(nullptr, providers, &size, &err); if (n == SOCKET_ERROR) { // Lame. We provided the right size buffer; we'll just give up now. NS_WARNING("Could not get LSP list"); return NS_ERROR_FAILURE;
--- a/widget/windows/nsFilePicker.cpp +++ b/widget/windows/nsFilePicker.cpp @@ -5,32 +5,35 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "nsFilePicker.h" #include <shlobj.h> #include <shlwapi.h> #include <cderr.h> +#include "mozilla/UniquePtr.h" #include "mozilla/WindowsVersion.h" #include "nsReadableUtils.h" #include "nsNetUtil.h" #include "nsWindow.h" #include "nsILoadContext.h" #include "nsIServiceManager.h" #include "nsIURL.h" #include "nsIStringBundle.h" #include "nsEnumeratorUtils.h" #include "nsCRT.h" #include "nsString.h" #include "nsToolkit.h" #include "WinUtils.h" #include "nsPIDOMWindow.h" using mozilla::IsVistaOrLater; +using mozilla::MakeUnique; +using mozilla::UniquePtr; using namespace mozilla::widget; char16_t *nsFilePicker::mLastUsedUnicodeDirectory; char nsFilePicker::mLastUsedDirectory[MAX_PATH+1] = { 0 }; static const wchar_t kDialogPtrProp[] = L"DialogPtrProperty"; static const DWORD kDialogTimerID = 9999; static const unsigned long kDialogTimerTimeout = 300; @@ -65,33 +68,33 @@ private: }; // Manages the current working path. class AutoRestoreWorkingPath { public: AutoRestoreWorkingPath() { DWORD bufferLength = GetCurrentDirectoryW(0, nullptr); - mWorkingPath = new wchar_t[bufferLength]; - if (GetCurrentDirectoryW(bufferLength, mWorkingPath) == 0) { + mWorkingPath = MakeUnique<wchar_t[]>(bufferLength); + if (GetCurrentDirectoryW(bufferLength, mWorkingPath.get()) == 0) { mWorkingPath = nullptr; } } ~AutoRestoreWorkingPath() { if (HasWorkingPath()) { - ::SetCurrentDirectoryW(mWorkingPath); + ::SetCurrentDirectoryW(mWorkingPath.get()); } } inline bool HasWorkingPath() const { return mWorkingPath != nullptr; } private: - nsAutoArrayPtr<wchar_t> mWorkingPath; + UniquePtr<wchar_t[]> mWorkingPath; }; // Manages NS_NATIVE_TMP_WINDOW child windows. NS_NATIVE_TMP_WINDOWs are // temporary child windows of mParentWidget created to address RTL issues // in picker dialogs. We are responsible for destroying these. class AutoDestroyTmpWindow { public: @@ -518,26 +521,26 @@ nsFilePicker::SetDialogHandle(HWND aWnd) // Open the older XP style folder picker dialog. We end up in this call // on XP systems or when platform is built without the longhorn SDK. bool nsFilePicker::ShowXPFolderPicker(const nsString& aInitialDir) { bool result = false; - nsAutoArrayPtr<wchar_t> dirBuffer(new wchar_t[FILE_BUFFER_SIZE]); - wcsncpy(dirBuffer, aInitialDir.get(), FILE_BUFFER_SIZE); + auto dirBuffer = MakeUnique<wchar_t[]>(FILE_BUFFER_SIZE); + wcsncpy(dirBuffer.get(), aInitialDir.get(), FILE_BUFFER_SIZE); dirBuffer[FILE_BUFFER_SIZE-1] = '\0'; AutoDestroyTmpWindow adtw((HWND)(mParentWidget.get() ? mParentWidget->GetNativeData(NS_NATIVE_TMP_WINDOW) : nullptr)); BROWSEINFOW browserInfo = {0}; browserInfo.pidlRoot = nullptr; - browserInfo.pszDisplayName = dirBuffer; + browserInfo.pszDisplayName = dirBuffer.get(); browserInfo.lpszTitle = mTitle.get(); browserInfo.ulFlags = BIF_USENEWUI | BIF_RETURNONLYFSDIRS; browserInfo.hwndOwner = adtw.get(); browserInfo.iImage = 0; browserInfo.lParam = reinterpret_cast<LPARAM>(this); if (!aInitialDir.IsEmpty()) { // the dialog is modal so that |initialDir.get()| will be valid in @@ -546,19 +549,19 @@ nsFilePicker::ShowXPFolderPicker(const n browserInfo.lpfn = &BrowseCallbackProc; } else { browserInfo.lParam = 0; browserInfo.lpfn = nullptr; } LPITEMIDLIST list = ::SHBrowseForFolderW(&browserInfo); if (list) { - result = ::SHGetPathFromIDListW(list, dirBuffer); + result = ::SHGetPathFromIDListW(list, dirBuffer.get()); if (result) - mUnicodeFile.Assign(static_cast<const wchar_t*>(dirBuffer)); + mUnicodeFile.Assign(static_cast<const wchar_t*>(dirBuffer.get())); // free PIDL CoTaskMemFree(list); } return result; } /* @@ -662,31 +665,31 @@ nsFilePicker::FilePickerWrapper(OPENFILE bool nsFilePicker::ShowXPFilePicker(const nsString& aInitialDir) { OPENFILENAMEW ofn = {0}; ofn.lStructSize = sizeof(ofn); nsString filterBuffer = mFilterList; - nsAutoArrayPtr<wchar_t> fileBuffer(new wchar_t[FILE_BUFFER_SIZE]); - wcsncpy(fileBuffer, mDefaultFilePath.get(), FILE_BUFFER_SIZE); + auto fileBuffer = MakeUnique<wchar_t[]>(FILE_BUFFER_SIZE); + wcsncpy(fileBuffer.get(), mDefaultFilePath.get(), FILE_BUFFER_SIZE); fileBuffer[FILE_BUFFER_SIZE-1] = '\0'; // null terminate in case copy truncated if (!aInitialDir.IsEmpty()) { ofn.lpstrInitialDir = aInitialDir.get(); } AutoDestroyTmpWindow adtw((HWND) (mParentWidget.get() ? mParentWidget->GetNativeData(NS_NATIVE_TMP_WINDOW) : nullptr)); ofn.lpstrTitle = (LPCWSTR)mTitle.get(); ofn.lpstrFilter = (LPCWSTR)filterBuffer.get(); ofn.nFilterIndex = mSelectedType; - ofn.lpstrFile = fileBuffer; + ofn.lpstrFile = fileBuffer.get(); ofn.nMaxFile = FILE_BUFFER_SIZE; ofn.hwndOwner = adtw.get(); ofn.lCustData = reinterpret_cast<LPARAM>(this); ofn.Flags = OFN_SHAREAWARE | OFN_LONGNAMES | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_ENABLESIZING | OFN_EXPLORER; // Windows Vista and up won't allow you to use the new looking dialogs with @@ -749,19 +752,19 @@ nsFilePicker::ShowXPFilePicker(const nsS // allocated and that the returned value should be freed by the caller. // If the hook changes the buffer, it will deallocate the old buffer. // This fix would be nice to have in Vista and up, but it would force // the file picker to use the old style dialogs because hooks are not // allowed in the new file picker UI. We need to eventually move to // the new Common File Dialogs for Vista and up. if (!IsVistaOrLater()) { ofn.lpfnHook = MultiFilePickerHook; - fileBuffer.forget(); + fileBuffer.release(); result = FilePickerWrapper(&ofn, PICKER_TYPE_OPEN); - fileBuffer = ofn.lpstrFile; + fileBuffer.reset(ofn.lpstrFile); } else { result = FilePickerWrapper(&ofn, PICKER_TYPE_OPEN); } break; case modeSave: { ofn.Flags |= OFN_NOREADONLYRETURN; @@ -793,27 +796,27 @@ nsFilePicker::ShowXPFilePicker(const nsS if (!result) return false; // Remember what filter type the user selected mSelectedType = (int16_t)ofn.nFilterIndex; // Single file selection, we're done if (mMode != modeOpenMultiple) { - GetQualifiedPath(fileBuffer, mUnicodeFile); + GetQualifiedPath(fileBuffer.get(), mUnicodeFile); return true; } // Set user-selected location of file or directory. From msdn's "Open and // Save As Dialog Boxes" section: // If you specify OFN_EXPLORER, the directory and file name strings are '\0' // separated, with an extra '\0' character after the last file name. This // format enables the Explorer-style dialog boxes to return long file names // that include spaces. - wchar_t *current = fileBuffer; + wchar_t *current = fileBuffer.get(); nsAutoString dirName(current); // Sometimes dirName contains a trailing slash and sometimes it doesn't: if (current[dirName.Length() - 1] != '\\') dirName.Append((char16_t)'\\'); while (current && *current && *(current + wcslen(current) + 1)) { current = current + wcslen(current) + 1; @@ -834,17 +837,17 @@ nsFilePicker::ShowXPFilePicker(const nsS if (NS_FAILED(file->InitWithPath(canonicalizedPath)) || !mFiles.AppendObject(file)) return false; } // Handle the case where the user selected just one file. From msdn: If you // specify OFN_ALLOWMULTISELECT and the user selects only one file the // lpstrFile string does not have a separator between the path and file name. - if (current && *current && (current == fileBuffer)) { + if (current && *current && (current == fileBuffer.get())) { nsCOMPtr<nsIFile> file = do_CreateInstance("@mozilla.org/file/local;1"); NS_ENSURE_TRUE(file, false); nsAutoString canonicalizedPath; GetQualifiedPath(current, canonicalizedPath); if (NS_FAILED(file->InitWithPath(canonicalizedPath)) || !mFiles.AppendObject(file)) return false;