Hooking up document.getSelection() for html documents to return a string so that we're compatible with 4.x.

This commit is contained in:
jst@netscape.com
2000-04-28 14:05:45 +00:00
parent d629e5a8d2
commit c22b97ac63
2 changed files with 60 additions and 4 deletions

View File

@@ -75,6 +75,7 @@
#include "nsICookieService.h"
#include "nsIServiceManager.h"
#include "nsIConsoleService.h"
#include "nsIFormManager.h"
#include "nsIComponentManager.h"
#include "nsParserCIID.h"
@@ -89,6 +90,7 @@
#include "nsIFile.h"
#include "nsIEventListenerManager.h"
#include "nsISelectElement.h"
#include "nsIFrameSelection.h"
#include "nsICharsetDetector.h"
#include "nsICharsetDetectionAdaptor.h"
@@ -2449,9 +2451,35 @@ nsHTMLDocument::GetPlugins(nsIDOMHTMLCollection** aPlugins)
NS_IMETHODIMP
nsHTMLDocument::GetSelection(nsString& aReturn)
{
//XXX TBImplemented
aReturn.Truncate();
return NS_OK;
nsIPresShell* shell = (nsIPresShell*) mPresShells.ElementAt(0);
if (!shell)
return NS_OK;
nsCOMPtr<nsIFrameSelection> selection;
shell->GetFrameSelection(getter_AddRefs(selection));
if (!selection)
return NS_OK;
nsCOMPtr<nsIDOMSelection> domSelection;
selection->GetSelection(nsISelectionController::SELECTION_NORMAL,
getter_AddRefs(domSelection));
if (!domSelection)
return NS_OK;
nsCOMPtr<nsIConsoleService> consoleService
(do_GetService("mozilla.consoleservice.1"));
if (consoleService) {
consoleService->LogStringMessage(NS_ConvertASCIItoUCS2("Depricated method document.getSelection() called, use window.getSelection() in stead!").GetUnicode());
}
return domSelection->ToString(aReturn);
}
NS_IMETHODIMP