Bug 336104 - "ASSERTION: no frame, see bug #188946"; r=roc

This commit is contained in:
Ehsan Akhgari 2010-05-21 14:15:21 -04:00
parent 7dcf697f62
commit 2ca79e5889
2 changed files with 11 additions and 5 deletions

View File

@ -92,4 +92,5 @@ include $(topsrcdir)/config/rules.mk
INCLUDES += \
-I$(topsrcdir)/content/base/src \
-I$(topsrcdir)/content/events/src \
-I$(topsrcdir)/layout/style \
$(NULL)

View File

@ -110,6 +110,7 @@
#include "nsIParserService.h"
#include "nsITransferable.h"
#include "nsComputedDOMStyle.h"
#include "mozilla/FunctionTimer.h"
@ -3971,11 +3972,15 @@ nsEditor::IsPreformatted(nsIDOMNode *aNode, PRBool *aResult)
nsCOMPtr<nsIPresShell> ps = do_QueryReferent(mPresShellWeak);
if (!ps) return NS_ERROR_NOT_INITIALIZED;
nsIFrame *frame = content->GetPrimaryFrame();
NS_ASSERTION(frame, "no frame, see bug #188946");
if (!frame)
nsRefPtr<nsStyleContext> elementStyle;
if (content->IsElement()) {
elementStyle = nsComputedDOMStyle::GetStyleContextForElement(content->AsElement(),
nsnull,
ps);
}
if (!elementStyle)
{
// Consider nodes without a style context to be NOT preformatted:
// For instance, this is true of JS tags inside the body (which show
@ -3984,7 +3989,7 @@ nsEditor::IsPreformatted(nsIDOMNode *aNode, PRBool *aResult)
return NS_OK;
}
const nsStyleText* styleText = frame->GetStyleText();
const nsStyleText* styleText = elementStyle->GetStyleText();
*aResult = styleText->WhiteSpaceIsSignificant();
return NS_OK;