From 2ca79e58890c35cc0d3e222439275b7d35578bec Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Fri, 21 May 2010 14:15:21 -0400 Subject: [PATCH] Bug 336104 - "ASSERTION: no frame, see bug #188946"; r=roc --- editor/libeditor/base/Makefile.in | 1 + editor/libeditor/base/nsEditor.cpp | 15 ++++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/editor/libeditor/base/Makefile.in b/editor/libeditor/base/Makefile.in index 756fa2ce4a6..81c5bdc964b 100644 --- a/editor/libeditor/base/Makefile.in +++ b/editor/libeditor/base/Makefile.in @@ -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) diff --git a/editor/libeditor/base/nsEditor.cpp b/editor/libeditor/base/nsEditor.cpp index a09c794c476..2cfab8a8bd2 100644 --- a/editor/libeditor/base/nsEditor.cpp +++ b/editor/libeditor/base/nsEditor.cpp @@ -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 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 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;