mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-02 21:37:32 +09:00
Bug 1368547 - Remove nsFrameManagerBase::mPlaceholderMap and instead store the placeholder on a frame property on the out-of-flow
Tag #1375
This commit is contained in:
parent
854827bd83
commit
9b868f0298
18 changed files with 52 additions and 166 deletions
|
|
@ -692,10 +692,9 @@ nsAbsoluteItems::nsAbsoluteItems(nsContainerFrame* aContainingBlock)
|
|||
void
|
||||
nsAbsoluteItems::AddChild(nsIFrame* aChild)
|
||||
{
|
||||
NS_ASSERTION(aChild->PresContext()->FrameManager()->
|
||||
GetPlaceholderFrameFor(aChild),
|
||||
"Child without placeholder being added to nsAbsoluteItems?");
|
||||
aChild->AddStateBits(NS_FRAME_OUT_OF_FLOW);
|
||||
NS_ASSERTION(aChild->GetPlaceholderFrame(),
|
||||
"Child without placeholder being added to nsAbsoluteItems?");
|
||||
nsFrameItems::AddChild(aChild);
|
||||
}
|
||||
|
||||
|
|
@ -3032,14 +3031,12 @@ nsCSSFrameConstructor::CreatePlaceholderFrameFor(nsIPresShell* aPresShell,
|
|||
|
||||
placeholderFrame->Init(aContent, aParentFrame, aPrevInFlow);
|
||||
|
||||
// The placeholder frame has a pointer back to the out-of-flow frame
|
||||
// Associate the placeholder/out-of-flow with each other.
|
||||
placeholderFrame->SetOutOfFlowFrame(aFrame);
|
||||
aFrame->SetProperty(nsIFrame::PlaceholderFrameProperty(), placeholderFrame);
|
||||
|
||||
aFrame->AddStateBits(NS_FRAME_OUT_OF_FLOW);
|
||||
|
||||
// Add mapping from absolutely positioned frame to its placeholder frame
|
||||
aPresShell->FrameManager()->RegisterPlaceholderFrame(placeholderFrame);
|
||||
|
||||
return placeholderFrame;
|
||||
}
|
||||
|
||||
|
|
@ -6702,7 +6699,7 @@ nsCSSFrameConstructor::FindFrameForContentSibling(nsIContent* aContent,
|
|||
// If the frame is out-of-flow, GetPrimaryFrame() will have returned the
|
||||
// out-of-flow frame; we want the placeholder.
|
||||
if (sibling->GetStateBits() & NS_FRAME_OUT_OF_FLOW) {
|
||||
nsIFrame* placeholderFrame = GetPlaceholderFrameFor(sibling);
|
||||
nsIFrame* placeholderFrame = sibling->GetPlaceholderFrame();
|
||||
NS_ASSERTION(placeholderFrame, "no placeholder for out-of-flow frame");
|
||||
sibling = placeholderFrame;
|
||||
}
|
||||
|
|
@ -7968,7 +7965,7 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer,
|
|||
// the placeholder frame.
|
||||
if (insertion.mParentFrame->GetStateBits() & NS_FRAME_OUT_OF_FLOW) {
|
||||
nsPlaceholderFrame* placeholderFrame =
|
||||
GetPlaceholderFrameFor(insertion.mParentFrame);
|
||||
insertion.mParentFrame->GetPlaceholderFrame();
|
||||
NS_ASSERTION(placeholderFrame, "No placeholder for out-of-flow?");
|
||||
insertion.mParentFrame = placeholderFrame->GetParent();
|
||||
} else {
|
||||
|
|
@ -8456,7 +8453,7 @@ nsCSSFrameConstructor::ContentRemoved(nsIContent* aContainer,
|
|||
// :first-letter style applies.
|
||||
nsIFrame* inflowChild = childFrame;
|
||||
if (childFrame->GetStateBits() & NS_FRAME_OUT_OF_FLOW) {
|
||||
inflowChild = GetPlaceholderFrameFor(childFrame);
|
||||
inflowChild = childFrame->GetPlaceholderFrame();
|
||||
NS_ASSERTION(inflowChild, "No placeholder for out-of-flow?");
|
||||
}
|
||||
nsContainerFrame* containingBlock =
|
||||
|
|
@ -8512,7 +8509,7 @@ nsCSSFrameConstructor::ContentRemoved(nsIContent* aContainer,
|
|||
|
||||
// Notify the parent frame that it should delete the frame
|
||||
if (childFrame->GetStateBits() & NS_FRAME_OUT_OF_FLOW) {
|
||||
childFrame = GetPlaceholderFrameFor(childFrame);
|
||||
childFrame = childFrame->GetPlaceholderFrame();
|
||||
NS_ASSERTION(childFrame, "Missing placeholder frame for out of flow.");
|
||||
parentFrame = childFrame->GetParent();
|
||||
}
|
||||
|
|
@ -9153,7 +9150,7 @@ nsCSSFrameConstructor::ReplicateFixedFrames(nsPageContentFrame* aParentFrame)
|
|||
// are within fixed frames, because that would cause duplicates on the new
|
||||
// page - bug 389619)
|
||||
for (nsIFrame* fixed = firstFixed; fixed; fixed = fixed->GetNextSibling()) {
|
||||
nsIFrame* prevPlaceholder = GetPlaceholderFrameFor(fixed);
|
||||
nsIFrame* prevPlaceholder = fixed->GetPlaceholderFrame();
|
||||
if (prevPlaceholder &&
|
||||
nsLayoutUtils::IsProperAncestorFrame(prevCanvasFrame, prevPlaceholder)) {
|
||||
// We want to use the same style as the primary style frame for
|
||||
|
|
@ -9417,7 +9414,7 @@ nsCSSFrameConstructor::MaybeRecreateContainerForFrameRemoval(nsIFrame* aFrame,
|
|||
// Now check for possibly needing to reconstruct due to a pseudo parent
|
||||
nsIFrame* inFlowFrame =
|
||||
(aFrame->GetStateBits() & NS_FRAME_OUT_OF_FLOW) ?
|
||||
GetPlaceholderFrameFor(aFrame) : aFrame;
|
||||
aFrame->GetPlaceholderFrame() : aFrame;
|
||||
MOZ_ASSERT(inFlowFrame, "How did that happen?");
|
||||
MOZ_ASSERT(inFlowFrame == inFlowFrame->FirstContinuation(),
|
||||
"placeholder for primary frame has previous continuations?");
|
||||
|
|
@ -11594,7 +11591,7 @@ nsCSSFrameConstructor::RemoveFloatingFirstLetterFrames(
|
|||
}
|
||||
|
||||
// Discover the placeholder frame for the letter frame
|
||||
nsPlaceholderFrame* placeholderFrame = GetPlaceholderFrameFor(floatFrame);
|
||||
nsPlaceholderFrame* placeholderFrame = floatFrame->GetPlaceholderFrame();
|
||||
if (!placeholderFrame) {
|
||||
// Somethings really wrong
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -46,34 +46,9 @@ using namespace mozilla::dom;
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
struct PlaceholderMapEntry : public PLDHashEntryHdr {
|
||||
// key (the out of flow frame) can be obtained through placeholder frame
|
||||
nsPlaceholderFrame *placeholderFrame;
|
||||
};
|
||||
|
||||
static bool
|
||||
PlaceholderMapMatchEntry(const PLDHashEntryHdr *hdr, const void *key)
|
||||
{
|
||||
const PlaceholderMapEntry *entry =
|
||||
static_cast<const PlaceholderMapEntry*>(hdr);
|
||||
NS_ASSERTION(entry->placeholderFrame->GetOutOfFlowFrame() !=
|
||||
(void*)0xdddddddd,
|
||||
"Dead placeholder in placeholder map");
|
||||
return entry->placeholderFrame->GetOutOfFlowFrame() == key;
|
||||
}
|
||||
|
||||
static const PLDHashTableOps PlaceholderMapOps = {
|
||||
PLDHashTable::HashVoidPtrKeyStub,
|
||||
PlaceholderMapMatchEntry,
|
||||
PLDHashTable::MoveEntryStub,
|
||||
PLDHashTable::ClearEntryStub,
|
||||
nullptr
|
||||
};
|
||||
|
||||
nsFrameManagerBase::nsFrameManagerBase()
|
||||
: mPresShell(nullptr)
|
||||
, mRootFrame(nullptr)
|
||||
, mPlaceholderMap(&PlaceholderMapOps, sizeof(PlaceholderMapEntry))
|
||||
, mUndisplayedMap(nullptr)
|
||||
, mDisplayContentsMap(nullptr)
|
||||
, mIsDestroyingFrames(false)
|
||||
|
|
@ -142,9 +117,6 @@ nsFrameManager::Destroy()
|
|||
// Destroy the frame hierarchy.
|
||||
mPresShell->SetIgnoreFrameDestruction(true);
|
||||
|
||||
// Unregister all placeholders before tearing down the frame tree
|
||||
nsFrameManager::ClearPlaceholderFrameMap();
|
||||
|
||||
if (mRootFrame) {
|
||||
mRootFrame->Destroy();
|
||||
mRootFrame = nullptr;
|
||||
|
|
@ -159,56 +131,6 @@ nsFrameManager::Destroy()
|
|||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// Placeholder frame functions
|
||||
nsPlaceholderFrame*
|
||||
nsFrameManager::GetPlaceholderFrameFor(const nsIFrame* aFrame)
|
||||
{
|
||||
NS_PRECONDITION(aFrame, "null param unexpected");
|
||||
|
||||
auto entry = static_cast<PlaceholderMapEntry*>
|
||||
(const_cast<PLDHashTable*>(&mPlaceholderMap)->Search(aFrame));
|
||||
if (entry) {
|
||||
return entry->placeholderFrame;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
nsFrameManager::RegisterPlaceholderFrame(nsPlaceholderFrame* aPlaceholderFrame)
|
||||
{
|
||||
MOZ_ASSERT(aPlaceholderFrame, "null param unexpected");
|
||||
MOZ_ASSERT(nsGkAtoms::placeholderFrame == aPlaceholderFrame->GetType(),
|
||||
"unexpected frame type");
|
||||
auto entry = static_cast<PlaceholderMapEntry*>
|
||||
(mPlaceholderMap.Add(aPlaceholderFrame->GetOutOfFlowFrame()));
|
||||
MOZ_ASSERT(!entry->placeholderFrame,
|
||||
"Registering a placeholder for a frame that already has a placeholder!");
|
||||
entry->placeholderFrame = aPlaceholderFrame;
|
||||
}
|
||||
|
||||
void
|
||||
nsFrameManager::UnregisterPlaceholderFrame(nsPlaceholderFrame* aPlaceholderFrame)
|
||||
{
|
||||
NS_PRECONDITION(aPlaceholderFrame, "null param unexpected");
|
||||
NS_PRECONDITION(nsGkAtoms::placeholderFrame == aPlaceholderFrame->GetType(),
|
||||
"unexpected frame type");
|
||||
|
||||
mPlaceholderMap.Remove(aPlaceholderFrame->GetOutOfFlowFrame());
|
||||
}
|
||||
|
||||
void
|
||||
nsFrameManager::ClearPlaceholderFrameMap()
|
||||
{
|
||||
for (auto iter = mPlaceholderMap.Iter(); !iter.Done(); iter.Next()) {
|
||||
auto entry = static_cast<PlaceholderMapEntry*>(iter.Get());
|
||||
entry->placeholderFrame->SetOutOfFlowFrame(nullptr);
|
||||
}
|
||||
mPlaceholderMap.Clear();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
/* static */ nsStyleContext*
|
||||
nsFrameManager::GetStyleContextInMap(UndisplayedMap* aMap, nsIContent* aContent)
|
||||
{
|
||||
|
|
@ -497,7 +419,7 @@ nsFrameManager::RemoveFrame(ChildListID aListID,
|
|||
aOldFrame->GetType() == nsGkAtoms::textFrame,
|
||||
"Must remove first continuation.");
|
||||
NS_ASSERTION(!(aOldFrame->GetStateBits() & NS_FRAME_OUT_OF_FLOW &&
|
||||
GetPlaceholderFrameFor(aOldFrame)),
|
||||
aOldFrame->GetPlaceholderFrame()),
|
||||
"Must call RemoveFrame on placeholder for out-of-flows.");
|
||||
nsContainerFrame* parentFrame = aOldFrame->GetParent();
|
||||
if (parentFrame->IsAbsoluteContainer() &&
|
||||
|
|
|
|||
|
|
@ -51,9 +51,7 @@ struct UndisplayedNode : public LinkedListElement<UndisplayedNode>
|
|||
} // namespace mozilla
|
||||
|
||||
/**
|
||||
* Frame manager interface. The frame manager serves two purposes:
|
||||
* <li>provides a service for mapping from content to frame and from
|
||||
* out-of-flow frame to placeholder frame.
|
||||
* Frame manager interface. The frame manager serves one purpose:
|
||||
* <li>handles structural modifications to the frame model. If the frame model
|
||||
* lock can be acquired, then the changes are processed immediately; otherwise,
|
||||
* they're queued and processed later.
|
||||
|
|
@ -81,13 +79,6 @@ public:
|
|||
*/
|
||||
void Destroy();
|
||||
|
||||
// Placeholder frame functions
|
||||
nsPlaceholderFrame* GetPlaceholderFrameFor(const nsIFrame* aFrame);
|
||||
void RegisterPlaceholderFrame(nsPlaceholderFrame* aPlaceholderFrame);
|
||||
void UnregisterPlaceholderFrame(nsPlaceholderFrame* aPlaceholderFrame);
|
||||
|
||||
void ClearPlaceholderFrameMap();
|
||||
|
||||
// Mapping undisplayed content
|
||||
nsStyleContext* GetUndisplayedContent(nsIContent* aContent)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -53,7 +53,6 @@ protected:
|
|||
// weak link, because the pres shell owns us
|
||||
nsIPresShell* MOZ_NON_OWNING_REF mPresShell;
|
||||
nsIFrame* mRootFrame;
|
||||
PLDHashTable mPlaceholderMap;
|
||||
UndisplayedMap* mUndisplayedMap;
|
||||
UndisplayedMap* mDisplayContentsMap;
|
||||
bool mIsDestroyingFrames; // The frame manager is destroying some frame(s).
|
||||
|
|
|
|||
|
|
@ -493,8 +493,7 @@ nsFrameIterator::GetPlaceholderFrame(nsIFrame* aFrame)
|
|||
if (MOZ_LIKELY(!aFrame || !aFrame->HasAnyStateBits(NS_FRAME_OUT_OF_FLOW))) {
|
||||
return aFrame;
|
||||
}
|
||||
nsIFrame* placeholder =
|
||||
aFrame->PresContext()->PresShell()->GetPlaceholderFrameFor(aFrame);
|
||||
nsIFrame* placeholder = aFrame->GetPlaceholderFrame();
|
||||
return placeholder ? placeholder : aFrame;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -485,12 +485,6 @@ public:
|
|||
*/
|
||||
virtual nsCanvasFrame* GetCanvasFrame() const = 0;
|
||||
|
||||
/**
|
||||
* Gets the placeholder frame associated with the specified frame. This is
|
||||
* a helper frame that forwards the request to the frame manager.
|
||||
*/
|
||||
virtual nsIFrame* GetPlaceholderFrameFor(nsIFrame* aFrame) const = 0;
|
||||
|
||||
/**
|
||||
* Tell the pres shell that a frame needs to be marked dirty and needs
|
||||
* Reflow. It's OK if this is an ancestor of the frame needing reflow as
|
||||
|
|
|
|||
|
|
@ -4348,8 +4348,7 @@ nsLayoutUtils::GetParentOrPlaceholderFor(nsIFrame* aFrame)
|
|||
{
|
||||
if ((aFrame->GetStateBits() & NS_FRAME_OUT_OF_FLOW)
|
||||
&& !aFrame->GetPrevInFlow()) {
|
||||
return aFrame->PresContext()->PresShell()->FrameManager()->
|
||||
GetPlaceholderFrameFor(aFrame);
|
||||
return aFrame->GetProperty(nsIFrame::PlaceholderFrameProperty());
|
||||
}
|
||||
return aFrame->GetParent();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4596,12 +4596,6 @@ PresShell::StyleRuleRemoved(StyleSheet* aStyleSheet)
|
|||
RecordStyleSheetChange(aStyleSheet);
|
||||
}
|
||||
|
||||
nsIFrame*
|
||||
PresShell::GetPlaceholderFrameFor(nsIFrame* aFrame) const
|
||||
{
|
||||
return mFrameConstructor->GetPlaceholderFrameFor(aFrame);
|
||||
}
|
||||
|
||||
nsresult
|
||||
PresShell::RenderDocument(const nsRect& aRect, uint32_t aFlags,
|
||||
nscolor aBackgroundColor,
|
||||
|
|
|
|||
|
|
@ -130,7 +130,6 @@ public:
|
|||
virtual nsIPageSequenceFrame* GetPageSequenceFrame() const override;
|
||||
virtual nsCanvasFrame* GetCanvasFrame() const override;
|
||||
|
||||
virtual nsIFrame* GetPlaceholderFrameFor(nsIFrame* aFrame) const override;
|
||||
virtual void FrameNeedsReflow(nsIFrame *aFrame, IntrinsicDirty aIntrinsicDirty,
|
||||
nsFrameState aBitToAdd,
|
||||
ReflowRootHandling aRootHandling =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue