mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1259246. Move nsIPresShell::GetRealPrimaryFrameFor to nsLayoutUtils::GetRealPrimaryFrameFor. r=dholbert
The function doesn't need to be a non-static member of nsIPresShell: it only checks if the document of the passed in element matches the presshell's document, and then the remaining code could be static. It has only one user, nsDocumentViewer::FindContainerView, and it doesn't care about the specific presshell, it just wants the primary frame, so it doesn't need the document check. This lets us simplify nsDocumentViewer::FindContainerView because it had to jump through hoops to get the presshell.
This commit is contained in:
parent
122b4efd17
commit
4fa1d92384
@ -2462,42 +2462,24 @@ nsDocumentViewer::FindContainerView()
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPresShell> parentPresShell;
|
||||
nsCOMPtr<nsIDocument> parentDoc = containerElement->GetUncomposedDoc();
|
||||
if (parentDoc) {
|
||||
parentPresShell = parentDoc->GetShell();
|
||||
}
|
||||
|
||||
if (!parentPresShell) {
|
||||
nsCOMPtr<nsIDocShellTreeItem> parentDocShellItem;
|
||||
docShell->GetParent(getter_AddRefs(parentDocShellItem));
|
||||
if (parentDocShellItem) {
|
||||
nsCOMPtr<nsIDocShell> parentDocShell = do_QueryInterface(parentDocShellItem);
|
||||
parentPresShell = parentDocShell->GetPresShell();
|
||||
}
|
||||
}
|
||||
if (!parentPresShell) {
|
||||
NS_WARNING("Subdocument container has no presshell");
|
||||
} else {
|
||||
nsIFrame* subdocFrame = parentPresShell->GetRealPrimaryFrameFor(containerElement);
|
||||
if (subdocFrame) {
|
||||
// subdocFrame might not be a subdocument frame; the frame
|
||||
// constructor can treat a <frame> as an inline in some XBL
|
||||
// cases. Treat that as display:none, the document is not
|
||||
// displayed.
|
||||
if (subdocFrame->GetType() == nsGkAtoms::subDocumentFrame) {
|
||||
NS_ASSERTION(subdocFrame->GetView(), "Subdoc frames must have views");
|
||||
nsView* innerView =
|
||||
static_cast<nsSubDocumentFrame*>(subdocFrame)->EnsureInnerView();
|
||||
containerView = innerView;
|
||||
} else {
|
||||
NS_WARN_IF_FALSE(!subdocFrame->GetType(),
|
||||
"Subdocument container has non-subdocument frame");
|
||||
}
|
||||
nsIFrame* subdocFrame = nsLayoutUtils::GetRealPrimaryFrameFor(containerElement);
|
||||
if (subdocFrame) {
|
||||
// subdocFrame might not be a subdocument frame; the frame
|
||||
// constructor can treat a <frame> as an inline in some XBL
|
||||
// cases. Treat that as display:none, the document is not
|
||||
// displayed.
|
||||
if (subdocFrame->GetType() == nsGkAtoms::subDocumentFrame) {
|
||||
NS_ASSERTION(subdocFrame->GetView(), "Subdoc frames must have views");
|
||||
nsView* innerView =
|
||||
static_cast<nsSubDocumentFrame*>(subdocFrame)->EnsureInnerView();
|
||||
containerView = innerView;
|
||||
} else {
|
||||
// XXX Silenced by default in bug 1175289
|
||||
LAYOUT_WARNING("Subdocument container has no frame");
|
||||
NS_WARN_IF_FALSE(!subdocFrame->GetType(),
|
||||
"Subdocument container has non-subdocument frame");
|
||||
}
|
||||
} else {
|
||||
// XXX Silenced by default in bug 1175289
|
||||
LAYOUT_WARNING("Subdocument container has no frame");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -497,15 +497,6 @@ public:
|
||||
*/
|
||||
virtual nsCanvasFrame* GetCanvasFrame() const = 0;
|
||||
|
||||
/**
|
||||
* Gets the real primary frame associated with the content object.
|
||||
*
|
||||
* In the case of absolutely positioned elements and floated elements,
|
||||
* the real primary frame is the frame that is out of the flow and not the
|
||||
* placeholder frame.
|
||||
*/
|
||||
virtual nsIFrame* GetRealPrimaryFrameFor(nsIContent* aContent) const = 0;
|
||||
|
||||
/**
|
||||
* Gets the placeholder frame associated with the specified frame. This is
|
||||
* a helper frame that forwards the request to the frame manager.
|
||||
|
@ -1577,6 +1577,17 @@ nsLayoutUtils::GetStyleFrame(const nsIContent* aContent)
|
||||
return nsLayoutUtils::GetStyleFrame(frame);
|
||||
}
|
||||
|
||||
/* static */ nsIFrame*
|
||||
nsLayoutUtils::GetRealPrimaryFrameFor(const nsIContent* aContent)
|
||||
{
|
||||
nsIFrame *frame = aContent->GetPrimaryFrame();
|
||||
if (!frame) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return nsPlaceholderFrame::GetRealFrameFor(frame);
|
||||
}
|
||||
|
||||
nsIFrame*
|
||||
nsLayoutUtils::GetFloatFromPlaceholder(nsIFrame* aFrame) {
|
||||
NS_ASSERTION(nsGkAtoms::placeholderFrame == aFrame->GetType(),
|
||||
|
@ -363,6 +363,15 @@ public:
|
||||
*/
|
||||
static nsIFrame* GetStyleFrame(const nsIContent* aContent);
|
||||
|
||||
/**
|
||||
* Gets the real primary frame associated with the content object.
|
||||
*
|
||||
* In the case of absolutely positioned elements and floated elements,
|
||||
* the real primary frame is the frame that is out of the flow and not the
|
||||
* placeholder frame.
|
||||
*/
|
||||
static nsIFrame* GetRealPrimaryFrameFor(const nsIContent* aContent);
|
||||
|
||||
/**
|
||||
* IsGeneratedContentFor returns true if aFrame is the outermost
|
||||
* frame for generated content of type aPseudoElement for aContent.
|
||||
|
@ -4552,18 +4552,6 @@ PresShell::StyleRuleRemoved(StyleSheetHandle aStyleSheet)
|
||||
RecordStyleSheetChange(aStyleSheet);
|
||||
}
|
||||
|
||||
nsIFrame*
|
||||
PresShell::GetRealPrimaryFrameFor(nsIContent* aContent) const
|
||||
{
|
||||
if (aContent->GetComposedDoc() != GetDocument()) {
|
||||
return nullptr;
|
||||
}
|
||||
nsIFrame *primaryFrame = aContent->GetPrimaryFrame();
|
||||
if (!primaryFrame)
|
||||
return nullptr;
|
||||
return nsPlaceholderFrame::GetRealFrameFor(primaryFrame);
|
||||
}
|
||||
|
||||
nsIFrame*
|
||||
PresShell::GetPlaceholderFrameFor(nsIFrame* aFrame) const
|
||||
{
|
||||
|
@ -123,7 +123,6 @@ public:
|
||||
virtual nsresult ResizeReflowIgnoreOverride(nscoord aWidth, nscoord aHeight) override;
|
||||
virtual nsIPageSequenceFrame* GetPageSequenceFrame() const override;
|
||||
virtual nsCanvasFrame* GetCanvasFrame() const override;
|
||||
virtual nsIFrame* GetRealPrimaryFrameFor(nsIContent* aContent) const override;
|
||||
|
||||
virtual nsIFrame* GetPlaceholderFrameFor(nsIFrame* aFrame) const override;
|
||||
virtual void FrameNeedsReflow(nsIFrame *aFrame, IntrinsicDirty aIntrinsicDirty,
|
||||
|
Loading…
Reference in New Issue
Block a user