diff --git a/mozilla/content/base/public/nsIDocument.h b/mozilla/content/base/public/nsIDocument.h index 94c446f6de4..7763cf76ad0 100644 --- a/mozilla/content/base/public/nsIDocument.h +++ b/mozilla/content/base/public/nsIDocument.h @@ -54,7 +54,7 @@ class nsINameSpaceManager; class nsIDOMDocumentFragment; class nsILineBreaker; class nsIWordBreaker; -class nsIDOMSelection; +class nsISelection; class nsIChannel; class nsIPrincipal; class nsINodeInfoManager; @@ -306,14 +306,14 @@ public: * NOTE: we may way to place the result in a stream, * but we will use a string for now -- gpk */ - NS_IMETHOD CreateXIF(nsAWritableString & aBuffer, nsIDOMSelection* aSelection = nsnull) = 0; + NS_IMETHOD CreateXIF(nsAWritableString & aBuffer, nsISelection* aSelection = nsnull) = 0; NS_IMETHOD ToXIF(nsIXIFConverter * aConverter, nsIDOMNode* aNode) = 0; virtual void BeginConvertToXIF(nsIXIFConverter * aConverter, nsIDOMNode* aNode) = 0; virtual void ConvertChildrenToXIF(nsIXIFConverter * aConverter, nsIDOMNode* aNode) = 0; virtual void FinishConvertToXIF(nsIXIFConverter * aConverter, nsIDOMNode* aNode) = 0; /* Helper methods to help determine the logical positioning of content */ - virtual PRBool IsInSelection(nsIDOMSelection* aSelection, const nsIContent *aContent) const = 0; + virtual PRBool IsInSelection(nsISelection* aSelection, const nsIContent *aContent) const = 0; virtual nsIContent* GetPrevContent(const nsIContent *aContent) const = 0; virtual nsIContent* GetNextContent(const nsIContent *aContent) const = 0; diff --git a/mozilla/content/base/public/nsIDocumentEncoder.h b/mozilla/content/base/public/nsIDocumentEncoder.h index e1786e9a893..9037d83b4a0 100644 --- a/mozilla/content/base/public/nsIDocumentEncoder.h +++ b/mozilla/content/base/public/nsIDocumentEncoder.h @@ -28,7 +28,7 @@ class nsIDocumentEncoder; class nsIDocument; -class nsIDOMSelection; +class nsISelection; class nsIOutputStream; class nsISupportsArray; @@ -119,7 +119,7 @@ public: * selection is used for encoding, otherwise the entire * document is encoded. */ - NS_IMETHOD SetSelection(nsIDOMSelection* aSelection) = 0; + NS_IMETHOD SetSelection(nsISelection* aSelection) = 0; /** * Documents typically have an intrinsic character set. diff --git a/mozilla/content/base/public/nsISelectionController.idl b/mozilla/content/base/public/nsISelectionController.idl index ef2d91998e1..158933213a8 100644 --- a/mozilla/content/base/public/nsISelectionController.idl +++ b/mozilla/content/base/public/nsISelectionController.idl @@ -24,11 +24,11 @@ #include "nsISupports.idl" #include "domstubs.idl" - +#include "nsISelection.idl" %{C++ -class nsIDOMSelection; +class nsISelection; typedef short SelectionType; typedef short SelectionRegion; class nsIDOMNode; @@ -86,7 +86,7 @@ interface nsISelectionController : nsISupports * @param aType will hold the type of selection //SelectionType * @param _return will hold the return value */ - nsIDOMSelection getSelection(in short type); + nsISelection getSelection(in short type); /** * ScrollSelectionIntoView scrolls a region of the selection, diff --git a/mozilla/content/base/src/nsCommentNode.cpp b/mozilla/content/base/src/nsCommentNode.cpp index 043d9c19500..36efb66b165 100644 --- a/mozilla/content/base/src/nsCommentNode.cpp +++ b/mozilla/content/base/src/nsCommentNode.cpp @@ -26,7 +26,8 @@ #include "nsIContent.h" #include "nsFrame.h" #include "nsLayoutAtoms.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" +#include "nsISelectionPrivate.h" #include "nsIXIFConverter.h" #include "nsIDocument.h" #include "nsIEnumerator.h" @@ -403,7 +404,7 @@ nsresult nsCommentNode::ConvertContentToXIF(nsIXIFConverter* aConverter) const { const nsIContent* content = this; - nsCOMPtr sel; + nsCOMPtr sel; aConverter->GetSelection(getter_AddRefs(sel)); nsIDocument* document; nsresult res; @@ -423,7 +424,8 @@ nsCommentNode::ConvertContentToXIF(nsIXIFConverter* aConverter) const if (sel != nsnull && document->IsInSelection(sel,content)) { nsIEnumerator *enumerator; - if (NS_SUCCEEDED(sel->GetEnumerator(&enumerator))) { + nsCOMPtr selPrivate(do_QueryInterface(sel)); + if (NS_SUCCEEDED(selPrivate->GetEnumerator(&enumerator))) { for (enumerator->First();NS_OK != enumerator->IsDone(); enumerator->Next()) { nsIDOMRange* range = nsnull; if (NS_SUCCEEDED(enumerator->CurrentItem((nsISupports**)&range))) { diff --git a/mozilla/content/base/src/nsDocument.cpp b/mozilla/content/base/src/nsDocument.cpp index 8e5631cdfba..bb08ff330ad 100644 --- a/mozilla/content/base/src/nsDocument.cpp +++ b/mozilla/content/base/src/nsDocument.cpp @@ -87,7 +87,7 @@ #include "nsLayoutAtoms.h" #include "nsLayoutCID.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIDOMRange.h" #include "nsIEnumerator.h" #include "nsDOMError.h" @@ -3355,7 +3355,7 @@ NS_IMETHODIMP nsDocument::ToXIF(nsIXIFConverter* aConverter, nsIDOMNode* aNode) { nsresult result=NS_OK; - nsCOMPtr sel; + nsCOMPtr sel; aConverter->GetSelection(getter_AddRefs(sel)); if (sel) { @@ -3387,7 +3387,7 @@ nsDocument::ToXIF(nsIXIFConverter* aConverter, nsIDOMNode* aNode) } NS_IMETHODIMP -nsDocument::CreateXIF(nsAWritableString & aBuffer, nsIDOMSelection* aSelection) +nsDocument::CreateXIF(nsAWritableString & aBuffer, nsISelection* aSelection) { nsresult result=NS_OK; @@ -3777,7 +3777,7 @@ nsIContent* nsDocument::FindContent(const nsIContent* aStartNode, * @return PR_TRUE if the content is found within the selection */ PRBool -nsDocument::IsInSelection(nsIDOMSelection* aSelection, const nsIContent* aContent) const +nsDocument::IsInSelection(nsISelection* aSelection, const nsIContent* aContent) const { PRBool aYes = PR_FALSE; nsCOMPtr node (do_QueryInterface((nsIContent *) aContent)); diff --git a/mozilla/content/base/src/nsDocument.h b/mozilla/content/base/src/nsDocument.h index fda087a204f..e50e6f5efaa 100644 --- a/mozilla/content/base/src/nsDocument.h +++ b/mozilla/content/base/src/nsDocument.h @@ -358,7 +358,7 @@ public: * document to XIF (XML Interchange Format) * and places the result in aBuffer. */ - NS_IMETHOD CreateXIF(nsAWritableString & aBuffer, nsIDOMSelection* aSelection); + NS_IMETHOD CreateXIF(nsAWritableString & aBuffer, nsISelection* aSelection); NS_IMETHOD ToXIF(nsIXIFConverter * aConverter, nsIDOMNode* aNode); virtual void BeginConvertToXIF(nsIXIFConverter * aConverter, nsIDOMNode* aNode); virtual void ConvertChildrenToXIF(nsIXIFConverter * aConverter, nsIDOMNode* aNode); @@ -448,7 +448,7 @@ public: nsEventStatus* aEventStatus); - virtual PRBool IsInSelection(nsIDOMSelection* aSelection, const nsIContent *aContent) const; + virtual PRBool IsInSelection(nsISelection* aSelection, const nsIContent *aContent) const; virtual nsIContent* GetPrevContent(const nsIContent *aContent) const; virtual nsIContent* GetNextContent(const nsIContent *aContent) const; diff --git a/mozilla/content/base/src/nsDocumentEncoder.cpp b/mozilla/content/base/src/nsDocumentEncoder.cpp index 713f1a584f9..cced3ae185f 100644 --- a/mozilla/content/base/src/nsDocumentEncoder.cpp +++ b/mozilla/content/base/src/nsDocumentEncoder.cpp @@ -29,7 +29,7 @@ #include "nsIComponentManager.h" #include "nsIServiceManager.h" #include "nsIDocument.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIPresShell.h" #include "nsXIFDTD.h" #include "nsParserCIID.h" @@ -60,7 +60,7 @@ public: NS_DECL_ISUPPORTS // Inherited methods from nsIDocumentEncoder - NS_IMETHOD SetSelection(nsIDOMSelection* aSelection); + NS_IMETHOD SetSelection(nsISelection* aSelection); NS_IMETHOD SetWrapColumn(PRUint32 aWC); NS_IMETHOD SetCharset(const nsAReadableString& aCharset); @@ -74,7 +74,7 @@ protected: //NS_IMETHOD AddHeader(PRBool aYes); nsIDocument* mDocument; - nsIDOMSelection* mSelection; + nsISelection* mSelection; nsString mMimeType; nsString mCharset; PRUint32 mFlags; @@ -149,7 +149,7 @@ nsTextEncoder::SetWrapColumn(PRUint32 aWC) } NS_IMETHODIMP -nsTextEncoder::SetSelection(nsIDOMSelection* aSelection) +nsTextEncoder::SetSelection(nsISelection* aSelection) { mSelection = aSelection; return NS_OK; diff --git a/mozilla/content/base/src/nsDocumentViewer.cpp b/mozilla/content/base/src/nsDocumentViewer.cpp index 7fd25959c26..3f6fb61b67f 100644 --- a/mozilla/content/base/src/nsDocumentViewer.cpp +++ b/mozilla/content/base/src/nsDocumentViewer.cpp @@ -45,7 +45,8 @@ #include "nsIScriptGlobalObject.h" #include "nsILinkHandler.h" #include "nsIDOMDocument.h" -#include "nsIDOMSelectionListener.h" +#include "nsISelectionListener.h" +#include "nsISelectionPrivate.h" #include "nsIDOMHTMLDocument.h" #include "nsIDOMHTMLElement.h" #include "nsIDOMRange.h" @@ -106,16 +107,15 @@ class DocumentViewerImpl; #pragma mark ** nsDocViwerSelectionListener ** #endif -class nsDocViwerSelectionListener : public nsIDOMSelectionListener +class nsDocViwerSelectionListener : public nsISelectionListener { public: // nsISupports interface... NS_DECL_ISUPPORTS - // nsIDOMSelectionListerner interface - NS_DECL_IDOMSELECTIONLISTENER - + // nsISelectionListerner interface + NS_DECL_NSISELECTIONLISTENER nsDocViwerSelectionListener() : mDocViewer(NULL) @@ -245,7 +245,7 @@ private: nsresult MakeWindow(nsIWidget* aParentWidget, const nsRect& aBounds); - nsresult GetDocumentSelection(nsIDOMSelection **aSelection); + nsresult GetDocumentSelection(nsISelection **aSelection); // // The following three methods are used for printing... @@ -279,7 +279,7 @@ protected: nsCOMPtr mUAStyleSheet; - nsCOMPtr mSelectionListener; + nsCOMPtr mSelectionListener; nsCOMPtr mFocusListener; PRBool mEnableRendering; @@ -436,12 +436,13 @@ DocumentViewerImpl::~DocumentViewerImpl() if (mPresShell) { // Break circular reference (or something) mPresShell->EndObservingDocument(); - nsCOMPtr selection; + nsCOMPtr selection; rv = GetDocumentSelection(getter_AddRefs(selection)); - if (NS_FAILED(rv) || !selection) + nsCOMPtr selPrivate(do_QueryInterface(selection)); + if (NS_FAILED(rv) || !selPrivate) return; if (mSelectionListener) - selection->RemoveSelectionListener(mSelectionListener); + selPrivate->RemoveSelectionListener(mSelectionListener); } } @@ -592,15 +593,16 @@ DocumentViewerImpl::Init(nsIWidget* aParentWidget, // this is the owning reference. The nsCOMPtr will take care of releasing // our ref to the listener on destruction. NS_ADDREF(selectionListener); - rv = selectionListener->QueryInterface(NS_GET_IID(nsIDOMSelectionListener), getter_AddRefs(mSelectionListener)); + rv = selectionListener->QueryInterface(NS_GET_IID(nsISelectionListener), getter_AddRefs(mSelectionListener)); NS_RELEASE(selectionListener); if (NS_FAILED(rv)) return rv; - nsCOMPtr selection; + nsCOMPtr selection; rv = GetDocumentSelection(getter_AddRefs(selection)); if (NS_FAILED(rv)) return rv; - rv = selection->AddSelectionListener(mSelectionListener); + nsCOMPtr selPrivate(do_QueryInterface(selection)); + rv = selPrivate->AddSelectionListener(mSelectionListener); if (NS_FAILED(rv)) return rv; //focus listener @@ -1194,7 +1196,7 @@ DocumentViewerImpl::MakeWindow(nsIWidget* aParentWidget, return rv; } -nsresult DocumentViewerImpl::GetDocumentSelection(nsIDOMSelection **aSelection) +nsresult DocumentViewerImpl::GetDocumentSelection(nsISelection **aSelection) { if (!aSelection) return NS_ERROR_NULL_POINTER; if (!mPresShell) return NS_ERROR_NOT_INITIALIZED; @@ -1338,7 +1340,7 @@ NS_IMETHODIMP DocumentViewerImpl::SelectAll() // XXX this is a temporary implementation copied from nsWebShell // for now. I think nsDocument and friends should have some helper // functions to make this easier. - nsCOMPtr selection; + nsCOMPtr selection; nsresult rv; rv = GetDocumentSelection(getter_AddRefs(selection)); if (NS_FAILED(rv)) return rv; @@ -1361,7 +1363,7 @@ NS_IMETHODIMP DocumentViewerImpl::SelectAll() } if (!bodyNode) return NS_ERROR_FAILURE; - rv = selection->ClearSelection(); + rv = selection->RemoveAllRanges(); if (NS_FAILED(rv)) return rv; static NS_DEFINE_CID(kCDOMRangeCID, NS_RANGE_CID); @@ -1385,7 +1387,7 @@ NS_IMETHODIMP DocumentViewerImpl::CopySelection() NS_IMETHODIMP DocumentViewerImpl::GetCopyable(PRBool *aCopyable) { - nsCOMPtr selection; + nsCOMPtr selection; nsresult rv; rv = GetDocumentSelection(getter_AddRefs(selection)); if (NS_FAILED(rv)) return rv; @@ -1922,7 +1924,7 @@ NS_IMETHODIMP DocumentViewerImpl::SizeToContent() #pragma mark - #endif -NS_IMPL_ISUPPORTS(nsDocViwerSelectionListener, NS_GET_IID(nsIDOMSelectionListener)); +NS_IMPL_ISUPPORTS(nsDocViwerSelectionListener, NS_GET_IID(nsISelectionListener)); nsresult nsDocViwerSelectionListener::Init(DocumentViewerImpl *aDocViewer) { @@ -1931,12 +1933,12 @@ nsresult nsDocViwerSelectionListener::Init(DocumentViewerImpl *aDocViewer) } -NS_IMETHODIMP nsDocViwerSelectionListener::NotifySelectionChanged(nsIDOMDocument *, nsIDOMSelection *, short) +NS_IMETHODIMP nsDocViwerSelectionListener::NotifySelectionChanged(nsIDOMDocument *, nsISelection *, short) { NS_ASSERTION(mDocViewer, "Should have doc viewer!"); // get the selection state - nsCOMPtr selection; + nsCOMPtr selection; nsresult rv = mDocViewer->GetDocumentSelection(getter_AddRefs(selection)); if (NS_FAILED(rv)) return rv; diff --git a/mozilla/content/base/src/nsGenericDOMDataNode.cpp b/mozilla/content/base/src/nsGenericDOMDataNode.cpp index 6a6be9c8405..c4af63ba33d 100644 --- a/mozilla/content/base/src/nsGenericDOMDataNode.cpp +++ b/mozilla/content/base/src/nsGenericDOMDataNode.cpp @@ -30,7 +30,8 @@ #include "nsIXIFConverter.h" #include "nsRange.h" #include "nsTextContentChangeData.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" +#include "nsISelectionPrivate.h" #include "nsIEnumerator.h" #include "nsReadableUtils.h" @@ -558,13 +559,14 @@ nsGenericDOMDataNode::ConvertContentToXIF(const nsIContent *aOuterContent, nsIXIFConverter* aConverter) const { const nsIContent* content = aOuterContent; - nsCOMPtr sel; + nsCOMPtr sel; aConverter->GetSelection(getter_AddRefs(sel)); if (sel && mDocument && mDocument->IsInSelection(sel,content)) { nsCOMPtr enumerator; - if (NS_SUCCEEDED(sel->GetEnumerator(getter_AddRefs(enumerator)))) { + nsCOMPtr selPrivate(do_QueryInterface(sel)); + if (NS_SUCCEEDED(selPrivate->GetEnumerator(getter_AddRefs(enumerator)))) { for (enumerator->First();NS_OK != enumerator->IsDone(); enumerator->Next()) { nsIDOMRange* range = nsnull; if (NS_SUCCEEDED(enumerator->CurrentItem((nsISupports**)&range))) { diff --git a/mozilla/content/base/src/nsSelection.cpp b/mozilla/content/base/src/nsSelection.cpp index 745a54067c5..ed826d6611e 100644 --- a/mozilla/content/base/src/nsSelection.cpp +++ b/mozilla/content/base/src/nsSelection.cpp @@ -20,7 +20,7 @@ */ /* - * Implementation of selection: nsIDOMSelection and nsIFrameSelection + * Implementation of selection: nsISelection,nsISelectionPrivate and nsIFrameSelection */ #include "nsCOMPtr.h" @@ -29,8 +29,9 @@ #include "nsIEnumerator.h" #include "nsIDOMRange.h" #include "nsIFrameSelection.h" -#include "nsIDOMSelection.h" -#include "nsIDOMSelectionListener.h" +#include "nsISelection.h" +#include "nsISelectionPrivate.h" +#include "nsISelectionListener.h" #include "nsIFocusTracker.h" #include "nsIComponentManager.h" #include "nsLayoutCID.h" @@ -45,7 +46,7 @@ #include "nsIDOMNodeList.h" #include "nsITextContent.h" -#include "nsIDOMSelectionListener.h" +#include "nsISelectionListener.h" #include "nsIContentIterator.h" #include "nsIDocumentEncoder.h" #include "nsIIndependentSelection.h" @@ -58,8 +59,6 @@ #include "nsIPresShell.h" #include "nsICaret.h" -#include "nsIScriptObjectOwner.h" -#include "nsIScriptGlobalObject.h" // included for view scrolling #include "nsIViewManager.h" @@ -113,7 +112,7 @@ class nsSelectionIterator; class nsSelection; class nsAutoScrollTimer; -class nsDOMSelection : public nsIDOMSelection , public nsIScriptObjectOwner, public nsSupportsWeakReference, public nsIIndependentSelection +class nsDOMSelection : public nsISelection , public nsISelectionPrivate, public nsSupportsWeakReference, public nsIIndependentSelection { public: nsDOMSelection(); @@ -124,7 +123,7 @@ public: /*BEGIN nsIIndependentSelection interface implementations */ NS_IMETHOD SetPresShell(nsIPresShell *aPresShell); - /*BEGIN nsIDOMSelection interface implementations*/ + /*BEGIN nsISelection,Private interface implementations*/ NS_IMETHOD GetAnchorNode(nsIDOMNode** aAnchorNode); NS_IMETHOD GetAnchorOffset(PRInt32* aAnchorOffset); NS_IMETHOD GetFocusNode(nsIDOMNode** aFocusNode); @@ -132,7 +131,7 @@ public: NS_IMETHOD GetIsCollapsed(PRBool* aIsCollapsed); NS_IMETHOD GetRangeCount(PRInt32* aRangeCount); NS_IMETHOD GetRangeAt(PRInt32 aIndex, nsIDOMRange** aReturn); - NS_IMETHOD ClearSelection(); + NS_IMETHOD RemoveAllRanges(); NS_IMETHOD Collapse(nsIDOMNode* aParentNode, PRInt32 aOffset); NS_IMETHOD CollapseToStart(); NS_IMETHOD CollapseToEnd(); @@ -146,21 +145,17 @@ public: NS_IMETHOD StartBatchChanges(); NS_IMETHOD EndBatchChanges(); - NS_IMETHOD AddSelectionListener(nsIDOMSelectionListener* aNewListener); - NS_IMETHOD RemoveSelectionListener(nsIDOMSelectionListener* aListenerToRemove); + NS_IMETHOD AddSelectionListener(nsISelectionListener* aNewListener); + NS_IMETHOD RemoveSelectionListener(nsISelectionListener* aListenerToRemove); NS_IMETHOD GetEnumerator(nsIEnumerator **aIterator); - NS_IMETHOD ToString(const nsAReadableString& aFormatType, PRUint32 aFlags, PRInt32 aWrapCount, nsAWritableString& aReturn); + NS_IMETHOD ToString(PRUnichar **_retval); + NS_IMETHOD ToStringWithFormat(const char *aFormatType, PRUint32 aFlags, PRInt32 aWrapCount, PRUnichar ** aReturn); - NS_IMETHOD SetHint(PRBool aHintRight); - NS_IMETHOD GetHint(PRBool *aHintRight); + NS_IMETHOD GetInterlinePosition(PRBool *aInterlinePosition); + NS_IMETHOD SetInterlinePosition(PRBool aInterlinePosition); -/*END nsIDOMSelection interface implementations*/ - -/*BEGIN nsIScriptObjectOwner interface implementations*/ - NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject); - NS_IMETHOD SetScriptObject(void *aScriptObject); -/*END nsIScriptObjectOwner interface implementations*/ +/*END nsISelection interface implementations*/ // utility methods for scrolling the selection into view nsresult GetPresContext(nsIPresContext **aPresContext); @@ -259,8 +254,6 @@ private: nsSelection *mFrameSelection; nsWeakPtr mPresShellWeak; //weak reference to presshell. - // for nsIScriptObjectOwner - void* mScriptObject; SelectionType mType;//type of this nsDOMSelection; nsAutoScrollTimer *mAutoScrollTimer; // timer for autoscrolling. nsCOMPtr mSelectionListeners; @@ -270,9 +263,9 @@ private: class nsSelectionBatcher { private: - nsCOMPtr mSelection; + nsCOMPtr mSelection; public: - nsSelectionBatcher(nsIDOMSelection *aSelection) : mSelection(aSelection) + nsSelectionBatcher(nsISelectionPrivate *aSelection) : mSelection(aSelection) { if (mSelection) mSelection->StartBatchChanges(); } @@ -313,7 +306,7 @@ public: NS_IMETHOD ClearTableCellSelection(){mSelectingTableCellMode = 0; return NS_OK;} NS_IMETHOD GetTableCellSelectionStyleColor(const nsStyleColor **aStyleColor); - NS_IMETHOD GetSelection(SelectionType aType, nsIDOMSelection **aDomSelection); + NS_IMETHOD GetSelection(SelectionType aType, nsISelection **aDomSelection); NS_IMETHOD ScrollSelectionIntoView(SelectionType aType, SelectionRegion aRegion); NS_IMETHOD RepaintSelection(nsIPresContext* aPresContext, SelectionType aType); NS_IMETHOD GetFrameForNodeOffset(nsIContent *aNode, PRInt32 aOffset, HINT aHint, nsIFrame **aReturnFrame, PRInt32 *aReturnOffset); @@ -598,14 +591,14 @@ nsresult NS_NewSelection(nsIFrameSelection **aFrameSelection) return NS_OK; } -nsresult NS_NewDomSelection(nsIDOMSelection **aDomSelection); +nsresult NS_NewDomSelection(nsISelection **aDomSelection); -nsresult NS_NewDomSelection(nsIDOMSelection **aDomSelection) +nsresult NS_NewDomSelection(nsISelection **aDomSelection) { nsDOMSelection *rlist = new nsDOMSelection; if (!rlist) return NS_ERROR_OUT_OF_MEMORY; - *aDomSelection = (nsIDOMSelection *)rlist; + *aDomSelection = (nsISelection *)rlist; rlist->AddRef(); return NS_OK; } @@ -881,7 +874,7 @@ nsSelection::nsSelection() mDelayCaretOverExistingSelection = PR_TRUE; mDelayedMouseEventValid = PR_FALSE; - mReason = nsIDOMSelectionListener::NO_REASON; + mReason = nsISelectionListener::NO_REASON; } @@ -1454,33 +1447,33 @@ nsSelection::MoveCaret(PRUint32 aKeycode, PRBool aContinue, nsSelectionAmount aA InvalidateDesiredX(); pos.mDirection = eDirNext; mHint = HINTLEFT;//stick to this line - PostReason(nsIDOMSelectionListener::KEYPRESS_REASON); + PostReason(nsISelectionListener::KEYPRESS_REASON); break; case nsIDOMKeyEvent::DOM_VK_LEFT : //no break InvalidateDesiredX(); mHint = HINTRIGHT;//stick to opposite of movement - PostReason(nsIDOMSelectionListener::KEYPRESS_REASON); + PostReason(nsISelectionListener::KEYPRESS_REASON); break; case nsIDOMKeyEvent::DOM_VK_DOWN : pos.mAmount = eSelectLine; pos.mDirection = eDirNext;//no break here - PostReason(nsIDOMSelectionListener::KEYPRESS_REASON); + PostReason(nsISelectionListener::KEYPRESS_REASON); break; case nsIDOMKeyEvent::DOM_VK_UP : pos.mAmount = eSelectLine; - PostReason(nsIDOMSelectionListener::KEYPRESS_REASON); + PostReason(nsISelectionListener::KEYPRESS_REASON); break; case nsIDOMKeyEvent::DOM_VK_HOME : InvalidateDesiredX(); pos.mAmount = eSelectBeginLine; mHint = HINTRIGHT;//stick to opposite of movement - PostReason(nsIDOMSelectionListener::KEYPRESS_REASON); + PostReason(nsISelectionListener::KEYPRESS_REASON); break; case nsIDOMKeyEvent::DOM_VK_END : InvalidateDesiredX(); pos.mAmount = eSelectEndLine; mHint = HINTLEFT;//stick to this line - PostReason(nsIDOMSelectionListener::KEYPRESS_REASON); + PostReason(nsISelectionListener::KEYPRESS_REASON); break; default :return NS_ERROR_FAILURE; } @@ -1509,7 +1502,7 @@ nsSelection::MoveCaret(PRUint32 aKeycode, PRBool aContinue, nsSelectionAmount aA if (NS_SUCCEEDED(result = frame->PeekOffset(context, &pos)) && pos.mResultContent) { mHint = (HINT)pos.mPreferLeft; - PostReason(nsIDOMSelectionListener::MOUSEUP_REASON);//force an update as though we used the mouse. + PostReason(nsISelectionListener::MOUSEUP_REASON);//force an update as though we used the mouse. result = TakeFocus(pos.mResultContent, pos.mContentOffset, pos.mContentOffset, aContinue, PR_FALSE); } } @@ -1569,13 +1562,23 @@ nsSelection::HandleKeyEvent(nsIPresContext* aPresContext, nsGUIEvent *aGuiEvent) //BEGIN nsIFrameSelection methods NS_IMETHODIMP -nsDOMSelection::ToString(const nsAReadableString& aFormatType, PRUint32 aFlags, PRInt32 aWrapCount, nsAWritableString& aReturn) +nsDOMSelection::ToString(PRUnichar **aReturn) +{ + return ToStringWithFormat("text/plain", 0, 0, aReturn); +} + + +NS_IMETHODIMP +nsDOMSelection::ToStringWithFormat(const char * aFormatType, PRUint32 aFlags, + PRInt32 aWrapCol, PRUnichar **aReturn) { nsresult rv = NS_OK; + if (!aReturn) + return NS_ERROR_NULL_POINTER; nsCOMPtr encoder; nsCAutoString formatType( NS_DOC_ENCODER_CONTRACTID_BASE ); - formatType.AppendWithConversion(aFormatType); + formatType.Append(aFormatType); rv = nsComponentManager::CreateInstance(formatType, nsnull, NS_GET_IID(nsIDocumentEncoder), @@ -1594,21 +1597,23 @@ nsDOMSelection::ToString(const nsAReadableString& aFormatType, PRUint32 aFlags, // Flags should always include OutputSelectionOnly if we're coming from here: aFlags |= nsIDocumentEncoder::OutputSelectionOnly; - - rv = encoder->Init(doc, aFormatType, aFlags); + nsAutoString readstring; + readstring.AssignWithConversion(aFormatType); + rv = encoder->Init(doc, readstring, aFlags); NS_ENSURE_SUCCESS(rv, rv); encoder->SetSelection(this); - if (aWrapCount != 0) - encoder->SetWrapColumn(aWrapCount); - - rv = encoder->EncodeToString(aReturn); + if (aWrapCol != 0) + encoder->SetWrapColumn(aWrapCol); + nsAutoString tmp; + rv = encoder->EncodeToString(tmp); + *aReturn = tmp.ToNewUnicode();//get the unicode pointer from it. this is temporary return rv; } NS_IMETHODIMP -nsDOMSelection::SetHint(PRBool aHintRight) +nsDOMSelection::SetInterlinePosition(PRBool aHintRight) { nsIFrameSelection::HINT hint; if (aHintRight) @@ -1619,7 +1624,7 @@ nsDOMSelection::SetHint(PRBool aHintRight) } NS_IMETHODIMP -nsDOMSelection::GetHint(PRBool *aHintRight) +nsDOMSelection::GetInterlinePosition(PRBool *aHintRight) { nsIFrameSelection::HINT hint; nsresult rv = mFrameSelection->GetHint(&hint); @@ -1643,7 +1648,7 @@ nsSelection::HandleClick(nsIContent *aNewFocus, PRUint32 aContentOffset, // Don't take focus when dragging off of a table if (!mSelectingTableCells) { - PostReason(nsIDOMSelectionListener::MOUSEDOWN_REASON + nsIDOMSelectionListener::DRAG_REASON); + PostReason(nsISelectionListener::MOUSEDOWN_REASON + nsISelectionListener::DRAG_REASON); return TakeFocus(aNewFocus, aContentOffset, aContentEndOffset, aContinueSelection, aMultipleSelection); } @@ -1839,7 +1844,7 @@ printf("SetMouseDownState to FALSE - stopping cell selection\n"); mSelectingTableCells = PR_FALSE; mStartSelectedCell = nsnull; mEndSelectedCell = nsnull; - PostReason(aState?nsIDOMSelectionListener::MOUSEDOWN_REASON:nsIDOMSelectionListener::MOUSEUP_REASON);//not a drag reason + PostReason(aState?nsISelectionListener::MOUSEDOWN_REASON:nsISelectionListener::MOUSEUP_REASON);//not a drag reason NotifySelectionListeners(nsISelectionController::SELECTION_NORMAL);//notify that reason is mouse up please. } return NS_OK; @@ -1870,14 +1875,14 @@ nsSelection::GetTableCellSelectionStyleColor(const nsStyleColor **aStyleColor) NS_IMETHODIMP -nsSelection::GetSelection(SelectionType aType, nsIDOMSelection **aDomSelection) +nsSelection::GetSelection(SelectionType aType, nsISelection **aDomSelection) { if (!aDomSelection) return NS_ERROR_NULL_POINTER; PRInt8 index = GetIndexFromSelectionType(aType); if (index < 0) return NS_ERROR_INVALID_ARG; - *aDomSelection = mDomSelections[index]; + *aDomSelection = NS_REINTERPRET_CAST(nsISelection *,mDomSelections[index]); (*aDomSelection)->AddRef(); return NS_OK; } @@ -2097,7 +2102,7 @@ NS_IMETHODIMP nsSelection::SelectAll() } PRInt32 numChildren; rootContent->ChildCount(numChildren); - PostReason(nsIDOMSelectionListener::NO_REASON); + PostReason(nsISelectionListener::NO_REASON); return TakeFocus(mLimiter, 0, numChildren, PR_FALSE, PR_FALSE); } @@ -2200,7 +2205,7 @@ nsresult nsSelection::ClearNormalSelection() { PRInt8 index = GetIndexFromSelectionType(nsISelectionController::SELECTION_NORMAL); - return mDomSelections[index]->ClearSelection(); + return mDomSelections[index]->RemoveAllRanges(); } nsresult @@ -2296,7 +2301,7 @@ printf("HandleTableSelection: Dragged into a new cell\n"); { // Force new selection block mStartSelectedCell = nsnull; - mDomSelections[index]->ClearSelection(); + mDomSelections[index]->RemoveAllRanges(); mSelectingTableCellMode = (startRowIndex == curRowIndex) ? TABLESELECTION_ROW : TABLESELECTION_COLUMN; @@ -2346,7 +2351,7 @@ printf("HandleTableSelection: Mouse down event\n"); else { // No cells selected -- remove non-cell selection - mDomSelections[index]->ClearSelection(); + mDomSelections[index]->RemoveAllRanges(); } mSelectingTableCells = PR_TRUE; // Signal to start drag-cell-selection mSelectingTableCellMode = aTarget; @@ -2370,8 +2375,8 @@ printf("HandleTableSelection: Saving mUnselectCellOnMouseUp\n"); nsCOMPtr previousCellContent = do_QueryInterface(previousCellNode); if (!IsInSameTable(previousCellContent, childContent, nsnull)) { - mDomSelections[index]->ClearSelection(); - // Reset selection mode that is cleared in ClearSelection + mDomSelections[index]->RemoveAllRanges(); + // Reset selection mode that is cleared in RemoveAllRanges mSelectingTableCellMode = aTarget; } @@ -2391,7 +2396,7 @@ printf("HandleTableSelection: Saving mUnselectCellOnMouseUp\n"); mEndSelectedCell = nsnull; // Remove existing selection and select the table - mDomSelections[index]->ClearSelection(); + mDomSelections[index]->RemoveAllRanges(); return CreateAndAddRange(parentNode, aContentOffset); } else if (aTarget == TABLESELECTION_ROW || aTarget == TABLESELECTION_COLUMN) @@ -2403,8 +2408,8 @@ printf("HandleTableSelection: Saving mUnselectCellOnMouseUp\n"); // Force new selection block mStartSelectedCell = nsnull; - mDomSelections[index]->ClearSelection(); - // Always do this AFTER ClearSelection + mDomSelections[index]->RemoveAllRanges(); + // Always do this AFTER RemoveAllRanges mSelectingTableCellMode = aTarget; return SelectRowOrColumn(childContent, aTarget); } @@ -3056,7 +3061,7 @@ nsSelection::GetHint(HINT *aHintRight) #pragma mark - #endif -//BEGIN nsIDOMSelection interface implementations +//BEGIN nsISelection interface implementations @@ -3206,7 +3211,7 @@ nsSelection::GetLimiter(nsIContent **aLimiterContent) } -//END nsIDOMSelection interface implementations +//END nsISelection interface implementations #ifdef XP_MAC #pragma mark - @@ -3227,7 +3232,6 @@ nsDOMSelection::nsDOMSelection(nsSelection *aList) mFixupState = PR_FALSE; mDirection = eDirNext; NS_NewISupportsArray(getter_AddRefs(mRangeArray)); - mScriptObject = nsnull; mAutoScrollTimer = nsnull; NS_NewISupportsArray(getter_AddRefs(mSelectionListeners)); NS_INIT_REFCNT(); @@ -3240,7 +3244,6 @@ nsDOMSelection::nsDOMSelection() mFixupState = PR_FALSE; mDirection = eDirNext; NS_NewISupportsArray(getter_AddRefs(mRangeArray)); - mScriptObject = nsnull; mAutoScrollTimer = nsnull; NS_NewISupportsArray(getter_AddRefs(mSelectionListeners)); NS_INIT_REFCNT(); @@ -3281,7 +3284,7 @@ NS_IMPL_ADDREF(nsDOMSelection) NS_IMPL_RELEASE(nsDOMSelection) -NS_IMPL_QUERY_INTERFACE4(nsDOMSelection, nsIDOMSelection, nsIScriptObjectOwner, nsISupportsWeakReference, nsIIndependentSelection) +NS_IMPL_QUERY_INTERFACE4(nsDOMSelection, nsISelection, nsISelectionPrivate, nsISupportsWeakReference, nsIIndependentSelection) NS_IMETHODIMP @@ -4517,10 +4520,10 @@ nsDOMSelection::GetEnumerator(nsIEnumerator **aIterator) -/** ClearSelection zeroes the selection +/** RemoveAllRanges zeroes the selection */ NS_IMETHODIMP -nsDOMSelection::ClearSelection() +nsDOMSelection::RemoveAllRanges() { if (!mFrameSelection) return NS_OK;//nothing to do @@ -5541,7 +5544,7 @@ nsDOMSelection::SelectAllChildren(nsIDOMNode* aParentNode) if (mFrameSelection) { - mFrameSelection->PostReason(nsIDOMSelectionListener::SELECTALL_REASON); + mFrameSelection->PostReason(nsISelectionListener::SELECTALL_REASON); } nsresult result = Collapse(aParentNode, 0); if (NS_SUCCEEDED(result)) @@ -5554,7 +5557,7 @@ nsDOMSelection::SelectAllChildren(nsIDOMNode* aParentNode) GetChildOffset(lastChild, aParentNode, numBodyChildren); if (mFrameSelection) { - mFrameSelection->PostReason(nsIDOMSelectionListener::SELECTALL_REASON); + mFrameSelection->PostReason(nsISelectionListener::SELECTALL_REASON); } result = Extend(aParentNode, numBodyChildren+1); } @@ -6644,7 +6647,7 @@ nsDOMSelection::ScrollIntoView(SelectionRegion aRegion) NS_IMETHODIMP -nsDOMSelection::AddSelectionListener(nsIDOMSelectionListener* aNewListener) +nsDOMSelection::AddSelectionListener(nsISelectionListener* aNewListener) { if (!mSelectionListeners) return NS_ERROR_FAILURE; @@ -6660,7 +6663,7 @@ nsDOMSelection::AddSelectionListener(nsIDOMSelectionListener* aNewListener) NS_IMETHODIMP -nsDOMSelection::RemoveSelectionListener(nsIDOMSelectionListener* aListenerToRemove) +nsDOMSelection::RemoveSelectionListener(nsISelectionListener* aListenerToRemove) { if (!mSelectionListeners) return NS_ERROR_FAILURE; @@ -6702,7 +6705,7 @@ nsDOMSelection::NotifySelectionListeners() for (PRUint32 i = 0; i < cnt;i++) { nsCOMPtr isupports(dont_AddRef(mSelectionListeners->ElementAt(i))); - nsCOMPtr thisListener = do_QueryInterface(isupports); + nsCOMPtr thisListener = do_QueryInterface(isupports); if (thisListener) thisListener->NotifySelectionChanged(domdoc,this, reason); } @@ -6737,27 +6740,3 @@ nsDOMSelection::DeleteFromDocument() return mFrameSelection->DeleteFromDocument(); } -// BEGIN nsIScriptObjectOwner interface implementations -NS_IMETHODIMP -nsDOMSelection::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject) -{ - nsresult res = NS_OK; - nsIScriptGlobalObject *globalObj = aContext->GetGlobalObject(); - - if (nsnull == mScriptObject) { - res = NS_NewScriptSelection(aContext, (nsISupports *)(nsIDOMSelection *)this, globalObj, (void**)&mScriptObject); - } - *aScriptObject = mScriptObject; - - NS_RELEASE(globalObj); - return res; -} - -NS_IMETHODIMP -nsDOMSelection::SetScriptObject(void *aScriptObject) -{ - mScriptObject = aScriptObject; - return NS_OK; -} - -// END nsIScriptObjectOwner interface implementations diff --git a/mozilla/content/events/src/nsEventStateManager.cpp b/mozilla/content/events/src/nsEventStateManager.cpp index 3b286f3bb71..0dbc1534664 100644 --- a/mozilla/content/events/src/nsEventStateManager.cpp +++ b/mozilla/content/events/src/nsEventStateManager.cpp @@ -47,7 +47,7 @@ #include "nsIWebShell.h" #include "nsIBaseWindow.h" #include "nsIScrollableView.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIFrameSelection.h" #include "nsIDeviceContext.h" #include "nsIScriptGlobalObject.h" diff --git a/mozilla/content/html/content/src/nsAttributeContent.cpp b/mozilla/content/html/content/src/nsAttributeContent.cpp index 0f3ab1bc357..f4da0f72f26 100644 --- a/mozilla/content/html/content/src/nsAttributeContent.cpp +++ b/mozilla/content/html/content/src/nsAttributeContent.cpp @@ -31,7 +31,7 @@ #include "nsIXIFConverter.h" #include "nsRange.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIEnumerator.h" diff --git a/mozilla/content/html/document/src/nsHTMLDocument.cpp b/mozilla/content/html/document/src/nsHTMLDocument.cpp index ce4a1169ce5..9aeee4dd0ca 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/content/html/document/src/nsHTMLDocument.cpp @@ -93,6 +93,7 @@ #include "nsIEventListenerManager.h" #include "nsISelectElement.h" #include "nsIFrameSelection.h" +#include "nsISelectionPrivate.h"//for toStringwithformat code #include "nsICharsetDetector.h" #include "nsICharsetDetectionAdaptor.h" @@ -2842,13 +2843,14 @@ nsHTMLDocument::GetSelection(nsAWritableString& aReturn) if (!selection) return NS_OK; - nsCOMPtr domSelection; + nsCOMPtr domSelection; selection->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(domSelection)); if (!domSelection) return NS_OK; + nsCOMPtr privSel(do_QueryInterface(domSelection)); nsCOMPtr consoleService (do_GetService("mozilla.consoleservice.1")); @@ -2856,8 +2858,14 @@ nsHTMLDocument::GetSelection(nsAWritableString& aReturn) if (consoleService) { consoleService->LogStringMessage(NS_LITERAL_STRING("Deprecated method document.getSelection() called. Please use window.getSelection() instead.").get()); } - - return domSelection->ToString(NS_ConvertASCIItoUCS2("text/plain"), nsIDocumentEncoder::OutputFormatted |nsIDocumentEncoder::OutputSelectionOnly, 0, aReturn); + PRUnichar *tmp; + nsresult rv = privSel->ToStringWithFormat("text/plain", nsIDocumentEncoder::OutputFormatted |nsIDocumentEncoder::OutputSelectionOnly, 0, &tmp); + if (tmp) + { + aReturn.Assign(tmp); + nsMemory::Free(tmp); + } + return rv; } NS_IMETHODIMP @@ -4138,7 +4146,7 @@ nsHTMLDocument::GetForms(nsIDOMHTMLCollection** aForms) } PRBool -nsHTMLDocument::IsInSelection(nsIDOMSelection* aSelection, +nsHTMLDocument::IsInSelection(nsISelection* aSelection, const nsIContent* aContent) const { nsIAtom* tag; diff --git a/mozilla/content/html/document/src/nsHTMLDocument.h b/mozilla/content/html/document/src/nsHTMLDocument.h index 1f21a911565..81f488b15a0 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.h +++ b/mozilla/content/html/document/src/nsHTMLDocument.h @@ -145,7 +145,7 @@ public: /* * Like nsDocument::IsInSelection except it always includes the body node */ - virtual PRBool IsInSelection(nsIDOMSelection* aSelection, const nsIContent *aContent) const; + virtual PRBool IsInSelection(nsISelection* aSelection, const nsIContent *aContent) const; virtual nsresult Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup); protected: diff --git a/mozilla/content/xul/document/src/nsXULDocument.cpp b/mozilla/content/xul/document/src/nsXULDocument.cpp index 95b6e7861bd..9311f538678 100644 --- a/mozilla/content/xul/document/src/nsXULDocument.cpp +++ b/mozilla/content/xul/document/src/nsXULDocument.cpp @@ -1835,7 +1835,7 @@ nsXULDocument::StyleRuleRemoved(nsIStyleSheet* aStyleSheet, } NS_IMETHODIMP -nsXULDocument::GetSelection(nsIDOMSelection** aSelection) +nsXULDocument::GetSelection(nsISelection** aSelection) { if (!mSelection) { NS_ASSERTION(0,"not initialized"); @@ -2012,7 +2012,7 @@ nsXULDocument::IsBefore(const nsIContent *aNewContent, const nsIContent* aCurren } PRBool -nsXULDocument::IsInSelection(nsIDOMSelection* aSelection, const nsIContent *aContent) const +nsXULDocument::IsInSelection(nsISelection* aSelection, const nsIContent *aContent) const { PRBool aYes = PR_FALSE; nsCOMPtr node (do_QueryInterface((nsIContent *) aContent)); @@ -6702,7 +6702,7 @@ NS_IMETHODIMP nsXULDocument::ToXIF(nsIXIFConverter* aConverter, nsIDOMNode* aNode) { nsresult result=NS_OK; - nsCOMPtr sel; + nsCOMPtr sel; aConverter->GetSelection(getter_AddRefs(sel)); if (sel) { @@ -6734,7 +6734,7 @@ nsXULDocument::ToXIF(nsIXIFConverter* aConverter, nsIDOMNode* aNode) } NS_IMETHODIMP -nsXULDocument::CreateXIF(nsAWritableString & aBuffer, nsIDOMSelection* aSelection) +nsXULDocument::CreateXIF(nsAWritableString & aBuffer, nsISelection* aSelection) { nsresult result=NS_OK; diff --git a/mozilla/content/xul/document/src/nsXULDocument.h b/mozilla/content/xul/document/src/nsXULDocument.h index bcffb9f3e75..ea668784919 100644 --- a/mozilla/content/xul/document/src/nsXULDocument.h +++ b/mozilla/content/xul/document/src/nsXULDocument.h @@ -37,7 +37,7 @@ #include "nsIDOMNSDocument.h" #include "nsIDOMDocumentView.h" #include "nsIDOMDocumentXBL.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIDOMXULCommandDispatcher.h" #include "nsIDOMXULDocument.h" #include "nsIDocument.h" @@ -260,13 +260,13 @@ public: NS_IMETHOD StyleRuleRemoved(nsIStyleSheet* aStyleSheet, nsIStyleRule* aStyleRule); - NS_IMETHOD GetSelection(nsIDOMSelection** aSelection); + NS_IMETHOD GetSelection(nsISelection** aSelection); NS_IMETHOD SelectAll(); NS_IMETHOD FindNext(const nsAReadableString &aSearchStr, PRBool aMatchCase, PRBool aSearchDown, PRBool &aIsFound); - NS_IMETHOD CreateXIF(nsAWritableString & aBuffer, nsIDOMSelection* aSelection); + NS_IMETHOD CreateXIF(nsAWritableString & aBuffer, nsISelection* aSelection); NS_IMETHOD ToXIF(nsIXIFConverter *aConverter, nsIDOMNode* aNode); @@ -288,7 +288,7 @@ public: virtual PRBool IsBefore(const nsIContent *aNewContent, const nsIContent* aCurrentContent) const; - virtual PRBool IsInSelection(nsIDOMSelection* aSelection, const nsIContent *aContent) const; + virtual PRBool IsInSelection(nsISelection* aSelection, const nsIContent *aContent) const; virtual nsIContent* GetPrevContent(const nsIContent *aContent) const; @@ -540,7 +540,7 @@ protected: nsString mCharSetID; nsVoidArray mCharSetObservers; nsVoidArray mStyleSheets; - nsCOMPtr mSelection; // [OWNER] + nsCOMPtr mSelection; // [OWNER] PRInt8 mDisplaySelection; PRBool mIsKeyBindingDoc; nsVoidArray mPresShells; diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index c6c17ce7e66..adc56c1a4a0 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -1311,7 +1311,7 @@ nsWebShell::SelectAll(void) nsCOMPtr selCon = do_QueryInterface(presShell); if (NS_FAILED(rv) || !selCon) return rv; - nsCOMPtr selection; + nsCOMPtr selection; rv = selCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection)); if (NS_FAILED(rv) || !selection) return rv; @@ -1341,7 +1341,7 @@ nsWebShell::SelectAll(void) if (NS_FAILED(rv) || !range) return rv; #endif - rv = selection->ClearSelection(); + rv = selection->RemoveAllRanges(); if (NS_FAILED(rv)) return rv; nsCOMPtr range; diff --git a/mozilla/dom/public/base/nsIDOMWindow.h b/mozilla/dom/public/base/nsIDOMWindow.h index a337fddbb40..c3c036ad95d 100644 --- a/mozilla/dom/public/base/nsIDOMWindow.h +++ b/mozilla/dom/public/base/nsIDOMWindow.h @@ -29,9 +29,9 @@ #include "nsIScriptContext.h" class nsIDOMDocument; -class nsIDOMSelection; class nsIDOMBarProp; class nsIDOMWindowCollection; +class nsISelection; class nsIDOMWindow; #define NS_IDOMWINDOW_IID \ @@ -63,11 +63,11 @@ public: NS_IMETHOD ScrollBy(PRInt32 aXScrollDif, PRInt32 aYScrollDif)=0; + NS_IMETHOD GetSelection(nsISelection** aReturn)=0; + NS_IMETHOD ScrollByLines(PRInt32 aNumLines)=0; NS_IMETHOD ScrollByPages(PRInt32 aNumPages)=0; - - NS_IMETHOD GetSelection(nsIDOMSelection** aReturn)=0; }; @@ -83,9 +83,9 @@ public: NS_IMETHOD GetScrollY(PRInt32* aScrollY); \ NS_IMETHOD ScrollTo(PRInt32 aXScroll, PRInt32 aYScroll); \ NS_IMETHOD ScrollBy(PRInt32 aXScrollDif, PRInt32 aYScrollDif); \ + NS_IMETHOD GetSelection(nsISelection** aReturn); \ NS_IMETHOD ScrollByLines(PRInt32 aNumLines); \ NS_IMETHOD ScrollByPages(PRInt32 aNumPages); \ - NS_IMETHOD GetSelection(nsIDOMSelection** aReturn); \ @@ -101,9 +101,9 @@ public: NS_IMETHOD GetScrollY(PRInt32* aScrollY) { return _to GetScrollY(aScrollY); } \ NS_IMETHOD ScrollTo(PRInt32 aXScroll, PRInt32 aYScroll) { return _to ScrollTo(aXScroll, aYScroll); } \ NS_IMETHOD ScrollBy(PRInt32 aXScrollDif, PRInt32 aYScrollDif) { return _to ScrollBy(aXScrollDif, aYScrollDif); } \ + NS_IMETHOD GetSelection(nsISelection** aReturn) { return _to GetSelection(aReturn); } \ NS_IMETHOD ScrollByLines(PRInt32 aNumLines) { return _to ScrollByLines(aNumLines); } \ NS_IMETHOD ScrollByPages(PRInt32 aNumPages) { return _to ScrollByPages(aNumPages); } \ - NS_IMETHOD GetSelection(nsIDOMSelection** aReturn) { return _to GetSelection(aReturn); } \ extern nsresult NS_InitWindowClass(nsIScriptContext *aContext, nsIScriptGlobalObject *aGlobal); diff --git a/mozilla/dom/public/domstubs.idl b/mozilla/dom/public/domstubs.idl index 34436fe945f..1e40cf51c8c 100644 --- a/mozilla/dom/public/domstubs.idl +++ b/mozilla/dom/public/domstubs.idl @@ -77,12 +77,6 @@ interface nsIDOMDocumentFragment : nsIDOMNode {}; [scriptable, uuid(a6cf90ce-15b3-11d2-932e-00805f8add32)] interface nsIDOMRange : nsISupports {}; -[scriptable, uuid(a6cf90e1-15b3-11d2-932e-00805f8add32)] -interface nsIDOMSelection : nsISupports {}; - -[scriptable, uuid(a6cf90e2-15b3-11d2-932e-00805f8add32)] -interface nsIDOMSelectionListener : nsISupports {}; - %{C++ #else @@ -103,7 +97,5 @@ interface nsIDOMSelectionListener : nsISupports {}; class nsIDOMWindowInternal; class nsIDOMDocumentFragment; class nsIDOMRange; - class nsIDOMSelection; - class nsIDOMSelectionListener; #endif %} diff --git a/mozilla/dom/public/idl/base/Window.idl b/mozilla/dom/public/idl/base/Window.idl index 1c93b0a758b..c1a61f8b833 100644 --- a/mozilla/dom/public/idl/base/Window.idl +++ b/mozilla/dom/public/idl/base/Window.idl @@ -12,9 +12,9 @@ interface Window { readonly attribute long scrollY; void scrollTo(in long xScroll, in long yScroll); void scrollBy(in long xScrollDif, in long yScrollDif); + xpidl nsISelection getSelection(); void scrollByLines(in long numLines); void scrollByPages(in long numPages); - Selection getSelection(); }; interface WindowInternal : Window { diff --git a/mozilla/dom/public/nsDOMPropEnums.h b/mozilla/dom/public/nsDOMPropEnums.h index 98ec52f9bf4..2262fb2c8c5 100644 --- a/mozilla/dom/public/nsDOMPropEnums.h +++ b/mozilla/dom/public/nsDOMPropEnums.h @@ -889,31 +889,6 @@ enum nsDOMProp { NS_DOM_PROP_SCREEN_PIXELDEPTH, NS_DOM_PROP_SCREEN_TOP, NS_DOM_PROP_SCREEN_WIDTH, - NS_DOM_PROP_SELECTION_ADDRANGE, - NS_DOM_PROP_SELECTION_ADDSELECTIONLISTENER, - NS_DOM_PROP_SELECTION_ANCHORNODE, - NS_DOM_PROP_SELECTION_ANCHOROFFSET, - NS_DOM_PROP_SELECTION_CLEARSELECTION, - NS_DOM_PROP_SELECTION_COLLAPSE, - NS_DOM_PROP_SELECTION_COLLAPSETOEND, - NS_DOM_PROP_SELECTION_COLLAPSETOSTART, - NS_DOM_PROP_SELECTION_CONTAINSNODE, - NS_DOM_PROP_SELECTION_DELETEFROMDOCUMENT, - NS_DOM_PROP_SELECTION_ENDBATCHCHANGES, - NS_DOM_PROP_SELECTION_EXTEND, - NS_DOM_PROP_SELECTION_FOCUSNODE, - NS_DOM_PROP_SELECTION_FOCUSOFFSET, - NS_DOM_PROP_SELECTION_GETHINT, - NS_DOM_PROP_SELECTION_GETRANGEAT, - NS_DOM_PROP_SELECTION_ISCOLLAPSED, - NS_DOM_PROP_SELECTION_RANGECOUNT, - NS_DOM_PROP_SELECTION_REMOVERANGE, - NS_DOM_PROP_SELECTION_REMOVESELECTIONLISTENER, - NS_DOM_PROP_SELECTION_SELECTALLCHILDREN, - NS_DOM_PROP_SELECTION_SETHINT, - NS_DOM_PROP_SELECTION_STARTBATCHCHANGES, - NS_DOM_PROP_SELECTION_TOSTRING, - NS_DOM_PROP_SELECTIONLISTENER_NOTIFYSELECTIONCHANGED, NS_DOM_PROP_STYLESHEET_DISABLED, NS_DOM_PROP_STYLESHEET_HREF, NS_DOM_PROP_STYLESHEET_MEDIA, diff --git a/mozilla/dom/public/nsDOMPropNames.h b/mozilla/dom/public/nsDOMPropNames.h index 702186ebc93..6d1a45990f5 100644 --- a/mozilla/dom/public/nsDOMPropNames.h +++ b/mozilla/dom/public/nsDOMPropNames.h @@ -887,31 +887,6 @@ "screen.pixeldepth", \ "screen.top", \ "screen.width", \ - "selection.addrange", \ - "selection.addselectionlistener", \ - "selection.anchornode", \ - "selection.anchoroffset", \ - "selection.clearselection", \ - "selection.collapse", \ - "selection.collapsetoend", \ - "selection.collapsetostart", \ - "selection.containsnode", \ - "selection.deletefromdocument", \ - "selection.endbatchchanges", \ - "selection.extend", \ - "selection.focusnode", \ - "selection.focusoffset", \ - "selection.gethint", \ - "selection.getrangeat", \ - "selection.iscollapsed", \ - "selection.rangecount", \ - "selection.removerange", \ - "selection.removeselectionlistener", \ - "selection.selectallchildren", \ - "selection.sethint", \ - "selection.startbatchchanges", \ - "selection.tostring", \ - "selectionlistener.notifyselectionchanged", \ "stylesheet.disabled", \ "stylesheet.href", \ "stylesheet.media", \ diff --git a/mozilla/dom/public/range/MANIFEST b/mozilla/dom/public/range/MANIFEST index 085341e8f9c..19b72e0e30d 100644 --- a/mozilla/dom/public/range/MANIFEST +++ b/mozilla/dom/public/range/MANIFEST @@ -22,5 +22,3 @@ nsIDOMRange.h nsIDOMNSRange.h -nsIDOMSelection.h -nsIDOMSelectionListener.h diff --git a/mozilla/dom/public/range/Makefile.in b/mozilla/dom/public/range/Makefile.in index 2242607c2ae..32fd0eb6a04 100644 --- a/mozilla/dom/public/range/Makefile.in +++ b/mozilla/dom/public/range/Makefile.in @@ -31,8 +31,6 @@ MODULE = dom EXPORTS = \ nsIDOMRange.h \ nsIDOMNSRange.h \ - nsIDOMSelection.h \ - nsIDOMSelectionListener.h \ $(NULL) EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS)) diff --git a/mozilla/dom/public/range/makefile.win b/mozilla/dom/public/range/makefile.win index 5f51faa607a..f2a6518f749 100644 --- a/mozilla/dom/public/range/makefile.win +++ b/mozilla/dom/public/range/makefile.win @@ -26,8 +26,6 @@ DEFINES=-D_IMPL_NS_DOM EXPORTS = \ nsIDOMRange.h \ nsIDOMNSRange.h \ - nsIDOMSelection.h \ - nsIDOMSelectionListener.h \ $(NULL) diff --git a/mozilla/dom/public/range/nsIDOMSelection.h b/mozilla/dom/public/range/nsIDOMSelection.h deleted file mode 100644 index 74e9ad75d22..00000000000 --- a/mozilla/dom/public/range/nsIDOMSelection.h +++ /dev/null @@ -1,157 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ -/* AUTO-GENERATED. DO NOT EDIT!!! */ - -#ifndef nsIDOMSelection_h__ -#define nsIDOMSelection_h__ - -#include "nsISupports.h" -#include "nsString.h" -#include "nsIScriptContext.h" - -class nsIDOMNode; -class nsIDOMSelectionListener; -class nsIEnumerator; -class nsIDOMRange; - -#define NS_IDOMSELECTION_IID \ - { 0xa6cf90e1, 0x15b3, 0x11d2, \ - { 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } } - -class nsIDOMSelection : public nsISupports { -public: - static const nsIID& GetIID() { static nsIID iid = NS_IDOMSELECTION_IID; return iid; } - - NS_IMETHOD GetAnchorNode(nsIDOMNode** aAnchorNode)=0; - - NS_IMETHOD GetAnchorOffset(PRInt32* aAnchorOffset)=0; - - NS_IMETHOD GetFocusNode(nsIDOMNode** aFocusNode)=0; - - NS_IMETHOD GetFocusOffset(PRInt32* aFocusOffset)=0; - - NS_IMETHOD GetIsCollapsed(PRBool* aIsCollapsed)=0; - - NS_IMETHOD GetRangeCount(PRInt32* aRangeCount)=0; - - NS_IMETHOD GetRangeAt(PRInt32 aIndex, nsIDOMRange** aReturn)=0; - - NS_IMETHOD ClearSelection()=0; - - NS_IMETHOD Collapse(nsIDOMNode* aParentNode, PRInt32 aOffset)=0; - - NS_IMETHOD Extend(nsIDOMNode* aParentNode, PRInt32 aOffset)=0; - - NS_IMETHOD CollapseToStart()=0; - - NS_IMETHOD CollapseToEnd()=0; - - NS_IMETHOD SelectAllChildren(nsIDOMNode* aParentNode)=0; - - NS_IMETHOD ContainsNode(nsIDOMNode* aNode, PRBool aRecursive, PRBool* aReturn)=0; - - NS_IMETHOD DeleteFromDocument()=0; - - NS_IMETHOD AddRange(nsIDOMRange* aRange)=0; - - NS_IMETHOD RemoveRange(nsIDOMRange* aRange)=0; - - NS_IMETHOD StartBatchChanges()=0; - - NS_IMETHOD EndBatchChanges()=0; - - NS_IMETHOD AddSelectionListener(nsIDOMSelectionListener* aNewListener)=0; - - NS_IMETHOD RemoveSelectionListener(nsIDOMSelectionListener* aListenerToRemove)=0; - - NS_IMETHOD SetHint(PRBool aRight)=0; - - NS_IMETHOD GetHint(PRBool* aReturn)=0; - - NS_IMETHOD GetEnumerator(nsIEnumerator** aReturn)=0; - - NS_IMETHOD ToString(const nsAReadableString& aFormatType, PRUint32 aFlags, PRInt32 aWrapCount, nsAWritableString& aReturn)=0; -}; - - -#define NS_DECL_IDOMSELECTION \ - NS_IMETHOD GetAnchorNode(nsIDOMNode** aAnchorNode); \ - NS_IMETHOD GetAnchorOffset(PRInt32* aAnchorOffset); \ - NS_IMETHOD GetFocusNode(nsIDOMNode** aFocusNode); \ - NS_IMETHOD GetFocusOffset(PRInt32* aFocusOffset); \ - NS_IMETHOD GetIsCollapsed(PRBool* aIsCollapsed); \ - NS_IMETHOD GetRangeCount(PRInt32* aRangeCount); \ - NS_IMETHOD GetRangeAt(PRInt32 aIndex, nsIDOMRange** aReturn); \ - NS_IMETHOD ClearSelection(); \ - NS_IMETHOD Collapse(nsIDOMNode* aParentNode, PRInt32 aOffset); \ - NS_IMETHOD Extend(nsIDOMNode* aParentNode, PRInt32 aOffset); \ - NS_IMETHOD CollapseToStart(); \ - NS_IMETHOD CollapseToEnd(); \ - NS_IMETHOD SelectAllChildren(nsIDOMNode* aParentNode); \ - NS_IMETHOD ContainsNode(nsIDOMNode* aNode, PRBool aRecursive, PRBool* aReturn); \ - NS_IMETHOD DeleteFromDocument(); \ - NS_IMETHOD AddRange(nsIDOMRange* aRange); \ - NS_IMETHOD RemoveRange(nsIDOMRange* aRange); \ - NS_IMETHOD StartBatchChanges(); \ - NS_IMETHOD EndBatchChanges(); \ - NS_IMETHOD AddSelectionListener(nsIDOMSelectionListener* aNewListener); \ - NS_IMETHOD RemoveSelectionListener(nsIDOMSelectionListener* aListenerToRemove); \ - NS_IMETHOD SetHint(PRBool aRight); \ - NS_IMETHOD GetHint(PRBool* aReturn); \ - NS_IMETHOD GetEnumerator(nsIEnumerator** aReturn); \ - NS_IMETHOD ToString(const nsAReadableString& aFormatType, PRUint32 aFlags, PRInt32 aWrapCount, nsAWritableString& aReturn); \ - - - -#define NS_FORWARD_IDOMSELECTION(_to) \ - NS_IMETHOD GetAnchorNode(nsIDOMNode** aAnchorNode) { return _to GetAnchorNode(aAnchorNode); } \ - NS_IMETHOD GetAnchorOffset(PRInt32* aAnchorOffset) { return _to GetAnchorOffset(aAnchorOffset); } \ - NS_IMETHOD GetFocusNode(nsIDOMNode** aFocusNode) { return _to GetFocusNode(aFocusNode); } \ - NS_IMETHOD GetFocusOffset(PRInt32* aFocusOffset) { return _to GetFocusOffset(aFocusOffset); } \ - NS_IMETHOD GetIsCollapsed(PRBool* aIsCollapsed) { return _to GetIsCollapsed(aIsCollapsed); } \ - NS_IMETHOD GetRangeCount(PRInt32* aRangeCount) { return _to GetRangeCount(aRangeCount); } \ - NS_IMETHOD GetRangeAt(PRInt32 aIndex, nsIDOMRange** aReturn) { return _to GetRangeAt(aIndex, aReturn); } \ - NS_IMETHOD ClearSelection() { return _to ClearSelection(); } \ - NS_IMETHOD Collapse(nsIDOMNode* aParentNode, PRInt32 aOffset) { return _to Collapse(aParentNode, aOffset); } \ - NS_IMETHOD Extend(nsIDOMNode* aParentNode, PRInt32 aOffset) { return _to Extend(aParentNode, aOffset); } \ - NS_IMETHOD CollapseToStart() { return _to CollapseToStart(); } \ - NS_IMETHOD CollapseToEnd() { return _to CollapseToEnd(); } \ - NS_IMETHOD SelectAllChildren(nsIDOMNode* aParentNode) { return _to SelectAllChildren(aParentNode); } \ - NS_IMETHOD ContainsNode(nsIDOMNode* aNode, PRBool aRecursive, PRBool* aReturn) { return _to ContainsNode(aNode, aRecursive, aReturn); } \ - NS_IMETHOD DeleteFromDocument() { return _to DeleteFromDocument(); } \ - NS_IMETHOD AddRange(nsIDOMRange* aRange) { return _to AddRange(aRange); } \ - NS_IMETHOD RemoveRange(nsIDOMRange* aRange) { return _to RemoveRange(aRange); } \ - NS_IMETHOD StartBatchChanges() { return _to StartBatchChanges(); } \ - NS_IMETHOD EndBatchChanges() { return _to EndBatchChanges(); } \ - NS_IMETHOD AddSelectionListener(nsIDOMSelectionListener* aNewListener) { return _to AddSelectionListener(aNewListener); } \ - NS_IMETHOD RemoveSelectionListener(nsIDOMSelectionListener* aListenerToRemove) { return _to RemoveSelectionListener(aListenerToRemove); } \ - NS_IMETHOD SetHint(PRBool aRight) { return _to SetHint(aRight); } \ - NS_IMETHOD GetHint(PRBool* aReturn) { return _to GetHint(aReturn); } \ - NS_IMETHOD GetEnumerator(nsIEnumerator** aReturn) { return _to GetEnumerator(aReturn); } \ - NS_IMETHOD ToString(const nsAReadableString& aFormatType, PRUint32 aFlags, PRInt32 aWrapCount, nsAWritableString& aReturn) { return _to ToString(aFormatType, aFlags, aWrapCount, aReturn); } \ - - -extern "C" NS_DOM nsresult NS_InitSelectionClass(nsIScriptContext *aContext, void **aPrototype); - -extern "C" NS_DOM nsresult NS_NewScriptSelection(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn); - -#endif // nsIDOMSelection_h__ diff --git a/mozilla/dom/public/range/nsIDOMSelectionListener.h b/mozilla/dom/public/range/nsIDOMSelectionListener.h deleted file mode 100644 index cd4eb436e0d..00000000000 --- a/mozilla/dom/public/range/nsIDOMSelectionListener.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ -/* AUTO-GENERATED. DO NOT EDIT!!! */ - -#ifndef nsIDOMSelectionListener_h__ -#define nsIDOMSelectionListener_h__ - -#include "nsISupports.h" -#include "nsString.h" -#include "nsIScriptContext.h" - -class nsIDOMDocument; -class nsIDOMSelection; - -#define NS_IDOMSELECTIONLISTENER_IID \ - { 0xa6cf90e2, 0x15b3, 0x11d2, \ - { 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} } - -class nsIDOMSelectionListener : public nsISupports { -public: - static const nsIID& GetIID() { static nsIID iid = NS_IDOMSELECTIONLISTENER_IID; return iid; } - enum { - NO_REASON = 0, - DRAG_REASON = 1, - MOUSEDOWN_REASON = 2, - MOUSEUP_REASON = 4, - KEYPRESS_REASON = 8, - SELECTALL_REASON = 16 - }; - - NS_IMETHOD NotifySelectionChanged(nsIDOMDocument* aDoc, nsIDOMSelection* aSel, PRInt16 aReason)=0; -}; - - -#define NS_DECL_IDOMSELECTIONLISTENER \ - NS_IMETHOD NotifySelectionChanged(nsIDOMDocument* aDoc, nsIDOMSelection* aSel, PRInt16 aReason); \ - - - -#define NS_FORWARD_IDOMSELECTIONLISTENER(_to) \ - NS_IMETHOD NotifySelectionChanged(nsIDOMDocument* aDoc, nsIDOMSelection* aSel, PRInt16 aReason) { return _to NotifySelectionChanged(aDoc, aSel, aReason); } \ - - -extern "C" NS_DOM nsresult NS_InitSelectionListenerClass(nsIScriptContext *aContext, void **aPrototype); - -extern "C" NS_DOM nsresult NS_NewScriptSelectionListener(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn); - -#endif // nsIDOMSelectionListener_h__ diff --git a/mozilla/dom/src/base/nsGlobalWindow.cpp b/mozilla/dom/src/base/nsGlobalWindow.cpp index 5705e3ab33f..643a0118715 100644 --- a/mozilla/dom/src/base/nsGlobalWindow.cpp +++ b/mozilla/dom/src/base/nsGlobalWindow.cpp @@ -87,7 +87,7 @@ #include "nsIScriptGlobalObjectOwner.h" #include "nsIScriptSecurityManager.h" #include "nsISelectionController.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIFrameSelection.h" #include "nsISidebar.h" // XXX for sidebar HACK, see bug 20721 #include "nsIPrompt.h" @@ -2213,7 +2213,7 @@ NS_IMETHODIMP GlobalWindowImpl::Unescape(const nsAReadableString& aStr, return NS_OK; } -NS_IMETHODIMP GlobalWindowImpl::GetSelection(nsIDOMSelection** aSelection) +NS_IMETHODIMP GlobalWindowImpl::GetSelection(nsISelection** aSelection) { NS_ENSURE_ARG_POINTER(aSelection); *aSelection = nsnull; diff --git a/mozilla/dom/src/base/nsJSWindow.cpp b/mozilla/dom/src/base/nsJSWindow.cpp index 8ebb320b095..a75b6669450 100644 --- a/mozilla/dom/src/base/nsJSWindow.cpp +++ b/mozilla/dom/src/base/nsJSWindow.cpp @@ -40,7 +40,6 @@ #include "nsIDOMDocumentView.h" #include "nsIDOMCSSStyleDeclaration.h" #include "nsIDOMDocument.h" -#include "nsIDOMSelection.h" #include "nsIDOMBarProp.h" #include "nsIDOMAbstractView.h" #include "nsIDOMScreen.h" @@ -53,6 +52,7 @@ #include "nsISidebar.h" #include "nsIDOMPkcs11.h" #include "nsIDOMViewCSS.h" +#include "nsISelection.h" #include "nsIDOMCrypto.h" #include "nsIDOMWindow.h" #include "nsIControllers.h" @@ -68,7 +68,6 @@ static NS_DEFINE_IID(kIElementIID, NS_IDOMELEMENT_IID); static NS_DEFINE_IID(kIDocumentViewIID, NS_IDOMDOCUMENTVIEW_IID); static NS_DEFINE_IID(kICSSStyleDeclarationIID, NS_IDOMCSSSTYLEDECLARATION_IID); static NS_DEFINE_IID(kIDocumentIID, NS_IDOMDOCUMENT_IID); -static NS_DEFINE_IID(kISelectionIID, NS_IDOMSELECTION_IID); static NS_DEFINE_IID(kIBarPropIID, NS_IDOMBARPROP_IID); static NS_DEFINE_IID(kIAbstractViewIID, NS_IDOMABSTRACTVIEW_IID); static NS_DEFINE_IID(kIScreenIID, NS_IDOMSCREEN_IID); @@ -81,6 +80,7 @@ static NS_DEFINE_IID(kIEventTargetIID, NS_IDOMEVENTTARGET_IID); static NS_DEFINE_IID(kISidebarIID, NS_ISIDEBAR_IID); static NS_DEFINE_IID(kIPkcs11IID, NS_IDOMPKCS11_IID); static NS_DEFINE_IID(kIViewCSSIID, NS_IDOMVIEWCSS_IID); +static NS_DEFINE_IID(kISelectionIID, NS_ISELECTION_IID); static NS_DEFINE_IID(kICryptoIID, NS_IDOMCRYPTO_IID); static NS_DEFINE_IID(kIWindowIID, NS_IDOMWINDOW_IID); static NS_DEFINE_IID(kIControllersIID, NS_ICONTROLLERS_IID); @@ -2726,6 +2726,43 @@ WindowScrollBy(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rva } +// +// Native method GetSelection +// +PR_STATIC_CALLBACK(JSBool) +WindowGetSelection(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMWindow *nativeThis = (nsIDOMWindow*)nsJSUtils::nsGetNativeThis(cx, obj); + nsresult result = NS_OK; + nsISelection* nativeRet; + // If there's no private data, this must be the prototype, so ignore + if (nsnull == nativeThis) { + return JS_TRUE; + } + + { + *rval = JSVAL_NULL; + nsIScriptSecurityManager *secMan = nsJSUtils::nsGetSecurityManager(cx, obj); + if (!secMan) + return PR_FALSE; + result = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_WINDOW_GETSELECTION, PR_FALSE); + if (NS_FAILED(result)) { + return nsJSUtils::nsReportError(cx, obj, result); + } + + result = nativeThis->GetSelection(&nativeRet); + if (NS_FAILED(result)) { + return nsJSUtils::nsReportError(cx, obj, result); + } + + // n.b., this will release nativeRet + nsJSUtils::nsConvertXPCObjectToJSVal(nativeRet, NS_GET_IID(nsISelection), cx, obj, rval); + } + + return JS_TRUE; +} + + // // Native method ScrollByLines // @@ -2812,42 +2849,6 @@ WindowScrollByPages(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval } -// -// Native method GetSelection -// -PR_STATIC_CALLBACK(JSBool) -WindowGetSelection(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) -{ - nsIDOMWindow *nativeThis = (nsIDOMWindow*)nsJSUtils::nsGetNativeThis(cx, obj); - nsresult result = NS_OK; - nsIDOMSelection* nativeRet; - // If there's no private data, this must be the prototype, so ignore - if (nsnull == nativeThis) { - return JS_TRUE; - } - - { - *rval = JSVAL_NULL; - nsIScriptSecurityManager *secMan = nsJSUtils::nsGetSecurityManager(cx, obj); - if (!secMan) - return PR_FALSE; - result = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_WINDOW_GETSELECTION, PR_FALSE); - if (NS_FAILED(result)) { - return nsJSUtils::nsReportError(cx, obj, result); - } - - result = nativeThis->GetSelection(&nativeRet); - if (NS_FAILED(result)) { - return nsJSUtils::nsReportError(cx, obj, result); - } - - nsJSUtils::nsConvertObjectToJSVal(nativeRet, cx, obj, rval); - } - - return JS_TRUE; -} - - // // Native method Dump // @@ -4672,9 +4673,9 @@ static JSFunctionSpec WindowMethods[] = { {"scrollTo", WindowScrollTo, 2}, {"scrollBy", WindowScrollBy, 2}, + {"getSelection", WindowGetSelection, 0}, {"scrollByLines", WindowScrollByLines, 1}, {"scrollByPages", WindowScrollByPages, 1}, - {"getSelection", WindowGetSelection, 0}, {"dump", WindowInternalDump, 1}, {"alert", WindowInternalAlert, 0}, {"confirm", WindowInternalConfirm, 0}, diff --git a/mozilla/dom/src/build/nsDOMFactory.cpp b/mozilla/dom/src/build/nsDOMFactory.cpp index af9baee5ec1..0055b24a539 100644 --- a/mozilla/dom/src/build/nsDOMFactory.cpp +++ b/mozilla/dom/src/build/nsDOMFactory.cpp @@ -132,8 +132,6 @@ #include "nsIDOMCSSMediaRule.h" #include "nsIDOMCSSRuleList.h" #include "nsIDOMRange.h" -#include "nsIDOMSelection.h" -#include "nsIDOMSelectionListener.h" #include "nsIDOMMediaList.h" #include "nsIDOMCrypto.h" #include "nsIDOMCRMFObject.h" @@ -773,8 +771,6 @@ void XXXDomNeverCalled() NS_NewScriptCSSMediaRule(0, 0, 0, 0); NS_NewScriptCSSRuleList(0, 0, 0, 0); NS_NewScriptRange(0, 0, 0, 0); - NS_NewScriptSelection(0, 0, 0, 0); - NS_NewScriptSelectionListener(0, 0, 0, 0); NS_NewScriptHTMLFormControlList(0, 0, 0, 0); NS_InitDocumentClass(nsnull, nsnull); NS_NewScriptNSHTMLOptionCollection(0, 0, 0, 0); diff --git a/mozilla/dom/src/range/Makefile.in b/mozilla/dom/src/range/Makefile.in index db61d36912f..e1a807e6baa 100644 --- a/mozilla/dom/src/range/Makefile.in +++ b/mozilla/dom/src/range/Makefile.in @@ -32,8 +32,6 @@ LIBRARY_NAME = jsdomrange_s CPPSRCS = \ nsJSRange.cpp \ - nsJSSelection.cpp \ - nsJSSelectionListener.cpp \ $(NULL) # we don't want the shared lib, but we want to force the creation of a static lib. diff --git a/mozilla/dom/src/range/makefile.win b/mozilla/dom/src/range/makefile.win index 2b0a9e9fe6a..2c609c91b69 100644 --- a/mozilla/dom/src/range/makefile.win +++ b/mozilla/dom/src/range/makefile.win @@ -29,12 +29,10 @@ DEFINES=-D_IMPL_NS_DOM -DWIN32_LEAN_AND_MEAN CPPSRCS = \ nsJSRange.cpp \ - nsJSSelection.cpp \ - nsJSSelectionListener.cpp \ $(NULL) CPP_OBJS= \ - .\$(OBJDIR)\nsJSRange.obj .\$(OBJDIR)\nsJSSelection.obj .\$(OBJDIR)\nsJSSelectionListener.obj + .\$(OBJDIR)\nsJSRange.obj LINCS=-I$(XPDIST)\public\xpcom -I$(XPDIST)\public\raptor -I$(XPDIST)\public\dom -I$(XPDIST)\public\js diff --git a/mozilla/dom/src/range/nsJSSelection.cpp b/mozilla/dom/src/range/nsJSSelection.cpp deleted file mode 100644 index 66e1819919a..00000000000 --- a/mozilla/dom/src/range/nsJSSelection.cpp +++ /dev/null @@ -1,1176 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ -/* AUTO-GENERATED. DO NOT EDIT!!! */ - -#include "jsapi.h" -#include "nsJSUtils.h" -#include "nsDOMError.h" -#include "nscore.h" -#include "nsIServiceManager.h" -#include "nsIScriptContext.h" -#include "nsIScriptSecurityManager.h" -#include "nsIJSScriptObject.h" -#include "nsIScriptObjectOwner.h" -#include "nsIScriptGlobalObject.h" -#include "nsCOMPtr.h" -#include "nsDOMPropEnums.h" -#include "nsString.h" -#include "nsIDOMSelection.h" -#include "nsIDOMNode.h" -#include "nsIDOMSelectionListener.h" -#include "nsIEnumerator.h" -#include "nsIDOMRange.h" - - -static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID); -static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID); -static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID); -static NS_DEFINE_IID(kISelectionIID, NS_IDOMSELECTION_IID); -static NS_DEFINE_IID(kINodeIID, NS_IDOMNODE_IID); -static NS_DEFINE_IID(kISelectionListenerIID, NS_IDOMSELECTIONLISTENER_IID); -static NS_DEFINE_IID(kIEnumeratorIID, NS_IENUMERATOR_IID); -static NS_DEFINE_IID(kIRangeIID, NS_IDOMRANGE_IID); - -// -// Selection property ids -// -enum Selection_slots { - SELECTION_ANCHORNODE = -1, - SELECTION_ANCHOROFFSET = -2, - SELECTION_FOCUSNODE = -3, - SELECTION_FOCUSOFFSET = -4, - SELECTION_ISCOLLAPSED = -5, - SELECTION_RANGECOUNT = -6 -}; - -/***********************************************************************/ -// -// Selection Properties Getter -// -PR_STATIC_CALLBACK(JSBool) -GetSelectionProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) -{ - nsIDOMSelection *a = (nsIDOMSelection*)nsJSUtils::nsGetNativeThis(cx, obj); - - // If there's no private data, this must be the prototype, so ignore - if (nsnull == a) { - return JS_TRUE; - } - - nsresult rv = NS_OK; - if (JSVAL_IS_INT(id)) { - nsIScriptSecurityManager *secMan = nsJSUtils::nsGetSecurityManager(cx, obj); - if (!secMan) - return PR_FALSE; - switch(JSVAL_TO_INT(id)) { - case SELECTION_ANCHORNODE: - { - rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_SELECTION_ANCHORNODE, PR_FALSE); - if (NS_SUCCEEDED(rv)) { - nsIDOMNode* prop; - rv = a->GetAnchorNode(&prop); - if (NS_SUCCEEDED(rv)) { - // get the js object - nsJSUtils::nsConvertObjectToJSVal((nsISupports *)prop, cx, obj, vp); - } - } - break; - } - case SELECTION_ANCHOROFFSET: - { - rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_SELECTION_ANCHOROFFSET, PR_FALSE); - if (NS_SUCCEEDED(rv)) { - PRInt32 prop; - rv = a->GetAnchorOffset(&prop); - if (NS_SUCCEEDED(rv)) { - *vp = INT_TO_JSVAL(prop); - } - } - break; - } - case SELECTION_FOCUSNODE: - { - rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_SELECTION_FOCUSNODE, PR_FALSE); - if (NS_SUCCEEDED(rv)) { - nsIDOMNode* prop; - rv = a->GetFocusNode(&prop); - if (NS_SUCCEEDED(rv)) { - // get the js object - nsJSUtils::nsConvertObjectToJSVal((nsISupports *)prop, cx, obj, vp); - } - } - break; - } - case SELECTION_FOCUSOFFSET: - { - rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_SELECTION_FOCUSOFFSET, PR_FALSE); - if (NS_SUCCEEDED(rv)) { - PRInt32 prop; - rv = a->GetFocusOffset(&prop); - if (NS_SUCCEEDED(rv)) { - *vp = INT_TO_JSVAL(prop); - } - } - break; - } - case SELECTION_ISCOLLAPSED: - { - rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_SELECTION_ISCOLLAPSED, PR_FALSE); - if (NS_SUCCEEDED(rv)) { - PRBool prop; - rv = a->GetIsCollapsed(&prop); - if (NS_SUCCEEDED(rv)) { - *vp = BOOLEAN_TO_JSVAL(prop); - } - } - break; - } - case SELECTION_RANGECOUNT: - { - rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_SELECTION_RANGECOUNT, PR_FALSE); - if (NS_SUCCEEDED(rv)) { - PRInt32 prop; - rv = a->GetRangeCount(&prop); - if (NS_SUCCEEDED(rv)) { - *vp = INT_TO_JSVAL(prop); - } - } - break; - } - default: - return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, obj, id, vp); - } - } - else { - return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, obj, id, vp); - } - - if (NS_FAILED(rv)) - return nsJSUtils::nsReportError(cx, obj, rv); - return PR_TRUE; -} - -/***********************************************************************/ -// -// Selection Properties Setter -// -PR_STATIC_CALLBACK(JSBool) -SetSelectionProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) -{ - nsIDOMSelection *a = (nsIDOMSelection*)nsJSUtils::nsGetNativeThis(cx, obj); - - // If there's no private data, this must be the prototype, so ignore - if (nsnull == a) { - return JS_TRUE; - } - - nsresult rv = NS_OK; - if (JSVAL_IS_INT(id)) { - nsIScriptSecurityManager *secMan = nsJSUtils::nsGetSecurityManager(cx, obj); - if (!secMan) - return PR_FALSE; - switch(JSVAL_TO_INT(id)) { - case 0: - default: - return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, obj, id, vp); - } - } - else { - return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, obj, id, vp); - } - - if (NS_FAILED(rv)) - return nsJSUtils::nsReportError(cx, obj, rv); - return PR_TRUE; -} - - -// -// Selection finalizer -// -PR_STATIC_CALLBACK(void) -FinalizeSelection(JSContext *cx, JSObject *obj) -{ - nsJSUtils::nsGenericFinalize(cx, obj); -} - - -// -// Selection enumerate -// -PR_STATIC_CALLBACK(JSBool) -EnumerateSelection(JSContext *cx, JSObject *obj) -{ - return nsJSUtils::nsGenericEnumerate(cx, obj); -} - - -// -// Selection resolve -// -PR_STATIC_CALLBACK(JSBool) -ResolveSelection(JSContext *cx, JSObject *obj, jsval id) -{ - return nsJSUtils::nsGenericResolve(cx, obj, id); -} - - -// -// Native method GetRangeAt -// -PR_STATIC_CALLBACK(JSBool) -SelectionGetRangeAt(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) -{ - nsIDOMSelection *nativeThis = (nsIDOMSelection*)nsJSUtils::nsGetNativeThis(cx, obj); - nsresult result = NS_OK; - nsIDOMRange* nativeRet; - PRInt32 b0; - // If there's no private data, this must be the prototype, so ignore - if (nsnull == nativeThis) { - return JS_TRUE; - } - - { - *rval = JSVAL_NULL; - nsIScriptSecurityManager *secMan = nsJSUtils::nsGetSecurityManager(cx, obj); - if (!secMan) - return PR_FALSE; - result = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_SELECTION_GETRANGEAT, PR_FALSE); - if (NS_FAILED(result)) { - return nsJSUtils::nsReportError(cx, obj, result); - } - if (argc < 1) { - return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_TOO_FEW_PARAMETERS_ERR); - } - - if (!JS_ValueToInt32(cx, argv[0], (int32 *)&b0)) { - return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_NOT_NUMBER_ERR); - } - - result = nativeThis->GetRangeAt(b0, &nativeRet); - if (NS_FAILED(result)) { - return nsJSUtils::nsReportError(cx, obj, result); - } - - nsJSUtils::nsConvertObjectToJSVal(nativeRet, cx, obj, rval); - } - - return JS_TRUE; -} - - -// -// Native method ClearSelection -// -PR_STATIC_CALLBACK(JSBool) -SelectionClearSelection(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) -{ - nsIDOMSelection *nativeThis = (nsIDOMSelection*)nsJSUtils::nsGetNativeThis(cx, obj); - nsresult result = NS_OK; - // If there's no private data, this must be the prototype, so ignore - if (nsnull == nativeThis) { - return JS_TRUE; - } - - { - *rval = JSVAL_NULL; - nsIScriptSecurityManager *secMan = nsJSUtils::nsGetSecurityManager(cx, obj); - if (!secMan) - return PR_FALSE; - result = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_SELECTION_CLEARSELECTION, PR_FALSE); - if (NS_FAILED(result)) { - return nsJSUtils::nsReportError(cx, obj, result); - } - - result = nativeThis->ClearSelection(); - if (NS_FAILED(result)) { - return nsJSUtils::nsReportError(cx, obj, result); - } - - *rval = JSVAL_VOID; - } - - return JS_TRUE; -} - - -// -// Native method Collapse -// -PR_STATIC_CALLBACK(JSBool) -SelectionCollapse(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) -{ - nsIDOMSelection *nativeThis = (nsIDOMSelection*)nsJSUtils::nsGetNativeThis(cx, obj); - nsresult result = NS_OK; - nsCOMPtr b0; - PRInt32 b1; - // If there's no private data, this must be the prototype, so ignore - if (nsnull == nativeThis) { - return JS_TRUE; - } - - { - *rval = JSVAL_NULL; - nsIScriptSecurityManager *secMan = nsJSUtils::nsGetSecurityManager(cx, obj); - if (!secMan) - return PR_FALSE; - result = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_SELECTION_COLLAPSE, PR_FALSE); - if (NS_FAILED(result)) { - return nsJSUtils::nsReportError(cx, obj, result); - } - if (argc < 2) { - return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_TOO_FEW_PARAMETERS_ERR); - } - - if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)(void**)getter_AddRefs(b0), - kINodeIID, - NS_ConvertASCIItoUCS2("Node"), - cx, - argv[0])) { - return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_NOT_OBJECT_ERR); - } - if (!JS_ValueToInt32(cx, argv[1], (int32 *)&b1)) { - return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_NOT_NUMBER_ERR); - } - - result = nativeThis->Collapse(b0, b1); - if (NS_FAILED(result)) { - return nsJSUtils::nsReportError(cx, obj, result); - } - - *rval = JSVAL_VOID; - } - - return JS_TRUE; -} - - -// -// Native method Extend -// -PR_STATIC_CALLBACK(JSBool) -SelectionExtend(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) -{ - nsIDOMSelection *nativeThis = (nsIDOMSelection*)nsJSUtils::nsGetNativeThis(cx, obj); - nsresult result = NS_OK; - nsCOMPtr b0; - PRInt32 b1; - // If there's no private data, this must be the prototype, so ignore - if (nsnull == nativeThis) { - return JS_TRUE; - } - - { - *rval = JSVAL_NULL; - nsIScriptSecurityManager *secMan = nsJSUtils::nsGetSecurityManager(cx, obj); - if (!secMan) - return PR_FALSE; - result = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_SELECTION_EXTEND, PR_FALSE); - if (NS_FAILED(result)) { - return nsJSUtils::nsReportError(cx, obj, result); - } - if (argc < 2) { - return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_TOO_FEW_PARAMETERS_ERR); - } - - if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)(void**)getter_AddRefs(b0), - kINodeIID, - NS_ConvertASCIItoUCS2("Node"), - cx, - argv[0])) { - return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_NOT_OBJECT_ERR); - } - if (!JS_ValueToInt32(cx, argv[1], (int32 *)&b1)) { - return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_NOT_NUMBER_ERR); - } - - result = nativeThis->Extend(b0, b1); - if (NS_FAILED(result)) { - return nsJSUtils::nsReportError(cx, obj, result); - } - - *rval = JSVAL_VOID; - } - - return JS_TRUE; -} - - -// -// Native method CollapseToStart -// -PR_STATIC_CALLBACK(JSBool) -SelectionCollapseToStart(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) -{ - nsIDOMSelection *nativeThis = (nsIDOMSelection*)nsJSUtils::nsGetNativeThis(cx, obj); - nsresult result = NS_OK; - // If there's no private data, this must be the prototype, so ignore - if (nsnull == nativeThis) { - return JS_TRUE; - } - - { - *rval = JSVAL_NULL; - nsIScriptSecurityManager *secMan = nsJSUtils::nsGetSecurityManager(cx, obj); - if (!secMan) - return PR_FALSE; - result = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_SELECTION_COLLAPSETOSTART, PR_FALSE); - if (NS_FAILED(result)) { - return nsJSUtils::nsReportError(cx, obj, result); - } - - result = nativeThis->CollapseToStart(); - if (NS_FAILED(result)) { - return nsJSUtils::nsReportError(cx, obj, result); - } - - *rval = JSVAL_VOID; - } - - return JS_TRUE; -} - - -// -// Native method CollapseToEnd -// -PR_STATIC_CALLBACK(JSBool) -SelectionCollapseToEnd(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) -{ - nsIDOMSelection *nativeThis = (nsIDOMSelection*)nsJSUtils::nsGetNativeThis(cx, obj); - nsresult result = NS_OK; - // If there's no private data, this must be the prototype, so ignore - if (nsnull == nativeThis) { - return JS_TRUE; - } - - { - *rval = JSVAL_NULL; - nsIScriptSecurityManager *secMan = nsJSUtils::nsGetSecurityManager(cx, obj); - if (!secMan) - return PR_FALSE; - result = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_SELECTION_COLLAPSETOEND, PR_FALSE); - if (NS_FAILED(result)) { - return nsJSUtils::nsReportError(cx, obj, result); - } - - result = nativeThis->CollapseToEnd(); - if (NS_FAILED(result)) { - return nsJSUtils::nsReportError(cx, obj, result); - } - - *rval = JSVAL_VOID; - } - - return JS_TRUE; -} - - -// -// Native method SelectAllChildren -// -PR_STATIC_CALLBACK(JSBool) -SelectionSelectAllChildren(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) -{ - nsIDOMSelection *nativeThis = (nsIDOMSelection*)nsJSUtils::nsGetNativeThis(cx, obj); - nsresult result = NS_OK; - nsCOMPtr b0; - // If there's no private data, this must be the prototype, so ignore - if (nsnull == nativeThis) { - return JS_TRUE; - } - - { - *rval = JSVAL_NULL; - nsIScriptSecurityManager *secMan = nsJSUtils::nsGetSecurityManager(cx, obj); - if (!secMan) - return PR_FALSE; - result = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_SELECTION_SELECTALLCHILDREN, PR_FALSE); - if (NS_FAILED(result)) { - return nsJSUtils::nsReportError(cx, obj, result); - } - if (argc < 1) { - return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_TOO_FEW_PARAMETERS_ERR); - } - - if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)(void**)getter_AddRefs(b0), - kINodeIID, - NS_ConvertASCIItoUCS2("Node"), - cx, - argv[0])) { - return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_NOT_OBJECT_ERR); - } - - result = nativeThis->SelectAllChildren(b0); - if (NS_FAILED(result)) { - return nsJSUtils::nsReportError(cx, obj, result); - } - - *rval = JSVAL_VOID; - } - - return JS_TRUE; -} - - -// -// Native method ContainsNode -// -PR_STATIC_CALLBACK(JSBool) -SelectionContainsNode(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) -{ - nsIDOMSelection *nativeThis = (nsIDOMSelection*)nsJSUtils::nsGetNativeThis(cx, obj); - nsresult result = NS_OK; - PRBool nativeRet; - nsCOMPtr b0; - PRBool b1; - // If there's no private data, this must be the prototype, so ignore - if (nsnull == nativeThis) { - return JS_TRUE; - } - - { - *rval = JSVAL_NULL; - nsIScriptSecurityManager *secMan = nsJSUtils::nsGetSecurityManager(cx, obj); - if (!secMan) - return PR_FALSE; - result = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_SELECTION_CONTAINSNODE, PR_FALSE); - if (NS_FAILED(result)) { - return nsJSUtils::nsReportError(cx, obj, result); - } - if (argc < 2) { - return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_TOO_FEW_PARAMETERS_ERR); - } - - if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)(void**)getter_AddRefs(b0), - kINodeIID, - NS_ConvertASCIItoUCS2("Node"), - cx, - argv[0])) { - return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_NOT_OBJECT_ERR); - } - if (!nsJSUtils::nsConvertJSValToBool(&b1, cx, argv[1])) { - return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_NOT_BOOLEAN_ERR); - } - - result = nativeThis->ContainsNode(b0, b1, &nativeRet); - if (NS_FAILED(result)) { - return nsJSUtils::nsReportError(cx, obj, result); - } - - *rval = BOOLEAN_TO_JSVAL(nativeRet); - } - - return JS_TRUE; -} - - -// -// Native method DeleteFromDocument -// -PR_STATIC_CALLBACK(JSBool) -SelectionDeleteFromDocument(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) -{ - nsIDOMSelection *nativeThis = (nsIDOMSelection*)nsJSUtils::nsGetNativeThis(cx, obj); - nsresult result = NS_OK; - // If there's no private data, this must be the prototype, so ignore - if (nsnull == nativeThis) { - return JS_TRUE; - } - - { - *rval = JSVAL_NULL; - nsIScriptSecurityManager *secMan = nsJSUtils::nsGetSecurityManager(cx, obj); - if (!secMan) - return PR_FALSE; - result = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_SELECTION_DELETEFROMDOCUMENT, PR_FALSE); - if (NS_FAILED(result)) { - return nsJSUtils::nsReportError(cx, obj, result); - } - - result = nativeThis->DeleteFromDocument(); - if (NS_FAILED(result)) { - return nsJSUtils::nsReportError(cx, obj, result); - } - - *rval = JSVAL_VOID; - } - - return JS_TRUE; -} - - -// -// Native method AddRange -// -PR_STATIC_CALLBACK(JSBool) -SelectionAddRange(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) -{ - nsIDOMSelection *nativeThis = (nsIDOMSelection*)nsJSUtils::nsGetNativeThis(cx, obj); - nsresult result = NS_OK; - nsCOMPtr b0; - // If there's no private data, this must be the prototype, so ignore - if (nsnull == nativeThis) { - return JS_TRUE; - } - - { - *rval = JSVAL_NULL; - nsIScriptSecurityManager *secMan = nsJSUtils::nsGetSecurityManager(cx, obj); - if (!secMan) - return PR_FALSE; - result = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_SELECTION_ADDRANGE, PR_FALSE); - if (NS_FAILED(result)) { - return nsJSUtils::nsReportError(cx, obj, result); - } - if (argc < 1) { - return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_TOO_FEW_PARAMETERS_ERR); - } - - if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)(void**)getter_AddRefs(b0), - kIRangeIID, - NS_ConvertASCIItoUCS2("Range"), - cx, - argv[0])) { - return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_NOT_OBJECT_ERR); - } - - result = nativeThis->AddRange(b0); - if (NS_FAILED(result)) { - return nsJSUtils::nsReportError(cx, obj, result); - } - - *rval = JSVAL_VOID; - } - - return JS_TRUE; -} - - -// -// Native method RemoveRange -// -PR_STATIC_CALLBACK(JSBool) -SelectionRemoveRange(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) -{ - nsIDOMSelection *nativeThis = (nsIDOMSelection*)nsJSUtils::nsGetNativeThis(cx, obj); - nsresult result = NS_OK; - nsCOMPtr b0; - // If there's no private data, this must be the prototype, so ignore - if (nsnull == nativeThis) { - return JS_TRUE; - } - - { - *rval = JSVAL_NULL; - nsIScriptSecurityManager *secMan = nsJSUtils::nsGetSecurityManager(cx, obj); - if (!secMan) - return PR_FALSE; - result = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_SELECTION_REMOVERANGE, PR_FALSE); - if (NS_FAILED(result)) { - return nsJSUtils::nsReportError(cx, obj, result); - } - if (argc < 1) { - return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_TOO_FEW_PARAMETERS_ERR); - } - - if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)(void**)getter_AddRefs(b0), - kIRangeIID, - NS_ConvertASCIItoUCS2("Range"), - cx, - argv[0])) { - return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_NOT_OBJECT_ERR); - } - - result = nativeThis->RemoveRange(b0); - if (NS_FAILED(result)) { - return nsJSUtils::nsReportError(cx, obj, result); - } - - *rval = JSVAL_VOID; - } - - return JS_TRUE; -} - - -// -// Native method StartBatchChanges -// -PR_STATIC_CALLBACK(JSBool) -SelectionStartBatchChanges(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) -{ - nsIDOMSelection *nativeThis = (nsIDOMSelection*)nsJSUtils::nsGetNativeThis(cx, obj); - nsresult result = NS_OK; - // If there's no private data, this must be the prototype, so ignore - if (nsnull == nativeThis) { - return JS_TRUE; - } - - { - *rval = JSVAL_NULL; - nsIScriptSecurityManager *secMan = nsJSUtils::nsGetSecurityManager(cx, obj); - if (!secMan) - return PR_FALSE; - result = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_SELECTION_STARTBATCHCHANGES, PR_FALSE); - if (NS_FAILED(result)) { - return nsJSUtils::nsReportError(cx, obj, result); - } - - result = nativeThis->StartBatchChanges(); - if (NS_FAILED(result)) { - return nsJSUtils::nsReportError(cx, obj, result); - } - - *rval = JSVAL_VOID; - } - - return JS_TRUE; -} - - -// -// Native method EndBatchChanges -// -PR_STATIC_CALLBACK(JSBool) -SelectionEndBatchChanges(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) -{ - nsIDOMSelection *nativeThis = (nsIDOMSelection*)nsJSUtils::nsGetNativeThis(cx, obj); - nsresult result = NS_OK; - // If there's no private data, this must be the prototype, so ignore - if (nsnull == nativeThis) { - return JS_TRUE; - } - - { - *rval = JSVAL_NULL; - nsIScriptSecurityManager *secMan = nsJSUtils::nsGetSecurityManager(cx, obj); - if (!secMan) - return PR_FALSE; - result = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_SELECTION_ENDBATCHCHANGES, PR_FALSE); - if (NS_FAILED(result)) { - return nsJSUtils::nsReportError(cx, obj, result); - } - - result = nativeThis->EndBatchChanges(); - if (NS_FAILED(result)) { - return nsJSUtils::nsReportError(cx, obj, result); - } - - *rval = JSVAL_VOID; - } - - return JS_TRUE; -} - - -// -// Native method AddSelectionListener -// -PR_STATIC_CALLBACK(JSBool) -SelectionAddSelectionListener(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) -{ - nsIDOMSelection *nativeThis = (nsIDOMSelection*)nsJSUtils::nsGetNativeThis(cx, obj); - nsresult result = NS_OK; - nsCOMPtr b0; - // If there's no private data, this must be the prototype, so ignore - if (nsnull == nativeThis) { - return JS_TRUE; - } - - { - *rval = JSVAL_NULL; - nsIScriptSecurityManager *secMan = nsJSUtils::nsGetSecurityManager(cx, obj); - if (!secMan) - return PR_FALSE; - result = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_SELECTION_ADDSELECTIONLISTENER, PR_FALSE); - if (NS_FAILED(result)) { - return nsJSUtils::nsReportError(cx, obj, result); - } - if (argc < 1) { - return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_TOO_FEW_PARAMETERS_ERR); - } - - if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)(void**)getter_AddRefs(b0), - kISelectionListenerIID, - NS_ConvertASCIItoUCS2("SelectionListener"), - cx, - argv[0])) { - return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_NOT_OBJECT_ERR); - } - - result = nativeThis->AddSelectionListener(b0); - if (NS_FAILED(result)) { - return nsJSUtils::nsReportError(cx, obj, result); - } - - *rval = JSVAL_VOID; - } - - return JS_TRUE; -} - - -// -// Native method RemoveSelectionListener -// -PR_STATIC_CALLBACK(JSBool) -SelectionRemoveSelectionListener(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) -{ - nsIDOMSelection *nativeThis = (nsIDOMSelection*)nsJSUtils::nsGetNativeThis(cx, obj); - nsresult result = NS_OK; - nsCOMPtr b0; - // If there's no private data, this must be the prototype, so ignore - if (nsnull == nativeThis) { - return JS_TRUE; - } - - { - *rval = JSVAL_NULL; - nsIScriptSecurityManager *secMan = nsJSUtils::nsGetSecurityManager(cx, obj); - if (!secMan) - return PR_FALSE; - result = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_SELECTION_REMOVESELECTIONLISTENER, PR_FALSE); - if (NS_FAILED(result)) { - return nsJSUtils::nsReportError(cx, obj, result); - } - if (argc < 1) { - return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_TOO_FEW_PARAMETERS_ERR); - } - - if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)(void**)getter_AddRefs(b0), - kISelectionListenerIID, - NS_ConvertASCIItoUCS2("SelectionListener"), - cx, - argv[0])) { - return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_NOT_OBJECT_ERR); - } - - result = nativeThis->RemoveSelectionListener(b0); - if (NS_FAILED(result)) { - return nsJSUtils::nsReportError(cx, obj, result); - } - - *rval = JSVAL_VOID; - } - - return JS_TRUE; -} - - -// -// Native method SetHint -// -PR_STATIC_CALLBACK(JSBool) -SelectionSetHint(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) -{ - nsIDOMSelection *nativeThis = (nsIDOMSelection*)nsJSUtils::nsGetNativeThis(cx, obj); - nsresult result = NS_OK; - PRBool b0; - // If there's no private data, this must be the prototype, so ignore - if (nsnull == nativeThis) { - return JS_TRUE; - } - - { - *rval = JSVAL_NULL; - nsIScriptSecurityManager *secMan = nsJSUtils::nsGetSecurityManager(cx, obj); - if (!secMan) - return PR_FALSE; - result = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_SELECTION_SETHINT, PR_FALSE); - if (NS_FAILED(result)) { - return nsJSUtils::nsReportError(cx, obj, result); - } - if (argc < 1) { - return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_TOO_FEW_PARAMETERS_ERR); - } - - if (!nsJSUtils::nsConvertJSValToBool(&b0, cx, argv[0])) { - return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_NOT_BOOLEAN_ERR); - } - - result = nativeThis->SetHint(b0); - if (NS_FAILED(result)) { - return nsJSUtils::nsReportError(cx, obj, result); - } - - *rval = JSVAL_VOID; - } - - return JS_TRUE; -} - - -// -// Native method GetHint -// -PR_STATIC_CALLBACK(JSBool) -SelectionGetHint(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) -{ - nsIDOMSelection *nativeThis = (nsIDOMSelection*)nsJSUtils::nsGetNativeThis(cx, obj); - nsresult result = NS_OK; - PRBool nativeRet; - // If there's no private data, this must be the prototype, so ignore - if (nsnull == nativeThis) { - return JS_TRUE; - } - - { - *rval = JSVAL_NULL; - nsIScriptSecurityManager *secMan = nsJSUtils::nsGetSecurityManager(cx, obj); - if (!secMan) - return PR_FALSE; - result = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_SELECTION_GETHINT, PR_FALSE); - if (NS_FAILED(result)) { - return nsJSUtils::nsReportError(cx, obj, result); - } - - result = nativeThis->GetHint(&nativeRet); - if (NS_FAILED(result)) { - return nsJSUtils::nsReportError(cx, obj, result); - } - - *rval = BOOLEAN_TO_JSVAL(nativeRet); - } - - return JS_TRUE; -} - - -// -// Native method ToString -// -PR_STATIC_CALLBACK(JSBool) -SelectionToString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) -{ - nsIDOMSelection *nativeThis = (nsIDOMSelection*)nsJSUtils::nsGetNativeThis(cx, obj); - nsresult result = NS_OK; - nsAutoString nativeRet; - nsAutoString b0; - PRUint32 b1; - PRInt32 b2; - // If there's no private data, this must be the prototype, so ignore - if (nsnull == nativeThis) { - return JS_TRUE; - } - - { - *rval = JSVAL_NULL; - nsIScriptSecurityManager *secMan = nsJSUtils::nsGetSecurityManager(cx, obj); - if (!secMan) - return PR_FALSE; - result = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_SELECTION_TOSTRING, PR_FALSE); - if (NS_FAILED(result)) { - return nsJSUtils::nsReportError(cx, obj, result); - } - if (argc < 3) { - return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_TOO_FEW_PARAMETERS_ERR); - } - - nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]); - if (!JS_ValueToInt32(cx, argv[1], (int32 *)&b1)) { - return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_NOT_NUMBER_ERR); - } - if (!JS_ValueToInt32(cx, argv[2], (int32 *)&b2)) { - return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_NOT_NUMBER_ERR); - } - - result = nativeThis->ToString(b0, b1, b2, nativeRet); - if (NS_FAILED(result)) { - return nsJSUtils::nsReportError(cx, obj, result); - } - - nsJSUtils::nsConvertStringToJSVal(nativeRet, cx, rval); - } - - return JS_TRUE; -} - - -/***********************************************************************/ -// -// class for Selection -// -JSClass SelectionClass = { - "Selection", - JSCLASS_HAS_PRIVATE | JSCLASS_PRIVATE_IS_NSISUPPORTS, - JS_PropertyStub, - JS_PropertyStub, - GetSelectionProperty, - SetSelectionProperty, - EnumerateSelection, - ResolveSelection, - JS_ConvertStub, - FinalizeSelection, - nsnull, - nsJSUtils::nsCheckAccess -}; - - -// -// Selection class properties -// -static JSPropertySpec SelectionProperties[] = -{ - {"anchorNode", SELECTION_ANCHORNODE, JSPROP_ENUMERATE | JSPROP_READONLY}, - {"anchorOffset", SELECTION_ANCHOROFFSET, JSPROP_ENUMERATE | JSPROP_READONLY}, - {"focusNode", SELECTION_FOCUSNODE, JSPROP_ENUMERATE | JSPROP_READONLY}, - {"focusOffset", SELECTION_FOCUSOFFSET, JSPROP_ENUMERATE | JSPROP_READONLY}, - {"isCollapsed", SELECTION_ISCOLLAPSED, JSPROP_ENUMERATE | JSPROP_READONLY}, - {"rangeCount", SELECTION_RANGECOUNT, JSPROP_ENUMERATE | JSPROP_READONLY}, - {0} -}; - - -// -// Selection class methods -// -static JSFunctionSpec SelectionMethods[] = -{ - {"getRangeAt", SelectionGetRangeAt, 1}, - {"clearSelection", SelectionClearSelection, 0}, - {"collapse", SelectionCollapse, 2}, - {"extend", SelectionExtend, 2}, - {"collapseToStart", SelectionCollapseToStart, 0}, - {"collapseToEnd", SelectionCollapseToEnd, 0}, - {"selectAllChildren", SelectionSelectAllChildren, 1}, - {"containsNode", SelectionContainsNode, 2}, - {"deleteFromDocument", SelectionDeleteFromDocument, 0}, - {"addRange", SelectionAddRange, 1}, - {"removeRange", SelectionRemoveRange, 1}, - {"startBatchChanges", SelectionStartBatchChanges, 0}, - {"endBatchChanges", SelectionEndBatchChanges, 0}, - {"addSelectionListener", SelectionAddSelectionListener, 1}, - {"removeSelectionListener", SelectionRemoveSelectionListener, 1}, - {"setHint", SelectionSetHint, 1}, - {"getHint", SelectionGetHint, 0}, - {"toString", SelectionToString, 3}, - {0} -}; - - -// -// Selection constructor -// -PR_STATIC_CALLBACK(JSBool) -Selection(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) -{ - return JS_FALSE; -} - - -// -// Selection class initialization -// -extern "C" NS_DOM nsresult NS_InitSelectionClass(nsIScriptContext *aContext, void **aPrototype) -{ - JSContext *jscontext = (JSContext *)aContext->GetNativeContext(); - JSObject *proto = nsnull; - JSObject *constructor = nsnull; - JSObject *parent_proto = nsnull; - JSObject *global = JS_GetGlobalObject(jscontext); - jsval vp; - - if ((PR_TRUE != JS_LookupProperty(jscontext, global, "Selection", &vp)) || - !JSVAL_IS_OBJECT(vp) || - ((constructor = JSVAL_TO_OBJECT(vp)) == nsnull) || - (PR_TRUE != JS_LookupProperty(jscontext, JSVAL_TO_OBJECT(vp), "prototype", &vp)) || - !JSVAL_IS_OBJECT(vp)) { - - proto = JS_InitClass(jscontext, // context - global, // global object - parent_proto, // parent proto - &SelectionClass, // JSClass - Selection, // JSNative ctor - 0, // ctor args - SelectionProperties, // proto props - SelectionMethods, // proto funcs - nsnull, // ctor props (static) - nsnull); // ctor funcs (static) - if (nsnull == proto) { - return NS_ERROR_FAILURE; - } - - } - else if ((nsnull != constructor) && JSVAL_IS_OBJECT(vp)) { - proto = JSVAL_TO_OBJECT(vp); - } - else { - return NS_ERROR_FAILURE; - } - - if (aPrototype) { - *aPrototype = proto; - } - return NS_OK; -} - - -// -// Method for creating a new Selection JavaScript object -// -extern "C" NS_DOM nsresult NS_NewScriptSelection(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn) -{ - NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptSelection"); - JSObject *proto; - JSObject *parent; - nsIScriptObjectOwner *owner; - JSContext *jscontext = (JSContext *)aContext->GetNativeContext(); - nsresult result = NS_OK; - nsIDOMSelection *aSelection; - - if (nsnull == aParent) { - parent = nsnull; - } - else if (NS_OK == aParent->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) { - if (NS_OK != owner->GetScriptObject(aContext, (void **)&parent)) { - NS_RELEASE(owner); - return NS_ERROR_FAILURE; - } - NS_RELEASE(owner); - } - else { - return NS_ERROR_FAILURE; - } - - if (NS_OK != NS_InitSelectionClass(aContext, (void **)&proto)) { - return NS_ERROR_FAILURE; - } - - result = aSupports->QueryInterface(kISelectionIID, (void **)&aSelection); - if (NS_OK != result) { - return result; - } - - // create a js object for this class - *aReturn = JS_NewObject(jscontext, &SelectionClass, proto, parent); - if (nsnull != *aReturn) { - // connect the native object to the js object - JS_SetPrivate(jscontext, (JSObject *)*aReturn, aSelection); - } - else { - NS_RELEASE(aSelection); - return NS_ERROR_FAILURE; - } - - return NS_OK; -} diff --git a/mozilla/dom/src/range/nsJSSelectionListener.cpp b/mozilla/dom/src/range/nsJSSelectionListener.cpp deleted file mode 100644 index 7e475cc4a06..00000000000 --- a/mozilla/dom/src/range/nsJSSelectionListener.cpp +++ /dev/null @@ -1,375 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ -/* AUTO-GENERATED. DO NOT EDIT!!! */ - -#include "jsapi.h" -#include "nsJSUtils.h" -#include "nsDOMError.h" -#include "nscore.h" -#include "nsIServiceManager.h" -#include "nsIScriptContext.h" -#include "nsIScriptSecurityManager.h" -#include "nsIJSScriptObject.h" -#include "nsIScriptObjectOwner.h" -#include "nsIScriptGlobalObject.h" -#include "nsCOMPtr.h" -#include "nsDOMPropEnums.h" -#include "nsString.h" -#include "nsIDOMDocument.h" -#include "nsIDOMSelection.h" -#include "nsIDOMSelectionListener.h" - - -static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID); -static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID); -static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID); -static NS_DEFINE_IID(kIDocumentIID, NS_IDOMDOCUMENT_IID); -static NS_DEFINE_IID(kISelectionIID, NS_IDOMSELECTION_IID); -static NS_DEFINE_IID(kISelectionListenerIID, NS_IDOMSELECTIONLISTENER_IID); - - -/***********************************************************************/ -// -// SelectionListener Properties Getter -// -PR_STATIC_CALLBACK(JSBool) -GetSelectionListenerProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) -{ - nsIDOMSelectionListener *a = (nsIDOMSelectionListener*)nsJSUtils::nsGetNativeThis(cx, obj); - - // If there's no private data, this must be the prototype, so ignore - if (nsnull == a) { - return JS_TRUE; - } - - nsresult rv = NS_OK; - if (JSVAL_IS_INT(id)) { - nsIScriptSecurityManager *secMan = nsJSUtils::nsGetSecurityManager(cx, obj); - if (!secMan) - return PR_FALSE; - switch(JSVAL_TO_INT(id)) { - case 0: - default: - return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, obj, id, vp); - } - } - else { - return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, obj, id, vp); - } - - if (NS_FAILED(rv)) - return nsJSUtils::nsReportError(cx, obj, rv); - return PR_TRUE; -} - -/***********************************************************************/ -// -// SelectionListener Properties Setter -// -PR_STATIC_CALLBACK(JSBool) -SetSelectionListenerProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) -{ - nsIDOMSelectionListener *a = (nsIDOMSelectionListener*)nsJSUtils::nsGetNativeThis(cx, obj); - - // If there's no private data, this must be the prototype, so ignore - if (nsnull == a) { - return JS_TRUE; - } - - nsresult rv = NS_OK; - if (JSVAL_IS_INT(id)) { - nsIScriptSecurityManager *secMan = nsJSUtils::nsGetSecurityManager(cx, obj); - if (!secMan) - return PR_FALSE; - switch(JSVAL_TO_INT(id)) { - case 0: - default: - return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, obj, id, vp); - } - } - else { - return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, obj, id, vp); - } - - if (NS_FAILED(rv)) - return nsJSUtils::nsReportError(cx, obj, rv); - return PR_TRUE; -} - - -// -// SelectionListener finalizer -// -PR_STATIC_CALLBACK(void) -FinalizeSelectionListener(JSContext *cx, JSObject *obj) -{ - nsJSUtils::nsGenericFinalize(cx, obj); -} - - -// -// SelectionListener enumerate -// -PR_STATIC_CALLBACK(JSBool) -EnumerateSelectionListener(JSContext *cx, JSObject *obj) -{ - return nsJSUtils::nsGenericEnumerate(cx, obj); -} - - -// -// SelectionListener resolve -// -PR_STATIC_CALLBACK(JSBool) -ResolveSelectionListener(JSContext *cx, JSObject *obj, jsval id) -{ - return nsJSUtils::nsGenericResolve(cx, obj, id); -} - - -// -// Native method NotifySelectionChanged -// -PR_STATIC_CALLBACK(JSBool) -SelectionListenerNotifySelectionChanged(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) -{ - nsIDOMSelectionListener *nativeThis = (nsIDOMSelectionListener*)nsJSUtils::nsGetNativeThis(cx, obj); - nsresult result = NS_OK; - nsCOMPtr b0; - nsCOMPtr b1; - PRInt32 b2; - // If there's no private data, this must be the prototype, so ignore - if (nsnull == nativeThis) { - return JS_TRUE; - } - - { - *rval = JSVAL_NULL; - nsIScriptSecurityManager *secMan = nsJSUtils::nsGetSecurityManager(cx, obj); - if (!secMan) - return PR_FALSE; - result = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_SELECTIONLISTENER_NOTIFYSELECTIONCHANGED, PR_FALSE); - if (NS_FAILED(result)) { - return nsJSUtils::nsReportError(cx, obj, result); - } - if (argc < 3) { - return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_TOO_FEW_PARAMETERS_ERR); - } - - if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)(void**)getter_AddRefs(b0), - kIDocumentIID, - NS_ConvertASCIItoUCS2("Document"), - cx, - argv[0])) { - return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_NOT_OBJECT_ERR); - } - if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)(void**)getter_AddRefs(b1), - kISelectionIID, - NS_ConvertASCIItoUCS2("Selection"), - cx, - argv[1])) { - return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_NOT_OBJECT_ERR); - } - if (!JS_ValueToInt32(cx, argv[2], (int32 *)&b2)) { - return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_NOT_NUMBER_ERR); - } - - result = nativeThis->NotifySelectionChanged(b0, b1, b2); - if (NS_FAILED(result)) { - return nsJSUtils::nsReportError(cx, obj, result); - } - - *rval = JSVAL_VOID; - } - - return JS_TRUE; -} - - -/***********************************************************************/ -// -// class for SelectionListener -// -JSClass SelectionListenerClass = { - "SelectionListener", - JSCLASS_HAS_PRIVATE | JSCLASS_PRIVATE_IS_NSISUPPORTS, - JS_PropertyStub, - JS_PropertyStub, - GetSelectionListenerProperty, - SetSelectionListenerProperty, - EnumerateSelectionListener, - ResolveSelectionListener, - JS_ConvertStub, - FinalizeSelectionListener, - nsnull, - nsJSUtils::nsCheckAccess -}; - - -// -// SelectionListener class properties -// -static JSPropertySpec SelectionListenerProperties[] = -{ - {0} -}; - - -// -// SelectionListener class methods -// -static JSFunctionSpec SelectionListenerMethods[] = -{ - {"notifySelectionChanged", SelectionListenerNotifySelectionChanged, 3}, - {0} -}; - - -// -// SelectionListener constructor -// -PR_STATIC_CALLBACK(JSBool) -SelectionListener(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) -{ - return JS_FALSE; -} - - -// -// SelectionListener class initialization -// -extern "C" NS_DOM nsresult NS_InitSelectionListenerClass(nsIScriptContext *aContext, void **aPrototype) -{ - JSContext *jscontext = (JSContext *)aContext->GetNativeContext(); - JSObject *proto = nsnull; - JSObject *constructor = nsnull; - JSObject *parent_proto = nsnull; - JSObject *global = JS_GetGlobalObject(jscontext); - jsval vp; - - if ((PR_TRUE != JS_LookupProperty(jscontext, global, "SelectionListener", &vp)) || - !JSVAL_IS_OBJECT(vp) || - ((constructor = JSVAL_TO_OBJECT(vp)) == nsnull) || - (PR_TRUE != JS_LookupProperty(jscontext, JSVAL_TO_OBJECT(vp), "prototype", &vp)) || - !JSVAL_IS_OBJECT(vp)) { - - proto = JS_InitClass(jscontext, // context - global, // global object - parent_proto, // parent proto - &SelectionListenerClass, // JSClass - SelectionListener, // JSNative ctor - 0, // ctor args - SelectionListenerProperties, // proto props - SelectionListenerMethods, // proto funcs - nsnull, // ctor props (static) - nsnull); // ctor funcs (static) - if (nsnull == proto) { - return NS_ERROR_FAILURE; - } - - if ((PR_TRUE == JS_LookupProperty(jscontext, global, "SelectionListener", &vp)) && - JSVAL_IS_OBJECT(vp) && - ((constructor = JSVAL_TO_OBJECT(vp)) != nsnull)) { - vp = INT_TO_JSVAL(nsIDOMSelectionListener::NO_REASON); - JS_SetProperty(jscontext, constructor, "NO_REASON", &vp); - - vp = INT_TO_JSVAL(nsIDOMSelectionListener::DRAG_REASON); - JS_SetProperty(jscontext, constructor, "DRAG_REASON", &vp); - - vp = INT_TO_JSVAL(nsIDOMSelectionListener::MOUSEDOWN_REASON); - JS_SetProperty(jscontext, constructor, "MOUSEDOWN_REASON", &vp); - - vp = INT_TO_JSVAL(nsIDOMSelectionListener::MOUSEUP_REASON); - JS_SetProperty(jscontext, constructor, "MOUSEUP_REASON", &vp); - - vp = INT_TO_JSVAL(nsIDOMSelectionListener::KEYPRESS_REASON); - JS_SetProperty(jscontext, constructor, "KEYPRESS_REASON", &vp); - - vp = INT_TO_JSVAL(nsIDOMSelectionListener::SELECTALL_REASON); - JS_SetProperty(jscontext, constructor, "SELECTALL_REASON", &vp); - - } - - } - else if ((nsnull != constructor) && JSVAL_IS_OBJECT(vp)) { - proto = JSVAL_TO_OBJECT(vp); - } - else { - return NS_ERROR_FAILURE; - } - - if (aPrototype) { - *aPrototype = proto; - } - return NS_OK; -} - - -// -// Method for creating a new SelectionListener JavaScript object -// -extern "C" NS_DOM nsresult NS_NewScriptSelectionListener(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn) -{ - NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptSelectionListener"); - JSObject *proto; - JSObject *parent; - nsIScriptObjectOwner *owner; - JSContext *jscontext = (JSContext *)aContext->GetNativeContext(); - nsresult result = NS_OK; - nsIDOMSelectionListener *aSelectionListener; - - if (nsnull == aParent) { - parent = nsnull; - } - else if (NS_OK == aParent->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) { - if (NS_OK != owner->GetScriptObject(aContext, (void **)&parent)) { - NS_RELEASE(owner); - return NS_ERROR_FAILURE; - } - NS_RELEASE(owner); - } - else { - return NS_ERROR_FAILURE; - } - - if (NS_OK != NS_InitSelectionListenerClass(aContext, (void **)&proto)) { - return NS_ERROR_FAILURE; - } - - result = aSupports->QueryInterface(kISelectionListenerIID, (void **)&aSelectionListener); - if (NS_OK != result) { - return result; - } - - // create a js object for this class - *aReturn = JS_NewObject(jscontext, &SelectionListenerClass, proto, parent); - if (nsnull != *aReturn) { - // connect the native object to the js object - JS_SetPrivate(jscontext, (JSObject *)*aReturn, aSelectionListener); - } - else { - NS_RELEASE(aSelectionListener); - return NS_ERROR_FAILURE; - } - - return NS_OK; -} diff --git a/mozilla/editor/base/CreateElementTxn.cpp b/mozilla/editor/base/CreateElementTxn.cpp index b0442a7ab70..e7080bd959c 100644 --- a/mozilla/editor/base/CreateElementTxn.cpp +++ b/mozilla/editor/base/CreateElementTxn.cpp @@ -24,7 +24,7 @@ #include "nsEditor.h" #include "nsIDOMDocument.h" #include "nsIDOMNodeList.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIDOMText.h" #include "nsIDOMElement.h" @@ -149,7 +149,7 @@ NS_IMETHODIMP CreateElementTxn::Do(void) mEditor->ShouldTxnSetSelection(&bAdjustSelection); if (bAdjustSelection) { - nsCOMPtr selection; + nsCOMPtr selection; result = mEditor->GetSelection(getter_AddRefs(selection)); if (NS_FAILED(result)) return result; if (!selection) return NS_ERROR_NULL_POINTER; diff --git a/mozilla/editor/base/DeleteRangeTxn.cpp b/mozilla/editor/base/DeleteRangeTxn.cpp index 3c6eb9895e5..1e3299d1b69 100644 --- a/mozilla/editor/base/DeleteRangeTxn.cpp +++ b/mozilla/editor/base/DeleteRangeTxn.cpp @@ -25,7 +25,7 @@ #include "nsIDOMRange.h" #include "nsIDOMCharacterData.h" #include "nsIDOMNodeList.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "DeleteTextTxn.h" #include "DeleteElementTxn.h" #include "TransactionFactory.h" @@ -153,7 +153,7 @@ NS_IMETHODIMP DeleteRangeTxn::Do(void) mEditor->ShouldTxnSetSelection(&bAdjustSelection); if (bAdjustSelection) { - nsCOMPtr selection; + nsCOMPtr selection; result = mEditor->GetSelection(getter_AddRefs(selection)); if (NS_FAILED(result)) return result; if (!selection) return NS_ERROR_NULL_POINTER; diff --git a/mozilla/editor/base/DeleteTextTxn.cpp b/mozilla/editor/base/DeleteTextTxn.cpp index dffb70c8393..88db0665f0f 100644 --- a/mozilla/editor/base/DeleteTextTxn.cpp +++ b/mozilla/editor/base/DeleteTextTxn.cpp @@ -22,7 +22,7 @@ #include "DeleteTextTxn.h" #include "nsIDOMCharacterData.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #ifdef NS_DEBUG static PRBool gNoisy = PR_FALSE; @@ -78,7 +78,7 @@ NS_IMETHODIMP DeleteTextTxn::Do(void) mEditor->ShouldTxnSetSelection(&bAdjustSelection); if (bAdjustSelection) { - nsCOMPtr selection; + nsCOMPtr selection; result = mEditor->GetSelection(getter_AddRefs(selection)); if (NS_FAILED(result)) return result; if (!selection) return NS_ERROR_NULL_POINTER; diff --git a/mozilla/editor/base/IMETextTxn.cpp b/mozilla/editor/base/IMETextTxn.cpp index 0736c822fcf..95aa41bd6f5 100644 --- a/mozilla/editor/base/IMETextTxn.cpp +++ b/mozilla/editor/base/IMETextTxn.cpp @@ -25,7 +25,8 @@ #include "nsEditor.h" #include "nsIDOMCharacterData.h" #include "nsIPrivateTextRange.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" +#include "nsISelectionPrivate.h" #include "nsIPresShell.h" #include "EditAggregateTxn.h" #include "nsLayoutCID.h" @@ -33,7 +34,7 @@ // #define DEBUG_IMETXN static NS_DEFINE_IID(kRangeCID, NS_RANGE_CID); -static NS_DEFINE_IID(kIDOMSelectionIID, NS_IDOMSELECTION_IID); +static NS_DEFINE_IID(kIDOMSelectionIID, NS_ISELECTION_IID); nsIAtom *IMETextTxn::gIMETextTxnName = nsnull; @@ -121,7 +122,7 @@ NS_IMETHODIMP IMETextTxn::Undo(void) result = mElement->DeleteData(mOffset, length); if (NS_SUCCEEDED(result)) { // set the selection to the insertion point where the string was removed - nsCOMPtr selection; + nsCOMPtr selection; result = selCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection)); if (NS_SUCCEEDED(result) && selection) { result = selection->Collapse(mElement, mOffset); @@ -321,12 +322,13 @@ NS_IMETHODIMP IMETextTxn::CollapseTextSelection(void) result = mRangeList->GetLength(&textRangeListLength); if(NS_FAILED(result)) return result; - nsCOMPtr selection; + nsCOMPtr selection; result = selCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection)); - nsCOMPtr imeSel; + nsCOMPtr imeSel; if(NS_SUCCEEDED(result)) { - result = selection->StartBatchChanges(); + nsCOMPtr selPriv(do_QueryInterface(selection)); + result = selPriv->StartBatchChanges(); if (NS_SUCCEEDED(result)) { for(PRInt8 selIdx = 0; selIdx < 4;selIdx++) @@ -334,7 +336,7 @@ NS_IMETHODIMP IMETextTxn::CollapseTextSelection(void) result = selCon->GetSelection(sel[selIdx], getter_AddRefs(imeSel)); if(NS_SUCCEEDED(result)) { - result = imeSel->ClearSelection(); + result = imeSel->RemoveAllRanges(); NS_ASSERTION(NS_SUCCEEDED(result), "Cannot ClearSelection"); // we just ignore the result and clean up the next one here } @@ -412,7 +414,7 @@ NS_IMETHODIMP IMETextTxn::CollapseTextSelection(void) result = selection->Collapse(mElement,mOffset+mStringToInsert.Length()); NS_ASSERTION(NS_SUCCEEDED(result), "Cannot Collapse"); } - result = selection->EndBatchChanges(); + result = selPriv->EndBatchChanges(); NS_ASSERTION(NS_SUCCEEDED(result), "Cannot EndBatchChanges"); } // if StartBatchChanges } // if GetSelection diff --git a/mozilla/editor/base/InsertElementTxn.cpp b/mozilla/editor/base/InsertElementTxn.cpp index 010153516f7..fb6797fbac6 100644 --- a/mozilla/editor/base/InsertElementTxn.cpp +++ b/mozilla/editor/base/InsertElementTxn.cpp @@ -21,7 +21,7 @@ */ #include "InsertElementTxn.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIContent.h" #include "nsIDOMNodeList.h" @@ -105,7 +105,7 @@ NS_IMETHODIMP InsertElementTxn::Do(void) mEditor->ShouldTxnSetSelection(&bAdjustSelection); if (bAdjustSelection) { - nsCOMPtr selection; + nsCOMPtr selection; result = mEditor->GetSelection(getter_AddRefs(selection)); if (NS_FAILED(result)) return result; if (!selection) return NS_ERROR_NULL_POINTER; diff --git a/mozilla/editor/base/InsertTextTxn.cpp b/mozilla/editor/base/InsertTextTxn.cpp index 1a60556dcff..921bfe3dec7 100644 --- a/mozilla/editor/base/InsertTextTxn.cpp +++ b/mozilla/editor/base/InsertTextTxn.cpp @@ -23,10 +23,10 @@ #include "InsertTextTxn.h" #include "nsEditor.h" #include "nsIDOMCharacterData.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "EditAggregateTxn.h" -static NS_DEFINE_IID(kIDOMSelectionIID, NS_IDOMSELECTION_IID); +static NS_DEFINE_IID(kIDOMSelectionIID, NS_ISELECTION_IID); #ifdef NS_DEBUG static PRBool gNoisy = PR_FALSE; @@ -97,7 +97,7 @@ NS_IMETHODIMP InsertTextTxn::Do(void) mEditor->ShouldTxnSetSelection(&bAdjustSelection); if (bAdjustSelection) { - nsCOMPtr selection; + nsCOMPtr selection; result = mEditor->GetSelection(getter_AddRefs(selection)); if (NS_FAILED(result)) return result; if (!selection) return NS_ERROR_NULL_POINTER; diff --git a/mozilla/editor/base/PlaceholderTxn.cpp b/mozilla/editor/base/PlaceholderTxn.cpp index 55a8a4916a3..5a1df3492b3 100644 --- a/mozilla/editor/base/PlaceholderTxn.cpp +++ b/mozilla/editor/base/PlaceholderTxn.cpp @@ -97,7 +97,7 @@ NS_IMETHODIMP PlaceholderTxn::Undo(void) if (NS_FAILED(res)) return res; // now restore selection - nsCOMPtr selection; + nsCOMPtr selection; res = mEditor->GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_NULL_POINTER; @@ -114,7 +114,7 @@ NS_IMETHODIMP PlaceholderTxn::Redo(void) if (NS_FAILED(res)) return res; // now restore selection - nsCOMPtr selection; + nsCOMPtr selection; res = mEditor->GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_NULL_POINTER; @@ -265,7 +265,7 @@ NS_IMETHODIMP PlaceholderTxn::Commit() NS_IMETHODIMP PlaceholderTxn::RememberEndingSelection() { - nsCOMPtr selection; + nsCOMPtr selection; nsresult res = mEditor->GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_NULL_POINTER; diff --git a/mozilla/editor/base/SplitElementTxn.cpp b/mozilla/editor/base/SplitElementTxn.cpp index 55bb8c3eee0..e742f526ec6 100644 --- a/mozilla/editor/base/SplitElementTxn.cpp +++ b/mozilla/editor/base/SplitElementTxn.cpp @@ -23,7 +23,7 @@ #include "SplitElementTxn.h" #include "nsEditor.h" #include "nsIDOMNode.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIDOMCharacterData.h" #ifdef NS_DEBUG @@ -82,7 +82,7 @@ NS_IMETHODIMP SplitElementTxn::Do(void) result = mEditor->SplitNodeImpl(mExistingRightNode, mOffset, mNewLeftNode, mParent); if (NS_SUCCEEDED(result) && mNewLeftNode) { - nsCOMPtrselection; + nsCOMPtrselection; mEditor->GetSelection(getter_AddRefs(selection)); if (NS_FAILED(result)) return result; if (!selection) return NS_ERROR_NULL_POINTER; diff --git a/mozilla/editor/base/TextEditorTest.cpp b/mozilla/editor/base/TextEditorTest.cpp index 161cffd6bc6..94cc597349e 100644 --- a/mozilla/editor/base/TextEditorTest.cpp +++ b/mozilla/editor/base/TextEditorTest.cpp @@ -24,7 +24,7 @@ #include "nsIEditor.h" #include "TextEditorTest.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIDOMCharacterData.h" #include "nsIDOMDocument.h" #include "nsIDOMNode.h" @@ -111,7 +111,7 @@ nsresult TextEditorTest::InitDoc() nsresult TextEditorTest::TestInsertBreak() { - nsCOMPtrselection; + nsCOMPtrselection; nsresult result = mEditor->GetSelection(getter_AddRefs(selection)); TEST_RESULT(result); TEST_POINTER(selection.get()); @@ -156,7 +156,7 @@ nsresult TextEditorTest::TestTextProperties() // set the whole text node to bold printf("set the whole first text node to bold\n"); - nsCOMPtrselection; + nsCOMPtrselection; result = mEditor->GetSelection(getter_AddRefs(selection)); TEST_RESULT(result); TEST_POINTER(selection.get()); diff --git a/mozilla/editor/base/TypeInState.cpp b/mozilla/editor/base/TypeInState.cpp index 89ed469a6a1..d7b555bc576 100644 --- a/mozilla/editor/base/TypeInState.cpp +++ b/mozilla/editor/base/TypeInState.cpp @@ -42,8 +42,8 @@ TypeInState::QueryInterface(REFNSIID aIID, void** aInstancePtr) NS_ADDREF_THIS(); return NS_OK; } - if (aIID.Equals(NS_GET_IID(nsIDOMSelectionListener))) { - *aInstancePtr = (void*)(nsIDOMSelectionListener*)this; + if (aIID.Equals(NS_GET_IID(nsISelectionListener))) { + *aInstancePtr = (void*)(nsISelectionListener*)this; NS_ADDREF_THIS(); return NS_OK; } @@ -67,7 +67,7 @@ TypeInState::~TypeInState() { } -NS_IMETHODIMP TypeInState::NotifySelectionChanged(nsIDOMDocument *, nsIDOMSelection *,short) +NS_IMETHODIMP TypeInState::NotifySelectionChanged(nsIDOMDocument *, nsISelection *,short) { Reset(); return NS_OK; diff --git a/mozilla/editor/base/TypeInState.h b/mozilla/editor/base/TypeInState.h index 3d3bd7b7a6d..b164bbca8d4 100644 --- a/mozilla/editor/base/TypeInState.h +++ b/mozilla/editor/base/TypeInState.h @@ -23,7 +23,7 @@ #ifndef TypeInState_h__ #define TypeInState_h__ -#include "nsIDOMSelectionListener.h" +#include "nsISelectionListener.h" #include "nsIEditProperty.h" #include "nsString.h" #include "nsVoidArray.h" @@ -38,7 +38,7 @@ struct PropItem ~PropItem(); }; -class TypeInState : public nsIDOMSelectionListener +class TypeInState : public nsISelectionListener { public: @@ -48,7 +48,7 @@ public: void Reset(); virtual ~TypeInState(); - NS_IMETHOD NotifySelectionChanged(nsIDOMDocument *aDoc, nsIDOMSelection *aSel, short aReason); + NS_IMETHOD NotifySelectionChanged(nsIDOMDocument *aDoc, nsISelection *aSel, short aReason); nsresult SetProp(nsIAtom *aProp); nsresult SetProp(nsIAtom *aProp, const nsString &aAttr); diff --git a/mozilla/editor/base/nsComposerCommands.cpp b/mozilla/editor/base/nsComposerCommands.cpp index ffb13cfff54..7b446cb6f96 100644 --- a/mozilla/editor/base/nsComposerCommands.cpp +++ b/mozilla/editor/base/nsComposerCommands.cpp @@ -28,7 +28,7 @@ #include "nsIEditorShell.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIDOMNode.h" #include "nsIDOMElement.h" #include "nsIDOMWindowInternal.h" @@ -231,7 +231,11 @@ nsPrintingCommands::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * re *outCmdEnabled = PR_FALSE; // not implemented yet else if (cmdString.EqualsWithConversion("cmd_printPreview")) *outCmdEnabled = PR_FALSE; // not implemented yet - + else if (cmdString.EqualsWithConversion("cmd_print_button")) + *outCmdEnabled = PR_TRUE; + else if (cmdString.EqualsWithConversion("cmd_printSetup")) + *outCmdEnabled = PR_FALSE; // not implemented yet + return NS_OK; } diff --git a/mozilla/editor/base/nsEditRules.h b/mozilla/editor/base/nsEditRules.h index 0279e977908..2af710fd2dc 100644 --- a/mozilla/editor/base/nsEditRules.h +++ b/mozilla/editor/base/nsEditRules.h @@ -29,7 +29,7 @@ {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} } class nsHTMLEditor; -class nsIDOMSelection; +class nsISelection; /*************************************************************************** * base for an object to encapsulate any additional info needed to be passed @@ -60,8 +60,8 @@ public: NS_IMETHOD Init(nsHTMLEditor *aEditor, PRUint32 aFlags)=0; NS_IMETHOD BeforeEdit(PRInt32 action, nsIEditor::EDirection aDirection)=0; NS_IMETHOD AfterEdit(PRInt32 action, nsIEditor::EDirection aDirection)=0; - NS_IMETHOD WillDoAction(nsIDOMSelection *aSelection, nsRulesInfo *aInfo, PRBool *aCancel, PRBool *aHandled)=0; - NS_IMETHOD DidDoAction(nsIDOMSelection *aSelection, nsRulesInfo *aInfo, nsresult aResult)=0; + NS_IMETHOD WillDoAction(nsISelection *aSelection, nsRulesInfo *aInfo, PRBool *aCancel, PRBool *aHandled)=0; + NS_IMETHOD DidDoAction(nsISelection *aSelection, nsRulesInfo *aInfo, nsresult aResult)=0; NS_IMETHOD GetFlags(PRUint32 *aFlags)=0; NS_IMETHOD SetFlags(PRUint32 aFlags)=0; NS_IMETHOD DocumentIsEmpty(PRBool *aDocumentIsEmpty)=0; diff --git a/mozilla/editor/base/nsEditor.cpp b/mozilla/editor/base/nsEditor.cpp index f51a75e3da8..b0157e8235c 100644 --- a/mozilla/editor/base/nsEditor.cpp +++ b/mozilla/editor/base/nsEditor.cpp @@ -47,7 +47,8 @@ #include "nsIPresShell.h" #include "nsIPresContext.h" #include "nsIViewManager.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" +#include "nsISelectionPrivate.h" #include "nsIEnumerator.h" #include "nsIAtom.h" #include "nsISupportsArray.h" @@ -160,7 +161,7 @@ nsSelectionState::~nsSelectionState() } nsresult -nsSelectionState::SaveSelection(nsIDOMSelection *aSel) +nsSelectionState::SaveSelection(nsISelection *aSel) { if (!aSel) return NS_ERROR_NULL_POINTER; nsresult res = NS_OK; @@ -203,7 +204,7 @@ nsSelectionState::SaveSelection(nsIDOMSelection *aSel) } nsresult -nsSelectionState::RestoreSelection(nsIDOMSelection *aSel) +nsSelectionState::RestoreSelection(nsISelection *aSel) { if (!aSel) return NS_ERROR_NULL_POINTER; nsresult res = NS_OK; @@ -211,7 +212,7 @@ nsSelectionState::RestoreSelection(nsIDOMSelection *aSel) nsRangeStore *item; // clear out selection - aSel->ClearSelection(); + aSel->RemoveAllRanges(); // set the selection ranges anew for (i=0; iselection; + nsCOMPtrselection; result = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(result)) { return result; } if (!selection) { return NS_ERROR_NULL_POINTER; } + nsCOMPtrselPrivate(do_QueryInterface(selection)); - selection->StartBatchChanges(); + selPrivate->StartBatchChanges(); if (mTxnMgr) { result = mTxnMgr->Do(aTxn); } @@ -1155,7 +1157,7 @@ nsEditor::Do(nsITransaction *aTxn) result = DoAfterDoTransaction(aTxn); } - selection->EndBatchChanges(); // no need to check result here, don't lose result of operation + selPrivate->EndBatchChanges(); // no need to check result here, don't lose result of operation } NS_POSTCONDITION((NS_SUCCEEDED(result)), "transaction did not execute properly\n"); @@ -1343,7 +1345,7 @@ nsEditor::BeginPlaceHolderTransaction(nsIAtom *aName) BeginUpdateViewBatch(); mPlaceHolderTxn = nsnull; mPlaceHolderName = aName; - nsCOMPtr selection; + nsCOMPtr selection; nsresult res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; mSelState = new nsSelectionState(); @@ -1410,7 +1412,7 @@ NS_IMETHODIMP nsEditor::SelectAll() if (!mDocWeak || !mPresShellWeak) { return NS_ERROR_NOT_INITIALIZED; } ForceCompositionEnd(); - nsCOMPtr selection; + nsCOMPtr selection; nsCOMPtr selCon = do_QueryReferent(mSelConWeak); if (!selCon) return NS_ERROR_NOT_INITIALIZED; nsresult result = selCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection)); @@ -1425,7 +1427,7 @@ NS_IMETHODIMP nsEditor::BeginningOfDocument() { if (!mDocWeak || !mPresShellWeak) { return NS_ERROR_NOT_INITIALIZED; } - nsCOMPtr selection; + nsCOMPtr selection; if (!mPresShellWeak) return NS_ERROR_NOT_INITIALIZED; nsCOMPtr selCon = do_QueryReferent(mSelConWeak); if (!selCon) return NS_ERROR_NOT_INITIALIZED; @@ -1487,7 +1489,7 @@ nsEditor::EndOfDocument() nsresult res; // get selection - nsCOMPtr selection; + nsCOMPtr selection; res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_NULL_POINTER; @@ -2385,7 +2387,7 @@ nsEditor::ArePreservingSelection() } nsresult -nsEditor::PreserveSelectionAcrossActions(nsIDOMSelection *aSel) +nsEditor::PreserveSelectionAcrossActions(nsISelection *aSel) { mSavedSel.SaveSelection(aSel); mRangeUpdater.RegisterSelectionState(mSavedSel); @@ -2393,7 +2395,7 @@ nsEditor::PreserveSelectionAcrossActions(nsIDOMSelection *aSel) } nsresult -nsEditor::RestorePreservedSelection(nsIDOMSelection *aSel) +nsEditor::RestorePreservedSelection(nsISelection *aSel) { if (mSavedSel.IsEmpty()) return NS_ERROR_FAILURE; mSavedSel.RestoreSelection(aSel); @@ -2422,7 +2424,7 @@ NS_IMETHODIMP nsEditor::QueryComposition(nsTextEventReply* aReply) { nsresult result; - nsCOMPtr selection; + nsCOMPtr selection; nsCOMPtr selcon = do_QueryReferent(mSelConWeak); if (selcon) selcon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection)); @@ -2980,7 +2982,7 @@ NS_IMETHODIMP nsEditor::InsertTextIntoTextNodeImpl(const nsString& aStringToInse } -NS_IMETHODIMP nsEditor::SelectEntireDocument(nsIDOMSelection *aSelection) +NS_IMETHODIMP nsEditor::SelectEntireDocument(nsISelection *aSelection) { nsresult result; if (!aSelection) { return NS_ERROR_NULL_POINTER; } @@ -3256,7 +3258,7 @@ nsEditor::SplitNodeImpl(nsIDOMNode * aExistingRightNode, (nsnull!=aParent)) { // get selection - nsCOMPtr selection; + nsCOMPtr selection; result = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(result)) return result; if (!selection) return NS_ERROR_NULL_POINTER; @@ -3374,7 +3376,7 @@ nsEditor::JoinNodesImpl(nsIDOMNode * aNodeToKeep, if (aNodeToKeep && aNodeToJoin && aParent) { // get selection - nsCOMPtr selection; + nsCOMPtr selection; GetSelection(getter_AddRefs(selection)); if (NS_FAILED(result)) return result; if (!selection) return NS_ERROR_NULL_POINTER; @@ -4866,7 +4868,7 @@ nsEditor::NextNodeInBlock(nsIDOMNode *aNode, IterDirection aDir) // GetStartNodeAndOffset: returns whatever the start parent & offset is of // the first range in the selection. nsresult -nsEditor::GetStartNodeAndOffset(nsIDOMSelection *aSelection, +nsEditor::GetStartNodeAndOffset(nsISelection *aSelection, nsCOMPtr *outStartNode, PRInt32 *outStartOffset) { @@ -4875,7 +4877,9 @@ nsEditor::GetStartNodeAndOffset(nsIDOMSelection *aSelection, nsCOMPtr enumerator; nsresult result; - result = aSelection->GetEnumerator(getter_AddRefs(enumerator)); + nsCOMPtr sel(aSelection); + nsCOMPtrselPrivate(do_QueryInterface(sel)); + result = selPrivate->GetEnumerator(getter_AddRefs(enumerator)); if (NS_FAILED(result) || !enumerator) return NS_ERROR_FAILURE; @@ -4902,7 +4906,7 @@ nsEditor::GetStartNodeAndOffset(nsIDOMSelection *aSelection, // GetEndNodeAndOffset: returns whatever the end parent & offset is of // the first range in the selection. nsresult -nsEditor::GetEndNodeAndOffset(nsIDOMSelection *aSelection, +nsEditor::GetEndNodeAndOffset(nsISelection *aSelection, nsCOMPtr *outEndNode, PRInt32 *outEndOffset) { @@ -4910,7 +4914,9 @@ nsEditor::GetEndNodeAndOffset(nsIDOMSelection *aSelection, return NS_ERROR_NULL_POINTER; nsCOMPtr enumerator; - nsresult result = aSelection->GetEnumerator(getter_AddRefs(enumerator)); + nsCOMPtr sel(aSelection); + nsCOMPtrselPrivate(do_QueryInterface(sel)); + nsresult result = selPrivate->GetEnumerator(getter_AddRefs(enumerator)); if (NS_FAILED(result) || !enumerator) return NS_ERROR_FAILURE; @@ -5282,11 +5288,12 @@ nsresult nsEditor::BeginUpdateViewBatch() { NS_PRECONDITION(mUpdateCount>=0, "bad state"); - nsCOMPtrselection; + nsCOMPtrselection; nsresult rv = GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(rv) && selection) { - selection->StartBatchChanges(); + nsCOMPtrselPrivate(do_QueryInterface(selection)); + selPrivate->StartBatchChanges(); } if (nsnull!=mViewManager) @@ -5327,10 +5334,11 @@ nsresult nsEditor::EndUpdateViewBatch() return rv?rv:NS_ERROR_FAILURE; StCaretHider caretHider(caret); - nsCOMPtrselection; + nsCOMPtrselection; nsresult selectionResult = GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(selectionResult) && selection) { - selection->EndBatchChanges(); + nsCOMPtrselPrivate(do_QueryInterface(selection)); + selPrivate->EndBatchChanges(); } if (mViewManager) @@ -5406,7 +5414,7 @@ nsEditor::DeleteSelectionImpl(nsIEditor::EDirection aAction) EditAggregateTxn *txn; PRInt32 i; nsIEditActionListener *listener; - nsCOMPtrselection; + nsCOMPtrselection; res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; res = CreateTxnForDeleteSelection(aAction, &txn); @@ -5604,7 +5612,7 @@ NS_IMETHODIMP nsEditor::CreateTxnForDeleteElement(nsIDOMNode * aElement, // Get current selection and setup txn to delete it, // but only if selection exists (is not a collapsed "caret" state) - nsCOMPtr selection; + nsCOMPtr selection; if (!mPresShellWeak) return NS_ERROR_NOT_INITIALIZED; nsCOMPtr ps = do_QueryReferent(mPresShellWeak); if (!ps) return NS_ERROR_NOT_INITIALIZED; @@ -5689,7 +5697,7 @@ nsEditor::CreateTxnForDeleteSelection(nsIEditor::EDirection aAction, #endif nsresult result; - nsCOMPtr selection; + nsCOMPtr selection; nsCOMPtr selCon = do_QueryReferent(mSelConWeak); if (!selCon) return NS_ERROR_NOT_INITIALIZED; result = selCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection)); @@ -5708,7 +5716,8 @@ nsEditor::CreateTxnForDeleteSelection(nsIEditor::EDirection aAction, } nsCOMPtr enumerator; - result = selection->GetEnumerator(getter_AddRefs(enumerator)); + nsCOMPtrselPrivate(do_QueryInterface(selection)); + result = selPrivate->GetEnumerator(getter_AddRefs(enumerator)); if (NS_SUCCEEDED(result) && enumerator) { for (enumerator->First(); NS_OK!=enumerator->IsDone(); enumerator->Next()) @@ -6000,7 +6009,7 @@ nsresult nsEditor::AppendNodeToSelectionAsRange(nsIDOMNode *aNode) { if (!aNode) return NS_ERROR_NULL_POINTER; - nsCOMPtr selection; + nsCOMPtr selection; nsresult res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if(!selection) return NS_ERROR_FAILURE; @@ -6024,11 +6033,11 @@ nsEditor::AppendNodeToSelectionAsRange(nsIDOMNode *aNode) nsresult nsEditor::ClearSelection() { - nsCOMPtr selection; + nsCOMPtr selection; nsresult res = nsEditor::GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_FAILURE; - return selection->ClearSelection(); + return selection->RemoveAllRanges(); } nsresult diff --git a/mozilla/editor/base/nsEditor.h b/mozilla/editor/base/nsEditor.h index 59ce695d7b6..5acaa6e30b3 100644 --- a/mozilla/editor/base/nsEditor.h +++ b/mozilla/editor/base/nsEditor.h @@ -31,7 +31,7 @@ #include "nsIDOMDocument.h" #include "nsIDiskDocument.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIDOMCharacterData.h" #include "nsIDOMEventListener.h" #include "nsIDOMRange.h" @@ -101,8 +101,8 @@ class nsSelectionState nsSelectionState(); ~nsSelectionState(); - nsresult SaveSelection(nsIDOMSelection *aSel); - nsresult RestoreSelection(nsIDOMSelection *aSel); + nsresult SaveSelection(nsISelection *aSel); + nsresult RestoreSelection(nsISelection *aSel); PRBool IsCollapsed(); PRBool IsEqual(nsSelectionState *aSelState); void MakeEmpty(); @@ -220,7 +220,7 @@ public: NS_IMETHOD GetRootElement(nsIDOMElement **aElement); NS_IMETHOD GetPresShell(nsIPresShell **aPS); NS_IMETHOD GetSelectionController(nsISelectionController **aSel); - NS_IMETHOD GetSelection(nsIDOMSelection **aSelection); + NS_IMETHOD GetSelection(nsISelection **aSelection); NS_IMETHOD EnableUndo(PRBool aEnable); NS_IMETHOD GetTransactionManager(nsITransactionManager* *aTxnManager); @@ -486,7 +486,7 @@ protected: NS_IMETHOD NotifyDocumentListeners(TDocumentListenerNotification aNotificationType); /** make the given selection span the entire document */ - NS_IMETHOD SelectEntireDocument(nsIDOMSelection *aSelection); + NS_IMETHOD SelectEntireDocument(nsISelection *aSelection); protected: // XXXX: Horrible hack! We are doing this because @@ -509,8 +509,8 @@ public: /** routines for managing the preservation of selection across * various editor actions */ PRBool ArePreservingSelection(); - nsresult PreserveSelectionAcrossActions(nsIDOMSelection *aSel); - nsresult RestorePreservedSelection(nsIDOMSelection *aSel); + nsresult PreserveSelectionAcrossActions(nsISelection *aSel); + nsresult RestorePreservedSelection(nsISelection *aSel); void StopPreservingSelection(); @@ -722,8 +722,8 @@ public: static nsCOMPtr GetChildAt(nsIDOMNode *aParent, PRInt32 aOffset); static nsCOMPtr NextNodeInBlock(nsIDOMNode *aNode, IterDirection aDir); - static nsresult GetStartNodeAndOffset(nsIDOMSelection *aSelection, nsCOMPtr *outStartNode, PRInt32 *outStartOffset); - static nsresult GetEndNodeAndOffset(nsIDOMSelection *aSelection, nsCOMPtr *outEndNode, PRInt32 *outEndOffset); + static nsresult GetStartNodeAndOffset(nsISelection *aSelection, nsCOMPtr *outStartNode, PRInt32 *outStartOffset); + static nsresult GetEndNodeAndOffset(nsISelection *aSelection, nsCOMPtr *outEndNode, PRInt32 *outEndOffset); // Helpers to add a node to the selection. // Used by table cell selection methods diff --git a/mozilla/editor/base/nsEditorController.cpp b/mozilla/editor/base/nsEditorController.cpp index c3c19ab9d20..4addd2182c3 100644 --- a/mozilla/editor/base/nsEditorController.cpp +++ b/mozilla/editor/base/nsEditorController.cpp @@ -28,7 +28,7 @@ #include "nsIEditorShell.h" #include "nsIEditorMailSupport.h" #include "nsIFormControlFrame.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIHTMLEditor.h" #include "nsISupportsPrimitives.h" #include "nsXPIDLString.h" @@ -293,6 +293,8 @@ nsresult nsComposerController::RegisterComposerCommands(nsIControllerCommandMana // File menu NS_REGISTER_FIRST_COMMAND(nsPrintingCommands, "cmd_print"); NS_REGISTER_NEXT_COMMAND(nsPrintingCommands, "cmd_printSetup"); + NS_REGISTER_NEXT_COMMAND(nsPrintingCommands,"cmd_print_button"); + NS_REGISTER_NEXT_COMMAND(nsPrintingCommands,"cmd_printSetup"); NS_REGISTER_LAST_COMMAND(nsPrintingCommands, "cmd_printPreview"); // Edit menu diff --git a/mozilla/editor/base/nsEditorEventListeners.cpp b/mozilla/editor/base/nsEditorEventListeners.cpp index c9841b67d2c..acff9f53fd7 100644 --- a/mozilla/editor/base/nsEditorEventListeners.cpp +++ b/mozilla/editor/base/nsEditorEventListeners.cpp @@ -30,7 +30,7 @@ #include "nsIDocument.h" #include "nsIPresShell.h" #include "nsIDOMElement.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIDOMCharacterData.h" #include "nsIEditProperty.h" #include "nsISupportsArray.h" @@ -394,7 +394,7 @@ nsTextEditorMouseListener::MouseClick(nsIDOMEvent* aMouseEvent) if (!NS_SUCCEEDED(nsuiEvent->GetRangeOffset(&offset))) return NS_ERROR_NULL_POINTER; - nsCOMPtr selection; + nsCOMPtr selection; if (NS_SUCCEEDED(editor->GetSelection(getter_AddRefs(selection)))) (void)selection->Collapse(parent, offset); @@ -704,7 +704,7 @@ nsTextEditorDragListener::DragDrop(nsIDOMEvent* aMouseEvent) selection, nothing should happen. cmanske: But do this only if drag source is not the same as target (current) document! */ - nsCOMPtr selection; + nsCOMPtr selection; rv = mEditor->GetSelection(getter_AddRefs(selection)); if (NS_FAILED(rv) || !selection) return rv?rv:NS_ERROR_FAILURE; diff --git a/mozilla/editor/base/nsEditorShell.cpp b/mozilla/editor/base/nsEditorShell.cpp index 881bdcf076b..d211b36a1fe 100644 --- a/mozilla/editor/base/nsEditorShell.cpp +++ b/mozilla/editor/base/nsEditorShell.cpp @@ -69,7 +69,8 @@ #include "nsIDOMHTMLImageElement.h" #include "nsIPresShell.h" #include "nsIPresContext.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" +#include "nsISelectionPrivate.h" #include "nsIFileWidget.h" #include "nsFileSpec.h" @@ -386,12 +387,13 @@ nsEditorShell::ResetEditingState() // now, unregister the selection listener, if there was one if (mStateMaintainer) { - nsCOMPtr domSelection; + nsCOMPtr domSelection; // using a scoped result, because we don't really care if this fails rv = GetEditorSelection(getter_AddRefs(domSelection)); if (NS_SUCCEEDED(rv) && domSelection) { - domSelection->RemoveSelectionListener(mStateMaintainer); + nsCOMPtr selPriv(do_QueryInterface(domSelection)); + selPriv->RemoveSelectionListener(mStateMaintainer); NS_IF_RELEASE(mStateMaintainer); } } @@ -483,11 +485,12 @@ nsEditorShell::PrepareDocumentForEditing(nsIDocumentLoader* aLoader, nsIURI *aUr if (NS_FAILED(rv)) return rv; // set it up as a selection listener - nsCOMPtr domSelection; + nsCOMPtr domSelection; rv = GetEditorSelection(getter_AddRefs(domSelection)); if (NS_FAILED(rv)) return rv; - rv = domSelection->AddSelectionListener(mStateMaintainer); + nsCOMPtr selPriv(do_QueryInterface(domSelection)); + rv = selPriv->AddSelectionListener(mStateMaintainer); if (NS_FAILED(rv)) return rv; // and set it up as a doc state listener @@ -2566,7 +2569,7 @@ nsEditorShell::Rewrap(PRBool aRespectNewlines) printf("nsEditorShell::Rewrap to %ld columns\n", (long)wrapCol); #endif - nsCOMPtr selection; + nsCOMPtr selection; rv = GetEditorSelection(getter_AddRefs(selection)); if (NS_FAILED(rv)) return rv; @@ -2630,7 +2633,7 @@ nsEditorShell::StripCites() printf("nsEditorShell::StripCites()\n"); #endif - nsCOMPtr selection; + nsCOMPtr selection; nsresult rv = GetEditorSelection(getter_AddRefs(selection)); if (NS_FAILED(rv)) return rv; @@ -3328,7 +3331,7 @@ nsEditorShell::GetEditor(nsIEditor** aEditor) NS_IMETHODIMP -nsEditorShell::GetEditorSelection(nsIDOMSelection** aEditorSelection) +nsEditorShell::GetEditorSelection(nsISelection** aEditorSelection) { nsCOMPtr editor = do_QueryInterface(mEditor); if (editor) diff --git a/mozilla/editor/base/nsEditorShell.h b/mozilla/editor/base/nsEditorShell.h index 3ded2d7d89e..6766d5d7c7c 100644 --- a/mozilla/editor/base/nsEditorShell.h +++ b/mozilla/editor/base/nsEditorShell.h @@ -33,7 +33,7 @@ #include "nsIEditorShell.h" #include "nsIEditorController.h" #include "nsIDocumentLoaderObserver.h" -#include "nsIDOMSelectionListener.h" +#include "nsISelectionListener.h" #include "nsIDOMEventReceiver.h" #include "nsIPrompt.h" #include "nsIStreamObserver.h" diff --git a/mozilla/editor/base/nsEditorShellMouseListener.cpp b/mozilla/editor/base/nsEditorShellMouseListener.cpp index a9a00efb73e..779b9cb96de 100644 --- a/mozilla/editor/base/nsEditorShellMouseListener.cpp +++ b/mozilla/editor/base/nsEditorShellMouseListener.cpp @@ -30,7 +30,7 @@ #include "nsIDOMElement.h" #include "nsIDOMCharacterData.h" #include "nsIDOMMouseEvent.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIDOMRange.h" #include "nsIDOMNSRange.h" #include "nsIDOMEventTarget.h" @@ -208,7 +208,7 @@ nsEditorShellMouseListener::MouseDown(nsIDOMEvent* aMouseEvent) res = mouseEvent->GetDetail(&clickCount); if (NS_FAILED(res)) return res; - nsCOMPtr selection; + nsCOMPtr selection; mEditorShell->GetEditorSelection(getter_AddRefs(selection)); if (!selection) return NS_OK; diff --git a/mozilla/editor/base/nsEditorUtils.cpp b/mozilla/editor/base/nsEditorUtils.cpp index 00f80836790..3b925349034 100644 --- a/mozilla/editor/base/nsEditorUtils.cpp +++ b/mozilla/editor/base/nsEditorUtils.cpp @@ -32,7 +32,7 @@ * nsAutoSelectionReset *****************************************************************************/ -nsAutoSelectionReset::nsAutoSelectionReset(nsIDOMSelection *aSel, nsEditor *aEd) : +nsAutoSelectionReset::nsAutoSelectionReset(nsISelection *aSel, nsEditor *aEd) : mSel(nsnull) ,mEd(nsnull) { diff --git a/mozilla/editor/base/nsEditorUtils.h b/mozilla/editor/base/nsEditorUtils.h index 9932e49a1c3..d9e1aa4bf72 100644 --- a/mozilla/editor/base/nsEditorUtils.h +++ b/mozilla/editor/base/nsEditorUtils.h @@ -27,7 +27,7 @@ #include "nsCOMPtr.h" #include "nsIDOMNode.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIEditor.h" #include "nsIAtom.h" #include "nsVoidArray.h" @@ -69,12 +69,12 @@ class nsAutoSelectionReset { private: /** ref-counted reference to the selection that we are supposed to restore */ - nsCOMPtr mSel; + nsCOMPtr mSel; nsEditor *mEd; // non-owning ref to nsEditor public: /** constructor responsible for remembering all state needed to restore aSel */ - nsAutoSelectionReset(nsIDOMSelection *aSel, nsEditor *aEd); + nsAutoSelectionReset(nsISelection *aSel, nsEditor *aEd); /** destructor restores mSel to its former state */ ~nsAutoSelectionReset(); diff --git a/mozilla/editor/base/nsHTMLEditRules.cpp b/mozilla/editor/base/nsHTMLEditRules.cpp index 987d827062e..9b056664a71 100644 --- a/mozilla/editor/base/nsHTMLEditRules.cpp +++ b/mozilla/editor/base/nsHTMLEditRules.cpp @@ -33,7 +33,8 @@ #include "nsIDOMText.h" #include "nsIDOMElement.h" #include "nsIDOMNodeList.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" +#include "nsISelectionPrivate.h" #include "nsIDOMRange.h" #include "nsIDOMCharacterData.h" #include "nsIEnumerator.h" @@ -307,7 +308,7 @@ nsHTMLEditRules::AfterEditInner(PRInt32 action, nsIEditor::EDirection aDirection ConfirmSelectionInBody(); if (action == nsEditor::kOpIgnore) return NS_OK; - nsCOMPtrselection; + nsCOMPtrselection; nsresult res = mEditor->GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; @@ -375,7 +376,7 @@ nsHTMLEditRules::AfterEditInner(PRInt32 action, nsIEditor::EDirection aDirection NS_IMETHODIMP -nsHTMLEditRules::WillDoAction(nsIDOMSelection *aSelection, +nsHTMLEditRules::WillDoAction(nsISelection *aSelection, nsRulesInfo *aInfo, PRBool *aCancel, PRBool *aHandled) @@ -429,7 +430,7 @@ nsHTMLEditRules::WillDoAction(nsIDOMSelection *aSelection, NS_IMETHODIMP -nsHTMLEditRules::DidDoAction(nsIDOMSelection *aSelection, +nsHTMLEditRules::DidDoAction(nsISelection *aSelection, nsRulesInfo *aInfo, nsresult aResult) { nsTextRulesInfo *info = NS_STATIC_CAST(nsTextRulesInfo*, aInfo); @@ -572,7 +573,7 @@ nsHTMLEditRules::GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign) aAlign = nsIHTMLEditor::eLeft; // get selection - nsCOMPtrselection; + nsCOMPtrselection; nsresult res = mEditor->GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; @@ -702,7 +703,7 @@ nsHTMLEditRules::GetParagraphState(PRBool &aMixed, nsString &outFormat) { nsCOMPtr selNode; PRInt32 selOffset; - nsCOMPtrselection; + nsCOMPtrselection; nsresult res = mEditor->GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; res = mEditor->GetStartNodeAndOffset(selection, &selNode, &selOffset); @@ -788,7 +789,7 @@ nsHTMLEditRules::GetParagraphState(PRBool &aMixed, nsString &outFormat) ********************************************************/ nsresult -nsHTMLEditRules::WillInsert(nsIDOMSelection *aSelection, PRBool *aCancel) +nsHTMLEditRules::WillInsert(nsISelection *aSelection, PRBool *aCancel) { nsresult res = nsTextEditRules::WillInsert(aSelection, aCancel); if (NS_FAILED(res)) return res; @@ -805,14 +806,14 @@ nsHTMLEditRules::WillInsert(nsIDOMSelection *aSelection, PRBool *aCancel) } nsresult -nsHTMLEditRules::DidInsert(nsIDOMSelection *aSelection, nsresult aResult) +nsHTMLEditRules::DidInsert(nsISelection *aSelection, nsresult aResult) { return nsTextEditRules::DidInsert(aSelection, aResult); } nsresult nsHTMLEditRules::WillInsertText(PRInt32 aAction, - nsIDOMSelection *aSelection, + nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled, const nsString *inString, @@ -1004,9 +1005,11 @@ nsHTMLEditRules::WillInsertText(PRInt32 aAction, } nsresult -nsHTMLEditRules::WillInsertBreak(nsIDOMSelection *aSelection, PRBool *aCancel, PRBool *aHandled) +nsHTMLEditRules::WillInsertBreak(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled) { if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; } + nsCOMPtr selection(aSelection); + nsCOMPtr selPriv(do_QueryInterface(selection)); // initialize out param *aCancel = PR_FALSE; *aHandled = PR_FALSE; @@ -1050,7 +1053,7 @@ nsHTMLEditRules::WillInsertBreak(nsIDOMSelection *aSelection, PRBool *aCancel, P res = mEditor->CreateBR(selNode, newOffset, &brNode); if (NS_FAILED(res)) return res; // want selection before the break, and on same line - aSelection->SetHint(PR_TRUE); + selPriv->SetInterlinePosition(PR_TRUE); res = aSelection->Collapse(selNode, newOffset); if (NS_FAILED(res)) return res; *aHandled = PR_TRUE; @@ -1101,12 +1104,14 @@ nsHTMLEditRules::WillInsertBreak(nsIDOMSelection *aSelection, PRBool *aCancel, P // its something else (body, div, td, ...): insert a normal br else { + nsCOMPtr selection(aSelection); + nsCOMPtr selPriv(do_QueryInterface(selection)); nsCOMPtr brNode; res = mEditor->CreateBR(node, offset, &brNode); if (NS_FAILED(res)) return res; res = nsEditor::GetNodeLocation(brNode, &node, &offset); if (NS_FAILED(res)) return res; - // SetHint(PR_TRUE) means we want the caret to stick to the content on the "right". + // SetInterlinePosition(PR_TRUE) means we want the caret to stick to the content on the "right". // We want the caret to stick to whatever is past the break. This is // because the break is on the same line we were on, but the next content // will be on the following line. @@ -1116,9 +1121,9 @@ nsHTMLEditRules::WillInsertBreak(nsIDOMSelection *aSelection, PRBool *aCancel, P nsCOMPtr siblingNode; brNode->GetNextSibling(getter_AddRefs(siblingNode)); if (siblingNode && mEditor->IsBlockNode(siblingNode)) - aSelection->SetHint(PR_FALSE); + selPriv->SetInterlinePosition(PR_FALSE); else - aSelection->SetHint(PR_TRUE); + selPriv->SetInterlinePosition(PR_TRUE); res = aSelection->Collapse(node, offset+1); if (NS_FAILED(res)) return res; *aHandled = PR_TRUE; @@ -1130,7 +1135,7 @@ nsHTMLEditRules::WillInsertBreak(nsIDOMSelection *aSelection, PRBool *aCancel, P nsresult -nsHTMLEditRules::WillDeleteSelection(nsIDOMSelection *aSelection, +nsHTMLEditRules::WillDeleteSelection(nsISelection *aSelection, nsIEditor::EDirection aAction, PRBool *aCancel, PRBool *aHandled) @@ -1139,6 +1144,8 @@ nsHTMLEditRules::WillDeleteSelection(nsIDOMSelection *aSelection, // initialize out param *aCancel = PR_FALSE; *aHandled = PR_FALSE; + nsCOMPtr selection(aSelection); + nsCOMPtr selPriv(do_QueryInterface(selection)); // if there is only bogus content, cancel the operation if (mBogusNode) @@ -1604,7 +1611,7 @@ nsHTMLEditRules::WillDeleteSelection(nsIDOMSelection *aSelection, // table elements. *aHandled = PR_TRUE; nsCOMPtr enumerator; - res = aSelection->GetEnumerator(getter_AddRefs(enumerator)); + res = selPriv->GetEnumerator(getter_AddRefs(enumerator)); if (NS_FAILED(res)) return res; if (!enumerator) return NS_ERROR_UNEXPECTED; @@ -1717,7 +1724,7 @@ nsHTMLEditRules::DeleteNonTableElements(nsIDOMNode *aNode) } nsresult -nsHTMLEditRules::WillMakeList(nsIDOMSelection *aSelection, +nsHTMLEditRules::WillMakeList(nsISelection *aSelection, const nsString *aListType, PRBool aEntireList, PRBool *aCancel, @@ -2041,7 +2048,7 @@ nsHTMLEditRules::WillMakeList(nsIDOMSelection *aSelection, nsresult -nsHTMLEditRules::WillRemoveList(nsIDOMSelection *aSelection, +nsHTMLEditRules::WillRemoveList(nsISelection *aSelection, PRBool aOrdered, PRBool *aCancel, PRBool *aHandled) @@ -2131,7 +2138,7 @@ nsHTMLEditRules::WillRemoveList(nsIDOMSelection *aSelection, nsresult -nsHTMLEditRules::WillMakeDefListItem(nsIDOMSelection *aSelection, +nsHTMLEditRules::WillMakeDefListItem(nsISelection *aSelection, const nsString *aItemType, PRBool aEntireList, PRBool *aCancel, @@ -2144,7 +2151,7 @@ nsHTMLEditRules::WillMakeDefListItem(nsIDOMSelection *aSelection, } nsresult -nsHTMLEditRules::WillMakeBasicBlock(nsIDOMSelection *aSelection, +nsHTMLEditRules::WillMakeBasicBlock(nsISelection *aSelection, const nsString *aBlockType, PRBool *aCancel, PRBool *aHandled) @@ -2210,7 +2217,7 @@ nsHTMLEditRules::WillMakeBasicBlock(nsIDOMSelection *aSelection, } nsresult -nsHTMLEditRules::DidMakeBasicBlock(nsIDOMSelection *aSelection, +nsHTMLEditRules::DidMakeBasicBlock(nsISelection *aSelection, nsRulesInfo *aInfo, nsresult aResult) { if (!aSelection) return NS_ERROR_NULL_POINTER; @@ -2229,7 +2236,7 @@ nsHTMLEditRules::DidMakeBasicBlock(nsIDOMSelection *aSelection, } nsresult -nsHTMLEditRules::WillIndent(nsIDOMSelection *aSelection, PRBool *aCancel, PRBool * aHandled) +nsHTMLEditRules::WillIndent(nsISelection *aSelection, PRBool *aCancel, PRBool * aHandled) { if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; } @@ -2362,7 +2369,7 @@ nsHTMLEditRules::WillIndent(nsIDOMSelection *aSelection, PRBool *aCancel, PRBool nsresult -nsHTMLEditRules::WillOutdent(nsIDOMSelection *aSelection, PRBool *aCancel, PRBool *aHandled) +nsHTMLEditRules::WillOutdent(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled) { if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; } // initialize out param @@ -2518,7 +2525,7 @@ nsHTMLEditRules::ConvertListType(nsIDOMNode *aList, // // nsresult -nsHTMLEditRules::CreateStyleForInsertText(nsIDOMSelection *aSelection, nsIDOMDocument *aDoc) +nsHTMLEditRules::CreateStyleForInsertText(nsISelection *aSelection, nsIDOMDocument *aDoc) { if (!aSelection || !aDoc) return NS_ERROR_NULL_POINTER; if (!mEditor->mTypeInState) return NS_ERROR_NULL_POINTER; @@ -2661,7 +2668,7 @@ nsHTMLEditRules::IsEmptyBlock(nsIDOMNode *aNode, nsresult -nsHTMLEditRules::WillAlign(nsIDOMSelection *aSelection, +nsHTMLEditRules::WillAlign(nsISelection *aSelection, const nsString *alignType, PRBool *aCancel, PRBool *aHandled) @@ -3290,7 +3297,7 @@ nsHTMLEditRules::GetPromotedPoint(RulesEndpoint aWhere, nsIDOMNode *aNode, PRInt // GetPromotedPoint() // nsresult -nsHTMLEditRules::GetPromotedRanges(nsIDOMSelection *inSelection, +nsHTMLEditRules::GetPromotedRanges(nsISelection *inSelection, nsCOMPtr *outArrayOfRanges, PRInt32 inOperationType) { @@ -3577,10 +3584,12 @@ nsHTMLEditRules::GetListActionNodes(nsCOMPtr *outArrayOfNodes, if (!outArrayOfNodes) return NS_ERROR_NULL_POINTER; nsresult res = NS_OK; - nsCOMPtrselection; + nsCOMPtrselection; res = mEditor->GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; - + nsCOMPtr selPriv(do_QueryInterface(selection)); + if (!selPriv) + return NS_ERROR_FAILURE; // added this in so that ui code can ask to change an entire list, even if selection // is only in part of it. used by list item dialog. if (aEntireList) @@ -3588,7 +3597,7 @@ nsHTMLEditRules::GetListActionNodes(nsCOMPtr *outArrayOfNodes, res = NS_NewISupportsArray(getter_AddRefs(*outArrayOfNodes)); if (NS_FAILED(res)) return res; nsCOMPtr enumerator; - res = selection->GetEnumerator(getter_AddRefs(enumerator)); + res = selPriv->GetEnumerator(getter_AddRefs(enumerator)); if (NS_FAILED(res)) return res; if (!enumerator) return NS_ERROR_UNEXPECTED; @@ -3694,7 +3703,7 @@ nsHTMLEditRules::GetParagraphFormatNodes(nsCOMPtr *outArrayOfN { if (!outArrayOfNodes) return NS_ERROR_NULL_POINTER; - nsCOMPtrselection; + nsCOMPtrselection; nsresult res = mEditor->GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; @@ -3928,7 +3937,7 @@ nsHTMLEditRules::MakeTransitionList(nsISupportsArray *inArrayOfNodes, // InsertTab: top level logic for determining how to insert a tab // nsresult -nsHTMLEditRules::InsertTab(nsIDOMSelection *aSelection, +nsHTMLEditRules::InsertTab(nsISelection *aSelection, nsString *outString) { nsCOMPtr parentNode; @@ -3963,7 +3972,7 @@ nsHTMLEditRules::InsertTab(nsIDOMSelection *aSelection, // ReturnInHeader: do the right thing for returns pressed in headers // nsresult -nsHTMLEditRules::ReturnInHeader(nsIDOMSelection *aSelection, +nsHTMLEditRules::ReturnInHeader(nsISelection *aSelection, nsIDOMNode *aHeader, nsIDOMNode *aNode, PRInt32 aOffset) @@ -4033,7 +4042,7 @@ nsHTMLEditRules::ReturnInHeader(nsIDOMSelection *aSelection, // ReturnInParagraph: do the right thing for returns pressed in paragraphs // nsresult -nsHTMLEditRules::ReturnInParagraph(nsIDOMSelection *aSelection, +nsHTMLEditRules::ReturnInParagraph(nsISelection *aSelection, nsIDOMNode *aPara, nsIDOMNode *aNode, PRInt32 aOffset, @@ -4168,12 +4177,14 @@ nsHTMLEditRules::ReturnInParagraph(nsIDOMSelection *aSelection, // ReturnInListItem: do the right thing for returns pressed in list items // nsresult -nsHTMLEditRules::ReturnInListItem(nsIDOMSelection *aSelection, +nsHTMLEditRules::ReturnInListItem(nsISelection *aSelection, nsIDOMNode *aListItem, nsIDOMNode *aNode, PRInt32 aOffset) { if (!aSelection || !aListItem || !aNode) return NS_ERROR_NULL_POINTER; + nsCOMPtr selection(aSelection); + nsCOMPtr selPriv(do_QueryInterface(selection)); nsresult res = NS_OK; nsCOMPtr listitem; @@ -4226,7 +4237,7 @@ nsHTMLEditRules::ReturnInListItem(nsIDOMSelection *aSelection, if (NS_FAILED(res)) return res; // set selection to before the moz br - aSelection->SetHint(PR_TRUE); + selPriv->SetInterlinePosition(PR_TRUE); res = aSelection->Collapse(listparent,offset+1); } return res; @@ -4702,7 +4713,7 @@ nsHTMLEditRules::AdjustSpecialBreaks(PRBool aSafeToAskFrames) nsresult -nsHTMLEditRules::AdjustWhitespace(nsIDOMSelection *aSelection) +nsHTMLEditRules::AdjustWhitespace(nsISelection *aSelection) { nsCOMPtr arrayOfNodes; nsCOMPtr isupports; @@ -4759,10 +4770,12 @@ nsHTMLEditRules::AdjustWhitespace(nsIDOMSelection *aSelection) nsresult -nsHTMLEditRules::AdjustSelection(nsIDOMSelection *aSelection, nsIEditor::EDirection aAction) +nsHTMLEditRules::AdjustSelection(nsISelection *aSelection, nsIEditor::EDirection aAction) { if (!aSelection) return NS_ERROR_NULL_POINTER; - + nsCOMPtr selection(aSelection); + nsCOMPtr selPriv(do_QueryInterface(selection)); + // if the selection isn't collapsed, do nothing. // moose: one thing to do instead is check for the case of // only a single break selected, and collapse it. Good thing? Beats me. @@ -4828,7 +4841,7 @@ nsHTMLEditRules::AdjustSelection(nsIDOMSelection *aSelection, nsIEditor::EDirect res = nsEditor::GetNodeLocation(brNode, &selNode, &selOffset); if (NS_FAILED(res)) return res; // selection stays *before* moz-br, sticking to it - aSelection->SetHint(PR_TRUE); + selPriv->SetInterlinePosition(PR_TRUE); res = aSelection->Collapse(selNode,selOffset); if (NS_FAILED(res)) return res; } @@ -4853,7 +4866,7 @@ nsHTMLEditRules::AdjustSelection(nsIDOMSelection *aSelection, nsIEditor::EDirect res = nsEditor::GetNodeLocation(brNode, &selNode, &selOffset); if (NS_FAILED(res)) return res; // selection stays *before* moz-br, sticking to it - aSelection->SetHint(PR_TRUE); + selPriv->SetInterlinePosition(PR_TRUE); res = aSelection->Collapse(selNode,selOffset); if (NS_FAILED(res)) return res; } @@ -5070,12 +5083,13 @@ nsHTMLEditRules::SelectionEndpointInNode(nsIDOMNode *aNode, PRBool *aResult) *aResult = PR_FALSE; - nsCOMPtrselection; + nsCOMPtrselection; nsresult res = mEditor->GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; + nsCOMPtrselPriv(do_QueryInterface(selection)); nsCOMPtr enumerator; - res = selection->GetEnumerator(getter_AddRefs(enumerator)); + res = selPriv->GetEnumerator(getter_AddRefs(enumerator)); if (NS_FAILED(res)) return res; if (!enumerator) return NS_ERROR_UNEXPECTED; @@ -5338,7 +5352,7 @@ nsHTMLEditRules::ConfirmSelectionInBody() bodyNode = do_QueryInterface(bodyElement); // get the selection - nsCOMPtrselection; + nsCOMPtrselection; res = mEditor->GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; @@ -5619,7 +5633,7 @@ nsHTMLEditRules::DidDeleteText(nsIDOMCharacterData *aTextNode, } NS_IMETHODIMP -nsHTMLEditRules::WillDeleteSelection(nsIDOMSelection *aSelection) +nsHTMLEditRules::WillDeleteSelection(nsISelection *aSelection) { if (!mListenerEnabled) return NS_OK; // get the (collapsed) selection location @@ -5639,7 +5653,7 @@ nsHTMLEditRules::WillDeleteSelection(nsIDOMSelection *aSelection) } NS_IMETHODIMP -nsHTMLEditRules::DidDeleteSelection(nsIDOMSelection *aSelection) +nsHTMLEditRules::DidDeleteSelection(nsISelection *aSelection) { return NS_OK; } diff --git a/mozilla/editor/base/nsHTMLEditRules.h b/mozilla/editor/base/nsHTMLEditRules.h index 7d98a752a52..d827487b3c5 100644 --- a/mozilla/editor/base/nsHTMLEditRules.h +++ b/mozilla/editor/base/nsHTMLEditRules.h @@ -49,8 +49,8 @@ public: NS_IMETHOD Init(nsHTMLEditor *aEditor, PRUint32 aFlags); NS_IMETHOD BeforeEdit(PRInt32 action, nsIEditor::EDirection aDirection); NS_IMETHOD AfterEdit(PRInt32 action, nsIEditor::EDirection aDirection); - NS_IMETHOD WillDoAction(nsIDOMSelection *aSelection, nsRulesInfo *aInfo, PRBool *aCancel, PRBool *aHandled); - NS_IMETHOD DidDoAction(nsIDOMSelection *aSelection, nsRulesInfo *aInfo, nsresult aResult); + NS_IMETHOD WillDoAction(nsISelection *aSelection, nsRulesInfo *aInfo, PRBool *aCancel, PRBool *aHandled); + NS_IMETHOD DidDoAction(nsISelection *aSelection, nsRulesInfo *aInfo, nsresult aResult); // nsIHTMLEditRules methods NS_IMETHOD GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &aDL); @@ -75,8 +75,8 @@ public: NS_IMETHOD DidInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsString &aString, nsresult aResult); NS_IMETHOD WillDeleteText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, PRInt32 aLength); NS_IMETHOD DidDeleteText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, PRInt32 aLength, nsresult aResult); - NS_IMETHOD WillDeleteSelection(nsIDOMSelection *aSelection); - NS_IMETHOD DidDeleteSelection(nsIDOMSelection *aSelection); + NS_IMETHOD WillDeleteSelection(nsISelection *aSelection); + NS_IMETHOD DidDeleteSelection(nsISelection *aSelection); protected: @@ -88,41 +88,42 @@ protected: // nsHTMLEditRules implementation methods - nsresult WillInsert(nsIDOMSelection *aSelection, PRBool *aCancel); - nsresult DidInsert(nsIDOMSelection *aSelection, nsresult aResult); + nsresult WillInsert(nsISelection *aSelection, PRBool *aCancel); + nsresult DidInsert(nsISelection *aSelection, nsresult aResult); nsresult WillInsertText( PRInt32 aAction, - nsIDOMSelection *aSelection, + nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled, const nsString *inString, nsString *outString, PRInt32 aMaxLength); - nsresult WillInsertBreak(nsIDOMSelection *aSelection, PRBool *aCancel, PRBool *aHandled); - nsresult WillDeleteSelection(nsIDOMSelection *aSelection, nsIEditor::EDirection aAction, + nsresult WillInsertBreak(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled); + nsresult WillDeleteSelection(nsISelection *aSelection, nsIEditor::EDirection aAction, PRBool *aCancel, PRBool *aHandled); nsresult DeleteNonTableElements(nsIDOMNode *aNode); - nsresult WillMakeList(nsIDOMSelection *aSelection, const nsString *aListType, PRBool aEntireList, PRBool *aCancel, PRBool *aHandled, const nsString *aItemType=nsnull); - nsresult WillRemoveList(nsIDOMSelection *aSelection, PRBool aOrderd, PRBool *aCancel, PRBool *aHandled); - nsresult WillIndent(nsIDOMSelection *aSelection, PRBool *aCancel, PRBool *aHandled); - nsresult WillOutdent(nsIDOMSelection *aSelection, PRBool *aCancel, PRBool *aHandled); - nsresult WillAlign(nsIDOMSelection *aSelection, const nsString *alignType, PRBool *aCancel, PRBool *aHandled); - nsresult WillMakeDefListItem(nsIDOMSelection *aSelection, const nsString *aBlockType, PRBool aEntireList, PRBool *aCancel, PRBool *aHandled); - nsresult WillMakeBasicBlock(nsIDOMSelection *aSelection, const nsString *aBlockType, PRBool *aCancel, PRBool *aHandled); - nsresult DidMakeBasicBlock(nsIDOMSelection *aSelection, nsRulesInfo *aInfo, nsresult aResult); + + nsresult WillMakeList(nsISelection *aSelection, const nsString *aListType, PRBool aEntireList, PRBool *aCancel, PRBool *aHandled, const nsString *aItemType=nsnull); + nsresult WillRemoveList(nsISelection *aSelection, PRBool aOrderd, PRBool *aCancel, PRBool *aHandled); + nsresult WillIndent(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled); + nsresult WillOutdent(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled); + nsresult WillAlign(nsISelection *aSelection, const nsString *alignType, PRBool *aCancel, PRBool *aHandled); + nsresult WillMakeDefListItem(nsISelection *aSelection, const nsString *aBlockType, PRBool aEntireList, PRBool *aCancel, PRBool *aHandled); + nsresult WillMakeBasicBlock(nsISelection *aSelection, const nsString *aBlockType, PRBool *aCancel, PRBool *aHandled); + nsresult DidMakeBasicBlock(nsISelection *aSelection, nsRulesInfo *aInfo, nsresult aResult); nsresult AlignInnerBlocks(nsIDOMNode *aNode, const nsString *alignType); nsresult AlignBlockContents(nsIDOMNode *aNode, const nsString *alignType); nsresult GetInnerContent(nsIDOMNode *aNode, nsISupportsArray *outArrayOfNodes, PRBool aList = PR_TRUE, PRBool aTble = PR_TRUE); - nsresult InsertTab(nsIDOMSelection *aSelection, nsString *outString); + nsresult InsertTab(nsISelection *aSelection, nsString *outString); - nsresult ReturnInHeader(nsIDOMSelection *aSelection, nsIDOMNode *aHeader, nsIDOMNode *aTextNode, PRInt32 aOffset); - nsresult ReturnInParagraph(nsIDOMSelection *aSelection, nsIDOMNode *aHeader, nsIDOMNode *aTextNode, PRInt32 aOffset, PRBool *aCancel, PRBool *aHandled); - nsresult ReturnInListItem(nsIDOMSelection *aSelection, nsIDOMNode *aHeader, nsIDOMNode *aTextNode, PRInt32 aOffset); + nsresult ReturnInHeader(nsISelection *aSelection, nsIDOMNode *aHeader, nsIDOMNode *aTextNode, PRInt32 aOffset); + nsresult ReturnInParagraph(nsISelection *aSelection, nsIDOMNode *aHeader, nsIDOMNode *aTextNode, PRInt32 aOffset, PRBool *aCancel, PRBool *aHandled); + nsresult ReturnInListItem(nsISelection *aSelection, nsIDOMNode *aHeader, nsIDOMNode *aTextNode, PRInt32 aOffset); nsresult AfterEditInner(PRInt32 action, nsIEditor::EDirection aDirection); nsresult ConvertListType(nsIDOMNode *aList, nsCOMPtr *outList, const nsString& aListType, const nsString& aItemType); - nsresult CreateStyleForInsertText(nsIDOMSelection *aSelection, nsIDOMDocument *aDoc); + nsresult CreateStyleForInsertText(nsISelection *aSelection, nsIDOMDocument *aDoc); nsresult IsEmptyBlock(nsIDOMNode *aNode, PRBool *outIsEmptyBlock, PRBool aMozBRDoesntCount = PR_FALSE, @@ -134,7 +135,7 @@ protected: nsresult GetPromotedPoint(RulesEndpoint aWhere, nsIDOMNode *aNode, PRInt32 aOffset, PRInt32 actionID, nsCOMPtr *outNode, PRInt32 *outOffset); - nsresult GetPromotedRanges(nsIDOMSelection *inSelection, + nsresult GetPromotedRanges(nsISelection *inSelection, nsCOMPtr *outArrayOfRanges, PRInt32 inOperationType); nsresult PromoteRange(nsIDOMRange *inRange, PRInt32 inOperationType); @@ -168,8 +169,8 @@ protected: nsresult PopListItem(nsIDOMNode *aListItem, PRBool *aOutOfList); nsresult AdjustSpecialBreaks(PRBool aSafeToAskFrames = PR_FALSE); - nsresult AdjustWhitespace(nsIDOMSelection *aSelection); - nsresult AdjustSelection(nsIDOMSelection *aSelection, nsIEditor::EDirection aAction); + nsresult AdjustWhitespace(nsISelection *aSelection); + nsresult AdjustSelection(nsISelection *aSelection, nsIEditor::EDirection aAction); nsresult FindNearSelectableNode(nsIDOMNode *aSelNode, PRInt32 aSelOffset, nsIEditor::EDirection aDirection, diff --git a/mozilla/editor/base/nsHTMLEditor.cpp b/mozilla/editor/base/nsHTMLEditor.cpp index 140c80b2272..8c4af61630f 100644 --- a/mozilla/editor/base/nsHTMLEditor.cpp +++ b/mozilla/editor/base/nsHTMLEditor.cpp @@ -39,7 +39,8 @@ #include "nsIDOMKeyListener.h" #include "nsIDOMMouseListener.h" #include "nsIDOMMouseEvent.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" +#include "nsISelectionPrivate.h" #include "nsIDOMHTMLAnchorElement.h" #include "nsIDOMHTMLImageElement.h" #include "nsISelectionController.h" @@ -307,15 +308,16 @@ nsHTMLEditor::~nsHTMLEditor() //the autopointers will clear themselves up. //but we need to also remove the listeners or we have a leak - nsCOMPtrselection; + nsCOMPtrselection; nsresult result = GetSelection(getter_AddRefs(selection)); // if we don't get the selection, just skip this if (NS_SUCCEEDED(result) && selection) { - nsCOMPtrlistener; + nsCOMPtr selPriv(do_QueryInterface(selection)); + nsCOMPtrlistener; listener = do_QueryInterface(mTypeInState); if (listener) { - selection->RemoveSelectionListener(listener); + selPriv->RemoveSelectionListener(listener); } } nsCOMPtr erP; @@ -417,15 +419,16 @@ NS_IMETHODIMP nsHTMLEditor::Init(nsIDOMDocument *aDoc, if (!mTypeInState) {return NS_ERROR_NULL_POINTER;} NS_ADDREF(mTypeInState); - nsCOMPtrselection; + nsCOMPtrselection; result = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(result)) { return result; } if (selection) { - nsCOMPtrlistener; + nsCOMPtr selPriv(do_QueryInterface(selection)); + nsCOMPtrlistener; listener = do_QueryInterface(mTypeInState); if (listener) { - selection->AddSelectionListener(listener); + selPriv->AddSelectionListener(listener); } } @@ -716,7 +719,7 @@ NS_IMETHODIMP nsHTMLEditor::EditorKeyPress(nsIDOMKeyEvent* aKeyEvent) if (keyCode == nsIDOMKeyEvent::DOM_VK_TAB && !(mFlags&eEditorPlaintextBit)) { - nsCOMPtrselection; + nsCOMPtrselection; res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; PRInt32 offset; @@ -866,7 +869,7 @@ NS_IMETHODIMP nsHTMLEditor::TabInTable(PRBool inIsShift, PRBool *outHandled) *outHandled = PR_TRUE; // put selection in right place // Use table code to get selection and index to new row... - nsCOMPtrselection; + nsCOMPtrselection; nsCOMPtr tblElement; nsCOMPtr cell; PRInt32 row; @@ -943,23 +946,24 @@ NS_IMETHODIMP nsHTMLEditor::CreateBRImpl(nsCOMPtr *aInOutParent, PRI *outBRNode = brNode; if (*outBRNode && (aSelect != eNone)) { - nsCOMPtr selection; + nsCOMPtr selection; nsCOMPtr parent; PRInt32 offset; res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; + nsCOMPtr selPriv(do_QueryInterface(selection)); res = GetNodeLocation(*outBRNode, &parent, &offset); if (NS_FAILED(res)) return res; if (aSelect == eNext) { // position selection after br - selection->SetHint(PR_TRUE); + selPriv->SetInterlinePosition(PR_TRUE); res = selection->Collapse(parent, offset+1); } else if (aSelect == ePrevious) { // position selection before br - selection->SetHint(PR_TRUE); + selPriv->SetInterlinePosition(PR_TRUE); res = selection->Collapse(parent, offset); } } @@ -977,7 +981,7 @@ NS_IMETHODIMP nsHTMLEditor::CreateBR(nsIDOMNode *aNode, PRInt32 aOffset, nsCOMPt NS_IMETHODIMP nsHTMLEditor::InsertBR(nsCOMPtr *outBRNode) { PRBool bCollapsed; - nsCOMPtr selection; + nsCOMPtr selection; if (!outBRNode) return NS_ERROR_NULL_POINTER; *outBRNode = nsnull; @@ -987,6 +991,7 @@ NS_IMETHODIMP nsHTMLEditor::InsertBR(nsCOMPtr *outBRNode) nsresult res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; + nsCOMPtr selPriv(do_QueryInterface(selection)); res = selection->GetIsCollapsed(&bCollapsed); if (NS_FAILED(res)) return res; if (!bCollapsed) @@ -1005,7 +1010,7 @@ NS_IMETHODIMP nsHTMLEditor::InsertBR(nsCOMPtr *outBRNode) // position selection after br res = GetNodeLocation(*outBRNode, &selNode, &selOffset); if (NS_FAILED(res)) return res; - selection->SetHint(PR_TRUE); + selPriv->SetInterlinePosition(PR_TRUE); res = selection->Collapse(selNode, selOffset+1); return res; @@ -1020,10 +1025,11 @@ NS_IMETHODIMP nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty, ForceCompositionEnd(); nsresult res; - nsCOMPtrselection; + nsCOMPtrselection; res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_NULL_POINTER; + nsCOMPtr selPriv(do_QueryInterface(selection)); PRBool isCollapsed; selection->GetIsCollapsed(&isCollapsed); @@ -1046,7 +1052,7 @@ NS_IMETHODIMP nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty, { // get selection range enumerator nsCOMPtr enumerator; - res = selection->GetEnumerator(getter_AddRefs(enumerator)); + res = selPriv->GetEnumerator(getter_AddRefs(enumerator)); if (NS_FAILED(res)) return res; if (!enumerator) return NS_ERROR_FAILURE; @@ -1741,16 +1747,17 @@ NS_IMETHODIMP nsHTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom *aProperty, aAll=PR_TRUE; aFirst=PR_FALSE; PRBool first=PR_TRUE; - nsCOMPtrselection; + nsCOMPtrselection; result = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(result)) return result; if (!selection) return NS_ERROR_NULL_POINTER; + nsCOMPtr selPriv(do_QueryInterface(selection)); PRBool isCollapsed; selection->GetIsCollapsed(&isCollapsed); nsCOMPtr collapsedNode; nsCOMPtr enumerator; - result = selection->GetEnumerator(getter_AddRefs(enumerator)); + result = selPriv->GetEnumerator(getter_AddRefs(enumerator)); if (NS_FAILED(result)) return result; if (!enumerator) return NS_ERROR_NULL_POINTER; @@ -1934,10 +1941,11 @@ nsresult nsHTMLEditor::RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsStri ForceCompositionEnd(); nsresult res; - nsCOMPtrselection; + nsCOMPtrselection; res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_NULL_POINTER; + nsCOMPtr selPriv(do_QueryInterface(selection)); PRBool isCollapsed; selection->GetIsCollapsed(&isCollapsed); @@ -1965,7 +1973,7 @@ nsresult nsHTMLEditor::RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsStri { // get selection range enumerator nsCOMPtr enumerator; - res = selection->GetEnumerator(getter_AddRefs(enumerator)); + res = selPriv->GetEnumerator(getter_AddRefs(enumerator)); if (NS_FAILED(res)) return res; if (!enumerator) return NS_ERROR_FAILURE; @@ -2069,7 +2077,7 @@ NS_IMETHODIMP nsHTMLEditor::DecreaseFontSize() return RelativeFontChange(-1); } -nsresult nsHTMLEditor::GetTextSelectionOffsets(nsIDOMSelection *aSelection, +nsresult nsHTMLEditor::GetTextSelectionOffsets(nsISelection *aSelection, PRInt32 &aOutStartOffset, PRInt32 &aOutEndOffset) { @@ -2087,7 +2095,9 @@ nsresult nsHTMLEditor::GetTextSelectionOffsets(nsIDOMSelection *aSelection, aSelection->GetFocusOffset(&endOffset); nsCOMPtr enumerator; - result = aSelection->GetEnumerator(getter_AddRefs(enumerator)); + nsCOMPtr selection(aSelection); + nsCOMPtr selPriv(do_QueryInterface(selection)); + result = selPriv->GetEnumerator(getter_AddRefs(enumerator)); if (NS_FAILED(result)) return result; if (!enumerator) return NS_ERROR_NULL_POINTER; @@ -2255,12 +2265,12 @@ nsHTMLEditor::SetCaretToDocumentStart() } nsresult -nsHTMLEditor::CollapseSelectionToDeepestNonTableFirstChild(nsIDOMSelection *aSelection, nsIDOMNode *aNode) +nsHTMLEditor::CollapseSelectionToDeepestNonTableFirstChild(nsISelection *aSelection, nsIDOMNode *aNode) { if (!aNode) return NS_ERROR_NULL_POINTER; nsresult res; - nsCOMPtr selection; + nsCOMPtr selection; if (aSelection) { selection = aSelection; @@ -2295,7 +2305,7 @@ NS_IMETHODIMP nsHTMLEditor::DeleteSelection(nsIEditor::EDirection aAction) { if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } - nsCOMPtr selection; + nsCOMPtr selection; PRBool cancel, handled; nsresult result; @@ -2375,7 +2385,7 @@ NS_IMETHODIMP nsHTMLEditor::InsertText(const nsString& aStringToInsert) { if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } - nsCOMPtr selection; + nsCOMPtr selection; PRBool cancel, handled; PRInt32 theAction = nsTextEditRules::kInsertText; PRInt32 opID = kOpInsertText; @@ -2439,7 +2449,7 @@ NS_IMETHODIMP nsHTMLEditor::InsertHTMLWithCharset(const nsString& aInputString, nsresult res; - nsCOMPtrselection; + nsCOMPtrselection; if (!mRules) return NS_ERROR_NOT_INITIALIZED; @@ -2562,7 +2572,7 @@ NS_IMETHODIMP nsHTMLEditor::InsertHTMLWithCharset(const nsString& aInputString, NS_IMETHODIMP nsHTMLEditor::ReplaceHeadContentsWithHTML(const nsString &aSourceToInsert) { - nsCOMPtr selection; + nsCOMPtr selection; nsresult res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_NULL_POINTER; @@ -2669,7 +2679,7 @@ nsHTMLEditor::RebuildDocumentFromSource(const nsString& aSourceString) { ForceCompositionEnd(); - nsCOMPtrselection; + nsCOMPtrselection; nsresult res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; @@ -2753,7 +2763,7 @@ NS_IMETHODIMP nsHTMLEditor::InsertBreak() if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } nsAutoRules beginRulesSniffing(this, kOpInsertBreak, nsIEditor::eNext); - nsCOMPtr selection; + nsCOMPtr selection; PRBool cancel, handled; // pre-process @@ -2800,16 +2810,17 @@ NS_IMETHODIMP nsHTMLEditor::InsertBreak() if (!selection) res = NS_ERROR_NULL_POINTER; // don't return here, so DidDoAction is called if (NS_SUCCEEDED(res)) { + nsCOMPtr selPriv(do_QueryInterface(selection)); if (-1==offsetInParent) { nextNode->GetParentNode(getter_AddRefs(parent)); res = GetChildOffset(nextNode, parent, offsetInParent); if (NS_SUCCEEDED(res)) { - // SetHint(PR_TRUE) means we want the caret to stick to the content on the "right". + // SetInterlinePosition(PR_TRUE) means we want the caret to stick to the content on the "right". // We want the caret to stick to whatever is past the break. This is // because the break is on the same line we were on, but the next content // will be on the following line. - selection->SetHint(PR_TRUE); + selPriv->SetInterlinePosition(PR_TRUE); res = selection->Collapse(parent, offsetInParent+1); // +1 to insert just after the break } } @@ -2843,7 +2854,7 @@ nsHTMLEditor::InsertElementAtSelection(nsIDOMElement* aElement, PRBool aDeleteSe nsAutoEditBatch beginBatching(this); nsAutoRules beginRulesSniffing(this, kOpInsertElement, nsIEditor::eNext); - nsCOMPtrselection; + nsCOMPtrselection; res = GetSelection(getter_AddRefs(selection)); if (!NS_SUCCEEDED(res) || !selection) return NS_ERROR_FAILURE; @@ -2976,7 +2987,7 @@ nsHTMLEditor::DeleteSelectionAndCreateNode(const nsString& aTag, NS_IF_ADDREF(*aNewNode); // we want the selection to be just after the new node - nsCOMPtr selection; + nsCOMPtr selection; result = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(result)) return result; if (!selection) return NS_ERROR_NULL_POINTER; @@ -2993,7 +3004,7 @@ nsHTMLEditor::SelectElement(nsIDOMElement* aElement) // Must be sure that element is contained in the document body if (IsElementInBody(aElement)) { - nsCOMPtr selection; + nsCOMPtr selection; res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_NULL_POINTER; @@ -3026,7 +3037,7 @@ nsHTMLEditor::SetCaretAfterElement(nsIDOMElement* aElement) // Be sure the element is contained in the document body if (aElement && IsElementInBody(aElement)) { - nsCOMPtr selection; + nsCOMPtr selection; res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_NULL_POINTER; @@ -3077,10 +3088,11 @@ nsHTMLEditor::GetParentBlockTags(nsStringArray *aTagList, PRBool aGetLists) if (!aTagList) { return NS_ERROR_NULL_POINTER; } nsresult res; - nsCOMPtrselection; + nsCOMPtrselection; res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_NULL_POINTER; + nsCOMPtr selPriv(do_QueryInterface(selection)); // Find out if the selection is collapsed: PRBool isCollapsed; @@ -3120,7 +3132,7 @@ nsHTMLEditor::GetParentBlockTags(nsStringArray *aTagList, PRBool aGetLists) // else non-collapsed selection nsCOMPtr enumerator; - res = selection->GetEnumerator(getter_AddRefs(enumerator)); + res = selPriv->GetEnumerator(getter_AddRefs(enumerator)); if (NS_FAILED(res)) return res; if (!enumerator) return NS_ERROR_NULL_POINTER; @@ -3354,7 +3366,7 @@ nsHTMLEditor::MakeOrChangeList(const nsString& aListType, PRBool entireList) nsresult res; if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } - nsCOMPtr selection; + nsCOMPtr selection; PRBool cancel, handled; nsAutoEditBatch beginBatching(this); @@ -3432,7 +3444,7 @@ nsHTMLEditor::RemoveList(const nsString& aListType) nsresult res; if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } - nsCOMPtr selection; + nsCOMPtr selection; PRBool cancel, handled; nsAutoEditBatch beginBatching(this); @@ -3461,7 +3473,7 @@ nsHTMLEditor::MakeDefinitionItem(const nsString& aItemType) nsresult res; if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } - nsCOMPtr selection; + nsCOMPtr selection; PRBool cancel, handled; nsAutoEditBatch beginBatching(this); @@ -3491,7 +3503,7 @@ nsHTMLEditor::InsertBasicBlock(const nsString& aBlockType) nsresult res; if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } - nsCOMPtr selection; + nsCOMPtr selection; PRBool cancel, handled; nsAutoEditBatch beginBatching(this); @@ -3575,7 +3587,7 @@ nsHTMLEditor::Indent(const nsString& aIndent) nsAutoRules beginRulesSniffing(this, opID, nsIEditor::eNext); // pre-process - nsCOMPtr selection; + nsCOMPtr selection; res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_NULL_POINTER; @@ -3656,7 +3668,7 @@ nsHTMLEditor::Align(const nsString& aAlignType) PRBool cancel, handled; // Find out if the selection is collapsed: - nsCOMPtr selection; + nsCOMPtr selection; nsresult res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_NULL_POINTER; @@ -3684,7 +3696,7 @@ nsHTMLEditor::GetElementOrParentByTagName(const nsString &aTagName, nsIDOMNode * else { // If no node supplied, get it from anchor node of current selection - nsCOMPtrselection; + nsCOMPtrselection; res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_NULL_POINTER; @@ -3802,10 +3814,11 @@ nsHTMLEditor::GetSelectedElement(const nsString& aTagName, nsIDOMElement** aRetu *aReturn = nsnull; // First look for a single element in selection - nsCOMPtrselection; + nsCOMPtrselection; nsresult res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_NULL_POINTER; + nsCOMPtr selPriv(do_QueryInterface(selection)); PRBool bNodeFound = PR_FALSE; res=NS_ERROR_NOT_INITIALIZED; @@ -3938,7 +3951,7 @@ nsHTMLEditor::GetSelectedElement(const nsString& aTagName, nsIDOMElement** aRetu if (!isCollapsed) // Don't bother to examine selection if it is collapsed { nsCOMPtr enumerator; - res = selection->GetEnumerator(getter_AddRefs(enumerator)); + res = selPriv->GetEnumerator(getter_AddRefs(enumerator)); if (NS_SUCCEEDED(res)) { if(!enumerator) @@ -4108,7 +4121,7 @@ NS_IMETHODIMP nsHTMLEditor::InsertLinkAroundSelection(nsIDOMElement* aAnchorElement) { nsresult res=NS_ERROR_NULL_POINTER; - nsCOMPtr selection; + nsCOMPtr selection; if (!aAnchorElement) return NS_ERROR_NULL_POINTER; @@ -4761,7 +4774,7 @@ nsHTMLEditor::Undo(PRUint32 aCount) nsAutoRules beginRulesSniffing(this, kOpUndo, nsIEditor::eNone); nsTextRulesInfo ruleInfo(nsTextEditRules::kUndo); - nsCOMPtr selection; + nsCOMPtr selection; GetSelection(getter_AddRefs(selection)); PRBool cancel, handled; result = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled); @@ -4784,7 +4797,7 @@ nsHTMLEditor::Redo(PRUint32 aCount) nsAutoRules beginRulesSniffing(this, kOpRedo, nsIEditor::eNone); nsTextRulesInfo ruleInfo(nsTextEditRules::kRedo); - nsCOMPtr selection; + nsCOMPtr selection; GetSelection(getter_AddRefs(selection)); PRBool cancel, handled; result = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled); @@ -4800,7 +4813,7 @@ nsHTMLEditor::Redo(PRUint32 aCount) NS_IMETHODIMP nsHTMLEditor::Cut() { - nsCOMPtr selection; + nsCOMPtr selection; nsresult res = GetSelection(getter_AddRefs(selection)); if (!NS_SUCCEEDED(res)) return res; @@ -4819,7 +4832,7 @@ NS_IMETHODIMP nsHTMLEditor::CanCut(PRBool &aCanCut) { aCanCut = PR_FALSE; - nsCOMPtr selection; + nsCOMPtr selection; nsresult res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; @@ -4843,7 +4856,7 @@ NS_IMETHODIMP nsHTMLEditor::CanCopy(PRBool &aCanCopy) { aCanCopy = PR_FALSE; - nsCOMPtr selection; + nsCOMPtr selection; nsresult res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; @@ -5062,7 +5075,7 @@ NS_IMETHODIMP nsHTMLEditor::InsertFromDrop(nsIDOMEvent* aDropEvent) rv = GetDocument(getter_AddRefs(destdomdoc)); if (NS_FAILED(rv)) return rv; - nsCOMPtr selection; + nsCOMPtr selection; rv = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(rv)) return rv; if (!selection) return NS_ERROR_FAILURE; @@ -5180,7 +5193,7 @@ NS_IMETHODIMP nsHTMLEditor::CanDrag(nsIDOMEvent *aDragEvent, PRBool &aCanDrag) return NS_OK; } - nsCOMPtr selection; + nsCOMPtr selection; nsresult res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; @@ -5221,7 +5234,7 @@ NS_IMETHODIMP nsHTMLEditor::DoDrag(nsIDOMEvent *aDragEvent) nsCOMPtr domnode = do_QueryInterface(eventTarget); /* get the selection to be dragged */ - nsCOMPtr selection; + nsCOMPtr selection; rv = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(rv)) return rv; @@ -5406,7 +5419,7 @@ NS_IMETHODIMP nsHTMLEditor::PasteAsCitedQuotation(const nsString& aCitation, nsAutoRules beginRulesSniffing(this, kOpInsertQuotation, nsIEditor::eNext); // get selection - nsCOMPtr selection; + nsCOMPtr selection; nsresult res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_NULL_POINTER; @@ -5559,7 +5572,7 @@ nsHTMLEditor::InsertAsPlaintextQuotation(const nsString& aQuotedText, nsCOMPtr preNode; // get selection - nsCOMPtr selection; + nsCOMPtr selection; rv = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(rv)) return rv; if (!selection) return NS_ERROR_NULL_POINTER; @@ -5634,7 +5647,7 @@ nsHTMLEditor::InsertAsCitedQuotation(const nsString& aQuotedText, nsresult res = NS_OK; // get selection - nsCOMPtr selection; + nsCOMPtr selection; res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_NULL_POINTER; @@ -5718,7 +5731,7 @@ NS_IMETHODIMP nsHTMLEditor::OutputToString(nsAWritableString& aOutputString, } else { - nsCOMPtr selection; + nsCOMPtr selection; // Set the wrap column. If our wrap column is 0, // i.e. wrap to body width, then don't set it, let the @@ -5741,11 +5754,13 @@ NS_IMETHODIMP nsHTMLEditor::OutputToString(nsAWritableString& aOutputString, NS_ENSURE_TRUE(rootElement, NS_ERROR_FAILURE); //is this a body?? do we want to output the whole doc? // Set the selection, if appropriate: + nsCOMPtr selPriv; if (aFlags & nsIDocumentEncoder::OutputSelectionOnly) { rv = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(rv)) return rv; + selPriv = do_QueryInterface(selection); } else if (nsHTMLEditUtils::IsBody(rootElement)) { @@ -5790,10 +5805,11 @@ NS_IMETHODIMP nsHTMLEditor::OutputToString(nsAWritableString& aOutputString, return NS_ERROR_FAILURE; rv = nsComponentManager::CreateInstance(kCDOMSelectionCID, nsnull, - NS_GET_IID(nsIDOMSelection), + NS_GET_IID(nsISelection), getter_AddRefs(selection)); if (selection) { + selPriv = do_QueryInterface(selection); //get the independent selection interface nsCOMPtr indSel = do_QueryInterface(selection); if (indSel) @@ -5816,7 +5832,18 @@ NS_IMETHODIMP nsHTMLEditor::OutputToString(nsAWritableString& aOutputString, } } } - return selection->ToString(aFormatType, aFlags, wc, aOutputString); + PRUnichar *tmp; + char *tmpformattype= ToNewCString(aFormatType);//crap copied string + if (!tmpformattype) + return NS_ERROR_NULL_POINTER; + rv = selPriv->ToStringWithFormat(tmpformattype, aFlags, wc, &tmp); + if (NS_SUCCEEDED(rv) && tmp) + { + nsMemory::Free(tmpformattype); + aOutputString.Assign(tmp); + nsMemory::Free(tmp); + } + return rv; } #if 0 @@ -5882,7 +5909,7 @@ NS_IMETHODIMP nsHTMLEditor::OutputToString(nsAWritableString& aOutputString, // Set the selection, if appropriate: if (aFlags & nsIDocumentEncoder::OutputSelectionOnly) { - nsCOMPtr selection; + nsCOMPtr selection; rv = GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(rv) && selection) encoder->SetSelection(selection); @@ -5969,7 +5996,7 @@ NS_IMETHODIMP nsHTMLEditor::OutputToStream(nsIOutputStream* aOutputStream, // Set the selection, if appropriate: if (aFlags & nsIDocumentEncoder::OutputSelectionOnly) { - nsCOMPtr selection; + nsCOMPtr selection; rv = GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(rv) && selection) encoder->SetSelection(selection); @@ -5996,7 +6023,7 @@ NS_IMETHODIMP nsHTMLEditor::OutputToStream(nsIOutputStream* aOutputStream, return encoder->EncodeToStream(aOutputStream); } -static nsresult SetSelectionAroundHeadChildren(nsCOMPtr aSelection, nsWeakPtr aDocWeak) +static nsresult SetSelectionAroundHeadChildren(nsCOMPtr aSelection, nsWeakPtr aDocWeak) { nsresult res = NS_OK; // Set selection around node @@ -6036,7 +6063,7 @@ static nsresult SetSelectionAroundHeadChildren(nsCOMPtr aSelect NS_IMETHODIMP nsHTMLEditor::GetHeadContentsAsHTML(nsString& aOutputString) { - nsCOMPtr selection; + nsCOMPtr selection; nsresult res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_NULL_POINTER; @@ -6109,7 +6136,7 @@ nsHTMLEditor::SetCompositionString(const nsString& aCompositionString, nsIPrivat return NS_OK; } - nsCOMPtr selection; + nsCOMPtr selection; nsresult result = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(result)) return result; @@ -6140,7 +6167,7 @@ nsHTMLEditor::GetReconversionString(nsReconversionEventReply* aReply) { nsresult res; - nsCOMPtr selection; + nsCOMPtr selection; res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res) || !selection) return (res == NS_OK) ? NS_ERROR_FAILURE : res; @@ -6289,7 +6316,7 @@ nsHTMLEditor::TagCanContainTag(const nsString &aParentTag, const nsString &aChil NS_IMETHODIMP -nsHTMLEditor::SelectEntireDocument(nsIDOMSelection *aSelection) +nsHTMLEditor::SelectEntireDocument(nsISelection *aSelection) { nsresult res; if (!aSelection || !mRules) { return NS_ERROR_NULL_POINTER; } @@ -6491,7 +6518,7 @@ nsHTMLEditor::SetCaretInTableCell(nsIDOMElement* aElement) } } // Set selection at beginning of deepest node - nsCOMPtr selection; + nsCOMPtr selection; res = GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(res) && selection && firstChild) { @@ -6588,7 +6615,7 @@ NS_IMETHODIMP nsHTMLEditor::DeleteSelectionAndPrepareToCreateNode(nsCOMPtr &parentSelectedNode, PRInt32& offsetOfNewNode) { nsresult result=NS_ERROR_NOT_INITIALIZED; - nsCOMPtr selection; + nsCOMPtr selection; result = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(result)) return result; if (!selection) return NS_ERROR_NULL_POINTER; @@ -6920,7 +6947,7 @@ nsHTMLEditor::GetNextElementByTagName(nsIDOMElement *aCurrentElement, } NS_IMETHODIMP -nsHTMLEditor::SetSelectionAtDocumentStart(nsIDOMSelection *aSelection) +nsHTMLEditor::SetSelectionAtDocumentStart(nsISelection *aSelection) { nsCOMPtr bodyElement; nsresult res = GetRootElement(getter_AddRefs(bodyElement)); @@ -6946,11 +6973,11 @@ nsHTMLEditor::RelativeFontChange( PRInt32 aSizeChange) ForceCompositionEnd(); // Get the selection - nsCOMPtrselection; + nsCOMPtrselection; nsresult res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_FAILURE; - + nsCOMPtr selPriv(do_QueryInterface(selection)); // Is the selection collapsed? PRBool bCollapsed; res = selection->GetIsCollapsed(&bCollapsed); @@ -6974,7 +7001,7 @@ nsHTMLEditor::RelativeFontChange( PRInt32 aSizeChange) // get selection range enumerator nsCOMPtr enumerator; - res = selection->GetEnumerator(getter_AddRefs(enumerator)); + res = selPriv->GetEnumerator(getter_AddRefs(enumerator)); if (NS_FAILED(res)) return res; if (!enumerator) return NS_ERROR_FAILURE; diff --git a/mozilla/editor/base/nsHTMLEditor.h b/mozilla/editor/base/nsHTMLEditor.h index 6054d93ee23..d1d0f427c75 100644 --- a/mozilla/editor/base/nsHTMLEditor.h +++ b/mozilla/editor/base/nsHTMLEditor.h @@ -298,7 +298,7 @@ public: virtual PRBool TagCanContainTag(const nsString &aParentTag, const nsString &aChildTag); /** make the given selection span the entire document */ - NS_IMETHOD SelectEntireDocument(nsIDOMSelection *aSelection); + NS_IMETHOD SelectEntireDocument(nsISelection *aSelection); /** join together any afjacent editable text nodes in the range */ NS_IMETHOD CollapseAdjacentTextNodes(nsIDOMRange *aInRange); @@ -312,7 +312,7 @@ public: /** returns the absolute position of the end points of aSelection * in the document as a text stream. */ - nsresult GetTextSelectionOffsets(nsIDOMSelection *aSelection, + nsresult GetTextSelectionOffsets(nsISelection *aSelection, PRInt32 &aStartOffset, PRInt32 &aEndOffset); @@ -330,7 +330,7 @@ public: // This will stop at a table, however, since we don't want to // "drill down" into nested tables. // aSelection is optional -- if null, we get current seletion - nsresult CollapseSelectionToDeepestNonTableFirstChild(nsIDOMSelection *aSelection, nsIDOMNode *aNode); + nsresult CollapseSelectionToDeepestNonTableFirstChild(nsISelection *aSelection, nsIDOMNode *aNode); nsresult IsEmptyNode(nsIDOMNode *aNode, PRBool *outIsEmptyBlock, PRBool aMozBRDoesntCount = PR_FALSE, @@ -401,7 +401,7 @@ protected: // Move all contents from aCellToMerge into aTargetCell (append at end) NS_IMETHOD MergeCells(nsCOMPtr aTargetCell, nsCOMPtr aCellToMerge, PRBool aDeleteCellToMerge); - NS_IMETHOD DeleteTable2(nsIDOMElement *aTable, nsIDOMSelection *aSelection); + NS_IMETHOD DeleteTable2(nsIDOMElement *aTable, nsISelection *aSelection); NS_IMETHOD SetColSpan(nsIDOMElement *aCell, PRInt32 aColSpan); NS_IMETHOD SetRowSpan(nsIDOMElement *aCell, PRInt32 aRowSpan); @@ -421,7 +421,7 @@ protected: // Input: *aCell is a known cell, // if null, cell is obtained from the anchor node of the selection // Returns NS_EDITOR_ELEMENT_NOT_FOUND if cell is not found even if aCell is null - NS_IMETHOD GetCellContext(nsIDOMSelection **aSelection, + NS_IMETHOD GetCellContext(nsISelection **aSelection, nsIDOMElement **aTable, nsIDOMElement **aCell, nsIDOMNode **aCellParent, PRInt32 *aCellOffset, @@ -444,7 +444,7 @@ protected: // Fallback method: Call this after using ClearSelection() and you // failed to set selection to some other content in the document - NS_IMETHOD SetSelectionAtDocumentStart(nsIDOMSelection *aSelection); + NS_IMETHOD SetSelectionAtDocumentStart(nsISelection *aSelection); // End of Table Editing utilities @@ -489,7 +489,7 @@ protected: void ResetTextSelectionForRange(nsIDOMNode *aParent, PRInt32 aStartOffset, PRInt32 aEndOffset, - nsIDOMSelection *aSelection); + nsISelection *aSelection); // Methods for handling plaintext quotations diff --git a/mozilla/editor/base/nsHTMLEditorLog.cpp b/mozilla/editor/base/nsHTMLEditorLog.cpp index deba9cf3348..b867a8c04c4 100644 --- a/mozilla/editor/base/nsHTMLEditorLog.cpp +++ b/mozilla/editor/base/nsHTMLEditorLog.cpp @@ -28,7 +28,7 @@ #include "nsIDOMNodeList.h" #include "nsIDOMCharacterData.h" #include "nsIDOMNamedNodeMap.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIDOMRange.h" #include "nsHTMLEditorLog.h" #include "nsCOMPtr.h" @@ -958,7 +958,7 @@ nsHTMLEditorLog::PrintUnicode(const nsString &aString) nsresult nsHTMLEditorLog::PrintSelection() { - nsCOMPtr selection; + nsCOMPtr selection; nsresult result; PRInt32 rangeCount; diff --git a/mozilla/editor/base/nsInterfaceState.cpp b/mozilla/editor/base/nsInterfaceState.cpp index 3e4055e2423..1e36dc29103 100644 --- a/mozilla/editor/base/nsInterfaceState.cpp +++ b/mozilla/editor/base/nsInterfaceState.cpp @@ -32,7 +32,7 @@ #include "nsIDOMDocument.h" #include "nsIDiskDocument.h" #include "nsIDOMElement.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIDOMAttr.h" #include "nsIScriptGlobalObject.h" #include "nsIDOMWindowInternal.h" @@ -97,7 +97,7 @@ nsInterfaceState::~nsInterfaceState() NS_IMPL_ADDREF(nsInterfaceState); NS_IMPL_RELEASE(nsInterfaceState); -NS_IMPL_QUERY_INTERFACE4(nsInterfaceState, nsIDOMSelectionListener, nsIDocumentStateListener, nsITransactionListener, nsITimerCallback); +NS_IMPL_QUERY_INTERFACE4(nsInterfaceState, nsISelectionListener, nsIDocumentStateListener, nsITransactionListener, nsITimerCallback); NS_IMETHODIMP nsInterfaceState::Init(nsIHTMLEditor* aEditor, nsIDOMDocument *aChromeDoc) @@ -149,7 +149,7 @@ nsInterfaceState::NotifyDocumentStateChanged(PRBool aNowDirty) } NS_IMETHODIMP -nsInterfaceState::NotifySelectionChanged(nsIDOMDocument *, nsIDOMSelection *, short) +nsInterfaceState::NotifySelectionChanged(nsIDOMDocument *, nsISelection *, short) { return PrimeUpdateTimer(); } @@ -383,7 +383,7 @@ nsInterfaceState::SelectionIsCollapsed() nsCOMPtr editor = do_QueryInterface(mEditor, &rv); if (NS_SUCCEEDED(rv)) { - nsCOMPtr domSelection; + nsCOMPtr domSelection; rv = editor->GetSelection(getter_AddRefs(domSelection)); if (NS_SUCCEEDED(rv)) { @@ -398,7 +398,7 @@ nsInterfaceState::SelectionIsCollapsed() nsresult nsInterfaceState::UpdateParagraphState(const char* observerName, const char* attributeName) { - nsCOMPtr domSelection; + nsCOMPtr domSelection; nsCOMPtr editor = do_QueryInterface(mEditor); // Get the nsIEditor pointer (mEditor is nsIHTMLEditor) if (!editor) return NS_ERROR_NULL_POINTER; @@ -664,7 +664,7 @@ nsInterfaceState::Notify(nsITimer *timer) #endif -nsresult NS_NewInterfaceState(nsIHTMLEditor* aEditor, nsIDOMDocument* aChromeDoc, nsIDOMSelectionListener** aInstancePtrResult) +nsresult NS_NewInterfaceState(nsIHTMLEditor* aEditor, nsIDOMDocument* aChromeDoc, nsISelectionListener** aInstancePtrResult) { nsInterfaceState* newThang = new nsInterfaceState; if (!newThang) @@ -678,5 +678,5 @@ nsresult NS_NewInterfaceState(nsIHTMLEditor* aEditor, nsIDOMDocument* aChromeDoc return rv; } - return newThang->QueryInterface(NS_GET_IID(nsIDOMSelectionListener), (void **)aInstancePtrResult); + return newThang->QueryInterface(NS_GET_IID(nsISelectionListener), (void **)aInstancePtrResult); } diff --git a/mozilla/editor/base/nsInterfaceState.h b/mozilla/editor/base/nsInterfaceState.h index c50e6640205..190edea72d4 100644 --- a/mozilla/editor/base/nsInterfaceState.h +++ b/mozilla/editor/base/nsInterfaceState.h @@ -25,7 +25,7 @@ #define nsInterfaceState_h__ -#include "nsIDOMSelectionListener.h" +#include "nsISelectionListener.h" #include "nsIDocumentStateListener.h" #include "nsITransactionListener.h" #include "nsIWebShell.h" @@ -38,7 +38,7 @@ class nsIDOMDocument; // class responsible for communicating changes in local state back to the UI. // This is currently somewhat tied to a given XUL UI implementation -class nsInterfaceState : public nsIDOMSelectionListener, +class nsInterfaceState : public nsISelectionListener, public nsIDocumentStateListener, public nsITransactionListener, public nsITimerCallback @@ -56,8 +56,8 @@ public: // here to target certain things for updating. NS_IMETHOD ForceUpdate(const PRUnichar *tagToUpdate); - // nsIDOMSelectionListener interface - NS_IMETHOD NotifySelectionChanged(nsIDOMDocument *aDoc, nsIDOMSelection *aSel, short aReason); + // nsISelectionListener interface + NS_IMETHOD NotifySelectionChanged(nsIDOMDocument *aDoc, nsISelection *aSel, short aReason); NS_DECL_NSIDOCUMENTSTATELISTENER @@ -145,6 +145,6 @@ protected: }; -extern "C" nsresult NS_NewInterfaceState(nsIHTMLEditor* aEditor, nsIDOMDocument* aChromeDoc, nsIDOMSelectionListener** aInstancePtrResult); +extern "C" nsresult NS_NewInterfaceState(nsIHTMLEditor* aEditor, nsIDOMDocument* aChromeDoc, nsISelectionListener** aInstancePtrResult); #endif // nsInterfaceState_h__ diff --git a/mozilla/editor/base/nsTableEditor.cpp b/mozilla/editor/base/nsTableEditor.cpp index b0c1196b610..d66d820007e 100644 --- a/mozilla/editor/base/nsTableEditor.cpp +++ b/mozilla/editor/base/nsTableEditor.cpp @@ -30,7 +30,8 @@ #include "nsIDOMNode.h" #include "nsIDOMNodeList.h" #include "nsIDOMRange.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" +#include "nsISelectionPrivate.h" #include "nsLayoutCID.h" #include "nsIContent.h" #include "nsIContentIterator.h" @@ -87,11 +88,13 @@ class nsSetSelectionAfterTableEdit class nsSelectionBatcher { private: - nsCOMPtr mSelection; + nsCOMPtr mSelection; public: - nsSelectionBatcher(nsIDOMSelection *aSelection) : mSelection(aSelection) + nsSelectionBatcher(nsISelection *aSelection) { - if (mSelection) mSelection->StartBatchChanges(); + nsCOMPtr sel(aSelection); + mSelection = do_QueryInterface(sel); + if (mSelection) mSelection->StartBatchChanges(); } virtual ~nsSelectionBatcher() { @@ -366,7 +369,7 @@ nsHTMLEditor::GetNextRow(nsIDOMElement* aTableElement, nsIDOMElement* &aRow) NS_IMETHODIMP nsHTMLEditor::InsertTableColumn(PRInt32 aNumber, PRBool aAfter) { - nsCOMPtr selection; + nsCOMPtr selection; nsCOMPtr table; nsCOMPtr curCell; PRInt32 startRowIndex, startColIndex; @@ -484,7 +487,7 @@ nsHTMLEditor::InsertTableColumn(PRInt32 aNumber, PRBool aAfter) NS_IMETHODIMP nsHTMLEditor::InsertTableRow(PRInt32 aNumber, PRBool aAfter) { - nsCOMPtr selection; + nsCOMPtr selection; nsCOMPtr table; nsCOMPtr curCell; PRInt32 startRowIndex, startColIndex; @@ -636,7 +639,7 @@ nsHTMLEditor::InsertTableRow(PRInt32 aNumber, PRBool aAfter) // Editor helper only NS_IMETHODIMP -nsHTMLEditor::DeleteTable2(nsIDOMElement *aTable, nsIDOMSelection *aSelection) +nsHTMLEditor::DeleteTable2(nsIDOMElement *aTable, nsISelection *aSelection) { if (!aTable || !aSelection) return NS_ERROR_NULL_POINTER; @@ -661,7 +664,7 @@ nsHTMLEditor::DeleteTable2(nsIDOMElement *aTable, nsIDOMSelection *aSelection) NS_IMETHODIMP nsHTMLEditor::DeleteTable() { - nsCOMPtr selection; + nsCOMPtr selection; nsCOMPtr table; nsresult res = GetCellContext(getter_AddRefs(selection), getter_AddRefs(table), @@ -679,7 +682,7 @@ nsHTMLEditor::DeleteTable() NS_IMETHODIMP nsHTMLEditor::DeleteTableCell(PRInt32 aNumber) { - nsCOMPtr selection; + nsCOMPtr selection; nsCOMPtr table; nsCOMPtr cell; PRInt32 startRowIndex, startColIndex; @@ -862,7 +865,7 @@ nsHTMLEditor::DeleteTableCell(PRInt32 aNumber) NS_IMETHODIMP nsHTMLEditor::DeleteTableCellContents() { - nsCOMPtr selection; + nsCOMPtr selection; nsCOMPtr table; nsCOMPtr cell; PRInt32 startRowIndex, startColIndex; @@ -940,7 +943,7 @@ nsHTMLEditor::DeleteCellContents(nsIDOMElement *aCell) NS_IMETHODIMP nsHTMLEditor::DeleteTableColumn(PRInt32 aNumber) { - nsCOMPtr selection; + nsCOMPtr selection; nsCOMPtr table; nsCOMPtr cell; PRInt32 startRowIndex, startColIndex, rowCount, colCount; @@ -1086,7 +1089,7 @@ nsHTMLEditor::DeleteColumn(nsIDOMElement *aTable, PRInt32 aColIndex) if (rowCount == 1) { - nsCOMPtr selection; + nsCOMPtr selection; res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_FAILURE; @@ -1121,7 +1124,7 @@ nsHTMLEditor::DeleteColumn(nsIDOMElement *aTable, PRInt32 aColIndex) NS_IMETHODIMP nsHTMLEditor::DeleteTableRow(PRInt32 aNumber) { - nsCOMPtr selection; + nsCOMPtr selection; nsCOMPtr table; nsCOMPtr cell; PRInt32 startRowIndex, startColIndex; @@ -1370,7 +1373,7 @@ nsHTMLEditor::SelectBlockOfCells(nsIDOMElement *aStartCell, nsIDOMElement *aEndC { if (!aStartCell || !aEndCell) return NS_ERROR_NULL_POINTER; - nsCOMPtr selection; + nsCOMPtr selection; nsresult res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_FAILURE; @@ -1398,7 +1401,7 @@ nsHTMLEditor::SelectBlockOfCells(nsIDOMElement *aStartCell, nsIDOMElement *aEndC res = GetCellIndexes(aEndCell, endRowIndex, endColIndex); if(NS_FAILED(res)) return res; - // Suppress nsIDOMSelectionListener notification + // Suppress nsISelectionListener notification // until all selection changes are finished nsSelectionBatcher selectionBatcher(selection); @@ -1478,12 +1481,12 @@ nsHTMLEditor::SelectAllTableCells() res = GetTableSize(table, rowCount, colCount); if (NS_FAILED(res)) return res; - nsCOMPtr selection; + nsCOMPtr selection; res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_FAILURE; - // Suppress nsIDOMSelectionListener notification + // Suppress nsISelectionListener notification // until all selection changes are finished nsSelectionBatcher selectionBatcher(selection); @@ -1537,7 +1540,7 @@ nsHTMLEditor::SelectTableRow() if (!cellNode) return NS_ERROR_FAILURE; // Get table and location of cell: - nsCOMPtr selection; + nsCOMPtr selection; nsCOMPtr table; PRInt32 startRowIndex, startColIndex; @@ -1557,7 +1560,7 @@ nsHTMLEditor::SelectTableRow() // then call SelectBlockOfCells, but that would take just // a little less code, so the following is more efficient - // Suppress nsIDOMSelectionListener notification + // Suppress nsISelectionListener notification // until all selection changes are finished nsSelectionBatcher selectionBatcher(selection); @@ -1608,7 +1611,7 @@ nsHTMLEditor::SelectTableColumn() nsCOMPtr startCell = cell; // Get location of cell: - nsCOMPtr selection; + nsCOMPtr selection; nsCOMPtr table; PRInt32 startRowIndex, startColIndex; @@ -1624,7 +1627,7 @@ nsHTMLEditor::SelectTableColumn() res = GetTableSize(table, rowCount, colCount); if (NS_FAILED(res)) return res; - // Suppress nsIDOMSelectionListener notification + // Suppress nsISelectionListener notification // until all selection changes are finished nsSelectionBatcher selectionBatcher(selection); @@ -1913,7 +1916,7 @@ nsHTMLEditor::SwitchTableCellHeaderType(nsIDOMElement *aSourceCell, nsIDOMElemen // Save current selection to restore when done // This is needed so ReplaceContainer can monitor selection // when replacing nodes - nsCOMPtrselection; + nsCOMPtrselection; nsresult res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_FAILURE; @@ -2438,7 +2441,7 @@ nsHTMLEditor::FixBadColSpan(nsIDOMElement *aTable, PRInt32 aColIndex, PRInt32& a NS_IMETHODIMP nsHTMLEditor::NormalizeTable(nsIDOMElement *aTable) { - nsCOMPtrselection; + nsCOMPtrselection; nsresult res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_FAILURE; @@ -2697,7 +2700,7 @@ nsHTMLEditor::GetCellSpansAt(nsIDOMElement* aTable, PRInt32 aRowIndex, PRInt32 a } NS_IMETHODIMP -nsHTMLEditor::GetCellContext(nsIDOMSelection **aSelection, +nsHTMLEditor::GetCellContext(nsISelection **aSelection, nsIDOMElement **aTable, nsIDOMElement **aCell, nsIDOMNode **aCellParent, PRInt32 *aCellOffset, @@ -2712,7 +2715,7 @@ nsHTMLEditor::GetCellContext(nsIDOMSelection **aSelection, if (aRowIndex) *aRowIndex = 0; if (aColIndex) *aColIndex = 0; - nsCOMPtr selection; + nsCOMPtr selection; nsresult res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_FAILURE; @@ -2858,7 +2861,7 @@ nsHTMLEditor::GetFirstSelectedCell(nsIDOMElement **aCell, nsIDOMRange **aRange) *aCell = nsnull; if (aRange) *aRange = nsnull; - nsCOMPtr selection; + nsCOMPtr selection; nsresult res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_FAILURE; @@ -2898,7 +2901,7 @@ nsHTMLEditor::GetNextSelectedCell(nsIDOMElement **aCell, nsIDOMRange **aRange) *aCell = nsnull; if (aRange) *aRange = nsnull; - nsCOMPtr selection; + nsCOMPtr selection; nsresult res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_FAILURE; @@ -3013,7 +3016,7 @@ nsHTMLEditor::SetSelectionAfterTableEdit(nsIDOMElement* aTable, PRInt32 aRow, PR nsresult res = NS_ERROR_NOT_INITIALIZED; if (!aTable) return res; - nsCOMPtrselection; + nsCOMPtrselection; res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; @@ -3106,7 +3109,7 @@ nsHTMLEditor::GetSelectedOrParentTableElement(nsIDOMElement* &aTableElement, nsS aTagName.SetLength(0); aSelectedCount = 0; - nsCOMPtr selection; + nsCOMPtr selection; nsresult res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_FAILURE; diff --git a/mozilla/editor/base/nsTextEditRules.cpp b/mozilla/editor/base/nsTextEditRules.cpp index 9a5b223232a..f7e0cb9b1cb 100644 --- a/mozilla/editor/base/nsTextEditRules.cpp +++ b/mozilla/editor/base/nsTextEditRules.cpp @@ -29,7 +29,8 @@ #include "nsIDOMNode.h" #include "nsIDOMElement.h" #include "nsIDOMNodeList.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" +#include "nsISelectionPrivate.h" #include "nsIDOMRange.h" #include "nsIDOMCharacterData.h" #include "nsIContent.h" @@ -107,7 +108,7 @@ nsTextEditRules::Init(nsHTMLEditor *aEditor, PRUint32 aFlags) mEditor = aEditor; // we hold a non-refcounted reference back to our editor // call SetFlags only aftet mEditor has been initialized! SetFlags(aFlags); - nsCOMPtr selection; + nsCOMPtr selection; mEditor->GetSelection(getter_AddRefs(selection)); NS_ASSERTION(selection, "editor cannot get selection"); @@ -203,7 +204,7 @@ nsTextEditRules::AfterEdit(PRInt32 action, nsIEditor::EDirection aDirection) nsresult res = NS_OK; if (!--mActionNesting) { - nsCOMPtrselection; + nsCOMPtrselection; res = mEditor->GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; @@ -219,7 +220,7 @@ nsTextEditRules::AfterEdit(PRInt32 action, nsIEditor::EDirection aDirection) NS_IMETHODIMP -nsTextEditRules::WillDoAction(nsIDOMSelection *aSelection, +nsTextEditRules::WillDoAction(nsISelection *aSelection, nsRulesInfo *aInfo, PRBool *aCancel, PRBool *aHandled) @@ -273,7 +274,7 @@ nsTextEditRules::WillDoAction(nsIDOMSelection *aSelection, } NS_IMETHODIMP -nsTextEditRules::DidDoAction(nsIDOMSelection *aSelection, +nsTextEditRules::DidDoAction(nsISelection *aSelection, nsRulesInfo *aInfo, nsresult aResult) { // dont let any txns in here move the selection around behind our back. @@ -327,7 +328,7 @@ nsTextEditRules::DocumentIsEmpty(PRBool *aDocumentIsEmpty) nsresult -nsTextEditRules::WillInsert(nsIDOMSelection *aSelection, PRBool *aCancel) +nsTextEditRules::WillInsert(nsISelection *aSelection, PRBool *aCancel) { if (!aSelection || !aCancel) return NS_ERROR_NULL_POINTER; @@ -383,7 +384,7 @@ nsTextEditRules::WillInsert(nsIDOMSelection *aSelection, PRBool *aCancel) } nsresult -nsTextEditRules::DidInsert(nsIDOMSelection *aSelection, nsresult aResult) +nsTextEditRules::DidInsert(nsISelection *aSelection, nsresult aResult) { return NS_OK; } @@ -420,7 +421,7 @@ nsTextEditRules::GetTopEnclosingPre(nsIDOMNode *aNode, } nsresult -nsTextEditRules::WillInsertBreak(nsIDOMSelection *aSelection, PRBool *aCancel, PRBool *aHandled) +nsTextEditRules::WillInsertBreak(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled) { if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; } CANCEL_OPERATION_IF_READONLY_OR_DISABLED @@ -519,7 +520,7 @@ nsTextEditRules::WillInsertBreak(nsIDOMSelection *aSelection, PRBool *aCancel, P } nsresult -nsTextEditRules::DidInsertBreak(nsIDOMSelection *aSelection, nsresult aResult) +nsTextEditRules::DidInsertBreak(nsISelection *aSelection, nsresult aResult) { // we only need to execute the stuff below if we are a plaintext editor. // html editors have a different mechanism for putting in mozBR's @@ -543,6 +544,8 @@ nsTextEditRules::DidInsertBreak(nsIDOMSelection *aSelection, nsresult aResult) if (NS_FAILED(res)) return res; if (bIsLast) { + nsCOMPtr sel(aSelection); + nsCOMPtrselPrivate(do_QueryInterface(sel)); // need to insert special moz BR. Why? Because if we don't // the user will see no new line for the break. Also, things // like table cells won't grow in height. @@ -551,7 +554,7 @@ nsTextEditRules::DidInsertBreak(nsIDOMSelection *aSelection, nsresult aResult) if (NS_FAILED(res)) return res; res = nsEditor::GetNodeLocation(brNode, &selNode, &selOffset); if (NS_FAILED(res)) return res; - aSelection->SetHint(PR_TRUE); + selPrivate->SetInterlinePosition(PR_TRUE); res = aSelection->Collapse(selNode,selOffset); if (NS_FAILED(res)) return res; } @@ -562,7 +565,7 @@ nsTextEditRules::DidInsertBreak(nsIDOMSelection *aSelection, nsresult aResult) nsresult nsTextEditRules::WillInsertText(PRInt32 aAction, - nsIDOMSelection *aSelection, + nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled, const nsString *inString, @@ -800,7 +803,7 @@ nsTextEditRules::WillInsertText(PRInt32 aAction, } nsresult -nsTextEditRules::DidInsertText(nsIDOMSelection *aSelection, +nsTextEditRules::DidInsertText(nsISelection *aSelection, nsresult aResult) { return DidInsert(aSelection, aResult); @@ -809,7 +812,7 @@ nsTextEditRules::DidInsertText(nsIDOMSelection *aSelection, nsresult -nsTextEditRules::WillSetTextProperty(nsIDOMSelection *aSelection, PRBool *aCancel, PRBool *aHandled) +nsTextEditRules::WillSetTextProperty(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled) { if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; } @@ -823,13 +826,13 @@ nsTextEditRules::WillSetTextProperty(nsIDOMSelection *aSelection, PRBool *aCance } nsresult -nsTextEditRules::DidSetTextProperty(nsIDOMSelection *aSelection, nsresult aResult) +nsTextEditRules::DidSetTextProperty(nsISelection *aSelection, nsresult aResult) { return NS_OK; } nsresult -nsTextEditRules::WillRemoveTextProperty(nsIDOMSelection *aSelection, PRBool *aCancel, PRBool *aHandled) +nsTextEditRules::WillRemoveTextProperty(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled) { if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; } @@ -843,13 +846,13 @@ nsTextEditRules::WillRemoveTextProperty(nsIDOMSelection *aSelection, PRBool *aCa } nsresult -nsTextEditRules::DidRemoveTextProperty(nsIDOMSelection *aSelection, nsresult aResult) +nsTextEditRules::DidRemoveTextProperty(nsISelection *aSelection, nsresult aResult) { return NS_OK; } nsresult -nsTextEditRules::WillDeleteSelection(nsIDOMSelection *aSelection, +nsTextEditRules::WillDeleteSelection(nsISelection *aSelection, nsIEditor::EDirection aCollapsedAction, PRBool *aCancel, PRBool *aHandled) @@ -897,7 +900,7 @@ nsTextEditRules::WillDeleteSelection(nsIDOMSelection *aSelection, // if the document is empty, insert a bogus text node with a   // if we ended up with consecutive text nodes, merge them nsresult -nsTextEditRules::DidDeleteSelection(nsIDOMSelection *aSelection, +nsTextEditRules::DidDeleteSelection(nsISelection *aSelection, nsIEditor::EDirection aCollapsedAction, nsresult aResult) { @@ -992,7 +995,7 @@ nsTextEditRules::DidDeleteSelection(nsIDOMSelection *aSelection, } nsresult -nsTextEditRules::WillUndo(nsIDOMSelection *aSelection, PRBool *aCancel, PRBool *aHandled) +nsTextEditRules::WillUndo(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled) { if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; } CANCEL_OPERATION_IF_READONLY_OR_DISABLED @@ -1008,7 +1011,7 @@ nsTextEditRules::WillUndo(nsIDOMSelection *aSelection, PRBool *aCancel, PRBool * * Since undo and redo are relatively rare, it makes sense to take the (small) performance hit here. */ nsresult -nsTextEditRules:: DidUndo(nsIDOMSelection *aSelection, nsresult aResult) +nsTextEditRules:: DidUndo(nsISelection *aSelection, nsresult aResult) { nsresult res = aResult; // if aResult is an error, we return it. if (!aSelection) { return NS_ERROR_NULL_POINTER; } @@ -1035,7 +1038,7 @@ nsTextEditRules:: DidUndo(nsIDOMSelection *aSelection, nsresult aResult) } nsresult -nsTextEditRules::WillRedo(nsIDOMSelection *aSelection, PRBool *aCancel, PRBool *aHandled) +nsTextEditRules::WillRedo(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled) { if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; } CANCEL_OPERATION_IF_READONLY_OR_DISABLED @@ -1046,7 +1049,7 @@ nsTextEditRules::WillRedo(nsIDOMSelection *aSelection, PRBool *aCancel, PRBool * } nsresult -nsTextEditRules::DidRedo(nsIDOMSelection *aSelection, nsresult aResult) +nsTextEditRules::DidRedo(nsISelection *aSelection, nsresult aResult) { nsresult res = aResult; // if aResult is an error, we return it. if (!aSelection) { return NS_ERROR_NULL_POINTER; } @@ -1084,7 +1087,7 @@ nsTextEditRules::DidRedo(nsIDOMSelection *aSelection, nsresult aResult) } nsresult -nsTextEditRules::WillOutputText(nsIDOMSelection *aSelection, +nsTextEditRules::WillOutputText(nsISelection *aSelection, const nsString *aOutputFormat, nsString *aOutString, PRBool *aCancel, @@ -1115,7 +1118,7 @@ nsTextEditRules::WillOutputText(nsIDOMSelection *aSelection, } nsresult -nsTextEditRules::DidOutputText(nsIDOMSelection *aSelection, nsresult aResult) +nsTextEditRules::DidOutputText(nsISelection *aSelection, nsresult aResult) { return NS_OK; } @@ -1217,7 +1220,7 @@ nsTextEditRules::ReplaceNewlines(nsIDOMRange *aRange) nsresult -nsTextEditRules::CreateBogusNodeIfNeeded(nsIDOMSelection *aSelection) +nsTextEditRules::CreateBogusNodeIfNeeded(nsISelection *aSelection) { if (!aSelection) { return NS_ERROR_NULL_POINTER; } if (!mEditor) { return NS_ERROR_NULL_POINTER; } @@ -1280,7 +1283,7 @@ nsTextEditRules::CreateBogusNodeIfNeeded(nsIDOMSelection *aSelection) nsresult -nsTextEditRules::TruncateInsertionIfNeeded(nsIDOMSelection *aSelection, +nsTextEditRules::TruncateInsertionIfNeeded(nsISelection *aSelection, const nsString *aInString, nsString *aOutString, PRInt32 aMaxLength) @@ -1392,7 +1395,7 @@ nsTextEditRules::DeleteEmptyTextNode(nsIDOMNode *aNode) nsresult -nsTextEditRules::AdjustSelection(nsIDOMSelection *aSelection, nsIEditor::EDirection aDirection) +nsTextEditRules::AdjustSelection(nsISelection *aSelection, nsIEditor::EDirection aDirection) { if (!aSelection) return NS_ERROR_NULL_POINTER; @@ -1439,13 +1442,16 @@ nsTextEditRules::AdjustSelection(nsIDOMSelection *aSelection, nsIEditor::EDirect { if (!nextNode || mEditor->IsBlockNode(nextNode)) { + nsCOMPtr sel(aSelection); + nsCOMPtrselPrivate(do_QueryInterface(sel)); + nsCOMPtr brNode; res = CreateMozBR(selNode, selOffset, &brNode); if (NS_FAILED(res)) return res; res = nsEditor::GetNodeLocation(brNode, &selNode, &selOffset); if (NS_FAILED(res)) return res; // selection stays *before* moz-br, sticking to it - aSelection->SetHint(PR_TRUE); + selPrivate->SetInterlinePosition(PR_TRUE); res = aSelection->Collapse(selNode,selOffset); if (NS_FAILED(res)) return res; } diff --git a/mozilla/editor/base/nsTextEditRules.h b/mozilla/editor/base/nsTextEditRules.h index 9c3194b5d44..def80ad9dad 100644 --- a/mozilla/editor/base/nsTextEditRules.h +++ b/mozilla/editor/base/nsTextEditRules.h @@ -53,8 +53,8 @@ public: NS_IMETHOD Init(nsHTMLEditor *aEditor, PRUint32 aFlags); NS_IMETHOD BeforeEdit(PRInt32 action, nsIEditor::EDirection aDirection); NS_IMETHOD AfterEdit(PRInt32 action, nsIEditor::EDirection aDirection); - NS_IMETHOD WillDoAction(nsIDOMSelection *aSelection, nsRulesInfo *aInfo, PRBool *aCancel, PRBool *aHandled); - NS_IMETHOD DidDoAction(nsIDOMSelection *aSelection, nsRulesInfo *aInfo, nsresult aResult); + NS_IMETHOD WillDoAction(nsISelection *aSelection, nsRulesInfo *aInfo, PRBool *aCancel, PRBool *aHandled); + NS_IMETHOD DidDoAction(nsISelection *aSelection, nsRulesInfo *aInfo, nsresult aResult); NS_IMETHOD GetFlags(PRUint32 *aFlags); NS_IMETHOD SetFlags(PRUint32 aFlags); NS_IMETHOD DocumentIsEmpty(PRBool *aDocumentIsEmpty); @@ -89,40 +89,40 @@ protected: // nsTextEditRules implementation methods nsresult WillInsertText( PRInt32 aAction, - nsIDOMSelection *aSelection, + nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled, const nsString *inString, nsString *outString, PRInt32 aMaxLength); - nsresult DidInsertText(nsIDOMSelection *aSelection, nsresult aResult); + nsresult DidInsertText(nsISelection *aSelection, nsresult aResult); nsresult GetTopEnclosingPre(nsIDOMNode *aNode, nsIDOMNode** aOutPreNode); - nsresult WillInsertBreak(nsIDOMSelection *aSelection, PRBool *aCancel, PRBool *aHandled); - nsresult DidInsertBreak(nsIDOMSelection *aSelection, nsresult aResult); + nsresult WillInsertBreak(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled); + nsresult DidInsertBreak(nsISelection *aSelection, nsresult aResult); - nsresult WillInsert(nsIDOMSelection *aSelection, PRBool *aCancel); - nsresult DidInsert(nsIDOMSelection *aSelection, nsresult aResult); + nsresult WillInsert(nsISelection *aSelection, PRBool *aCancel); + nsresult DidInsert(nsISelection *aSelection, nsresult aResult); - nsresult WillDeleteSelection(nsIDOMSelection *aSelection, + nsresult WillDeleteSelection(nsISelection *aSelection, nsIEditor::EDirection aCollapsedAction, PRBool *aCancel, PRBool *aHandled); - nsresult DidDeleteSelection(nsIDOMSelection *aSelection, + nsresult DidDeleteSelection(nsISelection *aSelection, nsIEditor::EDirection aCollapsedAction, nsresult aResult); - nsresult WillSetTextProperty(nsIDOMSelection *aSelection, PRBool *aCancel, PRBool *aHandled); - nsresult DidSetTextProperty(nsIDOMSelection *aSelection, nsresult aResult); + nsresult WillSetTextProperty(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled); + nsresult DidSetTextProperty(nsISelection *aSelection, nsresult aResult); - nsresult WillRemoveTextProperty(nsIDOMSelection *aSelection, PRBool *aCancel, PRBool *aHandled); - nsresult DidRemoveTextProperty(nsIDOMSelection *aSelection, nsresult aResult); + nsresult WillRemoveTextProperty(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled); + nsresult DidRemoveTextProperty(nsISelection *aSelection, nsresult aResult); - nsresult WillUndo(nsIDOMSelection *aSelection, PRBool *aCancel, PRBool *aHandled); - nsresult DidUndo(nsIDOMSelection *aSelection, nsresult aResult); + nsresult WillUndo(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled); + nsresult DidUndo(nsISelection *aSelection, nsresult aResult); - nsresult WillRedo(nsIDOMSelection *aSelection, PRBool *aCancel, PRBool *aHandled); - nsresult DidRedo(nsIDOMSelection *aSelection, nsresult aResult); + nsresult WillRedo(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled); + nsresult DidRedo(nsISelection *aSelection, nsresult aResult); /** called prior to nsIEditor::OutputToString * @param aSelection @@ -131,13 +131,13 @@ protected: * @param aOutCancel if set to PR_TRUE, the caller should cancel the operation * and use aOutText as the result. */ - nsresult WillOutputText(nsIDOMSelection *aSelection, + nsresult WillOutputText(nsISelection *aSelection, const nsString *aInFormat, nsString *aOutText, PRBool *aOutCancel, PRBool *aHandled); - nsresult DidOutputText(nsIDOMSelection *aSelection, nsresult aResult); + nsresult DidOutputText(nsISelection *aSelection, nsresult aResult); // helper functions @@ -146,11 +146,11 @@ protected: nsresult ReplaceNewlines(nsIDOMRange *aRange); /** creates a bogus text node if the document has no editable content */ - nsresult CreateBogusNodeIfNeeded(nsIDOMSelection *aSelection); + nsresult CreateBogusNodeIfNeeded(nsISelection *aSelection); /** returns a truncated insertion string if insertion would place us over aMaxLength */ - nsresult TruncateInsertionIfNeeded(nsIDOMSelection *aSelection, + nsresult TruncateInsertionIfNeeded(nsISelection *aSelection, const nsString *aInString, nsString *aOutString, PRInt32 aMaxLength); @@ -163,7 +163,7 @@ protected: PRBool DeleteEmptyTextNode(nsIDOMNode *aNode); - nsresult AdjustSelection(nsIDOMSelection *aSelection, nsIEditor::EDirection aDirection); + nsresult AdjustSelection(nsISelection *aSelection, nsIEditor::EDirection aDirection); // data members nsHTMLEditor *mEditor; // note that we do not refcount the editor diff --git a/mozilla/editor/composer/src/nsComposerCommands.cpp b/mozilla/editor/composer/src/nsComposerCommands.cpp index ffb13cfff54..7b446cb6f96 100644 --- a/mozilla/editor/composer/src/nsComposerCommands.cpp +++ b/mozilla/editor/composer/src/nsComposerCommands.cpp @@ -28,7 +28,7 @@ #include "nsIEditorShell.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIDOMNode.h" #include "nsIDOMElement.h" #include "nsIDOMWindowInternal.h" @@ -231,7 +231,11 @@ nsPrintingCommands::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * re *outCmdEnabled = PR_FALSE; // not implemented yet else if (cmdString.EqualsWithConversion("cmd_printPreview")) *outCmdEnabled = PR_FALSE; // not implemented yet - + else if (cmdString.EqualsWithConversion("cmd_print_button")) + *outCmdEnabled = PR_TRUE; + else if (cmdString.EqualsWithConversion("cmd_printSetup")) + *outCmdEnabled = PR_FALSE; // not implemented yet + return NS_OK; } diff --git a/mozilla/editor/composer/src/nsEditorShell.cpp b/mozilla/editor/composer/src/nsEditorShell.cpp index 881bdcf076b..d211b36a1fe 100644 --- a/mozilla/editor/composer/src/nsEditorShell.cpp +++ b/mozilla/editor/composer/src/nsEditorShell.cpp @@ -69,7 +69,8 @@ #include "nsIDOMHTMLImageElement.h" #include "nsIPresShell.h" #include "nsIPresContext.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" +#include "nsISelectionPrivate.h" #include "nsIFileWidget.h" #include "nsFileSpec.h" @@ -386,12 +387,13 @@ nsEditorShell::ResetEditingState() // now, unregister the selection listener, if there was one if (mStateMaintainer) { - nsCOMPtr domSelection; + nsCOMPtr domSelection; // using a scoped result, because we don't really care if this fails rv = GetEditorSelection(getter_AddRefs(domSelection)); if (NS_SUCCEEDED(rv) && domSelection) { - domSelection->RemoveSelectionListener(mStateMaintainer); + nsCOMPtr selPriv(do_QueryInterface(domSelection)); + selPriv->RemoveSelectionListener(mStateMaintainer); NS_IF_RELEASE(mStateMaintainer); } } @@ -483,11 +485,12 @@ nsEditorShell::PrepareDocumentForEditing(nsIDocumentLoader* aLoader, nsIURI *aUr if (NS_FAILED(rv)) return rv; // set it up as a selection listener - nsCOMPtr domSelection; + nsCOMPtr domSelection; rv = GetEditorSelection(getter_AddRefs(domSelection)); if (NS_FAILED(rv)) return rv; - rv = domSelection->AddSelectionListener(mStateMaintainer); + nsCOMPtr selPriv(do_QueryInterface(domSelection)); + rv = selPriv->AddSelectionListener(mStateMaintainer); if (NS_FAILED(rv)) return rv; // and set it up as a doc state listener @@ -2566,7 +2569,7 @@ nsEditorShell::Rewrap(PRBool aRespectNewlines) printf("nsEditorShell::Rewrap to %ld columns\n", (long)wrapCol); #endif - nsCOMPtr selection; + nsCOMPtr selection; rv = GetEditorSelection(getter_AddRefs(selection)); if (NS_FAILED(rv)) return rv; @@ -2630,7 +2633,7 @@ nsEditorShell::StripCites() printf("nsEditorShell::StripCites()\n"); #endif - nsCOMPtr selection; + nsCOMPtr selection; nsresult rv = GetEditorSelection(getter_AddRefs(selection)); if (NS_FAILED(rv)) return rv; @@ -3328,7 +3331,7 @@ nsEditorShell::GetEditor(nsIEditor** aEditor) NS_IMETHODIMP -nsEditorShell::GetEditorSelection(nsIDOMSelection** aEditorSelection) +nsEditorShell::GetEditorSelection(nsISelection** aEditorSelection) { nsCOMPtr editor = do_QueryInterface(mEditor); if (editor) diff --git a/mozilla/editor/composer/src/nsEditorShell.h b/mozilla/editor/composer/src/nsEditorShell.h index 3ded2d7d89e..6766d5d7c7c 100644 --- a/mozilla/editor/composer/src/nsEditorShell.h +++ b/mozilla/editor/composer/src/nsEditorShell.h @@ -33,7 +33,7 @@ #include "nsIEditorShell.h" #include "nsIEditorController.h" #include "nsIDocumentLoaderObserver.h" -#include "nsIDOMSelectionListener.h" +#include "nsISelectionListener.h" #include "nsIDOMEventReceiver.h" #include "nsIPrompt.h" #include "nsIStreamObserver.h" diff --git a/mozilla/editor/composer/src/nsEditorShellMouseListener.cpp b/mozilla/editor/composer/src/nsEditorShellMouseListener.cpp index a9a00efb73e..779b9cb96de 100644 --- a/mozilla/editor/composer/src/nsEditorShellMouseListener.cpp +++ b/mozilla/editor/composer/src/nsEditorShellMouseListener.cpp @@ -30,7 +30,7 @@ #include "nsIDOMElement.h" #include "nsIDOMCharacterData.h" #include "nsIDOMMouseEvent.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIDOMRange.h" #include "nsIDOMNSRange.h" #include "nsIDOMEventTarget.h" @@ -208,7 +208,7 @@ nsEditorShellMouseListener::MouseDown(nsIDOMEvent* aMouseEvent) res = mouseEvent->GetDetail(&clickCount); if (NS_FAILED(res)) return res; - nsCOMPtr selection; + nsCOMPtr selection; mEditorShell->GetEditorSelection(getter_AddRefs(selection)); if (!selection) return NS_OK; diff --git a/mozilla/editor/composer/src/nsInterfaceState.cpp b/mozilla/editor/composer/src/nsInterfaceState.cpp index 3e4055e2423..1e36dc29103 100644 --- a/mozilla/editor/composer/src/nsInterfaceState.cpp +++ b/mozilla/editor/composer/src/nsInterfaceState.cpp @@ -32,7 +32,7 @@ #include "nsIDOMDocument.h" #include "nsIDiskDocument.h" #include "nsIDOMElement.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIDOMAttr.h" #include "nsIScriptGlobalObject.h" #include "nsIDOMWindowInternal.h" @@ -97,7 +97,7 @@ nsInterfaceState::~nsInterfaceState() NS_IMPL_ADDREF(nsInterfaceState); NS_IMPL_RELEASE(nsInterfaceState); -NS_IMPL_QUERY_INTERFACE4(nsInterfaceState, nsIDOMSelectionListener, nsIDocumentStateListener, nsITransactionListener, nsITimerCallback); +NS_IMPL_QUERY_INTERFACE4(nsInterfaceState, nsISelectionListener, nsIDocumentStateListener, nsITransactionListener, nsITimerCallback); NS_IMETHODIMP nsInterfaceState::Init(nsIHTMLEditor* aEditor, nsIDOMDocument *aChromeDoc) @@ -149,7 +149,7 @@ nsInterfaceState::NotifyDocumentStateChanged(PRBool aNowDirty) } NS_IMETHODIMP -nsInterfaceState::NotifySelectionChanged(nsIDOMDocument *, nsIDOMSelection *, short) +nsInterfaceState::NotifySelectionChanged(nsIDOMDocument *, nsISelection *, short) { return PrimeUpdateTimer(); } @@ -383,7 +383,7 @@ nsInterfaceState::SelectionIsCollapsed() nsCOMPtr editor = do_QueryInterface(mEditor, &rv); if (NS_SUCCEEDED(rv)) { - nsCOMPtr domSelection; + nsCOMPtr domSelection; rv = editor->GetSelection(getter_AddRefs(domSelection)); if (NS_SUCCEEDED(rv)) { @@ -398,7 +398,7 @@ nsInterfaceState::SelectionIsCollapsed() nsresult nsInterfaceState::UpdateParagraphState(const char* observerName, const char* attributeName) { - nsCOMPtr domSelection; + nsCOMPtr domSelection; nsCOMPtr editor = do_QueryInterface(mEditor); // Get the nsIEditor pointer (mEditor is nsIHTMLEditor) if (!editor) return NS_ERROR_NULL_POINTER; @@ -664,7 +664,7 @@ nsInterfaceState::Notify(nsITimer *timer) #endif -nsresult NS_NewInterfaceState(nsIHTMLEditor* aEditor, nsIDOMDocument* aChromeDoc, nsIDOMSelectionListener** aInstancePtrResult) +nsresult NS_NewInterfaceState(nsIHTMLEditor* aEditor, nsIDOMDocument* aChromeDoc, nsISelectionListener** aInstancePtrResult) { nsInterfaceState* newThang = new nsInterfaceState; if (!newThang) @@ -678,5 +678,5 @@ nsresult NS_NewInterfaceState(nsIHTMLEditor* aEditor, nsIDOMDocument* aChromeDoc return rv; } - return newThang->QueryInterface(NS_GET_IID(nsIDOMSelectionListener), (void **)aInstancePtrResult); + return newThang->QueryInterface(NS_GET_IID(nsISelectionListener), (void **)aInstancePtrResult); } diff --git a/mozilla/editor/composer/src/nsInterfaceState.h b/mozilla/editor/composer/src/nsInterfaceState.h index c50e6640205..190edea72d4 100644 --- a/mozilla/editor/composer/src/nsInterfaceState.h +++ b/mozilla/editor/composer/src/nsInterfaceState.h @@ -25,7 +25,7 @@ #define nsInterfaceState_h__ -#include "nsIDOMSelectionListener.h" +#include "nsISelectionListener.h" #include "nsIDocumentStateListener.h" #include "nsITransactionListener.h" #include "nsIWebShell.h" @@ -38,7 +38,7 @@ class nsIDOMDocument; // class responsible for communicating changes in local state back to the UI. // This is currently somewhat tied to a given XUL UI implementation -class nsInterfaceState : public nsIDOMSelectionListener, +class nsInterfaceState : public nsISelectionListener, public nsIDocumentStateListener, public nsITransactionListener, public nsITimerCallback @@ -56,8 +56,8 @@ public: // here to target certain things for updating. NS_IMETHOD ForceUpdate(const PRUnichar *tagToUpdate); - // nsIDOMSelectionListener interface - NS_IMETHOD NotifySelectionChanged(nsIDOMDocument *aDoc, nsIDOMSelection *aSel, short aReason); + // nsISelectionListener interface + NS_IMETHOD NotifySelectionChanged(nsIDOMDocument *aDoc, nsISelection *aSel, short aReason); NS_DECL_NSIDOCUMENTSTATELISTENER @@ -145,6 +145,6 @@ protected: }; -extern "C" nsresult NS_NewInterfaceState(nsIHTMLEditor* aEditor, nsIDOMDocument* aChromeDoc, nsIDOMSelectionListener** aInstancePtrResult); +extern "C" nsresult NS_NewInterfaceState(nsIHTMLEditor* aEditor, nsIDOMDocument* aChromeDoc, nsISelectionListener** aInstancePtrResult); #endif // nsInterfaceState_h__ diff --git a/mozilla/editor/idl/nsIEditorShell.idl b/mozilla/editor/idl/nsIEditorShell.idl index c991095fd22..1f9a3520eaf 100644 --- a/mozilla/editor/idl/nsIEditorShell.idl +++ b/mozilla/editor/idl/nsIEditorShell.idl @@ -31,7 +31,7 @@ class nsIDOMWindowInternal; class nsIDOMDocument; -class nsIDOMSelection; +class nsISelection; class nsIDOMElement; class nsIDOMNode; @@ -44,7 +44,7 @@ interface nsIEditor; interface nsIEditorShell : nsISupports { readonly attribute nsIDOMDocument editorDocument; - readonly attribute nsIDOMSelection editorSelection; + readonly attribute nsISelection editorSelection; readonly attribute nsISelectionController selectionController; attribute nsIDOMWindowInternal webShellWindow; diff --git a/mozilla/editor/libeditor/base/CreateElementTxn.cpp b/mozilla/editor/libeditor/base/CreateElementTxn.cpp index b0442a7ab70..e7080bd959c 100644 --- a/mozilla/editor/libeditor/base/CreateElementTxn.cpp +++ b/mozilla/editor/libeditor/base/CreateElementTxn.cpp @@ -24,7 +24,7 @@ #include "nsEditor.h" #include "nsIDOMDocument.h" #include "nsIDOMNodeList.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIDOMText.h" #include "nsIDOMElement.h" @@ -149,7 +149,7 @@ NS_IMETHODIMP CreateElementTxn::Do(void) mEditor->ShouldTxnSetSelection(&bAdjustSelection); if (bAdjustSelection) { - nsCOMPtr selection; + nsCOMPtr selection; result = mEditor->GetSelection(getter_AddRefs(selection)); if (NS_FAILED(result)) return result; if (!selection) return NS_ERROR_NULL_POINTER; diff --git a/mozilla/editor/libeditor/base/DeleteRangeTxn.cpp b/mozilla/editor/libeditor/base/DeleteRangeTxn.cpp index 3c6eb9895e5..1e3299d1b69 100644 --- a/mozilla/editor/libeditor/base/DeleteRangeTxn.cpp +++ b/mozilla/editor/libeditor/base/DeleteRangeTxn.cpp @@ -25,7 +25,7 @@ #include "nsIDOMRange.h" #include "nsIDOMCharacterData.h" #include "nsIDOMNodeList.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "DeleteTextTxn.h" #include "DeleteElementTxn.h" #include "TransactionFactory.h" @@ -153,7 +153,7 @@ NS_IMETHODIMP DeleteRangeTxn::Do(void) mEditor->ShouldTxnSetSelection(&bAdjustSelection); if (bAdjustSelection) { - nsCOMPtr selection; + nsCOMPtr selection; result = mEditor->GetSelection(getter_AddRefs(selection)); if (NS_FAILED(result)) return result; if (!selection) return NS_ERROR_NULL_POINTER; diff --git a/mozilla/editor/libeditor/base/DeleteTextTxn.cpp b/mozilla/editor/libeditor/base/DeleteTextTxn.cpp index dffb70c8393..88db0665f0f 100644 --- a/mozilla/editor/libeditor/base/DeleteTextTxn.cpp +++ b/mozilla/editor/libeditor/base/DeleteTextTxn.cpp @@ -22,7 +22,7 @@ #include "DeleteTextTxn.h" #include "nsIDOMCharacterData.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #ifdef NS_DEBUG static PRBool gNoisy = PR_FALSE; @@ -78,7 +78,7 @@ NS_IMETHODIMP DeleteTextTxn::Do(void) mEditor->ShouldTxnSetSelection(&bAdjustSelection); if (bAdjustSelection) { - nsCOMPtr selection; + nsCOMPtr selection; result = mEditor->GetSelection(getter_AddRefs(selection)); if (NS_FAILED(result)) return result; if (!selection) return NS_ERROR_NULL_POINTER; diff --git a/mozilla/editor/libeditor/base/IMETextTxn.cpp b/mozilla/editor/libeditor/base/IMETextTxn.cpp index 0736c822fcf..95aa41bd6f5 100644 --- a/mozilla/editor/libeditor/base/IMETextTxn.cpp +++ b/mozilla/editor/libeditor/base/IMETextTxn.cpp @@ -25,7 +25,8 @@ #include "nsEditor.h" #include "nsIDOMCharacterData.h" #include "nsIPrivateTextRange.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" +#include "nsISelectionPrivate.h" #include "nsIPresShell.h" #include "EditAggregateTxn.h" #include "nsLayoutCID.h" @@ -33,7 +34,7 @@ // #define DEBUG_IMETXN static NS_DEFINE_IID(kRangeCID, NS_RANGE_CID); -static NS_DEFINE_IID(kIDOMSelectionIID, NS_IDOMSELECTION_IID); +static NS_DEFINE_IID(kIDOMSelectionIID, NS_ISELECTION_IID); nsIAtom *IMETextTxn::gIMETextTxnName = nsnull; @@ -121,7 +122,7 @@ NS_IMETHODIMP IMETextTxn::Undo(void) result = mElement->DeleteData(mOffset, length); if (NS_SUCCEEDED(result)) { // set the selection to the insertion point where the string was removed - nsCOMPtr selection; + nsCOMPtr selection; result = selCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection)); if (NS_SUCCEEDED(result) && selection) { result = selection->Collapse(mElement, mOffset); @@ -321,12 +322,13 @@ NS_IMETHODIMP IMETextTxn::CollapseTextSelection(void) result = mRangeList->GetLength(&textRangeListLength); if(NS_FAILED(result)) return result; - nsCOMPtr selection; + nsCOMPtr selection; result = selCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection)); - nsCOMPtr imeSel; + nsCOMPtr imeSel; if(NS_SUCCEEDED(result)) { - result = selection->StartBatchChanges(); + nsCOMPtr selPriv(do_QueryInterface(selection)); + result = selPriv->StartBatchChanges(); if (NS_SUCCEEDED(result)) { for(PRInt8 selIdx = 0; selIdx < 4;selIdx++) @@ -334,7 +336,7 @@ NS_IMETHODIMP IMETextTxn::CollapseTextSelection(void) result = selCon->GetSelection(sel[selIdx], getter_AddRefs(imeSel)); if(NS_SUCCEEDED(result)) { - result = imeSel->ClearSelection(); + result = imeSel->RemoveAllRanges(); NS_ASSERTION(NS_SUCCEEDED(result), "Cannot ClearSelection"); // we just ignore the result and clean up the next one here } @@ -412,7 +414,7 @@ NS_IMETHODIMP IMETextTxn::CollapseTextSelection(void) result = selection->Collapse(mElement,mOffset+mStringToInsert.Length()); NS_ASSERTION(NS_SUCCEEDED(result), "Cannot Collapse"); } - result = selection->EndBatchChanges(); + result = selPriv->EndBatchChanges(); NS_ASSERTION(NS_SUCCEEDED(result), "Cannot EndBatchChanges"); } // if StartBatchChanges } // if GetSelection diff --git a/mozilla/editor/libeditor/base/InsertElementTxn.cpp b/mozilla/editor/libeditor/base/InsertElementTxn.cpp index 010153516f7..fb6797fbac6 100644 --- a/mozilla/editor/libeditor/base/InsertElementTxn.cpp +++ b/mozilla/editor/libeditor/base/InsertElementTxn.cpp @@ -21,7 +21,7 @@ */ #include "InsertElementTxn.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIContent.h" #include "nsIDOMNodeList.h" @@ -105,7 +105,7 @@ NS_IMETHODIMP InsertElementTxn::Do(void) mEditor->ShouldTxnSetSelection(&bAdjustSelection); if (bAdjustSelection) { - nsCOMPtr selection; + nsCOMPtr selection; result = mEditor->GetSelection(getter_AddRefs(selection)); if (NS_FAILED(result)) return result; if (!selection) return NS_ERROR_NULL_POINTER; diff --git a/mozilla/editor/libeditor/base/InsertTextTxn.cpp b/mozilla/editor/libeditor/base/InsertTextTxn.cpp index 1a60556dcff..921bfe3dec7 100644 --- a/mozilla/editor/libeditor/base/InsertTextTxn.cpp +++ b/mozilla/editor/libeditor/base/InsertTextTxn.cpp @@ -23,10 +23,10 @@ #include "InsertTextTxn.h" #include "nsEditor.h" #include "nsIDOMCharacterData.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "EditAggregateTxn.h" -static NS_DEFINE_IID(kIDOMSelectionIID, NS_IDOMSELECTION_IID); +static NS_DEFINE_IID(kIDOMSelectionIID, NS_ISELECTION_IID); #ifdef NS_DEBUG static PRBool gNoisy = PR_FALSE; @@ -97,7 +97,7 @@ NS_IMETHODIMP InsertTextTxn::Do(void) mEditor->ShouldTxnSetSelection(&bAdjustSelection); if (bAdjustSelection) { - nsCOMPtr selection; + nsCOMPtr selection; result = mEditor->GetSelection(getter_AddRefs(selection)); if (NS_FAILED(result)) return result; if (!selection) return NS_ERROR_NULL_POINTER; diff --git a/mozilla/editor/libeditor/base/PlaceholderTxn.cpp b/mozilla/editor/libeditor/base/PlaceholderTxn.cpp index 55a8a4916a3..5a1df3492b3 100644 --- a/mozilla/editor/libeditor/base/PlaceholderTxn.cpp +++ b/mozilla/editor/libeditor/base/PlaceholderTxn.cpp @@ -97,7 +97,7 @@ NS_IMETHODIMP PlaceholderTxn::Undo(void) if (NS_FAILED(res)) return res; // now restore selection - nsCOMPtr selection; + nsCOMPtr selection; res = mEditor->GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_NULL_POINTER; @@ -114,7 +114,7 @@ NS_IMETHODIMP PlaceholderTxn::Redo(void) if (NS_FAILED(res)) return res; // now restore selection - nsCOMPtr selection; + nsCOMPtr selection; res = mEditor->GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_NULL_POINTER; @@ -265,7 +265,7 @@ NS_IMETHODIMP PlaceholderTxn::Commit() NS_IMETHODIMP PlaceholderTxn::RememberEndingSelection() { - nsCOMPtr selection; + nsCOMPtr selection; nsresult res = mEditor->GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_NULL_POINTER; diff --git a/mozilla/editor/libeditor/base/SplitElementTxn.cpp b/mozilla/editor/libeditor/base/SplitElementTxn.cpp index 55bb8c3eee0..e742f526ec6 100644 --- a/mozilla/editor/libeditor/base/SplitElementTxn.cpp +++ b/mozilla/editor/libeditor/base/SplitElementTxn.cpp @@ -23,7 +23,7 @@ #include "SplitElementTxn.h" #include "nsEditor.h" #include "nsIDOMNode.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIDOMCharacterData.h" #ifdef NS_DEBUG @@ -82,7 +82,7 @@ NS_IMETHODIMP SplitElementTxn::Do(void) result = mEditor->SplitNodeImpl(mExistingRightNode, mOffset, mNewLeftNode, mParent); if (NS_SUCCEEDED(result) && mNewLeftNode) { - nsCOMPtrselection; + nsCOMPtrselection; mEditor->GetSelection(getter_AddRefs(selection)); if (NS_FAILED(result)) return result; if (!selection) return NS_ERROR_NULL_POINTER; diff --git a/mozilla/editor/libeditor/base/nsEditRules.h b/mozilla/editor/libeditor/base/nsEditRules.h index 0279e977908..2af710fd2dc 100644 --- a/mozilla/editor/libeditor/base/nsEditRules.h +++ b/mozilla/editor/libeditor/base/nsEditRules.h @@ -29,7 +29,7 @@ {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} } class nsHTMLEditor; -class nsIDOMSelection; +class nsISelection; /*************************************************************************** * base for an object to encapsulate any additional info needed to be passed @@ -60,8 +60,8 @@ public: NS_IMETHOD Init(nsHTMLEditor *aEditor, PRUint32 aFlags)=0; NS_IMETHOD BeforeEdit(PRInt32 action, nsIEditor::EDirection aDirection)=0; NS_IMETHOD AfterEdit(PRInt32 action, nsIEditor::EDirection aDirection)=0; - NS_IMETHOD WillDoAction(nsIDOMSelection *aSelection, nsRulesInfo *aInfo, PRBool *aCancel, PRBool *aHandled)=0; - NS_IMETHOD DidDoAction(nsIDOMSelection *aSelection, nsRulesInfo *aInfo, nsresult aResult)=0; + NS_IMETHOD WillDoAction(nsISelection *aSelection, nsRulesInfo *aInfo, PRBool *aCancel, PRBool *aHandled)=0; + NS_IMETHOD DidDoAction(nsISelection *aSelection, nsRulesInfo *aInfo, nsresult aResult)=0; NS_IMETHOD GetFlags(PRUint32 *aFlags)=0; NS_IMETHOD SetFlags(PRUint32 aFlags)=0; NS_IMETHOD DocumentIsEmpty(PRBool *aDocumentIsEmpty)=0; diff --git a/mozilla/editor/libeditor/base/nsEditor.cpp b/mozilla/editor/libeditor/base/nsEditor.cpp index f51a75e3da8..b0157e8235c 100644 --- a/mozilla/editor/libeditor/base/nsEditor.cpp +++ b/mozilla/editor/libeditor/base/nsEditor.cpp @@ -47,7 +47,8 @@ #include "nsIPresShell.h" #include "nsIPresContext.h" #include "nsIViewManager.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" +#include "nsISelectionPrivate.h" #include "nsIEnumerator.h" #include "nsIAtom.h" #include "nsISupportsArray.h" @@ -160,7 +161,7 @@ nsSelectionState::~nsSelectionState() } nsresult -nsSelectionState::SaveSelection(nsIDOMSelection *aSel) +nsSelectionState::SaveSelection(nsISelection *aSel) { if (!aSel) return NS_ERROR_NULL_POINTER; nsresult res = NS_OK; @@ -203,7 +204,7 @@ nsSelectionState::SaveSelection(nsIDOMSelection *aSel) } nsresult -nsSelectionState::RestoreSelection(nsIDOMSelection *aSel) +nsSelectionState::RestoreSelection(nsISelection *aSel) { if (!aSel) return NS_ERROR_NULL_POINTER; nsresult res = NS_OK; @@ -211,7 +212,7 @@ nsSelectionState::RestoreSelection(nsIDOMSelection *aSel) nsRangeStore *item; // clear out selection - aSel->ClearSelection(); + aSel->RemoveAllRanges(); // set the selection ranges anew for (i=0; iselection; + nsCOMPtrselection; result = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(result)) { return result; } if (!selection) { return NS_ERROR_NULL_POINTER; } + nsCOMPtrselPrivate(do_QueryInterface(selection)); - selection->StartBatchChanges(); + selPrivate->StartBatchChanges(); if (mTxnMgr) { result = mTxnMgr->Do(aTxn); } @@ -1155,7 +1157,7 @@ nsEditor::Do(nsITransaction *aTxn) result = DoAfterDoTransaction(aTxn); } - selection->EndBatchChanges(); // no need to check result here, don't lose result of operation + selPrivate->EndBatchChanges(); // no need to check result here, don't lose result of operation } NS_POSTCONDITION((NS_SUCCEEDED(result)), "transaction did not execute properly\n"); @@ -1343,7 +1345,7 @@ nsEditor::BeginPlaceHolderTransaction(nsIAtom *aName) BeginUpdateViewBatch(); mPlaceHolderTxn = nsnull; mPlaceHolderName = aName; - nsCOMPtr selection; + nsCOMPtr selection; nsresult res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; mSelState = new nsSelectionState(); @@ -1410,7 +1412,7 @@ NS_IMETHODIMP nsEditor::SelectAll() if (!mDocWeak || !mPresShellWeak) { return NS_ERROR_NOT_INITIALIZED; } ForceCompositionEnd(); - nsCOMPtr selection; + nsCOMPtr selection; nsCOMPtr selCon = do_QueryReferent(mSelConWeak); if (!selCon) return NS_ERROR_NOT_INITIALIZED; nsresult result = selCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection)); @@ -1425,7 +1427,7 @@ NS_IMETHODIMP nsEditor::BeginningOfDocument() { if (!mDocWeak || !mPresShellWeak) { return NS_ERROR_NOT_INITIALIZED; } - nsCOMPtr selection; + nsCOMPtr selection; if (!mPresShellWeak) return NS_ERROR_NOT_INITIALIZED; nsCOMPtr selCon = do_QueryReferent(mSelConWeak); if (!selCon) return NS_ERROR_NOT_INITIALIZED; @@ -1487,7 +1489,7 @@ nsEditor::EndOfDocument() nsresult res; // get selection - nsCOMPtr selection; + nsCOMPtr selection; res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_NULL_POINTER; @@ -2385,7 +2387,7 @@ nsEditor::ArePreservingSelection() } nsresult -nsEditor::PreserveSelectionAcrossActions(nsIDOMSelection *aSel) +nsEditor::PreserveSelectionAcrossActions(nsISelection *aSel) { mSavedSel.SaveSelection(aSel); mRangeUpdater.RegisterSelectionState(mSavedSel); @@ -2393,7 +2395,7 @@ nsEditor::PreserveSelectionAcrossActions(nsIDOMSelection *aSel) } nsresult -nsEditor::RestorePreservedSelection(nsIDOMSelection *aSel) +nsEditor::RestorePreservedSelection(nsISelection *aSel) { if (mSavedSel.IsEmpty()) return NS_ERROR_FAILURE; mSavedSel.RestoreSelection(aSel); @@ -2422,7 +2424,7 @@ NS_IMETHODIMP nsEditor::QueryComposition(nsTextEventReply* aReply) { nsresult result; - nsCOMPtr selection; + nsCOMPtr selection; nsCOMPtr selcon = do_QueryReferent(mSelConWeak); if (selcon) selcon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection)); @@ -2980,7 +2982,7 @@ NS_IMETHODIMP nsEditor::InsertTextIntoTextNodeImpl(const nsString& aStringToInse } -NS_IMETHODIMP nsEditor::SelectEntireDocument(nsIDOMSelection *aSelection) +NS_IMETHODIMP nsEditor::SelectEntireDocument(nsISelection *aSelection) { nsresult result; if (!aSelection) { return NS_ERROR_NULL_POINTER; } @@ -3256,7 +3258,7 @@ nsEditor::SplitNodeImpl(nsIDOMNode * aExistingRightNode, (nsnull!=aParent)) { // get selection - nsCOMPtr selection; + nsCOMPtr selection; result = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(result)) return result; if (!selection) return NS_ERROR_NULL_POINTER; @@ -3374,7 +3376,7 @@ nsEditor::JoinNodesImpl(nsIDOMNode * aNodeToKeep, if (aNodeToKeep && aNodeToJoin && aParent) { // get selection - nsCOMPtr selection; + nsCOMPtr selection; GetSelection(getter_AddRefs(selection)); if (NS_FAILED(result)) return result; if (!selection) return NS_ERROR_NULL_POINTER; @@ -4866,7 +4868,7 @@ nsEditor::NextNodeInBlock(nsIDOMNode *aNode, IterDirection aDir) // GetStartNodeAndOffset: returns whatever the start parent & offset is of // the first range in the selection. nsresult -nsEditor::GetStartNodeAndOffset(nsIDOMSelection *aSelection, +nsEditor::GetStartNodeAndOffset(nsISelection *aSelection, nsCOMPtr *outStartNode, PRInt32 *outStartOffset) { @@ -4875,7 +4877,9 @@ nsEditor::GetStartNodeAndOffset(nsIDOMSelection *aSelection, nsCOMPtr enumerator; nsresult result; - result = aSelection->GetEnumerator(getter_AddRefs(enumerator)); + nsCOMPtr sel(aSelection); + nsCOMPtrselPrivate(do_QueryInterface(sel)); + result = selPrivate->GetEnumerator(getter_AddRefs(enumerator)); if (NS_FAILED(result) || !enumerator) return NS_ERROR_FAILURE; @@ -4902,7 +4906,7 @@ nsEditor::GetStartNodeAndOffset(nsIDOMSelection *aSelection, // GetEndNodeAndOffset: returns whatever the end parent & offset is of // the first range in the selection. nsresult -nsEditor::GetEndNodeAndOffset(nsIDOMSelection *aSelection, +nsEditor::GetEndNodeAndOffset(nsISelection *aSelection, nsCOMPtr *outEndNode, PRInt32 *outEndOffset) { @@ -4910,7 +4914,9 @@ nsEditor::GetEndNodeAndOffset(nsIDOMSelection *aSelection, return NS_ERROR_NULL_POINTER; nsCOMPtr enumerator; - nsresult result = aSelection->GetEnumerator(getter_AddRefs(enumerator)); + nsCOMPtr sel(aSelection); + nsCOMPtrselPrivate(do_QueryInterface(sel)); + nsresult result = selPrivate->GetEnumerator(getter_AddRefs(enumerator)); if (NS_FAILED(result) || !enumerator) return NS_ERROR_FAILURE; @@ -5282,11 +5288,12 @@ nsresult nsEditor::BeginUpdateViewBatch() { NS_PRECONDITION(mUpdateCount>=0, "bad state"); - nsCOMPtrselection; + nsCOMPtrselection; nsresult rv = GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(rv) && selection) { - selection->StartBatchChanges(); + nsCOMPtrselPrivate(do_QueryInterface(selection)); + selPrivate->StartBatchChanges(); } if (nsnull!=mViewManager) @@ -5327,10 +5334,11 @@ nsresult nsEditor::EndUpdateViewBatch() return rv?rv:NS_ERROR_FAILURE; StCaretHider caretHider(caret); - nsCOMPtrselection; + nsCOMPtrselection; nsresult selectionResult = GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(selectionResult) && selection) { - selection->EndBatchChanges(); + nsCOMPtrselPrivate(do_QueryInterface(selection)); + selPrivate->EndBatchChanges(); } if (mViewManager) @@ -5406,7 +5414,7 @@ nsEditor::DeleteSelectionImpl(nsIEditor::EDirection aAction) EditAggregateTxn *txn; PRInt32 i; nsIEditActionListener *listener; - nsCOMPtrselection; + nsCOMPtrselection; res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; res = CreateTxnForDeleteSelection(aAction, &txn); @@ -5604,7 +5612,7 @@ NS_IMETHODIMP nsEditor::CreateTxnForDeleteElement(nsIDOMNode * aElement, // Get current selection and setup txn to delete it, // but only if selection exists (is not a collapsed "caret" state) - nsCOMPtr selection; + nsCOMPtr selection; if (!mPresShellWeak) return NS_ERROR_NOT_INITIALIZED; nsCOMPtr ps = do_QueryReferent(mPresShellWeak); if (!ps) return NS_ERROR_NOT_INITIALIZED; @@ -5689,7 +5697,7 @@ nsEditor::CreateTxnForDeleteSelection(nsIEditor::EDirection aAction, #endif nsresult result; - nsCOMPtr selection; + nsCOMPtr selection; nsCOMPtr selCon = do_QueryReferent(mSelConWeak); if (!selCon) return NS_ERROR_NOT_INITIALIZED; result = selCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection)); @@ -5708,7 +5716,8 @@ nsEditor::CreateTxnForDeleteSelection(nsIEditor::EDirection aAction, } nsCOMPtr enumerator; - result = selection->GetEnumerator(getter_AddRefs(enumerator)); + nsCOMPtrselPrivate(do_QueryInterface(selection)); + result = selPrivate->GetEnumerator(getter_AddRefs(enumerator)); if (NS_SUCCEEDED(result) && enumerator) { for (enumerator->First(); NS_OK!=enumerator->IsDone(); enumerator->Next()) @@ -6000,7 +6009,7 @@ nsresult nsEditor::AppendNodeToSelectionAsRange(nsIDOMNode *aNode) { if (!aNode) return NS_ERROR_NULL_POINTER; - nsCOMPtr selection; + nsCOMPtr selection; nsresult res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if(!selection) return NS_ERROR_FAILURE; @@ -6024,11 +6033,11 @@ nsEditor::AppendNodeToSelectionAsRange(nsIDOMNode *aNode) nsresult nsEditor::ClearSelection() { - nsCOMPtr selection; + nsCOMPtr selection; nsresult res = nsEditor::GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_FAILURE; - return selection->ClearSelection(); + return selection->RemoveAllRanges(); } nsresult diff --git a/mozilla/editor/libeditor/base/nsEditor.h b/mozilla/editor/libeditor/base/nsEditor.h index 59ce695d7b6..5acaa6e30b3 100644 --- a/mozilla/editor/libeditor/base/nsEditor.h +++ b/mozilla/editor/libeditor/base/nsEditor.h @@ -31,7 +31,7 @@ #include "nsIDOMDocument.h" #include "nsIDiskDocument.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIDOMCharacterData.h" #include "nsIDOMEventListener.h" #include "nsIDOMRange.h" @@ -101,8 +101,8 @@ class nsSelectionState nsSelectionState(); ~nsSelectionState(); - nsresult SaveSelection(nsIDOMSelection *aSel); - nsresult RestoreSelection(nsIDOMSelection *aSel); + nsresult SaveSelection(nsISelection *aSel); + nsresult RestoreSelection(nsISelection *aSel); PRBool IsCollapsed(); PRBool IsEqual(nsSelectionState *aSelState); void MakeEmpty(); @@ -220,7 +220,7 @@ public: NS_IMETHOD GetRootElement(nsIDOMElement **aElement); NS_IMETHOD GetPresShell(nsIPresShell **aPS); NS_IMETHOD GetSelectionController(nsISelectionController **aSel); - NS_IMETHOD GetSelection(nsIDOMSelection **aSelection); + NS_IMETHOD GetSelection(nsISelection **aSelection); NS_IMETHOD EnableUndo(PRBool aEnable); NS_IMETHOD GetTransactionManager(nsITransactionManager* *aTxnManager); @@ -486,7 +486,7 @@ protected: NS_IMETHOD NotifyDocumentListeners(TDocumentListenerNotification aNotificationType); /** make the given selection span the entire document */ - NS_IMETHOD SelectEntireDocument(nsIDOMSelection *aSelection); + NS_IMETHOD SelectEntireDocument(nsISelection *aSelection); protected: // XXXX: Horrible hack! We are doing this because @@ -509,8 +509,8 @@ public: /** routines for managing the preservation of selection across * various editor actions */ PRBool ArePreservingSelection(); - nsresult PreserveSelectionAcrossActions(nsIDOMSelection *aSel); - nsresult RestorePreservedSelection(nsIDOMSelection *aSel); + nsresult PreserveSelectionAcrossActions(nsISelection *aSel); + nsresult RestorePreservedSelection(nsISelection *aSel); void StopPreservingSelection(); @@ -722,8 +722,8 @@ public: static nsCOMPtr GetChildAt(nsIDOMNode *aParent, PRInt32 aOffset); static nsCOMPtr NextNodeInBlock(nsIDOMNode *aNode, IterDirection aDir); - static nsresult GetStartNodeAndOffset(nsIDOMSelection *aSelection, nsCOMPtr *outStartNode, PRInt32 *outStartOffset); - static nsresult GetEndNodeAndOffset(nsIDOMSelection *aSelection, nsCOMPtr *outEndNode, PRInt32 *outEndOffset); + static nsresult GetStartNodeAndOffset(nsISelection *aSelection, nsCOMPtr *outStartNode, PRInt32 *outStartOffset); + static nsresult GetEndNodeAndOffset(nsISelection *aSelection, nsCOMPtr *outEndNode, PRInt32 *outEndOffset); // Helpers to add a node to the selection. // Used by table cell selection methods diff --git a/mozilla/editor/libeditor/base/nsEditorController.cpp b/mozilla/editor/libeditor/base/nsEditorController.cpp index c3c19ab9d20..4addd2182c3 100644 --- a/mozilla/editor/libeditor/base/nsEditorController.cpp +++ b/mozilla/editor/libeditor/base/nsEditorController.cpp @@ -28,7 +28,7 @@ #include "nsIEditorShell.h" #include "nsIEditorMailSupport.h" #include "nsIFormControlFrame.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIHTMLEditor.h" #include "nsISupportsPrimitives.h" #include "nsXPIDLString.h" @@ -293,6 +293,8 @@ nsresult nsComposerController::RegisterComposerCommands(nsIControllerCommandMana // File menu NS_REGISTER_FIRST_COMMAND(nsPrintingCommands, "cmd_print"); NS_REGISTER_NEXT_COMMAND(nsPrintingCommands, "cmd_printSetup"); + NS_REGISTER_NEXT_COMMAND(nsPrintingCommands,"cmd_print_button"); + NS_REGISTER_NEXT_COMMAND(nsPrintingCommands,"cmd_printSetup"); NS_REGISTER_LAST_COMMAND(nsPrintingCommands, "cmd_printPreview"); // Edit menu diff --git a/mozilla/editor/libeditor/base/nsEditorUtils.cpp b/mozilla/editor/libeditor/base/nsEditorUtils.cpp index 00f80836790..3b925349034 100644 --- a/mozilla/editor/libeditor/base/nsEditorUtils.cpp +++ b/mozilla/editor/libeditor/base/nsEditorUtils.cpp @@ -32,7 +32,7 @@ * nsAutoSelectionReset *****************************************************************************/ -nsAutoSelectionReset::nsAutoSelectionReset(nsIDOMSelection *aSel, nsEditor *aEd) : +nsAutoSelectionReset::nsAutoSelectionReset(nsISelection *aSel, nsEditor *aEd) : mSel(nsnull) ,mEd(nsnull) { diff --git a/mozilla/editor/libeditor/base/nsEditorUtils.h b/mozilla/editor/libeditor/base/nsEditorUtils.h index 9932e49a1c3..d9e1aa4bf72 100644 --- a/mozilla/editor/libeditor/base/nsEditorUtils.h +++ b/mozilla/editor/libeditor/base/nsEditorUtils.h @@ -27,7 +27,7 @@ #include "nsCOMPtr.h" #include "nsIDOMNode.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIEditor.h" #include "nsIAtom.h" #include "nsVoidArray.h" @@ -69,12 +69,12 @@ class nsAutoSelectionReset { private: /** ref-counted reference to the selection that we are supposed to restore */ - nsCOMPtr mSel; + nsCOMPtr mSel; nsEditor *mEd; // non-owning ref to nsEditor public: /** constructor responsible for remembering all state needed to restore aSel */ - nsAutoSelectionReset(nsIDOMSelection *aSel, nsEditor *aEd); + nsAutoSelectionReset(nsISelection *aSel, nsEditor *aEd); /** destructor restores mSel to its former state */ ~nsAutoSelectionReset(); diff --git a/mozilla/editor/libeditor/html/TextEditorTest.cpp b/mozilla/editor/libeditor/html/TextEditorTest.cpp index 161cffd6bc6..94cc597349e 100644 --- a/mozilla/editor/libeditor/html/TextEditorTest.cpp +++ b/mozilla/editor/libeditor/html/TextEditorTest.cpp @@ -24,7 +24,7 @@ #include "nsIEditor.h" #include "TextEditorTest.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIDOMCharacterData.h" #include "nsIDOMDocument.h" #include "nsIDOMNode.h" @@ -111,7 +111,7 @@ nsresult TextEditorTest::InitDoc() nsresult TextEditorTest::TestInsertBreak() { - nsCOMPtrselection; + nsCOMPtrselection; nsresult result = mEditor->GetSelection(getter_AddRefs(selection)); TEST_RESULT(result); TEST_POINTER(selection.get()); @@ -156,7 +156,7 @@ nsresult TextEditorTest::TestTextProperties() // set the whole text node to bold printf("set the whole first text node to bold\n"); - nsCOMPtrselection; + nsCOMPtrselection; result = mEditor->GetSelection(getter_AddRefs(selection)); TEST_RESULT(result); TEST_POINTER(selection.get()); diff --git a/mozilla/editor/libeditor/html/TypeInState.cpp b/mozilla/editor/libeditor/html/TypeInState.cpp index 89ed469a6a1..d7b555bc576 100644 --- a/mozilla/editor/libeditor/html/TypeInState.cpp +++ b/mozilla/editor/libeditor/html/TypeInState.cpp @@ -42,8 +42,8 @@ TypeInState::QueryInterface(REFNSIID aIID, void** aInstancePtr) NS_ADDREF_THIS(); return NS_OK; } - if (aIID.Equals(NS_GET_IID(nsIDOMSelectionListener))) { - *aInstancePtr = (void*)(nsIDOMSelectionListener*)this; + if (aIID.Equals(NS_GET_IID(nsISelectionListener))) { + *aInstancePtr = (void*)(nsISelectionListener*)this; NS_ADDREF_THIS(); return NS_OK; } @@ -67,7 +67,7 @@ TypeInState::~TypeInState() { } -NS_IMETHODIMP TypeInState::NotifySelectionChanged(nsIDOMDocument *, nsIDOMSelection *,short) +NS_IMETHODIMP TypeInState::NotifySelectionChanged(nsIDOMDocument *, nsISelection *,short) { Reset(); return NS_OK; diff --git a/mozilla/editor/libeditor/html/TypeInState.h b/mozilla/editor/libeditor/html/TypeInState.h index 3d3bd7b7a6d..b164bbca8d4 100644 --- a/mozilla/editor/libeditor/html/TypeInState.h +++ b/mozilla/editor/libeditor/html/TypeInState.h @@ -23,7 +23,7 @@ #ifndef TypeInState_h__ #define TypeInState_h__ -#include "nsIDOMSelectionListener.h" +#include "nsISelectionListener.h" #include "nsIEditProperty.h" #include "nsString.h" #include "nsVoidArray.h" @@ -38,7 +38,7 @@ struct PropItem ~PropItem(); }; -class TypeInState : public nsIDOMSelectionListener +class TypeInState : public nsISelectionListener { public: @@ -48,7 +48,7 @@ public: void Reset(); virtual ~TypeInState(); - NS_IMETHOD NotifySelectionChanged(nsIDOMDocument *aDoc, nsIDOMSelection *aSel, short aReason); + NS_IMETHOD NotifySelectionChanged(nsIDOMDocument *aDoc, nsISelection *aSel, short aReason); nsresult SetProp(nsIAtom *aProp); nsresult SetProp(nsIAtom *aProp, const nsString &aAttr); diff --git a/mozilla/editor/libeditor/html/nsHTMLEditRules.cpp b/mozilla/editor/libeditor/html/nsHTMLEditRules.cpp index 987d827062e..9b056664a71 100644 --- a/mozilla/editor/libeditor/html/nsHTMLEditRules.cpp +++ b/mozilla/editor/libeditor/html/nsHTMLEditRules.cpp @@ -33,7 +33,8 @@ #include "nsIDOMText.h" #include "nsIDOMElement.h" #include "nsIDOMNodeList.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" +#include "nsISelectionPrivate.h" #include "nsIDOMRange.h" #include "nsIDOMCharacterData.h" #include "nsIEnumerator.h" @@ -307,7 +308,7 @@ nsHTMLEditRules::AfterEditInner(PRInt32 action, nsIEditor::EDirection aDirection ConfirmSelectionInBody(); if (action == nsEditor::kOpIgnore) return NS_OK; - nsCOMPtrselection; + nsCOMPtrselection; nsresult res = mEditor->GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; @@ -375,7 +376,7 @@ nsHTMLEditRules::AfterEditInner(PRInt32 action, nsIEditor::EDirection aDirection NS_IMETHODIMP -nsHTMLEditRules::WillDoAction(nsIDOMSelection *aSelection, +nsHTMLEditRules::WillDoAction(nsISelection *aSelection, nsRulesInfo *aInfo, PRBool *aCancel, PRBool *aHandled) @@ -429,7 +430,7 @@ nsHTMLEditRules::WillDoAction(nsIDOMSelection *aSelection, NS_IMETHODIMP -nsHTMLEditRules::DidDoAction(nsIDOMSelection *aSelection, +nsHTMLEditRules::DidDoAction(nsISelection *aSelection, nsRulesInfo *aInfo, nsresult aResult) { nsTextRulesInfo *info = NS_STATIC_CAST(nsTextRulesInfo*, aInfo); @@ -572,7 +573,7 @@ nsHTMLEditRules::GetAlignment(PRBool &aMixed, nsIHTMLEditor::EAlignment &aAlign) aAlign = nsIHTMLEditor::eLeft; // get selection - nsCOMPtrselection; + nsCOMPtrselection; nsresult res = mEditor->GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; @@ -702,7 +703,7 @@ nsHTMLEditRules::GetParagraphState(PRBool &aMixed, nsString &outFormat) { nsCOMPtr selNode; PRInt32 selOffset; - nsCOMPtrselection; + nsCOMPtrselection; nsresult res = mEditor->GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; res = mEditor->GetStartNodeAndOffset(selection, &selNode, &selOffset); @@ -788,7 +789,7 @@ nsHTMLEditRules::GetParagraphState(PRBool &aMixed, nsString &outFormat) ********************************************************/ nsresult -nsHTMLEditRules::WillInsert(nsIDOMSelection *aSelection, PRBool *aCancel) +nsHTMLEditRules::WillInsert(nsISelection *aSelection, PRBool *aCancel) { nsresult res = nsTextEditRules::WillInsert(aSelection, aCancel); if (NS_FAILED(res)) return res; @@ -805,14 +806,14 @@ nsHTMLEditRules::WillInsert(nsIDOMSelection *aSelection, PRBool *aCancel) } nsresult -nsHTMLEditRules::DidInsert(nsIDOMSelection *aSelection, nsresult aResult) +nsHTMLEditRules::DidInsert(nsISelection *aSelection, nsresult aResult) { return nsTextEditRules::DidInsert(aSelection, aResult); } nsresult nsHTMLEditRules::WillInsertText(PRInt32 aAction, - nsIDOMSelection *aSelection, + nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled, const nsString *inString, @@ -1004,9 +1005,11 @@ nsHTMLEditRules::WillInsertText(PRInt32 aAction, } nsresult -nsHTMLEditRules::WillInsertBreak(nsIDOMSelection *aSelection, PRBool *aCancel, PRBool *aHandled) +nsHTMLEditRules::WillInsertBreak(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled) { if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; } + nsCOMPtr selection(aSelection); + nsCOMPtr selPriv(do_QueryInterface(selection)); // initialize out param *aCancel = PR_FALSE; *aHandled = PR_FALSE; @@ -1050,7 +1053,7 @@ nsHTMLEditRules::WillInsertBreak(nsIDOMSelection *aSelection, PRBool *aCancel, P res = mEditor->CreateBR(selNode, newOffset, &brNode); if (NS_FAILED(res)) return res; // want selection before the break, and on same line - aSelection->SetHint(PR_TRUE); + selPriv->SetInterlinePosition(PR_TRUE); res = aSelection->Collapse(selNode, newOffset); if (NS_FAILED(res)) return res; *aHandled = PR_TRUE; @@ -1101,12 +1104,14 @@ nsHTMLEditRules::WillInsertBreak(nsIDOMSelection *aSelection, PRBool *aCancel, P // its something else (body, div, td, ...): insert a normal br else { + nsCOMPtr selection(aSelection); + nsCOMPtr selPriv(do_QueryInterface(selection)); nsCOMPtr brNode; res = mEditor->CreateBR(node, offset, &brNode); if (NS_FAILED(res)) return res; res = nsEditor::GetNodeLocation(brNode, &node, &offset); if (NS_FAILED(res)) return res; - // SetHint(PR_TRUE) means we want the caret to stick to the content on the "right". + // SetInterlinePosition(PR_TRUE) means we want the caret to stick to the content on the "right". // We want the caret to stick to whatever is past the break. This is // because the break is on the same line we were on, but the next content // will be on the following line. @@ -1116,9 +1121,9 @@ nsHTMLEditRules::WillInsertBreak(nsIDOMSelection *aSelection, PRBool *aCancel, P nsCOMPtr siblingNode; brNode->GetNextSibling(getter_AddRefs(siblingNode)); if (siblingNode && mEditor->IsBlockNode(siblingNode)) - aSelection->SetHint(PR_FALSE); + selPriv->SetInterlinePosition(PR_FALSE); else - aSelection->SetHint(PR_TRUE); + selPriv->SetInterlinePosition(PR_TRUE); res = aSelection->Collapse(node, offset+1); if (NS_FAILED(res)) return res; *aHandled = PR_TRUE; @@ -1130,7 +1135,7 @@ nsHTMLEditRules::WillInsertBreak(nsIDOMSelection *aSelection, PRBool *aCancel, P nsresult -nsHTMLEditRules::WillDeleteSelection(nsIDOMSelection *aSelection, +nsHTMLEditRules::WillDeleteSelection(nsISelection *aSelection, nsIEditor::EDirection aAction, PRBool *aCancel, PRBool *aHandled) @@ -1139,6 +1144,8 @@ nsHTMLEditRules::WillDeleteSelection(nsIDOMSelection *aSelection, // initialize out param *aCancel = PR_FALSE; *aHandled = PR_FALSE; + nsCOMPtr selection(aSelection); + nsCOMPtr selPriv(do_QueryInterface(selection)); // if there is only bogus content, cancel the operation if (mBogusNode) @@ -1604,7 +1611,7 @@ nsHTMLEditRules::WillDeleteSelection(nsIDOMSelection *aSelection, // table elements. *aHandled = PR_TRUE; nsCOMPtr enumerator; - res = aSelection->GetEnumerator(getter_AddRefs(enumerator)); + res = selPriv->GetEnumerator(getter_AddRefs(enumerator)); if (NS_FAILED(res)) return res; if (!enumerator) return NS_ERROR_UNEXPECTED; @@ -1717,7 +1724,7 @@ nsHTMLEditRules::DeleteNonTableElements(nsIDOMNode *aNode) } nsresult -nsHTMLEditRules::WillMakeList(nsIDOMSelection *aSelection, +nsHTMLEditRules::WillMakeList(nsISelection *aSelection, const nsString *aListType, PRBool aEntireList, PRBool *aCancel, @@ -2041,7 +2048,7 @@ nsHTMLEditRules::WillMakeList(nsIDOMSelection *aSelection, nsresult -nsHTMLEditRules::WillRemoveList(nsIDOMSelection *aSelection, +nsHTMLEditRules::WillRemoveList(nsISelection *aSelection, PRBool aOrdered, PRBool *aCancel, PRBool *aHandled) @@ -2131,7 +2138,7 @@ nsHTMLEditRules::WillRemoveList(nsIDOMSelection *aSelection, nsresult -nsHTMLEditRules::WillMakeDefListItem(nsIDOMSelection *aSelection, +nsHTMLEditRules::WillMakeDefListItem(nsISelection *aSelection, const nsString *aItemType, PRBool aEntireList, PRBool *aCancel, @@ -2144,7 +2151,7 @@ nsHTMLEditRules::WillMakeDefListItem(nsIDOMSelection *aSelection, } nsresult -nsHTMLEditRules::WillMakeBasicBlock(nsIDOMSelection *aSelection, +nsHTMLEditRules::WillMakeBasicBlock(nsISelection *aSelection, const nsString *aBlockType, PRBool *aCancel, PRBool *aHandled) @@ -2210,7 +2217,7 @@ nsHTMLEditRules::WillMakeBasicBlock(nsIDOMSelection *aSelection, } nsresult -nsHTMLEditRules::DidMakeBasicBlock(nsIDOMSelection *aSelection, +nsHTMLEditRules::DidMakeBasicBlock(nsISelection *aSelection, nsRulesInfo *aInfo, nsresult aResult) { if (!aSelection) return NS_ERROR_NULL_POINTER; @@ -2229,7 +2236,7 @@ nsHTMLEditRules::DidMakeBasicBlock(nsIDOMSelection *aSelection, } nsresult -nsHTMLEditRules::WillIndent(nsIDOMSelection *aSelection, PRBool *aCancel, PRBool * aHandled) +nsHTMLEditRules::WillIndent(nsISelection *aSelection, PRBool *aCancel, PRBool * aHandled) { if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; } @@ -2362,7 +2369,7 @@ nsHTMLEditRules::WillIndent(nsIDOMSelection *aSelection, PRBool *aCancel, PRBool nsresult -nsHTMLEditRules::WillOutdent(nsIDOMSelection *aSelection, PRBool *aCancel, PRBool *aHandled) +nsHTMLEditRules::WillOutdent(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled) { if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; } // initialize out param @@ -2518,7 +2525,7 @@ nsHTMLEditRules::ConvertListType(nsIDOMNode *aList, // // nsresult -nsHTMLEditRules::CreateStyleForInsertText(nsIDOMSelection *aSelection, nsIDOMDocument *aDoc) +nsHTMLEditRules::CreateStyleForInsertText(nsISelection *aSelection, nsIDOMDocument *aDoc) { if (!aSelection || !aDoc) return NS_ERROR_NULL_POINTER; if (!mEditor->mTypeInState) return NS_ERROR_NULL_POINTER; @@ -2661,7 +2668,7 @@ nsHTMLEditRules::IsEmptyBlock(nsIDOMNode *aNode, nsresult -nsHTMLEditRules::WillAlign(nsIDOMSelection *aSelection, +nsHTMLEditRules::WillAlign(nsISelection *aSelection, const nsString *alignType, PRBool *aCancel, PRBool *aHandled) @@ -3290,7 +3297,7 @@ nsHTMLEditRules::GetPromotedPoint(RulesEndpoint aWhere, nsIDOMNode *aNode, PRInt // GetPromotedPoint() // nsresult -nsHTMLEditRules::GetPromotedRanges(nsIDOMSelection *inSelection, +nsHTMLEditRules::GetPromotedRanges(nsISelection *inSelection, nsCOMPtr *outArrayOfRanges, PRInt32 inOperationType) { @@ -3577,10 +3584,12 @@ nsHTMLEditRules::GetListActionNodes(nsCOMPtr *outArrayOfNodes, if (!outArrayOfNodes) return NS_ERROR_NULL_POINTER; nsresult res = NS_OK; - nsCOMPtrselection; + nsCOMPtrselection; res = mEditor->GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; - + nsCOMPtr selPriv(do_QueryInterface(selection)); + if (!selPriv) + return NS_ERROR_FAILURE; // added this in so that ui code can ask to change an entire list, even if selection // is only in part of it. used by list item dialog. if (aEntireList) @@ -3588,7 +3597,7 @@ nsHTMLEditRules::GetListActionNodes(nsCOMPtr *outArrayOfNodes, res = NS_NewISupportsArray(getter_AddRefs(*outArrayOfNodes)); if (NS_FAILED(res)) return res; nsCOMPtr enumerator; - res = selection->GetEnumerator(getter_AddRefs(enumerator)); + res = selPriv->GetEnumerator(getter_AddRefs(enumerator)); if (NS_FAILED(res)) return res; if (!enumerator) return NS_ERROR_UNEXPECTED; @@ -3694,7 +3703,7 @@ nsHTMLEditRules::GetParagraphFormatNodes(nsCOMPtr *outArrayOfN { if (!outArrayOfNodes) return NS_ERROR_NULL_POINTER; - nsCOMPtrselection; + nsCOMPtrselection; nsresult res = mEditor->GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; @@ -3928,7 +3937,7 @@ nsHTMLEditRules::MakeTransitionList(nsISupportsArray *inArrayOfNodes, // InsertTab: top level logic for determining how to insert a tab // nsresult -nsHTMLEditRules::InsertTab(nsIDOMSelection *aSelection, +nsHTMLEditRules::InsertTab(nsISelection *aSelection, nsString *outString) { nsCOMPtr parentNode; @@ -3963,7 +3972,7 @@ nsHTMLEditRules::InsertTab(nsIDOMSelection *aSelection, // ReturnInHeader: do the right thing for returns pressed in headers // nsresult -nsHTMLEditRules::ReturnInHeader(nsIDOMSelection *aSelection, +nsHTMLEditRules::ReturnInHeader(nsISelection *aSelection, nsIDOMNode *aHeader, nsIDOMNode *aNode, PRInt32 aOffset) @@ -4033,7 +4042,7 @@ nsHTMLEditRules::ReturnInHeader(nsIDOMSelection *aSelection, // ReturnInParagraph: do the right thing for returns pressed in paragraphs // nsresult -nsHTMLEditRules::ReturnInParagraph(nsIDOMSelection *aSelection, +nsHTMLEditRules::ReturnInParagraph(nsISelection *aSelection, nsIDOMNode *aPara, nsIDOMNode *aNode, PRInt32 aOffset, @@ -4168,12 +4177,14 @@ nsHTMLEditRules::ReturnInParagraph(nsIDOMSelection *aSelection, // ReturnInListItem: do the right thing for returns pressed in list items // nsresult -nsHTMLEditRules::ReturnInListItem(nsIDOMSelection *aSelection, +nsHTMLEditRules::ReturnInListItem(nsISelection *aSelection, nsIDOMNode *aListItem, nsIDOMNode *aNode, PRInt32 aOffset) { if (!aSelection || !aListItem || !aNode) return NS_ERROR_NULL_POINTER; + nsCOMPtr selection(aSelection); + nsCOMPtr selPriv(do_QueryInterface(selection)); nsresult res = NS_OK; nsCOMPtr listitem; @@ -4226,7 +4237,7 @@ nsHTMLEditRules::ReturnInListItem(nsIDOMSelection *aSelection, if (NS_FAILED(res)) return res; // set selection to before the moz br - aSelection->SetHint(PR_TRUE); + selPriv->SetInterlinePosition(PR_TRUE); res = aSelection->Collapse(listparent,offset+1); } return res; @@ -4702,7 +4713,7 @@ nsHTMLEditRules::AdjustSpecialBreaks(PRBool aSafeToAskFrames) nsresult -nsHTMLEditRules::AdjustWhitespace(nsIDOMSelection *aSelection) +nsHTMLEditRules::AdjustWhitespace(nsISelection *aSelection) { nsCOMPtr arrayOfNodes; nsCOMPtr isupports; @@ -4759,10 +4770,12 @@ nsHTMLEditRules::AdjustWhitespace(nsIDOMSelection *aSelection) nsresult -nsHTMLEditRules::AdjustSelection(nsIDOMSelection *aSelection, nsIEditor::EDirection aAction) +nsHTMLEditRules::AdjustSelection(nsISelection *aSelection, nsIEditor::EDirection aAction) { if (!aSelection) return NS_ERROR_NULL_POINTER; - + nsCOMPtr selection(aSelection); + nsCOMPtr selPriv(do_QueryInterface(selection)); + // if the selection isn't collapsed, do nothing. // moose: one thing to do instead is check for the case of // only a single break selected, and collapse it. Good thing? Beats me. @@ -4828,7 +4841,7 @@ nsHTMLEditRules::AdjustSelection(nsIDOMSelection *aSelection, nsIEditor::EDirect res = nsEditor::GetNodeLocation(brNode, &selNode, &selOffset); if (NS_FAILED(res)) return res; // selection stays *before* moz-br, sticking to it - aSelection->SetHint(PR_TRUE); + selPriv->SetInterlinePosition(PR_TRUE); res = aSelection->Collapse(selNode,selOffset); if (NS_FAILED(res)) return res; } @@ -4853,7 +4866,7 @@ nsHTMLEditRules::AdjustSelection(nsIDOMSelection *aSelection, nsIEditor::EDirect res = nsEditor::GetNodeLocation(brNode, &selNode, &selOffset); if (NS_FAILED(res)) return res; // selection stays *before* moz-br, sticking to it - aSelection->SetHint(PR_TRUE); + selPriv->SetInterlinePosition(PR_TRUE); res = aSelection->Collapse(selNode,selOffset); if (NS_FAILED(res)) return res; } @@ -5070,12 +5083,13 @@ nsHTMLEditRules::SelectionEndpointInNode(nsIDOMNode *aNode, PRBool *aResult) *aResult = PR_FALSE; - nsCOMPtrselection; + nsCOMPtrselection; nsresult res = mEditor->GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; + nsCOMPtrselPriv(do_QueryInterface(selection)); nsCOMPtr enumerator; - res = selection->GetEnumerator(getter_AddRefs(enumerator)); + res = selPriv->GetEnumerator(getter_AddRefs(enumerator)); if (NS_FAILED(res)) return res; if (!enumerator) return NS_ERROR_UNEXPECTED; @@ -5338,7 +5352,7 @@ nsHTMLEditRules::ConfirmSelectionInBody() bodyNode = do_QueryInterface(bodyElement); // get the selection - nsCOMPtrselection; + nsCOMPtrselection; res = mEditor->GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; @@ -5619,7 +5633,7 @@ nsHTMLEditRules::DidDeleteText(nsIDOMCharacterData *aTextNode, } NS_IMETHODIMP -nsHTMLEditRules::WillDeleteSelection(nsIDOMSelection *aSelection) +nsHTMLEditRules::WillDeleteSelection(nsISelection *aSelection) { if (!mListenerEnabled) return NS_OK; // get the (collapsed) selection location @@ -5639,7 +5653,7 @@ nsHTMLEditRules::WillDeleteSelection(nsIDOMSelection *aSelection) } NS_IMETHODIMP -nsHTMLEditRules::DidDeleteSelection(nsIDOMSelection *aSelection) +nsHTMLEditRules::DidDeleteSelection(nsISelection *aSelection) { return NS_OK; } diff --git a/mozilla/editor/libeditor/html/nsHTMLEditRules.h b/mozilla/editor/libeditor/html/nsHTMLEditRules.h index 7d98a752a52..d827487b3c5 100644 --- a/mozilla/editor/libeditor/html/nsHTMLEditRules.h +++ b/mozilla/editor/libeditor/html/nsHTMLEditRules.h @@ -49,8 +49,8 @@ public: NS_IMETHOD Init(nsHTMLEditor *aEditor, PRUint32 aFlags); NS_IMETHOD BeforeEdit(PRInt32 action, nsIEditor::EDirection aDirection); NS_IMETHOD AfterEdit(PRInt32 action, nsIEditor::EDirection aDirection); - NS_IMETHOD WillDoAction(nsIDOMSelection *aSelection, nsRulesInfo *aInfo, PRBool *aCancel, PRBool *aHandled); - NS_IMETHOD DidDoAction(nsIDOMSelection *aSelection, nsRulesInfo *aInfo, nsresult aResult); + NS_IMETHOD WillDoAction(nsISelection *aSelection, nsRulesInfo *aInfo, PRBool *aCancel, PRBool *aHandled); + NS_IMETHOD DidDoAction(nsISelection *aSelection, nsRulesInfo *aInfo, nsresult aResult); // nsIHTMLEditRules methods NS_IMETHOD GetListState(PRBool &aMixed, PRBool &aOL, PRBool &aUL, PRBool &aDL); @@ -75,8 +75,8 @@ public: NS_IMETHOD DidInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsString &aString, nsresult aResult); NS_IMETHOD WillDeleteText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, PRInt32 aLength); NS_IMETHOD DidDeleteText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, PRInt32 aLength, nsresult aResult); - NS_IMETHOD WillDeleteSelection(nsIDOMSelection *aSelection); - NS_IMETHOD DidDeleteSelection(nsIDOMSelection *aSelection); + NS_IMETHOD WillDeleteSelection(nsISelection *aSelection); + NS_IMETHOD DidDeleteSelection(nsISelection *aSelection); protected: @@ -88,41 +88,42 @@ protected: // nsHTMLEditRules implementation methods - nsresult WillInsert(nsIDOMSelection *aSelection, PRBool *aCancel); - nsresult DidInsert(nsIDOMSelection *aSelection, nsresult aResult); + nsresult WillInsert(nsISelection *aSelection, PRBool *aCancel); + nsresult DidInsert(nsISelection *aSelection, nsresult aResult); nsresult WillInsertText( PRInt32 aAction, - nsIDOMSelection *aSelection, + nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled, const nsString *inString, nsString *outString, PRInt32 aMaxLength); - nsresult WillInsertBreak(nsIDOMSelection *aSelection, PRBool *aCancel, PRBool *aHandled); - nsresult WillDeleteSelection(nsIDOMSelection *aSelection, nsIEditor::EDirection aAction, + nsresult WillInsertBreak(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled); + nsresult WillDeleteSelection(nsISelection *aSelection, nsIEditor::EDirection aAction, PRBool *aCancel, PRBool *aHandled); nsresult DeleteNonTableElements(nsIDOMNode *aNode); - nsresult WillMakeList(nsIDOMSelection *aSelection, const nsString *aListType, PRBool aEntireList, PRBool *aCancel, PRBool *aHandled, const nsString *aItemType=nsnull); - nsresult WillRemoveList(nsIDOMSelection *aSelection, PRBool aOrderd, PRBool *aCancel, PRBool *aHandled); - nsresult WillIndent(nsIDOMSelection *aSelection, PRBool *aCancel, PRBool *aHandled); - nsresult WillOutdent(nsIDOMSelection *aSelection, PRBool *aCancel, PRBool *aHandled); - nsresult WillAlign(nsIDOMSelection *aSelection, const nsString *alignType, PRBool *aCancel, PRBool *aHandled); - nsresult WillMakeDefListItem(nsIDOMSelection *aSelection, const nsString *aBlockType, PRBool aEntireList, PRBool *aCancel, PRBool *aHandled); - nsresult WillMakeBasicBlock(nsIDOMSelection *aSelection, const nsString *aBlockType, PRBool *aCancel, PRBool *aHandled); - nsresult DidMakeBasicBlock(nsIDOMSelection *aSelection, nsRulesInfo *aInfo, nsresult aResult); + + nsresult WillMakeList(nsISelection *aSelection, const nsString *aListType, PRBool aEntireList, PRBool *aCancel, PRBool *aHandled, const nsString *aItemType=nsnull); + nsresult WillRemoveList(nsISelection *aSelection, PRBool aOrderd, PRBool *aCancel, PRBool *aHandled); + nsresult WillIndent(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled); + nsresult WillOutdent(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled); + nsresult WillAlign(nsISelection *aSelection, const nsString *alignType, PRBool *aCancel, PRBool *aHandled); + nsresult WillMakeDefListItem(nsISelection *aSelection, const nsString *aBlockType, PRBool aEntireList, PRBool *aCancel, PRBool *aHandled); + nsresult WillMakeBasicBlock(nsISelection *aSelection, const nsString *aBlockType, PRBool *aCancel, PRBool *aHandled); + nsresult DidMakeBasicBlock(nsISelection *aSelection, nsRulesInfo *aInfo, nsresult aResult); nsresult AlignInnerBlocks(nsIDOMNode *aNode, const nsString *alignType); nsresult AlignBlockContents(nsIDOMNode *aNode, const nsString *alignType); nsresult GetInnerContent(nsIDOMNode *aNode, nsISupportsArray *outArrayOfNodes, PRBool aList = PR_TRUE, PRBool aTble = PR_TRUE); - nsresult InsertTab(nsIDOMSelection *aSelection, nsString *outString); + nsresult InsertTab(nsISelection *aSelection, nsString *outString); - nsresult ReturnInHeader(nsIDOMSelection *aSelection, nsIDOMNode *aHeader, nsIDOMNode *aTextNode, PRInt32 aOffset); - nsresult ReturnInParagraph(nsIDOMSelection *aSelection, nsIDOMNode *aHeader, nsIDOMNode *aTextNode, PRInt32 aOffset, PRBool *aCancel, PRBool *aHandled); - nsresult ReturnInListItem(nsIDOMSelection *aSelection, nsIDOMNode *aHeader, nsIDOMNode *aTextNode, PRInt32 aOffset); + nsresult ReturnInHeader(nsISelection *aSelection, nsIDOMNode *aHeader, nsIDOMNode *aTextNode, PRInt32 aOffset); + nsresult ReturnInParagraph(nsISelection *aSelection, nsIDOMNode *aHeader, nsIDOMNode *aTextNode, PRInt32 aOffset, PRBool *aCancel, PRBool *aHandled); + nsresult ReturnInListItem(nsISelection *aSelection, nsIDOMNode *aHeader, nsIDOMNode *aTextNode, PRInt32 aOffset); nsresult AfterEditInner(PRInt32 action, nsIEditor::EDirection aDirection); nsresult ConvertListType(nsIDOMNode *aList, nsCOMPtr *outList, const nsString& aListType, const nsString& aItemType); - nsresult CreateStyleForInsertText(nsIDOMSelection *aSelection, nsIDOMDocument *aDoc); + nsresult CreateStyleForInsertText(nsISelection *aSelection, nsIDOMDocument *aDoc); nsresult IsEmptyBlock(nsIDOMNode *aNode, PRBool *outIsEmptyBlock, PRBool aMozBRDoesntCount = PR_FALSE, @@ -134,7 +135,7 @@ protected: nsresult GetPromotedPoint(RulesEndpoint aWhere, nsIDOMNode *aNode, PRInt32 aOffset, PRInt32 actionID, nsCOMPtr *outNode, PRInt32 *outOffset); - nsresult GetPromotedRanges(nsIDOMSelection *inSelection, + nsresult GetPromotedRanges(nsISelection *inSelection, nsCOMPtr *outArrayOfRanges, PRInt32 inOperationType); nsresult PromoteRange(nsIDOMRange *inRange, PRInt32 inOperationType); @@ -168,8 +169,8 @@ protected: nsresult PopListItem(nsIDOMNode *aListItem, PRBool *aOutOfList); nsresult AdjustSpecialBreaks(PRBool aSafeToAskFrames = PR_FALSE); - nsresult AdjustWhitespace(nsIDOMSelection *aSelection); - nsresult AdjustSelection(nsIDOMSelection *aSelection, nsIEditor::EDirection aAction); + nsresult AdjustWhitespace(nsISelection *aSelection); + nsresult AdjustSelection(nsISelection *aSelection, nsIEditor::EDirection aAction); nsresult FindNearSelectableNode(nsIDOMNode *aSelNode, PRInt32 aSelOffset, nsIEditor::EDirection aDirection, diff --git a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp index 140c80b2272..8c4af61630f 100644 --- a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp +++ b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp @@ -39,7 +39,8 @@ #include "nsIDOMKeyListener.h" #include "nsIDOMMouseListener.h" #include "nsIDOMMouseEvent.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" +#include "nsISelectionPrivate.h" #include "nsIDOMHTMLAnchorElement.h" #include "nsIDOMHTMLImageElement.h" #include "nsISelectionController.h" @@ -307,15 +308,16 @@ nsHTMLEditor::~nsHTMLEditor() //the autopointers will clear themselves up. //but we need to also remove the listeners or we have a leak - nsCOMPtrselection; + nsCOMPtrselection; nsresult result = GetSelection(getter_AddRefs(selection)); // if we don't get the selection, just skip this if (NS_SUCCEEDED(result) && selection) { - nsCOMPtrlistener; + nsCOMPtr selPriv(do_QueryInterface(selection)); + nsCOMPtrlistener; listener = do_QueryInterface(mTypeInState); if (listener) { - selection->RemoveSelectionListener(listener); + selPriv->RemoveSelectionListener(listener); } } nsCOMPtr erP; @@ -417,15 +419,16 @@ NS_IMETHODIMP nsHTMLEditor::Init(nsIDOMDocument *aDoc, if (!mTypeInState) {return NS_ERROR_NULL_POINTER;} NS_ADDREF(mTypeInState); - nsCOMPtrselection; + nsCOMPtrselection; result = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(result)) { return result; } if (selection) { - nsCOMPtrlistener; + nsCOMPtr selPriv(do_QueryInterface(selection)); + nsCOMPtrlistener; listener = do_QueryInterface(mTypeInState); if (listener) { - selection->AddSelectionListener(listener); + selPriv->AddSelectionListener(listener); } } @@ -716,7 +719,7 @@ NS_IMETHODIMP nsHTMLEditor::EditorKeyPress(nsIDOMKeyEvent* aKeyEvent) if (keyCode == nsIDOMKeyEvent::DOM_VK_TAB && !(mFlags&eEditorPlaintextBit)) { - nsCOMPtrselection; + nsCOMPtrselection; res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; PRInt32 offset; @@ -866,7 +869,7 @@ NS_IMETHODIMP nsHTMLEditor::TabInTable(PRBool inIsShift, PRBool *outHandled) *outHandled = PR_TRUE; // put selection in right place // Use table code to get selection and index to new row... - nsCOMPtrselection; + nsCOMPtrselection; nsCOMPtr tblElement; nsCOMPtr cell; PRInt32 row; @@ -943,23 +946,24 @@ NS_IMETHODIMP nsHTMLEditor::CreateBRImpl(nsCOMPtr *aInOutParent, PRI *outBRNode = brNode; if (*outBRNode && (aSelect != eNone)) { - nsCOMPtr selection; + nsCOMPtr selection; nsCOMPtr parent; PRInt32 offset; res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; + nsCOMPtr selPriv(do_QueryInterface(selection)); res = GetNodeLocation(*outBRNode, &parent, &offset); if (NS_FAILED(res)) return res; if (aSelect == eNext) { // position selection after br - selection->SetHint(PR_TRUE); + selPriv->SetInterlinePosition(PR_TRUE); res = selection->Collapse(parent, offset+1); } else if (aSelect == ePrevious) { // position selection before br - selection->SetHint(PR_TRUE); + selPriv->SetInterlinePosition(PR_TRUE); res = selection->Collapse(parent, offset); } } @@ -977,7 +981,7 @@ NS_IMETHODIMP nsHTMLEditor::CreateBR(nsIDOMNode *aNode, PRInt32 aOffset, nsCOMPt NS_IMETHODIMP nsHTMLEditor::InsertBR(nsCOMPtr *outBRNode) { PRBool bCollapsed; - nsCOMPtr selection; + nsCOMPtr selection; if (!outBRNode) return NS_ERROR_NULL_POINTER; *outBRNode = nsnull; @@ -987,6 +991,7 @@ NS_IMETHODIMP nsHTMLEditor::InsertBR(nsCOMPtr *outBRNode) nsresult res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; + nsCOMPtr selPriv(do_QueryInterface(selection)); res = selection->GetIsCollapsed(&bCollapsed); if (NS_FAILED(res)) return res; if (!bCollapsed) @@ -1005,7 +1010,7 @@ NS_IMETHODIMP nsHTMLEditor::InsertBR(nsCOMPtr *outBRNode) // position selection after br res = GetNodeLocation(*outBRNode, &selNode, &selOffset); if (NS_FAILED(res)) return res; - selection->SetHint(PR_TRUE); + selPriv->SetInterlinePosition(PR_TRUE); res = selection->Collapse(selNode, selOffset+1); return res; @@ -1020,10 +1025,11 @@ NS_IMETHODIMP nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty, ForceCompositionEnd(); nsresult res; - nsCOMPtrselection; + nsCOMPtrselection; res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_NULL_POINTER; + nsCOMPtr selPriv(do_QueryInterface(selection)); PRBool isCollapsed; selection->GetIsCollapsed(&isCollapsed); @@ -1046,7 +1052,7 @@ NS_IMETHODIMP nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty, { // get selection range enumerator nsCOMPtr enumerator; - res = selection->GetEnumerator(getter_AddRefs(enumerator)); + res = selPriv->GetEnumerator(getter_AddRefs(enumerator)); if (NS_FAILED(res)) return res; if (!enumerator) return NS_ERROR_FAILURE; @@ -1741,16 +1747,17 @@ NS_IMETHODIMP nsHTMLEditor::GetInlinePropertyWithAttrValue(nsIAtom *aProperty, aAll=PR_TRUE; aFirst=PR_FALSE; PRBool first=PR_TRUE; - nsCOMPtrselection; + nsCOMPtrselection; result = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(result)) return result; if (!selection) return NS_ERROR_NULL_POINTER; + nsCOMPtr selPriv(do_QueryInterface(selection)); PRBool isCollapsed; selection->GetIsCollapsed(&isCollapsed); nsCOMPtr collapsedNode; nsCOMPtr enumerator; - result = selection->GetEnumerator(getter_AddRefs(enumerator)); + result = selPriv->GetEnumerator(getter_AddRefs(enumerator)); if (NS_FAILED(result)) return result; if (!enumerator) return NS_ERROR_NULL_POINTER; @@ -1934,10 +1941,11 @@ nsresult nsHTMLEditor::RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsStri ForceCompositionEnd(); nsresult res; - nsCOMPtrselection; + nsCOMPtrselection; res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_NULL_POINTER; + nsCOMPtr selPriv(do_QueryInterface(selection)); PRBool isCollapsed; selection->GetIsCollapsed(&isCollapsed); @@ -1965,7 +1973,7 @@ nsresult nsHTMLEditor::RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsStri { // get selection range enumerator nsCOMPtr enumerator; - res = selection->GetEnumerator(getter_AddRefs(enumerator)); + res = selPriv->GetEnumerator(getter_AddRefs(enumerator)); if (NS_FAILED(res)) return res; if (!enumerator) return NS_ERROR_FAILURE; @@ -2069,7 +2077,7 @@ NS_IMETHODIMP nsHTMLEditor::DecreaseFontSize() return RelativeFontChange(-1); } -nsresult nsHTMLEditor::GetTextSelectionOffsets(nsIDOMSelection *aSelection, +nsresult nsHTMLEditor::GetTextSelectionOffsets(nsISelection *aSelection, PRInt32 &aOutStartOffset, PRInt32 &aOutEndOffset) { @@ -2087,7 +2095,9 @@ nsresult nsHTMLEditor::GetTextSelectionOffsets(nsIDOMSelection *aSelection, aSelection->GetFocusOffset(&endOffset); nsCOMPtr enumerator; - result = aSelection->GetEnumerator(getter_AddRefs(enumerator)); + nsCOMPtr selection(aSelection); + nsCOMPtr selPriv(do_QueryInterface(selection)); + result = selPriv->GetEnumerator(getter_AddRefs(enumerator)); if (NS_FAILED(result)) return result; if (!enumerator) return NS_ERROR_NULL_POINTER; @@ -2255,12 +2265,12 @@ nsHTMLEditor::SetCaretToDocumentStart() } nsresult -nsHTMLEditor::CollapseSelectionToDeepestNonTableFirstChild(nsIDOMSelection *aSelection, nsIDOMNode *aNode) +nsHTMLEditor::CollapseSelectionToDeepestNonTableFirstChild(nsISelection *aSelection, nsIDOMNode *aNode) { if (!aNode) return NS_ERROR_NULL_POINTER; nsresult res; - nsCOMPtr selection; + nsCOMPtr selection; if (aSelection) { selection = aSelection; @@ -2295,7 +2305,7 @@ NS_IMETHODIMP nsHTMLEditor::DeleteSelection(nsIEditor::EDirection aAction) { if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } - nsCOMPtr selection; + nsCOMPtr selection; PRBool cancel, handled; nsresult result; @@ -2375,7 +2385,7 @@ NS_IMETHODIMP nsHTMLEditor::InsertText(const nsString& aStringToInsert) { if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } - nsCOMPtr selection; + nsCOMPtr selection; PRBool cancel, handled; PRInt32 theAction = nsTextEditRules::kInsertText; PRInt32 opID = kOpInsertText; @@ -2439,7 +2449,7 @@ NS_IMETHODIMP nsHTMLEditor::InsertHTMLWithCharset(const nsString& aInputString, nsresult res; - nsCOMPtrselection; + nsCOMPtrselection; if (!mRules) return NS_ERROR_NOT_INITIALIZED; @@ -2562,7 +2572,7 @@ NS_IMETHODIMP nsHTMLEditor::InsertHTMLWithCharset(const nsString& aInputString, NS_IMETHODIMP nsHTMLEditor::ReplaceHeadContentsWithHTML(const nsString &aSourceToInsert) { - nsCOMPtr selection; + nsCOMPtr selection; nsresult res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_NULL_POINTER; @@ -2669,7 +2679,7 @@ nsHTMLEditor::RebuildDocumentFromSource(const nsString& aSourceString) { ForceCompositionEnd(); - nsCOMPtrselection; + nsCOMPtrselection; nsresult res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; @@ -2753,7 +2763,7 @@ NS_IMETHODIMP nsHTMLEditor::InsertBreak() if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } nsAutoRules beginRulesSniffing(this, kOpInsertBreak, nsIEditor::eNext); - nsCOMPtr selection; + nsCOMPtr selection; PRBool cancel, handled; // pre-process @@ -2800,16 +2810,17 @@ NS_IMETHODIMP nsHTMLEditor::InsertBreak() if (!selection) res = NS_ERROR_NULL_POINTER; // don't return here, so DidDoAction is called if (NS_SUCCEEDED(res)) { + nsCOMPtr selPriv(do_QueryInterface(selection)); if (-1==offsetInParent) { nextNode->GetParentNode(getter_AddRefs(parent)); res = GetChildOffset(nextNode, parent, offsetInParent); if (NS_SUCCEEDED(res)) { - // SetHint(PR_TRUE) means we want the caret to stick to the content on the "right". + // SetInterlinePosition(PR_TRUE) means we want the caret to stick to the content on the "right". // We want the caret to stick to whatever is past the break. This is // because the break is on the same line we were on, but the next content // will be on the following line. - selection->SetHint(PR_TRUE); + selPriv->SetInterlinePosition(PR_TRUE); res = selection->Collapse(parent, offsetInParent+1); // +1 to insert just after the break } } @@ -2843,7 +2854,7 @@ nsHTMLEditor::InsertElementAtSelection(nsIDOMElement* aElement, PRBool aDeleteSe nsAutoEditBatch beginBatching(this); nsAutoRules beginRulesSniffing(this, kOpInsertElement, nsIEditor::eNext); - nsCOMPtrselection; + nsCOMPtrselection; res = GetSelection(getter_AddRefs(selection)); if (!NS_SUCCEEDED(res) || !selection) return NS_ERROR_FAILURE; @@ -2976,7 +2987,7 @@ nsHTMLEditor::DeleteSelectionAndCreateNode(const nsString& aTag, NS_IF_ADDREF(*aNewNode); // we want the selection to be just after the new node - nsCOMPtr selection; + nsCOMPtr selection; result = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(result)) return result; if (!selection) return NS_ERROR_NULL_POINTER; @@ -2993,7 +3004,7 @@ nsHTMLEditor::SelectElement(nsIDOMElement* aElement) // Must be sure that element is contained in the document body if (IsElementInBody(aElement)) { - nsCOMPtr selection; + nsCOMPtr selection; res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_NULL_POINTER; @@ -3026,7 +3037,7 @@ nsHTMLEditor::SetCaretAfterElement(nsIDOMElement* aElement) // Be sure the element is contained in the document body if (aElement && IsElementInBody(aElement)) { - nsCOMPtr selection; + nsCOMPtr selection; res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_NULL_POINTER; @@ -3077,10 +3088,11 @@ nsHTMLEditor::GetParentBlockTags(nsStringArray *aTagList, PRBool aGetLists) if (!aTagList) { return NS_ERROR_NULL_POINTER; } nsresult res; - nsCOMPtrselection; + nsCOMPtrselection; res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_NULL_POINTER; + nsCOMPtr selPriv(do_QueryInterface(selection)); // Find out if the selection is collapsed: PRBool isCollapsed; @@ -3120,7 +3132,7 @@ nsHTMLEditor::GetParentBlockTags(nsStringArray *aTagList, PRBool aGetLists) // else non-collapsed selection nsCOMPtr enumerator; - res = selection->GetEnumerator(getter_AddRefs(enumerator)); + res = selPriv->GetEnumerator(getter_AddRefs(enumerator)); if (NS_FAILED(res)) return res; if (!enumerator) return NS_ERROR_NULL_POINTER; @@ -3354,7 +3366,7 @@ nsHTMLEditor::MakeOrChangeList(const nsString& aListType, PRBool entireList) nsresult res; if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } - nsCOMPtr selection; + nsCOMPtr selection; PRBool cancel, handled; nsAutoEditBatch beginBatching(this); @@ -3432,7 +3444,7 @@ nsHTMLEditor::RemoveList(const nsString& aListType) nsresult res; if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } - nsCOMPtr selection; + nsCOMPtr selection; PRBool cancel, handled; nsAutoEditBatch beginBatching(this); @@ -3461,7 +3473,7 @@ nsHTMLEditor::MakeDefinitionItem(const nsString& aItemType) nsresult res; if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } - nsCOMPtr selection; + nsCOMPtr selection; PRBool cancel, handled; nsAutoEditBatch beginBatching(this); @@ -3491,7 +3503,7 @@ nsHTMLEditor::InsertBasicBlock(const nsString& aBlockType) nsresult res; if (!mRules) { return NS_ERROR_NOT_INITIALIZED; } - nsCOMPtr selection; + nsCOMPtr selection; PRBool cancel, handled; nsAutoEditBatch beginBatching(this); @@ -3575,7 +3587,7 @@ nsHTMLEditor::Indent(const nsString& aIndent) nsAutoRules beginRulesSniffing(this, opID, nsIEditor::eNext); // pre-process - nsCOMPtr selection; + nsCOMPtr selection; res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_NULL_POINTER; @@ -3656,7 +3668,7 @@ nsHTMLEditor::Align(const nsString& aAlignType) PRBool cancel, handled; // Find out if the selection is collapsed: - nsCOMPtr selection; + nsCOMPtr selection; nsresult res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_NULL_POINTER; @@ -3684,7 +3696,7 @@ nsHTMLEditor::GetElementOrParentByTagName(const nsString &aTagName, nsIDOMNode * else { // If no node supplied, get it from anchor node of current selection - nsCOMPtrselection; + nsCOMPtrselection; res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_NULL_POINTER; @@ -3802,10 +3814,11 @@ nsHTMLEditor::GetSelectedElement(const nsString& aTagName, nsIDOMElement** aRetu *aReturn = nsnull; // First look for a single element in selection - nsCOMPtrselection; + nsCOMPtrselection; nsresult res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_NULL_POINTER; + nsCOMPtr selPriv(do_QueryInterface(selection)); PRBool bNodeFound = PR_FALSE; res=NS_ERROR_NOT_INITIALIZED; @@ -3938,7 +3951,7 @@ nsHTMLEditor::GetSelectedElement(const nsString& aTagName, nsIDOMElement** aRetu if (!isCollapsed) // Don't bother to examine selection if it is collapsed { nsCOMPtr enumerator; - res = selection->GetEnumerator(getter_AddRefs(enumerator)); + res = selPriv->GetEnumerator(getter_AddRefs(enumerator)); if (NS_SUCCEEDED(res)) { if(!enumerator) @@ -4108,7 +4121,7 @@ NS_IMETHODIMP nsHTMLEditor::InsertLinkAroundSelection(nsIDOMElement* aAnchorElement) { nsresult res=NS_ERROR_NULL_POINTER; - nsCOMPtr selection; + nsCOMPtr selection; if (!aAnchorElement) return NS_ERROR_NULL_POINTER; @@ -4761,7 +4774,7 @@ nsHTMLEditor::Undo(PRUint32 aCount) nsAutoRules beginRulesSniffing(this, kOpUndo, nsIEditor::eNone); nsTextRulesInfo ruleInfo(nsTextEditRules::kUndo); - nsCOMPtr selection; + nsCOMPtr selection; GetSelection(getter_AddRefs(selection)); PRBool cancel, handled; result = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled); @@ -4784,7 +4797,7 @@ nsHTMLEditor::Redo(PRUint32 aCount) nsAutoRules beginRulesSniffing(this, kOpRedo, nsIEditor::eNone); nsTextRulesInfo ruleInfo(nsTextEditRules::kRedo); - nsCOMPtr selection; + nsCOMPtr selection; GetSelection(getter_AddRefs(selection)); PRBool cancel, handled; result = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled); @@ -4800,7 +4813,7 @@ nsHTMLEditor::Redo(PRUint32 aCount) NS_IMETHODIMP nsHTMLEditor::Cut() { - nsCOMPtr selection; + nsCOMPtr selection; nsresult res = GetSelection(getter_AddRefs(selection)); if (!NS_SUCCEEDED(res)) return res; @@ -4819,7 +4832,7 @@ NS_IMETHODIMP nsHTMLEditor::CanCut(PRBool &aCanCut) { aCanCut = PR_FALSE; - nsCOMPtr selection; + nsCOMPtr selection; nsresult res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; @@ -4843,7 +4856,7 @@ NS_IMETHODIMP nsHTMLEditor::CanCopy(PRBool &aCanCopy) { aCanCopy = PR_FALSE; - nsCOMPtr selection; + nsCOMPtr selection; nsresult res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; @@ -5062,7 +5075,7 @@ NS_IMETHODIMP nsHTMLEditor::InsertFromDrop(nsIDOMEvent* aDropEvent) rv = GetDocument(getter_AddRefs(destdomdoc)); if (NS_FAILED(rv)) return rv; - nsCOMPtr selection; + nsCOMPtr selection; rv = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(rv)) return rv; if (!selection) return NS_ERROR_FAILURE; @@ -5180,7 +5193,7 @@ NS_IMETHODIMP nsHTMLEditor::CanDrag(nsIDOMEvent *aDragEvent, PRBool &aCanDrag) return NS_OK; } - nsCOMPtr selection; + nsCOMPtr selection; nsresult res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; @@ -5221,7 +5234,7 @@ NS_IMETHODIMP nsHTMLEditor::DoDrag(nsIDOMEvent *aDragEvent) nsCOMPtr domnode = do_QueryInterface(eventTarget); /* get the selection to be dragged */ - nsCOMPtr selection; + nsCOMPtr selection; rv = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(rv)) return rv; @@ -5406,7 +5419,7 @@ NS_IMETHODIMP nsHTMLEditor::PasteAsCitedQuotation(const nsString& aCitation, nsAutoRules beginRulesSniffing(this, kOpInsertQuotation, nsIEditor::eNext); // get selection - nsCOMPtr selection; + nsCOMPtr selection; nsresult res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_NULL_POINTER; @@ -5559,7 +5572,7 @@ nsHTMLEditor::InsertAsPlaintextQuotation(const nsString& aQuotedText, nsCOMPtr preNode; // get selection - nsCOMPtr selection; + nsCOMPtr selection; rv = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(rv)) return rv; if (!selection) return NS_ERROR_NULL_POINTER; @@ -5634,7 +5647,7 @@ nsHTMLEditor::InsertAsCitedQuotation(const nsString& aQuotedText, nsresult res = NS_OK; // get selection - nsCOMPtr selection; + nsCOMPtr selection; res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_NULL_POINTER; @@ -5718,7 +5731,7 @@ NS_IMETHODIMP nsHTMLEditor::OutputToString(nsAWritableString& aOutputString, } else { - nsCOMPtr selection; + nsCOMPtr selection; // Set the wrap column. If our wrap column is 0, // i.e. wrap to body width, then don't set it, let the @@ -5741,11 +5754,13 @@ NS_IMETHODIMP nsHTMLEditor::OutputToString(nsAWritableString& aOutputString, NS_ENSURE_TRUE(rootElement, NS_ERROR_FAILURE); //is this a body?? do we want to output the whole doc? // Set the selection, if appropriate: + nsCOMPtr selPriv; if (aFlags & nsIDocumentEncoder::OutputSelectionOnly) { rv = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(rv)) return rv; + selPriv = do_QueryInterface(selection); } else if (nsHTMLEditUtils::IsBody(rootElement)) { @@ -5790,10 +5805,11 @@ NS_IMETHODIMP nsHTMLEditor::OutputToString(nsAWritableString& aOutputString, return NS_ERROR_FAILURE; rv = nsComponentManager::CreateInstance(kCDOMSelectionCID, nsnull, - NS_GET_IID(nsIDOMSelection), + NS_GET_IID(nsISelection), getter_AddRefs(selection)); if (selection) { + selPriv = do_QueryInterface(selection); //get the independent selection interface nsCOMPtr indSel = do_QueryInterface(selection); if (indSel) @@ -5816,7 +5832,18 @@ NS_IMETHODIMP nsHTMLEditor::OutputToString(nsAWritableString& aOutputString, } } } - return selection->ToString(aFormatType, aFlags, wc, aOutputString); + PRUnichar *tmp; + char *tmpformattype= ToNewCString(aFormatType);//crap copied string + if (!tmpformattype) + return NS_ERROR_NULL_POINTER; + rv = selPriv->ToStringWithFormat(tmpformattype, aFlags, wc, &tmp); + if (NS_SUCCEEDED(rv) && tmp) + { + nsMemory::Free(tmpformattype); + aOutputString.Assign(tmp); + nsMemory::Free(tmp); + } + return rv; } #if 0 @@ -5882,7 +5909,7 @@ NS_IMETHODIMP nsHTMLEditor::OutputToString(nsAWritableString& aOutputString, // Set the selection, if appropriate: if (aFlags & nsIDocumentEncoder::OutputSelectionOnly) { - nsCOMPtr selection; + nsCOMPtr selection; rv = GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(rv) && selection) encoder->SetSelection(selection); @@ -5969,7 +5996,7 @@ NS_IMETHODIMP nsHTMLEditor::OutputToStream(nsIOutputStream* aOutputStream, // Set the selection, if appropriate: if (aFlags & nsIDocumentEncoder::OutputSelectionOnly) { - nsCOMPtr selection; + nsCOMPtr selection; rv = GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(rv) && selection) encoder->SetSelection(selection); @@ -5996,7 +6023,7 @@ NS_IMETHODIMP nsHTMLEditor::OutputToStream(nsIOutputStream* aOutputStream, return encoder->EncodeToStream(aOutputStream); } -static nsresult SetSelectionAroundHeadChildren(nsCOMPtr aSelection, nsWeakPtr aDocWeak) +static nsresult SetSelectionAroundHeadChildren(nsCOMPtr aSelection, nsWeakPtr aDocWeak) { nsresult res = NS_OK; // Set selection around node @@ -6036,7 +6063,7 @@ static nsresult SetSelectionAroundHeadChildren(nsCOMPtr aSelect NS_IMETHODIMP nsHTMLEditor::GetHeadContentsAsHTML(nsString& aOutputString) { - nsCOMPtr selection; + nsCOMPtr selection; nsresult res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_NULL_POINTER; @@ -6109,7 +6136,7 @@ nsHTMLEditor::SetCompositionString(const nsString& aCompositionString, nsIPrivat return NS_OK; } - nsCOMPtr selection; + nsCOMPtr selection; nsresult result = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(result)) return result; @@ -6140,7 +6167,7 @@ nsHTMLEditor::GetReconversionString(nsReconversionEventReply* aReply) { nsresult res; - nsCOMPtr selection; + nsCOMPtr selection; res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res) || !selection) return (res == NS_OK) ? NS_ERROR_FAILURE : res; @@ -6289,7 +6316,7 @@ nsHTMLEditor::TagCanContainTag(const nsString &aParentTag, const nsString &aChil NS_IMETHODIMP -nsHTMLEditor::SelectEntireDocument(nsIDOMSelection *aSelection) +nsHTMLEditor::SelectEntireDocument(nsISelection *aSelection) { nsresult res; if (!aSelection || !mRules) { return NS_ERROR_NULL_POINTER; } @@ -6491,7 +6518,7 @@ nsHTMLEditor::SetCaretInTableCell(nsIDOMElement* aElement) } } // Set selection at beginning of deepest node - nsCOMPtr selection; + nsCOMPtr selection; res = GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(res) && selection && firstChild) { @@ -6588,7 +6615,7 @@ NS_IMETHODIMP nsHTMLEditor::DeleteSelectionAndPrepareToCreateNode(nsCOMPtr &parentSelectedNode, PRInt32& offsetOfNewNode) { nsresult result=NS_ERROR_NOT_INITIALIZED; - nsCOMPtr selection; + nsCOMPtr selection; result = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(result)) return result; if (!selection) return NS_ERROR_NULL_POINTER; @@ -6920,7 +6947,7 @@ nsHTMLEditor::GetNextElementByTagName(nsIDOMElement *aCurrentElement, } NS_IMETHODIMP -nsHTMLEditor::SetSelectionAtDocumentStart(nsIDOMSelection *aSelection) +nsHTMLEditor::SetSelectionAtDocumentStart(nsISelection *aSelection) { nsCOMPtr bodyElement; nsresult res = GetRootElement(getter_AddRefs(bodyElement)); @@ -6946,11 +6973,11 @@ nsHTMLEditor::RelativeFontChange( PRInt32 aSizeChange) ForceCompositionEnd(); // Get the selection - nsCOMPtrselection; + nsCOMPtrselection; nsresult res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_FAILURE; - + nsCOMPtr selPriv(do_QueryInterface(selection)); // Is the selection collapsed? PRBool bCollapsed; res = selection->GetIsCollapsed(&bCollapsed); @@ -6974,7 +7001,7 @@ nsHTMLEditor::RelativeFontChange( PRInt32 aSizeChange) // get selection range enumerator nsCOMPtr enumerator; - res = selection->GetEnumerator(getter_AddRefs(enumerator)); + res = selPriv->GetEnumerator(getter_AddRefs(enumerator)); if (NS_FAILED(res)) return res; if (!enumerator) return NS_ERROR_FAILURE; diff --git a/mozilla/editor/libeditor/html/nsHTMLEditor.h b/mozilla/editor/libeditor/html/nsHTMLEditor.h index 6054d93ee23..d1d0f427c75 100644 --- a/mozilla/editor/libeditor/html/nsHTMLEditor.h +++ b/mozilla/editor/libeditor/html/nsHTMLEditor.h @@ -298,7 +298,7 @@ public: virtual PRBool TagCanContainTag(const nsString &aParentTag, const nsString &aChildTag); /** make the given selection span the entire document */ - NS_IMETHOD SelectEntireDocument(nsIDOMSelection *aSelection); + NS_IMETHOD SelectEntireDocument(nsISelection *aSelection); /** join together any afjacent editable text nodes in the range */ NS_IMETHOD CollapseAdjacentTextNodes(nsIDOMRange *aInRange); @@ -312,7 +312,7 @@ public: /** returns the absolute position of the end points of aSelection * in the document as a text stream. */ - nsresult GetTextSelectionOffsets(nsIDOMSelection *aSelection, + nsresult GetTextSelectionOffsets(nsISelection *aSelection, PRInt32 &aStartOffset, PRInt32 &aEndOffset); @@ -330,7 +330,7 @@ public: // This will stop at a table, however, since we don't want to // "drill down" into nested tables. // aSelection is optional -- if null, we get current seletion - nsresult CollapseSelectionToDeepestNonTableFirstChild(nsIDOMSelection *aSelection, nsIDOMNode *aNode); + nsresult CollapseSelectionToDeepestNonTableFirstChild(nsISelection *aSelection, nsIDOMNode *aNode); nsresult IsEmptyNode(nsIDOMNode *aNode, PRBool *outIsEmptyBlock, PRBool aMozBRDoesntCount = PR_FALSE, @@ -401,7 +401,7 @@ protected: // Move all contents from aCellToMerge into aTargetCell (append at end) NS_IMETHOD MergeCells(nsCOMPtr aTargetCell, nsCOMPtr aCellToMerge, PRBool aDeleteCellToMerge); - NS_IMETHOD DeleteTable2(nsIDOMElement *aTable, nsIDOMSelection *aSelection); + NS_IMETHOD DeleteTable2(nsIDOMElement *aTable, nsISelection *aSelection); NS_IMETHOD SetColSpan(nsIDOMElement *aCell, PRInt32 aColSpan); NS_IMETHOD SetRowSpan(nsIDOMElement *aCell, PRInt32 aRowSpan); @@ -421,7 +421,7 @@ protected: // Input: *aCell is a known cell, // if null, cell is obtained from the anchor node of the selection // Returns NS_EDITOR_ELEMENT_NOT_FOUND if cell is not found even if aCell is null - NS_IMETHOD GetCellContext(nsIDOMSelection **aSelection, + NS_IMETHOD GetCellContext(nsISelection **aSelection, nsIDOMElement **aTable, nsIDOMElement **aCell, nsIDOMNode **aCellParent, PRInt32 *aCellOffset, @@ -444,7 +444,7 @@ protected: // Fallback method: Call this after using ClearSelection() and you // failed to set selection to some other content in the document - NS_IMETHOD SetSelectionAtDocumentStart(nsIDOMSelection *aSelection); + NS_IMETHOD SetSelectionAtDocumentStart(nsISelection *aSelection); // End of Table Editing utilities @@ -489,7 +489,7 @@ protected: void ResetTextSelectionForRange(nsIDOMNode *aParent, PRInt32 aStartOffset, PRInt32 aEndOffset, - nsIDOMSelection *aSelection); + nsISelection *aSelection); // Methods for handling plaintext quotations diff --git a/mozilla/editor/libeditor/html/nsHTMLEditorLog.cpp b/mozilla/editor/libeditor/html/nsHTMLEditorLog.cpp index deba9cf3348..b867a8c04c4 100644 --- a/mozilla/editor/libeditor/html/nsHTMLEditorLog.cpp +++ b/mozilla/editor/libeditor/html/nsHTMLEditorLog.cpp @@ -28,7 +28,7 @@ #include "nsIDOMNodeList.h" #include "nsIDOMCharacterData.h" #include "nsIDOMNamedNodeMap.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIDOMRange.h" #include "nsHTMLEditorLog.h" #include "nsCOMPtr.h" @@ -958,7 +958,7 @@ nsHTMLEditorLog::PrintUnicode(const nsString &aString) nsresult nsHTMLEditorLog::PrintSelection() { - nsCOMPtr selection; + nsCOMPtr selection; nsresult result; PRInt32 rangeCount; diff --git a/mozilla/editor/libeditor/html/nsTableEditor.cpp b/mozilla/editor/libeditor/html/nsTableEditor.cpp index b0c1196b610..d66d820007e 100644 --- a/mozilla/editor/libeditor/html/nsTableEditor.cpp +++ b/mozilla/editor/libeditor/html/nsTableEditor.cpp @@ -30,7 +30,8 @@ #include "nsIDOMNode.h" #include "nsIDOMNodeList.h" #include "nsIDOMRange.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" +#include "nsISelectionPrivate.h" #include "nsLayoutCID.h" #include "nsIContent.h" #include "nsIContentIterator.h" @@ -87,11 +88,13 @@ class nsSetSelectionAfterTableEdit class nsSelectionBatcher { private: - nsCOMPtr mSelection; + nsCOMPtr mSelection; public: - nsSelectionBatcher(nsIDOMSelection *aSelection) : mSelection(aSelection) + nsSelectionBatcher(nsISelection *aSelection) { - if (mSelection) mSelection->StartBatchChanges(); + nsCOMPtr sel(aSelection); + mSelection = do_QueryInterface(sel); + if (mSelection) mSelection->StartBatchChanges(); } virtual ~nsSelectionBatcher() { @@ -366,7 +369,7 @@ nsHTMLEditor::GetNextRow(nsIDOMElement* aTableElement, nsIDOMElement* &aRow) NS_IMETHODIMP nsHTMLEditor::InsertTableColumn(PRInt32 aNumber, PRBool aAfter) { - nsCOMPtr selection; + nsCOMPtr selection; nsCOMPtr table; nsCOMPtr curCell; PRInt32 startRowIndex, startColIndex; @@ -484,7 +487,7 @@ nsHTMLEditor::InsertTableColumn(PRInt32 aNumber, PRBool aAfter) NS_IMETHODIMP nsHTMLEditor::InsertTableRow(PRInt32 aNumber, PRBool aAfter) { - nsCOMPtr selection; + nsCOMPtr selection; nsCOMPtr table; nsCOMPtr curCell; PRInt32 startRowIndex, startColIndex; @@ -636,7 +639,7 @@ nsHTMLEditor::InsertTableRow(PRInt32 aNumber, PRBool aAfter) // Editor helper only NS_IMETHODIMP -nsHTMLEditor::DeleteTable2(nsIDOMElement *aTable, nsIDOMSelection *aSelection) +nsHTMLEditor::DeleteTable2(nsIDOMElement *aTable, nsISelection *aSelection) { if (!aTable || !aSelection) return NS_ERROR_NULL_POINTER; @@ -661,7 +664,7 @@ nsHTMLEditor::DeleteTable2(nsIDOMElement *aTable, nsIDOMSelection *aSelection) NS_IMETHODIMP nsHTMLEditor::DeleteTable() { - nsCOMPtr selection; + nsCOMPtr selection; nsCOMPtr table; nsresult res = GetCellContext(getter_AddRefs(selection), getter_AddRefs(table), @@ -679,7 +682,7 @@ nsHTMLEditor::DeleteTable() NS_IMETHODIMP nsHTMLEditor::DeleteTableCell(PRInt32 aNumber) { - nsCOMPtr selection; + nsCOMPtr selection; nsCOMPtr table; nsCOMPtr cell; PRInt32 startRowIndex, startColIndex; @@ -862,7 +865,7 @@ nsHTMLEditor::DeleteTableCell(PRInt32 aNumber) NS_IMETHODIMP nsHTMLEditor::DeleteTableCellContents() { - nsCOMPtr selection; + nsCOMPtr selection; nsCOMPtr table; nsCOMPtr cell; PRInt32 startRowIndex, startColIndex; @@ -940,7 +943,7 @@ nsHTMLEditor::DeleteCellContents(nsIDOMElement *aCell) NS_IMETHODIMP nsHTMLEditor::DeleteTableColumn(PRInt32 aNumber) { - nsCOMPtr selection; + nsCOMPtr selection; nsCOMPtr table; nsCOMPtr cell; PRInt32 startRowIndex, startColIndex, rowCount, colCount; @@ -1086,7 +1089,7 @@ nsHTMLEditor::DeleteColumn(nsIDOMElement *aTable, PRInt32 aColIndex) if (rowCount == 1) { - nsCOMPtr selection; + nsCOMPtr selection; res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_FAILURE; @@ -1121,7 +1124,7 @@ nsHTMLEditor::DeleteColumn(nsIDOMElement *aTable, PRInt32 aColIndex) NS_IMETHODIMP nsHTMLEditor::DeleteTableRow(PRInt32 aNumber) { - nsCOMPtr selection; + nsCOMPtr selection; nsCOMPtr table; nsCOMPtr cell; PRInt32 startRowIndex, startColIndex; @@ -1370,7 +1373,7 @@ nsHTMLEditor::SelectBlockOfCells(nsIDOMElement *aStartCell, nsIDOMElement *aEndC { if (!aStartCell || !aEndCell) return NS_ERROR_NULL_POINTER; - nsCOMPtr selection; + nsCOMPtr selection; nsresult res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_FAILURE; @@ -1398,7 +1401,7 @@ nsHTMLEditor::SelectBlockOfCells(nsIDOMElement *aStartCell, nsIDOMElement *aEndC res = GetCellIndexes(aEndCell, endRowIndex, endColIndex); if(NS_FAILED(res)) return res; - // Suppress nsIDOMSelectionListener notification + // Suppress nsISelectionListener notification // until all selection changes are finished nsSelectionBatcher selectionBatcher(selection); @@ -1478,12 +1481,12 @@ nsHTMLEditor::SelectAllTableCells() res = GetTableSize(table, rowCount, colCount); if (NS_FAILED(res)) return res; - nsCOMPtr selection; + nsCOMPtr selection; res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_FAILURE; - // Suppress nsIDOMSelectionListener notification + // Suppress nsISelectionListener notification // until all selection changes are finished nsSelectionBatcher selectionBatcher(selection); @@ -1537,7 +1540,7 @@ nsHTMLEditor::SelectTableRow() if (!cellNode) return NS_ERROR_FAILURE; // Get table and location of cell: - nsCOMPtr selection; + nsCOMPtr selection; nsCOMPtr table; PRInt32 startRowIndex, startColIndex; @@ -1557,7 +1560,7 @@ nsHTMLEditor::SelectTableRow() // then call SelectBlockOfCells, but that would take just // a little less code, so the following is more efficient - // Suppress nsIDOMSelectionListener notification + // Suppress nsISelectionListener notification // until all selection changes are finished nsSelectionBatcher selectionBatcher(selection); @@ -1608,7 +1611,7 @@ nsHTMLEditor::SelectTableColumn() nsCOMPtr startCell = cell; // Get location of cell: - nsCOMPtr selection; + nsCOMPtr selection; nsCOMPtr table; PRInt32 startRowIndex, startColIndex; @@ -1624,7 +1627,7 @@ nsHTMLEditor::SelectTableColumn() res = GetTableSize(table, rowCount, colCount); if (NS_FAILED(res)) return res; - // Suppress nsIDOMSelectionListener notification + // Suppress nsISelectionListener notification // until all selection changes are finished nsSelectionBatcher selectionBatcher(selection); @@ -1913,7 +1916,7 @@ nsHTMLEditor::SwitchTableCellHeaderType(nsIDOMElement *aSourceCell, nsIDOMElemen // Save current selection to restore when done // This is needed so ReplaceContainer can monitor selection // when replacing nodes - nsCOMPtrselection; + nsCOMPtrselection; nsresult res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_FAILURE; @@ -2438,7 +2441,7 @@ nsHTMLEditor::FixBadColSpan(nsIDOMElement *aTable, PRInt32 aColIndex, PRInt32& a NS_IMETHODIMP nsHTMLEditor::NormalizeTable(nsIDOMElement *aTable) { - nsCOMPtrselection; + nsCOMPtrselection; nsresult res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_FAILURE; @@ -2697,7 +2700,7 @@ nsHTMLEditor::GetCellSpansAt(nsIDOMElement* aTable, PRInt32 aRowIndex, PRInt32 a } NS_IMETHODIMP -nsHTMLEditor::GetCellContext(nsIDOMSelection **aSelection, +nsHTMLEditor::GetCellContext(nsISelection **aSelection, nsIDOMElement **aTable, nsIDOMElement **aCell, nsIDOMNode **aCellParent, PRInt32 *aCellOffset, @@ -2712,7 +2715,7 @@ nsHTMLEditor::GetCellContext(nsIDOMSelection **aSelection, if (aRowIndex) *aRowIndex = 0; if (aColIndex) *aColIndex = 0; - nsCOMPtr selection; + nsCOMPtr selection; nsresult res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_FAILURE; @@ -2858,7 +2861,7 @@ nsHTMLEditor::GetFirstSelectedCell(nsIDOMElement **aCell, nsIDOMRange **aRange) *aCell = nsnull; if (aRange) *aRange = nsnull; - nsCOMPtr selection; + nsCOMPtr selection; nsresult res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_FAILURE; @@ -2898,7 +2901,7 @@ nsHTMLEditor::GetNextSelectedCell(nsIDOMElement **aCell, nsIDOMRange **aRange) *aCell = nsnull; if (aRange) *aRange = nsnull; - nsCOMPtr selection; + nsCOMPtr selection; nsresult res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_FAILURE; @@ -3013,7 +3016,7 @@ nsHTMLEditor::SetSelectionAfterTableEdit(nsIDOMElement* aTable, PRInt32 aRow, PR nsresult res = NS_ERROR_NOT_INITIALIZED; if (!aTable) return res; - nsCOMPtrselection; + nsCOMPtrselection; res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; @@ -3106,7 +3109,7 @@ nsHTMLEditor::GetSelectedOrParentTableElement(nsIDOMElement* &aTableElement, nsS aTagName.SetLength(0); aSelectedCount = 0; - nsCOMPtr selection; + nsCOMPtr selection; nsresult res = GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_FAILURE; diff --git a/mozilla/editor/libeditor/text/nsEditorEventListeners.cpp b/mozilla/editor/libeditor/text/nsEditorEventListeners.cpp index c9841b67d2c..acff9f53fd7 100644 --- a/mozilla/editor/libeditor/text/nsEditorEventListeners.cpp +++ b/mozilla/editor/libeditor/text/nsEditorEventListeners.cpp @@ -30,7 +30,7 @@ #include "nsIDocument.h" #include "nsIPresShell.h" #include "nsIDOMElement.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIDOMCharacterData.h" #include "nsIEditProperty.h" #include "nsISupportsArray.h" @@ -394,7 +394,7 @@ nsTextEditorMouseListener::MouseClick(nsIDOMEvent* aMouseEvent) if (!NS_SUCCEEDED(nsuiEvent->GetRangeOffset(&offset))) return NS_ERROR_NULL_POINTER; - nsCOMPtr selection; + nsCOMPtr selection; if (NS_SUCCEEDED(editor->GetSelection(getter_AddRefs(selection)))) (void)selection->Collapse(parent, offset); @@ -704,7 +704,7 @@ nsTextEditorDragListener::DragDrop(nsIDOMEvent* aMouseEvent) selection, nothing should happen. cmanske: But do this only if drag source is not the same as target (current) document! */ - nsCOMPtr selection; + nsCOMPtr selection; rv = mEditor->GetSelection(getter_AddRefs(selection)); if (NS_FAILED(rv) || !selection) return rv?rv:NS_ERROR_FAILURE; diff --git a/mozilla/editor/libeditor/text/nsTextEditRules.cpp b/mozilla/editor/libeditor/text/nsTextEditRules.cpp index 9a5b223232a..f7e0cb9b1cb 100644 --- a/mozilla/editor/libeditor/text/nsTextEditRules.cpp +++ b/mozilla/editor/libeditor/text/nsTextEditRules.cpp @@ -29,7 +29,8 @@ #include "nsIDOMNode.h" #include "nsIDOMElement.h" #include "nsIDOMNodeList.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" +#include "nsISelectionPrivate.h" #include "nsIDOMRange.h" #include "nsIDOMCharacterData.h" #include "nsIContent.h" @@ -107,7 +108,7 @@ nsTextEditRules::Init(nsHTMLEditor *aEditor, PRUint32 aFlags) mEditor = aEditor; // we hold a non-refcounted reference back to our editor // call SetFlags only aftet mEditor has been initialized! SetFlags(aFlags); - nsCOMPtr selection; + nsCOMPtr selection; mEditor->GetSelection(getter_AddRefs(selection)); NS_ASSERTION(selection, "editor cannot get selection"); @@ -203,7 +204,7 @@ nsTextEditRules::AfterEdit(PRInt32 action, nsIEditor::EDirection aDirection) nsresult res = NS_OK; if (!--mActionNesting) { - nsCOMPtrselection; + nsCOMPtrselection; res = mEditor->GetSelection(getter_AddRefs(selection)); if (NS_FAILED(res)) return res; @@ -219,7 +220,7 @@ nsTextEditRules::AfterEdit(PRInt32 action, nsIEditor::EDirection aDirection) NS_IMETHODIMP -nsTextEditRules::WillDoAction(nsIDOMSelection *aSelection, +nsTextEditRules::WillDoAction(nsISelection *aSelection, nsRulesInfo *aInfo, PRBool *aCancel, PRBool *aHandled) @@ -273,7 +274,7 @@ nsTextEditRules::WillDoAction(nsIDOMSelection *aSelection, } NS_IMETHODIMP -nsTextEditRules::DidDoAction(nsIDOMSelection *aSelection, +nsTextEditRules::DidDoAction(nsISelection *aSelection, nsRulesInfo *aInfo, nsresult aResult) { // dont let any txns in here move the selection around behind our back. @@ -327,7 +328,7 @@ nsTextEditRules::DocumentIsEmpty(PRBool *aDocumentIsEmpty) nsresult -nsTextEditRules::WillInsert(nsIDOMSelection *aSelection, PRBool *aCancel) +nsTextEditRules::WillInsert(nsISelection *aSelection, PRBool *aCancel) { if (!aSelection || !aCancel) return NS_ERROR_NULL_POINTER; @@ -383,7 +384,7 @@ nsTextEditRules::WillInsert(nsIDOMSelection *aSelection, PRBool *aCancel) } nsresult -nsTextEditRules::DidInsert(nsIDOMSelection *aSelection, nsresult aResult) +nsTextEditRules::DidInsert(nsISelection *aSelection, nsresult aResult) { return NS_OK; } @@ -420,7 +421,7 @@ nsTextEditRules::GetTopEnclosingPre(nsIDOMNode *aNode, } nsresult -nsTextEditRules::WillInsertBreak(nsIDOMSelection *aSelection, PRBool *aCancel, PRBool *aHandled) +nsTextEditRules::WillInsertBreak(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled) { if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; } CANCEL_OPERATION_IF_READONLY_OR_DISABLED @@ -519,7 +520,7 @@ nsTextEditRules::WillInsertBreak(nsIDOMSelection *aSelection, PRBool *aCancel, P } nsresult -nsTextEditRules::DidInsertBreak(nsIDOMSelection *aSelection, nsresult aResult) +nsTextEditRules::DidInsertBreak(nsISelection *aSelection, nsresult aResult) { // we only need to execute the stuff below if we are a plaintext editor. // html editors have a different mechanism for putting in mozBR's @@ -543,6 +544,8 @@ nsTextEditRules::DidInsertBreak(nsIDOMSelection *aSelection, nsresult aResult) if (NS_FAILED(res)) return res; if (bIsLast) { + nsCOMPtr sel(aSelection); + nsCOMPtrselPrivate(do_QueryInterface(sel)); // need to insert special moz BR. Why? Because if we don't // the user will see no new line for the break. Also, things // like table cells won't grow in height. @@ -551,7 +554,7 @@ nsTextEditRules::DidInsertBreak(nsIDOMSelection *aSelection, nsresult aResult) if (NS_FAILED(res)) return res; res = nsEditor::GetNodeLocation(brNode, &selNode, &selOffset); if (NS_FAILED(res)) return res; - aSelection->SetHint(PR_TRUE); + selPrivate->SetInterlinePosition(PR_TRUE); res = aSelection->Collapse(selNode,selOffset); if (NS_FAILED(res)) return res; } @@ -562,7 +565,7 @@ nsTextEditRules::DidInsertBreak(nsIDOMSelection *aSelection, nsresult aResult) nsresult nsTextEditRules::WillInsertText(PRInt32 aAction, - nsIDOMSelection *aSelection, + nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled, const nsString *inString, @@ -800,7 +803,7 @@ nsTextEditRules::WillInsertText(PRInt32 aAction, } nsresult -nsTextEditRules::DidInsertText(nsIDOMSelection *aSelection, +nsTextEditRules::DidInsertText(nsISelection *aSelection, nsresult aResult) { return DidInsert(aSelection, aResult); @@ -809,7 +812,7 @@ nsTextEditRules::DidInsertText(nsIDOMSelection *aSelection, nsresult -nsTextEditRules::WillSetTextProperty(nsIDOMSelection *aSelection, PRBool *aCancel, PRBool *aHandled) +nsTextEditRules::WillSetTextProperty(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled) { if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; } @@ -823,13 +826,13 @@ nsTextEditRules::WillSetTextProperty(nsIDOMSelection *aSelection, PRBool *aCance } nsresult -nsTextEditRules::DidSetTextProperty(nsIDOMSelection *aSelection, nsresult aResult) +nsTextEditRules::DidSetTextProperty(nsISelection *aSelection, nsresult aResult) { return NS_OK; } nsresult -nsTextEditRules::WillRemoveTextProperty(nsIDOMSelection *aSelection, PRBool *aCancel, PRBool *aHandled) +nsTextEditRules::WillRemoveTextProperty(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled) { if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; } @@ -843,13 +846,13 @@ nsTextEditRules::WillRemoveTextProperty(nsIDOMSelection *aSelection, PRBool *aCa } nsresult -nsTextEditRules::DidRemoveTextProperty(nsIDOMSelection *aSelection, nsresult aResult) +nsTextEditRules::DidRemoveTextProperty(nsISelection *aSelection, nsresult aResult) { return NS_OK; } nsresult -nsTextEditRules::WillDeleteSelection(nsIDOMSelection *aSelection, +nsTextEditRules::WillDeleteSelection(nsISelection *aSelection, nsIEditor::EDirection aCollapsedAction, PRBool *aCancel, PRBool *aHandled) @@ -897,7 +900,7 @@ nsTextEditRules::WillDeleteSelection(nsIDOMSelection *aSelection, // if the document is empty, insert a bogus text node with a   // if we ended up with consecutive text nodes, merge them nsresult -nsTextEditRules::DidDeleteSelection(nsIDOMSelection *aSelection, +nsTextEditRules::DidDeleteSelection(nsISelection *aSelection, nsIEditor::EDirection aCollapsedAction, nsresult aResult) { @@ -992,7 +995,7 @@ nsTextEditRules::DidDeleteSelection(nsIDOMSelection *aSelection, } nsresult -nsTextEditRules::WillUndo(nsIDOMSelection *aSelection, PRBool *aCancel, PRBool *aHandled) +nsTextEditRules::WillUndo(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled) { if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; } CANCEL_OPERATION_IF_READONLY_OR_DISABLED @@ -1008,7 +1011,7 @@ nsTextEditRules::WillUndo(nsIDOMSelection *aSelection, PRBool *aCancel, PRBool * * Since undo and redo are relatively rare, it makes sense to take the (small) performance hit here. */ nsresult -nsTextEditRules:: DidUndo(nsIDOMSelection *aSelection, nsresult aResult) +nsTextEditRules:: DidUndo(nsISelection *aSelection, nsresult aResult) { nsresult res = aResult; // if aResult is an error, we return it. if (!aSelection) { return NS_ERROR_NULL_POINTER; } @@ -1035,7 +1038,7 @@ nsTextEditRules:: DidUndo(nsIDOMSelection *aSelection, nsresult aResult) } nsresult -nsTextEditRules::WillRedo(nsIDOMSelection *aSelection, PRBool *aCancel, PRBool *aHandled) +nsTextEditRules::WillRedo(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled) { if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; } CANCEL_OPERATION_IF_READONLY_OR_DISABLED @@ -1046,7 +1049,7 @@ nsTextEditRules::WillRedo(nsIDOMSelection *aSelection, PRBool *aCancel, PRBool * } nsresult -nsTextEditRules::DidRedo(nsIDOMSelection *aSelection, nsresult aResult) +nsTextEditRules::DidRedo(nsISelection *aSelection, nsresult aResult) { nsresult res = aResult; // if aResult is an error, we return it. if (!aSelection) { return NS_ERROR_NULL_POINTER; } @@ -1084,7 +1087,7 @@ nsTextEditRules::DidRedo(nsIDOMSelection *aSelection, nsresult aResult) } nsresult -nsTextEditRules::WillOutputText(nsIDOMSelection *aSelection, +nsTextEditRules::WillOutputText(nsISelection *aSelection, const nsString *aOutputFormat, nsString *aOutString, PRBool *aCancel, @@ -1115,7 +1118,7 @@ nsTextEditRules::WillOutputText(nsIDOMSelection *aSelection, } nsresult -nsTextEditRules::DidOutputText(nsIDOMSelection *aSelection, nsresult aResult) +nsTextEditRules::DidOutputText(nsISelection *aSelection, nsresult aResult) { return NS_OK; } @@ -1217,7 +1220,7 @@ nsTextEditRules::ReplaceNewlines(nsIDOMRange *aRange) nsresult -nsTextEditRules::CreateBogusNodeIfNeeded(nsIDOMSelection *aSelection) +nsTextEditRules::CreateBogusNodeIfNeeded(nsISelection *aSelection) { if (!aSelection) { return NS_ERROR_NULL_POINTER; } if (!mEditor) { return NS_ERROR_NULL_POINTER; } @@ -1280,7 +1283,7 @@ nsTextEditRules::CreateBogusNodeIfNeeded(nsIDOMSelection *aSelection) nsresult -nsTextEditRules::TruncateInsertionIfNeeded(nsIDOMSelection *aSelection, +nsTextEditRules::TruncateInsertionIfNeeded(nsISelection *aSelection, const nsString *aInString, nsString *aOutString, PRInt32 aMaxLength) @@ -1392,7 +1395,7 @@ nsTextEditRules::DeleteEmptyTextNode(nsIDOMNode *aNode) nsresult -nsTextEditRules::AdjustSelection(nsIDOMSelection *aSelection, nsIEditor::EDirection aDirection) +nsTextEditRules::AdjustSelection(nsISelection *aSelection, nsIEditor::EDirection aDirection) { if (!aSelection) return NS_ERROR_NULL_POINTER; @@ -1439,13 +1442,16 @@ nsTextEditRules::AdjustSelection(nsIDOMSelection *aSelection, nsIEditor::EDirect { if (!nextNode || mEditor->IsBlockNode(nextNode)) { + nsCOMPtr sel(aSelection); + nsCOMPtrselPrivate(do_QueryInterface(sel)); + nsCOMPtr brNode; res = CreateMozBR(selNode, selOffset, &brNode); if (NS_FAILED(res)) return res; res = nsEditor::GetNodeLocation(brNode, &selNode, &selOffset); if (NS_FAILED(res)) return res; // selection stays *before* moz-br, sticking to it - aSelection->SetHint(PR_TRUE); + selPrivate->SetInterlinePosition(PR_TRUE); res = aSelection->Collapse(selNode,selOffset); if (NS_FAILED(res)) return res; } diff --git a/mozilla/editor/libeditor/text/nsTextEditRules.h b/mozilla/editor/libeditor/text/nsTextEditRules.h index 9c3194b5d44..def80ad9dad 100644 --- a/mozilla/editor/libeditor/text/nsTextEditRules.h +++ b/mozilla/editor/libeditor/text/nsTextEditRules.h @@ -53,8 +53,8 @@ public: NS_IMETHOD Init(nsHTMLEditor *aEditor, PRUint32 aFlags); NS_IMETHOD BeforeEdit(PRInt32 action, nsIEditor::EDirection aDirection); NS_IMETHOD AfterEdit(PRInt32 action, nsIEditor::EDirection aDirection); - NS_IMETHOD WillDoAction(nsIDOMSelection *aSelection, nsRulesInfo *aInfo, PRBool *aCancel, PRBool *aHandled); - NS_IMETHOD DidDoAction(nsIDOMSelection *aSelection, nsRulesInfo *aInfo, nsresult aResult); + NS_IMETHOD WillDoAction(nsISelection *aSelection, nsRulesInfo *aInfo, PRBool *aCancel, PRBool *aHandled); + NS_IMETHOD DidDoAction(nsISelection *aSelection, nsRulesInfo *aInfo, nsresult aResult); NS_IMETHOD GetFlags(PRUint32 *aFlags); NS_IMETHOD SetFlags(PRUint32 aFlags); NS_IMETHOD DocumentIsEmpty(PRBool *aDocumentIsEmpty); @@ -89,40 +89,40 @@ protected: // nsTextEditRules implementation methods nsresult WillInsertText( PRInt32 aAction, - nsIDOMSelection *aSelection, + nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled, const nsString *inString, nsString *outString, PRInt32 aMaxLength); - nsresult DidInsertText(nsIDOMSelection *aSelection, nsresult aResult); + nsresult DidInsertText(nsISelection *aSelection, nsresult aResult); nsresult GetTopEnclosingPre(nsIDOMNode *aNode, nsIDOMNode** aOutPreNode); - nsresult WillInsertBreak(nsIDOMSelection *aSelection, PRBool *aCancel, PRBool *aHandled); - nsresult DidInsertBreak(nsIDOMSelection *aSelection, nsresult aResult); + nsresult WillInsertBreak(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled); + nsresult DidInsertBreak(nsISelection *aSelection, nsresult aResult); - nsresult WillInsert(nsIDOMSelection *aSelection, PRBool *aCancel); - nsresult DidInsert(nsIDOMSelection *aSelection, nsresult aResult); + nsresult WillInsert(nsISelection *aSelection, PRBool *aCancel); + nsresult DidInsert(nsISelection *aSelection, nsresult aResult); - nsresult WillDeleteSelection(nsIDOMSelection *aSelection, + nsresult WillDeleteSelection(nsISelection *aSelection, nsIEditor::EDirection aCollapsedAction, PRBool *aCancel, PRBool *aHandled); - nsresult DidDeleteSelection(nsIDOMSelection *aSelection, + nsresult DidDeleteSelection(nsISelection *aSelection, nsIEditor::EDirection aCollapsedAction, nsresult aResult); - nsresult WillSetTextProperty(nsIDOMSelection *aSelection, PRBool *aCancel, PRBool *aHandled); - nsresult DidSetTextProperty(nsIDOMSelection *aSelection, nsresult aResult); + nsresult WillSetTextProperty(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled); + nsresult DidSetTextProperty(nsISelection *aSelection, nsresult aResult); - nsresult WillRemoveTextProperty(nsIDOMSelection *aSelection, PRBool *aCancel, PRBool *aHandled); - nsresult DidRemoveTextProperty(nsIDOMSelection *aSelection, nsresult aResult); + nsresult WillRemoveTextProperty(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled); + nsresult DidRemoveTextProperty(nsISelection *aSelection, nsresult aResult); - nsresult WillUndo(nsIDOMSelection *aSelection, PRBool *aCancel, PRBool *aHandled); - nsresult DidUndo(nsIDOMSelection *aSelection, nsresult aResult); + nsresult WillUndo(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled); + nsresult DidUndo(nsISelection *aSelection, nsresult aResult); - nsresult WillRedo(nsIDOMSelection *aSelection, PRBool *aCancel, PRBool *aHandled); - nsresult DidRedo(nsIDOMSelection *aSelection, nsresult aResult); + nsresult WillRedo(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled); + nsresult DidRedo(nsISelection *aSelection, nsresult aResult); /** called prior to nsIEditor::OutputToString * @param aSelection @@ -131,13 +131,13 @@ protected: * @param aOutCancel if set to PR_TRUE, the caller should cancel the operation * and use aOutText as the result. */ - nsresult WillOutputText(nsIDOMSelection *aSelection, + nsresult WillOutputText(nsISelection *aSelection, const nsString *aInFormat, nsString *aOutText, PRBool *aOutCancel, PRBool *aHandled); - nsresult DidOutputText(nsIDOMSelection *aSelection, nsresult aResult); + nsresult DidOutputText(nsISelection *aSelection, nsresult aResult); // helper functions @@ -146,11 +146,11 @@ protected: nsresult ReplaceNewlines(nsIDOMRange *aRange); /** creates a bogus text node if the document has no editable content */ - nsresult CreateBogusNodeIfNeeded(nsIDOMSelection *aSelection); + nsresult CreateBogusNodeIfNeeded(nsISelection *aSelection); /** returns a truncated insertion string if insertion would place us over aMaxLength */ - nsresult TruncateInsertionIfNeeded(nsIDOMSelection *aSelection, + nsresult TruncateInsertionIfNeeded(nsISelection *aSelection, const nsString *aInString, nsString *aOutString, PRInt32 aMaxLength); @@ -163,7 +163,7 @@ protected: PRBool DeleteEmptyTextNode(nsIDOMNode *aNode); - nsresult AdjustSelection(nsIDOMSelection *aSelection, nsIEditor::EDirection aDirection); + nsresult AdjustSelection(nsISelection *aSelection, nsIEditor::EDirection aDirection); // data members nsHTMLEditor *mEditor; // note that we do not refcount the editor diff --git a/mozilla/editor/libeditor/txtsvc/nsTSDNotifier.cpp b/mozilla/editor/libeditor/txtsvc/nsTSDNotifier.cpp index 1af8bff87f6..a5f56c707a3 100644 --- a/mozilla/editor/libeditor/txtsvc/nsTSDNotifier.cpp +++ b/mozilla/editor/libeditor/txtsvc/nsTSDNotifier.cpp @@ -209,13 +209,13 @@ nsTSDNotifier::DidDeleteText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, PR } NS_IMETHODIMP -nsTSDNotifier::WillDeleteSelection(nsIDOMSelection *aSelection) +nsTSDNotifier::WillDeleteSelection(nsISelection *aSelection) { return NS_OK; } NS_IMETHODIMP -nsTSDNotifier::DidDeleteSelection(nsIDOMSelection *aSelection) +nsTSDNotifier::DidDeleteSelection(nsISelection *aSelection) { return NS_OK; } diff --git a/mozilla/editor/libeditor/txtsvc/nsTSDNotifier.h b/mozilla/editor/libeditor/txtsvc/nsTSDNotifier.h index 86efb335374..b8df20f7d6c 100644 --- a/mozilla/editor/libeditor/txtsvc/nsTSDNotifier.h +++ b/mozilla/editor/libeditor/txtsvc/nsTSDNotifier.h @@ -80,8 +80,8 @@ public: NS_IMETHOD DidInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsString &aString, nsresult aResult); NS_IMETHOD WillDeleteText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, PRInt32 aLength); NS_IMETHOD DidDeleteText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, PRInt32 aLength, nsresult aResult); - NS_IMETHOD WillDeleteSelection(nsIDOMSelection *aSelection); - NS_IMETHOD DidDeleteSelection(nsIDOMSelection *aSelection); + NS_IMETHOD WillDeleteSelection(nsISelection *aSelection); + NS_IMETHOD DidDeleteSelection(nsISelection *aSelection); }; #endif // nsTSDNotifier_h__ diff --git a/mozilla/editor/libeditor/txtsvc/nsTextServicesDocument.cpp b/mozilla/editor/libeditor/txtsvc/nsTextServicesDocument.cpp index be360b7214b..90562216383 100644 --- a/mozilla/editor/libeditor/txtsvc/nsTextServicesDocument.cpp +++ b/mozilla/editor/libeditor/txtsvc/nsTextServicesDocument.cpp @@ -27,7 +27,7 @@ #include "nsIContentIterator.h" #include "nsIDOMNodeList.h" #include "nsIDOMRange.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIHTMLEditor.h" #include "nsTextServicesDocument.h" @@ -581,7 +581,7 @@ nsTextServicesDocument::FirstSelectedBlock(TSDBlockSelectionStatus *aSelStatus, return NS_ERROR_FAILURE; } - nsCOMPtr selection; + nsCOMPtr selection; PRBool isCollapsed = PR_FALSE; result = mSelCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection)); @@ -1089,7 +1089,7 @@ nsTextServicesDocument::LastSelectedBlock(TSDBlockSelectionStatus *aSelStatus, P return NS_ERROR_FAILURE; } - nsCOMPtr selection; + nsCOMPtr selection; PRBool isCollapsed = PR_FALSE; result = mSelCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection)); @@ -2059,7 +2059,7 @@ nsTextServicesDocument::InsertText(const nsString *aText) PRInt32 i, strLength = aText->Length(); - nsCOMPtr selection; + nsCOMPtr selection; OffsetEntry *itEntry; OffsetEntry *entry = (OffsetEntry *)mOffsetTable[mSelStartIndex]; void *node = entry->mNode; @@ -3043,7 +3043,7 @@ nsTextServicesDocument::SetSelectionInternal(PRInt32 aOffset, PRInt32 aLength, P // XXX: If we ever get a SetSelection() method in nsIEditor, we should // use it. - nsCOMPtr selection; + nsCOMPtr selection; if (aDoUpdate) { @@ -3140,7 +3140,7 @@ nsTextServicesDocument::GetSelection(nsITextServicesDocument::TSDBlockSelectionS if (mIteratorStatus == nsTextServicesDocument::eIsDone) return NS_OK; - nsCOMPtr selection; + nsCOMPtr selection; PRBool isCollapsed; result = mSelCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection)); @@ -3175,7 +3175,7 @@ nsresult nsTextServicesDocument::GetCollapsedSelection(nsITextServicesDocument::TSDBlockSelectionStatus *aSelStatus, PRInt32 *aSelOffset, PRInt32 *aSelLength) { nsresult result; - nsCOMPtr selection; + nsCOMPtr selection; result = mSelCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection)); @@ -3504,7 +3504,7 @@ nsTextServicesDocument::GetUncollapsedSelection(nsITextServicesDocument::TSDBloc { nsresult result; - nsCOMPtr selection; + nsCOMPtr selection; nsCOMPtr range; OffsetEntry *entry; diff --git a/mozilla/editor/public/nsIEditActionListener.h b/mozilla/editor/public/nsIEditActionListener.h index 8adb5a6a41d..d9c3e58d575 100644 --- a/mozilla/editor/public/nsIEditActionListener.h +++ b/mozilla/editor/public/nsIEditActionListener.h @@ -28,7 +28,7 @@ class nsIDOMNode; class nsString; class nsIDOMCharacterData; -class nsIDOMSelection; +class nsISelection; /* Editor Action Listener interface to outside world @@ -214,13 +214,13 @@ public: * Called before the editor deletes the selection. * @param aSelection The selection to be deleted */ - NS_IMETHOD WillDeleteSelection(nsIDOMSelection *aSelection)=0; + NS_IMETHOD WillDeleteSelection(nsISelection *aSelection)=0; /** * Called after the editor deletes the selection. * @param aSelection The selection, after deletion */ - NS_IMETHOD DidDeleteSelection(nsIDOMSelection *aSelection)=0; + NS_IMETHOD DidDeleteSelection(nsISelection *aSelection)=0; }; #endif //nsIEditActionListener_h__ diff --git a/mozilla/editor/public/nsIEditor.h b/mozilla/editor/public/nsIEditor.h index 7f0ae91cd83..129e27a0d7d 100644 --- a/mozilla/editor/public/nsIEditor.h +++ b/mozilla/editor/public/nsIEditor.h @@ -37,7 +37,7 @@ class nsIPresShell; class nsIDOMNode; class nsIDOMElement; class nsIDOMDocument; -class nsIDOMSelection; +class nsISelection; class nsITransaction; class nsITransactionManager; class nsIOutputStream; @@ -47,6 +47,7 @@ class nsIDocumentStateListener; class nsFileSpec; class nsISelectionController; class nsIContent; +class nsIDOMEvent; class nsIEditor : public nsISupports { @@ -122,7 +123,7 @@ public: * (or most recently had focus.) * @param aSelection [OUT] the dom interface for the selection */ - NS_IMETHOD GetSelection(nsIDOMSelection **aSelection)=0; + NS_IMETHOD GetSelection(nsISelection **aSelection)=0; /* ------------ Selected content removal -------------- */ diff --git a/mozilla/editor/public/nsIHTMLEditor.h b/mozilla/editor/public/nsIHTMLEditor.h index 7c2c109ac06..81fafac700c 100644 --- a/mozilla/editor/public/nsIHTMLEditor.h +++ b/mozilla/editor/public/nsIHTMLEditor.h @@ -277,7 +277,7 @@ public: NS_IMETHOD DeleteSelectionAndCreateNode(const nsString& aTag, nsIDOMNode ** aNewNode)=0; /* ------------ Selection manipulation -------------- */ - /* Should these be moved to nsIDOMSelection? */ + /* Should these be moved to nsISelection? */ /** Set the selection at the suppled element * diff --git a/mozilla/editor/txtsvc/src/nsTSDNotifier.cpp b/mozilla/editor/txtsvc/src/nsTSDNotifier.cpp index 1af8bff87f6..a5f56c707a3 100644 --- a/mozilla/editor/txtsvc/src/nsTSDNotifier.cpp +++ b/mozilla/editor/txtsvc/src/nsTSDNotifier.cpp @@ -209,13 +209,13 @@ nsTSDNotifier::DidDeleteText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, PR } NS_IMETHODIMP -nsTSDNotifier::WillDeleteSelection(nsIDOMSelection *aSelection) +nsTSDNotifier::WillDeleteSelection(nsISelection *aSelection) { return NS_OK; } NS_IMETHODIMP -nsTSDNotifier::DidDeleteSelection(nsIDOMSelection *aSelection) +nsTSDNotifier::DidDeleteSelection(nsISelection *aSelection) { return NS_OK; } diff --git a/mozilla/editor/txtsvc/src/nsTSDNotifier.h b/mozilla/editor/txtsvc/src/nsTSDNotifier.h index 86efb335374..b8df20f7d6c 100644 --- a/mozilla/editor/txtsvc/src/nsTSDNotifier.h +++ b/mozilla/editor/txtsvc/src/nsTSDNotifier.h @@ -80,8 +80,8 @@ public: NS_IMETHOD DidInsertText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, const nsString &aString, nsresult aResult); NS_IMETHOD WillDeleteText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, PRInt32 aLength); NS_IMETHOD DidDeleteText(nsIDOMCharacterData *aTextNode, PRInt32 aOffset, PRInt32 aLength, nsresult aResult); - NS_IMETHOD WillDeleteSelection(nsIDOMSelection *aSelection); - NS_IMETHOD DidDeleteSelection(nsIDOMSelection *aSelection); + NS_IMETHOD WillDeleteSelection(nsISelection *aSelection); + NS_IMETHOD DidDeleteSelection(nsISelection *aSelection); }; #endif // nsTSDNotifier_h__ diff --git a/mozilla/editor/txtsvc/src/nsTextServicesDocument.cpp b/mozilla/editor/txtsvc/src/nsTextServicesDocument.cpp index be360b7214b..90562216383 100644 --- a/mozilla/editor/txtsvc/src/nsTextServicesDocument.cpp +++ b/mozilla/editor/txtsvc/src/nsTextServicesDocument.cpp @@ -27,7 +27,7 @@ #include "nsIContentIterator.h" #include "nsIDOMNodeList.h" #include "nsIDOMRange.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIHTMLEditor.h" #include "nsTextServicesDocument.h" @@ -581,7 +581,7 @@ nsTextServicesDocument::FirstSelectedBlock(TSDBlockSelectionStatus *aSelStatus, return NS_ERROR_FAILURE; } - nsCOMPtr selection; + nsCOMPtr selection; PRBool isCollapsed = PR_FALSE; result = mSelCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection)); @@ -1089,7 +1089,7 @@ nsTextServicesDocument::LastSelectedBlock(TSDBlockSelectionStatus *aSelStatus, P return NS_ERROR_FAILURE; } - nsCOMPtr selection; + nsCOMPtr selection; PRBool isCollapsed = PR_FALSE; result = mSelCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection)); @@ -2059,7 +2059,7 @@ nsTextServicesDocument::InsertText(const nsString *aText) PRInt32 i, strLength = aText->Length(); - nsCOMPtr selection; + nsCOMPtr selection; OffsetEntry *itEntry; OffsetEntry *entry = (OffsetEntry *)mOffsetTable[mSelStartIndex]; void *node = entry->mNode; @@ -3043,7 +3043,7 @@ nsTextServicesDocument::SetSelectionInternal(PRInt32 aOffset, PRInt32 aLength, P // XXX: If we ever get a SetSelection() method in nsIEditor, we should // use it. - nsCOMPtr selection; + nsCOMPtr selection; if (aDoUpdate) { @@ -3140,7 +3140,7 @@ nsTextServicesDocument::GetSelection(nsITextServicesDocument::TSDBlockSelectionS if (mIteratorStatus == nsTextServicesDocument::eIsDone) return NS_OK; - nsCOMPtr selection; + nsCOMPtr selection; PRBool isCollapsed; result = mSelCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection)); @@ -3175,7 +3175,7 @@ nsresult nsTextServicesDocument::GetCollapsedSelection(nsITextServicesDocument::TSDBlockSelectionStatus *aSelStatus, PRInt32 *aSelOffset, PRInt32 *aSelLength) { nsresult result; - nsCOMPtr selection; + nsCOMPtr selection; result = mSelCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection)); @@ -3504,7 +3504,7 @@ nsTextServicesDocument::GetUncollapsedSelection(nsITextServicesDocument::TSDBloc { nsresult result; - nsCOMPtr selection; + nsCOMPtr selection; nsCOMPtr range; OffsetEntry *entry; diff --git a/mozilla/embedding/browser/activex/src/control/StdAfx.h b/mozilla/embedding/browser/activex/src/control/StdAfx.h index ea3e9ce9c29..2ef0c615b61 100644 --- a/mozilla/embedding/browser/activex/src/control/StdAfx.h +++ b/mozilla/embedding/browser/activex/src/control/StdAfx.h @@ -76,7 +76,7 @@ #include "nsIInterfaceRequestor.h" #include "nsIPresShell.h" #include "nsCOMPtr.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIPresContext.h" #include "nsIPrompt.h" diff --git a/mozilla/extensions/xmlterm/base/mozXMLTermListeners.cpp b/mozilla/extensions/xmlterm/base/mozXMLTermListeners.cpp index 6d903071ad2..60a761be553 100644 --- a/mozilla/extensions/xmlterm/base/mozXMLTermListeners.cpp +++ b/mozilla/extensions/xmlterm/base/mozXMLTermListeners.cpp @@ -241,7 +241,7 @@ mozXMLTermKeyListener::KeyPress(nsIDOMEvent* aKeyEvent) nsCOMPtr presShell; result = mXMLTerminal->GetPresShell(getter_AddRefs(presShell)); if (NS_SUCCEEDED(result) && presShell) { - nsCOMPtr selection; + nsCOMPtr selection; result = presShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection)); if (NS_SUCCEEDED(result) && selection) { @@ -637,7 +637,7 @@ mozXMLTermMouseListener::MouseClick(nsIDOMEvent* aMouseEvent) selCon = do_QueryInterface(presShell); if (!selCon) return NS_ERROR_FAILURE; - nsCOMPtr selection; + nsCOMPtr selection; result = selCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection)); diff --git a/mozilla/extensions/xmlterm/base/mozXMLTermSession.cpp b/mozilla/extensions/xmlterm/base/mozXMLTermSession.cpp index a66889c71dd..8d2092bef97 100644 --- a/mozilla/extensions/xmlterm/base/mozXMLTermSession.cpp +++ b/mozilla/extensions/xmlterm/base/mozXMLTermSession.cpp @@ -33,7 +33,7 @@ #include "nsITextContent.h" #include "nsIDOMElement.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIDOMText.h" #include "nsIDOMAttr.h" #include "nsIDOMNamedNodeMap.h" @@ -1134,7 +1134,7 @@ NS_IMETHODIMP mozXMLTermSession::Abort(mozILineTermAux* lineTermAux, selCon = do_QueryInterface(mPresShell); if (!selCon) return NS_ERROR_FAILURE; - nsCOMPtr selection; + nsCOMPtr selection; result = selCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection)); if (NS_SUCCEEDED(result) && selection) { @@ -1177,7 +1177,7 @@ NS_IMETHODIMP mozXMLTermSession::DisplayInput(const nsString& aString, selCon = do_QueryInterface(mPresShell); if (!selCon) return NS_ERROR_FAILURE; - nsCOMPtr selection; + nsCOMPtr selection; result = selCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection)); @@ -2245,7 +2245,7 @@ NS_IMETHODIMP mozXMLTermSession::AppendLineLS(const nsString& aString, nsCRT::free(temCString); // Get selection - nsCOMPtr selection; + nsCOMPtr selection; nsCOMPtr selCon; selCon = do_QueryInterface(mPresShell); @@ -2836,7 +2836,7 @@ void mozXMLTermSession::PositionOutputCursor(mozILineTermAux* lineTermAux) } // Get selection - nsCOMPtr selection; + nsCOMPtr selection; nsCOMPtr selCon; selCon = do_QueryInterface(mPresShell); @@ -3412,7 +3412,7 @@ NS_IMETHODIMP mozXMLTermSession::PositionScreenCursor(PRInt32 aRow, } // Get selection - nsCOMPtr selection; + nsCOMPtr selection; nsCOMPtr selCon; selCon = do_QueryInterface(mPresShell); diff --git a/mozilla/extensions/xmlterm/base/mozXMLTermShell.cpp b/mozilla/extensions/xmlterm/base/mozXMLTermShell.cpp index 66a95e9611e..1251a01bdda 100644 --- a/mozilla/extensions/xmlterm/base/mozXMLTermShell.cpp +++ b/mozilla/extensions/xmlterm/base/mozXMLTermShell.cpp @@ -45,7 +45,7 @@ #include "nsAppShellCIDs.h" #include "nsIDOMDocument.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIDOMWindowInternal.h" #include "mozXMLT.h" diff --git a/mozilla/extensions/xmlterm/base/mozXMLTerminal.cpp b/mozilla/extensions/xmlterm/base/mozXMLTerminal.cpp index 8def8926159..3a32e453cc0 100644 --- a/mozilla/extensions/xmlterm/base/mozXMLTerminal.cpp +++ b/mozilla/extensions/xmlterm/base/mozXMLTerminal.cpp @@ -722,7 +722,7 @@ NS_IMETHODIMP mozXMLTerminal::ShowCaret(void) nsCOMPtr selCon = do_QueryInterface(mPresShell); if (selCon) { - nsCOMPtr sel; + nsCOMPtr sel; if (NS_SUCCEEDED(selCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(sel))) && sel) { caret->SetCaretDOMSelection(sel); diff --git a/mozilla/layout/base/nsAutoCopy.cpp b/mozilla/layout/base/nsAutoCopy.cpp index aad12121e46..dc0b6921cf4 100644 --- a/mozilla/layout/base/nsAutoCopy.cpp +++ b/mozilla/layout/base/nsAutoCopy.cpp @@ -25,8 +25,9 @@ #include "nsIServiceManager.h" #include "nsIAutoCopy.h" -#include "nsIDOMSelection.h" -#include "nsIDOMSelectionListener.h" +#include "nsISelection.h" +#include "nsISelectionPrivate.h" +#include "nsISelectionListener.h" #include "nsWidgetsCID.h" #include "nsIClipboard.h" #include "nsIDOMDocument.h" @@ -34,7 +35,7 @@ #include "nsIDocument.h" #include "nsSupportsPrimitives.h" -class nsAutoCopyService : public nsIAutoCopyService , public nsIDOMSelectionListener +class nsAutoCopyService : public nsIAutoCopyService , public nsISelectionListener { public: NS_DECL_ISUPPORTS @@ -43,12 +44,12 @@ public: virtual ~nsAutoCopyService(){}//someday maybe we have it able to shutdown during run //nsIAutoCopyService interfaces - NS_IMETHOD Listen(nsIDOMSelection *aDomSelection); + NS_IMETHOD Listen(nsISelection *aDomSelection); //end nsIAutoCopyService - //nsIDOMSelectionListener interfaces - NS_IMETHOD NotifySelectionChanged(nsIDOMDocument *aDoc, nsIDOMSelection *aSel, short aReason); - //end nsIDOMSelectionListener + //nsISelectionListener interfaces + NS_IMETHOD NotifySelectionChanged(nsIDOMDocument *aDoc, nsISelection *aSel, short aReason); + //end nsISelectionListener protected: nsCOMPtr mClipboard; nsCOMPtr mXIF; @@ -57,7 +58,7 @@ protected: }; // Implement our nsISupports methods -NS_IMPL_ISUPPORTS2(nsAutoCopyService, nsIAutoCopyService,nsIDOMSelectionListener) +NS_IMPL_ISUPPORTS2(nsAutoCopyService, nsIAutoCopyService,nsISelectionListener) nsresult NS_NewAutoCopyService(nsIAutoCopyService** aResult) @@ -75,9 +76,13 @@ nsAutoCopyService::nsAutoCopyService() } NS_IMETHODIMP -nsAutoCopyService::Listen(nsIDOMSelection *aDomSelection) +nsAutoCopyService::Listen(nsISelection *aDomSelection) { - return aDomSelection->AddSelectionListener(this); + if (!aDomSelection) + return NS_ERROR_NULL_POINTER; + nsCOMPtr selection(aDomSelection); + nsCOMPtr selectionPrivate(do_QueryInterface(selection)); + return selectionPrivate->AddSelectionListener(this); } @@ -91,7 +96,7 @@ nsAutoCopyService::Listen(nsIDOMSelection *aDomSelection) * What we should do, to make our end of the deal faster: * Create a singleton transferable with our own magic converter. When selection * changes (use a quick cache to detect ``real'' changes), we put the new - * nsIDOMSelection in the transferable. Our magic converter will take care of + * nsISelection in the transferable. Our magic converter will take care of * transferable->XIF->whatever-other-format when the time comes to actually * hand over the clipboard contents. * @@ -111,7 +116,7 @@ nsAutoCopyService::Listen(nsIDOMSelection *aDomSelection) #define DRAGGING 1 NS_IMETHODIMP -nsAutoCopyService::NotifySelectionChanged(nsIDOMDocument *aDoc, nsIDOMSelection *aSel, short aReason) +nsAutoCopyService::NotifySelectionChanged(nsIDOMDocument *aDoc, nsISelection *aSel, short aReason) { nsresult rv; @@ -121,7 +126,7 @@ nsAutoCopyService::NotifySelectionChanged(nsIDOMDocument *aDoc, nsIDOMSelection if (NS_FAILED(rv)) return rv; } - if (!(aReason & nsIDOMSelectionListener::MOUSEUP_REASON)) + if (!(aReason & nsISelectionListener::MOUSEUP_REASON)) return NS_OK;//dont care if we are still dragging. or if its not from a mouseup PRBool collapsed; if (!aDoc || !aSel || NS_FAILED(aSel->GetIsCollapsed(&collapsed)) || collapsed) { diff --git a/mozilla/layout/base/nsCaret.cpp b/mozilla/layout/base/nsCaret.cpp index 33e5dca4d1d..b8830a1ccfb 100644 --- a/mozilla/layout/base/nsCaret.cpp +++ b/mozilla/layout/base/nsCaret.cpp @@ -32,7 +32,8 @@ #include "nsIFrame.h" #include "nsIDOMNode.h" #include "nsIDOMRange.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" +#include "nsISelectionPrivate.h" #include "nsIDOMCharacterData.h" #include "nsIContent.h" #include "nsIPresShell.h" @@ -105,13 +106,16 @@ NS_IMETHODIMP nsCaret::Init(nsIPresShell *inPresShell) // get the selection from the pres shell, and set ourselves up as a selection // listener - nsCOMPtr domSelection; + + nsCOMPtr domSelection; + nsCOMPtr privateSelection; nsCOMPtr selCon = do_QueryReferent(mPresShell); if (selCon) { if (NS_SUCCEEDED(selCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(domSelection)))) { - domSelection->AddSelectionListener(this); + privateSelection = do_QueryInterface(domSelection); + privateSelection->AddSelectionListener(this); mDomSelectionWeak = getter_AddRefs( NS_GetWeakReference(domSelection) ); } } @@ -138,6 +142,7 @@ NS_IMPL_RELEASE(nsCaret); NS_IMETHODIMP nsCaret::QueryInterface(const nsIID& aIID, void** aInstancePtrResult) { + NS_PRECONDITION(aInstancePtrResult, "null pointer"); if (!aInstancePtrResult) return NS_ERROR_NULL_POINTER; @@ -148,8 +153,8 @@ NS_IMETHODIMP nsCaret::QueryInterface(const nsIID& aIID, foundInterface = (nsISupports*)(nsICaret*)this; // whoo boy else if (aIID.Equals(NS_GET_IID(nsICaret))) foundInterface = (nsICaret*)this; - else if (aIID.Equals(NS_GET_IID(nsIDOMSelectionListener))) - foundInterface = (nsIDOMSelectionListener*)this; + else if (aIID.Equals(NS_GET_IID(nsISelectionListener))) + foundInterface = (nsISelectionListener*)this; else foundInterface = nsnull; @@ -167,7 +172,7 @@ NS_IMETHODIMP nsCaret::QueryInterface(const nsIID& aIID, } //----------------------------------------------------------------------------- -NS_IMETHODIMP nsCaret::SetCaretDOMSelection(nsIDOMSelection *aDOMSel) +NS_IMETHODIMP nsCaret::SetCaretDOMSelection(nsISelection *aDOMSel) { NS_ENSURE_ARG_POINTER(aDOMSel); mDomSelectionWeak = getter_AddRefs( NS_GetWeakReference(aDOMSel) ); // weak reference to pres shell @@ -205,14 +210,15 @@ NS_IMETHODIMP nsCaret::SetCaretReadOnly(PRBool inMakeReadonly) //----------------------------------------------------------------------------- -NS_IMETHODIMP nsCaret::GetWindowRelativeCoordinates(nsRect& outCoordinates, PRBool& outIsCollapsed, nsIDOMSelection *aDOMSel) +NS_IMETHODIMP nsCaret::GetWindowRelativeCoordinates(nsRect& outCoordinates, PRBool& outIsCollapsed, nsISelection *aDOMSel) { if (!mPresShell) return NS_ERROR_NOT_INITIALIZED; mDomSelectionWeak = getter_AddRefs( NS_GetWeakReference(aDOMSel) ); // weak reference to pres shell - - nsCOMPtr domSelection = aDOMSel; + + nsCOMPtr domSelection = aDOMSel; + nsCOMPtr privateSelection(do_QueryInterface(domSelection)); nsresult err; if (!domSelection) return NS_ERROR_NOT_INITIALIZED; // no selection @@ -268,7 +274,7 @@ NS_IMETHODIMP nsCaret::GetWindowRelativeCoordinates(nsRect& outCoordinates, PRBo nsIFrame* theFrame = nsnull; PRInt32 theFrameOffset = 0; PRBool hintRight; - domSelection->GetHint(&hintRight);//translate hint. + privateSelection->GetInterlinePosition(&hintRight);//translate hint. nsIFrameSelection::HINT hint; if (hintRight) hint = nsIFrameSelection::HINTRIGHT; @@ -357,13 +363,13 @@ NS_IMETHODIMP nsCaret::EraseCaret() #endif //----------------------------------------------------------------------------- -NS_IMETHODIMP nsCaret::NotifySelectionChanged(nsIDOMDocument *, nsIDOMSelection *aDomSel, short aReason) +NS_IMETHODIMP nsCaret::NotifySelectionChanged(nsIDOMDocument *, nsISelection *aDomSel, short aReason) { - if (aReason & nsIDOMSelectionListener::MOUSEUP_REASON)//this wont do + if (aReason & nsISelectionListener::MOUSEUP_REASON)//this wont do return NS_OK; - if (mVisible) - StopBlinking(); - nsCOMPtr domSel(do_QueryReferent(mDomSelectionWeak)); + if (mVisible) + StopBlinking(); + nsCOMPtr domSel(do_QueryReferent(mDomSelectionWeak)); if (domSel.get() != aDomSel) return NS_OK; //ignore this then. if (mVisible) @@ -439,8 +445,10 @@ PRBool nsCaret::SetupDrawingFrameAndOffset() { if (!mDomSelectionWeak) return PR_FALSE; + - nsCOMPtr domSelection = do_QueryReferent(mDomSelectionWeak); + nsCOMPtr domSelection = do_QueryReferent(mDomSelectionWeak); + nsCOMPtr privateSelection(do_QueryInterface(domSelection)); if (!domSelection) return PR_FALSE; PRBool isCollapsed = PR_FALSE; @@ -470,7 +478,7 @@ PRBool nsCaret::SetupDrawingFrameAndOffset() return PR_FALSE; PRBool hintRight; - domSelection->GetHint(&hintRight);//translate hint. + privateSelection->GetInterlinePosition(&hintRight);//translate hint. nsIFrameSelection::HINT hint; hint = (hintRight) ? nsIFrameSelection::HINTRIGHT : nsIFrameSelection::HINTLEFT; @@ -634,10 +642,10 @@ void nsCaret::GetViewForRendering(nsIFrame *caretFrame, EViewCoordinates coordTy ----------------------------------------------------------------------------- */ PRBool nsCaret::MustDrawCaret() { - if (mDrawn) - return PR_TRUE; - - nsCOMPtr domSelection = do_QueryReferent(mDomSelectionWeak); + if (mDrawn) + return PR_TRUE; + + nsCOMPtr domSelection = do_QueryReferent(mDomSelectionWeak); if (!domSelection) return PR_FALSE; PRBool isCollapsed; diff --git a/mozilla/layout/base/nsCaret.h b/mozilla/layout/base/nsCaret.h index bb3c48dd20c..a95f9fb48b8 100644 --- a/mozilla/layout/base/nsCaret.h +++ b/mozilla/layout/base/nsCaret.h @@ -23,7 +23,7 @@ #include "nsCoord.h" -#include "nsIDOMSelectionListener.h" +#include "nsISelectionListener.h" #include "nsIRenderingContext.h" #include "nsITimer.h" #include "nsICaret.h" @@ -40,7 +40,7 @@ class nsISelectionController; //----------------------------------------------------------------------------- class nsCaret : public nsICaret, - public nsIDOMSelectionListener + public nsISelectionListener { public: @@ -54,17 +54,18 @@ class nsCaret : public nsICaret, // nsICaret interface NS_IMETHOD Init(nsIPresShell *inPresShell); - NS_IMETHOD SetCaretDOMSelection(nsIDOMSelection *inDOMSel); + NS_IMETHOD SetCaretDOMSelection(nsISelection *inDOMSel); NS_IMETHOD GetCaretVisible(PRBool *outMakeVisible); - NS_IMETHOD SetCaretVisible(PRBool intMakeVisible); - NS_IMETHOD SetCaretReadOnly(PRBool inMakeReadonly); - NS_IMETHOD GetWindowRelativeCoordinates(nsRect& outCoordinates, PRBool& outIsCollapsed, nsIDOMSelection *inDOMSel); - NS_IMETHOD ClearFrameRefs(nsIFrame* aFrame); - NS_IMETHOD EraseCaret(); + NS_IMETHOD SetCaretVisible(PRBool intMakeVisible); + NS_IMETHOD SetCaretReadOnly(PRBool inMakeReadonly); + NS_IMETHOD GetWindowRelativeCoordinates(nsRect& outCoordinates, PRBool& outIsCollapsed, nsISelection *inDOMSel); + NS_IMETHOD ClearFrameRefs(nsIFrame* aFrame); + NS_IMETHOD EraseCaret(); + NS_IMETHOD SetCaretWidth(nscoord aPixels); - - //nsIDOMSelectionListener interface - NS_IMETHOD NotifySelectionChanged(nsIDOMDocument *aDoc, nsIDOMSelection *aSel, short aReason); + + //nsISelectionListener interface + NS_IMETHOD NotifySelectionChanged(nsIDOMDocument *aDoc, nsISelection *aSel, short aReason); static void CaretBlinkCallback(nsITimer *aTimer, void *aClosure); diff --git a/mozilla/layout/base/nsDocumentViewer.cpp b/mozilla/layout/base/nsDocumentViewer.cpp index 7fd25959c26..3f6fb61b67f 100644 --- a/mozilla/layout/base/nsDocumentViewer.cpp +++ b/mozilla/layout/base/nsDocumentViewer.cpp @@ -45,7 +45,8 @@ #include "nsIScriptGlobalObject.h" #include "nsILinkHandler.h" #include "nsIDOMDocument.h" -#include "nsIDOMSelectionListener.h" +#include "nsISelectionListener.h" +#include "nsISelectionPrivate.h" #include "nsIDOMHTMLDocument.h" #include "nsIDOMHTMLElement.h" #include "nsIDOMRange.h" @@ -106,16 +107,15 @@ class DocumentViewerImpl; #pragma mark ** nsDocViwerSelectionListener ** #endif -class nsDocViwerSelectionListener : public nsIDOMSelectionListener +class nsDocViwerSelectionListener : public nsISelectionListener { public: // nsISupports interface... NS_DECL_ISUPPORTS - // nsIDOMSelectionListerner interface - NS_DECL_IDOMSELECTIONLISTENER - + // nsISelectionListerner interface + NS_DECL_NSISELECTIONLISTENER nsDocViwerSelectionListener() : mDocViewer(NULL) @@ -245,7 +245,7 @@ private: nsresult MakeWindow(nsIWidget* aParentWidget, const nsRect& aBounds); - nsresult GetDocumentSelection(nsIDOMSelection **aSelection); + nsresult GetDocumentSelection(nsISelection **aSelection); // // The following three methods are used for printing... @@ -279,7 +279,7 @@ protected: nsCOMPtr mUAStyleSheet; - nsCOMPtr mSelectionListener; + nsCOMPtr mSelectionListener; nsCOMPtr mFocusListener; PRBool mEnableRendering; @@ -436,12 +436,13 @@ DocumentViewerImpl::~DocumentViewerImpl() if (mPresShell) { // Break circular reference (or something) mPresShell->EndObservingDocument(); - nsCOMPtr selection; + nsCOMPtr selection; rv = GetDocumentSelection(getter_AddRefs(selection)); - if (NS_FAILED(rv) || !selection) + nsCOMPtr selPrivate(do_QueryInterface(selection)); + if (NS_FAILED(rv) || !selPrivate) return; if (mSelectionListener) - selection->RemoveSelectionListener(mSelectionListener); + selPrivate->RemoveSelectionListener(mSelectionListener); } } @@ -592,15 +593,16 @@ DocumentViewerImpl::Init(nsIWidget* aParentWidget, // this is the owning reference. The nsCOMPtr will take care of releasing // our ref to the listener on destruction. NS_ADDREF(selectionListener); - rv = selectionListener->QueryInterface(NS_GET_IID(nsIDOMSelectionListener), getter_AddRefs(mSelectionListener)); + rv = selectionListener->QueryInterface(NS_GET_IID(nsISelectionListener), getter_AddRefs(mSelectionListener)); NS_RELEASE(selectionListener); if (NS_FAILED(rv)) return rv; - nsCOMPtr selection; + nsCOMPtr selection; rv = GetDocumentSelection(getter_AddRefs(selection)); if (NS_FAILED(rv)) return rv; - rv = selection->AddSelectionListener(mSelectionListener); + nsCOMPtr selPrivate(do_QueryInterface(selection)); + rv = selPrivate->AddSelectionListener(mSelectionListener); if (NS_FAILED(rv)) return rv; //focus listener @@ -1194,7 +1196,7 @@ DocumentViewerImpl::MakeWindow(nsIWidget* aParentWidget, return rv; } -nsresult DocumentViewerImpl::GetDocumentSelection(nsIDOMSelection **aSelection) +nsresult DocumentViewerImpl::GetDocumentSelection(nsISelection **aSelection) { if (!aSelection) return NS_ERROR_NULL_POINTER; if (!mPresShell) return NS_ERROR_NOT_INITIALIZED; @@ -1338,7 +1340,7 @@ NS_IMETHODIMP DocumentViewerImpl::SelectAll() // XXX this is a temporary implementation copied from nsWebShell // for now. I think nsDocument and friends should have some helper // functions to make this easier. - nsCOMPtr selection; + nsCOMPtr selection; nsresult rv; rv = GetDocumentSelection(getter_AddRefs(selection)); if (NS_FAILED(rv)) return rv; @@ -1361,7 +1363,7 @@ NS_IMETHODIMP DocumentViewerImpl::SelectAll() } if (!bodyNode) return NS_ERROR_FAILURE; - rv = selection->ClearSelection(); + rv = selection->RemoveAllRanges(); if (NS_FAILED(rv)) return rv; static NS_DEFINE_CID(kCDOMRangeCID, NS_RANGE_CID); @@ -1385,7 +1387,7 @@ NS_IMETHODIMP DocumentViewerImpl::CopySelection() NS_IMETHODIMP DocumentViewerImpl::GetCopyable(PRBool *aCopyable) { - nsCOMPtr selection; + nsCOMPtr selection; nsresult rv; rv = GetDocumentSelection(getter_AddRefs(selection)); if (NS_FAILED(rv)) return rv; @@ -1922,7 +1924,7 @@ NS_IMETHODIMP DocumentViewerImpl::SizeToContent() #pragma mark - #endif -NS_IMPL_ISUPPORTS(nsDocViwerSelectionListener, NS_GET_IID(nsIDOMSelectionListener)); +NS_IMPL_ISUPPORTS(nsDocViwerSelectionListener, NS_GET_IID(nsISelectionListener)); nsresult nsDocViwerSelectionListener::Init(DocumentViewerImpl *aDocViewer) { @@ -1931,12 +1933,12 @@ nsresult nsDocViwerSelectionListener::Init(DocumentViewerImpl *aDocViewer) } -NS_IMETHODIMP nsDocViwerSelectionListener::NotifySelectionChanged(nsIDOMDocument *, nsIDOMSelection *, short) +NS_IMETHODIMP nsDocViwerSelectionListener::NotifySelectionChanged(nsIDOMDocument *, nsISelection *, short) { NS_ASSERTION(mDocViewer, "Should have doc viewer!"); // get the selection state - nsCOMPtr selection; + nsCOMPtr selection; nsresult rv = mDocViewer->GetDocumentSelection(getter_AddRefs(selection)); if (NS_FAILED(rv)) return rv; diff --git a/mozilla/layout/base/nsIAutoCopy.h b/mozilla/layout/base/nsIAutoCopy.h index 9beaa46d8bd..906744006be 100644 --- a/mozilla/layout/base/nsIAutoCopy.h +++ b/mozilla/layout/base/nsIAutoCopy.h @@ -31,7 +31,7 @@ { 0x558b93cd, 0x95c1, 0x417d, { 0xa6, 0x6e, 0xf9, 0xca, 0x66, 0xdc, 0x98, 0xa8 } } -class nsIDOMSelection; +class nsISelection; class nsIAutoCopyService : public nsISupports { @@ -39,7 +39,7 @@ public: static const nsIID& GetIID() { static nsIID iid = NS_IAUTOCOPYSERVICE_IID; return iid; } //This will add this service as a selection listener. - NS_IMETHOD Listen(nsIDOMSelection *aDomSelection)=0; + NS_IMETHOD Listen(nsISelection *aDomSelection)=0; }; diff --git a/mozilla/layout/base/nsICaret.h b/mozilla/layout/base/nsICaret.h index 3919fd9f1f3..b1b550b1937 100644 --- a/mozilla/layout/base/nsICaret.h +++ b/mozilla/layout/base/nsICaret.h @@ -44,7 +44,7 @@ public: NS_IMETHOD Init(nsIPresShell *inPresShell) = 0; - NS_IMETHOD SetCaretDOMSelection(nsIDOMSelection *aDOMSel) = 0; + NS_IMETHOD SetCaretDOMSelection(nsISelection *aDOMSel) = 0; /** SetCaretVisible will set the visibility of the caret * @param inMakeVisible PR_TRUE to show the caret, PR_FALSE to hide it @@ -69,7 +69,7 @@ public: * If the selection is not collapsed, this returns the location of the focus pos, * and false in outIsCollapsed. */ - NS_IMETHOD GetWindowRelativeCoordinates(nsRect& outCoordinates, PRBool& outIsCollapsed, nsIDOMSelection *aDOMSel) = 0; + NS_IMETHOD GetWindowRelativeCoordinates(nsRect& outCoordinates, PRBool& outIsCollapsed, nsISelection *aDOMSel) = 0; /** ClearFrameRefs * The caret stores a reference to the frame that the caret was last drawn in. diff --git a/mozilla/layout/base/nsIFrameSelection.h b/mozilla/layout/base/nsIFrameSelection.h index a0b4db61ee4..7fe4b869e0b 100644 --- a/mozilla/layout/base/nsIFrameSelection.h +++ b/mozilla/layout/base/nsIFrameSelection.h @@ -24,7 +24,7 @@ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! * NOTE!! This is not a general class, but specific to layout and frames. * Consumers looking for the general selection interface should look at - * nsIDOMSelection. + * nsISelection. */ #ifndef nsIFrameSelection_h___ @@ -33,7 +33,7 @@ #include "nsISupports.h" #include "nsIFrame.h" #include "nsIFocusTracker.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIPresShell.h" #include "nsIContent.h" #include "nsCOMPtr.h" @@ -244,9 +244,9 @@ public: /** GetSelection * no query interface for selection. must use this method now. - * @param aSelectionType enum value defined in nsIDOMSelection for the domseleciton you want. + * @param aSelectionType enum value defined in nsISelection for the seleciton you want. */ - NS_IMETHOD GetSelection(SelectionType aSelectionType, nsIDOMSelection **aDomSelection)=0; + NS_IMETHOD GetSelection(SelectionType aSelectionType, nsISelection **aSelection)=0; /** * ScrollSelectionIntoView scrolls a region of the selection, @@ -259,7 +259,7 @@ public: /** RepaintSelection repaints the selected frames that are inside the selection * specified by aSelectionType. - * @param aSelectionType enum value defined in nsIDOMSelection for the domseleciton you want. + * @param aSelectionType enum value defined in nsISelection for the seleciton you want. */ NS_IMETHOD RepaintSelection(nsIPresContext* aPresContext, SelectionType aSelectionType)=0; diff --git a/mozilla/layout/base/nsIPresShell.h b/mozilla/layout/base/nsIPresShell.h index 9333caeecdc..3ae40b68484 100644 --- a/mozilla/layout/base/nsIPresShell.h +++ b/mozilla/layout/base/nsIPresShell.h @@ -39,7 +39,7 @@ #include "nslayout.h" #include "nsISupports.h" #include "nsCoord.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIReflowCommand.h" #include "nsGUIEvent.h" diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index 58abb88329e..ee8c92ea626 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -61,13 +61,14 @@ #include "nsIEventStateManager.h" #include "nsDOMEvent.h" #include "nsHTMLParts.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsISelectionController.h" #include "nsLayoutCID.h" #include "nsLayoutAtoms.h" #include "nsIDOMRange.h" #include "nsIDOMDocument.h" #include "nsIDOMNode.h" +#include "nsIDOMNodeList.h" #include "nsIDOMElement.h" #include "nsHTMLAtoms.h" #include "nsCOMPtr.h" @@ -745,7 +746,7 @@ public: NS_IMETHOD SetDisplaySelection(PRInt16 aToggle); NS_IMETHOD GetDisplaySelection(PRInt16 *aToggle); - NS_IMETHOD GetSelection(SelectionType aType, nsIDOMSelection** aSelection); + NS_IMETHOD GetSelection(SelectionType aType, nsISelection** aSelection); NS_IMETHOD ScrollSelectionIntoView(SelectionType aType, SelectionRegion aRegion); NS_IMETHOD RepaintSelection(SelectionType aType); NS_IMETHOD GetFrameSelection(nsIFrameSelection** aSelection); @@ -1597,7 +1598,7 @@ PresShell::GetDisplaySelection(PRInt16 *aToggle) } NS_IMETHODIMP -PresShell::GetSelection(SelectionType aType, nsIDOMSelection **aSelection) +PresShell::GetSelection(SelectionType aType, nsISelection **aSelection) { if (!aSelection || !mSelection) return NS_ERROR_NULL_POINTER; @@ -1651,7 +1652,7 @@ PresShell::EndObservingDocument() mDocument->RemoveObserver(this); } if (mSelection){ - nsCOMPtr domselection; + nsCOMPtr domselection; nsresult result; result = mSelection->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(domselection)); if (NS_FAILED(result)) @@ -2334,7 +2335,50 @@ PresShell::CompleteScroll(PRBool aForward) NS_IMETHODIMP PresShell::CompleteMove(PRBool aForward, PRBool aExtend) { - return CompleteScroll(aForward); + nsCOMPtr document; + if (NS_FAILED(GetDocument(getter_AddRefs(document))) || !document) + return NS_ERROR_FAILURE; + + nsCOMPtrnodeList; + nsAutoString bodyTag; bodyTag.AssignWithConversion("body"); + + nsCOMPtr doc = do_QueryInterface(document); + if (!doc) + return NS_ERROR_FAILURE; + nsresult result = doc->GetElementsByTagName(bodyTag, getter_AddRefs(nodeList)); + + if (NS_FAILED(result) || !nodeList) + return result?result:NS_ERROR_NULL_POINTER; + + PRUint32 count; + nodeList->GetLength(&count); + + if (count < 1) + return NS_ERROR_FAILURE; + + // Use the first body node in the list: + nsCOMPtr node; + result = nodeList->Item(0, getter_AddRefs(node)); + if (NS_SUCCEEDED(result) && node) + { + //return node->QueryInterface(NS_GET_IID(nsIDOMElement), (void **)aBodyElement); + // Is above equivalent to this: + nsCOMPtr bodyElement = do_QueryInterface(node); + if (bodyElement) + { + nsCOMPtr bodyContent = do_QueryInterface(bodyElement); + if (bodyContent) + { + PRInt32 offset = 0; + if (aForward) + { + bodyContent->ChildCount(offset); + } + result = mSelection->HandleClick(bodyContent,offset,offset,aExtend, PR_FALSE,aExtend); + } + } + } + return result; } NS_IMETHODIMP @@ -3020,7 +3064,7 @@ PresShell::DoCopy() nsString buffer; nsresult rv; - nsCOMPtr sel; + nsCOMPtr sel; nsCOMPtr manager; nsCOMPtr content; diff --git a/mozilla/layout/base/public/Makefile.in b/mozilla/layout/base/public/Makefile.in index 27c6a472b11..b3be300cbee 100644 --- a/mozilla/layout/base/public/Makefile.in +++ b/mozilla/layout/base/public/Makefile.in @@ -95,6 +95,8 @@ XPIDLSRCS = \ nsIChromeEventHandler.idl \ nsIContentPolicy.idl \ nsISelectionController.idl \ + nsISelectionListener.idl \ + nsISelection.idl \ nsIPrintListener.idl \ $(NULL) diff --git a/mozilla/layout/base/public/makefile.win b/mozilla/layout/base/public/makefile.win index eb93e7c27e6..20523ca0dfc 100644 --- a/mozilla/layout/base/public/makefile.win +++ b/mozilla/layout/base/public/makefile.win @@ -90,6 +90,9 @@ XPIDLSRCS= \ .\nsIChromeEventHandler.idl \ .\nsIContentPolicy.idl \ .\nsISelectionController.idl \ + .\nsISelectionListener.idl \ + .\nsISelection.idl \ + .\nsISelectionPrivate.idl \ .\nsIPrintListener.idl \ $(NULL) diff --git a/mozilla/layout/base/public/nsIAutoCopy.h b/mozilla/layout/base/public/nsIAutoCopy.h index 9beaa46d8bd..906744006be 100644 --- a/mozilla/layout/base/public/nsIAutoCopy.h +++ b/mozilla/layout/base/public/nsIAutoCopy.h @@ -31,7 +31,7 @@ { 0x558b93cd, 0x95c1, 0x417d, { 0xa6, 0x6e, 0xf9, 0xca, 0x66, 0xdc, 0x98, 0xa8 } } -class nsIDOMSelection; +class nsISelection; class nsIAutoCopyService : public nsISupports { @@ -39,7 +39,7 @@ public: static const nsIID& GetIID() { static nsIID iid = NS_IAUTOCOPYSERVICE_IID; return iid; } //This will add this service as a selection listener. - NS_IMETHOD Listen(nsIDOMSelection *aDomSelection)=0; + NS_IMETHOD Listen(nsISelection *aDomSelection)=0; }; diff --git a/mozilla/layout/base/public/nsICaret.h b/mozilla/layout/base/public/nsICaret.h index 3919fd9f1f3..b1b550b1937 100644 --- a/mozilla/layout/base/public/nsICaret.h +++ b/mozilla/layout/base/public/nsICaret.h @@ -44,7 +44,7 @@ public: NS_IMETHOD Init(nsIPresShell *inPresShell) = 0; - NS_IMETHOD SetCaretDOMSelection(nsIDOMSelection *aDOMSel) = 0; + NS_IMETHOD SetCaretDOMSelection(nsISelection *aDOMSel) = 0; /** SetCaretVisible will set the visibility of the caret * @param inMakeVisible PR_TRUE to show the caret, PR_FALSE to hide it @@ -69,7 +69,7 @@ public: * If the selection is not collapsed, this returns the location of the focus pos, * and false in outIsCollapsed. */ - NS_IMETHOD GetWindowRelativeCoordinates(nsRect& outCoordinates, PRBool& outIsCollapsed, nsIDOMSelection *aDOMSel) = 0; + NS_IMETHOD GetWindowRelativeCoordinates(nsRect& outCoordinates, PRBool& outIsCollapsed, nsISelection *aDOMSel) = 0; /** ClearFrameRefs * The caret stores a reference to the frame that the caret was last drawn in. diff --git a/mozilla/layout/base/public/nsIDocument.h b/mozilla/layout/base/public/nsIDocument.h index 94c446f6de4..7763cf76ad0 100644 --- a/mozilla/layout/base/public/nsIDocument.h +++ b/mozilla/layout/base/public/nsIDocument.h @@ -54,7 +54,7 @@ class nsINameSpaceManager; class nsIDOMDocumentFragment; class nsILineBreaker; class nsIWordBreaker; -class nsIDOMSelection; +class nsISelection; class nsIChannel; class nsIPrincipal; class nsINodeInfoManager; @@ -306,14 +306,14 @@ public: * NOTE: we may way to place the result in a stream, * but we will use a string for now -- gpk */ - NS_IMETHOD CreateXIF(nsAWritableString & aBuffer, nsIDOMSelection* aSelection = nsnull) = 0; + NS_IMETHOD CreateXIF(nsAWritableString & aBuffer, nsISelection* aSelection = nsnull) = 0; NS_IMETHOD ToXIF(nsIXIFConverter * aConverter, nsIDOMNode* aNode) = 0; virtual void BeginConvertToXIF(nsIXIFConverter * aConverter, nsIDOMNode* aNode) = 0; virtual void ConvertChildrenToXIF(nsIXIFConverter * aConverter, nsIDOMNode* aNode) = 0; virtual void FinishConvertToXIF(nsIXIFConverter * aConverter, nsIDOMNode* aNode) = 0; /* Helper methods to help determine the logical positioning of content */ - virtual PRBool IsInSelection(nsIDOMSelection* aSelection, const nsIContent *aContent) const = 0; + virtual PRBool IsInSelection(nsISelection* aSelection, const nsIContent *aContent) const = 0; virtual nsIContent* GetPrevContent(const nsIContent *aContent) const = 0; virtual nsIContent* GetNextContent(const nsIContent *aContent) const = 0; diff --git a/mozilla/layout/base/public/nsIDocumentEncoder.h b/mozilla/layout/base/public/nsIDocumentEncoder.h index e1786e9a893..9037d83b4a0 100644 --- a/mozilla/layout/base/public/nsIDocumentEncoder.h +++ b/mozilla/layout/base/public/nsIDocumentEncoder.h @@ -28,7 +28,7 @@ class nsIDocumentEncoder; class nsIDocument; -class nsIDOMSelection; +class nsISelection; class nsIOutputStream; class nsISupportsArray; @@ -119,7 +119,7 @@ public: * selection is used for encoding, otherwise the entire * document is encoded. */ - NS_IMETHOD SetSelection(nsIDOMSelection* aSelection) = 0; + NS_IMETHOD SetSelection(nsISelection* aSelection) = 0; /** * Documents typically have an intrinsic character set. diff --git a/mozilla/layout/base/public/nsIFrameSelection.h b/mozilla/layout/base/public/nsIFrameSelection.h index a0b4db61ee4..7fe4b869e0b 100644 --- a/mozilla/layout/base/public/nsIFrameSelection.h +++ b/mozilla/layout/base/public/nsIFrameSelection.h @@ -24,7 +24,7 @@ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! * NOTE!! This is not a general class, but specific to layout and frames. * Consumers looking for the general selection interface should look at - * nsIDOMSelection. + * nsISelection. */ #ifndef nsIFrameSelection_h___ @@ -33,7 +33,7 @@ #include "nsISupports.h" #include "nsIFrame.h" #include "nsIFocusTracker.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIPresShell.h" #include "nsIContent.h" #include "nsCOMPtr.h" @@ -244,9 +244,9 @@ public: /** GetSelection * no query interface for selection. must use this method now. - * @param aSelectionType enum value defined in nsIDOMSelection for the domseleciton you want. + * @param aSelectionType enum value defined in nsISelection for the seleciton you want. */ - NS_IMETHOD GetSelection(SelectionType aSelectionType, nsIDOMSelection **aDomSelection)=0; + NS_IMETHOD GetSelection(SelectionType aSelectionType, nsISelection **aSelection)=0; /** * ScrollSelectionIntoView scrolls a region of the selection, @@ -259,7 +259,7 @@ public: /** RepaintSelection repaints the selected frames that are inside the selection * specified by aSelectionType. - * @param aSelectionType enum value defined in nsIDOMSelection for the domseleciton you want. + * @param aSelectionType enum value defined in nsISelection for the seleciton you want. */ NS_IMETHOD RepaintSelection(nsIPresContext* aPresContext, SelectionType aSelectionType)=0; diff --git a/mozilla/layout/base/public/nsIIndependentSelection.h b/mozilla/layout/base/public/nsIIndependentSelection.h index 12e1113c817..72c4ceb9b5a 100644 --- a/mozilla/layout/base/public/nsIIndependentSelection.h +++ b/mozilla/layout/base/public/nsIIndependentSelection.h @@ -23,7 +23,7 @@ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! * NOTE!! This is not a general class, but specific to layout and frames. * Consumers looking for the general selection interface should look at - * nsIDOMSelection. + * nsISelection. */ diff --git a/mozilla/layout/base/public/nsIPresShell.h b/mozilla/layout/base/public/nsIPresShell.h index 9333caeecdc..3ae40b68484 100644 --- a/mozilla/layout/base/public/nsIPresShell.h +++ b/mozilla/layout/base/public/nsIPresShell.h @@ -39,7 +39,7 @@ #include "nslayout.h" #include "nsISupports.h" #include "nsCoord.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIReflowCommand.h" #include "nsGUIEvent.h" diff --git a/mozilla/layout/base/public/nsISelection.h b/mozilla/layout/base/public/nsISelection.h deleted file mode 100644 index b8b392eea5d..00000000000 --- a/mozilla/layout/base/public/nsISelection.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * - * The contents of this file are subject to the Netscape Public - * License Version 1.1 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.mozilla.org/NPL/ - * - * Software distributed under the License is distributed on an "AS - * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - * implied. See the License for the specific language governing - * rights and limitations under the License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All - * Rights Reserved. - * - * Contributor(s): - */ - -/* NOTE This should be renamed asap to nsIFrameSelection - * -- it's not a general class, but specific to frames. - * nsIDOMSelection is the more general selection interface. - */ - -#ifndef nsISelection_h___ -#define nsISelection_h___ - -#include "nsISupports.h" -#include "nsIFrame.h" -#include "nsIFocusTracker.h" - -// IID for the nsISelection interface -#define NS_ISELECTION_IID \ -{ 0xf46e4171, 0xdeaa, 0x11d1, \ - { 0x97, 0xfc, 0x0, 0x60, 0x97, 0x3, 0xc1, 0x4e } } - -//---------------------------------------------------------------------- - -// Selection interface -class nsISelection : public nsISupports { -public: - static const nsIID& GetIID() { static nsIID iid = NS_ISELECTION_IID; return iid; } - - /** HandleKeyEvent will accept an event and frame and - * will return NS_OK if it handles the event or NS_COMFALSE if not. - *

DOES NOT ADDREF

- * @param tracker to ask where the current focus is and to set the new anchor ect. - * @param aGuiEvent is the event that should be dealt with by aFocusFrame - * @param aFrame is the frame that MAY handle the event - */ - NS_IMETHOD HandleKeyEvent(nsIFocusTracker *aTracker, nsGUIEvent *aGuiEvent, nsIFrame *aFrame) = 0; - - /** TakeFocus will take the focus to the new frame at the new offset and - * will either extend the selection from the old anchor, or replace the old anchor. - * the old anchor and focus position may also be used to deselect things - * @param aTracker we need a focus tracker to get the old focus ect. - * @param aFrame is the frame that wants the focus - * @param aOffset is the offset in the aFrame that will get the focus point - * @param aContentOffset is the offset in the node of the aFrame that is reflected be aOffset - * @param aContinueSelection is the flag that tells the selection to keep the old anchor point or not. - */ - NS_IMETHOD TakeFocus(nsIFocusTracker *aTracker, nsIFrame *aFrame, PRInt32 aOffset, PRInt32 aContentOffset, PRBool aContinueSelection) = 0; - - /** ResetSelection will top down search for frames that need selection - */ - NS_IMETHOD ResetSelection(nsIFocusTracker *aTracker, nsIFrame *aStartFrame) = 0; - -}; - - -#endif /* nsISelection_h___ */ diff --git a/mozilla/layout/base/public/nsISelectionController.idl b/mozilla/layout/base/public/nsISelectionController.idl index ef2d91998e1..158933213a8 100644 --- a/mozilla/layout/base/public/nsISelectionController.idl +++ b/mozilla/layout/base/public/nsISelectionController.idl @@ -24,11 +24,11 @@ #include "nsISupports.idl" #include "domstubs.idl" - +#include "nsISelection.idl" %{C++ -class nsIDOMSelection; +class nsISelection; typedef short SelectionType; typedef short SelectionRegion; class nsIDOMNode; @@ -86,7 +86,7 @@ interface nsISelectionController : nsISupports * @param aType will hold the type of selection //SelectionType * @param _return will hold the return value */ - nsIDOMSelection getSelection(in short type); + nsISelection getSelection(in short type); /** * ScrollSelectionIntoView scrolls a region of the selection, diff --git a/mozilla/layout/base/public/nsIXIFConverter.h b/mozilla/layout/base/public/nsIXIFConverter.h index a17cc6411e2..0deacb3cffb 100644 --- a/mozilla/layout/base/public/nsIXIFConverter.h +++ b/mozilla/layout/base/public/nsIXIFConverter.h @@ -26,7 +26,7 @@ #include "nsString.h" -class nsIDOMSelection; +class nsISelection; #define NS_IXIFCONVERTER_IID \ @@ -112,9 +112,9 @@ public: //NS_IMETHOD WriteDebugFile(); // saves to a temp file - NS_IMETHOD SetSelection(nsIDOMSelection* aSelection) = 0; + NS_IMETHOD SetSelection(nsISelection* aSelection) = 0; - NS_IMETHOD GetSelection(nsIDOMSelection** aSelection) = 0; + NS_IMETHOD GetSelection(nsISelection** aSelection) = 0; }; #endif //nsIXIFConverter_h__ diff --git a/mozilla/layout/base/src/nsAutoCopy.cpp b/mozilla/layout/base/src/nsAutoCopy.cpp index aad12121e46..dc0b6921cf4 100644 --- a/mozilla/layout/base/src/nsAutoCopy.cpp +++ b/mozilla/layout/base/src/nsAutoCopy.cpp @@ -25,8 +25,9 @@ #include "nsIServiceManager.h" #include "nsIAutoCopy.h" -#include "nsIDOMSelection.h" -#include "nsIDOMSelectionListener.h" +#include "nsISelection.h" +#include "nsISelectionPrivate.h" +#include "nsISelectionListener.h" #include "nsWidgetsCID.h" #include "nsIClipboard.h" #include "nsIDOMDocument.h" @@ -34,7 +35,7 @@ #include "nsIDocument.h" #include "nsSupportsPrimitives.h" -class nsAutoCopyService : public nsIAutoCopyService , public nsIDOMSelectionListener +class nsAutoCopyService : public nsIAutoCopyService , public nsISelectionListener { public: NS_DECL_ISUPPORTS @@ -43,12 +44,12 @@ public: virtual ~nsAutoCopyService(){}//someday maybe we have it able to shutdown during run //nsIAutoCopyService interfaces - NS_IMETHOD Listen(nsIDOMSelection *aDomSelection); + NS_IMETHOD Listen(nsISelection *aDomSelection); //end nsIAutoCopyService - //nsIDOMSelectionListener interfaces - NS_IMETHOD NotifySelectionChanged(nsIDOMDocument *aDoc, nsIDOMSelection *aSel, short aReason); - //end nsIDOMSelectionListener + //nsISelectionListener interfaces + NS_IMETHOD NotifySelectionChanged(nsIDOMDocument *aDoc, nsISelection *aSel, short aReason); + //end nsISelectionListener protected: nsCOMPtr mClipboard; nsCOMPtr mXIF; @@ -57,7 +58,7 @@ protected: }; // Implement our nsISupports methods -NS_IMPL_ISUPPORTS2(nsAutoCopyService, nsIAutoCopyService,nsIDOMSelectionListener) +NS_IMPL_ISUPPORTS2(nsAutoCopyService, nsIAutoCopyService,nsISelectionListener) nsresult NS_NewAutoCopyService(nsIAutoCopyService** aResult) @@ -75,9 +76,13 @@ nsAutoCopyService::nsAutoCopyService() } NS_IMETHODIMP -nsAutoCopyService::Listen(nsIDOMSelection *aDomSelection) +nsAutoCopyService::Listen(nsISelection *aDomSelection) { - return aDomSelection->AddSelectionListener(this); + if (!aDomSelection) + return NS_ERROR_NULL_POINTER; + nsCOMPtr selection(aDomSelection); + nsCOMPtr selectionPrivate(do_QueryInterface(selection)); + return selectionPrivate->AddSelectionListener(this); } @@ -91,7 +96,7 @@ nsAutoCopyService::Listen(nsIDOMSelection *aDomSelection) * What we should do, to make our end of the deal faster: * Create a singleton transferable with our own magic converter. When selection * changes (use a quick cache to detect ``real'' changes), we put the new - * nsIDOMSelection in the transferable. Our magic converter will take care of + * nsISelection in the transferable. Our magic converter will take care of * transferable->XIF->whatever-other-format when the time comes to actually * hand over the clipboard contents. * @@ -111,7 +116,7 @@ nsAutoCopyService::Listen(nsIDOMSelection *aDomSelection) #define DRAGGING 1 NS_IMETHODIMP -nsAutoCopyService::NotifySelectionChanged(nsIDOMDocument *aDoc, nsIDOMSelection *aSel, short aReason) +nsAutoCopyService::NotifySelectionChanged(nsIDOMDocument *aDoc, nsISelection *aSel, short aReason) { nsresult rv; @@ -121,7 +126,7 @@ nsAutoCopyService::NotifySelectionChanged(nsIDOMDocument *aDoc, nsIDOMSelection if (NS_FAILED(rv)) return rv; } - if (!(aReason & nsIDOMSelectionListener::MOUSEUP_REASON)) + if (!(aReason & nsISelectionListener::MOUSEUP_REASON)) return NS_OK;//dont care if we are still dragging. or if its not from a mouseup PRBool collapsed; if (!aDoc || !aSel || NS_FAILED(aSel->GetIsCollapsed(&collapsed)) || collapsed) { diff --git a/mozilla/layout/base/src/nsCaret.cpp b/mozilla/layout/base/src/nsCaret.cpp index 33e5dca4d1d..b8830a1ccfb 100644 --- a/mozilla/layout/base/src/nsCaret.cpp +++ b/mozilla/layout/base/src/nsCaret.cpp @@ -32,7 +32,8 @@ #include "nsIFrame.h" #include "nsIDOMNode.h" #include "nsIDOMRange.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" +#include "nsISelectionPrivate.h" #include "nsIDOMCharacterData.h" #include "nsIContent.h" #include "nsIPresShell.h" @@ -105,13 +106,16 @@ NS_IMETHODIMP nsCaret::Init(nsIPresShell *inPresShell) // get the selection from the pres shell, and set ourselves up as a selection // listener - nsCOMPtr domSelection; + + nsCOMPtr domSelection; + nsCOMPtr privateSelection; nsCOMPtr selCon = do_QueryReferent(mPresShell); if (selCon) { if (NS_SUCCEEDED(selCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(domSelection)))) { - domSelection->AddSelectionListener(this); + privateSelection = do_QueryInterface(domSelection); + privateSelection->AddSelectionListener(this); mDomSelectionWeak = getter_AddRefs( NS_GetWeakReference(domSelection) ); } } @@ -138,6 +142,7 @@ NS_IMPL_RELEASE(nsCaret); NS_IMETHODIMP nsCaret::QueryInterface(const nsIID& aIID, void** aInstancePtrResult) { + NS_PRECONDITION(aInstancePtrResult, "null pointer"); if (!aInstancePtrResult) return NS_ERROR_NULL_POINTER; @@ -148,8 +153,8 @@ NS_IMETHODIMP nsCaret::QueryInterface(const nsIID& aIID, foundInterface = (nsISupports*)(nsICaret*)this; // whoo boy else if (aIID.Equals(NS_GET_IID(nsICaret))) foundInterface = (nsICaret*)this; - else if (aIID.Equals(NS_GET_IID(nsIDOMSelectionListener))) - foundInterface = (nsIDOMSelectionListener*)this; + else if (aIID.Equals(NS_GET_IID(nsISelectionListener))) + foundInterface = (nsISelectionListener*)this; else foundInterface = nsnull; @@ -167,7 +172,7 @@ NS_IMETHODIMP nsCaret::QueryInterface(const nsIID& aIID, } //----------------------------------------------------------------------------- -NS_IMETHODIMP nsCaret::SetCaretDOMSelection(nsIDOMSelection *aDOMSel) +NS_IMETHODIMP nsCaret::SetCaretDOMSelection(nsISelection *aDOMSel) { NS_ENSURE_ARG_POINTER(aDOMSel); mDomSelectionWeak = getter_AddRefs( NS_GetWeakReference(aDOMSel) ); // weak reference to pres shell @@ -205,14 +210,15 @@ NS_IMETHODIMP nsCaret::SetCaretReadOnly(PRBool inMakeReadonly) //----------------------------------------------------------------------------- -NS_IMETHODIMP nsCaret::GetWindowRelativeCoordinates(nsRect& outCoordinates, PRBool& outIsCollapsed, nsIDOMSelection *aDOMSel) +NS_IMETHODIMP nsCaret::GetWindowRelativeCoordinates(nsRect& outCoordinates, PRBool& outIsCollapsed, nsISelection *aDOMSel) { if (!mPresShell) return NS_ERROR_NOT_INITIALIZED; mDomSelectionWeak = getter_AddRefs( NS_GetWeakReference(aDOMSel) ); // weak reference to pres shell - - nsCOMPtr domSelection = aDOMSel; + + nsCOMPtr domSelection = aDOMSel; + nsCOMPtr privateSelection(do_QueryInterface(domSelection)); nsresult err; if (!domSelection) return NS_ERROR_NOT_INITIALIZED; // no selection @@ -268,7 +274,7 @@ NS_IMETHODIMP nsCaret::GetWindowRelativeCoordinates(nsRect& outCoordinates, PRBo nsIFrame* theFrame = nsnull; PRInt32 theFrameOffset = 0; PRBool hintRight; - domSelection->GetHint(&hintRight);//translate hint. + privateSelection->GetInterlinePosition(&hintRight);//translate hint. nsIFrameSelection::HINT hint; if (hintRight) hint = nsIFrameSelection::HINTRIGHT; @@ -357,13 +363,13 @@ NS_IMETHODIMP nsCaret::EraseCaret() #endif //----------------------------------------------------------------------------- -NS_IMETHODIMP nsCaret::NotifySelectionChanged(nsIDOMDocument *, nsIDOMSelection *aDomSel, short aReason) +NS_IMETHODIMP nsCaret::NotifySelectionChanged(nsIDOMDocument *, nsISelection *aDomSel, short aReason) { - if (aReason & nsIDOMSelectionListener::MOUSEUP_REASON)//this wont do + if (aReason & nsISelectionListener::MOUSEUP_REASON)//this wont do return NS_OK; - if (mVisible) - StopBlinking(); - nsCOMPtr domSel(do_QueryReferent(mDomSelectionWeak)); + if (mVisible) + StopBlinking(); + nsCOMPtr domSel(do_QueryReferent(mDomSelectionWeak)); if (domSel.get() != aDomSel) return NS_OK; //ignore this then. if (mVisible) @@ -439,8 +445,10 @@ PRBool nsCaret::SetupDrawingFrameAndOffset() { if (!mDomSelectionWeak) return PR_FALSE; + - nsCOMPtr domSelection = do_QueryReferent(mDomSelectionWeak); + nsCOMPtr domSelection = do_QueryReferent(mDomSelectionWeak); + nsCOMPtr privateSelection(do_QueryInterface(domSelection)); if (!domSelection) return PR_FALSE; PRBool isCollapsed = PR_FALSE; @@ -470,7 +478,7 @@ PRBool nsCaret::SetupDrawingFrameAndOffset() return PR_FALSE; PRBool hintRight; - domSelection->GetHint(&hintRight);//translate hint. + privateSelection->GetInterlinePosition(&hintRight);//translate hint. nsIFrameSelection::HINT hint; hint = (hintRight) ? nsIFrameSelection::HINTRIGHT : nsIFrameSelection::HINTLEFT; @@ -634,10 +642,10 @@ void nsCaret::GetViewForRendering(nsIFrame *caretFrame, EViewCoordinates coordTy ----------------------------------------------------------------------------- */ PRBool nsCaret::MustDrawCaret() { - if (mDrawn) - return PR_TRUE; - - nsCOMPtr domSelection = do_QueryReferent(mDomSelectionWeak); + if (mDrawn) + return PR_TRUE; + + nsCOMPtr domSelection = do_QueryReferent(mDomSelectionWeak); if (!domSelection) return PR_FALSE; PRBool isCollapsed; diff --git a/mozilla/layout/base/src/nsCaret.h b/mozilla/layout/base/src/nsCaret.h index bb3c48dd20c..a95f9fb48b8 100644 --- a/mozilla/layout/base/src/nsCaret.h +++ b/mozilla/layout/base/src/nsCaret.h @@ -23,7 +23,7 @@ #include "nsCoord.h" -#include "nsIDOMSelectionListener.h" +#include "nsISelectionListener.h" #include "nsIRenderingContext.h" #include "nsITimer.h" #include "nsICaret.h" @@ -40,7 +40,7 @@ class nsISelectionController; //----------------------------------------------------------------------------- class nsCaret : public nsICaret, - public nsIDOMSelectionListener + public nsISelectionListener { public: @@ -54,17 +54,18 @@ class nsCaret : public nsICaret, // nsICaret interface NS_IMETHOD Init(nsIPresShell *inPresShell); - NS_IMETHOD SetCaretDOMSelection(nsIDOMSelection *inDOMSel); + NS_IMETHOD SetCaretDOMSelection(nsISelection *inDOMSel); NS_IMETHOD GetCaretVisible(PRBool *outMakeVisible); - NS_IMETHOD SetCaretVisible(PRBool intMakeVisible); - NS_IMETHOD SetCaretReadOnly(PRBool inMakeReadonly); - NS_IMETHOD GetWindowRelativeCoordinates(nsRect& outCoordinates, PRBool& outIsCollapsed, nsIDOMSelection *inDOMSel); - NS_IMETHOD ClearFrameRefs(nsIFrame* aFrame); - NS_IMETHOD EraseCaret(); + NS_IMETHOD SetCaretVisible(PRBool intMakeVisible); + NS_IMETHOD SetCaretReadOnly(PRBool inMakeReadonly); + NS_IMETHOD GetWindowRelativeCoordinates(nsRect& outCoordinates, PRBool& outIsCollapsed, nsISelection *inDOMSel); + NS_IMETHOD ClearFrameRefs(nsIFrame* aFrame); + NS_IMETHOD EraseCaret(); + NS_IMETHOD SetCaretWidth(nscoord aPixels); - - //nsIDOMSelectionListener interface - NS_IMETHOD NotifySelectionChanged(nsIDOMDocument *aDoc, nsIDOMSelection *aSel, short aReason); + + //nsISelectionListener interface + NS_IMETHOD NotifySelectionChanged(nsIDOMDocument *aDoc, nsISelection *aSel, short aReason); static void CaretBlinkCallback(nsITimer *aTimer, void *aClosure); diff --git a/mozilla/layout/base/src/nsCommentNode.cpp b/mozilla/layout/base/src/nsCommentNode.cpp index 043d9c19500..36efb66b165 100644 --- a/mozilla/layout/base/src/nsCommentNode.cpp +++ b/mozilla/layout/base/src/nsCommentNode.cpp @@ -26,7 +26,8 @@ #include "nsIContent.h" #include "nsFrame.h" #include "nsLayoutAtoms.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" +#include "nsISelectionPrivate.h" #include "nsIXIFConverter.h" #include "nsIDocument.h" #include "nsIEnumerator.h" @@ -403,7 +404,7 @@ nsresult nsCommentNode::ConvertContentToXIF(nsIXIFConverter* aConverter) const { const nsIContent* content = this; - nsCOMPtr sel; + nsCOMPtr sel; aConverter->GetSelection(getter_AddRefs(sel)); nsIDocument* document; nsresult res; @@ -423,7 +424,8 @@ nsCommentNode::ConvertContentToXIF(nsIXIFConverter* aConverter) const if (sel != nsnull && document->IsInSelection(sel,content)) { nsIEnumerator *enumerator; - if (NS_SUCCEEDED(sel->GetEnumerator(&enumerator))) { + nsCOMPtr selPrivate(do_QueryInterface(sel)); + if (NS_SUCCEEDED(selPrivate->GetEnumerator(&enumerator))) { for (enumerator->First();NS_OK != enumerator->IsDone(); enumerator->Next()) { nsIDOMRange* range = nsnull; if (NS_SUCCEEDED(enumerator->CurrentItem((nsISupports**)&range))) { diff --git a/mozilla/layout/base/src/nsDocument.cpp b/mozilla/layout/base/src/nsDocument.cpp index 8e5631cdfba..bb08ff330ad 100644 --- a/mozilla/layout/base/src/nsDocument.cpp +++ b/mozilla/layout/base/src/nsDocument.cpp @@ -87,7 +87,7 @@ #include "nsLayoutAtoms.h" #include "nsLayoutCID.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIDOMRange.h" #include "nsIEnumerator.h" #include "nsDOMError.h" @@ -3355,7 +3355,7 @@ NS_IMETHODIMP nsDocument::ToXIF(nsIXIFConverter* aConverter, nsIDOMNode* aNode) { nsresult result=NS_OK; - nsCOMPtr sel; + nsCOMPtr sel; aConverter->GetSelection(getter_AddRefs(sel)); if (sel) { @@ -3387,7 +3387,7 @@ nsDocument::ToXIF(nsIXIFConverter* aConverter, nsIDOMNode* aNode) } NS_IMETHODIMP -nsDocument::CreateXIF(nsAWritableString & aBuffer, nsIDOMSelection* aSelection) +nsDocument::CreateXIF(nsAWritableString & aBuffer, nsISelection* aSelection) { nsresult result=NS_OK; @@ -3777,7 +3777,7 @@ nsIContent* nsDocument::FindContent(const nsIContent* aStartNode, * @return PR_TRUE if the content is found within the selection */ PRBool -nsDocument::IsInSelection(nsIDOMSelection* aSelection, const nsIContent* aContent) const +nsDocument::IsInSelection(nsISelection* aSelection, const nsIContent* aContent) const { PRBool aYes = PR_FALSE; nsCOMPtr node (do_QueryInterface((nsIContent *) aContent)); diff --git a/mozilla/layout/base/src/nsDocument.h b/mozilla/layout/base/src/nsDocument.h index fda087a204f..e50e6f5efaa 100644 --- a/mozilla/layout/base/src/nsDocument.h +++ b/mozilla/layout/base/src/nsDocument.h @@ -358,7 +358,7 @@ public: * document to XIF (XML Interchange Format) * and places the result in aBuffer. */ - NS_IMETHOD CreateXIF(nsAWritableString & aBuffer, nsIDOMSelection* aSelection); + NS_IMETHOD CreateXIF(nsAWritableString & aBuffer, nsISelection* aSelection); NS_IMETHOD ToXIF(nsIXIFConverter * aConverter, nsIDOMNode* aNode); virtual void BeginConvertToXIF(nsIXIFConverter * aConverter, nsIDOMNode* aNode); virtual void ConvertChildrenToXIF(nsIXIFConverter * aConverter, nsIDOMNode* aNode); @@ -448,7 +448,7 @@ public: nsEventStatus* aEventStatus); - virtual PRBool IsInSelection(nsIDOMSelection* aSelection, const nsIContent *aContent) const; + virtual PRBool IsInSelection(nsISelection* aSelection, const nsIContent *aContent) const; virtual nsIContent* GetPrevContent(const nsIContent *aContent) const; virtual nsIContent* GetNextContent(const nsIContent *aContent) const; diff --git a/mozilla/layout/base/src/nsDocumentEncoder.cpp b/mozilla/layout/base/src/nsDocumentEncoder.cpp index 713f1a584f9..cced3ae185f 100644 --- a/mozilla/layout/base/src/nsDocumentEncoder.cpp +++ b/mozilla/layout/base/src/nsDocumentEncoder.cpp @@ -29,7 +29,7 @@ #include "nsIComponentManager.h" #include "nsIServiceManager.h" #include "nsIDocument.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIPresShell.h" #include "nsXIFDTD.h" #include "nsParserCIID.h" @@ -60,7 +60,7 @@ public: NS_DECL_ISUPPORTS // Inherited methods from nsIDocumentEncoder - NS_IMETHOD SetSelection(nsIDOMSelection* aSelection); + NS_IMETHOD SetSelection(nsISelection* aSelection); NS_IMETHOD SetWrapColumn(PRUint32 aWC); NS_IMETHOD SetCharset(const nsAReadableString& aCharset); @@ -74,7 +74,7 @@ protected: //NS_IMETHOD AddHeader(PRBool aYes); nsIDocument* mDocument; - nsIDOMSelection* mSelection; + nsISelection* mSelection; nsString mMimeType; nsString mCharset; PRUint32 mFlags; @@ -149,7 +149,7 @@ nsTextEncoder::SetWrapColumn(PRUint32 aWC) } NS_IMETHODIMP -nsTextEncoder::SetSelection(nsIDOMSelection* aSelection) +nsTextEncoder::SetSelection(nsISelection* aSelection) { mSelection = aSelection; return NS_OK; diff --git a/mozilla/layout/base/src/nsDocumentViewer.cpp b/mozilla/layout/base/src/nsDocumentViewer.cpp index 7fd25959c26..3f6fb61b67f 100644 --- a/mozilla/layout/base/src/nsDocumentViewer.cpp +++ b/mozilla/layout/base/src/nsDocumentViewer.cpp @@ -45,7 +45,8 @@ #include "nsIScriptGlobalObject.h" #include "nsILinkHandler.h" #include "nsIDOMDocument.h" -#include "nsIDOMSelectionListener.h" +#include "nsISelectionListener.h" +#include "nsISelectionPrivate.h" #include "nsIDOMHTMLDocument.h" #include "nsIDOMHTMLElement.h" #include "nsIDOMRange.h" @@ -106,16 +107,15 @@ class DocumentViewerImpl; #pragma mark ** nsDocViwerSelectionListener ** #endif -class nsDocViwerSelectionListener : public nsIDOMSelectionListener +class nsDocViwerSelectionListener : public nsISelectionListener { public: // nsISupports interface... NS_DECL_ISUPPORTS - // nsIDOMSelectionListerner interface - NS_DECL_IDOMSELECTIONLISTENER - + // nsISelectionListerner interface + NS_DECL_NSISELECTIONLISTENER nsDocViwerSelectionListener() : mDocViewer(NULL) @@ -245,7 +245,7 @@ private: nsresult MakeWindow(nsIWidget* aParentWidget, const nsRect& aBounds); - nsresult GetDocumentSelection(nsIDOMSelection **aSelection); + nsresult GetDocumentSelection(nsISelection **aSelection); // // The following three methods are used for printing... @@ -279,7 +279,7 @@ protected: nsCOMPtr mUAStyleSheet; - nsCOMPtr mSelectionListener; + nsCOMPtr mSelectionListener; nsCOMPtr mFocusListener; PRBool mEnableRendering; @@ -436,12 +436,13 @@ DocumentViewerImpl::~DocumentViewerImpl() if (mPresShell) { // Break circular reference (or something) mPresShell->EndObservingDocument(); - nsCOMPtr selection; + nsCOMPtr selection; rv = GetDocumentSelection(getter_AddRefs(selection)); - if (NS_FAILED(rv) || !selection) + nsCOMPtr selPrivate(do_QueryInterface(selection)); + if (NS_FAILED(rv) || !selPrivate) return; if (mSelectionListener) - selection->RemoveSelectionListener(mSelectionListener); + selPrivate->RemoveSelectionListener(mSelectionListener); } } @@ -592,15 +593,16 @@ DocumentViewerImpl::Init(nsIWidget* aParentWidget, // this is the owning reference. The nsCOMPtr will take care of releasing // our ref to the listener on destruction. NS_ADDREF(selectionListener); - rv = selectionListener->QueryInterface(NS_GET_IID(nsIDOMSelectionListener), getter_AddRefs(mSelectionListener)); + rv = selectionListener->QueryInterface(NS_GET_IID(nsISelectionListener), getter_AddRefs(mSelectionListener)); NS_RELEASE(selectionListener); if (NS_FAILED(rv)) return rv; - nsCOMPtr selection; + nsCOMPtr selection; rv = GetDocumentSelection(getter_AddRefs(selection)); if (NS_FAILED(rv)) return rv; - rv = selection->AddSelectionListener(mSelectionListener); + nsCOMPtr selPrivate(do_QueryInterface(selection)); + rv = selPrivate->AddSelectionListener(mSelectionListener); if (NS_FAILED(rv)) return rv; //focus listener @@ -1194,7 +1196,7 @@ DocumentViewerImpl::MakeWindow(nsIWidget* aParentWidget, return rv; } -nsresult DocumentViewerImpl::GetDocumentSelection(nsIDOMSelection **aSelection) +nsresult DocumentViewerImpl::GetDocumentSelection(nsISelection **aSelection) { if (!aSelection) return NS_ERROR_NULL_POINTER; if (!mPresShell) return NS_ERROR_NOT_INITIALIZED; @@ -1338,7 +1340,7 @@ NS_IMETHODIMP DocumentViewerImpl::SelectAll() // XXX this is a temporary implementation copied from nsWebShell // for now. I think nsDocument and friends should have some helper // functions to make this easier. - nsCOMPtr selection; + nsCOMPtr selection; nsresult rv; rv = GetDocumentSelection(getter_AddRefs(selection)); if (NS_FAILED(rv)) return rv; @@ -1361,7 +1363,7 @@ NS_IMETHODIMP DocumentViewerImpl::SelectAll() } if (!bodyNode) return NS_ERROR_FAILURE; - rv = selection->ClearSelection(); + rv = selection->RemoveAllRanges(); if (NS_FAILED(rv)) return rv; static NS_DEFINE_CID(kCDOMRangeCID, NS_RANGE_CID); @@ -1385,7 +1387,7 @@ NS_IMETHODIMP DocumentViewerImpl::CopySelection() NS_IMETHODIMP DocumentViewerImpl::GetCopyable(PRBool *aCopyable) { - nsCOMPtr selection; + nsCOMPtr selection; nsresult rv; rv = GetDocumentSelection(getter_AddRefs(selection)); if (NS_FAILED(rv)) return rv; @@ -1922,7 +1924,7 @@ NS_IMETHODIMP DocumentViewerImpl::SizeToContent() #pragma mark - #endif -NS_IMPL_ISUPPORTS(nsDocViwerSelectionListener, NS_GET_IID(nsIDOMSelectionListener)); +NS_IMPL_ISUPPORTS(nsDocViwerSelectionListener, NS_GET_IID(nsISelectionListener)); nsresult nsDocViwerSelectionListener::Init(DocumentViewerImpl *aDocViewer) { @@ -1931,12 +1933,12 @@ nsresult nsDocViwerSelectionListener::Init(DocumentViewerImpl *aDocViewer) } -NS_IMETHODIMP nsDocViwerSelectionListener::NotifySelectionChanged(nsIDOMDocument *, nsIDOMSelection *, short) +NS_IMETHODIMP nsDocViwerSelectionListener::NotifySelectionChanged(nsIDOMDocument *, nsISelection *, short) { NS_ASSERTION(mDocViewer, "Should have doc viewer!"); // get the selection state - nsCOMPtr selection; + nsCOMPtr selection; nsresult rv = mDocViewer->GetDocumentSelection(getter_AddRefs(selection)); if (NS_FAILED(rv)) return rv; diff --git a/mozilla/layout/base/src/nsGenericDOMDataNode.cpp b/mozilla/layout/base/src/nsGenericDOMDataNode.cpp index 6a6be9c8405..c4af63ba33d 100644 --- a/mozilla/layout/base/src/nsGenericDOMDataNode.cpp +++ b/mozilla/layout/base/src/nsGenericDOMDataNode.cpp @@ -30,7 +30,8 @@ #include "nsIXIFConverter.h" #include "nsRange.h" #include "nsTextContentChangeData.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" +#include "nsISelectionPrivate.h" #include "nsIEnumerator.h" #include "nsReadableUtils.h" @@ -558,13 +559,14 @@ nsGenericDOMDataNode::ConvertContentToXIF(const nsIContent *aOuterContent, nsIXIFConverter* aConverter) const { const nsIContent* content = aOuterContent; - nsCOMPtr sel; + nsCOMPtr sel; aConverter->GetSelection(getter_AddRefs(sel)); if (sel && mDocument && mDocument->IsInSelection(sel,content)) { nsCOMPtr enumerator; - if (NS_SUCCEEDED(sel->GetEnumerator(getter_AddRefs(enumerator)))) { + nsCOMPtr selPrivate(do_QueryInterface(sel)); + if (NS_SUCCEEDED(selPrivate->GetEnumerator(getter_AddRefs(enumerator)))) { for (enumerator->First();NS_OK != enumerator->IsDone(); enumerator->Next()) { nsIDOMRange* range = nsnull; if (NS_SUCCEEDED(enumerator->CurrentItem((nsISupports**)&range))) { diff --git a/mozilla/layout/base/src/nsSelection.cpp b/mozilla/layout/base/src/nsSelection.cpp index 745a54067c5..ed826d6611e 100644 --- a/mozilla/layout/base/src/nsSelection.cpp +++ b/mozilla/layout/base/src/nsSelection.cpp @@ -20,7 +20,7 @@ */ /* - * Implementation of selection: nsIDOMSelection and nsIFrameSelection + * Implementation of selection: nsISelection,nsISelectionPrivate and nsIFrameSelection */ #include "nsCOMPtr.h" @@ -29,8 +29,9 @@ #include "nsIEnumerator.h" #include "nsIDOMRange.h" #include "nsIFrameSelection.h" -#include "nsIDOMSelection.h" -#include "nsIDOMSelectionListener.h" +#include "nsISelection.h" +#include "nsISelectionPrivate.h" +#include "nsISelectionListener.h" #include "nsIFocusTracker.h" #include "nsIComponentManager.h" #include "nsLayoutCID.h" @@ -45,7 +46,7 @@ #include "nsIDOMNodeList.h" #include "nsITextContent.h" -#include "nsIDOMSelectionListener.h" +#include "nsISelectionListener.h" #include "nsIContentIterator.h" #include "nsIDocumentEncoder.h" #include "nsIIndependentSelection.h" @@ -58,8 +59,6 @@ #include "nsIPresShell.h" #include "nsICaret.h" -#include "nsIScriptObjectOwner.h" -#include "nsIScriptGlobalObject.h" // included for view scrolling #include "nsIViewManager.h" @@ -113,7 +112,7 @@ class nsSelectionIterator; class nsSelection; class nsAutoScrollTimer; -class nsDOMSelection : public nsIDOMSelection , public nsIScriptObjectOwner, public nsSupportsWeakReference, public nsIIndependentSelection +class nsDOMSelection : public nsISelection , public nsISelectionPrivate, public nsSupportsWeakReference, public nsIIndependentSelection { public: nsDOMSelection(); @@ -124,7 +123,7 @@ public: /*BEGIN nsIIndependentSelection interface implementations */ NS_IMETHOD SetPresShell(nsIPresShell *aPresShell); - /*BEGIN nsIDOMSelection interface implementations*/ + /*BEGIN nsISelection,Private interface implementations*/ NS_IMETHOD GetAnchorNode(nsIDOMNode** aAnchorNode); NS_IMETHOD GetAnchorOffset(PRInt32* aAnchorOffset); NS_IMETHOD GetFocusNode(nsIDOMNode** aFocusNode); @@ -132,7 +131,7 @@ public: NS_IMETHOD GetIsCollapsed(PRBool* aIsCollapsed); NS_IMETHOD GetRangeCount(PRInt32* aRangeCount); NS_IMETHOD GetRangeAt(PRInt32 aIndex, nsIDOMRange** aReturn); - NS_IMETHOD ClearSelection(); + NS_IMETHOD RemoveAllRanges(); NS_IMETHOD Collapse(nsIDOMNode* aParentNode, PRInt32 aOffset); NS_IMETHOD CollapseToStart(); NS_IMETHOD CollapseToEnd(); @@ -146,21 +145,17 @@ public: NS_IMETHOD StartBatchChanges(); NS_IMETHOD EndBatchChanges(); - NS_IMETHOD AddSelectionListener(nsIDOMSelectionListener* aNewListener); - NS_IMETHOD RemoveSelectionListener(nsIDOMSelectionListener* aListenerToRemove); + NS_IMETHOD AddSelectionListener(nsISelectionListener* aNewListener); + NS_IMETHOD RemoveSelectionListener(nsISelectionListener* aListenerToRemove); NS_IMETHOD GetEnumerator(nsIEnumerator **aIterator); - NS_IMETHOD ToString(const nsAReadableString& aFormatType, PRUint32 aFlags, PRInt32 aWrapCount, nsAWritableString& aReturn); + NS_IMETHOD ToString(PRUnichar **_retval); + NS_IMETHOD ToStringWithFormat(const char *aFormatType, PRUint32 aFlags, PRInt32 aWrapCount, PRUnichar ** aReturn); - NS_IMETHOD SetHint(PRBool aHintRight); - NS_IMETHOD GetHint(PRBool *aHintRight); + NS_IMETHOD GetInterlinePosition(PRBool *aInterlinePosition); + NS_IMETHOD SetInterlinePosition(PRBool aInterlinePosition); -/*END nsIDOMSelection interface implementations*/ - -/*BEGIN nsIScriptObjectOwner interface implementations*/ - NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject); - NS_IMETHOD SetScriptObject(void *aScriptObject); -/*END nsIScriptObjectOwner interface implementations*/ +/*END nsISelection interface implementations*/ // utility methods for scrolling the selection into view nsresult GetPresContext(nsIPresContext **aPresContext); @@ -259,8 +254,6 @@ private: nsSelection *mFrameSelection; nsWeakPtr mPresShellWeak; //weak reference to presshell. - // for nsIScriptObjectOwner - void* mScriptObject; SelectionType mType;//type of this nsDOMSelection; nsAutoScrollTimer *mAutoScrollTimer; // timer for autoscrolling. nsCOMPtr mSelectionListeners; @@ -270,9 +263,9 @@ private: class nsSelectionBatcher { private: - nsCOMPtr mSelection; + nsCOMPtr mSelection; public: - nsSelectionBatcher(nsIDOMSelection *aSelection) : mSelection(aSelection) + nsSelectionBatcher(nsISelectionPrivate *aSelection) : mSelection(aSelection) { if (mSelection) mSelection->StartBatchChanges(); } @@ -313,7 +306,7 @@ public: NS_IMETHOD ClearTableCellSelection(){mSelectingTableCellMode = 0; return NS_OK;} NS_IMETHOD GetTableCellSelectionStyleColor(const nsStyleColor **aStyleColor); - NS_IMETHOD GetSelection(SelectionType aType, nsIDOMSelection **aDomSelection); + NS_IMETHOD GetSelection(SelectionType aType, nsISelection **aDomSelection); NS_IMETHOD ScrollSelectionIntoView(SelectionType aType, SelectionRegion aRegion); NS_IMETHOD RepaintSelection(nsIPresContext* aPresContext, SelectionType aType); NS_IMETHOD GetFrameForNodeOffset(nsIContent *aNode, PRInt32 aOffset, HINT aHint, nsIFrame **aReturnFrame, PRInt32 *aReturnOffset); @@ -598,14 +591,14 @@ nsresult NS_NewSelection(nsIFrameSelection **aFrameSelection) return NS_OK; } -nsresult NS_NewDomSelection(nsIDOMSelection **aDomSelection); +nsresult NS_NewDomSelection(nsISelection **aDomSelection); -nsresult NS_NewDomSelection(nsIDOMSelection **aDomSelection) +nsresult NS_NewDomSelection(nsISelection **aDomSelection) { nsDOMSelection *rlist = new nsDOMSelection; if (!rlist) return NS_ERROR_OUT_OF_MEMORY; - *aDomSelection = (nsIDOMSelection *)rlist; + *aDomSelection = (nsISelection *)rlist; rlist->AddRef(); return NS_OK; } @@ -881,7 +874,7 @@ nsSelection::nsSelection() mDelayCaretOverExistingSelection = PR_TRUE; mDelayedMouseEventValid = PR_FALSE; - mReason = nsIDOMSelectionListener::NO_REASON; + mReason = nsISelectionListener::NO_REASON; } @@ -1454,33 +1447,33 @@ nsSelection::MoveCaret(PRUint32 aKeycode, PRBool aContinue, nsSelectionAmount aA InvalidateDesiredX(); pos.mDirection = eDirNext; mHint = HINTLEFT;//stick to this line - PostReason(nsIDOMSelectionListener::KEYPRESS_REASON); + PostReason(nsISelectionListener::KEYPRESS_REASON); break; case nsIDOMKeyEvent::DOM_VK_LEFT : //no break InvalidateDesiredX(); mHint = HINTRIGHT;//stick to opposite of movement - PostReason(nsIDOMSelectionListener::KEYPRESS_REASON); + PostReason(nsISelectionListener::KEYPRESS_REASON); break; case nsIDOMKeyEvent::DOM_VK_DOWN : pos.mAmount = eSelectLine; pos.mDirection = eDirNext;//no break here - PostReason(nsIDOMSelectionListener::KEYPRESS_REASON); + PostReason(nsISelectionListener::KEYPRESS_REASON); break; case nsIDOMKeyEvent::DOM_VK_UP : pos.mAmount = eSelectLine; - PostReason(nsIDOMSelectionListener::KEYPRESS_REASON); + PostReason(nsISelectionListener::KEYPRESS_REASON); break; case nsIDOMKeyEvent::DOM_VK_HOME : InvalidateDesiredX(); pos.mAmount = eSelectBeginLine; mHint = HINTRIGHT;//stick to opposite of movement - PostReason(nsIDOMSelectionListener::KEYPRESS_REASON); + PostReason(nsISelectionListener::KEYPRESS_REASON); break; case nsIDOMKeyEvent::DOM_VK_END : InvalidateDesiredX(); pos.mAmount = eSelectEndLine; mHint = HINTLEFT;//stick to this line - PostReason(nsIDOMSelectionListener::KEYPRESS_REASON); + PostReason(nsISelectionListener::KEYPRESS_REASON); break; default :return NS_ERROR_FAILURE; } @@ -1509,7 +1502,7 @@ nsSelection::MoveCaret(PRUint32 aKeycode, PRBool aContinue, nsSelectionAmount aA if (NS_SUCCEEDED(result = frame->PeekOffset(context, &pos)) && pos.mResultContent) { mHint = (HINT)pos.mPreferLeft; - PostReason(nsIDOMSelectionListener::MOUSEUP_REASON);//force an update as though we used the mouse. + PostReason(nsISelectionListener::MOUSEUP_REASON);//force an update as though we used the mouse. result = TakeFocus(pos.mResultContent, pos.mContentOffset, pos.mContentOffset, aContinue, PR_FALSE); } } @@ -1569,13 +1562,23 @@ nsSelection::HandleKeyEvent(nsIPresContext* aPresContext, nsGUIEvent *aGuiEvent) //BEGIN nsIFrameSelection methods NS_IMETHODIMP -nsDOMSelection::ToString(const nsAReadableString& aFormatType, PRUint32 aFlags, PRInt32 aWrapCount, nsAWritableString& aReturn) +nsDOMSelection::ToString(PRUnichar **aReturn) +{ + return ToStringWithFormat("text/plain", 0, 0, aReturn); +} + + +NS_IMETHODIMP +nsDOMSelection::ToStringWithFormat(const char * aFormatType, PRUint32 aFlags, + PRInt32 aWrapCol, PRUnichar **aReturn) { nsresult rv = NS_OK; + if (!aReturn) + return NS_ERROR_NULL_POINTER; nsCOMPtr encoder; nsCAutoString formatType( NS_DOC_ENCODER_CONTRACTID_BASE ); - formatType.AppendWithConversion(aFormatType); + formatType.Append(aFormatType); rv = nsComponentManager::CreateInstance(formatType, nsnull, NS_GET_IID(nsIDocumentEncoder), @@ -1594,21 +1597,23 @@ nsDOMSelection::ToString(const nsAReadableString& aFormatType, PRUint32 aFlags, // Flags should always include OutputSelectionOnly if we're coming from here: aFlags |= nsIDocumentEncoder::OutputSelectionOnly; - - rv = encoder->Init(doc, aFormatType, aFlags); + nsAutoString readstring; + readstring.AssignWithConversion(aFormatType); + rv = encoder->Init(doc, readstring, aFlags); NS_ENSURE_SUCCESS(rv, rv); encoder->SetSelection(this); - if (aWrapCount != 0) - encoder->SetWrapColumn(aWrapCount); - - rv = encoder->EncodeToString(aReturn); + if (aWrapCol != 0) + encoder->SetWrapColumn(aWrapCol); + nsAutoString tmp; + rv = encoder->EncodeToString(tmp); + *aReturn = tmp.ToNewUnicode();//get the unicode pointer from it. this is temporary return rv; } NS_IMETHODIMP -nsDOMSelection::SetHint(PRBool aHintRight) +nsDOMSelection::SetInterlinePosition(PRBool aHintRight) { nsIFrameSelection::HINT hint; if (aHintRight) @@ -1619,7 +1624,7 @@ nsDOMSelection::SetHint(PRBool aHintRight) } NS_IMETHODIMP -nsDOMSelection::GetHint(PRBool *aHintRight) +nsDOMSelection::GetInterlinePosition(PRBool *aHintRight) { nsIFrameSelection::HINT hint; nsresult rv = mFrameSelection->GetHint(&hint); @@ -1643,7 +1648,7 @@ nsSelection::HandleClick(nsIContent *aNewFocus, PRUint32 aContentOffset, // Don't take focus when dragging off of a table if (!mSelectingTableCells) { - PostReason(nsIDOMSelectionListener::MOUSEDOWN_REASON + nsIDOMSelectionListener::DRAG_REASON); + PostReason(nsISelectionListener::MOUSEDOWN_REASON + nsISelectionListener::DRAG_REASON); return TakeFocus(aNewFocus, aContentOffset, aContentEndOffset, aContinueSelection, aMultipleSelection); } @@ -1839,7 +1844,7 @@ printf("SetMouseDownState to FALSE - stopping cell selection\n"); mSelectingTableCells = PR_FALSE; mStartSelectedCell = nsnull; mEndSelectedCell = nsnull; - PostReason(aState?nsIDOMSelectionListener::MOUSEDOWN_REASON:nsIDOMSelectionListener::MOUSEUP_REASON);//not a drag reason + PostReason(aState?nsISelectionListener::MOUSEDOWN_REASON:nsISelectionListener::MOUSEUP_REASON);//not a drag reason NotifySelectionListeners(nsISelectionController::SELECTION_NORMAL);//notify that reason is mouse up please. } return NS_OK; @@ -1870,14 +1875,14 @@ nsSelection::GetTableCellSelectionStyleColor(const nsStyleColor **aStyleColor) NS_IMETHODIMP -nsSelection::GetSelection(SelectionType aType, nsIDOMSelection **aDomSelection) +nsSelection::GetSelection(SelectionType aType, nsISelection **aDomSelection) { if (!aDomSelection) return NS_ERROR_NULL_POINTER; PRInt8 index = GetIndexFromSelectionType(aType); if (index < 0) return NS_ERROR_INVALID_ARG; - *aDomSelection = mDomSelections[index]; + *aDomSelection = NS_REINTERPRET_CAST(nsISelection *,mDomSelections[index]); (*aDomSelection)->AddRef(); return NS_OK; } @@ -2097,7 +2102,7 @@ NS_IMETHODIMP nsSelection::SelectAll() } PRInt32 numChildren; rootContent->ChildCount(numChildren); - PostReason(nsIDOMSelectionListener::NO_REASON); + PostReason(nsISelectionListener::NO_REASON); return TakeFocus(mLimiter, 0, numChildren, PR_FALSE, PR_FALSE); } @@ -2200,7 +2205,7 @@ nsresult nsSelection::ClearNormalSelection() { PRInt8 index = GetIndexFromSelectionType(nsISelectionController::SELECTION_NORMAL); - return mDomSelections[index]->ClearSelection(); + return mDomSelections[index]->RemoveAllRanges(); } nsresult @@ -2296,7 +2301,7 @@ printf("HandleTableSelection: Dragged into a new cell\n"); { // Force new selection block mStartSelectedCell = nsnull; - mDomSelections[index]->ClearSelection(); + mDomSelections[index]->RemoveAllRanges(); mSelectingTableCellMode = (startRowIndex == curRowIndex) ? TABLESELECTION_ROW : TABLESELECTION_COLUMN; @@ -2346,7 +2351,7 @@ printf("HandleTableSelection: Mouse down event\n"); else { // No cells selected -- remove non-cell selection - mDomSelections[index]->ClearSelection(); + mDomSelections[index]->RemoveAllRanges(); } mSelectingTableCells = PR_TRUE; // Signal to start drag-cell-selection mSelectingTableCellMode = aTarget; @@ -2370,8 +2375,8 @@ printf("HandleTableSelection: Saving mUnselectCellOnMouseUp\n"); nsCOMPtr previousCellContent = do_QueryInterface(previousCellNode); if (!IsInSameTable(previousCellContent, childContent, nsnull)) { - mDomSelections[index]->ClearSelection(); - // Reset selection mode that is cleared in ClearSelection + mDomSelections[index]->RemoveAllRanges(); + // Reset selection mode that is cleared in RemoveAllRanges mSelectingTableCellMode = aTarget; } @@ -2391,7 +2396,7 @@ printf("HandleTableSelection: Saving mUnselectCellOnMouseUp\n"); mEndSelectedCell = nsnull; // Remove existing selection and select the table - mDomSelections[index]->ClearSelection(); + mDomSelections[index]->RemoveAllRanges(); return CreateAndAddRange(parentNode, aContentOffset); } else if (aTarget == TABLESELECTION_ROW || aTarget == TABLESELECTION_COLUMN) @@ -2403,8 +2408,8 @@ printf("HandleTableSelection: Saving mUnselectCellOnMouseUp\n"); // Force new selection block mStartSelectedCell = nsnull; - mDomSelections[index]->ClearSelection(); - // Always do this AFTER ClearSelection + mDomSelections[index]->RemoveAllRanges(); + // Always do this AFTER RemoveAllRanges mSelectingTableCellMode = aTarget; return SelectRowOrColumn(childContent, aTarget); } @@ -3056,7 +3061,7 @@ nsSelection::GetHint(HINT *aHintRight) #pragma mark - #endif -//BEGIN nsIDOMSelection interface implementations +//BEGIN nsISelection interface implementations @@ -3206,7 +3211,7 @@ nsSelection::GetLimiter(nsIContent **aLimiterContent) } -//END nsIDOMSelection interface implementations +//END nsISelection interface implementations #ifdef XP_MAC #pragma mark - @@ -3227,7 +3232,6 @@ nsDOMSelection::nsDOMSelection(nsSelection *aList) mFixupState = PR_FALSE; mDirection = eDirNext; NS_NewISupportsArray(getter_AddRefs(mRangeArray)); - mScriptObject = nsnull; mAutoScrollTimer = nsnull; NS_NewISupportsArray(getter_AddRefs(mSelectionListeners)); NS_INIT_REFCNT(); @@ -3240,7 +3244,6 @@ nsDOMSelection::nsDOMSelection() mFixupState = PR_FALSE; mDirection = eDirNext; NS_NewISupportsArray(getter_AddRefs(mRangeArray)); - mScriptObject = nsnull; mAutoScrollTimer = nsnull; NS_NewISupportsArray(getter_AddRefs(mSelectionListeners)); NS_INIT_REFCNT(); @@ -3281,7 +3284,7 @@ NS_IMPL_ADDREF(nsDOMSelection) NS_IMPL_RELEASE(nsDOMSelection) -NS_IMPL_QUERY_INTERFACE4(nsDOMSelection, nsIDOMSelection, nsIScriptObjectOwner, nsISupportsWeakReference, nsIIndependentSelection) +NS_IMPL_QUERY_INTERFACE4(nsDOMSelection, nsISelection, nsISelectionPrivate, nsISupportsWeakReference, nsIIndependentSelection) NS_IMETHODIMP @@ -4517,10 +4520,10 @@ nsDOMSelection::GetEnumerator(nsIEnumerator **aIterator) -/** ClearSelection zeroes the selection +/** RemoveAllRanges zeroes the selection */ NS_IMETHODIMP -nsDOMSelection::ClearSelection() +nsDOMSelection::RemoveAllRanges() { if (!mFrameSelection) return NS_OK;//nothing to do @@ -5541,7 +5544,7 @@ nsDOMSelection::SelectAllChildren(nsIDOMNode* aParentNode) if (mFrameSelection) { - mFrameSelection->PostReason(nsIDOMSelectionListener::SELECTALL_REASON); + mFrameSelection->PostReason(nsISelectionListener::SELECTALL_REASON); } nsresult result = Collapse(aParentNode, 0); if (NS_SUCCEEDED(result)) @@ -5554,7 +5557,7 @@ nsDOMSelection::SelectAllChildren(nsIDOMNode* aParentNode) GetChildOffset(lastChild, aParentNode, numBodyChildren); if (mFrameSelection) { - mFrameSelection->PostReason(nsIDOMSelectionListener::SELECTALL_REASON); + mFrameSelection->PostReason(nsISelectionListener::SELECTALL_REASON); } result = Extend(aParentNode, numBodyChildren+1); } @@ -6644,7 +6647,7 @@ nsDOMSelection::ScrollIntoView(SelectionRegion aRegion) NS_IMETHODIMP -nsDOMSelection::AddSelectionListener(nsIDOMSelectionListener* aNewListener) +nsDOMSelection::AddSelectionListener(nsISelectionListener* aNewListener) { if (!mSelectionListeners) return NS_ERROR_FAILURE; @@ -6660,7 +6663,7 @@ nsDOMSelection::AddSelectionListener(nsIDOMSelectionListener* aNewListener) NS_IMETHODIMP -nsDOMSelection::RemoveSelectionListener(nsIDOMSelectionListener* aListenerToRemove) +nsDOMSelection::RemoveSelectionListener(nsISelectionListener* aListenerToRemove) { if (!mSelectionListeners) return NS_ERROR_FAILURE; @@ -6702,7 +6705,7 @@ nsDOMSelection::NotifySelectionListeners() for (PRUint32 i = 0; i < cnt;i++) { nsCOMPtr isupports(dont_AddRef(mSelectionListeners->ElementAt(i))); - nsCOMPtr thisListener = do_QueryInterface(isupports); + nsCOMPtr thisListener = do_QueryInterface(isupports); if (thisListener) thisListener->NotifySelectionChanged(domdoc,this, reason); } @@ -6737,27 +6740,3 @@ nsDOMSelection::DeleteFromDocument() return mFrameSelection->DeleteFromDocument(); } -// BEGIN nsIScriptObjectOwner interface implementations -NS_IMETHODIMP -nsDOMSelection::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject) -{ - nsresult res = NS_OK; - nsIScriptGlobalObject *globalObj = aContext->GetGlobalObject(); - - if (nsnull == mScriptObject) { - res = NS_NewScriptSelection(aContext, (nsISupports *)(nsIDOMSelection *)this, globalObj, (void**)&mScriptObject); - } - *aScriptObject = mScriptObject; - - NS_RELEASE(globalObj); - return res; -} - -NS_IMETHODIMP -nsDOMSelection::SetScriptObject(void *aScriptObject) -{ - mScriptObject = aScriptObject; - return NS_OK; -} - -// END nsIScriptObjectOwner interface implementations diff --git a/mozilla/layout/base/src/nsXIFConverter.cpp b/mozilla/layout/base/src/nsXIFConverter.cpp index 99c9f3574f0..4cf23dd2c5e 100644 --- a/mozilla/layout/base/src/nsXIFConverter.cpp +++ b/mozilla/layout/base/src/nsXIFConverter.cpp @@ -22,7 +22,7 @@ #include "nsCOMPtr.h" #include "nsXIFConverter.h" #include -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsReadableUtils.h" MOZ_DECL_CTOR_COUNTER(nsXIFConverter); @@ -100,7 +100,7 @@ nsXIFConverter::Init(nsAWritableString& aBuffer) } NS_IMETHODIMP -nsXIFConverter::SetSelection(nsIDOMSelection* aSelection) +nsXIFConverter::SetSelection(nsISelection* aSelection) { NS_ENSURE_ARG_POINTER(aSelection); NS_ENSURE_TRUE(mBuffer,NS_ERROR_NOT_INITIALIZED); @@ -121,10 +121,10 @@ nsXIFConverter::SetSelection(nsIDOMSelection* aSelection) NS_IMETHODIMP -nsXIFConverter::GetSelection(nsIDOMSelection** aSelection) +nsXIFConverter::GetSelection(nsISelection** aSelection) { NS_ENSURE_ARG_POINTER(aSelection); - nsCOMPtr sel = do_QueryReferent(mSelectionWeak); + nsCOMPtr sel = do_QueryReferent(mSelectionWeak); NS_IF_ADDREF(*aSelection = sel); return *aSelection?NS_OK :NS_ERROR_FAILURE; } diff --git a/mozilla/layout/base/src/nsXIFConverter.h b/mozilla/layout/base/src/nsXIFConverter.h index 3e660b7951f..7d978d34dd8 100644 --- a/mozilla/layout/base/src/nsXIFConverter.h +++ b/mozilla/layout/base/src/nsXIFConverter.h @@ -26,7 +26,7 @@ #include "nsWeakReference.h" #include "nsIXIFConverter.h" -class nsIDOMSelection; +class nsISelection; class nsXIFConverter :public nsIXIFConverter { @@ -142,9 +142,9 @@ public: NS_IMETHOD AppendWithEntityConversion(const nsAReadableString& aName, nsAWritableString& aOutStr); - NS_IMETHOD SetSelection(nsIDOMSelection* aSelection); + NS_IMETHOD SetSelection(nsISelection* aSelection); - NS_IMETHOD GetSelection(nsIDOMSelection** aSelection); + NS_IMETHOD GetSelection(nsISelection** aSelection); //helper NS_IMETHOD WriteDebugFile(); // saves to a temp file }; diff --git a/mozilla/layout/build/nsLayoutFactory.cpp b/mozilla/layout/build/nsLayoutFactory.cpp index 3b9789da2e6..13483553d08 100644 --- a/mozilla/layout/build/nsLayoutFactory.cpp +++ b/mozilla/layout/build/nsLayoutFactory.cpp @@ -29,7 +29,7 @@ #include "nsITextContent.h" #include "nsIPresShell.h" #include "nsIPresContext.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIFrameUtil.h" #include "nsHTMLAtoms.h" @@ -125,7 +125,7 @@ static NS_DEFINE_CID(kComputedDOMStyleCID, NS_COMPUTEDDOMSTYLE_CID); extern nsresult NS_NewSelection(nsIFrameSelection** aResult); -extern nsresult NS_NewDomSelection(nsIDOMSelection** aResult); +extern nsresult NS_NewDomSelection(nsISelection** aResult); extern nsresult NS_NewRange(nsIDOMRange** aResult); extern nsresult NS_NewContentIterator(nsIContentIterator** aResult); extern nsresult NS_NewGenRegularIterator(nsIContentIterator** aResult); @@ -271,7 +271,7 @@ nsLayoutFactory::CreateInstance(nsISupports *aOuter, } } else if (mClassID.Equals(kDOMSelectionCID)) { - res = NS_NewDomSelection((nsIDOMSelection**)&inst); + res = NS_NewDomSelection((nsISelection**)&inst); if (NS_FAILED(res)) { LOG_NEW_FAILURE("NS_NewDomSelection", res); return res; diff --git a/mozilla/layout/events/src/nsEventStateManager.cpp b/mozilla/layout/events/src/nsEventStateManager.cpp index 3b286f3bb71..0dbc1534664 100644 --- a/mozilla/layout/events/src/nsEventStateManager.cpp +++ b/mozilla/layout/events/src/nsEventStateManager.cpp @@ -47,7 +47,7 @@ #include "nsIWebShell.h" #include "nsIBaseWindow.h" #include "nsIScrollableView.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIFrameSelection.h" #include "nsIDeviceContext.h" #include "nsIScriptGlobalObject.h" diff --git a/mozilla/layout/generic/nsFrame.cpp b/mozilla/layout/generic/nsFrame.cpp index 50f4800f25c..9007a97a567 100644 --- a/mozilla/layout/generic/nsFrame.cpp +++ b/mozilla/layout/generic/nsFrame.cpp @@ -49,7 +49,7 @@ #include "nsIDeviceContext.h" #include "nsHTMLIIDs.h" #include "nsIEventStateManager.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIFrameSelection.h" #include "nsHTMLParts.h" #include "nsLayoutAtoms.h" @@ -1323,7 +1323,7 @@ nsFrame::PeekBackwardAndForward(nsSelectionAmount aAmountBack, if (NS_FAILED(rv)) return rv; - nsCOMPtr selection; + nsCOMPtr selection; if (NS_SUCCEEDED(selcon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection)))){ rv = selection->Collapse(startNode,startpos.mContentOffset); diff --git a/mozilla/layout/generic/nsSelection.cpp b/mozilla/layout/generic/nsSelection.cpp index 745a54067c5..ed826d6611e 100644 --- a/mozilla/layout/generic/nsSelection.cpp +++ b/mozilla/layout/generic/nsSelection.cpp @@ -20,7 +20,7 @@ */ /* - * Implementation of selection: nsIDOMSelection and nsIFrameSelection + * Implementation of selection: nsISelection,nsISelectionPrivate and nsIFrameSelection */ #include "nsCOMPtr.h" @@ -29,8 +29,9 @@ #include "nsIEnumerator.h" #include "nsIDOMRange.h" #include "nsIFrameSelection.h" -#include "nsIDOMSelection.h" -#include "nsIDOMSelectionListener.h" +#include "nsISelection.h" +#include "nsISelectionPrivate.h" +#include "nsISelectionListener.h" #include "nsIFocusTracker.h" #include "nsIComponentManager.h" #include "nsLayoutCID.h" @@ -45,7 +46,7 @@ #include "nsIDOMNodeList.h" #include "nsITextContent.h" -#include "nsIDOMSelectionListener.h" +#include "nsISelectionListener.h" #include "nsIContentIterator.h" #include "nsIDocumentEncoder.h" #include "nsIIndependentSelection.h" @@ -58,8 +59,6 @@ #include "nsIPresShell.h" #include "nsICaret.h" -#include "nsIScriptObjectOwner.h" -#include "nsIScriptGlobalObject.h" // included for view scrolling #include "nsIViewManager.h" @@ -113,7 +112,7 @@ class nsSelectionIterator; class nsSelection; class nsAutoScrollTimer; -class nsDOMSelection : public nsIDOMSelection , public nsIScriptObjectOwner, public nsSupportsWeakReference, public nsIIndependentSelection +class nsDOMSelection : public nsISelection , public nsISelectionPrivate, public nsSupportsWeakReference, public nsIIndependentSelection { public: nsDOMSelection(); @@ -124,7 +123,7 @@ public: /*BEGIN nsIIndependentSelection interface implementations */ NS_IMETHOD SetPresShell(nsIPresShell *aPresShell); - /*BEGIN nsIDOMSelection interface implementations*/ + /*BEGIN nsISelection,Private interface implementations*/ NS_IMETHOD GetAnchorNode(nsIDOMNode** aAnchorNode); NS_IMETHOD GetAnchorOffset(PRInt32* aAnchorOffset); NS_IMETHOD GetFocusNode(nsIDOMNode** aFocusNode); @@ -132,7 +131,7 @@ public: NS_IMETHOD GetIsCollapsed(PRBool* aIsCollapsed); NS_IMETHOD GetRangeCount(PRInt32* aRangeCount); NS_IMETHOD GetRangeAt(PRInt32 aIndex, nsIDOMRange** aReturn); - NS_IMETHOD ClearSelection(); + NS_IMETHOD RemoveAllRanges(); NS_IMETHOD Collapse(nsIDOMNode* aParentNode, PRInt32 aOffset); NS_IMETHOD CollapseToStart(); NS_IMETHOD CollapseToEnd(); @@ -146,21 +145,17 @@ public: NS_IMETHOD StartBatchChanges(); NS_IMETHOD EndBatchChanges(); - NS_IMETHOD AddSelectionListener(nsIDOMSelectionListener* aNewListener); - NS_IMETHOD RemoveSelectionListener(nsIDOMSelectionListener* aListenerToRemove); + NS_IMETHOD AddSelectionListener(nsISelectionListener* aNewListener); + NS_IMETHOD RemoveSelectionListener(nsISelectionListener* aListenerToRemove); NS_IMETHOD GetEnumerator(nsIEnumerator **aIterator); - NS_IMETHOD ToString(const nsAReadableString& aFormatType, PRUint32 aFlags, PRInt32 aWrapCount, nsAWritableString& aReturn); + NS_IMETHOD ToString(PRUnichar **_retval); + NS_IMETHOD ToStringWithFormat(const char *aFormatType, PRUint32 aFlags, PRInt32 aWrapCount, PRUnichar ** aReturn); - NS_IMETHOD SetHint(PRBool aHintRight); - NS_IMETHOD GetHint(PRBool *aHintRight); + NS_IMETHOD GetInterlinePosition(PRBool *aInterlinePosition); + NS_IMETHOD SetInterlinePosition(PRBool aInterlinePosition); -/*END nsIDOMSelection interface implementations*/ - -/*BEGIN nsIScriptObjectOwner interface implementations*/ - NS_IMETHOD GetScriptObject(nsIScriptContext *aContext, void** aScriptObject); - NS_IMETHOD SetScriptObject(void *aScriptObject); -/*END nsIScriptObjectOwner interface implementations*/ +/*END nsISelection interface implementations*/ // utility methods for scrolling the selection into view nsresult GetPresContext(nsIPresContext **aPresContext); @@ -259,8 +254,6 @@ private: nsSelection *mFrameSelection; nsWeakPtr mPresShellWeak; //weak reference to presshell. - // for nsIScriptObjectOwner - void* mScriptObject; SelectionType mType;//type of this nsDOMSelection; nsAutoScrollTimer *mAutoScrollTimer; // timer for autoscrolling. nsCOMPtr mSelectionListeners; @@ -270,9 +263,9 @@ private: class nsSelectionBatcher { private: - nsCOMPtr mSelection; + nsCOMPtr mSelection; public: - nsSelectionBatcher(nsIDOMSelection *aSelection) : mSelection(aSelection) + nsSelectionBatcher(nsISelectionPrivate *aSelection) : mSelection(aSelection) { if (mSelection) mSelection->StartBatchChanges(); } @@ -313,7 +306,7 @@ public: NS_IMETHOD ClearTableCellSelection(){mSelectingTableCellMode = 0; return NS_OK;} NS_IMETHOD GetTableCellSelectionStyleColor(const nsStyleColor **aStyleColor); - NS_IMETHOD GetSelection(SelectionType aType, nsIDOMSelection **aDomSelection); + NS_IMETHOD GetSelection(SelectionType aType, nsISelection **aDomSelection); NS_IMETHOD ScrollSelectionIntoView(SelectionType aType, SelectionRegion aRegion); NS_IMETHOD RepaintSelection(nsIPresContext* aPresContext, SelectionType aType); NS_IMETHOD GetFrameForNodeOffset(nsIContent *aNode, PRInt32 aOffset, HINT aHint, nsIFrame **aReturnFrame, PRInt32 *aReturnOffset); @@ -598,14 +591,14 @@ nsresult NS_NewSelection(nsIFrameSelection **aFrameSelection) return NS_OK; } -nsresult NS_NewDomSelection(nsIDOMSelection **aDomSelection); +nsresult NS_NewDomSelection(nsISelection **aDomSelection); -nsresult NS_NewDomSelection(nsIDOMSelection **aDomSelection) +nsresult NS_NewDomSelection(nsISelection **aDomSelection) { nsDOMSelection *rlist = new nsDOMSelection; if (!rlist) return NS_ERROR_OUT_OF_MEMORY; - *aDomSelection = (nsIDOMSelection *)rlist; + *aDomSelection = (nsISelection *)rlist; rlist->AddRef(); return NS_OK; } @@ -881,7 +874,7 @@ nsSelection::nsSelection() mDelayCaretOverExistingSelection = PR_TRUE; mDelayedMouseEventValid = PR_FALSE; - mReason = nsIDOMSelectionListener::NO_REASON; + mReason = nsISelectionListener::NO_REASON; } @@ -1454,33 +1447,33 @@ nsSelection::MoveCaret(PRUint32 aKeycode, PRBool aContinue, nsSelectionAmount aA InvalidateDesiredX(); pos.mDirection = eDirNext; mHint = HINTLEFT;//stick to this line - PostReason(nsIDOMSelectionListener::KEYPRESS_REASON); + PostReason(nsISelectionListener::KEYPRESS_REASON); break; case nsIDOMKeyEvent::DOM_VK_LEFT : //no break InvalidateDesiredX(); mHint = HINTRIGHT;//stick to opposite of movement - PostReason(nsIDOMSelectionListener::KEYPRESS_REASON); + PostReason(nsISelectionListener::KEYPRESS_REASON); break; case nsIDOMKeyEvent::DOM_VK_DOWN : pos.mAmount = eSelectLine; pos.mDirection = eDirNext;//no break here - PostReason(nsIDOMSelectionListener::KEYPRESS_REASON); + PostReason(nsISelectionListener::KEYPRESS_REASON); break; case nsIDOMKeyEvent::DOM_VK_UP : pos.mAmount = eSelectLine; - PostReason(nsIDOMSelectionListener::KEYPRESS_REASON); + PostReason(nsISelectionListener::KEYPRESS_REASON); break; case nsIDOMKeyEvent::DOM_VK_HOME : InvalidateDesiredX(); pos.mAmount = eSelectBeginLine; mHint = HINTRIGHT;//stick to opposite of movement - PostReason(nsIDOMSelectionListener::KEYPRESS_REASON); + PostReason(nsISelectionListener::KEYPRESS_REASON); break; case nsIDOMKeyEvent::DOM_VK_END : InvalidateDesiredX(); pos.mAmount = eSelectEndLine; mHint = HINTLEFT;//stick to this line - PostReason(nsIDOMSelectionListener::KEYPRESS_REASON); + PostReason(nsISelectionListener::KEYPRESS_REASON); break; default :return NS_ERROR_FAILURE; } @@ -1509,7 +1502,7 @@ nsSelection::MoveCaret(PRUint32 aKeycode, PRBool aContinue, nsSelectionAmount aA if (NS_SUCCEEDED(result = frame->PeekOffset(context, &pos)) && pos.mResultContent) { mHint = (HINT)pos.mPreferLeft; - PostReason(nsIDOMSelectionListener::MOUSEUP_REASON);//force an update as though we used the mouse. + PostReason(nsISelectionListener::MOUSEUP_REASON);//force an update as though we used the mouse. result = TakeFocus(pos.mResultContent, pos.mContentOffset, pos.mContentOffset, aContinue, PR_FALSE); } } @@ -1569,13 +1562,23 @@ nsSelection::HandleKeyEvent(nsIPresContext* aPresContext, nsGUIEvent *aGuiEvent) //BEGIN nsIFrameSelection methods NS_IMETHODIMP -nsDOMSelection::ToString(const nsAReadableString& aFormatType, PRUint32 aFlags, PRInt32 aWrapCount, nsAWritableString& aReturn) +nsDOMSelection::ToString(PRUnichar **aReturn) +{ + return ToStringWithFormat("text/plain", 0, 0, aReturn); +} + + +NS_IMETHODIMP +nsDOMSelection::ToStringWithFormat(const char * aFormatType, PRUint32 aFlags, + PRInt32 aWrapCol, PRUnichar **aReturn) { nsresult rv = NS_OK; + if (!aReturn) + return NS_ERROR_NULL_POINTER; nsCOMPtr encoder; nsCAutoString formatType( NS_DOC_ENCODER_CONTRACTID_BASE ); - formatType.AppendWithConversion(aFormatType); + formatType.Append(aFormatType); rv = nsComponentManager::CreateInstance(formatType, nsnull, NS_GET_IID(nsIDocumentEncoder), @@ -1594,21 +1597,23 @@ nsDOMSelection::ToString(const nsAReadableString& aFormatType, PRUint32 aFlags, // Flags should always include OutputSelectionOnly if we're coming from here: aFlags |= nsIDocumentEncoder::OutputSelectionOnly; - - rv = encoder->Init(doc, aFormatType, aFlags); + nsAutoString readstring; + readstring.AssignWithConversion(aFormatType); + rv = encoder->Init(doc, readstring, aFlags); NS_ENSURE_SUCCESS(rv, rv); encoder->SetSelection(this); - if (aWrapCount != 0) - encoder->SetWrapColumn(aWrapCount); - - rv = encoder->EncodeToString(aReturn); + if (aWrapCol != 0) + encoder->SetWrapColumn(aWrapCol); + nsAutoString tmp; + rv = encoder->EncodeToString(tmp); + *aReturn = tmp.ToNewUnicode();//get the unicode pointer from it. this is temporary return rv; } NS_IMETHODIMP -nsDOMSelection::SetHint(PRBool aHintRight) +nsDOMSelection::SetInterlinePosition(PRBool aHintRight) { nsIFrameSelection::HINT hint; if (aHintRight) @@ -1619,7 +1624,7 @@ nsDOMSelection::SetHint(PRBool aHintRight) } NS_IMETHODIMP -nsDOMSelection::GetHint(PRBool *aHintRight) +nsDOMSelection::GetInterlinePosition(PRBool *aHintRight) { nsIFrameSelection::HINT hint; nsresult rv = mFrameSelection->GetHint(&hint); @@ -1643,7 +1648,7 @@ nsSelection::HandleClick(nsIContent *aNewFocus, PRUint32 aContentOffset, // Don't take focus when dragging off of a table if (!mSelectingTableCells) { - PostReason(nsIDOMSelectionListener::MOUSEDOWN_REASON + nsIDOMSelectionListener::DRAG_REASON); + PostReason(nsISelectionListener::MOUSEDOWN_REASON + nsISelectionListener::DRAG_REASON); return TakeFocus(aNewFocus, aContentOffset, aContentEndOffset, aContinueSelection, aMultipleSelection); } @@ -1839,7 +1844,7 @@ printf("SetMouseDownState to FALSE - stopping cell selection\n"); mSelectingTableCells = PR_FALSE; mStartSelectedCell = nsnull; mEndSelectedCell = nsnull; - PostReason(aState?nsIDOMSelectionListener::MOUSEDOWN_REASON:nsIDOMSelectionListener::MOUSEUP_REASON);//not a drag reason + PostReason(aState?nsISelectionListener::MOUSEDOWN_REASON:nsISelectionListener::MOUSEUP_REASON);//not a drag reason NotifySelectionListeners(nsISelectionController::SELECTION_NORMAL);//notify that reason is mouse up please. } return NS_OK; @@ -1870,14 +1875,14 @@ nsSelection::GetTableCellSelectionStyleColor(const nsStyleColor **aStyleColor) NS_IMETHODIMP -nsSelection::GetSelection(SelectionType aType, nsIDOMSelection **aDomSelection) +nsSelection::GetSelection(SelectionType aType, nsISelection **aDomSelection) { if (!aDomSelection) return NS_ERROR_NULL_POINTER; PRInt8 index = GetIndexFromSelectionType(aType); if (index < 0) return NS_ERROR_INVALID_ARG; - *aDomSelection = mDomSelections[index]; + *aDomSelection = NS_REINTERPRET_CAST(nsISelection *,mDomSelections[index]); (*aDomSelection)->AddRef(); return NS_OK; } @@ -2097,7 +2102,7 @@ NS_IMETHODIMP nsSelection::SelectAll() } PRInt32 numChildren; rootContent->ChildCount(numChildren); - PostReason(nsIDOMSelectionListener::NO_REASON); + PostReason(nsISelectionListener::NO_REASON); return TakeFocus(mLimiter, 0, numChildren, PR_FALSE, PR_FALSE); } @@ -2200,7 +2205,7 @@ nsresult nsSelection::ClearNormalSelection() { PRInt8 index = GetIndexFromSelectionType(nsISelectionController::SELECTION_NORMAL); - return mDomSelections[index]->ClearSelection(); + return mDomSelections[index]->RemoveAllRanges(); } nsresult @@ -2296,7 +2301,7 @@ printf("HandleTableSelection: Dragged into a new cell\n"); { // Force new selection block mStartSelectedCell = nsnull; - mDomSelections[index]->ClearSelection(); + mDomSelections[index]->RemoveAllRanges(); mSelectingTableCellMode = (startRowIndex == curRowIndex) ? TABLESELECTION_ROW : TABLESELECTION_COLUMN; @@ -2346,7 +2351,7 @@ printf("HandleTableSelection: Mouse down event\n"); else { // No cells selected -- remove non-cell selection - mDomSelections[index]->ClearSelection(); + mDomSelections[index]->RemoveAllRanges(); } mSelectingTableCells = PR_TRUE; // Signal to start drag-cell-selection mSelectingTableCellMode = aTarget; @@ -2370,8 +2375,8 @@ printf("HandleTableSelection: Saving mUnselectCellOnMouseUp\n"); nsCOMPtr previousCellContent = do_QueryInterface(previousCellNode); if (!IsInSameTable(previousCellContent, childContent, nsnull)) { - mDomSelections[index]->ClearSelection(); - // Reset selection mode that is cleared in ClearSelection + mDomSelections[index]->RemoveAllRanges(); + // Reset selection mode that is cleared in RemoveAllRanges mSelectingTableCellMode = aTarget; } @@ -2391,7 +2396,7 @@ printf("HandleTableSelection: Saving mUnselectCellOnMouseUp\n"); mEndSelectedCell = nsnull; // Remove existing selection and select the table - mDomSelections[index]->ClearSelection(); + mDomSelections[index]->RemoveAllRanges(); return CreateAndAddRange(parentNode, aContentOffset); } else if (aTarget == TABLESELECTION_ROW || aTarget == TABLESELECTION_COLUMN) @@ -2403,8 +2408,8 @@ printf("HandleTableSelection: Saving mUnselectCellOnMouseUp\n"); // Force new selection block mStartSelectedCell = nsnull; - mDomSelections[index]->ClearSelection(); - // Always do this AFTER ClearSelection + mDomSelections[index]->RemoveAllRanges(); + // Always do this AFTER RemoveAllRanges mSelectingTableCellMode = aTarget; return SelectRowOrColumn(childContent, aTarget); } @@ -3056,7 +3061,7 @@ nsSelection::GetHint(HINT *aHintRight) #pragma mark - #endif -//BEGIN nsIDOMSelection interface implementations +//BEGIN nsISelection interface implementations @@ -3206,7 +3211,7 @@ nsSelection::GetLimiter(nsIContent **aLimiterContent) } -//END nsIDOMSelection interface implementations +//END nsISelection interface implementations #ifdef XP_MAC #pragma mark - @@ -3227,7 +3232,6 @@ nsDOMSelection::nsDOMSelection(nsSelection *aList) mFixupState = PR_FALSE; mDirection = eDirNext; NS_NewISupportsArray(getter_AddRefs(mRangeArray)); - mScriptObject = nsnull; mAutoScrollTimer = nsnull; NS_NewISupportsArray(getter_AddRefs(mSelectionListeners)); NS_INIT_REFCNT(); @@ -3240,7 +3244,6 @@ nsDOMSelection::nsDOMSelection() mFixupState = PR_FALSE; mDirection = eDirNext; NS_NewISupportsArray(getter_AddRefs(mRangeArray)); - mScriptObject = nsnull; mAutoScrollTimer = nsnull; NS_NewISupportsArray(getter_AddRefs(mSelectionListeners)); NS_INIT_REFCNT(); @@ -3281,7 +3284,7 @@ NS_IMPL_ADDREF(nsDOMSelection) NS_IMPL_RELEASE(nsDOMSelection) -NS_IMPL_QUERY_INTERFACE4(nsDOMSelection, nsIDOMSelection, nsIScriptObjectOwner, nsISupportsWeakReference, nsIIndependentSelection) +NS_IMPL_QUERY_INTERFACE4(nsDOMSelection, nsISelection, nsISelectionPrivate, nsISupportsWeakReference, nsIIndependentSelection) NS_IMETHODIMP @@ -4517,10 +4520,10 @@ nsDOMSelection::GetEnumerator(nsIEnumerator **aIterator) -/** ClearSelection zeroes the selection +/** RemoveAllRanges zeroes the selection */ NS_IMETHODIMP -nsDOMSelection::ClearSelection() +nsDOMSelection::RemoveAllRanges() { if (!mFrameSelection) return NS_OK;//nothing to do @@ -5541,7 +5544,7 @@ nsDOMSelection::SelectAllChildren(nsIDOMNode* aParentNode) if (mFrameSelection) { - mFrameSelection->PostReason(nsIDOMSelectionListener::SELECTALL_REASON); + mFrameSelection->PostReason(nsISelectionListener::SELECTALL_REASON); } nsresult result = Collapse(aParentNode, 0); if (NS_SUCCEEDED(result)) @@ -5554,7 +5557,7 @@ nsDOMSelection::SelectAllChildren(nsIDOMNode* aParentNode) GetChildOffset(lastChild, aParentNode, numBodyChildren); if (mFrameSelection) { - mFrameSelection->PostReason(nsIDOMSelectionListener::SELECTALL_REASON); + mFrameSelection->PostReason(nsISelectionListener::SELECTALL_REASON); } result = Extend(aParentNode, numBodyChildren+1); } @@ -6644,7 +6647,7 @@ nsDOMSelection::ScrollIntoView(SelectionRegion aRegion) NS_IMETHODIMP -nsDOMSelection::AddSelectionListener(nsIDOMSelectionListener* aNewListener) +nsDOMSelection::AddSelectionListener(nsISelectionListener* aNewListener) { if (!mSelectionListeners) return NS_ERROR_FAILURE; @@ -6660,7 +6663,7 @@ nsDOMSelection::AddSelectionListener(nsIDOMSelectionListener* aNewListener) NS_IMETHODIMP -nsDOMSelection::RemoveSelectionListener(nsIDOMSelectionListener* aListenerToRemove) +nsDOMSelection::RemoveSelectionListener(nsISelectionListener* aListenerToRemove) { if (!mSelectionListeners) return NS_ERROR_FAILURE; @@ -6702,7 +6705,7 @@ nsDOMSelection::NotifySelectionListeners() for (PRUint32 i = 0; i < cnt;i++) { nsCOMPtr isupports(dont_AddRef(mSelectionListeners->ElementAt(i))); - nsCOMPtr thisListener = do_QueryInterface(isupports); + nsCOMPtr thisListener = do_QueryInterface(isupports); if (thisListener) thisListener->NotifySelectionChanged(domdoc,this, reason); } @@ -6737,27 +6740,3 @@ nsDOMSelection::DeleteFromDocument() return mFrameSelection->DeleteFromDocument(); } -// BEGIN nsIScriptObjectOwner interface implementations -NS_IMETHODIMP -nsDOMSelection::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject) -{ - nsresult res = NS_OK; - nsIScriptGlobalObject *globalObj = aContext->GetGlobalObject(); - - if (nsnull == mScriptObject) { - res = NS_NewScriptSelection(aContext, (nsISupports *)(nsIDOMSelection *)this, globalObj, (void**)&mScriptObject); - } - *aScriptObject = mScriptObject; - - NS_RELEASE(globalObj); - return res; -} - -NS_IMETHODIMP -nsDOMSelection::SetScriptObject(void *aScriptObject) -{ - mScriptObject = aScriptObject; - return NS_OK; -} - -// END nsIScriptObjectOwner interface implementations diff --git a/mozilla/layout/generic/nsTextFrame.cpp b/mozilla/layout/generic/nsTextFrame.cpp index 0339589db40..6af98138915 100644 --- a/mozilla/layout/generic/nsTextFrame.cpp +++ b/mozilla/layout/generic/nsTextFrame.cpp @@ -57,7 +57,7 @@ #include "nsTextTransformer.h" #include "nsLayoutAtoms.h" #include "nsIFrameSelection.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIDOMRange.h" #include "nsILookAndFeel.h" diff --git a/mozilla/layout/html/base/src/nsFrame.cpp b/mozilla/layout/html/base/src/nsFrame.cpp index 50f4800f25c..9007a97a567 100644 --- a/mozilla/layout/html/base/src/nsFrame.cpp +++ b/mozilla/layout/html/base/src/nsFrame.cpp @@ -49,7 +49,7 @@ #include "nsIDeviceContext.h" #include "nsHTMLIIDs.h" #include "nsIEventStateManager.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIFrameSelection.h" #include "nsHTMLParts.h" #include "nsLayoutAtoms.h" @@ -1323,7 +1323,7 @@ nsFrame::PeekBackwardAndForward(nsSelectionAmount aAmountBack, if (NS_FAILED(rv)) return rv; - nsCOMPtr selection; + nsCOMPtr selection; if (NS_SUCCEEDED(selcon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection)))){ rv = selection->Collapse(startNode,startpos.mContentOffset); diff --git a/mozilla/layout/html/base/src/nsPresShell.cpp b/mozilla/layout/html/base/src/nsPresShell.cpp index 58abb88329e..ee8c92ea626 100644 --- a/mozilla/layout/html/base/src/nsPresShell.cpp +++ b/mozilla/layout/html/base/src/nsPresShell.cpp @@ -61,13 +61,14 @@ #include "nsIEventStateManager.h" #include "nsDOMEvent.h" #include "nsHTMLParts.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsISelectionController.h" #include "nsLayoutCID.h" #include "nsLayoutAtoms.h" #include "nsIDOMRange.h" #include "nsIDOMDocument.h" #include "nsIDOMNode.h" +#include "nsIDOMNodeList.h" #include "nsIDOMElement.h" #include "nsHTMLAtoms.h" #include "nsCOMPtr.h" @@ -745,7 +746,7 @@ public: NS_IMETHOD SetDisplaySelection(PRInt16 aToggle); NS_IMETHOD GetDisplaySelection(PRInt16 *aToggle); - NS_IMETHOD GetSelection(SelectionType aType, nsIDOMSelection** aSelection); + NS_IMETHOD GetSelection(SelectionType aType, nsISelection** aSelection); NS_IMETHOD ScrollSelectionIntoView(SelectionType aType, SelectionRegion aRegion); NS_IMETHOD RepaintSelection(SelectionType aType); NS_IMETHOD GetFrameSelection(nsIFrameSelection** aSelection); @@ -1597,7 +1598,7 @@ PresShell::GetDisplaySelection(PRInt16 *aToggle) } NS_IMETHODIMP -PresShell::GetSelection(SelectionType aType, nsIDOMSelection **aSelection) +PresShell::GetSelection(SelectionType aType, nsISelection **aSelection) { if (!aSelection || !mSelection) return NS_ERROR_NULL_POINTER; @@ -1651,7 +1652,7 @@ PresShell::EndObservingDocument() mDocument->RemoveObserver(this); } if (mSelection){ - nsCOMPtr domselection; + nsCOMPtr domselection; nsresult result; result = mSelection->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(domselection)); if (NS_FAILED(result)) @@ -2334,7 +2335,50 @@ PresShell::CompleteScroll(PRBool aForward) NS_IMETHODIMP PresShell::CompleteMove(PRBool aForward, PRBool aExtend) { - return CompleteScroll(aForward); + nsCOMPtr document; + if (NS_FAILED(GetDocument(getter_AddRefs(document))) || !document) + return NS_ERROR_FAILURE; + + nsCOMPtrnodeList; + nsAutoString bodyTag; bodyTag.AssignWithConversion("body"); + + nsCOMPtr doc = do_QueryInterface(document); + if (!doc) + return NS_ERROR_FAILURE; + nsresult result = doc->GetElementsByTagName(bodyTag, getter_AddRefs(nodeList)); + + if (NS_FAILED(result) || !nodeList) + return result?result:NS_ERROR_NULL_POINTER; + + PRUint32 count; + nodeList->GetLength(&count); + + if (count < 1) + return NS_ERROR_FAILURE; + + // Use the first body node in the list: + nsCOMPtr node; + result = nodeList->Item(0, getter_AddRefs(node)); + if (NS_SUCCEEDED(result) && node) + { + //return node->QueryInterface(NS_GET_IID(nsIDOMElement), (void **)aBodyElement); + // Is above equivalent to this: + nsCOMPtr bodyElement = do_QueryInterface(node); + if (bodyElement) + { + nsCOMPtr bodyContent = do_QueryInterface(bodyElement); + if (bodyContent) + { + PRInt32 offset = 0; + if (aForward) + { + bodyContent->ChildCount(offset); + } + result = mSelection->HandleClick(bodyContent,offset,offset,aExtend, PR_FALSE,aExtend); + } + } + } + return result; } NS_IMETHODIMP @@ -3020,7 +3064,7 @@ PresShell::DoCopy() nsString buffer; nsresult rv; - nsCOMPtr sel; + nsCOMPtr sel; nsCOMPtr manager; nsCOMPtr content; diff --git a/mozilla/layout/html/base/src/nsTextFrame.cpp b/mozilla/layout/html/base/src/nsTextFrame.cpp index 0339589db40..6af98138915 100644 --- a/mozilla/layout/html/base/src/nsTextFrame.cpp +++ b/mozilla/layout/html/base/src/nsTextFrame.cpp @@ -57,7 +57,7 @@ #include "nsTextTransformer.h" #include "nsLayoutAtoms.h" #include "nsIFrameSelection.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIDOMRange.h" #include "nsILookAndFeel.h" diff --git a/mozilla/layout/html/content/src/nsAttributeContent.cpp b/mozilla/layout/html/content/src/nsAttributeContent.cpp index 0f3ab1bc357..f4da0f72f26 100644 --- a/mozilla/layout/html/content/src/nsAttributeContent.cpp +++ b/mozilla/layout/html/content/src/nsAttributeContent.cpp @@ -31,7 +31,7 @@ #include "nsIXIFConverter.h" #include "nsRange.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIEnumerator.h" diff --git a/mozilla/layout/html/document/src/nsHTMLDocument.cpp b/mozilla/layout/html/document/src/nsHTMLDocument.cpp index ce4a1169ce5..9aeee4dd0ca 100644 --- a/mozilla/layout/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/layout/html/document/src/nsHTMLDocument.cpp @@ -93,6 +93,7 @@ #include "nsIEventListenerManager.h" #include "nsISelectElement.h" #include "nsIFrameSelection.h" +#include "nsISelectionPrivate.h"//for toStringwithformat code #include "nsICharsetDetector.h" #include "nsICharsetDetectionAdaptor.h" @@ -2842,13 +2843,14 @@ nsHTMLDocument::GetSelection(nsAWritableString& aReturn) if (!selection) return NS_OK; - nsCOMPtr domSelection; + nsCOMPtr domSelection; selection->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(domSelection)); if (!domSelection) return NS_OK; + nsCOMPtr privSel(do_QueryInterface(domSelection)); nsCOMPtr consoleService (do_GetService("mozilla.consoleservice.1")); @@ -2856,8 +2858,14 @@ nsHTMLDocument::GetSelection(nsAWritableString& aReturn) if (consoleService) { consoleService->LogStringMessage(NS_LITERAL_STRING("Deprecated method document.getSelection() called. Please use window.getSelection() instead.").get()); } - - return domSelection->ToString(NS_ConvertASCIItoUCS2("text/plain"), nsIDocumentEncoder::OutputFormatted |nsIDocumentEncoder::OutputSelectionOnly, 0, aReturn); + PRUnichar *tmp; + nsresult rv = privSel->ToStringWithFormat("text/plain", nsIDocumentEncoder::OutputFormatted |nsIDocumentEncoder::OutputSelectionOnly, 0, &tmp); + if (tmp) + { + aReturn.Assign(tmp); + nsMemory::Free(tmp); + } + return rv; } NS_IMETHODIMP @@ -4138,7 +4146,7 @@ nsHTMLDocument::GetForms(nsIDOMHTMLCollection** aForms) } PRBool -nsHTMLDocument::IsInSelection(nsIDOMSelection* aSelection, +nsHTMLDocument::IsInSelection(nsISelection* aSelection, const nsIContent* aContent) const { nsIAtom* tag; diff --git a/mozilla/layout/html/document/src/nsHTMLDocument.h b/mozilla/layout/html/document/src/nsHTMLDocument.h index 1f21a911565..81f488b15a0 100644 --- a/mozilla/layout/html/document/src/nsHTMLDocument.h +++ b/mozilla/layout/html/document/src/nsHTMLDocument.h @@ -145,7 +145,7 @@ public: /* * Like nsDocument::IsInSelection except it always includes the body node */ - virtual PRBool IsInSelection(nsIDOMSelection* aSelection, const nsIContent *aContent) const; + virtual PRBool IsInSelection(nsISelection* aSelection, const nsIContent *aContent) const; virtual nsresult Reset(nsIChannel* aChannel, nsILoadGroup* aLoadGroup); protected: diff --git a/mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp b/mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp index ec677b836d7..0390ed50883 100644 --- a/mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsGfxTextControlFrame.cpp @@ -79,7 +79,7 @@ #include "nsIDOMNode.h" #include "nsIDOMElement.h" #include "nsIDOMNodeList.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIDOMCharacterData.h" #include "nsIDocument.h" #include "nsIDOMDocument.h" @@ -275,11 +275,11 @@ nsGfxTextControlFrame::~nsGfxTextControlFrame() if (mEditor) { // remove selection listener - nsCOMPtr selection; + nsCOMPtr selection; result = mEditor->GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(result) && selection) { - nsCOMPtr selListener = do_QueryInterface(mEventListener); + nsCOMPtr selListener = do_QueryInterface(mEventListener); if (selListener) selection->RemoveSelectionListener(selListener); } @@ -564,7 +564,7 @@ nsGfxTextControlFrame::SetSelectionEndPoints(PRInt32 aSelStart, PRInt32 aSelEnd) firstTextNode->GetLength(&nodeLengthU); PRInt32 nodeLength = (PRInt32)nodeLengthU; - nsCOMPtr selection; + nsCOMPtr selection; mEditor->GetSelection(getter_AddRefs(selection)); if (!selection) return NS_ERROR_FAILURE; @@ -725,7 +725,7 @@ nsGfxTextControlFrame::GetSelectionRange(PRInt32* aSelectionStart, PRInt32* aSel NS_ASSERTION(mEditor, "Should have an editor here"); NS_ASSERTION(mDoc, "Should have an editor here"); - nsCOMPtr selection; + nsCOMPtr selection; mEditor->GetSelection(getter_AddRefs(selection)); if (!selection) return NS_ERROR_FAILURE; @@ -3142,11 +3142,11 @@ nsGfxTextControlFrame::InstallEventListeners() // add the selection listener if (mEditor && mEventListener) { - nsCOMPtrselection; + nsCOMPtrselection; result = mEditor->GetSelection(getter_AddRefs(selection)); if (NS_FAILED(result)) { return result; } if (!selection) { return NS_ERROR_NULL_POINTER; } - nsCOMPtr selectionListener = do_QueryInterface(mEventListener); + nsCOMPtr selectionListener = do_QueryInterface(mEventListener); if (!selectionListener) { return NS_ERROR_NO_INTERFACE; } result = selection->AddSelectionListener(selectionListener); if (NS_FAILED(result)) { return result; } @@ -3397,7 +3397,7 @@ nsGfxTextControlFrame::InitializeTextControl(nsIPresShell *aPresShell, nsIDOMDoc NS_ASSERTION(editor, "bad QI to nsIEditor from mEditor"); if (editor) { - nsCOMPtrselection; + nsCOMPtrselection; result = editor->GetSelection(getter_AddRefs(selection)); if (NS_FAILED(result)) { return result; } if (!selection) { return NS_ERROR_NULL_POINTER; } @@ -3505,7 +3505,7 @@ nsresult nsGfxTextControlFrame::UpdateTextControlCommands(const nsString& aComma { if (aCommand == NS_ConvertASCIItoUCS2("select")) // optimize select updates { - nsCOMPtr domSelection; + nsCOMPtr domSelection; rv = mEditor->GetSelection(getter_AddRefs(domSelection)); if (NS_FAILED(rv)) return rv; if (!domSelection) return NS_ERROR_UNEXPECTED; @@ -3995,8 +3995,8 @@ nsEnderEventListener::QueryInterface(REFNSIID aIID, void** aInstancePtr) NS_ADDREF_THIS(); return NS_OK; } - if (aIID.Equals(NS_GET_IID(nsIDOMSelectionListener))) { - *aInstancePtr = (void*)(nsIDOMSelectionListener*)this; + if (aIID.Equals(NS_GET_IID(nsISelectionListener))) { + *aInstancePtr = (void*)(nsISelectionListener*)this; NS_ADDREF_THIS(); return NS_OK; } @@ -4601,7 +4601,7 @@ nsEnderEventListener::Blur(nsIDOMEvent* aEvent) } NS_IMETHODIMP -nsEnderEventListener::NotifySelectionChanged(nsIDOMDocument *, nsIDOMSelection *, short) +nsEnderEventListener::NotifySelectionChanged(nsIDOMDocument *, nsISelection *, short) { nsGfxTextControlFrame *gfxFrame = mFrame.Reference(); if (gfxFrame && mContent) diff --git a/mozilla/layout/html/forms/src/nsGfxTextControlFrame.h b/mozilla/layout/html/forms/src/nsGfxTextControlFrame.h index 1a95a1abbe9..5b3918f4e39 100644 --- a/mozilla/layout/html/forms/src/nsGfxTextControlFrame.h +++ b/mozilla/layout/html/forms/src/nsGfxTextControlFrame.h @@ -34,7 +34,7 @@ #include "nsIDOMMouseListener.h" #include "nsIDOMDragListener.h" #include "nsIDOMFocusListener.h" -#include "nsIDOMSelectionListener.h" +#include "nsISelectionListener.h" #include "nsITransactionListener.h" #include "nsIDOMDocument.h" #include "nsIPresContext.h" @@ -51,7 +51,7 @@ #include "nsCSSFrameConstructor.h" class nsIFrame; -class nsIDOMSelection; +class nsISelection; class nsIDOMCharacterData; class nsGfxTextControlFrame; @@ -201,7 +201,7 @@ class nsEnderEventListener : public nsIEnderEventListener, public nsIDOMKeyListener, public nsIDOMMouseListener, public nsIDOMFocusListener, - public nsIDOMSelectionListener, + public nsISelectionListener, public nsITransactionListener { public: @@ -248,11 +248,11 @@ public: virtual nsresult Blur (nsIDOMEvent* aEvent); /* END interfaces from nsIDOMFocusListener*/ - /** nsIDOMSelectionListener interfaces - * @see nsIDOMSelectionListener + /** nsISelectionListener interfaces + * @see nsISelectionListener */ - NS_IMETHOD NotifySelectionChanged(nsIDOMDocument *, nsIDOMSelection *, short); - /*END interfaces from nsIDOMSelectionListener*/ + NS_IMETHOD NotifySelectionChanged(nsIDOMDocument *, nsISelection *, short); + /*END interfaces from nsISelectionListener*/ /** nsITransactionListener interfaces */ diff --git a/mozilla/layout/html/forms/src/nsGfxTextControlFrame2.cpp b/mozilla/layout/html/forms/src/nsGfxTextControlFrame2.cpp index e5164de148e..cff0586aae8 100644 --- a/mozilla/layout/html/forms/src/nsGfxTextControlFrame2.cpp +++ b/mozilla/layout/html/forms/src/nsGfxTextControlFrame2.cpp @@ -37,7 +37,8 @@ #include "nsFormControlHelper.h" #include "nsIDocumentEncoder.h" #include "nsICaret.h" -#include "nsIDOMSelectionListener.h" +#include "nsISelectionListener.h" +#include "nsISelectionPrivate.h" #include "nsIController.h" #include "nsIControllers.h" #include "nsIEditorController.h" @@ -124,7 +125,7 @@ static nsresult GetElementFactoryService(nsIElementFactory **aFactory) class nsTextInputListener : public nsIDOMKeyListener, - public nsIDOMSelectionListener, + public nsISelectionListener, public nsIDOMFocusListener, public nsIEditorObserver, public nsITransactionListener, @@ -154,9 +155,9 @@ public: virtual nsresult KeyUp(nsIDOMEvent* aKeyEvent); virtual nsresult KeyPress(nsIDOMEvent* aKeyEvent); /*END interfaces from nsIDOMKeyListener*/ -/*BEGIN nsIDOMSelectionListener Interface*/ - NS_IMETHOD NotifySelectionChanged(nsIDOMDocument* aDoc, nsIDOMSelection* aSel, PRInt16 aReason); -/*END nsIDOMSelectionListener*/ +/*BEGIN nsISelectionListener Interface*/ + NS_IMETHOD NotifySelectionChanged(nsIDOMDocument* aDoc, nsISelection* aSel, PRInt16 aReason); +/*END nsISelectionListener*/ /* BEGIN EditorObserver*/ NS_IMETHOD EditAction(); @@ -234,7 +235,7 @@ nsTextInputListener::~nsTextInputListener() NS_IMPL_QUERY_INTERFACE6(nsTextInputListener, nsIDOMKeyListener, - nsIDOMSelectionListener, + nsISelectionListener, nsIDOMFocusListener, nsIEditorObserver, nsITransactionListener, @@ -299,7 +300,7 @@ nsTextInputListener::KeyPress(nsIDOMEvent* aKeyEvent) //BEGIN NS_IDOMSELECTIONLISTENER NS_IMETHODIMP -nsTextInputListener::NotifySelectionChanged(nsIDOMDocument* aDoc, nsIDOMSelection* aSel, PRInt16 aReason) +nsTextInputListener::NotifySelectionChanged(nsIDOMDocument* aDoc, nsISelection* aSel, PRInt16 aReason) { PRBool collapsed; if (!mFrame || !aDoc || !aSel || NS_FAILED(aSel->GetIsCollapsed(&collapsed))) @@ -319,9 +320,9 @@ nsTextInputListener::NotifySelectionChanged(nsIDOMDocument* aDoc, nsIDOMSelectio // was previously selected, becase technically select all will first collapse // and then extend. Mozilla will never create an event if the selection // collapses to nothing. - if (!collapsed && (aReason & (nsIDOMSelectionListener::MOUSEUP_REASON | - nsIDOMSelectionListener::KEYPRESS_REASON | - nsIDOMSelectionListener::SELECTALL_REASON))) + if (!collapsed && (aReason & (nsISelectionListener::MOUSEUP_REASON | + nsISelectionListener::KEYPRESS_REASON | + nsISelectionListener::SELECTALL_REASON))) { nsCOMPtr content; mFrame->GetFormContent(*getter_AddRefs(content)); @@ -552,7 +553,7 @@ public: NS_IMETHOD GetDisplaySelection(PRInt16 *_retval); NS_IMETHOD SetDisplayNonTextSelection(PRBool toggle); NS_IMETHOD GetDisplayNonTextSelection(PRBool *_retval); - NS_IMETHOD GetSelection(PRInt16 type, nsIDOMSelection **_retval); + NS_IMETHOD GetSelection(PRInt16 type, nsISelection **_retval); NS_IMETHOD ScrollSelectionIntoView(PRInt16 type, PRInt16 region); NS_IMETHOD RepaintSelection(PRInt16 type); NS_IMETHOD RepaintSelection(nsIPresContext* aPresContext, SelectionType aSelectionType); @@ -660,7 +661,7 @@ nsTextInputSelectionImpl::GetDisplayNonTextSelection(PRBool *aToggle) } NS_IMETHODIMP -nsTextInputSelectionImpl::GetSelection(PRInt16 type, nsIDOMSelection **_retval) +nsTextInputSelectionImpl::GetSelection(PRInt16 type, nsISelection **_retval) { if (mFrameSelection) return mFrameSelection->GetSelection(type, _retval); @@ -706,7 +707,7 @@ nsTextInputSelectionImpl::SetCaretEnabled(PRBool enabled) if (!shell) return NS_ERROR_FAILURE; // first, tell the caret which selection to use - nsCOMPtr domSel; + nsCOMPtr domSel; GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(domSel)); if (!domSel) return NS_ERROR_FAILURE; @@ -752,7 +753,7 @@ nsTextInputSelectionImpl::SetCaretReadOnly(PRBool aReadOnly) nsCOMPtr caret; if (NS_SUCCEEDED(result = shell->GetCaret(getter_AddRefs(caret)))) { - nsCOMPtr domSel; + nsCOMPtr domSel; if (NS_SUCCEEDED(result = mFrameSelection->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(domSel)))) { return caret->SetCaretReadOnly(aReadOnly); @@ -774,7 +775,7 @@ nsTextInputSelectionImpl::GetCaretEnabled(PRBool *_retval) nsCOMPtr caret; if (NS_SUCCEEDED(result = shell->GetCaret(getter_AddRefs(caret)))) { - nsCOMPtr domSel; + nsCOMPtr domSel; if (NS_SUCCEEDED(result = mFrameSelection->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(domSel)))) { return caret->GetCaretVisible(_retval); @@ -1886,21 +1887,22 @@ nsGfxTextControlFrame2::CreateAnonymousContent(nsIPresContext* aPresContext, // Get the caret and make it a selection listener. - nsCOMPtr domSelection; + nsCOMPtr domSelection; if (NS_SUCCEEDED(mSelCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(domSelection))) && domSelection) { + nsCOMPtr selPriv(do_QueryInterface(domSelection)); nsCOMPtr caret; - nsCOMPtr listener; + nsCOMPtr listener; if (NS_SUCCEEDED(shell->GetCaret(getter_AddRefs(caret))) && caret) { listener = do_QueryInterface(caret); if (listener) { - domSelection->AddSelectionListener(listener); + selPriv->AddSelectionListener(listener); } } - domSelection->AddSelectionListener(NS_STATIC_CAST(nsIDOMSelectionListener *, mTextListener)); + selPriv->AddSelectionListener(NS_STATIC_CAST(nsISelectionListener *, mTextListener)); } // also set up the text listener as a transaction listener on the editor @@ -2476,7 +2478,7 @@ nsGfxTextControlFrame2::SetSelectionEndPoints(PRInt32 aSelStart, PRInt32 aSelEnd firstTextNode->GetLength(&nodeLengthU); PRInt32 nodeLength = (PRInt32)nodeLengthU; - nsCOMPtr selection; + nsCOMPtr selection; mTextSelImpl->GetSelection(nsISelectionController::SELECTION_NORMAL,getter_AddRefs(selection)); if (!selection) return NS_ERROR_FAILURE; @@ -2494,7 +2496,7 @@ nsGfxTextControlFrame2::SetSelectionEndPoints(PRInt32 aSelStart, PRInt32 aSelEnd aSelEnd = 0; // remove existing ranges - selection->ClearSelection(); + selection->RemoveAllRanges(); nsCOMPtr selectionRange; NS_NewRange(getter_AddRefs(selectionRange)); @@ -2602,7 +2604,7 @@ nsGfxTextControlFrame2::GetSelectionRange(PRInt32* aSelectionStart, PRInt32* aSe if (!mEditor) return NS_ERROR_NOT_INITIALIZED; - nsCOMPtr selection; + nsCOMPtr selection; mTextSelImpl->GetSelection(nsISelectionController::SELECTION_NORMAL,getter_AddRefs(selection)); if (!selection) return NS_ERROR_FAILURE; @@ -3002,10 +3004,15 @@ nsGfxTextControlFrame2::SetTextControlFrameState(const nsAReadableString& aValue } if (PR_FALSE==currentValue.Equals(aValue)) // this is necessary to avoid infinite recursion { - nsCOMPtr domSel; + nsCOMPtr domSel; + nsCOMPtr selPriv; mSelCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(domSel)); if (domSel) - domSel->StartBatchChanges(); + { + selPriv = do_QueryInterface(domSel); + if (selPriv) + selPriv->StartBatchChanges(); + } // \r is an illegal character in the dom, but people use them, // so convert windows and mac platform linebreaks to \n: // Unfortunately aValue is declared const, so we have to copy @@ -3033,8 +3040,8 @@ nsGfxTextControlFrame2::SetTextControlFrameState(const nsAReadableString& aValue else htmlEditor->InsertText(currentValue); mEditor->SetFlags(savedFlags); - if (domSel) - domSel->EndBatchChanges(); + if (selPriv) + selPriv->EndBatchChanges(); } if (mScrollableView) diff --git a/mozilla/mailnews/compose/src/nsMsgCompose.cpp b/mozilla/mailnews/compose/src/nsMsgCompose.cpp index a52b54a5268..7cdcb19faf8 100644 --- a/mozilla/mailnews/compose/src/nsMsgCompose.cpp +++ b/mozilla/mailnews/compose/src/nsMsgCompose.cpp @@ -28,7 +28,7 @@ #include "nsIDOMNodeList.h" #include "nsIDOMHTMLInputElement.h" #include "nsIDOMDocument.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIDOMNamedNodeMap.h" #include "nsMsgI18N.h" #include "nsICharsetConverterManager.h" @@ -318,7 +318,7 @@ nsresult nsMsgCompose::ConvertAndLoadComposeWindow(nsIEditorShell *aEditorShell, break; } - nsCOMPtr selection = nsnull; + nsCOMPtr selection = nsnull; nsCOMPtr parent = nsnull; PRInt32 offset; nsresult rv; diff --git a/mozilla/rdf/content/src/nsXULDocument.cpp b/mozilla/rdf/content/src/nsXULDocument.cpp index 95b6e7861bd..9311f538678 100644 --- a/mozilla/rdf/content/src/nsXULDocument.cpp +++ b/mozilla/rdf/content/src/nsXULDocument.cpp @@ -1835,7 +1835,7 @@ nsXULDocument::StyleRuleRemoved(nsIStyleSheet* aStyleSheet, } NS_IMETHODIMP -nsXULDocument::GetSelection(nsIDOMSelection** aSelection) +nsXULDocument::GetSelection(nsISelection** aSelection) { if (!mSelection) { NS_ASSERTION(0,"not initialized"); @@ -2012,7 +2012,7 @@ nsXULDocument::IsBefore(const nsIContent *aNewContent, const nsIContent* aCurren } PRBool -nsXULDocument::IsInSelection(nsIDOMSelection* aSelection, const nsIContent *aContent) const +nsXULDocument::IsInSelection(nsISelection* aSelection, const nsIContent *aContent) const { PRBool aYes = PR_FALSE; nsCOMPtr node (do_QueryInterface((nsIContent *) aContent)); @@ -6702,7 +6702,7 @@ NS_IMETHODIMP nsXULDocument::ToXIF(nsIXIFConverter* aConverter, nsIDOMNode* aNode) { nsresult result=NS_OK; - nsCOMPtr sel; + nsCOMPtr sel; aConverter->GetSelection(getter_AddRefs(sel)); if (sel) { @@ -6734,7 +6734,7 @@ nsXULDocument::ToXIF(nsIXIFConverter* aConverter, nsIDOMNode* aNode) } NS_IMETHODIMP -nsXULDocument::CreateXIF(nsAWritableString & aBuffer, nsIDOMSelection* aSelection) +nsXULDocument::CreateXIF(nsAWritableString & aBuffer, nsISelection* aSelection) { nsresult result=NS_OK; diff --git a/mozilla/rdf/content/src/nsXULDocument.h b/mozilla/rdf/content/src/nsXULDocument.h index bcffb9f3e75..ea668784919 100644 --- a/mozilla/rdf/content/src/nsXULDocument.h +++ b/mozilla/rdf/content/src/nsXULDocument.h @@ -37,7 +37,7 @@ #include "nsIDOMNSDocument.h" #include "nsIDOMDocumentView.h" #include "nsIDOMDocumentXBL.h" -#include "nsIDOMSelection.h" +#include "nsISelection.h" #include "nsIDOMXULCommandDispatcher.h" #include "nsIDOMXULDocument.h" #include "nsIDocument.h" @@ -260,13 +260,13 @@ public: NS_IMETHOD StyleRuleRemoved(nsIStyleSheet* aStyleSheet, nsIStyleRule* aStyleRule); - NS_IMETHOD GetSelection(nsIDOMSelection** aSelection); + NS_IMETHOD GetSelection(nsISelection** aSelection); NS_IMETHOD SelectAll(); NS_IMETHOD FindNext(const nsAReadableString &aSearchStr, PRBool aMatchCase, PRBool aSearchDown, PRBool &aIsFound); - NS_IMETHOD CreateXIF(nsAWritableString & aBuffer, nsIDOMSelection* aSelection); + NS_IMETHOD CreateXIF(nsAWritableString & aBuffer, nsISelection* aSelection); NS_IMETHOD ToXIF(nsIXIFConverter *aConverter, nsIDOMNode* aNode); @@ -288,7 +288,7 @@ public: virtual PRBool IsBefore(const nsIContent *aNewContent, const nsIContent* aCurrentContent) const; - virtual PRBool IsInSelection(nsIDOMSelection* aSelection, const nsIContent *aContent) const; + virtual PRBool IsInSelection(nsISelection* aSelection, const nsIContent *aContent) const; virtual nsIContent* GetPrevContent(const nsIContent *aContent) const; @@ -540,7 +540,7 @@ protected: nsString mCharSetID; nsVoidArray mCharSetObservers; nsVoidArray mStyleSheets; - nsCOMPtr mSelection; // [OWNER] + nsCOMPtr mSelection; // [OWNER] PRInt8 mDisplaySelection; PRBool mIsKeyBindingDoc; nsVoidArray mPresShells; diff --git a/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp b/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp index 9b9d1437e31..ce638184427 100644 --- a/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp +++ b/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp @@ -98,7 +98,7 @@ #include // tolower // For Copy -#include "nsIDOMSelection.h" +#include "nsISelection.h" // XXX For font setting below #include "nsFont.h" diff --git a/mozilla/xpcom/base/IIDS.h b/mozilla/xpcom/base/IIDS.h index f926d009e2f..470454b27c4 100644 --- a/mozilla/xpcom/base/IIDS.h +++ b/mozilla/xpcom/base/IIDS.h @@ -890,12 +890,24 @@ nsICaret = { /* a6cf90e1-15b3-11d2-932e-00805f8add32 */ 0x11d2, {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }; -nsIDOMSelectionListener = { /* a6cf90e2-15b3-11d2-932e-00805f8add32 */ +nsISelectionListener = { /* a6cf90e2-15b3-11d2-932e-00805f8add32 */ 0xa6cf90e2, 0x15b3, 0x11d2, {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} }; +nsISelection = { /*B2C7ED59-8634-4352-9E37-5484C8B6E4E1 */ + 0xb2c7ed59, + 0x8634, + 0x4352, + {0x9e, 0x37, 0x54, 0x84, 0xc8, 0xb6, 0xe4, 0xe1} + }; +nsISelectionPrivate = { /*2D5535E2-1DD2-11B2-8E38-D53EC833ADF6 */ + 0x2d5535e2, + 0x1dd2, + 0x11b2, + {0x8e, 0x38, 0xd5, 0x3e, 0xc8, 0x33, 0xad, 0xf6} + }; nsContentIterator_CID = { /* a6cf90e3-15b3-11d2-932e-00805f8add32 */ 0xa6cf90e3, 0x15b3, diff --git a/mozilla/xpfe/browser/resources/content/navigatorDD.js b/mozilla/xpfe/browser/resources/content/navigatorDD.js index 487058a09e0..9f2104c8676 100644 --- a/mozilla/xpfe/browser/resources/content/navigatorDD.js +++ b/mozilla/xpfe/browser/resources/content/navigatorDD.js @@ -269,6 +269,7 @@ var personalToolbarObserver = { var contentAreaDNDObserver = { onDragStart: function (aEvent) { + dump("dragstart\n"); var htmlstring = null; var textstring = null; var isLink = false; @@ -276,12 +277,18 @@ var contentAreaDNDObserver = { if (domselection && !domselection.isCollapsed && domselection.containsNode(aEvent.target,false)) { - // the window has a selection so we should grab that rather than looking for specific elements - htmlstring = domselection.toString("text/html", 128+256, 0); - textstring = domselection.toString("text/plain", 0, 0); + var privateSelection = domselection.QueryInterface(Components.interfaces.nsISelectionPrivate); + if (privateSelection) + { + // the window has a selection so we should grab that rather than looking for specific elements + htmlstring = privateSelection.toStringWithFormat("text/html", 128+256, 0); + textstring = privateSelection.toStringWithFormat("text/plain", 0, 0); + dump("we cool?\n"); + } } else { + dump("didnt get here\n"); switch (aEvent.target.localName) { case 'AREA': diff --git a/mozilla/xpfe/communicator/resources/content/win/platformEditorBindings.xul b/mozilla/xpfe/communicator/resources/content/win/platformEditorBindings.xul index a508fb623fa..54faf2ae0fe 100644 --- a/mozilla/xpfe/communicator/resources/content/win/platformEditorBindings.xul +++ b/mozilla/xpfe/communicator/resources/content/win/platformEditorBindings.xul @@ -8,7 +8,7 @@ - + + + diff --git a/mozilla/xpfe/global/resources/content/win/platformHTMLBindings.xml b/mozilla/xpfe/global/resources/content/win/platformHTMLBindings.xml index c373514782a..9fc7ec48582 100644 --- a/mozilla/xpfe/global/resources/content/win/platformHTMLBindings.xml +++ b/mozilla/xpfe/global/resources/content/win/platformHTMLBindings.xml @@ -23,6 +23,14 @@ command="cmd_selectBeginLine"/> + + + + + + + +