зеркало из https://github.com/mozilla/gecko-dev.git
Merge inbound to mozilla-central. a=merge
This commit is contained in:
Коммит
21b5725e3c
|
@ -1804,7 +1804,8 @@ nsDocShell::AddWeakPrivacyTransitionObserver(
|
||||||
if (!weakObs) {
|
if (!weakObs) {
|
||||||
return NS_ERROR_NOT_AVAILABLE;
|
return NS_ERROR_NOT_AVAILABLE;
|
||||||
}
|
}
|
||||||
return mPrivacyObservers.AppendElement(weakObs) ? NS_OK : NS_ERROR_FAILURE;
|
mPrivacyObservers.AppendElement(weakObs);
|
||||||
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
@ -1814,7 +1815,8 @@ nsDocShell::AddWeakReflowObserver(nsIReflowObserver* aObserver)
|
||||||
if (!weakObs) {
|
if (!weakObs) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
return mReflowObservers.AppendElement(weakObs) ? NS_OK : NS_ERROR_FAILURE;
|
mReflowObservers.AppendElement(weakObs);
|
||||||
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
@ -2515,7 +2517,8 @@ nsDocShell::AddWeakScrollObserver(nsIScrollObserver* aObserver)
|
||||||
if (!weakObs) {
|
if (!weakObs) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
return mScrollObservers.AppendElement(weakObs) ? NS_OK : NS_ERROR_FAILURE;
|
mScrollObservers.AppendElement(weakObs);
|
||||||
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
|
|
@ -782,8 +782,8 @@ nsSHistory::AddSHistoryListener(nsISHistoryListener* aListener)
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return mListeners.AppendElementUnlessExists(listener) ?
|
mListeners.AppendElementUnlessExists(listener);
|
||||||
NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
|
|
@ -2100,9 +2100,7 @@ nsDocument::Init()
|
||||||
// subclasses currently do, other don't). This is because the code in
|
// subclasses currently do, other don't). This is because the code in
|
||||||
// nsNodeUtils always notifies the first observer first, expecting the
|
// nsNodeUtils always notifies the first observer first, expecting the
|
||||||
// first observer to be the document.
|
// first observer to be the document.
|
||||||
NS_ENSURE_TRUE(slots->mMutationObservers.PrependElementUnlessExists(static_cast<nsIMutationObserver*>(this)),
|
slots->mMutationObservers.PrependElementUnlessExists(static_cast<nsIMutationObserver*>(this));
|
||||||
NS_ERROR_OUT_OF_MEMORY);
|
|
||||||
|
|
||||||
|
|
||||||
mOnloadBlocker = new nsOnloadBlocker();
|
mOnloadBlocker = new nsOnloadBlocker();
|
||||||
mCSSLoader = new mozilla::css::Loader(this);
|
mCSSLoader = new mozilla::css::Loader(this);
|
||||||
|
|
|
@ -88,9 +88,7 @@ CoalescedMouseMoveFlusher::StartObserver()
|
||||||
RemoveObserver();
|
RemoveObserver();
|
||||||
if (refreshDriver) {
|
if (refreshDriver) {
|
||||||
mRefreshDriver = refreshDriver;
|
mRefreshDriver = refreshDriver;
|
||||||
DebugOnly<bool> success =
|
mRefreshDriver->AddRefreshObserver(this, FlushType::Event);
|
||||||
mRefreshDriver->AddRefreshObserver(this, FlushType::Event);
|
|
||||||
MOZ_ASSERT(success);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -319,8 +319,8 @@ nsXMLContentSink::DidBuildModel(bool aTerminated)
|
||||||
|
|
||||||
// We're pretty-printing now. See whether we should wait up on
|
// We're pretty-printing now. See whether we should wait up on
|
||||||
// stylesheet loads
|
// stylesheet loads
|
||||||
if (mDocument->CSSLoader()->HasPendingLoads() &&
|
if (mDocument->CSSLoader()->HasPendingLoads()) {
|
||||||
NS_SUCCEEDED(mDocument->CSSLoader()->AddObserver(this))) {
|
mDocument->CSSLoader()->AddObserver(this);
|
||||||
// wait for those sheets to load
|
// wait for those sheets to load
|
||||||
startLayout = false;
|
startLayout = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5563,12 +5563,8 @@ void PresShell::SynthesizeMouseMove(bool aFromScroll)
|
||||||
RefPtr<nsSynthMouseMoveEvent> ev =
|
RefPtr<nsSynthMouseMoveEvent> ev =
|
||||||
new nsSynthMouseMoveEvent(this, aFromScroll);
|
new nsSynthMouseMoveEvent(this, aFromScroll);
|
||||||
|
|
||||||
if (!GetPresContext()->RefreshDriver()
|
GetPresContext()->RefreshDriver()
|
||||||
->AddRefreshObserver(ev, FlushType::Display)) {
|
->AddRefreshObserver(ev, FlushType::Display);
|
||||||
NS_WARNING("failed to dispatch nsSynthMouseMoveEvent");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mSynthMouseMoveEvent = std::move(ev);
|
mSynthMouseMoveEvent = std::move(ev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9416,8 +9412,11 @@ nsIPresShell::AddRefreshObserver(nsARefreshObserver* aObserver,
|
||||||
FlushType aFlushType)
|
FlushType aFlushType)
|
||||||
{
|
{
|
||||||
nsPresContext* presContext = GetPresContext();
|
nsPresContext* presContext = GetPresContext();
|
||||||
return presContext &&
|
if (MOZ_UNLIKELY(!presContext)) {
|
||||||
presContext->RefreshDriver()->AddRefreshObserver(aObserver, aFlushType);
|
return false;
|
||||||
|
}
|
||||||
|
presContext->RefreshDriver()->AddRefreshObserver(aObserver, aFlushType);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
|
@ -1204,14 +1204,13 @@ nsRefreshDriver::MostRecentRefresh() const
|
||||||
return mMostRecentRefresh;
|
return mMostRecentRefresh;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
void
|
||||||
nsRefreshDriver::AddRefreshObserver(nsARefreshObserver* aObserver,
|
nsRefreshDriver::AddRefreshObserver(nsARefreshObserver* aObserver,
|
||||||
FlushType aFlushType)
|
FlushType aFlushType)
|
||||||
{
|
{
|
||||||
ObserverArray& array = ArrayFor(aFlushType);
|
ObserverArray& array = ArrayFor(aFlushType);
|
||||||
bool success = array.AppendElement(aObserver) != nullptr;
|
array.AppendElement(aObserver);
|
||||||
EnsureTimerStarted();
|
EnsureTimerStarted();
|
||||||
return success;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -1222,21 +1221,20 @@ nsRefreshDriver::RemoveRefreshObserver(nsARefreshObserver* aObserver,
|
||||||
return array.RemoveElement(aObserver);
|
return array.RemoveElement(aObserver);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
void
|
||||||
nsRefreshDriver::AddTimerAdjustmentObserver(
|
nsRefreshDriver::AddTimerAdjustmentObserver(
|
||||||
nsATimerAdjustmentObserver *aObserver)
|
nsATimerAdjustmentObserver* aObserver)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(!mTimerAdjustmentObservers.Contains(aObserver));
|
MOZ_ASSERT(!mTimerAdjustmentObservers.Contains(aObserver));
|
||||||
|
mTimerAdjustmentObservers.AppendElement(aObserver);
|
||||||
return mTimerAdjustmentObservers.AppendElement(aObserver) != nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
void
|
||||||
nsRefreshDriver::RemoveTimerAdjustmentObserver(
|
nsRefreshDriver::RemoveTimerAdjustmentObserver(
|
||||||
nsATimerAdjustmentObserver *aObserver)
|
nsATimerAdjustmentObserver* aObserver)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mTimerAdjustmentObservers.Contains(aObserver));
|
MOZ_ASSERT(mTimerAdjustmentObservers.Contains(aObserver));
|
||||||
return mTimerAdjustmentObservers.RemoveElement(aObserver);
|
mTimerAdjustmentObservers.RemoveElement(aObserver);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -120,8 +120,8 @@ public:
|
||||||
mozilla::TimeStamp MostRecentRefresh() const;
|
mozilla::TimeStamp MostRecentRefresh() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add / remove refresh observers. Returns whether the operation
|
* Add / remove refresh observers.
|
||||||
* succeeded.
|
* RemoveRefreshObserver returns true if aObserver was found.
|
||||||
*
|
*
|
||||||
* The flush type affects:
|
* The flush type affects:
|
||||||
* + the order in which the observers are notified (lowest flush
|
* + the order in which the observers are notified (lowest flush
|
||||||
|
@ -137,16 +137,16 @@ public:
|
||||||
*
|
*
|
||||||
* The observer will be called even if there is no other activity.
|
* The observer will be called even if there is no other activity.
|
||||||
*/
|
*/
|
||||||
bool AddRefreshObserver(nsARefreshObserver *aObserver,
|
void AddRefreshObserver(nsARefreshObserver* aObserver,
|
||||||
mozilla::FlushType aFlushType);
|
mozilla::FlushType aFlushType);
|
||||||
bool RemoveRefreshObserver(nsARefreshObserver *aObserver,
|
bool RemoveRefreshObserver(nsARefreshObserver* aObserver,
|
||||||
mozilla::FlushType aFlushType);
|
mozilla::FlushType aFlushType);
|
||||||
/**
|
/**
|
||||||
* Add / remove an observer wants to know the time when the refresh driver
|
* Add / remove an observer wants to know the time when the refresh driver
|
||||||
* updated the most recent refresh time due to its active timer changes.
|
* updated the most recent refresh time due to its active timer changes.
|
||||||
*/
|
*/
|
||||||
bool AddTimerAdjustmentObserver(nsATimerAdjustmentObserver *aObserver);
|
void AddTimerAdjustmentObserver(nsATimerAdjustmentObserver* aObserver);
|
||||||
bool RemoveTimerAdjustmentObserver(nsATimerAdjustmentObserver *aObserver);
|
void RemoveTimerAdjustmentObserver(nsATimerAdjustmentObserver* aObserver);
|
||||||
|
|
||||||
void PostScrollEvent(mozilla::Runnable* aScrollEvent);
|
void PostScrollEvent(mozilla::Runnable* aScrollEvent);
|
||||||
void DispatchScrollEvents();
|
void DispatchScrollEvents();
|
||||||
|
|
|
@ -1841,17 +1841,12 @@ public:
|
||||||
/*
|
/*
|
||||||
* Set a refresh observer for smooth scroll iterations (and start observing).
|
* Set a refresh observer for smooth scroll iterations (and start observing).
|
||||||
* Should be used at most once during the lifetime of this object.
|
* Should be used at most once during the lifetime of this object.
|
||||||
* Return value: true on success, false otherwise.
|
|
||||||
*/
|
*/
|
||||||
bool SetRefreshObserver(ScrollFrameHelper *aCallee) {
|
void SetRefreshObserver(ScrollFrameHelper* aCallee) {
|
||||||
NS_ASSERTION(aCallee && !mCallee, "AsyncSmoothMSDScroll::SetRefreshObserver - Invalid usage.");
|
NS_ASSERTION(aCallee && !mCallee, "AsyncSmoothMSDScroll::SetRefreshObserver - Invalid usage.");
|
||||||
|
|
||||||
if (!RefreshDriver(aCallee)->AddRefreshObserver(this, FlushType::Style)) {
|
RefreshDriver(aCallee)->AddRefreshObserver(this, FlushType::Style);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
mCallee = aCallee;
|
mCallee = aCallee;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1954,20 +1949,15 @@ public:
|
||||||
/*
|
/*
|
||||||
* Set a refresh observer for smooth scroll iterations (and start observing).
|
* Set a refresh observer for smooth scroll iterations (and start observing).
|
||||||
* Should be used at most once during the lifetime of this object.
|
* Should be used at most once during the lifetime of this object.
|
||||||
* Return value: true on success, false otherwise.
|
|
||||||
*/
|
*/
|
||||||
bool SetRefreshObserver(ScrollFrameHelper *aCallee) {
|
void SetRefreshObserver(ScrollFrameHelper* aCallee) {
|
||||||
NS_ASSERTION(aCallee && !mCallee, "AsyncScroll::SetRefreshObserver - Invalid usage.");
|
NS_ASSERTION(aCallee && !mCallee, "AsyncScroll::SetRefreshObserver - Invalid usage.");
|
||||||
|
|
||||||
if (!RefreshDriver(aCallee)->AddRefreshObserver(this, FlushType::Style)) {
|
RefreshDriver(aCallee)->AddRefreshObserver(this, FlushType::Style);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
mCallee = aCallee;
|
mCallee = aCallee;
|
||||||
nsIPresShell* shell = mCallee->mOuter->PresShell();
|
nsIPresShell* shell = mCallee->mOuter->PresShell();
|
||||||
MOZ_ASSERT(shell);
|
MOZ_ASSERT(shell);
|
||||||
shell->SuppressDisplayport(true);
|
shell->SuppressDisplayport(true);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void WillRefresh(mozilla::TimeStamp aTime) override {
|
virtual void WillRefresh(mozilla::TimeStamp aTime) override {
|
||||||
|
@ -2470,11 +2460,7 @@ ScrollFrameHelper::ScrollToWithOrigin(nsPoint aScrollPosition,
|
||||||
currentVelocity, GetScrollRangeForClamping(),
|
currentVelocity, GetScrollRangeForClamping(),
|
||||||
now, presContext);
|
now, presContext);
|
||||||
|
|
||||||
if (!mAsyncSmoothMSDScroll->SetRefreshObserver(this)) {
|
mAsyncSmoothMSDScroll->SetRefreshObserver(this);
|
||||||
// Observer setup failed. Scroll the normal way.
|
|
||||||
CompleteAsyncScroll(range, aOrigin);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// A previous smooth MSD scroll is still in progress, so we just need to
|
// A previous smooth MSD scroll is still in progress, so we just need to
|
||||||
// update its range and destination.
|
// update its range and destination.
|
||||||
|
@ -2493,11 +2479,7 @@ ScrollFrameHelper::ScrollToWithOrigin(nsPoint aScrollPosition,
|
||||||
|
|
||||||
if (!mAsyncScroll) {
|
if (!mAsyncScroll) {
|
||||||
mAsyncScroll = new AsyncScroll();
|
mAsyncScroll = new AsyncScroll();
|
||||||
if (!mAsyncScroll->SetRefreshObserver(this)) {
|
mAsyncScroll->SetRefreshObserver(this);
|
||||||
// Observer setup failed. Scroll the normal way.
|
|
||||||
CompleteAsyncScroll(range, aOrigin);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isSmoothScroll) {
|
if (isSmoothScroll) {
|
||||||
|
|
|
@ -2570,15 +2570,11 @@ Loader::HasPendingLoads()
|
||||||
mDatasToNotifyOn != 0;
|
mDatasToNotifyOn != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
Loader::AddObserver(nsICSSLoaderObserver* aObserver)
|
Loader::AddObserver(nsICSSLoaderObserver* aObserver)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(aObserver, "Must have observer");
|
MOZ_ASSERT(aObserver, "Must have observer");
|
||||||
if (mObservers.AppendElementUnlessExists(aObserver)) {
|
mObservers.AppendElementUnlessExists(aObserver);
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -429,7 +429,7 @@ public:
|
||||||
*
|
*
|
||||||
* aObserver must not be null.
|
* aObserver must not be null.
|
||||||
*/
|
*/
|
||||||
nsresult AddObserver(nsICSSLoaderObserver* aObserver);
|
void AddObserver(nsICSSLoaderObserver* aObserver);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove an observer added via AddObserver.
|
* Remove an observer added via AddObserver.
|
||||||
|
|
|
@ -2316,11 +2316,7 @@ History::RegisterVisitedCallback(nsIURI* aURI,
|
||||||
"Already tracking this Link object!");
|
"Already tracking this Link object!");
|
||||||
|
|
||||||
// Start tracking our Link.
|
// Start tracking our Link.
|
||||||
if (!observers.AppendElement(aLink)) {
|
observers.AppendElement(aLink);
|
||||||
// Curses - unregister and return failure.
|
|
||||||
(void)UnregisterVisitedCallback(aURI, aLink);
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If this link has already been visited, we cannot synchronously mark
|
// If this link has already been visited, we cannot synchronously mark
|
||||||
// ourselves as visited, so instead we fire a runnable into our docgroup,
|
// ourselves as visited, so instead we fire a runnable into our docgroup,
|
||||||
|
|
|
@ -643,11 +643,8 @@ nsresult nsDocLoader::RemoveChildLoader(nsDocLoader* aChild)
|
||||||
|
|
||||||
nsresult nsDocLoader::AddChildLoader(nsDocLoader* aChild)
|
nsresult nsDocLoader::AddChildLoader(nsDocLoader* aChild)
|
||||||
{
|
{
|
||||||
nsresult rv = mChildList.AppendElement(aChild) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
mChildList.AppendElement(aChild);
|
||||||
if (NS_SUCCEEDED(rv)) {
|
return aChild->SetDocLoaderParent(this);
|
||||||
rv = aChild->SetDocLoaderParent(this);
|
|
||||||
}
|
|
||||||
return rv;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsDocLoader::GetDocumentChannel(nsIChannel ** aChannel)
|
NS_IMETHODIMP nsDocLoader::GetDocumentChannel(nsIChannel ** aChannel)
|
||||||
|
@ -883,8 +880,8 @@ nsDocLoader::AddProgressListener(nsIWebProgressListener *aListener,
|
||||||
return NS_ERROR_INVALID_ARG;
|
return NS_ERROR_INVALID_ARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
return mListenerInfoList.AppendElement(nsListenerInfo(listener, aNotifyMask)) ?
|
mListenerInfoList.AppendElement(nsListenerInfo(listener, aNotifyMask));
|
||||||
NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
|
|
@ -175,13 +175,11 @@ public:
|
||||||
// Insert a given element at the given index.
|
// Insert a given element at the given index.
|
||||||
// @param aIndex The index at which to insert item.
|
// @param aIndex The index at which to insert item.
|
||||||
// @param aItem The item to insert,
|
// @param aItem The item to insert,
|
||||||
// @return A pointer to the newly inserted element, or a null on DOM
|
|
||||||
template<class Item>
|
template<class Item>
|
||||||
elem_type* InsertElementAt(index_type aIndex, const Item& aItem)
|
void InsertElementAt(index_type aIndex, const Item& aItem)
|
||||||
{
|
{
|
||||||
elem_type* item = mArray.InsertElementAt(aIndex, aItem);
|
mArray.InsertElementAt(aIndex, aItem);
|
||||||
AdjustIterators(aIndex, 1);
|
AdjustIterators(aIndex, 1);
|
||||||
return item;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Same as above but without copy constructing.
|
// Same as above but without copy constructing.
|
||||||
|
@ -196,26 +194,21 @@ public:
|
||||||
// Prepend an element to the array unless it already exists in the array.
|
// Prepend an element to the array unless it already exists in the array.
|
||||||
// 'operator==' must be defined for elem_type.
|
// 'operator==' must be defined for elem_type.
|
||||||
// @param aItem The item to prepend.
|
// @param aItem The item to prepend.
|
||||||
// @return true if the element was found, or inserted successfully.
|
|
||||||
template<class Item>
|
template<class Item>
|
||||||
bool PrependElementUnlessExists(const Item& aItem)
|
void PrependElementUnlessExists(const Item& aItem)
|
||||||
{
|
{
|
||||||
if (Contains(aItem)) {
|
if (!Contains(aItem)) {
|
||||||
return true;
|
mArray.InsertElementAt(0, aItem);
|
||||||
|
AdjustIterators(0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool inserted = mArray.InsertElementAt(0, aItem) != nullptr;
|
|
||||||
AdjustIterators(0, 1);
|
|
||||||
return inserted;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Append an element to the array.
|
// Append an element to the array.
|
||||||
// @param aItem The item to append.
|
// @param aItem The item to append.
|
||||||
// @return A pointer to the newly appended element, or null on OOM.
|
|
||||||
template<class Item>
|
template<class Item>
|
||||||
elem_type* AppendElement(const Item& aItem)
|
void AppendElement(const Item& aItem)
|
||||||
{
|
{
|
||||||
return mArray.AppendElement(aItem);
|
mArray.AppendElement(aItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Same as above, but without copy-constructing. This is useful to avoid
|
// Same as above, but without copy-constructing. This is useful to avoid
|
||||||
|
@ -228,11 +221,12 @@ public:
|
||||||
// Append an element to the array unless it already exists in the array.
|
// Append an element to the array unless it already exists in the array.
|
||||||
// 'operator==' must be defined for elem_type.
|
// 'operator==' must be defined for elem_type.
|
||||||
// @param aItem The item to append.
|
// @param aItem The item to append.
|
||||||
// @return true if the element was found, or inserted successfully.
|
|
||||||
template<class Item>
|
template<class Item>
|
||||||
bool AppendElementUnlessExists(const Item& aItem)
|
void AppendElementUnlessExists(const Item& aItem)
|
||||||
{
|
{
|
||||||
return Contains(aItem) || AppendElement(aItem) != nullptr;
|
if (!Contains(aItem)) {
|
||||||
|
mArray.AppendElement(aItem);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove an element from the array.
|
// Remove an element from the array.
|
||||||
|
|
Загрузка…
Ссылка в новой задаче