From 46389cab0e658c423d46b5f13c8a5d71507aa24c Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Fri, 2 Apr 2004 03:07:39 +0000 Subject: [PATCH] Don't look for the primary frame unless we have to on broken images. Bug 239262, r+sr=dbaron, a=chofmann --- layout/generic/nsImageFrame.cpp | 19 ++++++++++++++----- layout/html/base/src/nsImageFrame.cpp | 19 ++++++++++++++----- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp index adf97d5edc5..2633d1ed75e 100644 --- a/layout/generic/nsImageFrame.cpp +++ b/layout/generic/nsImageFrame.cpp @@ -490,12 +490,21 @@ nsImageFrame::HandleLoadError(nsresult aStatus, nsIPresShell* aPresShell) if (!useSizedBox) { // let the presShell handle converting this into the inline alt // text frame - // We have to try to get the primary frame for mContent, since for - // the frame CantRenderReplacedElement wants is the - // ObjectFrame, not us (we're an anonymous frame then).... nsIFrame* primaryFrame = nsnull; - aPresShell->GetPrimaryFrameFor(mContent, &primaryFrame); - aPresShell->CantRenderReplacedElement(primaryFrame ? primaryFrame : this); + if (mContent->IsContentOfType(nsIContent::eHTML) && + (mContent->Tag() == nsHTMLAtoms::object || + mContent->Tag() == nsHTMLAtoms::embed)) { + // We have to try to get the primary frame for mContent, since for + // the frame CantRenderReplacedElement wants is the + // ObjectFrame, not us (we're an anonymous frame then).... + aPresShell->GetPrimaryFrameFor(mContent, &primaryFrame); + } + + if (!primaryFrame) { + primaryFrame = this; + } + + aPresShell->CantRenderReplacedElement(primaryFrame); return NS_ERROR_FRAME_REPLACED; } diff --git a/layout/html/base/src/nsImageFrame.cpp b/layout/html/base/src/nsImageFrame.cpp index adf97d5edc5..2633d1ed75e 100644 --- a/layout/html/base/src/nsImageFrame.cpp +++ b/layout/html/base/src/nsImageFrame.cpp @@ -490,12 +490,21 @@ nsImageFrame::HandleLoadError(nsresult aStatus, nsIPresShell* aPresShell) if (!useSizedBox) { // let the presShell handle converting this into the inline alt // text frame - // We have to try to get the primary frame for mContent, since for - // the frame CantRenderReplacedElement wants is the - // ObjectFrame, not us (we're an anonymous frame then).... nsIFrame* primaryFrame = nsnull; - aPresShell->GetPrimaryFrameFor(mContent, &primaryFrame); - aPresShell->CantRenderReplacedElement(primaryFrame ? primaryFrame : this); + if (mContent->IsContentOfType(nsIContent::eHTML) && + (mContent->Tag() == nsHTMLAtoms::object || + mContent->Tag() == nsHTMLAtoms::embed)) { + // We have to try to get the primary frame for mContent, since for + // the frame CantRenderReplacedElement wants is the + // ObjectFrame, not us (we're an anonymous frame then).... + aPresShell->GetPrimaryFrameFor(mContent, &primaryFrame); + } + + if (!primaryFrame) { + primaryFrame = this; + } + + aPresShell->CantRenderReplacedElement(primaryFrame); return NS_ERROR_FRAME_REPLACED; }