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;