diff --git a/mozilla/dom/public/range/nsIDOMSelection.h b/mozilla/dom/public/range/nsIDOMSelection.h index 8c261f7f231..9351a6037a5 100644 --- a/mozilla/dom/public/range/nsIDOMSelection.h +++ b/mozilla/dom/public/range/nsIDOMSelection.h @@ -27,38 +27,48 @@ class nsIDOMNode; class nsIDOMSelectionListener; class nsIDOMRange; +class nsIEnumerator; #define NS_IDOMSELECTION_IID \ { 0xa6cf90e1, 0x15b3, 0x11d2, \ { 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } } +#ifndef SELECTIONTYPE +enum SelectionType{SELECTION_NORMAL = 0, + SELECTION_SPELLCHECK, + SELECTION_IME_SOLID, + SELECTION_IME_DASHED, + NUM_SELECTIONTYPES}; +#define SELECTIONTYPE +#endif + 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 GetAnchorNode(SelectionType aType, nsIDOMNode** aAnchorNode)=0; - NS_IMETHOD GetAnchorOffset(PRInt32* aAnchorOffset)=0; + NS_IMETHOD GetAnchorOffset(SelectionType aType, PRInt32* aAnchorOffset)=0; - NS_IMETHOD GetFocusNode(nsIDOMNode** aFocusNode)=0; + NS_IMETHOD GetFocusNode(SelectionType aType, nsIDOMNode** aFocusNode)=0; - NS_IMETHOD GetFocusOffset(PRInt32* aFocusOffset)=0; + NS_IMETHOD GetFocusOffset(SelectionType aType, PRInt32* aFocusOffset)=0; - NS_IMETHOD GetIsCollapsed(PRBool* aIsCollapsed)=0; + NS_IMETHOD GetIsCollapsed(SelectionType aType, PRBool* aIsCollapsed)=0; - NS_IMETHOD GetRangeCount(PRInt32* aRangeCount)=0; + NS_IMETHOD GetRangeCount(SelectionType aType, PRInt32* aRangeCount)=0; - NS_IMETHOD GetRangeAt(PRInt32 aIndex, nsIDOMRange** aReturn)=0; + NS_IMETHOD GetRangeAt(PRInt32 aIndex, SelectionType aType, nsIDOMRange** aReturn)=0; - NS_IMETHOD ClearSelection()=0; + NS_IMETHOD ClearSelection(SelectionType aType)=0; - NS_IMETHOD Collapse(nsIDOMNode* aParentNode, PRInt32 aOffset)=0; + NS_IMETHOD Collapse(nsIDOMNode* aParentNode, PRInt32 aOffset, SelectionType aType)=0; - NS_IMETHOD Extend(nsIDOMNode* aParentNode, PRInt32 aOffset)=0; + NS_IMETHOD Extend(nsIDOMNode* aParentNode, PRInt32 aOffset, SelectionType aType)=0; NS_IMETHOD DeleteFromDocument()=0; - NS_IMETHOD AddRange(nsIDOMRange* aRange)=0; + NS_IMETHOD AddRange(nsIDOMRange* aRange, SelectionType aType)=0; NS_IMETHOD StartBatchChanges()=0; @@ -67,46 +77,51 @@ public: NS_IMETHOD AddSelectionListener(nsIDOMSelectionListener* aNewListener)=0; NS_IMETHOD RemoveSelectionListener(nsIDOMSelectionListener* aListenerToRemove)=0; + + NS_IMETHOD GetEnumerator(SelectionType aType, nsIEnumerator **aIterator)=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 GetAnchorNode(SelectionType aType, nsIDOMNode** aAnchorNode); \ + NS_IMETHOD GetAnchorOffset(SelectionType aType, PRInt32* aAnchorOffset); \ + NS_IMETHOD GetFocusNode(SelectionType aType, nsIDOMNode** aFocusNode); \ + NS_IMETHOD GetFocusOffset(SelectionType aType, PRInt32* aFocusOffset); \ + NS_IMETHOD GetIsCollapsed(SelectionType aType, PRBool* aIsCollapsed); \ + NS_IMETHOD GetRangeCount(SelectionType aType, PRInt32* aRangeCount); \ + NS_IMETHOD GetRangeAt(PRInt32 aIndex, SelectionType aType, nsIDOMRange** aReturn); \ + NS_IMETHOD ClearSelection(SelectionType aType); \ + NS_IMETHOD Collapse(nsIDOMNode* aParentNode, PRInt32 aOffset, SelectionType aType); \ + NS_IMETHOD Extend(nsIDOMNode* aParentNode, PRInt32 aOffset, SelectionType aType); \ NS_IMETHOD DeleteFromDocument(); \ - NS_IMETHOD AddRange(nsIDOMRange* aRange); \ + NS_IMETHOD AddRange(nsIDOMRange* aRange, SelectionType aType); \ NS_IMETHOD StartBatchChanges(); \ NS_IMETHOD EndBatchChanges(); \ NS_IMETHOD AddSelectionListener(nsIDOMSelectionListener* aNewListener); \ NS_IMETHOD RemoveSelectionListener(nsIDOMSelectionListener* aListenerToRemove); \ + NS_IMETHOD GetEnumerator(SelectionType aType, nsIEnumerator **aIterator); \ #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 GetAnchorNode(SelectionType aType, nsIDOMNode** aAnchorNode) { return _to GetAnchorNode(aType, aAnchorNode); } \ + NS_IMETHOD GetAnchorOffset(SelectionType aType, PRInt32* aAnchorOffset) { return _to GetAnchorOffset(aType, aAnchorOffset, aType); } \ + NS_IMETHOD GetFocusNode(SelectionType aType, nsIDOMNode** aFocusNode) { return _to GetFocusNode(aType, aFocusNode, aType); } \ + NS_IMETHOD GetFocusOffset(SelectionType aType, PRInt32* aFocusOffset) { return _to GetFocusOffset(aType, aFocusOffset, aType); } \ + NS_IMETHOD GetIsCollapsed(SelectionType aType, PRBool* aIsCollapsed) { return _to GetIsCollapsed(aType, aIsCollapsed, aType); } \ + NS_IMETHOD GetRangeCount(SelectionType aType, PRInt32* aRangeCount) { return _to GetRangeCount(aType, aRangeCount, aType); } \ + NS_IMETHOD GetRangeAt(PRInt32 aIndex, SelectionType aType, nsIDOMRange** aReturn) { return _to GetRangeAt(aIndex, aType, aReturn); } \ + NS_IMETHOD ClearSelection(SelectionType aType) { return _to ClearSelection(); } \ + NS_IMETHOD Collapse(nsIDOMNode* aParentNode, PRInt32 aOffset, SelectionType aType) { return _to Collapse(aParentNode, aOffset, aType); } \ + NS_IMETHOD Extend(nsIDOMNode* aParentNode, PRInt32 aOffset, SelectionType aType) { return _to Extend(aParentNode, aOffset, aType); } \ NS_IMETHOD DeleteFromDocument() { return _to DeleteFromDocument(); } \ - NS_IMETHOD AddRange(nsIDOMRange* aRange) { return _to AddRange(aRange); } \ + NS_IMETHOD AddRange(nsIDOMRange* aRange, SelectionType aType) { return _to AddRange(aRange, aType); } \ 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 GetEnumerator(SelectionType aType, nsIEnumerator **aIterator){ return _to GetEnumerator(aType, aIterator); } \ extern "C" NS_DOM nsresult NS_InitSelectionClass(nsIScriptContext *aContext, void **aPrototype); diff --git a/mozilla/dom/src/range/nsJSSelection.cpp b/mozilla/dom/src/range/nsJSSelection.cpp index f4dfdbba3de..b9fdade74e0 100644 --- a/mozilla/dom/src/range/nsJSSelection.cpp +++ b/mozilla/dom/src/range/nsJSSelection.cpp @@ -88,7 +88,7 @@ GetSelectionProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) return JS_FALSE; } nsIDOMNode* prop; - if (NS_OK == a->GetAnchorNode(&prop)) { + if (NS_OK == a->GetAnchorNode(SELECTION_NORMAL, &prop)) { // get the js object nsJSUtils::nsConvertObjectToJSVal((nsISupports *)prop, cx, vp); } @@ -105,7 +105,7 @@ GetSelectionProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) return JS_FALSE; } PRInt32 prop; - if (NS_OK == a->GetAnchorOffset(&prop)) { + if (NS_OK == a->GetAnchorOffset(SELECTION_NORMAL, &prop)) { *vp = INT_TO_JSVAL(prop); } else { @@ -121,7 +121,7 @@ GetSelectionProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) return JS_FALSE; } nsIDOMNode* prop; - if (NS_OK == a->GetFocusNode(&prop)) { + if (NS_OK == a->GetFocusNode(SELECTION_NORMAL, &prop)) { // get the js object nsJSUtils::nsConvertObjectToJSVal((nsISupports *)prop, cx, vp); } @@ -138,7 +138,7 @@ GetSelectionProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) return JS_FALSE; } PRInt32 prop; - if (NS_OK == a->GetFocusOffset(&prop)) { + if (NS_OK == a->GetFocusOffset(SELECTION_NORMAL, &prop)) { *vp = INT_TO_JSVAL(prop); } else { @@ -154,7 +154,7 @@ GetSelectionProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) return JS_FALSE; } PRBool prop; - if (NS_OK == a->GetIsCollapsed(&prop)) { + if (NS_OK == a->GetIsCollapsed(SELECTION_NORMAL, &prop)) { *vp = BOOLEAN_TO_JSVAL(prop); } else { @@ -170,7 +170,7 @@ GetSelectionProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) return JS_FALSE; } PRInt32 prop; - if (NS_OK == a->GetRangeCount(&prop)) { + if (NS_OK == a->GetRangeCount(SELECTION_NORMAL, &prop)) { *vp = INT_TO_JSVAL(prop); } else { @@ -295,7 +295,7 @@ SelectionGetRangeAt(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval return JS_FALSE; } - if (NS_OK != nativeThis->GetRangeAt(b0, &nativeRet)) { + if (NS_OK != nativeThis->GetRangeAt(b0, SELECTION_NORMAL, &nativeRet)) { return JS_FALSE; } @@ -342,7 +342,7 @@ SelectionClearSelection(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, j if (argc >= 0) { - if (NS_OK != nativeThis->ClearSelection()) { + if (NS_OK != nativeThis->ClearSelection(SELECTION_NORMAL)) { return JS_FALSE; } @@ -404,7 +404,7 @@ SelectionCollapse(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval * return JS_FALSE; } - if (NS_OK != nativeThis->Collapse(b0, b1)) { + if (NS_OK != nativeThis->Collapse(b0, b1, SELECTION_NORMAL)) { return JS_FALSE; } @@ -466,7 +466,7 @@ SelectionExtend(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rv return JS_FALSE; } - if (NS_OK != nativeThis->Extend(b0, b1)) { + if (NS_OK != nativeThis->Extend(b0, b1, SELECTION_NORMAL)) { return JS_FALSE; } @@ -569,7 +569,7 @@ SelectionAddRange(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval * return JS_FALSE; } - if (NS_OK != nativeThis->AddRange(b0)) { + if (NS_OK != nativeThis->AddRange(b0, SELECTION_NORMAL)) { return JS_FALSE; } diff --git a/mozilla/editor/base/CreateElementTxn.cpp b/mozilla/editor/base/CreateElementTxn.cpp index 972544e0dca..1e30d328208 100644 --- a/mozilla/editor/base/CreateElementTxn.cpp +++ b/mozilla/editor/base/CreateElementTxn.cpp @@ -127,7 +127,7 @@ NS_IMETHODIMP CreateElementTxn::Do(void) if (NS_SUCCEEDED(selectionResult) && selection) { PRInt32 offset=0; nsEditor::GetChildOffset(mNewNode, mParent, offset); - selectionResult = selection->Collapse(mParent, offset); + selectionResult = selection->Collapse(mParent, offset, SELECTION_NORMAL); NS_ASSERTION((NS_SUCCEEDED(selectionResult)), "selection could not be collapsed after undo of insert."); } } @@ -155,7 +155,7 @@ NS_IMETHODIMP CreateElementTxn::Undo(void) if (mRefNode) { nsEditor::GetChildOffset(mRefNode, mParent, offset); } - selectionResult = selection->Collapse(mParent, offset); + selectionResult = selection->Collapse(mParent, offset, SELECTION_NORMAL); NS_ASSERTION((NS_SUCCEEDED(selectionResult)), "selection could not be collapsed after undo of insert."); } } @@ -185,7 +185,7 @@ NS_IMETHODIMP CreateElementTxn::Redo(void) if (NS_SUCCEEDED(result) && selection) { PRInt32 offset=0; nsEditor::GetChildOffset(mNewNode, mParent, offset); - nsresult selectionResult = selection->Collapse(mParent, offset); + nsresult selectionResult = selection->Collapse(mParent, offset, SELECTION_NORMAL); NS_ASSERTION((NS_SUCCEEDED(selectionResult)), "selection could not be collapsed after undo of insert."); } } diff --git a/mozilla/editor/base/DeleteRangeTxn.cpp b/mozilla/editor/base/DeleteRangeTxn.cpp index 82e7df577c3..5af55dacf64 100644 --- a/mozilla/editor/base/DeleteRangeTxn.cpp +++ b/mozilla/editor/base/DeleteRangeTxn.cpp @@ -149,7 +149,7 @@ NS_IMETHODIMP DeleteRangeTxn::Do(void) nsCOMPtr selection; result = mEditor->GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(result)) { - result = selection->Collapse(mStartParent, mStartOffset); + result = selection->Collapse(mStartParent, mStartOffset, SELECTION_NORMAL); } } @@ -169,8 +169,8 @@ NS_IMETHODIMP DeleteRangeTxn::Undo(void) nsCOMPtr selection; result = mEditor->GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(result)) { - selection->Collapse(mStartParent, mStartOffset); - selection->Extend(mEndParent, mEndOffset); + selection->Collapse(mStartParent, mStartOffset, SELECTION_NORMAL); + selection->Extend(mEndParent, mEndOffset, SELECTION_NORMAL); } } @@ -190,7 +190,7 @@ NS_IMETHODIMP DeleteRangeTxn::Redo(void) nsCOMPtr selection; result = mEditor->GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(result)) { - result = selection->Collapse(mStartParent, mStartOffset); + result = selection->Collapse(mStartParent, mStartOffset, SELECTION_NORMAL); } } diff --git a/mozilla/editor/base/DeleteTableCellTxn.cpp b/mozilla/editor/base/DeleteTableCellTxn.cpp index 1503221e0a4..e66237c38e7 100644 --- a/mozilla/editor/base/DeleteTableCellTxn.cpp +++ b/mozilla/editor/base/DeleteTableCellTxn.cpp @@ -63,7 +63,7 @@ NS_IMETHODIMP DeleteTableCellTxn::Do(void) nsCOMPtr selection; res = mPresShell->GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(res)) { - res = selection->Collapse(mElement, 0 /*mOffset+1*/ /*+mStringToInsert.Length()*/); + res = selection->Collapse(mElement, 0 /*mOffset+1*/ /*+mStringToInsert.Length()*/, SELECTION_NORMAL); } return res; } @@ -79,7 +79,7 @@ NS_IMETHODIMP DeleteTableCellTxn::Undo(void) nsCOMPtr selection; result = mPresShell->GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(result)) { - result = selection->Collapse(mElement, mOffset); + result = selection->Collapse(mElement, mOffset, SELECTION_NORMAL); } } #endif diff --git a/mozilla/editor/base/DeleteTableColumnTxn.cpp b/mozilla/editor/base/DeleteTableColumnTxn.cpp index d59e4a089ac..9476f87c5b4 100644 --- a/mozilla/editor/base/DeleteTableColumnTxn.cpp +++ b/mozilla/editor/base/DeleteTableColumnTxn.cpp @@ -63,7 +63,7 @@ NS_IMETHODIMP DeleteTableColumnTxn::Do(void) nsCOMPtr selection; res = mPresShell->GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(res)) { - res = selection->Collapse(mElement, 0 /*mOffset+1*/ /*+mStringToInsert.Length()*/); + res = selection->Collapse(mElement, 0 /*mOffset+1*/ /*+mStringToInsert.Length()*/, SELECTION_NORMAL); } return res; } @@ -79,7 +79,7 @@ NS_IMETHODIMP DeleteTableColumnTxn::Undo(void) nsCOMPtr selection; result = mPresShell->GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(result)) { - result = selection->Collapse(mElement, mOffset); + result = selection->Collapse(mElement, mOffset, SELECTION_NORMAL); } } #endif diff --git a/mozilla/editor/base/DeleteTableRowTxn.cpp b/mozilla/editor/base/DeleteTableRowTxn.cpp index 4e75b3a3ee6..f465546f47c 100644 --- a/mozilla/editor/base/DeleteTableRowTxn.cpp +++ b/mozilla/editor/base/DeleteTableRowTxn.cpp @@ -63,7 +63,7 @@ NS_IMETHODIMP DeleteTableRowTxn::Do(void) nsCOMPtr selection; res = mPresShell->GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(res)) { - res = selection->Collapse(mElement, 0 /*mOffset+1*/ /*+mStringToInsert.Length()*/); + res = selection->Collapse(mElement, 0 /*mOffset+1*/ /*+mStringToInsert.Length()*/, SELECTION_NORMAL); } return res; } @@ -79,7 +79,7 @@ NS_IMETHODIMP DeleteTableRowTxn::Undo(void) nsCOMPtr selection; result = mPresShell->GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(result)) { - result = selection->Collapse(mElement, mOffset); + result = selection->Collapse(mElement, mOffset, SELECTION_NORMAL); } } #endif diff --git a/mozilla/editor/base/DeleteTableTxn.cpp b/mozilla/editor/base/DeleteTableTxn.cpp index 5a37556624c..00e6b2322d8 100644 --- a/mozilla/editor/base/DeleteTableTxn.cpp +++ b/mozilla/editor/base/DeleteTableTxn.cpp @@ -63,7 +63,7 @@ NS_IMETHODIMP DeleteTableTxn::Do(void) nsCOMPtr selection; res = mPresShell->GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(res)) { - res = selection->Collapse(mElement, 0 /*mOffset+1*/ /*+mStringToInsert.Length()*/); + res = selection->Collapse(mElement, 0 /*mOffset+1*/ /*+mStringToInsert.Length()*/, SELECTION_NORMAL); } return res; } @@ -79,7 +79,7 @@ NS_IMETHODIMP DeleteTableTxn::Undo(void) nsCOMPtr selection; result = mPresShell->GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(result)) { - result = selection->Collapse(mElement, mOffset); + result = selection->Collapse(mElement, mOffset, SELECTION_NORMAL); } } #endif diff --git a/mozilla/editor/base/DeleteTextTxn.cpp b/mozilla/editor/base/DeleteTextTxn.cpp index cf713939181..47ac554a1b7 100644 --- a/mozilla/editor/base/DeleteTextTxn.cpp +++ b/mozilla/editor/base/DeleteTextTxn.cpp @@ -69,7 +69,7 @@ NS_IMETHODIMP DeleteTextTxn::Do(void) nsCOMPtr selection; nsresult selectionResult = mEditor->GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(selectionResult) && selection) { - selectionResult = selection->Collapse(mElement, mOffset); + selectionResult = selection->Collapse(mElement, mOffset, SELECTION_NORMAL); NS_ASSERTION((NS_SUCCEEDED(selectionResult)), "selection could not be collapsed after undo of insert."); } } @@ -91,7 +91,7 @@ NS_IMETHODIMP DeleteTextTxn::Undo(void) nsCOMPtr selection; nsresult selectionResult = mEditor->GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(selectionResult) && selection) { - selectionResult = selection->Collapse(mElement, mOffset); + selectionResult = selection->Collapse(mElement, mOffset, SELECTION_NORMAL); NS_ASSERTION((NS_SUCCEEDED(selectionResult)), "selection could not be collapsed after undo of insert."); } } diff --git a/mozilla/editor/base/IMETextTxn.cpp b/mozilla/editor/base/IMETextTxn.cpp index 9a97e3a4af4..adfb733b7c0 100644 --- a/mozilla/editor/base/IMETextTxn.cpp +++ b/mozilla/editor/base/IMETextTxn.cpp @@ -104,7 +104,7 @@ NS_IMETHODIMP IMETextTxn::Undo(void) nsCOMPtr selection; result = mPresShell->GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(result) && selection) { - result = selection->Collapse(mElement, mOffset); + result = selection->Collapse(mElement, mOffset, SELECTION_NORMAL); NS_ASSERTION((NS_SUCCEEDED(result)), "selection could not be collapsed after undo of IME insert."); } } @@ -281,13 +281,13 @@ NS_IMETHODIMP IMETextTxn::CollapseTextSelection(void) result = mPresShell->GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(result) && selection){ if (haveSelectedRange) { - result = selection->Collapse(mElement,mOffset+selectionStart); - result = selection->Extend(mElement,mOffset+selectionEnd); + result = selection->Collapse(mElement,mOffset+selectionStart, SELECTION_NORMAL); + result = selection->Extend(mElement,mOffset+selectionEnd, SELECTION_NORMAL); } else { if (haveCaretPosition) - result = selection->Collapse(mElement,mOffset+caretPosition); + result = selection->Collapse(mElement,mOffset+caretPosition, SELECTION_NORMAL); else - result = selection->Collapse(mElement,mOffset+mStringToInsert.Length()); + result = selection->Collapse(mElement,mOffset+mStringToInsert.Length(), SELECTION_NORMAL); } } @@ -299,7 +299,7 @@ NS_IMETHODIMP IMETextTxn::CollapseTextSelectionOnCommit(void) nsCOMPtr selection; nsresult result = mPresShell->GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(result) && selection){ - result = selection->Collapse(mElement,mOffset+mStringToInsert.Length()); + result = selection->Collapse(mElement,mOffset+mStringToInsert.Length(), SELECTION_NORMAL); } return result; diff --git a/mozilla/editor/base/InsertElementTxn.cpp b/mozilla/editor/base/InsertElementTxn.cpp index 213d298a296..0e94ccf886d 100644 --- a/mozilla/editor/base/InsertElementTxn.cpp +++ b/mozilla/editor/base/InsertElementTxn.cpp @@ -98,7 +98,7 @@ NS_IMETHODIMP InsertElementTxn::Do(void) result = mEditor->GetSelection(getter_AddRefs(selection)); if ((NS_SUCCEEDED(result)) && selection) { // place the selection just after the inserted element - selection->Collapse(mParent, mOffset+1); + selection->Collapse(mParent, mOffset+1, SELECTION_NORMAL); //selection->Extend(mParent, mOffset+1); } } diff --git a/mozilla/editor/base/InsertTableCellTxn.cpp b/mozilla/editor/base/InsertTableCellTxn.cpp index 1c7ceff8766..3c6a3210691 100644 --- a/mozilla/editor/base/InsertTableCellTxn.cpp +++ b/mozilla/editor/base/InsertTableCellTxn.cpp @@ -65,7 +65,7 @@ NS_IMETHODIMP InsertTableCellTxn::Do(void) nsCOMPtr selection; res = mPresShell->GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(res)) { - res = selection->Collapse(mElement, mOffset+1 /*+mStringToInsert.Length()*/); + res = selection->Collapse(mElement, mOffset+1 /*+mStringToInsert.Length()*/, SELECTION_NORMAL); } return res; } @@ -81,7 +81,7 @@ NS_IMETHODIMP InsertTableCellTxn::Undo(void) nsCOMPtr selection; result = mPresShell->GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(result)) { - result = selection->Collapse(mElement, mOffset); + result = selection->Collapse(mElement, mOffset, SELECTION_NORMAL); } } #endif diff --git a/mozilla/editor/base/InsertTableColumnTxn.cpp b/mozilla/editor/base/InsertTableColumnTxn.cpp index 2574dcf2a7b..e56cb8f2514 100644 --- a/mozilla/editor/base/InsertTableColumnTxn.cpp +++ b/mozilla/editor/base/InsertTableColumnTxn.cpp @@ -65,7 +65,7 @@ NS_IMETHODIMP InsertTableColumnTxn::Do(void) nsCOMPtr selection; res = mPresShell->GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(res)) { - res = selection->Collapse(mElement, mOffset+1 /*+mStringToInsert.Length()*/); + res = selection->Collapse(mElement, mOffset+1 /*+mStringToInsert.Length()*/, SELECTION_NORMAL); } return res; } @@ -81,7 +81,7 @@ NS_IMETHODIMP InsertTableColumnTxn::Undo(void) nsCOMPtr selection; result = mPresShell->GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(result)) { - result = selection->Collapse(mElement, mOffset); + result = selection->Collapse(mElement, mOffset, SELECTION_NORMAL); } } #endif diff --git a/mozilla/editor/base/InsertTableRowTxn.cpp b/mozilla/editor/base/InsertTableRowTxn.cpp index 4aab4ecafed..df3078add67 100644 --- a/mozilla/editor/base/InsertTableRowTxn.cpp +++ b/mozilla/editor/base/InsertTableRowTxn.cpp @@ -65,7 +65,7 @@ NS_IMETHODIMP InsertTableRowTxn::Do(void) nsCOMPtr selection; res = mPresShell->GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(res)) { - res = selection->Collapse(mElement, mOffset+1 /*+mStringToInsert.Length()*/); + res = selection->Collapse(mElement, mOffset+1 /*+mStringToInsert.Length()*/, SELECTION_NORMAL); } return res; } @@ -81,7 +81,7 @@ NS_IMETHODIMP InsertTableRowTxn::Undo(void) nsCOMPtr selection; result = mPresShell->GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(result)) { - result = selection->Collapse(mElement, mOffset); + result = selection->Collapse(mElement, mOffset, SELECTION_NORMAL); } } #endif diff --git a/mozilla/editor/base/InsertTableTxn.cpp b/mozilla/editor/base/InsertTableTxn.cpp index bd639b03ac1..f879f7363f3 100644 --- a/mozilla/editor/base/InsertTableTxn.cpp +++ b/mozilla/editor/base/InsertTableTxn.cpp @@ -65,7 +65,7 @@ NS_IMETHODIMP InsertTableTxn::Do(void) nsCOMPtr selection; res = mPresShell->GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(res)) { - res = selection->Collapse(mElement, mOffset+1 /*+mStringToInsert.Length()*/); + res = selection->Collapse(mElement, mOffset+1 /*+mStringToInsert.Length()*/, SELECTION_NORMAL); } return res; } @@ -81,7 +81,7 @@ NS_IMETHODIMP InsertTableTxn::Undo(void) nsCOMPtr selection; result = mPresShell->GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(result)) { - result = selection->Collapse(mElement, mOffset); + result = selection->Collapse(mElement, mOffset, SELECTION_NORMAL); } } #endif diff --git a/mozilla/editor/base/InsertTextTxn.cpp b/mozilla/editor/base/InsertTextTxn.cpp index 592be799909..27470efdf92 100644 --- a/mozilla/editor/base/InsertTextTxn.cpp +++ b/mozilla/editor/base/InsertTextTxn.cpp @@ -81,7 +81,7 @@ NS_IMETHODIMP InsertTextTxn::Do(void) if (NS_SUCCEEDED(result) && selection) { result = mElement->InsertData(mOffset, mStringToInsert); if (NS_SUCCEEDED(result)) { - result = selection->Collapse(mElement, mOffset+mStringToInsert.Length()); + result = selection->Collapse(mElement, mOffset+mStringToInsert.Length(), SELECTION_NORMAL); NS_ASSERTION((NS_SUCCEEDED(result)), "selection could not be collapsed after insert."); } } @@ -99,7 +99,7 @@ NS_IMETHODIMP InsertTextTxn::Undo(void) nsCOMPtr selection; result = mPresShell->GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(result) && selection) { - result = selection->Collapse(mElement, mOffset); + result = selection->Collapse(mElement, mOffset, SELECTION_NORMAL); NS_ASSERTION((NS_SUCCEEDED(result)), "selection could not be collapsed after undo of insert."); } } diff --git a/mozilla/editor/base/JoinElementTxn.cpp b/mozilla/editor/base/JoinElementTxn.cpp index c6d3902fbda..46ca5754e44 100644 --- a/mozilla/editor/base/JoinElementTxn.cpp +++ b/mozilla/editor/base/JoinElementTxn.cpp @@ -89,7 +89,7 @@ NS_IMETHODIMP JoinElementTxn::Do(void) mEditor->GetSelection(getter_AddRefs(selection)); if (selection) { - selection->Collapse(mRightNode, mOffset); + selection->Collapse(mRightNode, mOffset, SELECTION_NORMAL); } } } diff --git a/mozilla/editor/base/JoinTableCellsTxn.cpp b/mozilla/editor/base/JoinTableCellsTxn.cpp index 468703a13d5..3399a1df855 100644 --- a/mozilla/editor/base/JoinTableCellsTxn.cpp +++ b/mozilla/editor/base/JoinTableCellsTxn.cpp @@ -63,7 +63,7 @@ NS_IMETHODIMP JoinTableCellsTxn::Do(void) nsCOMPtr selection; res = mPresShell->GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(res)) { - res = selection->Collapse(mElement, 0 /*mOffset+1*/ /*+mStringToInsert.Length()*/); + res = selection->Collapse(mElement, 0 /*mOffset+1*/ /*+mStringToInsert.Length()*/, SELECTION_NORMAL); } return res; } @@ -79,7 +79,7 @@ NS_IMETHODIMP JoinTableCellsTxn::Undo(void) nsCOMPtr selection; result = mPresShell->GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(result)) { - result = selection->Collapse(mElement, mOffset); + result = selection->Collapse(mElement, mOffset, SELECTION_NORMAL); } } #endif diff --git a/mozilla/editor/base/SplitElementTxn.cpp b/mozilla/editor/base/SplitElementTxn.cpp index 179c1231f23..322583ca8f1 100644 --- a/mozilla/editor/base/SplitElementTxn.cpp +++ b/mozilla/editor/base/SplitElementTxn.cpp @@ -75,7 +75,7 @@ NS_IMETHODIMP SplitElementTxn::Do(void) mEditor->GetSelection(getter_AddRefs(selection)); if (selection) { - selection->Collapse(mNewLeftNode, mOffset); + selection->Collapse(mNewLeftNode, mOffset, SELECTION_NORMAL); } } else { @@ -112,7 +112,7 @@ NS_IMETHODIMP SplitElementTxn::Undo(void) mEditor->GetSelection(getter_AddRefs(selection)); if (selection) { - selection->Collapse(mExistingRightNode, mOffset); + selection->Collapse(mExistingRightNode, mOffset, SELECTION_NORMAL); } } else { diff --git a/mozilla/editor/base/TextEditorTest.cpp b/mozilla/editor/base/TextEditorTest.cpp index 235523fe357..cc2615cdbca 100644 --- a/mozilla/editor/base/TextEditorTest.cpp +++ b/mozilla/editor/base/TextEditorTest.cpp @@ -108,10 +108,10 @@ nsresult TextEditorTest::TestInsertBreak() TEST_RESULT(result); TEST_POINTER(selection.get()); nsCOMPtranchor; - result = selection->GetAnchorNode(getter_AddRefs(anchor)); + result = selection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(anchor)); TEST_RESULT(result); TEST_POINTER(anchor.get()); - selection->Collapse(anchor, 0); + selection->Collapse(anchor, 0, SELECTION_NORMAL); // insert one break printf("inserting a break\n"); result = mTextEditor->InsertBreak(); @@ -156,8 +156,8 @@ nsresult TextEditorTest::TestTextProperties() textData = do_QueryInterface(textNode); PRUint32 length; textData->GetLength(&length); - selection->Collapse(textNode, 0); - selection->Extend(textNode, length); + selection->Collapse(textNode, 0, SELECTION_NORMAL); + selection->Extend(textNode, length, SELECTION_NORMAL); PRBool any = PR_FALSE; PRBool all = PR_FALSE; PRBool first=PR_FALSE; @@ -188,8 +188,8 @@ nsresult TextEditorTest::TestTextProperties() // set all but the first and last character to bold printf("set the first text node (1, length-1) to bold and italic, and (2, length-1) to underline.\n"); - selection->Collapse(textNode, 1); - selection->Extend(textNode, length-1); + selection->Collapse(textNode, 1, SELECTION_NORMAL); + selection->Extend(textNode, length-1, SELECTION_NORMAL); result = mTextEditor->SetTextProperty(nsIEditProperty::b, nsnull, nsnull); TEST_RESULT(result); result = mTextEditor->GetTextProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all); @@ -224,8 +224,8 @@ nsresult TextEditorTest::TestTextProperties() TEST_POINTER(textNode.get()); textData = do_QueryInterface(textNode); textData->GetLength(&length); - selection->Collapse(textNode, 1); - selection->Extend(textNode, length-2); + selection->Collapse(textNode, 1, SELECTION_NORMAL); + selection->Extend(textNode, length-2, SELECTION_NORMAL); result = mTextEditor->SetTextProperty(nsIEditProperty::u, nsnull, nsnull); TEST_RESULT(result); diff --git a/mozilla/editor/base/nsEditor.cpp b/mozilla/editor/base/nsEditor.cpp index 0431fbcc9dd..e52fa655276 100644 --- a/mozilla/editor/base/nsEditor.cpp +++ b/mozilla/editor/base/nsEditor.cpp @@ -1075,7 +1075,7 @@ NS_IMETHODIMP nsEditor::SelectEntireDocument(nsIDOMSelection *aSelection) nsCOMPtrbodyNode = do_QueryInterface(bodyElement); if (bodyNode) { - result = aSelection->Collapse(bodyNode, 0); + result = aSelection->Collapse(bodyNode, 0, SELECTION_NORMAL); if (NS_SUCCEEDED(result)) { PRInt32 numBodyChildren=0; @@ -1084,7 +1084,7 @@ NS_IMETHODIMP nsEditor::SelectEntireDocument(nsIDOMSelection *aSelection) if ((NS_SUCCEEDED(result)) && lastChild) { GetChildOffset(lastChild, bodyNode, numBodyChildren); - result = aSelection->Extend(bodyNode, numBodyChildren+1); + result = aSelection->Extend(bodyNode, numBodyChildren+1, SELECTION_NORMAL); } } } @@ -1156,7 +1156,7 @@ NS_IMETHODIMP nsEditor::BeginningOfDocument() nsCOMPtr firstNode = GetDeepFirstChild(bodyNode); if (firstNode) { - result = selection->Collapse(firstNode, 0); + result = selection->Collapse(firstNode, 0, SELECTION_NORMAL); ScrollIntoView(PR_TRUE); } } @@ -1241,7 +1241,7 @@ NS_IMETHODIMP nsEditor::EndOfDocument() if (text) text->GetLength(&offset); } - result = selection->Collapse(lastChild, offset); + result = selection->Collapse(lastChild, offset, SELECTION_NORMAL); ScrollIntoView(PR_FALSE); } } @@ -1265,7 +1265,7 @@ NS_IMETHODIMP nsEditor::Cut() return res; PRBool isCollapsed; - if (NS_SUCCEEDED(selection->GetIsCollapsed(&isCollapsed)) && isCollapsed) + if (NS_SUCCEEDED(selection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed)) && isCollapsed) return NS_ERROR_NOT_AVAILABLE; res = Copy(); @@ -1764,7 +1764,7 @@ NS_IMETHODIMP nsEditor::CreateAggregateTxnForDeleteSelection(nsIAtom *aTxnName, if (NS_SUCCEEDED(result) && selection) { PRBool collapsed; - result = selection->GetIsCollapsed(&collapsed); + result = selection->GetIsCollapsed(SELECTION_NORMAL, &collapsed); if (NS_SUCCEEDED(result) && !collapsed) { EditAggregateTxn *delSelTxn; result = CreateTxnForDeleteSelection(nsIEditor::eDoNothing, @@ -1816,8 +1816,8 @@ nsEditor::InsertText(const nsString& aStringToInsert) { nsCOMPtr selectedNode; PRInt32 offset; - result = selection->GetAnchorNode(getter_AddRefs(selectedNode)); - if (NS_SUCCEEDED(result) && NS_SUCCEEDED(selection->GetAnchorOffset(&offset)) && selectedNode) + result = selection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(selectedNode)); + if (NS_SUCCEEDED(result) && NS_SUCCEEDED(selection->GetAnchorOffset(SELECTION_NORMAL, &offset)) && selectedNode) { nsCOMPtr newNode; result = CreateNode(GetTextNodeTag(), selectedNode, offset, // offset+1, why the +1??? @@ -1830,8 +1830,8 @@ nsEditor::InsertText(const nsString& aStringToInsert) { nsAutoString placeholderText(" "); newTextNode->SetData(placeholderText); - selection->Collapse(newNode, 0); - selection->Extend(newNode, 1); + selection->Collapse(newNode, 0, SELECTION_NORMAL); + selection->Extend(newNode, 1, SELECTION_NORMAL); result = InsertText(aStringToInsert); } } @@ -1880,8 +1880,8 @@ NS_IMETHODIMP nsEditor::CreateTxnForInsertText(const nsString & aStringToInsert, #endif result = NS_ERROR_UNEXPECTED; nsCOMPtr enumerator; - enumerator = do_QueryInterface(selection); - if (enumerator) + result = selection->GetEnumerator(SELECTION_NORMAL,getter_AddRefs(enumerator)); + if (NS_SUCCEEDED(result) && enumerator) { enumerator->First(); nsISupports *currentItem; @@ -2042,7 +2042,7 @@ NS_IMETHODIMP nsEditor::DeleteSelectionAndCreateNode(const nsString& aTag, nsCOMPtr selection; result = GetSelection(getter_AddRefs(selection)); if ((NS_SUCCEEDED(result)) && selection) - selection->Collapse(parentSelectedNode, offsetOfNewNode+1); + selection->Collapse(parentSelectedNode, offsetOfNewNode+1, SELECTION_NORMAL); return result; } @@ -2055,7 +2055,7 @@ NS_IMETHODIMP nsEditor::DeleteSelectionAndPrepareToCreateNode(nsCOMPtrGetIsCollapsed(&collapsed); + result = selection->GetIsCollapsed(SELECTION_NORMAL, &collapsed); if (NS_SUCCEEDED(result) && !collapsed) { result = DeleteSelection(nsIEditor::eDoNothing); @@ -2069,13 +2069,13 @@ NS_IMETHODIMP nsEditor::DeleteSelectionAndPrepareToCreateNode(nsCOMPtrtestSelectedNode; - nsresult debugResult = selection->GetAnchorNode(getter_AddRefs(testSelectedNode)); + nsresult debugResult = selection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(testSelectedNode)); // no selection is ok. // if there is a selection, it must be collapsed if (testSelectedNode) { PRBool testCollapsed; - debugResult = selection->GetIsCollapsed(&testCollapsed); + debugResult = selection->GetIsCollapsed(SELECTION_NORMAL, &testCollapsed); NS_ASSERTION((NS_SUCCEEDED(result)), "couldn't get a selection after deletion"); NS_ASSERTION(PR_TRUE==testCollapsed, "selection not reset after deletion"); } @@ -2083,8 +2083,8 @@ NS_IMETHODIMP nsEditor::DeleteSelectionAndPrepareToCreateNode(nsCOMPtrGetAnchorNode(getter_AddRefs(parentSelectedNode)); - if (NS_SUCCEEDED(result) && NS_SUCCEEDED(selection->GetAnchorOffset(&offsetOfSelectedNode)) && parentSelectedNode) + result = selection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(parentSelectedNode)); + if (NS_SUCCEEDED(result) && NS_SUCCEEDED(selection->GetAnchorOffset(SELECTION_NORMAL, &offsetOfSelectedNode)) && parentSelectedNode) { nsCOMPtr selectedNode; PRUint32 selectedNodeContentCount=0; @@ -2241,7 +2241,7 @@ NS_IMETHODIMP nsEditor::CreateTxnForDeleteSelection(nsIEditor::ECollapsedSelecti { // Check whether the selection is collapsed and we should do nothing: PRBool isCollapsed; - result = (selection->GetIsCollapsed(&isCollapsed)); + result = (selection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed)); if (NS_SUCCEEDED(result) && isCollapsed && aAction == eDoNothing) return NS_OK; @@ -2252,8 +2252,8 @@ NS_IMETHODIMP nsEditor::CreateTxnForDeleteSelection(nsIEditor::ECollapsedSelecti } nsCOMPtr enumerator; - enumerator = do_QueryInterface(selection); - if (enumerator) + result = selection->GetEnumerator(SELECTION_NORMAL, getter_AddRefs(enumerator)); + if (NS_SUCCEEDED(result) && enumerator) { for (enumerator->First(); NS_OK!=enumerator->IsDone(); enumerator->Next()) { @@ -3508,8 +3508,8 @@ nsEditor::BeginComposition(void) { result = NS_ERROR_UNEXPECTED; nsCOMPtr enumerator; - enumerator = do_QueryInterface(selection); - if (enumerator) + result = selection->GetEnumerator(SELECTION_NORMAL, getter_AddRefs(enumerator)); + if (NS_SUCCEEDED(result) && enumerator) { enumerator->First(); nsISupports *currentItem; @@ -3782,8 +3782,8 @@ nsEditor::SetInputMethodText(const nsString& aStringToInsert,nsIDOMTextRangeList { nsCOMPtr selectedNode; PRInt32 offset; - result = selection->GetAnchorNode(getter_AddRefs(selectedNode)); - if (NS_SUCCEEDED(result) && NS_SUCCEEDED(selection->GetAnchorOffset(&offset)) && selectedNode) + result = selection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(selectedNode)); + if (NS_SUCCEEDED(result) && NS_SUCCEEDED(selection->GetAnchorOffset(SELECTION_NORMAL, &offset)) && selectedNode) { nsCOMPtr newNode; result = CreateNode(GetTextNodeTag(), selectedNode, offset+1,getter_AddRefs(newNode)); @@ -3795,8 +3795,8 @@ nsEditor::SetInputMethodText(const nsString& aStringToInsert,nsIDOMTextRangeList { nsAutoString placeholderText(" "); newTextNode->SetData(placeholderText); - selection->Collapse(newNode, 0); - selection->Extend(newNode, 1); + selection->Collapse(newNode, 0, SELECTION_NORMAL); + selection->Extend(newNode, 1, SELECTION_NORMAL); result = SetInputMethodText(aStringToInsert,aTextRangeList); } } @@ -4203,12 +4203,13 @@ nsEditor::GetStartNodeAndOffset(nsIDOMSelection *aSelection, nsCOMPtr *outStartNode, PRInt32 *outStartOffset) { - if (!outStartNode || !outStartOffset) + if (!outStartNode || !outStartOffset || !aSelection) return NS_ERROR_NULL_POINTER; nsCOMPtr enumerator; - enumerator = do_QueryInterface(aSelection); - if (!enumerator) + nsresult result; + result = aSelection->GetEnumerator(SELECTION_NORMAL, getter_AddRefs(enumerator)); + if (NS_FAILED(result) || !enumerator) return NS_ERROR_FAILURE; enumerator->First(); @@ -4242,8 +4243,8 @@ nsEditor::GetEndNodeAndOffset(nsIDOMSelection *aSelection, return NS_ERROR_NULL_POINTER; nsCOMPtr enumerator; - enumerator = do_QueryInterface(aSelection); - if (!enumerator) + nsresult result = aSelection->GetEnumerator(SELECTION_NORMAL, getter_AddRefs(enumerator)); + if (NS_FAILED(result) || enumerator) return NS_ERROR_FAILURE; enumerator->First(); @@ -4586,10 +4587,10 @@ nsAutoSelectionReset::nsAutoSelectionReset(nsIDOMSelection *aSel) mSel = do_QueryInterface(aSel); if (mSel) { - mSel->GetAnchorNode(getter_AddRefs(mStartNode)); - mSel->GetAnchorOffset(&mStartOffset); - mSel->GetFocusNode(getter_AddRefs(mEndNode)); - mSel->GetFocusOffset(&mEndOffset); + mSel->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(mStartNode)); + mSel->GetAnchorOffset(SELECTION_NORMAL, &mStartOffset); + mSel->GetFocusNode(SELECTION_NORMAL, getter_AddRefs(mEndNode)); + mSel->GetFocusOffset(SELECTION_NORMAL, &mEndOffset); if (mStartNode && mEndNode) mInitialized = PR_TRUE; } @@ -4600,8 +4601,8 @@ nsAutoSelectionReset::~nsAutoSelectionReset() if (mSel && mInitialized) { // restore original selection - mSel->Collapse(mStartNode, mStartOffset); - mSel->Extend(mEndNode, mEndOffset); + mSel->Collapse(mStartNode, mStartOffset, SELECTION_NORMAL); + mSel->Extend(mEndNode, mEndOffset, SELECTION_NORMAL); } } diff --git a/mozilla/editor/base/nsEditorEventListeners.cpp b/mozilla/editor/base/nsEditorEventListeners.cpp index 5c1eef4c120..1f60162d27d 100644 --- a/mozilla/editor/base/nsEditorEventListeners.cpp +++ b/mozilla/editor/base/nsEditorEventListeners.cpp @@ -865,7 +865,7 @@ nsTextEditorMouseListener::MouseDown(nsIDOMEvent* aMouseEvent) nsCOMPtr selection; if (NS_SUCCEEDED(editor->GetSelection(getter_AddRefs(selection)))) - (void)selection->Collapse(parent, offset); + (void)selection->Collapse(parent, offset, SELECTION_NORMAL); // If the ctrl key is pressed, we'll do paste as quotation. // Would've used the alt key, but the kde wmgr treats alt-middle specially. diff --git a/mozilla/editor/base/nsHTMLEditRules.cpp b/mozilla/editor/base/nsHTMLEditRules.cpp index edb327382f0..dc9c8b67f7f 100644 --- a/mozilla/editor/base/nsHTMLEditRules.cpp +++ b/mozilla/editor/base/nsHTMLEditRules.cpp @@ -226,7 +226,7 @@ nsHTMLEditRules::WillInsertBreak(nsIDOMSelection *aSelection, PRBool *aCancel) // if the selection isn't collapsed, delete it. PRBool bCollapsed; - res = aSelection->GetIsCollapsed(&bCollapsed); + res = aSelection->GetIsCollapsed(SELECTION_NORMAL, &bCollapsed); if (NS_FAILED(res)) return res; if (!bCollapsed) { @@ -295,7 +295,7 @@ nsHTMLEditRules::WillDeleteSelection(nsIDOMSelection *aSelection, nsIEditor::ECo nsresult res = NS_OK; PRBool bCollapsed; - res = aSelection->GetIsCollapsed(&bCollapsed); + res = aSelection->GetIsCollapsed(SELECTION_NORMAL, &bCollapsed); if (NS_FAILED(res)) return res; nsCOMPtr node; @@ -1290,7 +1290,7 @@ nsHTMLEditRules::GetPromotedRanges(nsIDOMSelection *inSelection, if (NS_FAILED(res)) return res; PRInt32 rangeCount; - res = inSelection->GetRangeCount(&rangeCount); + res = inSelection->GetRangeCount(SELECTION_NORMAL, &rangeCount); if (NS_FAILED(res)) return res; PRInt32 i; @@ -1301,7 +1301,7 @@ nsHTMLEditRules::GetPromotedRanges(nsIDOMSelection *inSelection, for (i = 0; i < rangeCount; i++) { - res = inSelection->GetRangeAt(i, getter_AddRefs(selectionRange)); + res = inSelection->GetRangeAt(i, SELECTION_NORMAL, getter_AddRefs(selectionRange)); if (NS_FAILED(res)) return res; res = selectionRange->GetStartParent(getter_AddRefs(startNode)); if (NS_FAILED(res)) return res; @@ -1711,7 +1711,7 @@ nsHTMLEditRules::ReturnInHeader(nsIDOMSelection *aSelection, } // position selection before inserted node - res = aSelection->Collapse(textNode,0); + res = aSelection->Collapse(textNode,0, SELECTION_NORMAL); return res; } @@ -1823,7 +1823,7 @@ nsHTMLEditRules::ReturnInListItem(nsIDOMSelection *aSelection, nsresult res = mEditor->SplitNodeDeep( aListItem, aNode, aOffset); if (NS_FAILED(res)) return res; - res = aSelection->Collapse(aNode,0); + res = aSelection->Collapse(aNode,0, SELECTION_NORMAL); return res; } diff --git a/mozilla/editor/base/nsHTMLEditor.cpp b/mozilla/editor/base/nsHTMLEditor.cpp index 69a09e28091..79918e62c8f 100644 --- a/mozilla/editor/base/nsHTMLEditor.cpp +++ b/mozilla/editor/base/nsHTMLEditor.cpp @@ -179,6 +179,11 @@ NS_IMETHODIMP nsHTMLEditor::SetBackgroundColor(const nsString& aColor) mJSEditorLog->SetBackgroundColor(aColor); #endif // ENABLE_JS_EDITOR_LOG + NS_ASSERTION(mDoc, "Missing Editor DOM Document"); + + // TODO: Check selection for Cell, Row, Column or table and do color on appropriate level + // For initial testing, just set the background on the BODY tag (the document's background) + return nsTextEditor::SetBackgroundColor(aColor); } @@ -268,12 +273,12 @@ NS_IMETHODIMP nsHTMLEditor::InsertBreak() nextNode->GetParentNode(getter_AddRefs(parent)); res = GetChildOffset(nextNode, parent, offsetInParent); if (NS_SUCCEEDED(res)) { - selection->Collapse(parent, offsetInParent+1); // +1 to insert just after the break + selection->Collapse(parent, offsetInParent+1, SELECTION_NORMAL); // +1 to insert just after the break } } else { - selection->Collapse(nextNode, offsetInParent); + selection->Collapse(nextNode, offsetInParent, SELECTION_NORMAL); } } } @@ -495,7 +500,7 @@ NS_IMETHODIMP nsHTMLEditor::PasteAsCitedQuotation(const nsString& aCitation) #endif } - res = selection->Collapse(newNode, 0); + res = selection->Collapse(newNode, 0, SELECTION_NORMAL); if (NS_FAILED(res)) { #ifdef DEBUG_akkana @@ -576,7 +581,7 @@ NS_IMETHODIMP nsHTMLEditor::InsertHTML(const nsString& aInputString) // Get the first range in the selection, for context: nsCOMPtr range; - res = selection->GetRangeAt(0, getter_AddRefs(range)); + res = selection->GetRangeAt(0, SELECTION_NORMAL, getter_AddRefs(range)); if (NS_FAILED(res)) return res; @@ -614,7 +619,7 @@ NS_IMETHODIMP nsHTMLEditor::InsertHTML(const nsString& aInputString) // set the selection back there after the insert. // Unfortunately this doesn't work right yet. nsCOMPtr saverange; - res = selection->GetRangeAt(0, getter_AddRefs(saverange)); + res = selection->GetRangeAt(0, SELECTION_NORMAL, getter_AddRefs(saverange)); // Insert the node: res = InsertNode(fragmentAsNode, parentNode, offsetOfNewNode); @@ -627,10 +632,10 @@ NS_IMETHODIMP nsHTMLEditor::InsertHTML(const nsString& aInputString) PRInt32 offset; if (NS_SUCCEEDED(saverange->GetEndParent(getter_AddRefs(parent)))) if (NS_SUCCEEDED(saverange->GetEndOffset(&offset))) - selection->Collapse(parent, offset); + selection->Collapse(parent, offset, SELECTION_NORMAL); } else - selection->Collapse(parentNode, 0/*offsetOfNewNode*/); + selection->Collapse(parentNode, 0/*offsetOfNewNode*/, SELECTION_NORMAL); #else /* INSERT_FRAGMENT_DIRECTLY */ // Loop over the contents of the fragment: nsCOMPtr child; @@ -659,6 +664,7 @@ NS_IMETHODIMP nsHTMLEditor::InsertHTML(const nsString& aInputString) return res; } + NS_IMETHODIMP nsHTMLEditor::OutputToString(nsString& aOutputString, const nsString& aFormatType, PRUint32 aFlags) @@ -706,8 +712,8 @@ nsHTMLEditor::GetParagraphStyle(nsStringArray *aTagList) if ((NS_SUCCEEDED(res)) && selection) { nsCOMPtr enumerator; - enumerator = do_QueryInterface(selection); - if (enumerator) + res = selection->GetEnumerator(SELECTION_NORMAL, getter_AddRefs(enumerator)); + if (NS_SUCCEEDED(res) && enumerator) { enumerator->First(); nsISupports *currentItem; @@ -837,8 +843,8 @@ nsHTMLEditor::ReplaceBlockParent(nsString& aParentTag) // set the block parent for all selected ranges nsAutoEditBatch beginBatching(this); nsCOMPtr enumerator; - enumerator = do_QueryInterface(selection); - if (enumerator) + res = selection->GetEnumerator(SELECTION_NORMAL, getter_AddRefs(enumerator)); + if (NS_SUCCEEDED(res) && enumerator) { enumerator->First(); nsISupports *currentItem; @@ -1228,8 +1234,8 @@ nsHTMLEditor::RemoveParagraphStyle() nsAutoSelectionReset selectionResetter(selection); nsAutoEditBatch beginBatching(this); nsCOMPtr enumerator; - enumerator = do_QueryInterface(selection); - if (enumerator) + res = selection->GetEnumerator(SELECTION_NORMAL, getter_AddRefs(enumerator)); + if (NS_SUCCEEDED(res) && enumerator) { enumerator->First(); nsISupports *currentItem; @@ -1348,8 +1354,8 @@ nsHTMLEditor::RemoveParent(const nsString &aParentTag) nsAutoSelectionReset selectionResetter(selection); nsAutoEditBatch beginBatching(this); nsCOMPtr enumerator; - enumerator = do_QueryInterface(selection); - if (enumerator) + res = selection->GetEnumerator(SELECTION_NORMAL, getter_AddRefs(enumerator)); + if (NS_SUCCEEDED(res) && enumerator) { enumerator->First(); nsISupports *currentItem; @@ -1483,7 +1489,7 @@ nsHTMLEditor::Indent(const nsString& aIndent) nsCOMPtr node; PRInt32 offset; PRBool isCollapsed; - res = selection->GetIsCollapsed(&isCollapsed); + res = selection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed); if (NS_FAILED(res)) return res; res = GetStartNodeAndOffset(selection, &node, &offset); @@ -1525,7 +1531,7 @@ nsHTMLEditor::Indent(const nsString& aIndent) res = CreateNode(bq, parent, offset, getter_AddRefs(newBQ)); if (NS_FAILED(res)) return res; // put a space in it so layout will draw the list item - res = selection->Collapse(newBQ,0); + res = selection->Collapse(newBQ,0, SELECTION_NORMAL); if (NS_FAILED(res)) return res; nsAutoString theText(" "); res = InsertText(theText); @@ -1533,7 +1539,7 @@ nsHTMLEditor::Indent(const nsString& aIndent) // reposition selection to before the space character res = GetStartNodeAndOffset(selection, &node, &offset); if (NS_FAILED(res)) return res; - res = selection->Collapse(node,0); + res = selection->Collapse(node,0, SELECTION_NORMAL); if (NS_FAILED(res)) return res; } } @@ -1599,7 +1605,7 @@ nsHTMLEditor::InsertList(const nsString& aListType) if (NS_FAILED(res) || !selection) return res; PRBool isCollapsed; - res = selection->GetIsCollapsed(&isCollapsed); + res = selection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed); if (NS_FAILED(res)) return res; nsCOMPtr node; @@ -1646,7 +1652,7 @@ nsHTMLEditor::InsertList(const nsString& aListType) if (NS_FAILED(res)) return res; // put a space in it so layout will draw the list item // XXX - revisit when layout is fixed - res = selection->Collapse(newItem,0); + res = selection->Collapse(newItem,0, SELECTION_NORMAL); if (NS_FAILED(res)) return res; nsAutoString theText(" "); res = InsertText(theText); @@ -1654,7 +1660,7 @@ nsHTMLEditor::InsertList(const nsString& aListType) // reposition selection to before the space character res = GetStartNodeAndOffset(selection, &node, &offset); if (NS_FAILED(res)) return res; - res = selection->Collapse(node,0); + res = selection->Collapse(node,0, SELECTION_NORMAL); if (NS_FAILED(res)) return res; } @@ -1684,7 +1690,7 @@ nsHTMLEditor::InsertLink(nsString& aURL) return res; } PRBool isCollapsed; - res = selection->GetIsCollapsed(&isCollapsed); + res = selection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed); if (NS_FAILED(res)) isCollapsed = PR_TRUE; @@ -1732,7 +1738,7 @@ nsHTMLEditor::InsertLink(nsString& aURL) #endif return res; } - res = selection->Collapse(newNode, 0); + res = selection->Collapse(newNode, 0, SELECTION_NORMAL); if (NS_FAILED(res)) { #ifdef DEBUG_akkana @@ -1852,7 +1858,7 @@ nsHTMLEditor::GetSelectedElement(const nsString& aTagName, nsIDOMElement** aRetu return res; PRBool isCollapsed; - selection->GetIsCollapsed(&isCollapsed); + selection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed); nsCOMPtr selectedElement; PRBool bNodeFound = PR_FALSE; @@ -1860,8 +1866,8 @@ nsHTMLEditor::GetSelectedElement(const nsString& aTagName, nsIDOMElement** aRetu if (!isCollapsed) { nsCOMPtr enumerator; - enumerator = do_QueryInterface(selection); - if (enumerator) + res = selection->GetEnumerator(SELECTION_NORMAL,getter_AddRefs(enumerator)); + if (NS_SUCCEEDED(res) && enumerator) { enumerator->First(); nsISupports *currentItem; @@ -2029,6 +2035,10 @@ nsHTMLEditor::CreateElementWithDefaults(const nsString& aTagName, nsIDOMElement* // Set default values for new elements if (TagName.Equals("hr")) + { + // TODO: Get the text of the selection and build a suggested Name + // Replace spaces with "_" + } else if (TagName.Equals("hr")) { // Hard coded defaults in case there's no prefs nsAutoString align("center"); @@ -2181,14 +2191,14 @@ nsHTMLEditor::InsertElement(nsIDOMElement* aElement, PRBool aDeleteSelection) if (collapseAfter) { // Default behavior is to collapse to the end of the selection - selection->ClearSelection(); + selection->ClearSelection(SELECTION_NORMAL); } else { // Collapse to the start of the selection, // We must explore the first range and find // its parent and starting offset of selection // TODO: Move this logic to a new method nsIDOMSelection::CollapseToStart()??? nsCOMPtr firstRange; - res = selection->GetRangeAt(0, getter_AddRefs(firstRange)); + res = selection->GetRangeAt(0, SELECTION_NORMAL, getter_AddRefs(firstRange)); if (NS_SUCCEEDED(res) && firstRange) { nsCOMPtr parent; @@ -2197,10 +2207,10 @@ nsHTMLEditor::InsertElement(nsIDOMElement* aElement, PRBool aDeleteSelection) { PRInt32 startOffset; firstRange->GetStartOffset(&startOffset); - selection->Collapse(parent, startOffset); + selection->Collapse(parent, startOffset, SELECTION_NORMAL); } else { // Very unlikely, but collapse to the end if we failed above - selection->ClearSelection(); + selection->ClearSelection(SELECTION_NORMAL); } } } @@ -2369,7 +2379,7 @@ nsHTMLEditor::InsertLinkAroundSelection(nsIDOMElement* aAnchorElement) goto DELETE_ANCHOR; PRBool isCollapsed; - res = selection->GetIsCollapsed(&isCollapsed); + res = selection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed); if (NS_FAILED(res)) isCollapsed = PR_TRUE; @@ -2461,9 +2471,9 @@ nsHTMLEditor::SelectElement(nsIDOMElement* aElement) if (NS_SUCCEEDED(res)) { // Collapse selection to just before desired element, - selection->Collapse(parent, offsetInParent); + selection->Collapse(parent, offsetInParent, SELECTION_NORMAL); // then extend it to just after - selection->Extend(parent, offsetInParent+1); + selection->Extend(parent, offsetInParent+1, SELECTION_NORMAL); } } } @@ -2533,7 +2543,7 @@ nsHTMLEditor::SetCaretInTableCell(nsIDOMElement* aElement, PRBool* caretIsSet) res = nsEditor::GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(res) && selection) { - res = selection->Collapse(parent, offset); + res = selection->Collapse(parent, offset, SELECTION_NORMAL); if (NS_SUCCEEDED(res) && caretIsSet) *caretIsSet = PR_TRUE; } @@ -2571,8 +2581,8 @@ nsHTMLEditor::SetCaretAfterElement(nsIDOMElement* aElement) offsetInParent++; if (NS_SUCCEEDED(res)) { - // Collapse selection to just after desired element, - selection->Collapse(parent, offsetInParent); + // Collapse selection to just after desired element, + selection->Collapse(parent, offsetInParent+1, SELECTION_NORMAL); } } } diff --git a/mozilla/editor/base/nsInsertHTMLTxn.cpp b/mozilla/editor/base/nsInsertHTMLTxn.cpp index d2a42b60cdb..ed44748dd04 100644 --- a/mozilla/editor/base/nsInsertHTMLTxn.cpp +++ b/mozilla/editor/base/nsInsertHTMLTxn.cpp @@ -54,7 +54,7 @@ NS_IMETHODIMP nsInsertHTMLTxn::Do(void) if (NS_SUCCEEDED(res) && selection) { // Get the first range in the selection, and save it in mRange: - res = selection->GetRangeAt(0, getter_AddRefs(mRange)); + res = selection->GetRangeAt(0, SELECTION_NORMAL, getter_AddRefs(mRange)); if (NS_SUCCEEDED(res)) { nsCOMPtr nsrange (do_QueryInterface(mRange)); diff --git a/mozilla/editor/base/nsJSEditorLog.cpp b/mozilla/editor/base/nsJSEditorLog.cpp index 2900d757c89..5d295a236e8 100644 --- a/mozilla/editor/base/nsJSEditorLog.cpp +++ b/mozilla/editor/base/nsJSEditorLog.cpp @@ -957,7 +957,7 @@ nsJSEditorLog::PrintSelection() if (NS_FAILED(result)) return result; - result = selection->GetRangeCount(&rangeCount); + result = selection->GetRangeCount(SELECTION_NORMAL, &rangeCount); if (NS_FAILED(result)) return result; @@ -972,7 +972,7 @@ nsJSEditorLog::PrintSelection() for (i = 0; i < rangeCount; i++) { - result = selection->GetRangeAt(i, getter_AddRefs(range)); + result = selection->GetRangeAt(i, SELECTION_NORMAL, getter_AddRefs(range)); if (NS_FAILED(result)) return result; diff --git a/mozilla/editor/base/nsTextEditRules.cpp b/mozilla/editor/base/nsTextEditRules.cpp index 0a5cff344e7..c0d01d5195d 100644 --- a/mozilla/editor/base/nsTextEditRules.cpp +++ b/mozilla/editor/base/nsTextEditRules.cpp @@ -196,7 +196,7 @@ nsTextEditRules::WillInsert(nsIDOMSelection *aSelection, PRBool *aCancel) mEditor->DeleteNode(mBogusNode); mBogusNode = do_QueryInterface(nsnull); // there is no longer any legit selection, so clear it. - aSelection->ClearSelection(); + aSelection->ClearSelection(SELECTION_NORMAL); } return NS_OK; @@ -339,8 +339,8 @@ nsTextEditRules::CreateStyleForInsertText(nsIDOMSelection *aSelection, TypeInSta // Otherwise, create the text node and the new inline style parents. nsCOMPtranchor; PRInt32 offset; - nsresult result = aSelection->GetAnchorNode(getter_AddRefs(anchor)); - if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(&offset)) && anchor) + nsresult result = aSelection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(anchor)); + if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(SELECTION_NORMAL, &offset)) && anchor) { nsCOMPtranchorAsText; anchorAsText = do_QueryInterface(anchor); @@ -527,7 +527,7 @@ nsTextEditRules::InsertStyleNode(nsIDOMNode *aNode, result = mEditor->InsertNode(aNode, *aNewNode, 0); if (NS_SUCCEEDED(result)) { if (aSelection) { - aSelection->Collapse(aNode, 0); + aSelection->Collapse(aNode, 0, SELECTION_NORMAL); } } } @@ -548,8 +548,8 @@ nsTextEditRules::InsertStyleAndNewTextNode(nsIDOMNode *aParentNode, nsIAtom *aTa { nsCOMPtranchor; PRInt32 offset; - result = aSelection->GetAnchorNode(getter_AddRefs(anchor)); - if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(&offset)) && anchor) + result = aSelection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(anchor)); + if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(SELECTION_NORMAL, &offset)) && anchor) { nsCOMPtranchorAsText; anchorAsText = do_QueryInterface(anchor); @@ -573,7 +573,7 @@ nsTextEditRules::InsertStyleAndNewTextNode(nsIDOMNode *aParentNode, nsIAtom *aTa if (NS_SUCCEEDED(result)) { if (aSelection) { - aSelection->Collapse(newTextNode, 0); + aSelection->Collapse(newTextNode, 0, SELECTION_NORMAL); } } } @@ -668,7 +668,7 @@ nsTextEditRules::DidDeleteSelection(nsIDOMSelection *aSelection, nsresult result = aResult; // if aResult is an error, we just return it if (!aSelection) { return NS_ERROR_NULL_POINTER; } PRBool isCollapsed; - aSelection->GetIsCollapsed(&isCollapsed); + aSelection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed); NS_ASSERTION(PR_TRUE==isCollapsed, "selection not collapsed after delete selection."); // if the delete selection resulted in no content // insert a special bogus text node with a   character in it. @@ -680,8 +680,8 @@ nsTextEditRules::DidDeleteSelection(nsIDOMSelection *aSelection, { nsCOMPtranchor; PRInt32 offset; - result = aSelection->GetAnchorNode(getter_AddRefs(anchor)); - if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(&offset)) && anchor) + result = aSelection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(anchor)); + if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(SELECTION_NORMAL, &offset)) && anchor) { nsCOMPtr anchorChildren; result = anchor->GetChildNodes(getter_AddRefs(anchorChildren)); @@ -728,7 +728,7 @@ nsTextEditRules::DidDeleteSelection(nsIDOMSelection *aSelection, result = mEditor->JoinNodes(selectedNode, siblingNode, parentNode); // selectedNode will remain after the join, siblingNode is removed // set selection - aSelection->Collapse(siblingNode, selectedNodeLength); + aSelection->Collapse(siblingNode, selectedNodeLength, SELECTION_NORMAL); } } } @@ -768,8 +768,8 @@ nsTextEditRules:: DidUndo(nsIDOMSelection *aSelection, nsresult aResult) { nsCOMPtrnode; PRInt32 offset; - result = aSelection->GetAnchorNode(getter_AddRefs(node)); - if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(&offset)) && node) + result = aSelection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(node)); + if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(SELECTION_NORMAL, &offset)) && node) { nsCOMPtrelement; element = do_QueryInterface(node); @@ -815,8 +815,8 @@ nsTextEditRules::DidRedo(nsIDOMSelection *aSelection, nsresult aResult) { nsCOMPtrnode; PRInt32 offset; - result = aSelection->GetAnchorNode(getter_AddRefs(node)); - if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(&offset)) && node) + result = aSelection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(node)); + if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(SELECTION_NORMAL, &offset)) && node) { nsCOMPtrelement; element = do_QueryInterface(node); @@ -918,7 +918,7 @@ nsTextEditRules::CreateBogusNodeIfNeeded(nsIDOMSelection *aSelection) nsAutoString data; data += 160; newNodeAsText->SetData(data); - aSelection->Collapse(newTNode, 0); + aSelection->Collapse(newTNode, 0, SELECTION_NORMAL); } } // make sure we know the PNode is bogus @@ -967,7 +967,7 @@ nsTextEditRules::PinSelectionInPRE(nsIDOMSelection *aSelection) if (NS_FAILED(res)) return res; // there should only be one selection range in text docs - res = aSelection->GetRangeAt(0, getter_AddRefs(selectionRange)); + res = aSelection->GetRangeAt(0, SELECTION_NORMAL, getter_AddRefs(selectionRange)); if (NS_FAILED(res)) return res; res = selectionRange->Clone(getter_AddRefs(pinRange)); if (NS_FAILED(res)) return res; @@ -1021,9 +1021,9 @@ nsTextEditRules::PinSelectionInPRE(nsIDOMSelection *aSelection) if (NS_FAILED(res)) return res; res = pinRange->GetEndOffset(&endOffset); if (NS_FAILED(res)) return res; - res = aSelection->Collapse(startNode,startOffset); + res = aSelection->Collapse(startNode,startOffset, SELECTION_NORMAL); if (NS_FAILED(res)) return res; - res = aSelection->Extend(endNode,endOffset); + res = aSelection->Extend(endNode,endOffset, SELECTION_NORMAL); if (NS_FAILED(res)) return res; } diff --git a/mozilla/editor/base/nsTextEditor.cpp b/mozilla/editor/base/nsTextEditor.cpp index df678f10612..3aa13701ea9 100644 --- a/mozilla/editor/base/nsTextEditor.cpp +++ b/mozilla/editor/base/nsTextEditor.cpp @@ -399,7 +399,7 @@ NS_IMETHODIMP nsTextEditor::SetTextProperty(nsIAtom *aProperty, if ((PR_FALSE==cancel) && (NS_SUCCEEDED(result))) { PRBool isCollapsed; - selection->GetIsCollapsed(&isCollapsed); + selection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed); if (PR_TRUE==isCollapsed) { // manipulating text attributes on a collapsed selection only sets state for the next text insertion @@ -410,8 +410,8 @@ NS_IMETHODIMP nsTextEditor::SetTextProperty(nsIAtom *aProperty, // set the text property for all selected ranges nsEditor::BeginTransaction(); nsCOMPtr enumerator; - enumerator = do_QueryInterface(selection); - if (enumerator) + result = selection->GetEnumerator(SELECTION_NORMAL,getter_AddRefs(enumerator)); + if (NS_SUCCEEDED(result) && enumerator) { enumerator->First(); nsISupports *currentItem; @@ -525,10 +525,10 @@ NS_IMETHODIMP nsTextEditor::GetTextProperty(nsIAtom *aProperty, if ((NS_SUCCEEDED(result)) && selection) { PRBool isCollapsed; - selection->GetIsCollapsed(&isCollapsed); + selection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed); nsCOMPtr enumerator; - enumerator = do_QueryInterface(selection); - if (enumerator) + result = selection->GetEnumerator(SELECTION_NORMAL, getter_AddRefs(enumerator)); + if (NS_SUCCEEDED(result) && enumerator) { enumerator->First(); nsISupports *currentItem; @@ -735,7 +735,7 @@ NS_IMETHODIMP nsTextEditor::RemoveTextProperty(nsIAtom *aProperty, const nsStrin if ((PR_FALSE==cancel) && (NS_SUCCEEDED(result))) { PRBool isCollapsed; - selection->GetIsCollapsed(&isCollapsed); + selection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed); if (PR_TRUE==isCollapsed) { // manipulating text attributes on a collapsed selection only sets state for the next text insertion @@ -754,8 +754,8 @@ NS_IMETHODIMP nsTextEditor::RemoveTextProperty(nsIAtom *aProperty, const nsStrin nsCOMPtr startParent, endParent; PRInt32 startOffset, endOffset; nsCOMPtr enumerator; - enumerator = do_QueryInterface(selection); - if (enumerator) + result = selection->GetEnumerator(SELECTION_NORMAL,getter_AddRefs(enumerator)); + if (NS_SUCCEEDED(result) && enumerator) { enumerator->First(); nsISupports *currentItem; @@ -847,14 +847,14 @@ void nsTextEditor::GetTextSelectionOffsetsForRange(nsIDOMSelection *aSelection, nsCOMPtr startNode, endNode; PRInt32 startOffset, endOffset; - aSelection->GetAnchorNode(getter_AddRefs(startNode)); - aSelection->GetAnchorOffset(&startOffset); - aSelection->GetFocusNode(getter_AddRefs(endNode)); - aSelection->GetFocusOffset(&endOffset); + aSelection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(startNode)); + aSelection->GetAnchorOffset(SELECTION_NORMAL, &startOffset); + aSelection->GetFocusNode(SELECTION_NORMAL, getter_AddRefs(endNode)); + aSelection->GetFocusOffset(SELECTION_NORMAL, &endOffset); nsCOMPtr enumerator; - enumerator = do_QueryInterface(aSelection); - if (enumerator) + result = aSelection->GetEnumerator(SELECTION_NORMAL,getter_AddRefs(enumerator)); + if (NS_SUCCEEDED(result) && enumerator) { enumerator->First(); nsISupports *currentItem; @@ -951,8 +951,8 @@ void nsTextEditor::ResetTextSelectionForRange(nsIDOMNode *aParent, iter->Next(); iter->CurrentNode(getter_AddRefs(content)); } - aSelection->Collapse(startNode, startOffset); - aSelection->Extend(endNode, endOffset); + aSelection->Collapse(startNode, startOffset, SELECTION_NORMAL); + aSelection->Extend(endNode, endOffset, SELECTION_NORMAL); } } @@ -1856,9 +1856,9 @@ NS_IMETHODIMP nsTextEditor::MoveContentOfNodeIntoNewParent(nsIDOMNode *aNode, result = nsEditor::GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(result)) { - selection->Collapse(newChildNode, 0); + selection->Collapse(newChildNode, 0, SELECTION_NORMAL); PRInt32 endOffset = aEndOffset-aStartOffset; - selection->Extend(newChildNode, endOffset); + selection->Extend(newChildNode, endOffset, SELECTION_NORMAL); } } } @@ -2051,8 +2051,8 @@ NS_IMETHODIMP nsTextEditor::MoveContiguousContentIntoNewParent(nsIDOMNode *aSta result = nsEditor::GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(result)) { - selection->Collapse(startNode, startOffset); - selection->Extend(newRightNode, endOffset); + selection->Collapse(startNode, startOffset, SELECTION_NORMAL); + selection->Extend(newRightNode, endOffset, SELECTION_NORMAL); } } } @@ -2106,8 +2106,8 @@ nsTextEditor::SetTextPropertiesForNodeWithDifferentParents(nsIDOMRange *aRange, result = nsEditor::GetSelection(getter_AddRefs(selection)); if (NS_FAILED(result)) { return result; } if (!selection) { return NS_ERROR_NULL_POINTER; } - selection->GetAnchorOffset(&aStartOffset); - selection->GetFocusOffset(&aEndOffset); + selection->GetAnchorOffset(SELECTION_NORMAL, &aStartOffset); + selection->GetFocusOffset(SELECTION_NORMAL, &aEndOffset); // create new parent nodes for all the content between the start and end nodes nsCOMPtriter; @@ -2256,8 +2256,8 @@ nsTextEditor::SetTextPropertiesForNodeWithDifferentParents(nsIDOMRange *aRange, } if (NS_SUCCEEDED(result)) { - selection->Collapse(startNode, startOffset); - selection->Extend(endNode, aEndOffset); + selection->Collapse(startNode, startOffset, SELECTION_NORMAL); + selection->Extend(endNode, aEndOffset, SELECTION_NORMAL); } } } @@ -2770,8 +2770,8 @@ nsTextEditor::RemoveTextPropertiesForNodeWithDifferentParents(nsIDOMNode *aStar result = nsEditor::GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(result)) { - selection->Collapse(aStartNode, rangeStartOffset); - selection->Extend(aEndNode, rangeEndOffset); + selection->Collapse(aStartNode, rangeStartOffset, SELECTION_NORMAL); + selection->Extend(aEndNode, rangeEndOffset, SELECTION_NORMAL); if (gNoisy) { printf("RTPFNWDP set selection.\n"); } } } @@ -2973,14 +2973,14 @@ nsresult nsTextEditor::GetTextSelectionOffsets(nsIDOMSelection *aSelection, nsCOMPtr startNode, endNode, parentNode; PRInt32 startOffset, endOffset; - aSelection->GetAnchorNode(getter_AddRefs(startNode)); - aSelection->GetAnchorOffset(&startOffset); - aSelection->GetFocusNode(getter_AddRefs(endNode)); - aSelection->GetFocusOffset(&endOffset); + aSelection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(startNode)); + aSelection->GetAnchorOffset(SELECTION_NORMAL, &startOffset); + aSelection->GetFocusNode(SELECTION_NORMAL, getter_AddRefs(endNode)); + aSelection->GetFocusOffset(SELECTION_NORMAL, &endOffset); nsCOMPtr enumerator; - enumerator = do_QueryInterface(aSelection); - if (enumerator) + result = aSelection->GetEnumerator(SELECTION_NORMAL,getter_AddRefs(enumerator)); + if (NS_SUCCEEDED(result) && enumerator) { // don't use "result" in this block enumerator->First(); diff --git a/mozilla/editor/libeditor/base/CreateElementTxn.cpp b/mozilla/editor/libeditor/base/CreateElementTxn.cpp index 972544e0dca..1e30d328208 100644 --- a/mozilla/editor/libeditor/base/CreateElementTxn.cpp +++ b/mozilla/editor/libeditor/base/CreateElementTxn.cpp @@ -127,7 +127,7 @@ NS_IMETHODIMP CreateElementTxn::Do(void) if (NS_SUCCEEDED(selectionResult) && selection) { PRInt32 offset=0; nsEditor::GetChildOffset(mNewNode, mParent, offset); - selectionResult = selection->Collapse(mParent, offset); + selectionResult = selection->Collapse(mParent, offset, SELECTION_NORMAL); NS_ASSERTION((NS_SUCCEEDED(selectionResult)), "selection could not be collapsed after undo of insert."); } } @@ -155,7 +155,7 @@ NS_IMETHODIMP CreateElementTxn::Undo(void) if (mRefNode) { nsEditor::GetChildOffset(mRefNode, mParent, offset); } - selectionResult = selection->Collapse(mParent, offset); + selectionResult = selection->Collapse(mParent, offset, SELECTION_NORMAL); NS_ASSERTION((NS_SUCCEEDED(selectionResult)), "selection could not be collapsed after undo of insert."); } } @@ -185,7 +185,7 @@ NS_IMETHODIMP CreateElementTxn::Redo(void) if (NS_SUCCEEDED(result) && selection) { PRInt32 offset=0; nsEditor::GetChildOffset(mNewNode, mParent, offset); - nsresult selectionResult = selection->Collapse(mParent, offset); + nsresult selectionResult = selection->Collapse(mParent, offset, SELECTION_NORMAL); NS_ASSERTION((NS_SUCCEEDED(selectionResult)), "selection could not be collapsed after undo of insert."); } } diff --git a/mozilla/editor/libeditor/base/DeleteRangeTxn.cpp b/mozilla/editor/libeditor/base/DeleteRangeTxn.cpp index 82e7df577c3..5af55dacf64 100644 --- a/mozilla/editor/libeditor/base/DeleteRangeTxn.cpp +++ b/mozilla/editor/libeditor/base/DeleteRangeTxn.cpp @@ -149,7 +149,7 @@ NS_IMETHODIMP DeleteRangeTxn::Do(void) nsCOMPtr selection; result = mEditor->GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(result)) { - result = selection->Collapse(mStartParent, mStartOffset); + result = selection->Collapse(mStartParent, mStartOffset, SELECTION_NORMAL); } } @@ -169,8 +169,8 @@ NS_IMETHODIMP DeleteRangeTxn::Undo(void) nsCOMPtr selection; result = mEditor->GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(result)) { - selection->Collapse(mStartParent, mStartOffset); - selection->Extend(mEndParent, mEndOffset); + selection->Collapse(mStartParent, mStartOffset, SELECTION_NORMAL); + selection->Extend(mEndParent, mEndOffset, SELECTION_NORMAL); } } @@ -190,7 +190,7 @@ NS_IMETHODIMP DeleteRangeTxn::Redo(void) nsCOMPtr selection; result = mEditor->GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(result)) { - result = selection->Collapse(mStartParent, mStartOffset); + result = selection->Collapse(mStartParent, mStartOffset, SELECTION_NORMAL); } } diff --git a/mozilla/editor/libeditor/base/DeleteTextTxn.cpp b/mozilla/editor/libeditor/base/DeleteTextTxn.cpp index cf713939181..47ac554a1b7 100644 --- a/mozilla/editor/libeditor/base/DeleteTextTxn.cpp +++ b/mozilla/editor/libeditor/base/DeleteTextTxn.cpp @@ -69,7 +69,7 @@ NS_IMETHODIMP DeleteTextTxn::Do(void) nsCOMPtr selection; nsresult selectionResult = mEditor->GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(selectionResult) && selection) { - selectionResult = selection->Collapse(mElement, mOffset); + selectionResult = selection->Collapse(mElement, mOffset, SELECTION_NORMAL); NS_ASSERTION((NS_SUCCEEDED(selectionResult)), "selection could not be collapsed after undo of insert."); } } @@ -91,7 +91,7 @@ NS_IMETHODIMP DeleteTextTxn::Undo(void) nsCOMPtr selection; nsresult selectionResult = mEditor->GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(selectionResult) && selection) { - selectionResult = selection->Collapse(mElement, mOffset); + selectionResult = selection->Collapse(mElement, mOffset, SELECTION_NORMAL); NS_ASSERTION((NS_SUCCEEDED(selectionResult)), "selection could not be collapsed after undo of insert."); } } diff --git a/mozilla/editor/libeditor/base/IMETextTxn.cpp b/mozilla/editor/libeditor/base/IMETextTxn.cpp index 9a97e3a4af4..adfb733b7c0 100644 --- a/mozilla/editor/libeditor/base/IMETextTxn.cpp +++ b/mozilla/editor/libeditor/base/IMETextTxn.cpp @@ -104,7 +104,7 @@ NS_IMETHODIMP IMETextTxn::Undo(void) nsCOMPtr selection; result = mPresShell->GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(result) && selection) { - result = selection->Collapse(mElement, mOffset); + result = selection->Collapse(mElement, mOffset, SELECTION_NORMAL); NS_ASSERTION((NS_SUCCEEDED(result)), "selection could not be collapsed after undo of IME insert."); } } @@ -281,13 +281,13 @@ NS_IMETHODIMP IMETextTxn::CollapseTextSelection(void) result = mPresShell->GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(result) && selection){ if (haveSelectedRange) { - result = selection->Collapse(mElement,mOffset+selectionStart); - result = selection->Extend(mElement,mOffset+selectionEnd); + result = selection->Collapse(mElement,mOffset+selectionStart, SELECTION_NORMAL); + result = selection->Extend(mElement,mOffset+selectionEnd, SELECTION_NORMAL); } else { if (haveCaretPosition) - result = selection->Collapse(mElement,mOffset+caretPosition); + result = selection->Collapse(mElement,mOffset+caretPosition, SELECTION_NORMAL); else - result = selection->Collapse(mElement,mOffset+mStringToInsert.Length()); + result = selection->Collapse(mElement,mOffset+mStringToInsert.Length(), SELECTION_NORMAL); } } @@ -299,7 +299,7 @@ NS_IMETHODIMP IMETextTxn::CollapseTextSelectionOnCommit(void) nsCOMPtr selection; nsresult result = mPresShell->GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(result) && selection){ - result = selection->Collapse(mElement,mOffset+mStringToInsert.Length()); + result = selection->Collapse(mElement,mOffset+mStringToInsert.Length(), SELECTION_NORMAL); } return result; diff --git a/mozilla/editor/libeditor/base/InsertElementTxn.cpp b/mozilla/editor/libeditor/base/InsertElementTxn.cpp index 213d298a296..0e94ccf886d 100644 --- a/mozilla/editor/libeditor/base/InsertElementTxn.cpp +++ b/mozilla/editor/libeditor/base/InsertElementTxn.cpp @@ -98,7 +98,7 @@ NS_IMETHODIMP InsertElementTxn::Do(void) result = mEditor->GetSelection(getter_AddRefs(selection)); if ((NS_SUCCEEDED(result)) && selection) { // place the selection just after the inserted element - selection->Collapse(mParent, mOffset+1); + selection->Collapse(mParent, mOffset+1, SELECTION_NORMAL); //selection->Extend(mParent, mOffset+1); } } diff --git a/mozilla/editor/libeditor/base/InsertTextTxn.cpp b/mozilla/editor/libeditor/base/InsertTextTxn.cpp index 592be799909..27470efdf92 100644 --- a/mozilla/editor/libeditor/base/InsertTextTxn.cpp +++ b/mozilla/editor/libeditor/base/InsertTextTxn.cpp @@ -81,7 +81,7 @@ NS_IMETHODIMP InsertTextTxn::Do(void) if (NS_SUCCEEDED(result) && selection) { result = mElement->InsertData(mOffset, mStringToInsert); if (NS_SUCCEEDED(result)) { - result = selection->Collapse(mElement, mOffset+mStringToInsert.Length()); + result = selection->Collapse(mElement, mOffset+mStringToInsert.Length(), SELECTION_NORMAL); NS_ASSERTION((NS_SUCCEEDED(result)), "selection could not be collapsed after insert."); } } @@ -99,7 +99,7 @@ NS_IMETHODIMP InsertTextTxn::Undo(void) nsCOMPtr selection; result = mPresShell->GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(result) && selection) { - result = selection->Collapse(mElement, mOffset); + result = selection->Collapse(mElement, mOffset, SELECTION_NORMAL); NS_ASSERTION((NS_SUCCEEDED(result)), "selection could not be collapsed after undo of insert."); } } diff --git a/mozilla/editor/libeditor/base/JoinElementTxn.cpp b/mozilla/editor/libeditor/base/JoinElementTxn.cpp index c6d3902fbda..46ca5754e44 100644 --- a/mozilla/editor/libeditor/base/JoinElementTxn.cpp +++ b/mozilla/editor/libeditor/base/JoinElementTxn.cpp @@ -89,7 +89,7 @@ NS_IMETHODIMP JoinElementTxn::Do(void) mEditor->GetSelection(getter_AddRefs(selection)); if (selection) { - selection->Collapse(mRightNode, mOffset); + selection->Collapse(mRightNode, mOffset, SELECTION_NORMAL); } } } diff --git a/mozilla/editor/libeditor/base/SplitElementTxn.cpp b/mozilla/editor/libeditor/base/SplitElementTxn.cpp index 179c1231f23..322583ca8f1 100644 --- a/mozilla/editor/libeditor/base/SplitElementTxn.cpp +++ b/mozilla/editor/libeditor/base/SplitElementTxn.cpp @@ -75,7 +75,7 @@ NS_IMETHODIMP SplitElementTxn::Do(void) mEditor->GetSelection(getter_AddRefs(selection)); if (selection) { - selection->Collapse(mNewLeftNode, mOffset); + selection->Collapse(mNewLeftNode, mOffset, SELECTION_NORMAL); } } else { @@ -112,7 +112,7 @@ NS_IMETHODIMP SplitElementTxn::Undo(void) mEditor->GetSelection(getter_AddRefs(selection)); if (selection) { - selection->Collapse(mExistingRightNode, mOffset); + selection->Collapse(mExistingRightNode, mOffset, SELECTION_NORMAL); } } else { diff --git a/mozilla/editor/libeditor/base/nsEditor.cpp b/mozilla/editor/libeditor/base/nsEditor.cpp index 0431fbcc9dd..e52fa655276 100644 --- a/mozilla/editor/libeditor/base/nsEditor.cpp +++ b/mozilla/editor/libeditor/base/nsEditor.cpp @@ -1075,7 +1075,7 @@ NS_IMETHODIMP nsEditor::SelectEntireDocument(nsIDOMSelection *aSelection) nsCOMPtrbodyNode = do_QueryInterface(bodyElement); if (bodyNode) { - result = aSelection->Collapse(bodyNode, 0); + result = aSelection->Collapse(bodyNode, 0, SELECTION_NORMAL); if (NS_SUCCEEDED(result)) { PRInt32 numBodyChildren=0; @@ -1084,7 +1084,7 @@ NS_IMETHODIMP nsEditor::SelectEntireDocument(nsIDOMSelection *aSelection) if ((NS_SUCCEEDED(result)) && lastChild) { GetChildOffset(lastChild, bodyNode, numBodyChildren); - result = aSelection->Extend(bodyNode, numBodyChildren+1); + result = aSelection->Extend(bodyNode, numBodyChildren+1, SELECTION_NORMAL); } } } @@ -1156,7 +1156,7 @@ NS_IMETHODIMP nsEditor::BeginningOfDocument() nsCOMPtr firstNode = GetDeepFirstChild(bodyNode); if (firstNode) { - result = selection->Collapse(firstNode, 0); + result = selection->Collapse(firstNode, 0, SELECTION_NORMAL); ScrollIntoView(PR_TRUE); } } @@ -1241,7 +1241,7 @@ NS_IMETHODIMP nsEditor::EndOfDocument() if (text) text->GetLength(&offset); } - result = selection->Collapse(lastChild, offset); + result = selection->Collapse(lastChild, offset, SELECTION_NORMAL); ScrollIntoView(PR_FALSE); } } @@ -1265,7 +1265,7 @@ NS_IMETHODIMP nsEditor::Cut() return res; PRBool isCollapsed; - if (NS_SUCCEEDED(selection->GetIsCollapsed(&isCollapsed)) && isCollapsed) + if (NS_SUCCEEDED(selection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed)) && isCollapsed) return NS_ERROR_NOT_AVAILABLE; res = Copy(); @@ -1764,7 +1764,7 @@ NS_IMETHODIMP nsEditor::CreateAggregateTxnForDeleteSelection(nsIAtom *aTxnName, if (NS_SUCCEEDED(result) && selection) { PRBool collapsed; - result = selection->GetIsCollapsed(&collapsed); + result = selection->GetIsCollapsed(SELECTION_NORMAL, &collapsed); if (NS_SUCCEEDED(result) && !collapsed) { EditAggregateTxn *delSelTxn; result = CreateTxnForDeleteSelection(nsIEditor::eDoNothing, @@ -1816,8 +1816,8 @@ nsEditor::InsertText(const nsString& aStringToInsert) { nsCOMPtr selectedNode; PRInt32 offset; - result = selection->GetAnchorNode(getter_AddRefs(selectedNode)); - if (NS_SUCCEEDED(result) && NS_SUCCEEDED(selection->GetAnchorOffset(&offset)) && selectedNode) + result = selection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(selectedNode)); + if (NS_SUCCEEDED(result) && NS_SUCCEEDED(selection->GetAnchorOffset(SELECTION_NORMAL, &offset)) && selectedNode) { nsCOMPtr newNode; result = CreateNode(GetTextNodeTag(), selectedNode, offset, // offset+1, why the +1??? @@ -1830,8 +1830,8 @@ nsEditor::InsertText(const nsString& aStringToInsert) { nsAutoString placeholderText(" "); newTextNode->SetData(placeholderText); - selection->Collapse(newNode, 0); - selection->Extend(newNode, 1); + selection->Collapse(newNode, 0, SELECTION_NORMAL); + selection->Extend(newNode, 1, SELECTION_NORMAL); result = InsertText(aStringToInsert); } } @@ -1880,8 +1880,8 @@ NS_IMETHODIMP nsEditor::CreateTxnForInsertText(const nsString & aStringToInsert, #endif result = NS_ERROR_UNEXPECTED; nsCOMPtr enumerator; - enumerator = do_QueryInterface(selection); - if (enumerator) + result = selection->GetEnumerator(SELECTION_NORMAL,getter_AddRefs(enumerator)); + if (NS_SUCCEEDED(result) && enumerator) { enumerator->First(); nsISupports *currentItem; @@ -2042,7 +2042,7 @@ NS_IMETHODIMP nsEditor::DeleteSelectionAndCreateNode(const nsString& aTag, nsCOMPtr selection; result = GetSelection(getter_AddRefs(selection)); if ((NS_SUCCEEDED(result)) && selection) - selection->Collapse(parentSelectedNode, offsetOfNewNode+1); + selection->Collapse(parentSelectedNode, offsetOfNewNode+1, SELECTION_NORMAL); return result; } @@ -2055,7 +2055,7 @@ NS_IMETHODIMP nsEditor::DeleteSelectionAndPrepareToCreateNode(nsCOMPtrGetIsCollapsed(&collapsed); + result = selection->GetIsCollapsed(SELECTION_NORMAL, &collapsed); if (NS_SUCCEEDED(result) && !collapsed) { result = DeleteSelection(nsIEditor::eDoNothing); @@ -2069,13 +2069,13 @@ NS_IMETHODIMP nsEditor::DeleteSelectionAndPrepareToCreateNode(nsCOMPtrtestSelectedNode; - nsresult debugResult = selection->GetAnchorNode(getter_AddRefs(testSelectedNode)); + nsresult debugResult = selection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(testSelectedNode)); // no selection is ok. // if there is a selection, it must be collapsed if (testSelectedNode) { PRBool testCollapsed; - debugResult = selection->GetIsCollapsed(&testCollapsed); + debugResult = selection->GetIsCollapsed(SELECTION_NORMAL, &testCollapsed); NS_ASSERTION((NS_SUCCEEDED(result)), "couldn't get a selection after deletion"); NS_ASSERTION(PR_TRUE==testCollapsed, "selection not reset after deletion"); } @@ -2083,8 +2083,8 @@ NS_IMETHODIMP nsEditor::DeleteSelectionAndPrepareToCreateNode(nsCOMPtrGetAnchorNode(getter_AddRefs(parentSelectedNode)); - if (NS_SUCCEEDED(result) && NS_SUCCEEDED(selection->GetAnchorOffset(&offsetOfSelectedNode)) && parentSelectedNode) + result = selection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(parentSelectedNode)); + if (NS_SUCCEEDED(result) && NS_SUCCEEDED(selection->GetAnchorOffset(SELECTION_NORMAL, &offsetOfSelectedNode)) && parentSelectedNode) { nsCOMPtr selectedNode; PRUint32 selectedNodeContentCount=0; @@ -2241,7 +2241,7 @@ NS_IMETHODIMP nsEditor::CreateTxnForDeleteSelection(nsIEditor::ECollapsedSelecti { // Check whether the selection is collapsed and we should do nothing: PRBool isCollapsed; - result = (selection->GetIsCollapsed(&isCollapsed)); + result = (selection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed)); if (NS_SUCCEEDED(result) && isCollapsed && aAction == eDoNothing) return NS_OK; @@ -2252,8 +2252,8 @@ NS_IMETHODIMP nsEditor::CreateTxnForDeleteSelection(nsIEditor::ECollapsedSelecti } nsCOMPtr enumerator; - enumerator = do_QueryInterface(selection); - if (enumerator) + result = selection->GetEnumerator(SELECTION_NORMAL, getter_AddRefs(enumerator)); + if (NS_SUCCEEDED(result) && enumerator) { for (enumerator->First(); NS_OK!=enumerator->IsDone(); enumerator->Next()) { @@ -3508,8 +3508,8 @@ nsEditor::BeginComposition(void) { result = NS_ERROR_UNEXPECTED; nsCOMPtr enumerator; - enumerator = do_QueryInterface(selection); - if (enumerator) + result = selection->GetEnumerator(SELECTION_NORMAL, getter_AddRefs(enumerator)); + if (NS_SUCCEEDED(result) && enumerator) { enumerator->First(); nsISupports *currentItem; @@ -3782,8 +3782,8 @@ nsEditor::SetInputMethodText(const nsString& aStringToInsert,nsIDOMTextRangeList { nsCOMPtr selectedNode; PRInt32 offset; - result = selection->GetAnchorNode(getter_AddRefs(selectedNode)); - if (NS_SUCCEEDED(result) && NS_SUCCEEDED(selection->GetAnchorOffset(&offset)) && selectedNode) + result = selection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(selectedNode)); + if (NS_SUCCEEDED(result) && NS_SUCCEEDED(selection->GetAnchorOffset(SELECTION_NORMAL, &offset)) && selectedNode) { nsCOMPtr newNode; result = CreateNode(GetTextNodeTag(), selectedNode, offset+1,getter_AddRefs(newNode)); @@ -3795,8 +3795,8 @@ nsEditor::SetInputMethodText(const nsString& aStringToInsert,nsIDOMTextRangeList { nsAutoString placeholderText(" "); newTextNode->SetData(placeholderText); - selection->Collapse(newNode, 0); - selection->Extend(newNode, 1); + selection->Collapse(newNode, 0, SELECTION_NORMAL); + selection->Extend(newNode, 1, SELECTION_NORMAL); result = SetInputMethodText(aStringToInsert,aTextRangeList); } } @@ -4203,12 +4203,13 @@ nsEditor::GetStartNodeAndOffset(nsIDOMSelection *aSelection, nsCOMPtr *outStartNode, PRInt32 *outStartOffset) { - if (!outStartNode || !outStartOffset) + if (!outStartNode || !outStartOffset || !aSelection) return NS_ERROR_NULL_POINTER; nsCOMPtr enumerator; - enumerator = do_QueryInterface(aSelection); - if (!enumerator) + nsresult result; + result = aSelection->GetEnumerator(SELECTION_NORMAL, getter_AddRefs(enumerator)); + if (NS_FAILED(result) || !enumerator) return NS_ERROR_FAILURE; enumerator->First(); @@ -4242,8 +4243,8 @@ nsEditor::GetEndNodeAndOffset(nsIDOMSelection *aSelection, return NS_ERROR_NULL_POINTER; nsCOMPtr enumerator; - enumerator = do_QueryInterface(aSelection); - if (!enumerator) + nsresult result = aSelection->GetEnumerator(SELECTION_NORMAL, getter_AddRefs(enumerator)); + if (NS_FAILED(result) || enumerator) return NS_ERROR_FAILURE; enumerator->First(); @@ -4586,10 +4587,10 @@ nsAutoSelectionReset::nsAutoSelectionReset(nsIDOMSelection *aSel) mSel = do_QueryInterface(aSel); if (mSel) { - mSel->GetAnchorNode(getter_AddRefs(mStartNode)); - mSel->GetAnchorOffset(&mStartOffset); - mSel->GetFocusNode(getter_AddRefs(mEndNode)); - mSel->GetFocusOffset(&mEndOffset); + mSel->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(mStartNode)); + mSel->GetAnchorOffset(SELECTION_NORMAL, &mStartOffset); + mSel->GetFocusNode(SELECTION_NORMAL, getter_AddRefs(mEndNode)); + mSel->GetFocusOffset(SELECTION_NORMAL, &mEndOffset); if (mStartNode && mEndNode) mInitialized = PR_TRUE; } @@ -4600,8 +4601,8 @@ nsAutoSelectionReset::~nsAutoSelectionReset() if (mSel && mInitialized) { // restore original selection - mSel->Collapse(mStartNode, mStartOffset); - mSel->Extend(mEndNode, mEndOffset); + mSel->Collapse(mStartNode, mStartOffset, SELECTION_NORMAL); + mSel->Extend(mEndNode, mEndOffset, SELECTION_NORMAL); } } diff --git a/mozilla/editor/libeditor/html/TextEditorTest.cpp b/mozilla/editor/libeditor/html/TextEditorTest.cpp index 235523fe357..cc2615cdbca 100644 --- a/mozilla/editor/libeditor/html/TextEditorTest.cpp +++ b/mozilla/editor/libeditor/html/TextEditorTest.cpp @@ -108,10 +108,10 @@ nsresult TextEditorTest::TestInsertBreak() TEST_RESULT(result); TEST_POINTER(selection.get()); nsCOMPtranchor; - result = selection->GetAnchorNode(getter_AddRefs(anchor)); + result = selection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(anchor)); TEST_RESULT(result); TEST_POINTER(anchor.get()); - selection->Collapse(anchor, 0); + selection->Collapse(anchor, 0, SELECTION_NORMAL); // insert one break printf("inserting a break\n"); result = mTextEditor->InsertBreak(); @@ -156,8 +156,8 @@ nsresult TextEditorTest::TestTextProperties() textData = do_QueryInterface(textNode); PRUint32 length; textData->GetLength(&length); - selection->Collapse(textNode, 0); - selection->Extend(textNode, length); + selection->Collapse(textNode, 0, SELECTION_NORMAL); + selection->Extend(textNode, length, SELECTION_NORMAL); PRBool any = PR_FALSE; PRBool all = PR_FALSE; PRBool first=PR_FALSE; @@ -188,8 +188,8 @@ nsresult TextEditorTest::TestTextProperties() // set all but the first and last character to bold printf("set the first text node (1, length-1) to bold and italic, and (2, length-1) to underline.\n"); - selection->Collapse(textNode, 1); - selection->Extend(textNode, length-1); + selection->Collapse(textNode, 1, SELECTION_NORMAL); + selection->Extend(textNode, length-1, SELECTION_NORMAL); result = mTextEditor->SetTextProperty(nsIEditProperty::b, nsnull, nsnull); TEST_RESULT(result); result = mTextEditor->GetTextProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all); @@ -224,8 +224,8 @@ nsresult TextEditorTest::TestTextProperties() TEST_POINTER(textNode.get()); textData = do_QueryInterface(textNode); textData->GetLength(&length); - selection->Collapse(textNode, 1); - selection->Extend(textNode, length-2); + selection->Collapse(textNode, 1, SELECTION_NORMAL); + selection->Extend(textNode, length-2, SELECTION_NORMAL); result = mTextEditor->SetTextProperty(nsIEditProperty::u, nsnull, nsnull); TEST_RESULT(result); diff --git a/mozilla/editor/libeditor/html/nsHTMLEditRules.cpp b/mozilla/editor/libeditor/html/nsHTMLEditRules.cpp index edb327382f0..dc9c8b67f7f 100644 --- a/mozilla/editor/libeditor/html/nsHTMLEditRules.cpp +++ b/mozilla/editor/libeditor/html/nsHTMLEditRules.cpp @@ -226,7 +226,7 @@ nsHTMLEditRules::WillInsertBreak(nsIDOMSelection *aSelection, PRBool *aCancel) // if the selection isn't collapsed, delete it. PRBool bCollapsed; - res = aSelection->GetIsCollapsed(&bCollapsed); + res = aSelection->GetIsCollapsed(SELECTION_NORMAL, &bCollapsed); if (NS_FAILED(res)) return res; if (!bCollapsed) { @@ -295,7 +295,7 @@ nsHTMLEditRules::WillDeleteSelection(nsIDOMSelection *aSelection, nsIEditor::ECo nsresult res = NS_OK; PRBool bCollapsed; - res = aSelection->GetIsCollapsed(&bCollapsed); + res = aSelection->GetIsCollapsed(SELECTION_NORMAL, &bCollapsed); if (NS_FAILED(res)) return res; nsCOMPtr node; @@ -1290,7 +1290,7 @@ nsHTMLEditRules::GetPromotedRanges(nsIDOMSelection *inSelection, if (NS_FAILED(res)) return res; PRInt32 rangeCount; - res = inSelection->GetRangeCount(&rangeCount); + res = inSelection->GetRangeCount(SELECTION_NORMAL, &rangeCount); if (NS_FAILED(res)) return res; PRInt32 i; @@ -1301,7 +1301,7 @@ nsHTMLEditRules::GetPromotedRanges(nsIDOMSelection *inSelection, for (i = 0; i < rangeCount; i++) { - res = inSelection->GetRangeAt(i, getter_AddRefs(selectionRange)); + res = inSelection->GetRangeAt(i, SELECTION_NORMAL, getter_AddRefs(selectionRange)); if (NS_FAILED(res)) return res; res = selectionRange->GetStartParent(getter_AddRefs(startNode)); if (NS_FAILED(res)) return res; @@ -1711,7 +1711,7 @@ nsHTMLEditRules::ReturnInHeader(nsIDOMSelection *aSelection, } // position selection before inserted node - res = aSelection->Collapse(textNode,0); + res = aSelection->Collapse(textNode,0, SELECTION_NORMAL); return res; } @@ -1823,7 +1823,7 @@ nsHTMLEditRules::ReturnInListItem(nsIDOMSelection *aSelection, nsresult res = mEditor->SplitNodeDeep( aListItem, aNode, aOffset); if (NS_FAILED(res)) return res; - res = aSelection->Collapse(aNode,0); + res = aSelection->Collapse(aNode,0, SELECTION_NORMAL); return res; } diff --git a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp index 69a09e28091..79918e62c8f 100644 --- a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp +++ b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp @@ -179,6 +179,11 @@ NS_IMETHODIMP nsHTMLEditor::SetBackgroundColor(const nsString& aColor) mJSEditorLog->SetBackgroundColor(aColor); #endif // ENABLE_JS_EDITOR_LOG + NS_ASSERTION(mDoc, "Missing Editor DOM Document"); + + // TODO: Check selection for Cell, Row, Column or table and do color on appropriate level + // For initial testing, just set the background on the BODY tag (the document's background) + return nsTextEditor::SetBackgroundColor(aColor); } @@ -268,12 +273,12 @@ NS_IMETHODIMP nsHTMLEditor::InsertBreak() nextNode->GetParentNode(getter_AddRefs(parent)); res = GetChildOffset(nextNode, parent, offsetInParent); if (NS_SUCCEEDED(res)) { - selection->Collapse(parent, offsetInParent+1); // +1 to insert just after the break + selection->Collapse(parent, offsetInParent+1, SELECTION_NORMAL); // +1 to insert just after the break } } else { - selection->Collapse(nextNode, offsetInParent); + selection->Collapse(nextNode, offsetInParent, SELECTION_NORMAL); } } } @@ -495,7 +500,7 @@ NS_IMETHODIMP nsHTMLEditor::PasteAsCitedQuotation(const nsString& aCitation) #endif } - res = selection->Collapse(newNode, 0); + res = selection->Collapse(newNode, 0, SELECTION_NORMAL); if (NS_FAILED(res)) { #ifdef DEBUG_akkana @@ -576,7 +581,7 @@ NS_IMETHODIMP nsHTMLEditor::InsertHTML(const nsString& aInputString) // Get the first range in the selection, for context: nsCOMPtr range; - res = selection->GetRangeAt(0, getter_AddRefs(range)); + res = selection->GetRangeAt(0, SELECTION_NORMAL, getter_AddRefs(range)); if (NS_FAILED(res)) return res; @@ -614,7 +619,7 @@ NS_IMETHODIMP nsHTMLEditor::InsertHTML(const nsString& aInputString) // set the selection back there after the insert. // Unfortunately this doesn't work right yet. nsCOMPtr saverange; - res = selection->GetRangeAt(0, getter_AddRefs(saverange)); + res = selection->GetRangeAt(0, SELECTION_NORMAL, getter_AddRefs(saverange)); // Insert the node: res = InsertNode(fragmentAsNode, parentNode, offsetOfNewNode); @@ -627,10 +632,10 @@ NS_IMETHODIMP nsHTMLEditor::InsertHTML(const nsString& aInputString) PRInt32 offset; if (NS_SUCCEEDED(saverange->GetEndParent(getter_AddRefs(parent)))) if (NS_SUCCEEDED(saverange->GetEndOffset(&offset))) - selection->Collapse(parent, offset); + selection->Collapse(parent, offset, SELECTION_NORMAL); } else - selection->Collapse(parentNode, 0/*offsetOfNewNode*/); + selection->Collapse(parentNode, 0/*offsetOfNewNode*/, SELECTION_NORMAL); #else /* INSERT_FRAGMENT_DIRECTLY */ // Loop over the contents of the fragment: nsCOMPtr child; @@ -659,6 +664,7 @@ NS_IMETHODIMP nsHTMLEditor::InsertHTML(const nsString& aInputString) return res; } + NS_IMETHODIMP nsHTMLEditor::OutputToString(nsString& aOutputString, const nsString& aFormatType, PRUint32 aFlags) @@ -706,8 +712,8 @@ nsHTMLEditor::GetParagraphStyle(nsStringArray *aTagList) if ((NS_SUCCEEDED(res)) && selection) { nsCOMPtr enumerator; - enumerator = do_QueryInterface(selection); - if (enumerator) + res = selection->GetEnumerator(SELECTION_NORMAL, getter_AddRefs(enumerator)); + if (NS_SUCCEEDED(res) && enumerator) { enumerator->First(); nsISupports *currentItem; @@ -837,8 +843,8 @@ nsHTMLEditor::ReplaceBlockParent(nsString& aParentTag) // set the block parent for all selected ranges nsAutoEditBatch beginBatching(this); nsCOMPtr enumerator; - enumerator = do_QueryInterface(selection); - if (enumerator) + res = selection->GetEnumerator(SELECTION_NORMAL, getter_AddRefs(enumerator)); + if (NS_SUCCEEDED(res) && enumerator) { enumerator->First(); nsISupports *currentItem; @@ -1228,8 +1234,8 @@ nsHTMLEditor::RemoveParagraphStyle() nsAutoSelectionReset selectionResetter(selection); nsAutoEditBatch beginBatching(this); nsCOMPtr enumerator; - enumerator = do_QueryInterface(selection); - if (enumerator) + res = selection->GetEnumerator(SELECTION_NORMAL, getter_AddRefs(enumerator)); + if (NS_SUCCEEDED(res) && enumerator) { enumerator->First(); nsISupports *currentItem; @@ -1348,8 +1354,8 @@ nsHTMLEditor::RemoveParent(const nsString &aParentTag) nsAutoSelectionReset selectionResetter(selection); nsAutoEditBatch beginBatching(this); nsCOMPtr enumerator; - enumerator = do_QueryInterface(selection); - if (enumerator) + res = selection->GetEnumerator(SELECTION_NORMAL, getter_AddRefs(enumerator)); + if (NS_SUCCEEDED(res) && enumerator) { enumerator->First(); nsISupports *currentItem; @@ -1483,7 +1489,7 @@ nsHTMLEditor::Indent(const nsString& aIndent) nsCOMPtr node; PRInt32 offset; PRBool isCollapsed; - res = selection->GetIsCollapsed(&isCollapsed); + res = selection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed); if (NS_FAILED(res)) return res; res = GetStartNodeAndOffset(selection, &node, &offset); @@ -1525,7 +1531,7 @@ nsHTMLEditor::Indent(const nsString& aIndent) res = CreateNode(bq, parent, offset, getter_AddRefs(newBQ)); if (NS_FAILED(res)) return res; // put a space in it so layout will draw the list item - res = selection->Collapse(newBQ,0); + res = selection->Collapse(newBQ,0, SELECTION_NORMAL); if (NS_FAILED(res)) return res; nsAutoString theText(" "); res = InsertText(theText); @@ -1533,7 +1539,7 @@ nsHTMLEditor::Indent(const nsString& aIndent) // reposition selection to before the space character res = GetStartNodeAndOffset(selection, &node, &offset); if (NS_FAILED(res)) return res; - res = selection->Collapse(node,0); + res = selection->Collapse(node,0, SELECTION_NORMAL); if (NS_FAILED(res)) return res; } } @@ -1599,7 +1605,7 @@ nsHTMLEditor::InsertList(const nsString& aListType) if (NS_FAILED(res) || !selection) return res; PRBool isCollapsed; - res = selection->GetIsCollapsed(&isCollapsed); + res = selection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed); if (NS_FAILED(res)) return res; nsCOMPtr node; @@ -1646,7 +1652,7 @@ nsHTMLEditor::InsertList(const nsString& aListType) if (NS_FAILED(res)) return res; // put a space in it so layout will draw the list item // XXX - revisit when layout is fixed - res = selection->Collapse(newItem,0); + res = selection->Collapse(newItem,0, SELECTION_NORMAL); if (NS_FAILED(res)) return res; nsAutoString theText(" "); res = InsertText(theText); @@ -1654,7 +1660,7 @@ nsHTMLEditor::InsertList(const nsString& aListType) // reposition selection to before the space character res = GetStartNodeAndOffset(selection, &node, &offset); if (NS_FAILED(res)) return res; - res = selection->Collapse(node,0); + res = selection->Collapse(node,0, SELECTION_NORMAL); if (NS_FAILED(res)) return res; } @@ -1684,7 +1690,7 @@ nsHTMLEditor::InsertLink(nsString& aURL) return res; } PRBool isCollapsed; - res = selection->GetIsCollapsed(&isCollapsed); + res = selection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed); if (NS_FAILED(res)) isCollapsed = PR_TRUE; @@ -1732,7 +1738,7 @@ nsHTMLEditor::InsertLink(nsString& aURL) #endif return res; } - res = selection->Collapse(newNode, 0); + res = selection->Collapse(newNode, 0, SELECTION_NORMAL); if (NS_FAILED(res)) { #ifdef DEBUG_akkana @@ -1852,7 +1858,7 @@ nsHTMLEditor::GetSelectedElement(const nsString& aTagName, nsIDOMElement** aRetu return res; PRBool isCollapsed; - selection->GetIsCollapsed(&isCollapsed); + selection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed); nsCOMPtr selectedElement; PRBool bNodeFound = PR_FALSE; @@ -1860,8 +1866,8 @@ nsHTMLEditor::GetSelectedElement(const nsString& aTagName, nsIDOMElement** aRetu if (!isCollapsed) { nsCOMPtr enumerator; - enumerator = do_QueryInterface(selection); - if (enumerator) + res = selection->GetEnumerator(SELECTION_NORMAL,getter_AddRefs(enumerator)); + if (NS_SUCCEEDED(res) && enumerator) { enumerator->First(); nsISupports *currentItem; @@ -2029,6 +2035,10 @@ nsHTMLEditor::CreateElementWithDefaults(const nsString& aTagName, nsIDOMElement* // Set default values for new elements if (TagName.Equals("hr")) + { + // TODO: Get the text of the selection and build a suggested Name + // Replace spaces with "_" + } else if (TagName.Equals("hr")) { // Hard coded defaults in case there's no prefs nsAutoString align("center"); @@ -2181,14 +2191,14 @@ nsHTMLEditor::InsertElement(nsIDOMElement* aElement, PRBool aDeleteSelection) if (collapseAfter) { // Default behavior is to collapse to the end of the selection - selection->ClearSelection(); + selection->ClearSelection(SELECTION_NORMAL); } else { // Collapse to the start of the selection, // We must explore the first range and find // its parent and starting offset of selection // TODO: Move this logic to a new method nsIDOMSelection::CollapseToStart()??? nsCOMPtr firstRange; - res = selection->GetRangeAt(0, getter_AddRefs(firstRange)); + res = selection->GetRangeAt(0, SELECTION_NORMAL, getter_AddRefs(firstRange)); if (NS_SUCCEEDED(res) && firstRange) { nsCOMPtr parent; @@ -2197,10 +2207,10 @@ nsHTMLEditor::InsertElement(nsIDOMElement* aElement, PRBool aDeleteSelection) { PRInt32 startOffset; firstRange->GetStartOffset(&startOffset); - selection->Collapse(parent, startOffset); + selection->Collapse(parent, startOffset, SELECTION_NORMAL); } else { // Very unlikely, but collapse to the end if we failed above - selection->ClearSelection(); + selection->ClearSelection(SELECTION_NORMAL); } } } @@ -2369,7 +2379,7 @@ nsHTMLEditor::InsertLinkAroundSelection(nsIDOMElement* aAnchorElement) goto DELETE_ANCHOR; PRBool isCollapsed; - res = selection->GetIsCollapsed(&isCollapsed); + res = selection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed); if (NS_FAILED(res)) isCollapsed = PR_TRUE; @@ -2461,9 +2471,9 @@ nsHTMLEditor::SelectElement(nsIDOMElement* aElement) if (NS_SUCCEEDED(res)) { // Collapse selection to just before desired element, - selection->Collapse(parent, offsetInParent); + selection->Collapse(parent, offsetInParent, SELECTION_NORMAL); // then extend it to just after - selection->Extend(parent, offsetInParent+1); + selection->Extend(parent, offsetInParent+1, SELECTION_NORMAL); } } } @@ -2533,7 +2543,7 @@ nsHTMLEditor::SetCaretInTableCell(nsIDOMElement* aElement, PRBool* caretIsSet) res = nsEditor::GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(res) && selection) { - res = selection->Collapse(parent, offset); + res = selection->Collapse(parent, offset, SELECTION_NORMAL); if (NS_SUCCEEDED(res) && caretIsSet) *caretIsSet = PR_TRUE; } @@ -2571,8 +2581,8 @@ nsHTMLEditor::SetCaretAfterElement(nsIDOMElement* aElement) offsetInParent++; if (NS_SUCCEEDED(res)) { - // Collapse selection to just after desired element, - selection->Collapse(parent, offsetInParent); + // Collapse selection to just after desired element, + selection->Collapse(parent, offsetInParent+1, SELECTION_NORMAL); } } } diff --git a/mozilla/editor/libeditor/text/nsEditorEventListeners.cpp b/mozilla/editor/libeditor/text/nsEditorEventListeners.cpp index 5c1eef4c120..1f60162d27d 100644 --- a/mozilla/editor/libeditor/text/nsEditorEventListeners.cpp +++ b/mozilla/editor/libeditor/text/nsEditorEventListeners.cpp @@ -865,7 +865,7 @@ nsTextEditorMouseListener::MouseDown(nsIDOMEvent* aMouseEvent) nsCOMPtr selection; if (NS_SUCCEEDED(editor->GetSelection(getter_AddRefs(selection)))) - (void)selection->Collapse(parent, offset); + (void)selection->Collapse(parent, offset, SELECTION_NORMAL); // If the ctrl key is pressed, we'll do paste as quotation. // Would've used the alt key, but the kde wmgr treats alt-middle specially. diff --git a/mozilla/editor/libeditor/text/nsTextEditRules.cpp b/mozilla/editor/libeditor/text/nsTextEditRules.cpp index 0a5cff344e7..c0d01d5195d 100644 --- a/mozilla/editor/libeditor/text/nsTextEditRules.cpp +++ b/mozilla/editor/libeditor/text/nsTextEditRules.cpp @@ -196,7 +196,7 @@ nsTextEditRules::WillInsert(nsIDOMSelection *aSelection, PRBool *aCancel) mEditor->DeleteNode(mBogusNode); mBogusNode = do_QueryInterface(nsnull); // there is no longer any legit selection, so clear it. - aSelection->ClearSelection(); + aSelection->ClearSelection(SELECTION_NORMAL); } return NS_OK; @@ -339,8 +339,8 @@ nsTextEditRules::CreateStyleForInsertText(nsIDOMSelection *aSelection, TypeInSta // Otherwise, create the text node and the new inline style parents. nsCOMPtranchor; PRInt32 offset; - nsresult result = aSelection->GetAnchorNode(getter_AddRefs(anchor)); - if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(&offset)) && anchor) + nsresult result = aSelection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(anchor)); + if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(SELECTION_NORMAL, &offset)) && anchor) { nsCOMPtranchorAsText; anchorAsText = do_QueryInterface(anchor); @@ -527,7 +527,7 @@ nsTextEditRules::InsertStyleNode(nsIDOMNode *aNode, result = mEditor->InsertNode(aNode, *aNewNode, 0); if (NS_SUCCEEDED(result)) { if (aSelection) { - aSelection->Collapse(aNode, 0); + aSelection->Collapse(aNode, 0, SELECTION_NORMAL); } } } @@ -548,8 +548,8 @@ nsTextEditRules::InsertStyleAndNewTextNode(nsIDOMNode *aParentNode, nsIAtom *aTa { nsCOMPtranchor; PRInt32 offset; - result = aSelection->GetAnchorNode(getter_AddRefs(anchor)); - if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(&offset)) && anchor) + result = aSelection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(anchor)); + if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(SELECTION_NORMAL, &offset)) && anchor) { nsCOMPtranchorAsText; anchorAsText = do_QueryInterface(anchor); @@ -573,7 +573,7 @@ nsTextEditRules::InsertStyleAndNewTextNode(nsIDOMNode *aParentNode, nsIAtom *aTa if (NS_SUCCEEDED(result)) { if (aSelection) { - aSelection->Collapse(newTextNode, 0); + aSelection->Collapse(newTextNode, 0, SELECTION_NORMAL); } } } @@ -668,7 +668,7 @@ nsTextEditRules::DidDeleteSelection(nsIDOMSelection *aSelection, nsresult result = aResult; // if aResult is an error, we just return it if (!aSelection) { return NS_ERROR_NULL_POINTER; } PRBool isCollapsed; - aSelection->GetIsCollapsed(&isCollapsed); + aSelection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed); NS_ASSERTION(PR_TRUE==isCollapsed, "selection not collapsed after delete selection."); // if the delete selection resulted in no content // insert a special bogus text node with a   character in it. @@ -680,8 +680,8 @@ nsTextEditRules::DidDeleteSelection(nsIDOMSelection *aSelection, { nsCOMPtranchor; PRInt32 offset; - result = aSelection->GetAnchorNode(getter_AddRefs(anchor)); - if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(&offset)) && anchor) + result = aSelection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(anchor)); + if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(SELECTION_NORMAL, &offset)) && anchor) { nsCOMPtr anchorChildren; result = anchor->GetChildNodes(getter_AddRefs(anchorChildren)); @@ -728,7 +728,7 @@ nsTextEditRules::DidDeleteSelection(nsIDOMSelection *aSelection, result = mEditor->JoinNodes(selectedNode, siblingNode, parentNode); // selectedNode will remain after the join, siblingNode is removed // set selection - aSelection->Collapse(siblingNode, selectedNodeLength); + aSelection->Collapse(siblingNode, selectedNodeLength, SELECTION_NORMAL); } } } @@ -768,8 +768,8 @@ nsTextEditRules:: DidUndo(nsIDOMSelection *aSelection, nsresult aResult) { nsCOMPtrnode; PRInt32 offset; - result = aSelection->GetAnchorNode(getter_AddRefs(node)); - if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(&offset)) && node) + result = aSelection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(node)); + if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(SELECTION_NORMAL, &offset)) && node) { nsCOMPtrelement; element = do_QueryInterface(node); @@ -815,8 +815,8 @@ nsTextEditRules::DidRedo(nsIDOMSelection *aSelection, nsresult aResult) { nsCOMPtrnode; PRInt32 offset; - result = aSelection->GetAnchorNode(getter_AddRefs(node)); - if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(&offset)) && node) + result = aSelection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(node)); + if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(SELECTION_NORMAL, &offset)) && node) { nsCOMPtrelement; element = do_QueryInterface(node); @@ -918,7 +918,7 @@ nsTextEditRules::CreateBogusNodeIfNeeded(nsIDOMSelection *aSelection) nsAutoString data; data += 160; newNodeAsText->SetData(data); - aSelection->Collapse(newTNode, 0); + aSelection->Collapse(newTNode, 0, SELECTION_NORMAL); } } // make sure we know the PNode is bogus @@ -967,7 +967,7 @@ nsTextEditRules::PinSelectionInPRE(nsIDOMSelection *aSelection) if (NS_FAILED(res)) return res; // there should only be one selection range in text docs - res = aSelection->GetRangeAt(0, getter_AddRefs(selectionRange)); + res = aSelection->GetRangeAt(0, SELECTION_NORMAL, getter_AddRefs(selectionRange)); if (NS_FAILED(res)) return res; res = selectionRange->Clone(getter_AddRefs(pinRange)); if (NS_FAILED(res)) return res; @@ -1021,9 +1021,9 @@ nsTextEditRules::PinSelectionInPRE(nsIDOMSelection *aSelection) if (NS_FAILED(res)) return res; res = pinRange->GetEndOffset(&endOffset); if (NS_FAILED(res)) return res; - res = aSelection->Collapse(startNode,startOffset); + res = aSelection->Collapse(startNode,startOffset, SELECTION_NORMAL); if (NS_FAILED(res)) return res; - res = aSelection->Extend(endNode,endOffset); + res = aSelection->Extend(endNode,endOffset, SELECTION_NORMAL); if (NS_FAILED(res)) return res; } diff --git a/mozilla/editor/libeditor/txtsvc/nsTextServicesDocument.cpp b/mozilla/editor/libeditor/txtsvc/nsTextServicesDocument.cpp index 36aa0f74e75..6e4a08767b9 100644 --- a/mozilla/editor/libeditor/txtsvc/nsTextServicesDocument.cpp +++ b/mozilla/editor/libeditor/txtsvc/nsTextServicesDocument.cpp @@ -576,7 +576,7 @@ nsTextServicesDocument::FirstSelectedBlock(TSDBlockSelectionStatus *aSelStatus, return result; } - result = selection->GetIsCollapsed(&isCollapsed); + result = selection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed); if (NS_FAILED(result)) { @@ -597,7 +597,7 @@ nsTextServicesDocument::FirstSelectedBlock(TSDBlockSelectionStatus *aSelStatus, // If the caret isn't in a text node, search backwards in // the document, till we find a text node. - result = selection->GetRangeAt(0, getter_AddRefs(range)); + result = selection->GetRangeAt(0, SELECTION_NORMAL, getter_AddRefs(range)); if (NS_FAILED(result)) { @@ -792,7 +792,7 @@ nsTextServicesDocument::FirstSelectedBlock(TSDBlockSelectionStatus *aSelStatus, // beginning of it's text block, and make it the current // block. - result = selection->GetRangeCount(&rangeCount); + result = selection->GetRangeCount(SELECTION_NORMAL, &rangeCount); if (NS_FAILED(result)) { @@ -815,7 +815,7 @@ nsTextServicesDocument::FirstSelectedBlock(TSDBlockSelectionStatus *aSelStatus, { // Get the i'th range from the selection. - result = selection->GetRangeAt(i, getter_AddRefs(range)); + result = selection->GetRangeAt(i, SELECTION_NORMAL, getter_AddRefs(range)); if (NS_FAILED(result)) { @@ -902,7 +902,7 @@ nsTextServicesDocument::FirstSelectedBlock(TSDBlockSelectionStatus *aSelStatus, // to the beginning of the document, then iterate backwards through // it till you find a text node! - result = selection->GetRangeAt(0, getter_AddRefs(range)); + result = selection->GetRangeAt(0, SELECTION_NORMAL, getter_AddRefs(range)); if (NS_FAILED(result)) { @@ -1058,7 +1058,7 @@ nsTextServicesDocument::LastSelectedBlock(TSDBlockSelectionStatus *aSelStatus, P return result; } - result = selection->GetIsCollapsed(&isCollapsed); + result = selection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed); if (NS_FAILED(result)) { @@ -1079,7 +1079,7 @@ nsTextServicesDocument::LastSelectedBlock(TSDBlockSelectionStatus *aSelStatus, P // If the caret isn't in a text node, search forwards in // the document, till we find a text node. - result = selection->GetRangeAt(0, getter_AddRefs(range)); + result = selection->GetRangeAt(0, SELECTION_NORMAL, getter_AddRefs(range)); if (NS_FAILED(result)) { @@ -1273,7 +1273,7 @@ nsTextServicesDocument::LastSelectedBlock(TSDBlockSelectionStatus *aSelStatus, P // beginning of it's text block, and make it the current // block. - result = selection->GetRangeCount(&rangeCount); + result = selection->GetRangeCount(SELECTION_NORMAL, &rangeCount); if (NS_FAILED(result)) { @@ -1296,7 +1296,7 @@ nsTextServicesDocument::LastSelectedBlock(TSDBlockSelectionStatus *aSelStatus, P { // Get the i'th range from the selection. - result = selection->GetRangeAt(i, getter_AddRefs(range)); + result = selection->GetRangeAt(i, SELECTION_NORMAL, getter_AddRefs(range)); if (NS_FAILED(result)) { @@ -1383,7 +1383,7 @@ nsTextServicesDocument::LastSelectedBlock(TSDBlockSelectionStatus *aSelStatus, P // to the end of the document, then iterate forwards through // it till you find a text node! - result = selection->GetRangeAt(rangeCount - 1, getter_AddRefs(range)); + result = selection->GetRangeAt(rangeCount - 1, SELECTION_NORMAL, getter_AddRefs(range)); if (NS_FAILED(result)) { @@ -2081,7 +2081,7 @@ nsTextServicesDocument::InsertText(const nsString *aText) return result; } - result = selection->Collapse(itEntry->mNode, itEntry->mNodeOffset + itEntry->mLength); + result = selection->Collapse(itEntry->mNode, itEntry->mNodeOffset + itEntry->mLength, SELECTION_NORMAL); if (NS_FAILED(result)) { @@ -2951,7 +2951,7 @@ nsTextServicesDocument::SetSelectionInternal(PRInt32 aOffset, PRInt32 aLength, P if (NS_FAILED(result)) return result; - result = selection->Collapse(sNode, sOffset); + result = selection->Collapse(sNode, sOffset, SELECTION_NORMAL); if (NS_FAILED(result)) return result; @@ -3008,7 +3008,7 @@ nsTextServicesDocument::SetSelectionInternal(PRInt32 aOffset, PRInt32 aLength, P if (aDoUpdate && eNode) { - result = selection->Extend(eNode, eOffset); + result = selection->Extend(eNode, eOffset, SELECTION_NORMAL); if (NS_FAILED(result)) return result; @@ -3050,7 +3050,7 @@ nsTextServicesDocument::GetSelection(nsITextServicesDocument::TSDBlockSelectionS if (!selection) return NS_ERROR_FAILURE; - result = selection->GetIsCollapsed(&isCollapsed); + result = selection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed); if (NS_FAILED(result)) return result; @@ -3119,7 +3119,7 @@ nsTextServicesDocument::GetCollapsedSelection(nsITextServicesDocument::TSDBlockS eStartOffset = eStart->mNodeOffset; eEndOffset = eEnd->mNodeOffset + eEnd->mLength; - result = selection->GetRangeAt(0, getter_AddRefs(range)); + result = selection->GetRangeAt(0, SELECTION_NORMAL, getter_AddRefs(range)); if (NS_FAILED(result)) return result; @@ -3436,7 +3436,7 @@ nsTextServicesDocument::GetUncollapsedSelection(nsITextServicesDocument::TSDBloc eStartOffset = eStart->mNodeOffset; eEndOffset = eEnd->mNodeOffset + eEnd->mLength; - result = selection->GetRangeCount(&rangeCount); + result = selection->GetRangeCount(SELECTION_NORMAL, &rangeCount); if (NS_FAILED(result)) return result; @@ -3446,7 +3446,7 @@ nsTextServicesDocument::GetUncollapsedSelection(nsITextServicesDocument::TSDBloc for (i = 0; i < rangeCount; i++) { - result = selection->GetRangeAt(i, getter_AddRefs(range)); + result = selection->GetRangeAt(i, SELECTION_NORMAL, getter_AddRefs(range)); if (NS_FAILED(result)) return result; diff --git a/mozilla/editor/txtsvc/src/nsTextServicesDocument.cpp b/mozilla/editor/txtsvc/src/nsTextServicesDocument.cpp index 36aa0f74e75..6e4a08767b9 100644 --- a/mozilla/editor/txtsvc/src/nsTextServicesDocument.cpp +++ b/mozilla/editor/txtsvc/src/nsTextServicesDocument.cpp @@ -576,7 +576,7 @@ nsTextServicesDocument::FirstSelectedBlock(TSDBlockSelectionStatus *aSelStatus, return result; } - result = selection->GetIsCollapsed(&isCollapsed); + result = selection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed); if (NS_FAILED(result)) { @@ -597,7 +597,7 @@ nsTextServicesDocument::FirstSelectedBlock(TSDBlockSelectionStatus *aSelStatus, // If the caret isn't in a text node, search backwards in // the document, till we find a text node. - result = selection->GetRangeAt(0, getter_AddRefs(range)); + result = selection->GetRangeAt(0, SELECTION_NORMAL, getter_AddRefs(range)); if (NS_FAILED(result)) { @@ -792,7 +792,7 @@ nsTextServicesDocument::FirstSelectedBlock(TSDBlockSelectionStatus *aSelStatus, // beginning of it's text block, and make it the current // block. - result = selection->GetRangeCount(&rangeCount); + result = selection->GetRangeCount(SELECTION_NORMAL, &rangeCount); if (NS_FAILED(result)) { @@ -815,7 +815,7 @@ nsTextServicesDocument::FirstSelectedBlock(TSDBlockSelectionStatus *aSelStatus, { // Get the i'th range from the selection. - result = selection->GetRangeAt(i, getter_AddRefs(range)); + result = selection->GetRangeAt(i, SELECTION_NORMAL, getter_AddRefs(range)); if (NS_FAILED(result)) { @@ -902,7 +902,7 @@ nsTextServicesDocument::FirstSelectedBlock(TSDBlockSelectionStatus *aSelStatus, // to the beginning of the document, then iterate backwards through // it till you find a text node! - result = selection->GetRangeAt(0, getter_AddRefs(range)); + result = selection->GetRangeAt(0, SELECTION_NORMAL, getter_AddRefs(range)); if (NS_FAILED(result)) { @@ -1058,7 +1058,7 @@ nsTextServicesDocument::LastSelectedBlock(TSDBlockSelectionStatus *aSelStatus, P return result; } - result = selection->GetIsCollapsed(&isCollapsed); + result = selection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed); if (NS_FAILED(result)) { @@ -1079,7 +1079,7 @@ nsTextServicesDocument::LastSelectedBlock(TSDBlockSelectionStatus *aSelStatus, P // If the caret isn't in a text node, search forwards in // the document, till we find a text node. - result = selection->GetRangeAt(0, getter_AddRefs(range)); + result = selection->GetRangeAt(0, SELECTION_NORMAL, getter_AddRefs(range)); if (NS_FAILED(result)) { @@ -1273,7 +1273,7 @@ nsTextServicesDocument::LastSelectedBlock(TSDBlockSelectionStatus *aSelStatus, P // beginning of it's text block, and make it the current // block. - result = selection->GetRangeCount(&rangeCount); + result = selection->GetRangeCount(SELECTION_NORMAL, &rangeCount); if (NS_FAILED(result)) { @@ -1296,7 +1296,7 @@ nsTextServicesDocument::LastSelectedBlock(TSDBlockSelectionStatus *aSelStatus, P { // Get the i'th range from the selection. - result = selection->GetRangeAt(i, getter_AddRefs(range)); + result = selection->GetRangeAt(i, SELECTION_NORMAL, getter_AddRefs(range)); if (NS_FAILED(result)) { @@ -1383,7 +1383,7 @@ nsTextServicesDocument::LastSelectedBlock(TSDBlockSelectionStatus *aSelStatus, P // to the end of the document, then iterate forwards through // it till you find a text node! - result = selection->GetRangeAt(rangeCount - 1, getter_AddRefs(range)); + result = selection->GetRangeAt(rangeCount - 1, SELECTION_NORMAL, getter_AddRefs(range)); if (NS_FAILED(result)) { @@ -2081,7 +2081,7 @@ nsTextServicesDocument::InsertText(const nsString *aText) return result; } - result = selection->Collapse(itEntry->mNode, itEntry->mNodeOffset + itEntry->mLength); + result = selection->Collapse(itEntry->mNode, itEntry->mNodeOffset + itEntry->mLength, SELECTION_NORMAL); if (NS_FAILED(result)) { @@ -2951,7 +2951,7 @@ nsTextServicesDocument::SetSelectionInternal(PRInt32 aOffset, PRInt32 aLength, P if (NS_FAILED(result)) return result; - result = selection->Collapse(sNode, sOffset); + result = selection->Collapse(sNode, sOffset, SELECTION_NORMAL); if (NS_FAILED(result)) return result; @@ -3008,7 +3008,7 @@ nsTextServicesDocument::SetSelectionInternal(PRInt32 aOffset, PRInt32 aLength, P if (aDoUpdate && eNode) { - result = selection->Extend(eNode, eOffset); + result = selection->Extend(eNode, eOffset, SELECTION_NORMAL); if (NS_FAILED(result)) return result; @@ -3050,7 +3050,7 @@ nsTextServicesDocument::GetSelection(nsITextServicesDocument::TSDBlockSelectionS if (!selection) return NS_ERROR_FAILURE; - result = selection->GetIsCollapsed(&isCollapsed); + result = selection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed); if (NS_FAILED(result)) return result; @@ -3119,7 +3119,7 @@ nsTextServicesDocument::GetCollapsedSelection(nsITextServicesDocument::TSDBlockS eStartOffset = eStart->mNodeOffset; eEndOffset = eEnd->mNodeOffset + eEnd->mLength; - result = selection->GetRangeAt(0, getter_AddRefs(range)); + result = selection->GetRangeAt(0, SELECTION_NORMAL, getter_AddRefs(range)); if (NS_FAILED(result)) return result; @@ -3436,7 +3436,7 @@ nsTextServicesDocument::GetUncollapsedSelection(nsITextServicesDocument::TSDBloc eStartOffset = eStart->mNodeOffset; eEndOffset = eEnd->mNodeOffset + eEnd->mLength; - result = selection->GetRangeCount(&rangeCount); + result = selection->GetRangeCount(SELECTION_NORMAL, &rangeCount); if (NS_FAILED(result)) return result; @@ -3446,7 +3446,7 @@ nsTextServicesDocument::GetUncollapsedSelection(nsITextServicesDocument::TSDBloc for (i = 0; i < rangeCount; i++) { - result = selection->GetRangeAt(i, getter_AddRefs(range)); + result = selection->GetRangeAt(i, SELECTION_NORMAL, getter_AddRefs(range)); if (NS_FAILED(result)) return result;