Bug 1613349 - Rename nsIFrame::RemoveProperty to nsIFrame::TakeProperty. r=dholbert

This is hopefully clearer naming.

Differential Revision: https://phabricator.services.mozilla.com/D61755

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Emilio Cobos Álvarez 2020-02-06 00:13:38 +00:00
Родитель f3a6914b76
Коммит bba367ec8f
15 изменённых файлов: 32 добавлений и 33 удалений

Просмотреть файл

@ -176,7 +176,7 @@ class FrameProperties {
*
* In most cases, this shouldn't be used outside of assertions, because if
* you're doing a lookup anyway it would be far more efficient to call Get()
* or Remove() and check the aFoundResult outparam to find out whether the
* or Take() and check the aFoundResult outparam to find out whether the
* property is set. Legitimate non-assertion uses include:
*
* - Checking if a frame property is set in cases where that's all we want
@ -214,20 +214,19 @@ class FrameProperties {
}
/**
* Remove a property value. This requires a linear search through
* the properties of the frame. The old property value is returned
* (and not destroyed). If the frame has no such property,
* returns zero-filled result, which means null for pointers and
* zero for integers and floating point types.
* Remove a property value, and return it without destroying it.
*
* This requires a linear search through the properties of the frame.
* If the frame has no such property, returns zero-filled result, which means
* null for pointers and zero for integers and floating point types.
* @param aFoundResult if non-null, receives a value 'true' iff
* the frame had a value for the property. This lets callers
* disambiguate a null result, which can mean 'no such property' or
* 'property value is null'.
*/
template <typename T>
PropertyType<T> Remove(Descriptor<T> aProperty,
bool* aFoundResult = nullptr) {
void* ptr = RemoveInternal(aProperty, aFoundResult);
PropertyType<T> Take(Descriptor<T> aProperty, bool* aFoundResult = nullptr) {
void* ptr = TakeInternal(aProperty, aFoundResult);
return ReinterpretHelper<T>::FromPointer(ptr);
}
@ -294,7 +293,7 @@ class FrameProperties {
inline void* GetInternal(UntypedDescriptor aProperty,
bool* aFoundResult) const;
inline void* RemoveInternal(UntypedDescriptor aProperty, bool* aFoundResult);
inline void* TakeInternal(UntypedDescriptor aProperty, bool* aFoundResult);
inline void DeleteInternal(UntypedDescriptor aProperty,
const nsIFrame* aFrame);
@ -406,8 +405,8 @@ inline void FrameProperties::AddInternal(UntypedDescriptor aProperty,
mProperties.AppendElement(PropertyValue(aProperty, aValue));
}
inline void* FrameProperties::RemoveInternal(UntypedDescriptor aProperty,
bool* aFoundResult) {
inline void* FrameProperties::TakeInternal(UntypedDescriptor aProperty,
bool* aFoundResult) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aProperty, "Null property?");

Просмотреть файл

@ -10359,7 +10359,7 @@ void nsCSSFrameConstructor::RemoveLetterFrames(PresShell* aPresShell,
nsContainerFrame* aBlockFrame) {
aBlockFrame =
static_cast<nsContainerFrame*>(aBlockFrame->FirstContinuation());
aBlockFrame->RemoveProperty(nsContainerFrame::FirstLetterProperty());
aBlockFrame->TakeProperty(nsContainerFrame::FirstLetterProperty());
nsContainerFrame* continuation = aBlockFrame;
bool stopLooking = false;

Просмотреть файл

@ -1247,7 +1247,7 @@ void nsTextControlFrame::SetInitialChildList(ChildListID aListID,
UniquePtr<PresState> fakePresState = NewPresState();
fakePresState->scrollState() = *contentScrollPos;
statefulFrame->RestoreState(fakePresState.get());
RemoveProperty(ContentScrollPos());
TakeProperty(ContentScrollPos());
delete contentScrollPos;
}
} else {

Просмотреть файл

@ -24,7 +24,7 @@ void RubyUtils::SetReservedISize(nsIFrame* aFrame, nscoord aISize) {
/* static */
void RubyUtils::ClearReservedISize(nsIFrame* aFrame) {
MOZ_ASSERT(IsExpandableRubyBox(aFrame));
aFrame->RemoveProperty(ReservedISize());
aFrame->TakeProperty(ReservedISize());
}
/* static */

Просмотреть файл

@ -5349,7 +5349,7 @@ nsBlockFrame::FrameLines* nsBlockFrame::RemoveOverflowLines() {
if (!HasOverflowLines()) {
return nullptr;
}
FrameLines* prop = RemoveProperty(OverflowLinesProperty());
FrameLines* prop = TakeProperty(OverflowLinesProperty());
NS_ASSERTION(
prop && !prop->mLines.empty() &&
prop->mLines.front()->GetChildCount() == 0
@ -5362,7 +5362,7 @@ nsBlockFrame::FrameLines* nsBlockFrame::RemoveOverflowLines() {
void nsBlockFrame::DestroyOverflowLines() {
NS_ASSERTION(HasOverflowLines(), "huh?");
FrameLines* prop = RemoveProperty(OverflowLinesProperty());
FrameLines* prop = TakeProperty(OverflowLinesProperty());
NS_ASSERTION(prop && prop->mLines.empty(),
"value should always be stored but empty when destroying");
RemoveStateBits(NS_BLOCK_HAS_OVERFLOW_LINES);
@ -5471,7 +5471,7 @@ nsFrameList* nsBlockFrame::RemovePushedFloats() {
if (!HasPushedFloats()) {
return nullptr;
}
nsFrameList* result = RemoveProperty(PushedFloatProperty());
nsFrameList* result = TakeProperty(PushedFloatProperty());
RemoveStateBits(NS_BLOCK_HAS_PUSHED_FLOATS);
NS_ASSERTION(result, "value should always be non-empty when state set");
return result;

Просмотреть файл

@ -195,7 +195,7 @@ void nsContainerFrame::SafelyDestroyFrameListProp(
if (MOZ_LIKELY(frame)) {
frame->DestroyFrom(aDestructRoot, aPostDestroyData);
} else {
RemoveProperty(aProp);
TakeProperty(aProp);
frameList->Delete(aPresShell);
return;
}
@ -1244,7 +1244,7 @@ static bool TryRemoveFrame(nsIFrame* aFrame,
if (list && list->StartRemoveFrame(aChildToRemove)) {
// aChildToRemove *may* have been removed from this list.
if (list->IsEmpty()) {
aFrame->RemoveProperty(aProp);
aFrame->TakeProperty(aProp);
list->Delete(aFrame->PresShell());
}
return true;
@ -1432,7 +1432,7 @@ nsFrameList* nsContainerFrame::GetPropTableFrames(
nsFrameList* nsContainerFrame::RemovePropTableFrames(
FrameListPropertyDescriptor aProperty) {
return RemoveProperty(aProperty);
return TakeProperty(aProperty);
}
void nsContainerFrame::SetPropTableFrames(

Просмотреть файл

@ -839,7 +839,7 @@ inline nsFrameList* nsContainerFrame::GetOverflowFrames() const {
}
inline nsFrameList* nsContainerFrame::StealOverflowFrames() {
nsFrameList* list = RemoveProperty(OverflowProperty());
nsFrameList* list = TakeProperty(OverflowProperty());
NS_ASSERTION(!list || !list->IsEmpty(), "Unexpected empty overflow list");
return list;
}

Просмотреть файл

@ -4270,7 +4270,7 @@ class MOZ_RAII AutoFlexItemMainSizeOverride final {
}
~AutoFlexItemMainSizeOverride() {
mItemFrame->RemoveProperty(nsIFrame::FlexItemMainSizeOverride());
mItemFrame->TakeProperty(nsIFrame::FlexItemMainSizeOverride());
}
private:

Просмотреть файл

@ -1037,7 +1037,7 @@ void nsIFrame::RemoveDisplayItemDataForDeletion() {
// property table in an inconsistent state. So we remove it from the table and
// then destroy it. (bug 1530657)
WebRenderUserDataTable* userDataTable =
RemoveProperty(WebRenderUserDataProperty::Key());
TakeProperty(WebRenderUserDataProperty::Key());
if (userDataTable) {
for (auto iter = userDataTable->Iter(); !iter.Done(); iter.Next()) {
iter.UserData()->RemoveFromTable();
@ -1048,7 +1048,7 @@ void nsIFrame::RemoveDisplayItemDataForDeletion() {
FrameLayerBuilder::RemoveFrameFromLayerManager(this, DisplayItemData());
DisplayItemData().Clear();
DisplayItemArray* items = RemoveProperty(DisplayItems());
DisplayItemArray* items = TakeProperty(DisplayItems());
if (items) {
for (nsDisplayItemBase* i : *items) {
if (i->GetDependentFrame() == this && !i->HasDeletedFrame()) {
@ -2185,7 +2185,7 @@ void nsIFrame::DisableVisibilityTracking() {
}
bool isSet = false;
uint32_t visibleCount = RemoveProperty(VisibilityStateProperty(), &isSet);
uint32_t visibleCount = TakeProperty(VisibilityStateProperty(), &isSet);
MOZ_ASSERT(isSet,
"Should have a VisibilityStateProperty value "

Просмотреть файл

@ -3674,9 +3674,9 @@ class nsIFrame : public nsQueryFrame {
}
template <typename T>
FrameProperties::PropertyType<T> RemoveProperty(
FrameProperties::PropertyType<T> TakeProperty(
FrameProperties::Descriptor<T> aProperty, bool* aFoundResult = nullptr) {
return mProperties.Remove(aProperty, aFoundResult);
return mProperties.Take(aProperty, aFoundResult);
}
template <typename T>

Просмотреть файл

@ -758,7 +758,7 @@ void nsLineLayout::ReflowFrame(nsIFrame* aFrame, nsReflowStatus& aReflowStatus,
#endif
if (mCurrentSpan == mRootSpan) {
pfd->mFrame->RemoveProperty(nsIFrame::LineBaselineOffset());
pfd->mFrame->TakeProperty(nsIFrame::LineBaselineOffset());
} else {
#ifdef DEBUG
bool hasLineOffset;

Просмотреть файл

@ -9383,7 +9383,7 @@ void nsTextFrame::ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth,
gfxFloat em = fm->EmHeight();
// Compress the characters in horizontal axis if necessary.
if (width <= em) {
RemoveProperty(TextCombineScaleFactorProperty());
TakeProperty(TextCombineScaleFactorProperty());
} else {
SetProperty(TextCombineScaleFactorProperty(), em / width);
finalSize.ISize(wm) = em;

Просмотреть файл

@ -239,7 +239,7 @@ void ActiveLayerTracker::TransferActivityToContent(nsIFrame* aFrame,
return;
}
LayerActivity* layerActivity =
aFrame->RemoveProperty(LayerActivityProperty());
aFrame->TakeProperty(LayerActivityProperty());
aFrame->RemoveStateBits(NS_FRAME_HAS_LAYER_ACTIVITY_PROPERTY);
if (!layerActivity) {
return;

Просмотреть файл

@ -546,7 +546,7 @@ void FrameLayerBuilder::DestroyDisplayItemDataFor(nsIFrame* aFrame) {
// property table in an inconsistent state. So we remove it from the table and
// then destroy it. (bug 1530657)
WebRenderUserDataTable* userDataTable =
aFrame->RemoveProperty(WebRenderUserDataProperty::Key());
aFrame->TakeProperty(WebRenderUserDataProperty::Key());
if (userDataTable) {
for (auto iter = userDataTable->Iter(); !iter.Done(); iter.Next()) {
iter.UserData()->RemoveFromTable();

Просмотреть файл

@ -239,7 +239,7 @@ nsFrameList* nsMenuFrame::GetPopupList() const {
void nsMenuFrame::DestroyPopupList() {
NS_ASSERTION(HasPopup(), "huh?");
nsFrameList* prop = RemoveProperty(PopupListProperty());
nsFrameList* prop = TakeProperty(PopupListProperty());
NS_ASSERTION(prop && prop->IsEmpty(),
"popup list must exist and be empty when destroying");
RemoveStateBits(NS_STATE_MENU_HAS_POPUP_LIST);