diff --git a/editor/base/nsEditor.cpp b/editor/base/nsEditor.cpp index 0e4a2422c9a0..aa4e41014247 100644 --- a/editor/base/nsEditor.cpp +++ b/editor/base/nsEditor.cpp @@ -844,11 +844,7 @@ nsEditor::Init(nsIDOMDocument *aDoc, nsIPresShell* aPresShell, nsIContent *aRoot if (aRoot) mBodyElement = do_QueryInterface(aRoot); - // disable links - nsCOMPtr context; - ps->GetPresContext(getter_AddRefs(context)); - if (!context) return NS_ERROR_NULL_POINTER; - context->SetLinkHandler(0); + // Set up the DTD // XXX - in the long run we want to get this from the document, but there @@ -879,7 +875,11 @@ nsEditor::Init(nsIDOMDocument *aDoc, nsIPresShell* aPresShell, nsIContent *aRoot aSelCon->SetDisplaySelection(nsISelectionController::SELECTION_ON); // Set the selection to the beginning: - BeginningOfDocument(); + +//hack to get around this for now. + nsCOMPtr shell = do_QueryReferent(mSelConWeak); + if (shell) + BeginningOfDocument(); NS_POSTCONDITION(mDocWeak && mPresShellWeak, "bad state"); diff --git a/editor/base/nsHTMLEditor.cpp b/editor/base/nsHTMLEditor.cpp index a1f3d774ab8b..c1557a66fdb0 100644 --- a/editor/base/nsHTMLEditor.cpp +++ b/editor/base/nsHTMLEditor.cpp @@ -74,6 +74,7 @@ #include "nsIDocumentEncoder.h" #include "nsIDOMDocumentFragment.h" #include "nsIPresShell.h" +#include "nsIPresContext.h" #include "nsIImage.h" #include "nsAOLCiter.h" #include "nsInternetCiter.h" @@ -398,6 +399,13 @@ NS_IMETHODIMP nsHTMLEditor::Init(nsIDOMDocument *aDoc, result = nsEditor::Init(aDoc, aPresShell, aRoot, aSelCon, aFlags); if (NS_FAILED(result)) { return result; } + // disable links + nsCOMPtr context; + aPresShell->GetPresContext(getter_AddRefs(context)); + if (!context) return NS_ERROR_NULL_POINTER; + if (!(mFlags & eEditorPlaintextMask)) + context->SetLinkHandler(0); + nsCOMPtr bodyElement; result = nsEditor::GetRootElement(getter_AddRefs(bodyElement)); if (NS_FAILED(result)) { return result; } diff --git a/editor/libeditor/base/nsEditor.cpp b/editor/libeditor/base/nsEditor.cpp index 0e4a2422c9a0..aa4e41014247 100644 --- a/editor/libeditor/base/nsEditor.cpp +++ b/editor/libeditor/base/nsEditor.cpp @@ -844,11 +844,7 @@ nsEditor::Init(nsIDOMDocument *aDoc, nsIPresShell* aPresShell, nsIContent *aRoot if (aRoot) mBodyElement = do_QueryInterface(aRoot); - // disable links - nsCOMPtr context; - ps->GetPresContext(getter_AddRefs(context)); - if (!context) return NS_ERROR_NULL_POINTER; - context->SetLinkHandler(0); + // Set up the DTD // XXX - in the long run we want to get this from the document, but there @@ -879,7 +875,11 @@ nsEditor::Init(nsIDOMDocument *aDoc, nsIPresShell* aPresShell, nsIContent *aRoot aSelCon->SetDisplaySelection(nsISelectionController::SELECTION_ON); // Set the selection to the beginning: - BeginningOfDocument(); + +//hack to get around this for now. + nsCOMPtr shell = do_QueryReferent(mSelConWeak); + if (shell) + BeginningOfDocument(); NS_POSTCONDITION(mDocWeak && mPresShellWeak, "bad state"); diff --git a/editor/libeditor/html/nsHTMLEditor.cpp b/editor/libeditor/html/nsHTMLEditor.cpp index a1f3d774ab8b..c1557a66fdb0 100644 --- a/editor/libeditor/html/nsHTMLEditor.cpp +++ b/editor/libeditor/html/nsHTMLEditor.cpp @@ -74,6 +74,7 @@ #include "nsIDocumentEncoder.h" #include "nsIDOMDocumentFragment.h" #include "nsIPresShell.h" +#include "nsIPresContext.h" #include "nsIImage.h" #include "nsAOLCiter.h" #include "nsInternetCiter.h" @@ -398,6 +399,13 @@ NS_IMETHODIMP nsHTMLEditor::Init(nsIDOMDocument *aDoc, result = nsEditor::Init(aDoc, aPresShell, aRoot, aSelCon, aFlags); if (NS_FAILED(result)) { return result; } + // disable links + nsCOMPtr context; + aPresShell->GetPresContext(getter_AddRefs(context)); + if (!context) return NS_ERROR_NULL_POINTER; + if (!(mFlags & eEditorPlaintextMask)) + context->SetLinkHandler(0); + nsCOMPtr bodyElement; result = nsEditor::GetRootElement(getter_AddRefs(bodyElement)); if (NS_FAILED(result)) { return result; }