From 00812e30dfa70f9b1a752cf0d09de00f6d401c85 Mon Sep 17 00:00:00 2001 From: win7-7 Date: Wed, 26 Jun 2019 01:51:45 +0300 Subject: Attach FrameProperties to each frame instead of using a shared hashtable Dispense the shared hashtable and instead attach the frame property list directly to nsIFrame. --- layout/generic/ReflowInput.cpp | 36 +++---- layout/generic/RubyUtils.cpp | 6 +- layout/generic/StickyScrollContainer.cpp | 26 +++-- layout/generic/nsBlockFrame.cpp | 58 +++++----- layout/generic/nsBlockFrame.h | 4 +- layout/generic/nsBulletFrame.cpp | 6 +- layout/generic/nsCanvasFrame.cpp | 4 +- layout/generic/nsCanvasFrame.h | 2 +- layout/generic/nsContainerFrame.cpp | 70 ++++++------ layout/generic/nsContainerFrame.h | 10 +- layout/generic/nsFlexContainerFrame.cpp | 22 ++-- layout/generic/nsFloatManager.cpp | 9 +- layout/generic/nsFontInflationData.cpp | 12 +-- layout/generic/nsFrame.cpp | 177 ++++++++++++++++--------------- layout/generic/nsGridContainerFrame.cpp | 80 +++++++------- layout/generic/nsGridContainerFrame.h | 12 +-- layout/generic/nsIFrame.h | 75 ++++++++++--- layout/generic/nsLineLayout.cpp | 4 +- layout/generic/nsPlaceholderFrame.cpp | 2 +- layout/generic/nsTextFrame.cpp | 59 +++++------ 20 files changed, 353 insertions(+), 321 deletions(-) (limited to 'layout/generic') diff --git a/layout/generic/ReflowInput.cpp b/layout/generic/ReflowInput.cpp index bbff77ad4..78eca8c6c 100644 --- a/layout/generic/ReflowInput.cpp +++ b/layout/generic/ReflowInput.cpp @@ -999,13 +999,13 @@ ReflowInput::ComputeRelativeOffsets(WritingMode aWM, // Convert the offsets to physical coordinates and store them on the frame aComputedOffsets = offsets.GetPhysicalMargin(aWM); - FrameProperties props = aFrame->Properties(); - nsMargin* physicalOffsets = props.Get(nsIFrame::ComputedOffsetProperty()); + nsMargin* physicalOffsets = + aFrame->GetProperty(nsIFrame::ComputedOffsetProperty()); if (physicalOffsets) { *physicalOffsets = aComputedOffsets; } else { - props.Set(nsIFrame::ComputedOffsetProperty(), - new nsMargin(aComputedOffsets)); + aFrame->SetProperty(nsIFrame::ComputedOffsetProperty(), + new nsMargin(aComputedOffsets)); } } @@ -1015,21 +1015,22 @@ ReflowInput::ApplyRelativePositioning(nsIFrame* aFrame, nsPoint* aPosition) { if (!aFrame->IsRelativelyPositioned()) { - NS_ASSERTION(!aFrame->Properties().Get(nsIFrame::NormalPositionProperty()), + NS_ASSERTION(!aFrame->GetProperty(nsIFrame::NormalPositionProperty()), "We assume that changing the 'position' property causes " "frame reconstruction. If that ever changes, this code " "should call " - "props.Delete(nsIFrame::NormalPositionProperty())"); + "aFrame->DeleteProperty(nsIFrame::NormalPositionProperty())"); return; } // Store the normal position - FrameProperties props = aFrame->Properties(); - nsPoint* normalPosition = props.Get(nsIFrame::NormalPositionProperty()); + nsPoint* normalPosition = + aFrame->GetProperty(nsIFrame::NormalPositionProperty()); if (normalPosition) { *normalPosition = *aPosition; } else { - props.Set(nsIFrame::NormalPositionProperty(), new nsPoint(*aPosition)); + aFrame->SetProperty(nsIFrame::NormalPositionProperty(), + new nsPoint(*aPosition)); } const nsStyleDisplay* display = aFrame->StyleDisplay(); @@ -2452,20 +2453,20 @@ ReflowInput::InitConstraints(nsPresContext* aPresContext, } static void -UpdateProp(FrameProperties& aProps, +UpdateProp(nsIFrame* aFrame, const FramePropertyDescriptor* aProperty, bool aNeeded, nsMargin& aNewValue) { if (aNeeded) { - nsMargin* propValue = aProps.Get(aProperty); + nsMargin* propValue = aFrame->GetProperty(aProperty); if (propValue) { *propValue = aNewValue; } else { - aProps.Set(aProperty, new nsMargin(aNewValue)); + aFrame->SetProperty(aProperty, new nsMargin(aNewValue)); } } else { - aProps.Delete(aProperty); + aFrame->DeleteProperty(aProperty); } } @@ -2482,8 +2483,7 @@ SizeComputationInput::InitOffsets(WritingMode aWM, // Since we are in reflow, we don't need to store these properties anymore // unless they are dependent on width, in which case we store the new value. nsPresContext *presContext = mFrame->PresContext(); - FrameProperties props(presContext->PropertyTable(), mFrame); - props.Delete(nsIFrame::UsedBorderProperty()); + mFrame->DeleteProperty(nsIFrame::UsedBorderProperty()); // Compute margins from the specified margin style information. These // become the default computed values, and may be adjusted below @@ -2494,7 +2494,7 @@ SizeComputationInput::InitOffsets(WritingMode aWM, // ... but if we did that, we'd need to fix nsFrame::GetUsedMargin // to use it even when the margins are all zero (since sometimes // they get treated as auto) - ::UpdateProp(props, nsIFrame::UsedMarginProperty(), needMarginProp, + ::UpdateProp(mFrame, nsIFrame::UsedMarginProperty(), needMarginProp, ComputedPhysicalMargin()); @@ -2530,7 +2530,7 @@ SizeComputationInput::InitOffsets(WritingMode aWM, auto ApplyBaselinePadding = [this, &needPaddingProp] (LogicalAxis aAxis, Prop aProp) { bool found; - nscoord val = mFrame->Properties().Get(aProp, &found); + nscoord val = mFrame->GetProperty(aProp, &found); if (found) { NS_ASSERTION(val != nscoord(0), "zero in this property is useless"); WritingMode wm = GetWritingMode(); @@ -2603,7 +2603,7 @@ SizeComputationInput::InitOffsets(WritingMode aWM, ComputedPhysicalBorderPadding().SizeTo(0,0,0,0); } } - ::UpdateProp(props, nsIFrame::UsedPaddingProperty(), needPaddingProp, + ::UpdateProp(mFrame, nsIFrame::UsedPaddingProperty(), needPaddingProp, ComputedPhysicalPadding()); } diff --git a/layout/generic/RubyUtils.cpp b/layout/generic/RubyUtils.cpp index f340663bc..05dd25413 100644 --- a/layout/generic/RubyUtils.cpp +++ b/layout/generic/RubyUtils.cpp @@ -19,21 +19,21 @@ NS_DECLARE_FRAME_PROPERTY_SMALL_VALUE(ReservedISize, nscoord) RubyUtils::SetReservedISize(nsIFrame* aFrame, nscoord aISize) { MOZ_ASSERT(IsExpandableRubyBox(aFrame)); - aFrame->Properties().Set(ReservedISize(), aISize); + aFrame->SetProperty(ReservedISize(), aISize); } /* static */ void RubyUtils::ClearReservedISize(nsIFrame* aFrame) { MOZ_ASSERT(IsExpandableRubyBox(aFrame)); - aFrame->Properties().Remove(ReservedISize()); + aFrame->RemoveProperty(ReservedISize()); } /* static */ nscoord RubyUtils::GetReservedISize(nsIFrame* aFrame) { MOZ_ASSERT(IsExpandableRubyBox(aFrame)); - return aFrame->Properties().Get(ReservedISize()); + return aFrame->GetProperty(ReservedISize()); } AutoRubyTextContainerArray::AutoRubyTextContainerArray( diff --git a/layout/generic/StickyScrollContainer.cpp b/layout/generic/StickyScrollContainer.cpp index d61a7e042..ca68992c3 100644 --- a/layout/generic/StickyScrollContainer.cpp +++ b/layout/generic/StickyScrollContainer.cpp @@ -45,12 +45,12 @@ StickyScrollContainer::GetStickyScrollContainerForFrame(nsIFrame* aFrame) // return nullptr; } - FrameProperties props = static_cast(do_QueryFrame(scrollFrame))-> - Properties(); - StickyScrollContainer* s = props.Get(StickyScrollContainerProperty()); + auto frame = static_cast(do_QueryFrame(scrollFrame)); + StickyScrollContainer* s = + frame->GetProperty(StickyScrollContainerProperty()); if (!s) { s = new StickyScrollContainer(scrollFrame); - props.Set(StickyScrollContainerProperty(), s); + frame->SetProperty(StickyScrollContainerProperty(), s); } return s; } @@ -69,9 +69,9 @@ StickyScrollContainer::NotifyReparentedFrameAcrossScrollFrameBoundary(nsIFrame* // we aren't going to handle that. return; } - FrameProperties props = static_cast(do_QueryFrame(oldScrollFrame))-> - Properties(); - StickyScrollContainer* oldSSC = props.Get(StickyScrollContainerProperty()); + StickyScrollContainer* oldSSC = + static_cast(do_QueryFrame(oldScrollFrame))-> + GetProperty(StickyScrollContainerProperty()); if (!oldSSC) { // aOldParent had no sticky descendants, so aFrame doesn't have any sticky // descendants, and we're done here. @@ -95,8 +95,7 @@ StickyScrollContainer::NotifyReparentedFrameAcrossScrollFrameBoundary(nsIFrame* StickyScrollContainer* StickyScrollContainer::GetStickyScrollContainerForScrollFrame(nsIFrame* aFrame) { - FrameProperties props = aFrame->Properties(); - return props.Get(StickyScrollContainerProperty()); + return aFrame->GetProperty(StickyScrollContainerProperty()); } static nscoord @@ -141,13 +140,12 @@ StickyScrollContainer::ComputeStickyOffsets(nsIFrame* aFrame) scrollContainerSize.height); // Store the offset - FrameProperties props = aFrame->Properties(); - nsMargin* offsets = props.Get(nsIFrame::ComputedOffsetProperty()); + nsMargin* offsets = aFrame->GetProperty(nsIFrame::ComputedOffsetProperty()); if (offsets) { *offsets = computedOffsets; } else { - props.Set(nsIFrame::ComputedOffsetProperty(), - new nsMargin(computedOffsets)); + aFrame->SetProperty(nsIFrame::ComputedOffsetProperty(), + new nsMargin(computedOffsets)); } } @@ -162,7 +160,7 @@ StickyScrollContainer::ComputeStickyLimits(nsIFrame* aFrame, nsRect* aStick, aContain->SetRect(nscoord_MIN/2, nscoord_MIN/2, nscoord_MAX, nscoord_MAX); const nsMargin* computedOffsets = - aFrame->Properties().Get(nsIFrame::ComputedOffsetProperty()); + aFrame->GetProperty(nsIFrame::ComputedOffsetProperty()); if (!computedOffsets) { // We haven't reflowed the scroll frame yet, so offsets haven't been // computed. Bail. diff --git a/layout/generic/nsBlockFrame.cpp b/layout/generic/nsBlockFrame.cpp index 851e3406c..a37bfc06b 100644 --- a/layout/generic/nsBlockFrame.cpp +++ b/layout/generic/nsBlockFrame.cpp @@ -326,10 +326,8 @@ nsBlockFrame::DestroyFrom(nsIFrame* aDestructRoot) nsLineBox::DeleteLineList(presContext, mLines, aDestructRoot, &mFrames); - FramePropertyTable* props = presContext->PropertyTable(); - if (HasPushedFloats()) { - SafelyDestroyFrameListProp(aDestructRoot, shell, props, + SafelyDestroyFrameListProp(aDestructRoot, shell, PushedFloatProperty()); RemoveStateBits(NS_BLOCK_HAS_PUSHED_FLOATS); } @@ -343,13 +341,13 @@ nsBlockFrame::DestroyFrom(nsIFrame* aDestructRoot) } if (GetStateBits() & NS_BLOCK_HAS_OVERFLOW_OUT_OF_FLOWS) { - SafelyDestroyFrameListProp(aDestructRoot, shell, props, + SafelyDestroyFrameListProp(aDestructRoot, shell, OverflowOutOfFlowsProperty()); RemoveStateBits(NS_BLOCK_HAS_OVERFLOW_OUT_OF_FLOWS); } if (HasOutsideBullet()) { - SafelyDestroyFrameListProp(aDestructRoot, shell, props, + SafelyDestroyFrameListProp(aDestructRoot, shell, OutsideBulletProperty()); RemoveStateBits(NS_BLOCK_FRAME_HAS_OUTSIDE_BULLET); } @@ -1669,7 +1667,7 @@ nsBlockFrame::ComputeFinalSize(const ReflowInput& aReflowInput, // our computed size due to overflowing their containing block. (E.g. this // ensures we fill the last row when a multi-row grid item is fragmented). bool found; - nscoord bSize = Properties().Get(FragStretchBSizeProperty(), &found); + nscoord bSize = GetProperty(FragStretchBSizeProperty(), &found); if (found) { finalSize.BSize(wm) = std::max(bSize, finalSize.BSize(wm)); } @@ -1679,7 +1677,7 @@ nsBlockFrame::ComputeFinalSize(const ReflowInput& aReflowInput, if (MOZ_UNLIKELY(aReflowInput.mFlags.mBClampMarginBoxMinSize) && NS_FRAME_IS_COMPLETE(aState.mReflowStatus)) { bool found; - nscoord cbSize = Properties().Get(BClampMarginBoxMinSizeProperty(), &found); + nscoord cbSize = GetProperty(BClampMarginBoxMinSizeProperty(), &found); if (found) { auto marginBoxBSize = finalSize.BSize(wm) + aReflowInput.ComputedLogicalMargin().BStartEnd(wm); @@ -1697,11 +1695,10 @@ nsBlockFrame::ComputeFinalSize(const ReflowInput& aReflowInput, finalSize.BSize(wm) = std::max(0, finalSize.BSize(wm)); *aBEndEdgeOfChildren = blockEndEdgeOfChildren; - FrameProperties properties = Properties(); if (blockEndEdgeOfChildren != finalSize.BSize(wm) - borderPadding.BEnd(wm)) { - properties.Set(BlockEndEdgeOfChildrenProperty(), blockEndEdgeOfChildren); + SetProperty(BlockEndEdgeOfChildrenProperty(), blockEndEdgeOfChildren); } else { - properties.Delete(BlockEndEdgeOfChildrenProperty()); + DeleteProperty(BlockEndEdgeOfChildrenProperty()); } aMetrics.SetSize(wm, finalSize); @@ -1834,7 +1831,7 @@ nsBlockFrame::ComputeCustomOverflow(nsOverflowAreas& aOverflowAreas) { bool found; nscoord blockEndEdgeOfChildren = - Properties().Get(BlockEndEdgeOfChildrenProperty(), &found); + GetProperty(BlockEndEdgeOfChildrenProperty(), &found); if (found) { ConsiderBlockEndEdgeOfChildren(GetWritingMode(), blockEndEdgeOfChildren, aOverflowAreas); @@ -4985,7 +4982,7 @@ nsBlockFrame::GetOverflowLines() const if (!HasOverflowLines()) { return nullptr; } - FrameLines* prop = Properties().Get(OverflowLinesProperty()); + FrameLines* prop = GetProperty(OverflowLinesProperty()); NS_ASSERTION(prop && !prop->mLines.empty() && prop->mLines.front()->GetChildCount() == 0 ? prop->mFrames.IsEmpty() : prop->mLines.front()->mFirstChild == prop->mFrames.FirstChild(), @@ -4999,7 +4996,7 @@ nsBlockFrame::RemoveOverflowLines() if (!HasOverflowLines()) { return nullptr; } - FrameLines* prop = Properties().Remove(OverflowLinesProperty()); + FrameLines* prop = RemoveProperty(OverflowLinesProperty()); NS_ASSERTION(prop && !prop->mLines.empty() && prop->mLines.front()->GetChildCount() == 0 ? prop->mFrames.IsEmpty() : prop->mLines.front()->mFirstChild == prop->mFrames.FirstChild(), @@ -5012,7 +5009,7 @@ void nsBlockFrame::DestroyOverflowLines() { NS_ASSERTION(HasOverflowLines(), "huh?"); - FrameLines* prop = Properties().Remove(OverflowLinesProperty()); + FrameLines* prop = RemoveProperty(OverflowLinesProperty()); NS_ASSERTION(prop && prop->mLines.empty(), "value should always be stored but empty when destroying"); RemoveStateBits(NS_BLOCK_HAS_OVERFLOW_LINES); @@ -5032,10 +5029,9 @@ nsBlockFrame::SetOverflowLines(FrameLines* aOverflowLines) NS_ASSERTION(!(GetStateBits() & NS_BLOCK_HAS_OVERFLOW_LINES), "Overwriting existing overflow lines"); - FrameProperties props = Properties(); // Verify that we won't overwrite an existing overflow list - NS_ASSERTION(!props.Get(OverflowLinesProperty()), "existing overflow list"); - props.Set(OverflowLinesProperty(), aOverflowLines); + NS_ASSERTION(!GetProperty(OverflowLinesProperty()), "existing overflow list"); + SetProperty(OverflowLinesProperty(), aOverflowLines); AddStateBits(NS_BLOCK_HAS_OVERFLOW_LINES); } @@ -5088,7 +5084,7 @@ nsBlockFrame::GetInsideBullet() const return nullptr; } NS_ASSERTION(!HasOutsideBullet(), "invalid bullet state"); - nsBulletFrame* frame = Properties().Get(InsideBulletProperty()); + nsBulletFrame* frame = GetProperty(InsideBulletProperty()); NS_ASSERTION(frame && frame->GetType() == nsGkAtoms::bulletFrame, "bogus inside bullet frame"); return frame; @@ -5109,8 +5105,7 @@ nsBlockFrame::GetOutsideBulletList() const return nullptr; } NS_ASSERTION(!HasInsideBullet(), "invalid bullet state"); - nsFrameList* list = - Properties().Get(OutsideBulletProperty()); + nsFrameList* list = GetProperty(OutsideBulletProperty()); NS_ASSERTION(list && list->GetLength() == 1 && list->FirstChild()->GetType() == nsGkAtoms::bulletFrame, "bogus outside bullet list"); @@ -5123,8 +5118,7 @@ nsBlockFrame::GetPushedFloats() const if (!HasPushedFloats()) { return nullptr; } - nsFrameList* result = - Properties().Get(PushedFloatProperty()); + nsFrameList* result = GetProperty(PushedFloatProperty()); NS_ASSERTION(result, "value should always be non-empty when state set"); return result; } @@ -5137,7 +5131,7 @@ nsBlockFrame::EnsurePushedFloats() return result; result = new (PresContext()->PresShell()) nsFrameList; - Properties().Set(PushedFloatProperty(), result); + SetProperty(PushedFloatProperty(), result); AddStateBits(NS_BLOCK_HAS_PUSHED_FLOATS); return result; @@ -5149,7 +5143,7 @@ nsBlockFrame::RemovePushedFloats() if (!HasPushedFloats()) { return nullptr; } - nsFrameList *result = Properties().Remove(PushedFloatProperty()); + nsFrameList *result = RemoveProperty(PushedFloatProperty()); RemoveStateBits(NS_BLOCK_HAS_PUSHED_FLOATS); NS_ASSERTION(result, "value should always be non-empty when state set"); return result; @@ -5619,7 +5613,7 @@ nsBlockInFlowLineIterator::nsBlockInFlowLineIterator(nsBlockFrame* aFrame, if (mLine != line_end) { *aFoundValidLine = true; if (mLine != cursor) { - aFrame->Properties().Set(nsBlockFrame::LineCursorProperty(), mLine); + aFrame->SetProperty(nsBlockFrame::LineCursorProperty(), mLine); } return; } @@ -6769,7 +6763,7 @@ void nsBlockFrame::ClearLineCursor() return; } - Properties().Delete(LineCursorProperty()); + DeleteProperty(LineCursorProperty()); RemoveStateBits(NS_BLOCK_HAS_LINE_CURSOR); } @@ -6780,7 +6774,7 @@ void nsBlockFrame::SetupLineCursor() return; } - Properties().Set(LineCursorProperty(), mLines.front()); + SetProperty(LineCursorProperty(), mLines.front()); AddStateBits(NS_BLOCK_HAS_LINE_CURSOR); } @@ -6790,9 +6784,7 @@ nsLineBox* nsBlockFrame::GetFirstLineContaining(nscoord y) return nullptr; } - FrameProperties props = Properties(); - - nsLineBox* property = props.Get(LineCursorProperty()); + nsLineBox* property = GetProperty(LineCursorProperty()); LineIterator cursor = mLines.begin(property); nsRect cursorArea = cursor->GetVisualOverflowArea(); @@ -6808,7 +6800,7 @@ nsLineBox* nsBlockFrame::GetFirstLineContaining(nscoord y) } if (cursor.get() != property) { - props.Set(LineCursorProperty(), cursor.get()); + SetProperty(LineCursorProperty(), cursor.get()); } return cursor.get(); @@ -7021,11 +7013,11 @@ nsBlockFrame::CreateBulletFrameForListItem(bool aCreateBulletList, if (aListStylePositionInside) { nsFrameList bulletList(bullet, bullet); AddFrames(bulletList, nullptr); - Properties().Set(InsideBulletProperty(), bullet); + SetProperty(InsideBulletProperty(), bullet); AddStateBits(NS_BLOCK_FRAME_HAS_INSIDE_BULLET); } else { nsFrameList* bulletList = new (shell) nsFrameList(bullet, bullet); - Properties().Set(OutsideBulletProperty(), bulletList); + SetProperty(OutsideBulletProperty(), bulletList); AddStateBits(NS_BLOCK_FRAME_HAS_OUTSIDE_BULLET); } } diff --git a/layout/generic/nsBlockFrame.h b/layout/generic/nsBlockFrame.h index bb41a6e99..f515cc26f 100644 --- a/layout/generic/nsBlockFrame.h +++ b/layout/generic/nsBlockFrame.h @@ -215,7 +215,7 @@ public: ~AutoLineCursorSetup() { if (mOrigCursor) { - mFrame->Properties().Set(LineCursorProperty(), mOrigCursor); + mFrame->SetProperty(LineCursorProperty(), mOrigCursor); } else { mFrame->ClearLineCursor(); } @@ -416,7 +416,7 @@ protected: NS_DECLARE_FRAME_PROPERTY_WITHOUT_DTOR(LineCursorProperty, nsLineBox) bool HasLineCursor() { return GetStateBits() & NS_BLOCK_HAS_LINE_CURSOR; } nsLineBox* GetLineCursor() { - return HasLineCursor() ? Properties().Get(LineCursorProperty()) : nullptr; + return HasLineCursor() ? GetProperty(LineCursorProperty()) : nullptr; } nsLineBox* NewLineBox(nsIFrame* aFrame, bool aIsBlock) { diff --git a/layout/generic/nsBulletFrame.cpp b/layout/generic/nsBulletFrame.cpp index aa8794321..f6595e8f6 100644 --- a/layout/generic/nsBulletFrame.cpp +++ b/layout/generic/nsBulletFrame.cpp @@ -903,7 +903,7 @@ nsBulletFrame::GetFontSizeInflation() const if (!HasFontSizeInflation()) { return 1.0f; } - return Properties().Get(FontSizeInflationProperty()); + return GetProperty(FontSizeInflationProperty()); } void @@ -912,13 +912,13 @@ nsBulletFrame::SetFontSizeInflation(float aInflation) if (aInflation == 1.0f) { if (HasFontSizeInflation()) { RemoveStateBits(BULLET_FRAME_HAS_FONT_INFLATION); - Properties().Delete(FontSizeInflationProperty()); + DeleteProperty(FontSizeInflationProperty()); } return; } AddStateBits(BULLET_FRAME_HAS_FONT_INFLATION); - Properties().Set(FontSizeInflationProperty(), aInflation); + SetProperty(FontSizeInflationProperty(), aInflation); } already_AddRefed diff --git a/layout/generic/nsCanvasFrame.cpp b/layout/generic/nsCanvasFrame.cpp index 70a2117cf..1a8812fb7 100644 --- a/layout/generic/nsCanvasFrame.cpp +++ b/layout/generic/nsCanvasFrame.cpp @@ -300,7 +300,7 @@ nsDisplayCanvasBackgroundImage::Paint(nsDisplayListBuilder* aBuilder, // above. destRect.Round(); RefPtr dt = - Frame()->Properties().Get(nsIFrame::CachedBackgroundImageDT()); + Frame()->GetProperty(nsIFrame::CachedBackgroundImageDT()); DrawTarget* destDT = dest->GetDrawTarget(); if (dt) { BlitSurface(destDT, destRect, dt); @@ -317,7 +317,7 @@ nsDisplayCanvasBackgroundImage::Paint(nsDisplayListBuilder* aBuilder, nsRenderingContext context(ctx); PaintInternal(aBuilder, &context, bgClipRect, &bgClipRect); BlitSurface(dest->GetDrawTarget(), destRect, dt); - frame->Properties().Set(nsIFrame::CachedBackgroundImageDT(), + frame->SetProperty(nsIFrame::CachedBackgroundImageDT(), dt.forget().take()); return; } diff --git a/layout/generic/nsCanvasFrame.h b/layout/generic/nsCanvasFrame.h index 236ffb9c7..8bd9dbf79 100644 --- a/layout/generic/nsCanvasFrame.h +++ b/layout/generic/nsCanvasFrame.h @@ -201,7 +201,7 @@ public: virtual void NotifyRenderingChanged() override { - mFrame->Properties().Delete(nsIFrame::CachedBackgroundImageDT()); + mFrame->DeleteProperty(nsIFrame::CachedBackgroundImageDT()); } virtual bool ShouldFixToViewport(nsDisplayListBuilder* aBuilder) override diff --git a/layout/generic/nsContainerFrame.cpp b/layout/generic/nsContainerFrame.cpp index 813d19dfe..2933ac4cf 100644 --- a/layout/generic/nsContainerFrame.cpp +++ b/layout/generic/nsContainerFrame.cpp @@ -78,7 +78,7 @@ nsContainerFrame::SetInitialChildList(ChildListID aListID, "Only top layer frames should have backdrop"); MOZ_ASSERT(GetStateBits() & NS_FRAME_OUT_OF_FLOW, "Top layer frames should be out-of-flow"); - MOZ_ASSERT(!Properties().Get(BackdropProperty()), + MOZ_ASSERT(!GetProperty(BackdropProperty()), "We shouldn't have setup backdrop frame list before"); #ifdef DEBUG { @@ -93,7 +93,7 @@ nsContainerFrame::SetInitialChildList(ChildListID aListID, #endif nsFrameList* list = new (PresContext()->PresShell()) nsFrameList(aChildList); - Properties().Set(BackdropProperty(), list); + SetProperty(BackdropProperty(), list); } else { MOZ_ASSERT_UNREACHABLE("Unexpected child list"); } @@ -189,18 +189,17 @@ nsContainerFrame::DestroyAbsoluteFrames(nsIFrame* aDestructRoot) void nsContainerFrame::SafelyDestroyFrameListProp(nsIFrame* aDestructRoot, nsIPresShell* aPresShell, - FramePropertyTable* aPropTable, FrameListPropertyDescriptor aProp) { // Note that the last frame can be removed through another route and thus // delete the property -- that's why we fetch the property again before // removing each frame rather than fetching it once and iterating the list. - while (nsFrameList* frameList = aPropTable->Get(this, aProp)) { + while (nsFrameList* frameList = GetProperty(aProp)) { nsIFrame* frame = frameList->RemoveFirstChild(); if (MOZ_LIKELY(frame)) { frame->DestroyFrom(aDestructRoot); } else { - aPropTable->Remove(this, aProp); + RemoveProperty(aProp); frameList->Delete(aPresShell); return; } @@ -223,22 +222,21 @@ nsContainerFrame::DestroyFrom(nsIFrame* aDestructRoot) // Destroy frames on the auxiliary frame lists and delete the lists. nsPresContext* pc = PresContext(); nsIPresShell* shell = pc->PresShell(); - FramePropertyTable* props = pc->PropertyTable(); - SafelyDestroyFrameListProp(aDestructRoot, shell, props, OverflowProperty()); + SafelyDestroyFrameListProp(aDestructRoot, shell, OverflowProperty()); MOZ_ASSERT(IsFrameOfType(nsIFrame::eCanContainOverflowContainers) || - !(props->Get(this, nsContainerFrame::OverflowContainersProperty()) || - props->Get(this, nsContainerFrame::ExcessOverflowContainersProperty())), + !(GetProperty(nsContainerFrame::OverflowContainersProperty()) || + GetProperty(nsContainerFrame::ExcessOverflowContainersProperty())), "this type of frame should't have overflow containers"); - SafelyDestroyFrameListProp(aDestructRoot, shell, props, + SafelyDestroyFrameListProp(aDestructRoot, shell, OverflowContainersProperty()); - SafelyDestroyFrameListProp(aDestructRoot, shell, props, + SafelyDestroyFrameListProp(aDestructRoot, shell, ExcessOverflowContainersProperty()); - MOZ_ASSERT(!props->Get(this, BackdropProperty()) || + MOZ_ASSERT(!GetProperty(BackdropProperty()) || StyleDisplay()->mTopLayer != NS_STYLE_TOP_LAYER_NONE, "only top layer frame may have backdrop"); - SafelyDestroyFrameListProp(aDestructRoot, shell, props, BackdropProperty()); + SafelyDestroyFrameListProp(aDestructRoot, shell, BackdropProperty()); nsSplittableFrame::DestroyFrom(aDestructRoot); } @@ -278,12 +276,11 @@ nsContainerFrame::GetChildList(ChildListID aListID) const static void AppendIfNonempty(const nsIFrame* aFrame, - FramePropertyTable* aPropTable, nsContainerFrame::FrameListPropertyDescriptor aProperty, nsTArray* aLists, nsIFrame::ChildListID aListID) { - if (nsFrameList* list = aPropTable->Get(aFrame, aProperty)) { + if (nsFrameList* list = aFrame->GetProperty(aProperty)) { list->AppendIfNonempty(aLists, aListID); } } @@ -292,20 +289,19 @@ void nsContainerFrame::GetChildLists(nsTArray* aLists) const { mFrames.AppendIfNonempty(aLists, kPrincipalList); - FramePropertyTable* propTable = PresContext()->PropertyTable(); - ::AppendIfNonempty(this, propTable, OverflowProperty(), + ::AppendIfNonempty(this, OverflowProperty(), aLists, kOverflowList); if (IsFrameOfType(nsIFrame::eCanContainOverflowContainers)) { - ::AppendIfNonempty(this, propTable, OverflowContainersProperty(), + ::AppendIfNonempty(this, OverflowContainersProperty(), aLists, kOverflowContainersList); - ::AppendIfNonempty(this, propTable, ExcessOverflowContainersProperty(), + ::AppendIfNonempty(this, ExcessOverflowContainersProperty(), aLists, kExcessOverflowContainersList); } // Bypass BackdropProperty hashtable lookup for any in-flow frames // since frames in the top layer (only which can have backdrop) are // definitely out-of-flow. if (GetStateBits() & NS_FRAME_OUT_OF_FLOW) { - ::AppendIfNonempty(this, propTable, BackdropProperty(), + ::AppendIfNonempty(this, BackdropProperty(), aLists, kBackdropList); } nsSplittableFrame::GetChildLists(aLists); @@ -1335,15 +1331,15 @@ nsContainerFrame::DisplayOverflowContainers(nsDisplayListBuilder* aBuilder, } static bool -TryRemoveFrame(nsIFrame* aFrame, FramePropertyTable* aPropTable, +TryRemoveFrame(nsIFrame* aFrame, nsContainerFrame::FrameListPropertyDescriptor aProp, nsIFrame* aChildToRemove) { - nsFrameList* list = aPropTable->Get(aFrame, aProp); + nsFrameList* list = aFrame->GetProperty(aProp); if (list && list->StartRemoveFrame(aChildToRemove)) { // aChildToRemove *may* have been removed from this list. if (list->IsEmpty()) { - aPropTable->Remove(aFrame, aProp); + aFrame->RemoveProperty(aProp); list->Delete(aFrame->PresContext()->PresShell()); } return true; @@ -1356,13 +1352,12 @@ nsContainerFrame::MaybeStealOverflowContainerFrame(nsIFrame* aChild) { bool removed = false; if (MOZ_UNLIKELY(aChild->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER)) { - FramePropertyTable* propTable = PresContext()->PropertyTable(); // Try removing from the overflow container list. - removed = ::TryRemoveFrame(this, propTable, OverflowContainersProperty(), + removed = ::TryRemoveFrame(this, OverflowContainersProperty(), aChild); if (!removed) { // It might be in the excess overflow container list. - removed = ::TryRemoveFrame(this, propTable, + removed = ::TryRemoveFrame(this, ExcessOverflowContainersProperty(), aChild); } @@ -1377,10 +1372,9 @@ nsContainerFrame::StealFrame(nsIFrame* aChild) if (!mFrames.ContainsFrame(aChild)) { nsFrameList* list = GetOverflowFrames(); if (!list || !list->ContainsFrame(aChild)) { - FramePropertyTable* propTable = PresContext()->PropertyTable(); - list = propTable->Get(this, OverflowContainersProperty()); + list = GetProperty(OverflowContainersProperty()); if (!list || !list->ContainsFrame(aChild)) { - list = propTable->Get(this, ExcessOverflowContainersProperty()); + list = GetProperty(ExcessOverflowContainersProperty()); MOZ_ASSERT(list && list->ContainsFrame(aChild), "aChild isn't our child" " or on a frame list not supported by StealFrame"); } @@ -1536,20 +1530,20 @@ nsContainerFrame::SetOverflowFrames(const nsFrameList& aOverflowFrames) nsPresContext* pc = PresContext(); nsFrameList* newList = new (pc->PresShell()) nsFrameList(aOverflowFrames); - pc->PropertyTable()->Set(this, OverflowProperty(), newList); + SetProperty(OverflowProperty(), newList); } nsFrameList* nsContainerFrame::GetPropTableFrames( FrameListPropertyDescriptor aProperty) const { - return PresContext()->PropertyTable()->Get(this, aProperty); + return GetProperty(aProperty); } nsFrameList* nsContainerFrame::RemovePropTableFrames(FrameListPropertyDescriptor aProperty) { - return PresContext()->PropertyTable()->Remove(this, aProperty); + return RemoveProperty(aProperty); } void @@ -1563,7 +1557,7 @@ nsContainerFrame::SetPropTableFrames(nsFrameList* aFrameList, IsFrameOfType(nsIFrame::eCanContainOverflowContainers), "this type of frame can't have overflow containers"); MOZ_ASSERT(!GetPropTableFrames(aProperty)); - PresContext()->PropertyTable()->Set(this, aProperty, aFrameList); + SetProperty(aProperty, aFrameList); } /** @@ -2253,13 +2247,11 @@ nsOverflowContinuationTracker::EndFinish(nsIFrame* aChild) return; } // Forget mOverflowContList if it was deleted. - nsPresContext* pc = aChild->PresContext(); - FramePropertyTable* propTable = pc->PropertyTable(); - nsFrameList* eoc = propTable->Get( - mParent, nsContainerFrame::ExcessOverflowContainersProperty()); + nsFrameList* eoc = mParent->GetProperty + (nsContainerFrame::ExcessOverflowContainersProperty()); if (eoc != mOverflowContList) { - nsFrameList* oc = static_cast(propTable->Get(mParent, - nsContainerFrame::OverflowContainersProperty())); + nsFrameList* oc = static_cast(mParent->GetProperty + (nsContainerFrame::OverflowContainersProperty())); if (oc != mOverflowContList) { // mOverflowContList was deleted mPrevOverflowCont = nullptr; diff --git a/layout/generic/nsContainerFrame.h b/layout/generic/nsContainerFrame.h index a9f6d52df..ddf993d91 100644 --- a/layout/generic/nsContainerFrame.h +++ b/layout/generic/nsContainerFrame.h @@ -24,9 +24,6 @@ #define NS_FRAME_NO_DELETE_NEXT_IN_FLOW_CHILD 0x0010 class nsOverflowContinuationTracker; -namespace mozilla { -class FramePropertyTable; -} // namespace mozilla // Some macros for container classes to do sanity checking on // width/height/x/y values computed during reflow. @@ -548,7 +545,7 @@ public: // Use this to suppress the CRAZY_SIZE assertions. NS_DECLARE_FRAME_PROPERTY_SMALL_VALUE(DebugReflowingWithInfiniteISize, bool) bool IsCrazySizeAssertSuppressed() const { - return Properties().Get(DebugReflowingWithInfiniteISize()); + return GetProperty(DebugReflowingWithInfiniteISize()); } #endif @@ -716,7 +713,6 @@ protected: */ void SafelyDestroyFrameListProp(nsIFrame* aDestructRoot, nsIPresShell* aPresShell, - mozilla::FramePropertyTable* aPropTable, FrameListPropertyDescriptor aProp); // ========================================================================== @@ -898,7 +894,7 @@ inline nsFrameList* nsContainerFrame::GetOverflowFrames() const { - nsFrameList* list = Properties().Get(OverflowProperty()); + nsFrameList* list = GetProperty(OverflowProperty()); NS_ASSERTION(!list || !list->IsEmpty(), "Unexpected empty overflow list"); return list; } @@ -907,7 +903,7 @@ inline nsFrameList* nsContainerFrame::StealOverflowFrames() { - nsFrameList* list = Properties().Remove(OverflowProperty()); + nsFrameList* list = RemoveProperty(OverflowProperty()); NS_ASSERTION(!list || !list->IsEmpty(), "Unexpected empty overflow list"); return list; } diff --git a/layout/generic/nsFlexContainerFrame.cpp b/layout/generic/nsFlexContainerFrame.cpp index 3818d3cb7..94bce1e7a 100644 --- a/layout/generic/nsFlexContainerFrame.cpp +++ b/layout/generic/nsFlexContainerFrame.cpp @@ -1816,8 +1816,8 @@ nsFlexContainerFrame::MeasureAscentAndHeightForFlexItem( nsPresContext* aPresContext, ReflowInput& aChildReflowInput) { - const FrameProperties props = aItem.Frame()->Properties(); - if (const auto* cachedResult = props.Get(CachedFlexMeasuringReflow())) { + if (const auto* cachedResult = + aItem.Frame()->GetProperty(CachedFlexMeasuringReflow())) { if (cachedResult->IsValidFor(aChildReflowInput)) { return *cachedResult; } @@ -1847,7 +1847,7 @@ nsFlexContainerFrame::MeasureAscentAndHeightForFlexItem( auto result = new CachedMeasuringReflowResult(aChildReflowInput, childDesiredSize); - props.Set(CachedFlexMeasuringReflow(), result); + aItem.Frame()->SetProperty(CachedFlexMeasuringReflow(), result); return *result; } @@ -1855,7 +1855,7 @@ nsFlexContainerFrame::MeasureAscentAndHeightForFlexItem( nsFlexContainerFrame::MarkIntrinsicISizesDirty() { for (nsIFrame* childFrame : mFrames) { - childFrame->Properties().Delete(CachedFlexMeasuringReflow()); + childFrame->DeleteProperty(CachedFlexMeasuringReflow()); } nsContainerFrame::MarkIntrinsicISizesDirty(); } @@ -4236,25 +4236,26 @@ class MOZ_RAII AutoFlexItemMainSizeOverride final public: explicit AutoFlexItemMainSizeOverride(FlexItem& aItem MOZ_GUARD_OBJECT_NOTIFIER_PARAM) - : mItemProps(aItem.Frame()->Properties()) + : mItemFrame(aItem.Frame()) { MOZ_GUARD_OBJECT_NOTIFIER_INIT; - MOZ_ASSERT(!mItemProps.Has(nsIFrame::FlexItemMainSizeOverride()), + MOZ_ASSERT(!mItemFrame->HasProperty(nsIFrame::FlexItemMainSizeOverride()), "FlexItemMainSizeOverride prop shouldn't be set already; " "it should only be set temporarily (& not recursively)"); NS_ASSERTION(aItem.HasIntrinsicRatio(), "This should only be needed for items with an aspect ratio"); - mItemProps.Set(nsIFrame::FlexItemMainSizeOverride(), aItem.GetMainSize()); + mItemFrame->SetProperty(nsIFrame::FlexItemMainSizeOverride(), + aItem.GetMainSize()); } ~AutoFlexItemMainSizeOverride() { - mItemProps.Remove(nsIFrame::FlexItemMainSizeOverride()); + mItemFrame->RemoveProperty(nsIFrame::FlexItemMainSizeOverride()); } private: - const FrameProperties mItemProps; + nsIFrame* mItemFrame; MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER }; @@ -4668,8 +4669,7 @@ nsFlexContainerFrame::MoveFlexItemToFinalPosition( // If item is relpos, look up its offsets (cached from prev reflow) LogicalMargin logicalOffsets(outerWM); if (NS_STYLE_POSITION_RELATIVE == aItem.Frame()->StyleDisplay()->mPosition) { - FrameProperties props = aItem.Frame()->Properties(); - nsMargin* cachedOffsets = props.Get(nsIFrame::ComputedOffsetProperty()); + nsMargin* cachedOffsets = aItem.Frame()->GetProperty(nsIFrame::ComputedOffsetProperty()); MOZ_ASSERT(cachedOffsets, "relpos previously-reflowed frame should've cached its offsets"); logicalOffsets = LogicalMargin(outerWM, *cachedOffsets); diff --git a/layout/generic/nsFloatManager.cpp b/layout/generic/nsFloatManager.cpp index 2c0ff1f38..4e7e7ff91 100644 --- a/layout/generic/nsFloatManager.cpp +++ b/layout/generic/nsFloatManager.cpp @@ -331,7 +331,7 @@ nsFloatManager::GetRegionFor(WritingMode aWM, nsIFrame* aFloat, const nsSize& aContainerSize) { LogicalRect region = aFloat->GetLogicalRect(aWM, aContainerSize); - void* storedRegion = aFloat->Properties().Get(FloatRegionProperty()); + void* storedRegion = aFloat->GetProperty(FloatRegionProperty()); if (storedRegion) { nsMargin margin = *static_cast(storedRegion); region.Inflate(aWM, LogicalMargin(aWM, margin)); @@ -346,15 +346,14 @@ nsFloatManager::StoreRegionFor(WritingMode aWM, nsIFrame* aFloat, { nsRect region = aRegion.GetPhysicalRect(aWM, aContainerSize); nsRect rect = aFloat->GetRect(); - FrameProperties props = aFloat->Properties(); if (region.IsEqualEdges(rect)) { - props.Delete(FloatRegionProperty()); + aFloat->DeleteProperty(FloatRegionProperty()); } else { - nsMargin* storedMargin = props.Get(FloatRegionProperty()); + nsMargin* storedMargin = aFloat->GetProperty(FloatRegionProperty()); if (!storedMargin) { storedMargin = new nsMargin(); - props.Set(FloatRegionProperty(), storedMargin); + aFloat->SetProperty(FloatRegionProperty(), storedMargin); } *storedMargin = region - rect; } diff --git a/layout/generic/nsFontInflationData.cpp b/layout/generic/nsFontInflationData.cpp index 9e9a51999..831658c9e 100644 --- a/layout/generic/nsFontInflationData.cpp +++ b/layout/generic/nsFontInflationData.cpp @@ -6,7 +6,7 @@ /* Per-block-formatting-context manager of font size inflation for pan and zoom UI. */ #include "nsFontInflationData.h" -#include "FramePropertyTable.h" +#include "FrameProperties.h" #include "nsTextControlFrame.h" #include "nsListControlFrame.h" #include "nsComboboxControlFrame.h" @@ -27,7 +27,7 @@ nsFontInflationData::FindFontInflationDataFor(const nsIFrame *aFrame) NS_ASSERTION(bfc->GetStateBits() & NS_FRAME_FONT_INFLATION_FLOW_ROOT, "should have found a flow root"); - return bfc->Properties().Get(FontInflationDataProperty()); + return bfc->GetProperty(FontInflationDataProperty()); } /* static */ bool @@ -36,8 +36,7 @@ nsFontInflationData::UpdateFontInflationDataISizeFor(const ReflowInput& aReflowI nsIFrame *bfc = aReflowInput.mFrame; NS_ASSERTION(bfc->GetStateBits() & NS_FRAME_FONT_INFLATION_FLOW_ROOT, "should have been given a flow root"); - FrameProperties bfcProps(bfc->Properties()); - nsFontInflationData *data = bfcProps.Get(FontInflationDataProperty()); + nsFontInflationData *data = bfc->GetProperty(FontInflationDataProperty()); bool oldInflationEnabled; nscoord oldNCAISize; if (data) { @@ -45,7 +44,7 @@ nsFontInflationData::UpdateFontInflationDataISizeFor(const ReflowInput& aReflowI oldInflationEnabled = data->mInflationEnabled; } else { data = new nsFontInflationData(bfc); - bfcProps.Set(FontInflationDataProperty(), data); + bfc->SetProperty(FontInflationDataProperty(), data); oldNCAISize = -1; oldInflationEnabled = true; /* not relevant */ } @@ -65,8 +64,7 @@ nsFontInflationData::MarkFontInflationDataTextDirty(nsIFrame *aBFCFrame) NS_ASSERTION(aBFCFrame->GetStateBits() & NS_FRAME_FONT_INFLATION_FLOW_ROOT, "should have been given a flow root"); - FrameProperties bfcProps(aBFCFrame->Properties()); - nsFontInflationData *data = bfcProps.Get(FontInflationDataProperty()); + nsFontInflationData *data = aBFCFrame->GetProperty(FontInflationDataProperty()); if (data) { data->MarkTextDirty(); } diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index fa5b24d40..bd96f213b 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -168,13 +168,12 @@ NS_DECLARE_FRAME_PROPERTY_DELETABLE(BoxMetricsProperty, nsBoxLayoutMetrics) static void InitBoxMetrics(nsIFrame* aFrame, bool aClear) { - FrameProperties props = aFrame->Properties(); if (aClear) { - props.Delete(BoxMetricsProperty()); + aFrame->DeleteProperty(BoxMetricsProperty()); } nsBoxLayoutMetrics* metrics = new nsBoxLayoutMetrics(); - props.Set(BoxMetricsProperty(), metrics); + aFrame->SetProperty(BoxMetricsProperty(), metrics); static_cast(aFrame)->nsFrame::MarkIntrinsicISizesDirty(); metrics->mBlockAscent = 0; @@ -254,7 +253,7 @@ nsIFrame::HasAbsolutelyPositionedChildren() const { nsAbsoluteContainingBlock* nsIFrame::GetAbsoluteContainingBlock() const { NS_ASSERTION(IsAbsoluteContainer(), "The frame is not marked as an abspos container correctly"); - nsAbsoluteContainingBlock* absCB = Properties().Get(AbsoluteContainingBlockProperty()); + nsAbsoluteContainingBlock* absCB = GetProperty(AbsoluteContainingBlockProperty()); NS_ASSERTION(absCB, "The frame is marked as an abspos container but doesn't have the property"); return absCB; } @@ -263,25 +262,25 @@ void nsIFrame::MarkAsAbsoluteContainingBlock() { MOZ_ASSERT(GetStateBits() & NS_FRAME_CAN_HAVE_ABSPOS_CHILDREN); - NS_ASSERTION(!Properties().Get(AbsoluteContainingBlockProperty()), + NS_ASSERTION(!GetProperty(AbsoluteContainingBlockProperty()), "Already has an abs-pos containing block property?"); NS_ASSERTION(!HasAnyStateBits(NS_FRAME_HAS_ABSPOS_CHILDREN), "Already has NS_FRAME_HAS_ABSPOS_CHILDREN state bit?"); AddStateBits(NS_FRAME_HAS_ABSPOS_CHILDREN); - Properties().Set(AbsoluteContainingBlockProperty(), new nsAbsoluteContainingBlock(GetAbsoluteListID())); + SetProperty(AbsoluteContainingBlockProperty(), new nsAbsoluteContainingBlock(GetAbsoluteListID())); } void nsIFrame::MarkAsNotAbsoluteContainingBlock() { NS_ASSERTION(!HasAbsolutelyPositionedChildren(), "Think of the children!"); - NS_ASSERTION(Properties().Get(AbsoluteContainingBlockProperty()), + NS_ASSERTION(GetProperty(AbsoluteContainingBlockProperty()), "Should have an abs-pos containing block property"); NS_ASSERTION(HasAnyStateBits(NS_FRAME_HAS_ABSPOS_CHILDREN), "Should have NS_FRAME_HAS_ABSPOS_CHILDREN state bit"); MOZ_ASSERT(HasAnyStateBits(NS_FRAME_CAN_HAVE_ABSPOS_CHILDREN)); RemoveStateBits(NS_FRAME_HAS_ABSPOS_CHILDREN); - Properties().Delete(AbsoluteContainingBlockProperty()); + DeleteProperty(AbsoluteContainingBlockProperty()); } bool @@ -652,32 +651,30 @@ nsFrame::DestroyFrom(nsIFrame* aDestructRoot) } // If we have any IB split siblings, clear their references to us. - // (Note: This has to happen before we call shell->NotifyDestroyingFrame, - // because that clears our Properties() table.) + // (Note: This has to happen before we clear our Properties() table.) if (mState & NS_FRAME_PART_OF_IBSPLIT) { // Delete previous sibling's reference to me. - nsIFrame* prevSib = Properties().Get(nsIFrame::IBSplitPrevSibling()); + nsIFrame* prevSib = GetProperty(nsIFrame::IBSplitPrevSibling()); if (prevSib) { NS_WARNING_ASSERTION( - this == prevSib->Properties().Get(nsIFrame::IBSplitSibling()), + this == prevSib->GetProperty(nsIFrame::IBSplitSibling()), "IB sibling chain is inconsistent"); - prevSib->Properties().Delete(nsIFrame::IBSplitSibling()); + prevSib->DeleteProperty(nsIFrame::IBSplitSibling()); } // Delete next sibling's reference to me. - nsIFrame* nextSib = Properties().Get(nsIFrame::IBSplitSibling()); + nsIFrame* nextSib = GetProperty(nsIFrame::IBSplitSibling()); if (nextSib) { NS_WARNING_ASSERTION( - this == nextSib->Properties().Get(nsIFrame::IBSplitPrevSibling()), + this == nextSib->GetProperty(nsIFrame::IBSplitPrevSibling()), "IB sibling chain is inconsistent"); - nextSib->Properties().Delete(nsIFrame::IBSplitPrevSibling()); + nextSib->DeleteProperty(nsIFrame::IBSplitPrevSibling()); } } bool isPrimaryFrame = (mContent && mContent->GetPrimaryFrame() == this); if (isPrimaryFrame) { - // This needs to happen before shell->NotifyDestroyingFrame because - // that clears our Properties() table. + // This needs to happen before we clear our Properties() table. ActiveLayerTracker::TransferActivityToContent(this, mContent); // Unfortunately, we need to do this for all frames being reframed @@ -712,9 +709,8 @@ nsFrame::DestroyFrom(nsIFrame* aDestructRoot) } } - // Disable visibility tracking. Note that we have to do this before calling - // NotifyDestroyingFrame(), which will clear frame properties and make us lose - // track of whether we were previously visible or not. + // Disable visibility tracking. Note that we have to do this before we clear + // frame properties and lose track of whether we were previously visible. // XXX(seth): It'd be ideal to assert that we're already marked nonvisible // here, but it's unfortunately tricky to guarantee in the face of things like // frame reconstruction induced by style changes. @@ -742,6 +738,10 @@ nsFrame::DestroyFrom(nsIFrame* aDestructRoot) mContent->SetPrimaryFrame(nullptr); } + // Delete all properties attached to the frame, to ensure any property + // destructors that need the frame pointer are handled properly. + DeleteAllProperties(); + // Must retrieve the object ID before calling destructors, so the // vtable is still valid. // @@ -860,22 +860,21 @@ nsFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext) // calls GetUsed(Margin|Border|Padding)() before the next reflow, we // can give an accurate answer. // We don't want to set the property if one already exists. - FrameProperties props = Properties(); nsMargin oldValue(0, 0, 0, 0); nsMargin newValue(0, 0, 0, 0); const nsStyleMargin* oldMargin = aOldStyleContext->PeekStyleMargin(); if (oldMargin && oldMargin->GetMargin(oldValue)) { if ((!StyleMargin()->GetMargin(newValue) || oldValue != newValue) && - !props.Get(UsedMarginProperty())) { - props.Set(UsedMarginProperty(), new nsMargin(oldValue)); + !GetProperty(UsedMarginProperty())) { + SetProperty(UsedMarginProperty(), new nsMargin(oldValue)); } } const nsStylePadding* oldPadding = aOldStyleContext->PeekStylePadding(); if (oldPadding && oldPadding->GetPadding(oldValue)) { if ((!StylePadding()->GetPadding(newValue) || oldValue != newValue) && - !props.Get(UsedPaddingProperty())) { - props.Set(UsedPaddingProperty(), new nsMargin(oldValue)); + !GetProperty(UsedPaddingProperty())) { + SetProperty(UsedPaddingProperty(), new nsMargin(oldValue)); } } @@ -884,8 +883,8 @@ nsFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext) oldValue = oldBorder->GetComputedBorder(); newValue = StyleBorder()->GetComputedBorder(); if (oldValue != newValue && - !props.Get(UsedBorderProperty())) { - props.Set(UsedBorderProperty(), new nsMargin(oldValue)); + !GetProperty(UsedBorderProperty())) { + SetProperty(UsedBorderProperty(), new nsMargin(oldValue)); } } } @@ -961,7 +960,7 @@ nsIFrame::GetUsedMargin() const IsSVGText()) return margin; - nsMargin *m = Properties().Get(UsedMarginProperty()); + nsMargin *m = GetProperty(UsedMarginProperty()); if (m) { margin = *m; } else { @@ -1000,7 +999,7 @@ nsIFrame::GetUsedBorder() const return border; } - nsMargin *b = Properties().Get(UsedBorderProperty()); + nsMargin *b = GetProperty(UsedBorderProperty()); if (b) { border = *b; } else { @@ -1037,7 +1036,7 @@ nsIFrame::GetUsedPadding() const } } - nsMargin *p = Properties().Get(UsedPaddingProperty()); + nsMargin *p = GetProperty(UsedPaddingProperty()); if (p) { padding = *p; } else { @@ -1478,8 +1477,7 @@ nsIFrame::GetVisibility() const } bool isSet = false; - FrameProperties props = Properties(); - uint32_t visibleCount = props.Get(VisibilityStateProperty(), &isSet); + uint32_t visibleCount = GetProperty(VisibilityStateProperty(), &isSet); MOZ_ASSERT(isSet, "Should have a VisibilityStateProperty value " "if NS_FRAME_VISIBILITY_IS_TRACKED is set"); @@ -1552,15 +1550,14 @@ nsIFrame::EnableVisibilityTracking() return; // Nothing to do. } - FrameProperties props = Properties(); - MOZ_ASSERT(!props.Has(VisibilityStateProperty()), + MOZ_ASSERT(!HasProperty(VisibilityStateProperty()), "Shouldn't have a VisibilityStateProperty value " "if NS_FRAME_VISIBILITY_IS_TRACKED is not set"); // Add the state bit so we know to track visibility for this frame, and // initialize the frame property. AddStateBits(NS_FRAME_VISIBILITY_IS_TRACKED); - props.Set(VisibilityStateProperty(), 0); + SetProperty(VisibilityStateProperty(), 0); nsIPresShell* presShell = PresContext()->PresShell(); if (!presShell) { @@ -1582,8 +1579,7 @@ nsIFrame::DisableVisibilityTracking() } bool isSet = false; - FrameProperties props = Properties(); - uint32_t visibleCount = props.Remove(VisibilityStateProperty(), &isSet); + uint32_t visibleCount = RemoveProperty(VisibilityStateProperty(), &isSet); MOZ_ASSERT(isSet, "Should have a VisibilityStateProperty value " "if NS_FRAME_VISIBILITY_IS_TRACKED is set"); @@ -1605,8 +1601,7 @@ nsIFrame::DecApproximateVisibleCount(Maybe aNonvisibleAction MOZ_ASSERT(GetStateBits() & NS_FRAME_VISIBILITY_IS_TRACKED); bool isSet = false; - FrameProperties props = Properties(); - uint32_t visibleCount = props.Get(VisibilityStateProperty(), &isSet); + uint32_t visibleCount = GetProperty(VisibilityStateProperty(), &isSet); MOZ_ASSERT(isSet, "Should have a VisibilityStateProperty value " "if NS_FRAME_VISIBILITY_IS_TRACKED is set"); @@ -1614,7 +1609,7 @@ nsIFrame::DecApproximateVisibleCount(Maybe aNonvisibleAction "decrementing its visible count?"); visibleCount--; - props.Set(VisibilityStateProperty(), visibleCount); + SetProperty(VisibilityStateProperty(), visibleCount); if (visibleCount > 0) { return; } @@ -1629,14 +1624,13 @@ nsIFrame::IncApproximateVisibleCount() MOZ_ASSERT(GetStateBits() & NS_FRAME_VISIBILITY_IS_TRACKED); bool isSet = false; - FrameProperties props = Properties(); - uint32_t visibleCount = props.Get(VisibilityStateProperty(), &isSet); + uint32_t visibleCount = GetProperty(VisibilityStateProperty(), &isSet); MOZ_ASSERT(isSet, "Should have a VisibilityStateProperty value " "if NS_FRAME_VISIBILITY_IS_TRACKED is set"); visibleCount++; - props.Set(VisibilityStateProperty(), visibleCount); + SetProperty(VisibilityStateProperty(), visibleCount); if (visibleCount > 1) { return; } @@ -4943,10 +4937,9 @@ nsFrame::ComputeSizeWithIntrinsicDimensions(nsRenderingContext* aRenderingConte // If FlexItemMainSizeOverride frame-property is set, then that means the // flex container is imposing a main-size on this flex item for it to use // as its size in the container's main axis. - FrameProperties props = Properties(); bool didImposeMainSize; nscoord imposedMainSize = - props.Get(nsIFrame::FlexItemMainSizeOverride(), &didImposeMainSize); + GetProperty(nsIFrame::FlexItemMainSizeOverride(), &didImposeMainSize); if (didImposeMainSize) { imposedMainSizeStyleCoord.emplace(imposedMainSize, nsStyleCoord::CoordConstructor); @@ -5686,7 +5679,7 @@ nsIFrame::GetView() const return nullptr; // Check for a property on the frame - nsView* value = Properties().Get(ViewProperty()); + nsView* value = GetProperty(ViewProperty()); NS_ASSERTION(value, "frame state bit was set but frame has no view"); return value; } @@ -5709,7 +5702,7 @@ nsIFrame::SetView(nsView* aView) #endif // Set a property on the frame - Properties().Set(ViewProperty(), aView); + SetProperty(ViewProperty(), aView); // Set the frame state bit that says the frame has a view AddStateBits(NS_FRAME_HAS_VIEW); @@ -6098,7 +6091,7 @@ static void InvalidateFrameInternal(nsIFrame *aFrame, bool aHasDisplayItem = tru SchedulePaintInternal(aFrame); } if (aFrame->HasAnyStateBits(NS_FRAME_HAS_INVALID_RECT)) { - aFrame->Properties().Delete(nsIFrame::InvalidationRect()); + aFrame->DeleteProperty(nsIFrame::InvalidationRect()); aFrame->RemoveStateBits(NS_FRAME_HAS_INVALID_RECT); } } @@ -6173,13 +6166,13 @@ nsIFrame::InvalidateFrameWithRect(const nsRect& aRect, uint32_t aDisplayItemKey) return; } - nsRect* rect = Properties().Get(InvalidationRect()); + nsRect* rect = GetProperty(InvalidationRect()); if (!rect) { if (alreadyInvalid) { return; } rect = new nsRect(); - Properties().Set(InvalidationRect(), rect); + SetProperty(InvalidationRect(), rect); AddStateBits(NS_FRAME_HAS_INVALID_RECT); } @@ -6280,7 +6273,7 @@ nsIFrame::IsInvalid(nsRect& aRect) } if (HasAnyStateBits(NS_FRAME_HAS_INVALID_RECT)) { - nsRect* rect = Properties().Get(InvalidationRect()); + nsRect* rect = GetProperty(InvalidationRect()); NS_ASSERTION(rect, "Must have an invalid rect if NS_FRAME_HAS_INVALID_RECT is set!"); aRect = *rect; } else { @@ -6368,8 +6361,8 @@ ComputeEffectsRect(nsIFrame* aFrame, const nsRect& aOverflowRect, // TODO: We could also take account of clipPath and mask to reduce the // visual overflow, but that's not essential. if (aFrame->StyleEffects()->HasFilters()) { - aFrame->Properties(). - Set(nsIFrame::PreEffectsBBoxProperty(), new nsRect(r)); + aFrame->SetProperty + (nsIFrame::PreEffectsBBoxProperty(), new nsRect(r)); r = nsSVGUtils::GetPostFilterVisualOverflowRect(aFrame, aOverflowRect); } return r; @@ -6407,8 +6400,8 @@ ComputeEffectsRect(nsIFrame* aFrame, const nsRect& aOverflowRect, // the frame dies. if (nsSVGIntegrationUtils::UsingEffectsForFrame(aFrame)) { - aFrame->Properties(). - Set(nsIFrame::PreEffectsBBoxProperty(), new nsRect(r)); + aFrame->SetProperty + (nsIFrame::PreEffectsBBoxProperty(), new nsRect(r)); r = nsSVGIntegrationUtils::ComputePostEffectsVisualOverflowRect(aFrame, r); } @@ -6422,7 +6415,7 @@ nsIFrame::MovePositionBy(const nsPoint& aTranslation) const nsMargin* computedOffsets = nullptr; if (IsRelativelyPositioned()) { - computedOffsets = Properties().Get(nsIFrame::ComputedOffsetProperty()); + computedOffsets = GetProperty(nsIFrame::ComputedOffsetProperty()); } ReflowInput::ApplyRelativePositioning(this, computedOffsets ? *computedOffsets : nsMargin(), @@ -6435,7 +6428,7 @@ nsIFrame::GetNormalRect() const { // It might be faster to first check // StyleDisplay()->IsRelativelyPositionedStyle(). - nsPoint* normalPosition = Properties().Get(NormalPositionProperty()); + nsPoint* normalPosition = GetProperty(NormalPositionProperty()); if (normalPosition) { return nsRect(*normalPosition, GetSize()); } @@ -6447,7 +6440,7 @@ nsIFrame::GetNormalPosition() const { // It might be faster to first check // StyleDisplay()->IsRelativelyPositionedStyle(). - nsPoint* normalPosition = Properties().Get(NormalPositionProperty()); + nsPoint* normalPosition = GetProperty(NormalPositionProperty()); if (normalPosition) { return *normalPosition; } @@ -6506,7 +6499,7 @@ nsIFrame::GetOverflowAreasRelativeToSelf() const { if (IsTransformed()) { nsOverflowAreas* preTransformOverflows = - Properties().Get(PreTransformOverflowAreasProperty()); + GetProperty(PreTransformOverflowAreasProperty()); if (preTransformOverflows) { return nsOverflowAreas(preTransformOverflows->VisualOverflow(), preTransformOverflows->ScrollableOverflow()); @@ -6533,7 +6526,7 @@ nsIFrame::GetScrollableOverflowRectRelativeToSelf() const { if (IsTransformed()) { nsOverflowAreas* preTransformOverflows = - Properties().Get(PreTransformOverflowAreasProperty()); + GetProperty(PreTransformOverflowAreasProperty()); if (preTransformOverflows) return preTransformOverflows->ScrollableOverflow(); } @@ -6545,7 +6538,7 @@ nsIFrame::GetVisualOverflowRectRelativeToSelf() const { if (IsTransformed()) { nsOverflowAreas* preTransformOverflows = - Properties().Get(PreTransformOverflowAreasProperty()); + GetProperty(PreTransformOverflowAreasProperty()); if (preTransformOverflows) return preTransformOverflows->VisualOverflow(); } @@ -6555,7 +6548,7 @@ nsIFrame::GetVisualOverflowRectRelativeToSelf() const nsRect nsIFrame::GetPreEffectsVisualOverflowRect() const { - nsRect* r = Properties().Get(nsIFrame::PreEffectsBBoxProperty()); + nsRect* r = GetProperty(nsIFrame::PreEffectsBBoxProperty()); return r ? *r : GetVisualOverflowRectRelativeToSelf(); } @@ -6758,11 +6751,11 @@ nsIFrame::ListGeneric(nsACString& aTo, const char* aPrefix, uint32_t aFlags) con aTo += nsPrintfCString(" next-%s=%p", fluid?"in-flow":"continuation", static_cast(GetNextContinuation())); } - void* IBsibling = Properties().Get(IBSplitSibling()); + void* IBsibling = GetProperty(IBSplitSibling()); if (IBsibling) { aTo += nsPrintfCString(" IBSplitSibling=%p", IBsibling); } - void* IBprevsibling = Properties().Get(IBSplitPrevSibling()); + void* IBprevsibling = GetProperty(IBSplitPrevSibling()); if (IBprevsibling) { aTo += nsPrintfCString(" IBSplitPrevSibling=%p", IBprevsibling); } @@ -7164,8 +7157,7 @@ nsFrame::GetPointFromOffset(int32_t inOffset, nsPoint* outPoint) // If the embedding level isn't set, just use the CSS direction // property. bool hasBidiData; - FrameBidiData bidiData = - Properties().Get(BidiDataProperty(), &hasBidiData); + FrameBidiData bidiData = GetProperty(BidiDataProperty(), &hasBidiData); bool isRTL = hasBidiData ? IS_LEVEL_RTL(bidiData.embeddingLevel) : StyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL; @@ -8315,7 +8307,7 @@ nsIFrame::ClearOverflowRects() return false; } if (mOverflow.mType == NS_FRAME_OVERFLOW_LARGE) { - Properties().Delete(OverflowAreasProperty()); + DeleteProperty(OverflowAreasProperty()); } mOverflow.mType = NS_FRAME_OVERFLOW_NONE; return true; @@ -8328,8 +8320,7 @@ nsIFrame::ClearOverflowRects() nsOverflowAreas* nsIFrame::GetOverflowAreasProperty() { - FrameProperties props = Properties(); - nsOverflowAreas* overflow = props.Get(OverflowAreasProperty()); + nsOverflowAreas* overflow = GetProperty(OverflowAreasProperty()); if (overflow) { return overflow; // the property already exists @@ -8338,7 +8329,7 @@ nsIFrame::GetOverflowAreasProperty() // The property isn't set yet, so allocate a new rect, set the property, // and return the newly allocated rect overflow = new nsOverflowAreas; - props.Set(OverflowAreasProperty(), overflow); + SetProperty(OverflowAreasProperty(), overflow); return overflow; } @@ -8349,7 +8340,7 @@ bool nsIFrame::SetOverflowAreas(const nsOverflowAreas& aOverflowAreas) { if (mOverflow.mType == NS_FRAME_OVERFLOW_LARGE) { - nsOverflowAreas* overflow = Properties().Get(OverflowAreasProperty()); + nsOverflowAreas* overflow = GetProperty(OverflowAreasProperty()); bool changed = *overflow != aOverflowAreas; *overflow = aOverflowAreas; @@ -8593,7 +8584,7 @@ ComputeAndIncludeOutlineArea(nsIFrame* aFrame, nsOverflowAreas& aOverflowAreas, } // Keep this code in sync with GetOutlineInnerRect in nsCSSRendering.cpp. - aFrame->Properties().Set(nsIFrame::OutlineInnerRectProperty(), + aFrame->SetProperty(nsIFrame::OutlineInnerRectProperty(), new nsRect(innerRect)); const nscoord offset = outline->mOutlineOffset; nsRect outerRect(innerRect); @@ -8635,22 +8626,22 @@ nsIFrame::FinishAndStoreOverflow(nsOverflowAreas& aOverflowAreas, if (!aOverflowAreas.VisualOverflow().IsEqualEdges(bounds) || !aOverflowAreas.ScrollableOverflow().IsEqualEdges(bounds)) { nsOverflowAreas* initial = - Properties().Get(nsIFrame::InitialOverflowProperty()); + GetProperty(nsIFrame::InitialOverflowProperty()); if (!initial) { - Properties().Set(nsIFrame::InitialOverflowProperty(), + SetProperty(nsIFrame::InitialOverflowProperty(), new nsOverflowAreas(aOverflowAreas)); } else if (initial != &aOverflowAreas) { *initial = aOverflowAreas; } } else { - Properties().Delete(nsIFrame::InitialOverflowProperty()); + DeleteProperty(nsIFrame::InitialOverflowProperty()); } #ifdef DEBUG - Properties().Set(nsIFrame::DebugInitialOverflowPropertyApplied(), true); + SetProperty(nsIFrame::DebugInitialOverflowPropertyApplied(), true); #endif } else { #ifdef DEBUG - Properties().Delete(nsIFrame::DebugInitialOverflowPropertyApplied()); + DeleteProperty(nsIFrame::DebugInitialOverflowPropertyApplied()); #endif } @@ -8745,8 +8736,8 @@ nsIFrame::FinishAndStoreOverflow(nsOverflowAreas& aOverflowAreas, } if (hasTransform) { - Properties().Set(nsIFrame::PreTransformOverflowAreasProperty(), - new nsOverflowAreas(aOverflowAreas)); + SetProperty(nsIFrame::PreTransformOverflowAreasProperty(), + new nsOverflowAreas(aOverflowAreas)); if (Combines3DTransformWithAncestors()) { /* If we're a preserve-3d leaf frame, then our pre-transform overflow should be correct. Our @@ -8771,7 +8762,7 @@ nsIFrame::FinishAndStoreOverflow(nsOverflowAreas& aOverflowAreas, } } } else { - Properties().Delete(nsIFrame::PreTransformOverflowAreasProperty()); + DeleteProperty(nsIFrame::PreTransformOverflowAreasProperty()); } /* Revert the size change in case some caller is depending on this. */ @@ -8803,7 +8794,7 @@ nsIFrame::RecomputePerspectiveChildrenOverflow(const nsIFrame* aStartFrame) } if (child->HasPerspective()) { nsOverflowAreas* overflow = - child->Properties().Get(nsIFrame::InitialOverflowProperty()); + child->GetProperty(nsIFrame::InitialOverflowProperty()); nsRect bounds(nsPoint(0, 0), child->GetSize()); if (overflow) { nsOverflowAreas overflowCopy = *overflow; @@ -8915,7 +8906,7 @@ GetIBSplitSiblingForAnonymousBlock(const nsIFrame* aFrame) * property. */ nsIFrame *ibSplitSibling = - aFrame->Properties().Get(nsIFrame::IBSplitPrevSibling()); + aFrame->GetProperty(nsIFrame::IBSplitPrevSibling()); NS_ASSERTION(ibSplitSibling, "Broken frame tree?"); return ibSplitSibling; } @@ -9825,7 +9816,7 @@ nsFrame::BoxReflow(nsBoxLayoutState& aState, nsBoxLayoutMetrics* nsFrame::BoxMetrics() const { - nsBoxLayoutMetrics* metrics = Properties().Get(BoxMetricsProperty()); + nsBoxLayoutMetrics* metrics = GetProperty(BoxMetricsProperty()); NS_ASSERTION(metrics, "A box layout method was called but InitBoxMetrics was never called"); return metrics; } @@ -10069,6 +10060,24 @@ nsFrame::HasCSSTransitions() return collection && collection->mAnimations.Length() > 0; } +size_t +nsIFrame::SizeOfFramePropertiesForTree(MallocSizeOf aMallocSizeOf) const +{ + size_t result = 0; + + result += mProperties.SizeOfExcludingThis(aMallocSizeOf); + + FrameChildListIterator iter(this); + while (!iter.IsDone()) { + for (const nsIFrame* f : iter.CurrentList()) { + result += f->SizeOfFramePropertiesForTree(aMallocSizeOf); + } + iter.Next(); + } + + return result; +} + // Box layout debugging #ifdef DEBUG_REFLOW int32_t gIndent2 = 0; diff --git a/layout/generic/nsGridContainerFrame.cpp b/layout/generic/nsGridContainerFrame.cpp index fbd61f783..3a2d5ad1d 100644 --- a/layout/generic/nsGridContainerFrame.cpp +++ b/layout/generic/nsGridContainerFrame.cpp @@ -2000,7 +2000,7 @@ struct MOZ_STACK_CLASS nsGridContainerFrame::GridReflowInput ++fragment; firstInFlow = pif; } - mSharedGridData = firstInFlow->Properties().Get(SharedGridData::Prop()); + mSharedGridData = firstInFlow->GetProperty(SharedGridData::Prop()); MOZ_ASSERT(mSharedGridData, "first-in-flow must have SharedGridData"); // Find the start row for this fragment and undo breaks after that row @@ -2809,7 +2809,7 @@ nsGridContainerFrame::GridItemCB(nsIFrame* aChild) { MOZ_ASSERT((aChild->GetStateBits() & NS_FRAME_OUT_OF_FLOW) && aChild->IsAbsolutelyPositioned()); - nsRect* cb = aChild->Properties().Get(GridItemContainingBlockRect()); + nsRect* cb = aChild->GetProperty(GridItemContainingBlockRect()); MOZ_ASSERT(cb, "this method must only be called on grid items, and the grid " "container should've reflowed this item by now and set up cb"); return *cb; @@ -2836,7 +2836,7 @@ nsGridContainerFrame::AddImplicitNamedAreas( // Lazily create the ImplicitNamedAreas. if (!areas) { areas = new ImplicitNamedAreas; - Properties().Set(ImplicitNamedAreasProperty(), areas); + SetProperty(ImplicitNamedAreasProperty(), areas); } mozilla::css::GridNamedArea area; @@ -2868,7 +2868,7 @@ nsGridContainerFrame::InitImplicitNamedAreas(const nsStylePosition* aStyle) AddImplicitNamedAreas(aStyle->mGridTemplateColumns.mLineNameLists); AddImplicitNamedAreas(aStyle->mGridTemplateRows.mLineNameLists); if (areas && areas->Count() == 0) { - Properties().Delete(ImplicitNamedAreasProperty()); + DeleteProperty(ImplicitNamedAreasProperty()); } } @@ -3711,7 +3711,7 @@ MeasuringReflow(nsIFrame* aChild, } #ifdef DEBUG // This will suppress various CRAZY_SIZE warnings for this reflow. - parent->Properties().Set( + parent->SetProperty( nsContainerFrame::DebugReflowingWithInfiniteISize(), true); #endif auto wm = aChild->GetWritingMode(); @@ -3724,10 +3724,10 @@ MeasuringReflow(nsIFrame* aChild, } if (aBMinSizeClamp != NS_MAXSIZE) { riFlags |= ReflowInput::B_CLAMP_MARGIN_BOX_MIN_SIZE; - aChild->Properties().Set(nsIFrame::BClampMarginBoxMinSizeProperty(), + aChild->SetProperty(nsIFrame::BClampMarginBoxMinSizeProperty(), aBMinSizeClamp); } else { - aChild->Properties().Delete(nsIFrame::BClampMarginBoxMinSizeProperty()); + aChild->DeleteProperty(nsIFrame::BClampMarginBoxMinSizeProperty()); } ReflowInput childRI(pc, *rs, aChild, aAvailableSize, &aCBSize, riFlags); ReflowOutput childSize(childRI); @@ -3738,7 +3738,7 @@ MeasuringReflow(nsIFrame* aChild, parent->FinishReflowChild(aChild, pc, childSize, &childRI, wm, LogicalPoint(wm), nsSize(), flags); #ifdef DEBUG - parent->Properties().Delete(nsContainerFrame::DebugReflowingWithInfiniteISize()); + parent->DeleteProperty(nsContainerFrame::DebugReflowingWithInfiniteISize()); #endif return childSize.BSize(wm); } @@ -5253,9 +5253,9 @@ nsGridContainerFrame::ReflowInFlowChild(nsIFrame* aChild, baselineAdjust = -baselineAdjust; } if (baselineAdjust != nscoord(0)) { - aChild->Properties().Set(aProp, baselineAdjust); + aChild->SetProperty(aProp, baselineAdjust); } else { - aChild->Properties().Delete(aProp); + aChild->DeleteProperty(aProp); } }; SetProp(eLogicalAxisBlock, isOrthogonal ? IBaselinePadProperty() : @@ -5292,10 +5292,10 @@ nsGridContainerFrame::ReflowInFlowChild(nsIFrame* aChild, auto childBAxis = GetOrthogonalAxis(childIAxis); if (aGridItemInfo->mState[childBAxis] & ItemState::eClampMarginBoxMinSize) { flags |= ReflowInput::B_CLAMP_MARGIN_BOX_MIN_SIZE; - aChild->Properties().Set(BClampMarginBoxMinSizeProperty(), - childCBSize.BSize(childWM)); + aChild->SetProperty(BClampMarginBoxMinSizeProperty(), + childCBSize.BSize(childWM)); } else { - aChild->Properties().Delete(BClampMarginBoxMinSizeProperty()); + aChild->DeleteProperty(BClampMarginBoxMinSizeProperty()); } if ((aGridItemInfo->mState[childIAxis] & ItemState::eApplyAutoMinSize)) { flags |= ReflowInput::I_APPLY_AUTO_MIN_SIZE; @@ -5313,11 +5313,11 @@ nsGridContainerFrame::ReflowInFlowChild(nsIFrame* aChild, // A table-wrapper needs to propagate the CB size we give it to its // inner table frame later. @see nsTableWrapperFrame::InitChildReflowInput. if (childType == nsGkAtoms::tableWrapperFrame) { - const auto& props = aChild->Properties(); - LogicalSize* cb = props.Get(nsTableWrapperFrame::GridItemCBSizeProperty()); + LogicalSize* cb = + aChild->GetProperty(nsTableWrapperFrame::GridItemCBSizeProperty()); if (!cb) { cb = new LogicalSize(childWM); - props.Set(nsTableWrapperFrame::GridItemCBSizeProperty(), cb); + aChild->SetProperty(nsTableWrapperFrame::GridItemCBSizeProperty(), cb); } *cb = percentBasis; } @@ -5337,9 +5337,9 @@ nsGridContainerFrame::ReflowInFlowChild(nsIFrame* aChild, } } if (stretch) { - aChild->Properties().Set(FragStretchBSizeProperty(), *aStretchBSize); + aChild->SetProperty(FragStretchBSizeProperty(), *aStretchBSize); } else { - aChild->Properties().Delete(FragStretchBSizeProperty()); + aChild->DeleteProperty(FragStretchBSizeProperty()); } } @@ -5951,10 +5951,10 @@ nsGridContainerFrame::ReflowChildren(GridReflowInput& aState, LogicalRect itemCB = aState.ContainingBlockForAbsPos(area, gridOrigin, gridCB); // nsAbsoluteContainingBlock::Reflow uses physical coordinates. - nsRect* cb = child->Properties().Get(GridItemContainingBlockRect()); + nsRect* cb = child->GetProperty(GridItemContainingBlockRect()); if (!cb) { cb = new nsRect; - child->Properties().Set(GridItemContainingBlockRect(), cb); + child->SetProperty(GridItemContainingBlockRect(), cb); } *cb = itemCB.GetPhysicalRect(wm, gridCBPhysicalSize); } @@ -6044,7 +6044,7 @@ nsGridContainerFrame::Reflow(nsPresContext* aPresContext, f = next; } if (overflowContainers->IsEmpty()) { - Properties().Delete(OverflowContainersProperty()); + DeleteProperty(OverflowContainersProperty()); } MergeSortedExcessOverflowContainers(moveToEOC); } @@ -6355,7 +6355,7 @@ nsGridContainerFrame::Reflow(nsPresContext* aPresContext, Move(colTrackStates), Move(colRemovedRepeatTracks), gridReflowInput.mColFunctions.mRepeatAutoStart); - Properties().Set(GridColTrackInfo(), colInfo); + SetProperty(GridColTrackInfo(), colInfo); uint32_t rowTrackCount = gridReflowInput.mRows.mSizes.Length(); nsTArray rowTrackPositions(rowTrackCount); @@ -6390,7 +6390,7 @@ nsGridContainerFrame::Reflow(nsPresContext* aPresContext, Move(rowTrackStates), Move(rowRemovedRepeatTracks), gridReflowInput.mRowFunctions.mRepeatAutoStart); - Properties().Set(GridRowTrackInfo(), rowInfo); + SetProperty(GridRowTrackInfo(), rowInfo); if (prevInFlow) { // This frame is fragmenting rows from a previous frame, so patch up @@ -6399,7 +6399,7 @@ nsGridContainerFrame::Reflow(nsPresContext* aPresContext, // FIXME: This can be streamlined and/or removed when bug 1151204 lands. ComputedGridTrackInfo* priorRowInfo = - prevInFlow->Properties().Get(GridRowTrackInfo()); + prevInFlow->GetProperty(GridRowTrackInfo()); // Adjust track positions based on the first track in this fragment. if (priorRowInfo->mPositions.Length() > @@ -6421,7 +6421,7 @@ nsGridContainerFrame::Reflow(nsPresContext* aPresContext, Move(priorRowInfo->mStates), Move(priorRowInfo->mRemovedRepeatTracks), priorRowInfo->mRepeatFirstTrack); - prevInFlow->Properties().Set(GridRowTrackInfo(), revisedPriorRowInfo); + prevInFlow->SetProperty(GridRowTrackInfo(), revisedPriorRowInfo); } // Generate the line info properties. We need to provide the number of @@ -6448,7 +6448,7 @@ nsGridContainerFrame::Reflow(nsPresContext* aPresContext, Move(columnLineNames), gridColTemplate.mRepeatAutoLineNameListBefore, gridColTemplate.mRepeatAutoLineNameListAfter); - Properties().Set(GridColumnLineInfo(), columnLineInfo); + SetProperty(GridColumnLineInfo(), columnLineInfo); // Generate row lines next. capacity = gridReflowInput.mRows.mSizes.Length(); @@ -6469,25 +6469,25 @@ nsGridContainerFrame::Reflow(nsPresContext* aPresContext, Move(rowLineNames), gridRowTemplate.mRepeatAutoLineNameListBefore, gridRowTemplate.mRepeatAutoLineNameListAfter); - Properties().Set(GridRowLineInfo(), rowLineInfo); + SetProperty(GridRowLineInfo(), rowLineInfo); // Generate area info for explicit areas. Implicit areas are handled // elsewhere. if (gridReflowInput.mGridStyle->mGridTemplateAreas) { nsTArray* areas = new nsTArray( gridReflowInput.mGridStyle->mGridTemplateAreas->mNamedAreas); - Properties().Set(ExplicitNamedAreasProperty(), areas); + SetProperty(ExplicitNamedAreasProperty(), areas); } else { - Properties().Delete(ExplicitNamedAreasProperty()); + DeleteProperty(ExplicitNamedAreasProperty()); } } if (!prevInFlow) { - SharedGridData* sharedGridData = Properties().Get(SharedGridData::Prop()); + SharedGridData* sharedGridData = GetProperty(SharedGridData::Prop()); if (!NS_FRAME_IS_FULLY_COMPLETE(aStatus)) { if (!sharedGridData) { sharedGridData = new SharedGridData; - Properties().Set(SharedGridData::Prop(), sharedGridData); + SetProperty(SharedGridData::Prop(), sharedGridData); } sharedGridData->mCols.mSizes.Clear(); sharedGridData->mCols.mSizes.SwapElements(gridReflowInput.mCols.mSizes); @@ -6522,7 +6522,7 @@ nsGridContainerFrame::Reflow(nsPresContext* aPresContext, sharedGridData->mGenerateComputedGridInfo = HasAnyStateBits(NS_STATE_GRID_GENERATE_COMPUTED_VALUES); } else if (sharedGridData && !GetNextInFlow()) { - Properties().Delete(SharedGridData::Prop()); + DeleteProperty(SharedGridData::Prop()); } } @@ -7142,10 +7142,10 @@ nsGridContainerFrame::GetGridFrameWithComputedInfo(nsIFrame* aFrame) nsGridContainerFrame* gridFrame = GetGridContainerFrame(aFrame); if (gridFrame) { // if any of our properties are missing, generate them - bool reflowNeeded = (!gridFrame->Properties().Has(GridColTrackInfo()) || - !gridFrame->Properties().Has(GridRowTrackInfo()) || - !gridFrame->Properties().Has(GridColumnLineInfo()) || - !gridFrame->Properties().Has(GridRowLineInfo())); + bool reflowNeeded = (!gridFrame->HasProperty(GridColTrackInfo()) || + !gridFrame->HasProperty(GridRowTrackInfo()) || + !gridFrame->HasProperty(GridColumnLineInfo()) || + !gridFrame->HasProperty(GridRowLineInfo())); if (reflowNeeded) { // Trigger a reflow that generates additional grid property data. @@ -7161,13 +7161,13 @@ nsGridContainerFrame::GetGridFrameWithComputedInfo(nsIFrame* aFrame) // Assert the grid properties are present MOZ_ASSERT(!gridFrame || - gridFrame->Properties().Has(GridColTrackInfo())); + gridFrame->HasProperty(GridColTrackInfo())); MOZ_ASSERT(!gridFrame || - gridFrame->Properties().Has(GridRowTrackInfo())); + gridFrame->HasProperty(GridRowTrackInfo())); MOZ_ASSERT(!gridFrame || - gridFrame->Properties().Has(GridColumnLineInfo())); + gridFrame->HasProperty(GridColumnLineInfo())); MOZ_ASSERT(!gridFrame || - gridFrame->Properties().Has(GridRowLineInfo())); + gridFrame->HasProperty(GridRowLineInfo())); } } diff --git a/layout/generic/nsGridContainerFrame.h b/layout/generic/nsGridContainerFrame.h index e610dfa0b..960558421 100644 --- a/layout/generic/nsGridContainerFrame.h +++ b/layout/generic/nsGridContainerFrame.h @@ -164,7 +164,7 @@ public: NS_DECLARE_FRAME_PROPERTY_DELETABLE(GridColTrackInfo, ComputedGridTrackInfo) const ComputedGridTrackInfo* GetComputedTemplateColumns() { - const ComputedGridTrackInfo* info = Properties().Get(GridColTrackInfo()); + const ComputedGridTrackInfo* info = GetProperty(GridColTrackInfo()); MOZ_ASSERT(info, "Property generation wasn't requested."); return info; } @@ -172,7 +172,7 @@ public: NS_DECLARE_FRAME_PROPERTY_DELETABLE(GridRowTrackInfo, ComputedGridTrackInfo) const ComputedGridTrackInfo* GetComputedTemplateRows() { - const ComputedGridTrackInfo* info = Properties().Get(GridRowTrackInfo()); + const ComputedGridTrackInfo* info = GetProperty(GridRowTrackInfo()); MOZ_ASSERT(info, "Property generation wasn't requested."); return info; } @@ -180,7 +180,7 @@ public: NS_DECLARE_FRAME_PROPERTY_DELETABLE(GridColumnLineInfo, ComputedGridLineInfo) const ComputedGridLineInfo* GetComputedTemplateColumnLines() { - const ComputedGridLineInfo* info = Properties().Get(GridColumnLineInfo()); + const ComputedGridLineInfo* info = GetProperty(GridColumnLineInfo()); MOZ_ASSERT(info, "Property generation wasn't requested."); return info; } @@ -188,7 +188,7 @@ public: NS_DECLARE_FRAME_PROPERTY_DELETABLE(GridRowLineInfo, ComputedGridLineInfo) const ComputedGridLineInfo* GetComputedTemplateRowLines() { - const ComputedGridLineInfo* info = Properties().Get(GridRowLineInfo()); + const ComputedGridLineInfo* info = GetProperty(GridRowLineInfo()); MOZ_ASSERT(info, "Property generation wasn't requested."); return info; } @@ -199,14 +199,14 @@ public: NS_DECLARE_FRAME_PROPERTY_DELETABLE(ImplicitNamedAreasProperty, ImplicitNamedAreas) ImplicitNamedAreas* GetImplicitNamedAreas() const { - return Properties().Get(ImplicitNamedAreasProperty()); + return GetProperty(ImplicitNamedAreasProperty()); } typedef nsTArray ExplicitNamedAreas; NS_DECLARE_FRAME_PROPERTY_DELETABLE(ExplicitNamedAreasProperty, ExplicitNamedAreas) ExplicitNamedAreas* GetExplicitNamedAreas() const { - return Properties().Get(ExplicitNamedAreasProperty()); + return GetProperty(ExplicitNamedAreasProperty()); } /** diff --git a/layout/generic/nsIFrame.h b/layout/generic/nsIFrame.h index 2acafa882..37a4e3749 100644 --- a/layout/generic/nsIFrame.h +++ b/layout/generic/nsIFrame.h @@ -24,7 +24,7 @@ #include #include "CaretAssociationHint.h" -#include "FramePropertyTable.h" +#include "FrameProperties.h" #include "mozilla/layout/FrameChildList.h" #include "mozilla/Maybe.h" #include "mozilla/WritingModes.h" @@ -1005,8 +1005,8 @@ public: #define NS_DECLARE_FRAME_PROPERTY_SMALL_VALUE(prop, type) \ NS_DECLARE_FRAME_PROPERTY_WITHOUT_DTOR(prop, mozilla::SmallValueHolder) - NS_DECLARE_FRAME_PROPERTY_WITHOUT_DTOR(IBSplitSibling, nsIFrame) - NS_DECLARE_FRAME_PROPERTY_WITHOUT_DTOR(IBSplitPrevSibling, nsIFrame) + 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_DELETABLE(ComputedOffsetProperty, nsMargin) @@ -1059,7 +1059,7 @@ public: mozilla::FrameBidiData GetBidiData() { - return Properties().Get(BidiDataProperty()); + return GetProperty(BidiDataProperty()); } nsBidiLevel GetBaseLevel() @@ -1073,7 +1073,7 @@ public: } nsTArray* GetGenConPseudos() { - return Properties().Get(GenConProperty()); + return GetProperty(GenConProperty()); } /** @@ -1534,7 +1534,7 @@ public: bool RefusedAsyncAnimation() const { - return Properties().Get(RefusedAsyncAnimationProperty()); + return GetProperty(RefusedAsyncAnimationProperty()); } /** @@ -3061,9 +3061,53 @@ public: return mContent == aParentContent; } - FrameProperties Properties() const { - return FrameProperties(PresContext()->PropertyTable(), this); - } +/** + * Support for reading and writing properties on the frame. + * These call through to the frame's FrameProperties object, if it + * exists, but avoid creating it if no property is ever set. + */ +template +FrameProperties::PropertyType +GetProperty(FrameProperties::Descriptor aProperty, + bool* aFoundResult = nullptr) const +{ + return mProperties.Get(aProperty, aFoundResult); +} + +template +bool HasProperty(FrameProperties::Descriptor aProperty) const +{ + return mProperties.Has(aProperty); +} + +template +void SetProperty(FrameProperties::Descriptor aProperty, + FrameProperties::PropertyType aValue) +{ + mProperties.Set(aProperty, aValue, this); +} + +template +FrameProperties::PropertyType +RemoveProperty(FrameProperties::Descriptor aProperty, + bool* aFoundResult = nullptr) +{ + return mProperties.Remove(aProperty, aFoundResult); +} + +template +void DeleteProperty(FrameProperties::Descriptor aProperty) +{ + mProperties.Delete(aProperty, this); +} + +void DeleteAllProperties() +{ + mProperties.DeleteAll(this); +} + +// Reports size of the FrameProperties for this frame and its descendants +size_t SizeOfFramePropertiesForTree(mozilla::MallocSizeOf aMallocSizeOf) const; /** * Return true if and only if this frame obeys visibility:hidden. @@ -3423,7 +3467,7 @@ public: */ bool FrameIsNonFirstInIBSplit() const { return (GetStateBits() & NS_FRAME_PART_OF_IBSPLIT) && - FirstContinuation()->Properties().Get(nsIFrame::IBSplitPrevSibling()); + FirstContinuation()->GetProperty(nsIFrame::IBSplitPrevSibling()); } /** @@ -3432,7 +3476,7 @@ public: */ bool FrameIsNonLastInIBSplit() const { return (GetStateBits() & NS_FRAME_PART_OF_IBSPLIT) && - FirstContinuation()->Properties().Get(nsIFrame::IBSplitSibling()); + FirstContinuation()->GetProperty(nsIFrame::IBSplitSibling()); } /** @@ -3514,11 +3558,11 @@ private: DestroyPaintedPresShellList) nsTArray* PaintedPresShellList() { - nsTArray* list = Properties().Get(PaintedPresShellsProperty()); + nsTArray* list = GetProperty(PaintedPresShellsProperty()); if (!list) { list = new nsTArray(); - Properties().Set(PaintedPresShellsProperty(), list); + SetProperty(PaintedPresShellsProperty(), list); } return list; @@ -3535,6 +3579,11 @@ protected: nsFrameState mState; + /** + * List of properties attached to the frame. + */ + FrameProperties mProperties; + // When there is an overflow area only slightly larger than mRect, // we store a set of four 1-byte deltas from the edges of mRect // rather than allocating a whole separate rectangle property. diff --git a/layout/generic/nsLineLayout.cpp b/layout/generic/nsLineLayout.cpp index 138d0b871..6a15a9cfa 100644 --- a/layout/generic/nsLineLayout.cpp +++ b/layout/generic/nsLineLayout.cpp @@ -819,11 +819,11 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame, #endif if (mCurrentSpan == mRootSpan) { - pfd->mFrame->Properties().Remove(nsIFrame::LineBaselineOffset()); + pfd->mFrame->RemoveProperty(nsIFrame::LineBaselineOffset()); } else { #ifdef DEBUG bool hasLineOffset; - pfd->mFrame->Properties().Get(nsIFrame::LineBaselineOffset(), &hasLineOffset); + pfd->mFrame->GetProperty(nsIFrame::LineBaselineOffset(), &hasLineOffset); NS_ASSERTION(!hasLineOffset, "LineBaselineOffset was set but was not expected"); #endif } diff --git a/layout/generic/nsPlaceholderFrame.cpp b/layout/generic/nsPlaceholderFrame.cpp index 2b6799f48..bd380a2d9 100644 --- a/layout/generic/nsPlaceholderFrame.cpp +++ b/layout/generic/nsPlaceholderFrame.cpp @@ -128,7 +128,7 @@ nsPlaceholderFrame::Reflow(nsPresContext* aPresContext, nsIFrame* ancestor = this; while ((ancestor = ancestor->GetParent())) { if (ancestor->GetPrevContinuation() || - ancestor->Properties().Get(IBSplitPrevSibling())) { + ancestor->GetProperty(IBSplitPrevSibling())) { isInContinuationOrIBSplit = true; break; } diff --git a/layout/generic/nsTextFrame.cpp b/layout/generic/nsTextFrame.cpp index 3288d3f2e..0641c7439 100644 --- a/layout/generic/nsTextFrame.cpp +++ b/layout/generic/nsTextFrame.cpp @@ -2838,9 +2838,9 @@ nsTextFrame::EnsureTextRun(TextRunType aWhichTextRun, return gfxSkipCharsIterator(gfxPlatform:: GetPlatform()->EmptySkipChars(), 0); } - TabWidthStore* tabWidths = Properties().Get(TabWidthProperty()); + TabWidthStore* tabWidths = GetProperty(TabWidthProperty()); if (tabWidths && tabWidths->mValidForContentOffset != GetContentOffset()) { - Properties().Delete(TabWidthProperty()); + DeleteProperty(TabWidthProperty()); } } @@ -3478,7 +3478,7 @@ PropertyProvider::CalcTabWidths(Range aRange) return; } if (!mReflowing) { - mTabWidths = mFrame->Properties().Get(TabWidthProperty()); + mTabWidths = mFrame->GetProperty(TabWidthProperty()); #ifdef DEBUG // If we're not reflowing, we should have already computed the // tab widths; check that they're available as far as the last @@ -3524,7 +3524,7 @@ PropertyProvider::CalcTabWidths(Range aRange) } else { if (!mTabWidths) { mTabWidths = new TabWidthStore(mFrame->GetContentOffset()); - mFrame->Properties().Set(TabWidthProperty(), mTabWidths); + mFrame->SetProperty(TabWidthProperty(), mTabWidths); } double nextTab = AdvanceToNextTab(mOffsetFromBlockOriginForTabs, mFrame, mTextRun, &tabWidth); @@ -3543,7 +3543,7 @@ PropertyProvider::CalcTabWidths(Range aRange) if (!mTabWidths) { // Delete any stale property that may be left on the frame - mFrame->Properties().Delete(TabWidthProperty()); + mFrame->DeleteProperty(TabWidthProperty()); mTabWidthsAnalyzedLimit = std::max(mTabWidthsAnalyzedLimit, aRange.end - startOffset); } @@ -4249,7 +4249,7 @@ nsTextFrame::ClearFrameOffsetCache() // just destroys the frames in order, which means that the primary frame is already // dead if we're a continuing text frame, in which case, all of its properties are // gone, and we don't need to worry about deleting this property here. - primaryFrame->Properties().Delete(OffsetToFrameProperty()); + primaryFrame->DeleteProperty(OffsetToFrameProperty()); } RemoveStateBits(TEXT_IN_OFFSET_CACHE); } @@ -4358,7 +4358,7 @@ nsContinuingTextFrame::Init(nsIContent* aContent, if (aPrevInFlow->GetStateBits() & NS_FRAME_IS_BIDI) { FrameBidiData bidiData = aPrevInFlow->GetBidiData(); bidiData.precedingControl = kBidiLevelNone; - Properties().Set(BidiDataProperty(), bidiData); + SetProperty(BidiDataProperty(), bidiData); if (nextContinuation) { SetNextContinuation(nextContinuation); @@ -4622,7 +4622,7 @@ nsTextFrame::InvalidateFrameWithRect(const nsRect& aRect, uint32_t aDisplayItemK gfxTextRun* nsTextFrame::GetUninflatedTextRun() { - return Properties().Get(UninflatedTextRunProperty()); + return GetProperty(UninflatedTextRunProperty()); } void @@ -4648,7 +4648,7 @@ nsTextFrame::SetTextRun(gfxTextRun* aTextRun, TextRunType aWhichTextRun, // Setting the property will not automatically increment the textrun's // reference count, so we need to do it here. aTextRun->AddRef(); - Properties().Set(UninflatedTextRunProperty(), aTextRun); + SetProperty(UninflatedTextRunProperty(), aTextRun); return; } // fall through to setting mTextRun @@ -4668,10 +4668,9 @@ nsTextFrame::RemoveTextRun(gfxTextRun* aTextRun) mTextRun = nullptr; return true; } - FrameProperties props = Properties(); if ((GetStateBits() & TEXT_HAS_FONT_INFLATION) && - props.Get(UninflatedTextRunProperty()) == aTextRun) { - props.Delete(UninflatedTextRunProperty()); + GetProperty(UninflatedTextRunProperty()) == aTextRun) { + DeleteProperty(UninflatedTextRunProperty()); return true; } return false; @@ -4689,7 +4688,7 @@ nsTextFrame::ClearTextRun(nsTextFrame* aStartContinuation, DebugOnly checkmTextrun = textRun == mTextRun; UnhookTextRunFromFrames(textRun, aStartContinuation); MOZ_ASSERT(checkmTextrun ? !mTextRun - : !Properties().Get(UninflatedTextRunProperty())); + : !GetProperty(UninflatedTextRunProperty())); } void @@ -4699,7 +4698,7 @@ nsTextFrame::DisconnectTextRuns() "Textrun mentions this frame in its user data so we can't just disconnect"); mTextRun = nullptr; if ((GetStateBits() & TEXT_HAS_FONT_INFLATION)) { - Properties().Delete(UninflatedTextRunProperty()); + DeleteProperty(UninflatedTextRunProperty()); } } @@ -4929,7 +4928,7 @@ NS_DECLARE_FRAME_PROPERTY_SMALL_VALUE(TextCombineScaleFactorProperty, float) static float GetTextCombineScaleFactor(nsTextFrame* aFrame) { - float factor = aFrame->Properties().Get(TextCombineScaleFactorProperty()); + float factor = aFrame->GetProperty(TextCombineScaleFactorProperty()); return factor ? factor : 1.0f; } @@ -5105,7 +5104,7 @@ static nscoord LazyGetLineBaselineOffset(nsIFrame* aChildFrame, nsBlockFrame* aBlockFrame) { bool offsetFound; - nscoord offset = aChildFrame->Properties().Get( + nscoord offset = aChildFrame->GetProperty( nsIFrame::LineBaselineOffset(), &offsetFound); if (!offsetFound) { @@ -5118,11 +5117,11 @@ LazyGetLineBaselineOffset(nsIFrame* aChildFrame, nsBlockFrame* aBlockFrame) for (nsIFrame* lineFrame = line->mFirstChild; n > 0; lineFrame = lineFrame->GetNextSibling(), --n) { offset = lineBaseline - lineFrame->GetNormalPosition().y; - lineFrame->Properties().Set(nsIFrame::LineBaselineOffset(), offset); + lineFrame->SetProperty(nsIFrame::LineBaselineOffset(), offset); } } } - return aChildFrame->Properties().Get( + return aChildFrame->GetProperty( nsIFrame::LineBaselineOffset(), &offsetFound); } else { return offset; @@ -5367,7 +5366,7 @@ nsTextFrame::UpdateTextEmphasis(WritingMode aWM, PropertyProvider& aProvider) { const nsStyleText* styleText = StyleText(); if (!styleText->HasTextEmphasis()) { - Properties().Delete(EmphasisMarkProperty()); + DeleteProperty(EmphasisMarkProperty()); return nsRect(); } @@ -5419,7 +5418,7 @@ nsTextFrame::UpdateTextEmphasis(WritingMode aWM, PropertyProvider& aProvider) overflowRect.BStart(aWM) += gap * (side == eLogicalSideBStart ? -1 : 1); } - Properties().Set(EmphasisMarkProperty(), info); + SetProperty(EmphasisMarkProperty(), info); return overflowRect.GetPhysicalRect(aWM, frameSize.GetPhysicalSize(aWM)); } @@ -6432,7 +6431,7 @@ nsTextFrame::DrawEmphasisMarks(gfxContext* aContext, WritingMode aWM, const nscolor* aDecorationOverrideColor, PropertyProvider* aProvider) { - const EmphasisMarkInfo* info = Properties().Get(EmphasisMarkProperty()); + const EmphasisMarkInfo* info = GetProperty(EmphasisMarkProperty()); if (!info) { return; } @@ -7584,7 +7583,7 @@ nsTextFrame::GetChildFrameContainingOffset(int32_t aContentOffset, int32_t offset = mContentOffset; // Try to look up the offset to frame property - nsTextFrame* cachedFrame = Properties().Get(OffsetToFrameProperty()); + nsTextFrame* cachedFrame = GetProperty(OffsetToFrameProperty()); if (cachedFrame) { f = cachedFrame; @@ -7632,7 +7631,7 @@ nsTextFrame::GetChildFrameContainingOffset(int32_t aContentOffset, *aOutFrame = f; // cache the frame we found - Properties().Set(OffsetToFrameProperty(), f); + SetProperty(OffsetToFrameProperty(), f); f->AddStateBits(TEXT_IN_OFFSET_CACHE); return NS_OK; @@ -8169,7 +8168,7 @@ nsTextFrame::GetFontSizeInflation() const if (!HasFontSizeInflation()) { return 1.0f; } - return Properties().Get(FontSizeInflationProperty()); + return GetProperty(FontSizeInflationProperty()); } void @@ -8178,13 +8177,13 @@ nsTextFrame::SetFontSizeInflation(float aInflation) if (aInflation == 1.0f) { if (HasFontSizeInflation()) { RemoveStateBits(TEXT_HAS_FONT_INFLATION); - Properties().Delete(FontSizeInflationProperty()); + DeleteProperty(FontSizeInflationProperty()); } return; } AddStateBits(TEXT_HAS_FONT_INFLATION); - Properties().Set(FontSizeInflationProperty(), aInflation); + SetProperty(FontSizeInflationProperty(), aInflation); } /* virtual */ @@ -9319,9 +9318,9 @@ nsTextFrame::ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth, gfxFloat em = fm->EmHeight(); // Compress the characters in horizontal axis if necessary. if (width <= em) { - Properties().Remove(TextCombineScaleFactorProperty()); + RemoveProperty(TextCombineScaleFactorProperty()); } else { - Properties().Set(TextCombineScaleFactorProperty(), em / width); + SetProperty(TextCombineScaleFactorProperty(), em / width); finalSize.ISize(wm) = em; } // Make the characters be in an 1em square. @@ -10049,13 +10048,13 @@ nsTextFrame::AssignJustificationGaps( static_assert(sizeof(aAssign) == 1, "The encoding might be broken if JustificationAssignment " "is larger than 1 byte"); - Properties().Set(JustificationAssignmentProperty(), encoded); + SetProperty(JustificationAssignmentProperty(), encoded); } mozilla::JustificationAssignment nsTextFrame::GetJustificationAssignment() const { - int32_t encoded = Properties().Get(JustificationAssignmentProperty()); + int32_t encoded = GetProperty(JustificationAssignmentProperty()); mozilla::JustificationAssignment result; result.mGapsAtStart = encoded >> 8; result.mGapsAtEnd = encoded & 0xFF; -- cgit v1.2.3