commit a2bf1f70eb9ff6b24e7a8612ea1e4537241865a4
parent 68fc7de6054665a2ebd840a857e6502f939742b2
Author: Andrew McCreight <continuation@gmail.com>
Date: Fri, 3 Oct 2025 19:33:34 +0000
Bug 1880093 - part 2: Use nsTArray for Area::mCoords in nsImageMap.cpp. r=layout-reviewers,dholbert
mNumCoords is now redundant with mCoords.Length(). It will be removed in the next patch.
Differential Revision: https://phabricator.services.mozilla.com/D267082
Diffstat:
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/layout/generic/nsImageMap.cpp b/layout/generic/nsImageMap.cpp
@@ -24,6 +24,7 @@
#include "nsPresContext.h"
#include "nsReadableUtils.h"
#include "nsString.h"
+#include "nsTArray.h"
#ifdef ACCESSIBILITY
# include "nsAccessibilityService.h"
@@ -51,7 +52,7 @@ class Area {
bool HasFocus() const { return mHasFocus; }
RefPtr<HTMLAreaElement> mArea;
- UniquePtr<nscoord[]> mCoords;
+ nsTArray<nscoord> mCoords;
int32_t mNumCoords;
bool mHasFocus = false;
};
@@ -90,7 +91,7 @@ void Area::ParseCoords(const nsAString& aSpec) {
* Nothing in an empty list
*/
mNumCoords = 0;
- mCoords = nullptr;
+ mCoords.Clear();
if (*cp == '\0') {
free(cp);
return;
@@ -176,11 +177,8 @@ void Area::ParseCoords(const nsAString& aSpec) {
/*
* Allocate space for the coordinate array.
*/
- UniquePtr<nscoord[]> value_list = MakeUnique<nscoord[]>(cnt);
- if (!value_list) {
- free(cp);
- return;
- }
+ nsTArray<nscoord> value_list;
+ value_list.SetLength(cnt);
/*
* Second pass to copy integer values into list.