Bug 1731359 part 1: Change the "NormalPositionProperty" frame property to use the "small value" method of storage. r=emilio

This frame property's type is small enough to fit directly in the property
table's 64-byte slot; so, this patch makes us store the data directly there
(rather than allocating it externally and storing a pointer in the table).

This patch shouldn't impact behavior at all.

Differential Revision: https://phabricator.services.mozilla.com/D126031
This commit is contained in:
Daniel Holbert 2021-09-20 22:26:14 +00:00
parent 21221bbbe0
commit b7cb22a3af
5 changed files with 12 additions and 24 deletions

View File

@ -774,8 +774,7 @@ static bool RecomputePosition(nsIFrame* aFrame) {
bool hasProperty;
nsPoint normalPosition = cont->GetNormalPosition(&hasProperty);
if (!hasProperty) {
cont->AddProperty(nsIFrame::NormalPositionProperty(),
new nsPoint(normalPosition));
cont->AddProperty(nsIFrame::NormalPositionProperty(), normalPosition);
}
cont->SetPosition(normalPosition +
nsPoint(newOffsets.left, newOffsets.top));

View File

@ -875,7 +875,7 @@ void ReflowInput::ApplyRelativePositioning(nsIFrame* aFrame,
const nsMargin& aComputedOffsets,
nsPoint* aPosition) {
if (!aFrame->IsRelativelyPositioned()) {
NS_ASSERTION(!aFrame->GetProperty(nsIFrame::NormalPositionProperty()),
NS_ASSERTION(!aFrame->HasProperty(nsIFrame::NormalPositionProperty()),
"We assume that changing the 'position' property causes "
"frame reconstruction. If that ever changes, this code "
"should call "
@ -884,14 +884,7 @@ void ReflowInput::ApplyRelativePositioning(nsIFrame* aFrame,
}
// Store the normal position
nsPoint* normalPosition =
aFrame->GetProperty(nsIFrame::NormalPositionProperty());
if (normalPosition) {
*normalPosition = *aPosition;
} else {
aFrame->AddProperty(nsIFrame::NormalPositionProperty(),
new nsPoint(*aPosition));
}
aFrame->SetProperty(nsIFrame::NormalPositionProperty(), *aPosition);
const nsStyleDisplay* display = aFrame->StyleDisplay();
if (StylePositionProperty::Relative == display->mPosition) {

View File

@ -7494,9 +7494,10 @@ void nsIFrame::MovePositionBy(const nsPoint& aTranslation) {
nsRect nsIFrame::GetNormalRect() const {
// It might be faster to first check
// StyleDisplay()->IsRelativelyPositionedStyle().
nsPoint* normalPosition = GetProperty(NormalPositionProperty());
if (normalPosition) {
return nsRect(*normalPosition, GetSize());
bool hasProperty;
nsPoint normalPosition = GetProperty(NormalPositionProperty(), &hasProperty);
if (hasProperty) {
return nsRect(normalPosition, GetSize());
}
return GetRect();
}

View File

@ -1334,7 +1334,7 @@ class nsIFrame : public nsQueryFrame {
NS_DECLARE_FRAME_PROPERTY_WITHOUT_DTOR(IBSplitSibling, nsContainerFrame)
NS_DECLARE_FRAME_PROPERTY_WITHOUT_DTOR(IBSplitPrevSibling, nsContainerFrame)
NS_DECLARE_FRAME_PROPERTY_DELETABLE(NormalPositionProperty, nsPoint)
NS_DECLARE_FRAME_PROPERTY_SMALL_VALUE(NormalPositionProperty, nsPoint)
NS_DECLARE_FRAME_PROPERTY_DELETABLE(ComputedOffsetProperty, nsMargin)
NS_DECLARE_FRAME_PROPERTY_DELETABLE(OutlineInnerRectProperty, nsRect)

View File

@ -257,17 +257,12 @@ nsIFrame* nsIFrame::GetClosestFlattenedTreeAncestorPrimaryFrame() const {
}
nsPoint nsIFrame::GetNormalPosition(bool* aHasProperty) const {
nsPoint* normalPosition = GetProperty(NormalPositionProperty());
if (normalPosition) {
if (aHasProperty) {
*aHasProperty = true;
}
return *normalPosition;
}
bool hasProperty;
nsPoint normalPosition = GetProperty(NormalPositionProperty(), &hasProperty);
if (aHasProperty) {
*aHasProperty = false;
*aHasProperty = hasProperty;
}
return GetPosition();
return hasProperty ? normalPosition : GetPosition();
}
mozilla::LogicalPoint nsIFrame::GetLogicalNormalPosition(