massive checkin for selection. adjusting nsIDOMSelection api and nsIFrameSelection. many "small" changes. this is not as bad as it looks. layout will not be affected other than "getter" calls for selection. and all consumers of selection should be in good shape.

This commit is contained in:
mjudge%netscape.com 1999-07-18 02:27:19 +00:00
Родитель b3be1b4389
Коммит c0b1525970
66 изменённых файлов: 1588 добавлений и 1463 удалений

Просмотреть файл

@ -99,7 +99,6 @@ static NS_DEFINE_IID(kIDocumentObserverIID, NS_IDOCUMENT_OBSERVER_IID);
static NS_DEFINE_IID(kICSSStyleSheetIID, NS_ICSS_STYLE_SHEET_IID);
static NS_DEFINE_IID(kCRangeCID, NS_RANGE_CID);
static NS_DEFINE_IID(kIDOMRange, NS_IDOMRANGE_IID);
static NS_DEFINE_IID(kCRangeListCID, NS_RANGELIST_CID);
static NS_DEFINE_IID(kIEnumeratorIID, NS_IENUMERATOR_IID);
static NS_DEFINE_IID(kIDOMScriptObjectFactoryIID, NS_IDOM_SCRIPT_OBJECT_FACTORY_IID);
static NS_DEFINE_IID(kDOMScriptObjectFactoryCID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID);

Просмотреть файл

@ -196,12 +196,9 @@ nsEventStateManager::PostHandleEvent(nsIPresContext& aPresContext,
nsCOMPtr<nsIPresShell> shell;
nsresult rv = aPresContext.GetShell(getter_AddRefs(shell));
if (NS_SUCCEEDED(rv) && shell){
nsCOMPtr<nsIDOMSelection> selection;
rv = shell->GetSelection(getter_AddRefs(selection));
if (NS_SUCCEEDED(rv) && selection){
nsCOMPtr<nsIFrameSelection> frameSel;
frameSel = do_QueryInterface(selection);
if (frameSel)
nsCOMPtr<nsIFrameSelection> frameSel;
rv = shell->GetFrameSelection(getter_AddRefs(frameSel));
if (NS_SUCCEEDED(rv) && frameSel){
frameSel->SetMouseDownState(PR_FALSE);
}
}

Просмотреть файл

@ -174,7 +174,7 @@ static NS_DEFINE_CID(kRDFContainerUtilsCID, NS_RDFCONTAINERUTILS_CID);
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
static NS_DEFINE_CID(kRDFXMLDataSourceCID, NS_RDFXMLDATASOURCE_CID);
static NS_DEFINE_CID(kRDFXULBuilderCID, NS_RDFXULBUILDER_CID);
static NS_DEFINE_CID(kRangeListCID, NS_RANGELIST_CID);
static NS_DEFINE_CID(kFrameSelectionCID, NS_FRAMESELECTION_CID);
static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID);
static NS_DEFINE_CID(kWellFormedDTDCID, NS_WELLFORMEDDTD_CID);
static NS_DEFINE_CID(kXULContentSinkCID, NS_XULCONTENTSINK_CID);
@ -836,12 +836,12 @@ XULDocumentImpl::XULDocumentImpl(void)
nsresult rv;
// construct a selection object
if (NS_FAILED(rv = nsComponentManager::CreateInstance(kRangeListCID,
/* if (NS_FAILED(rv = nsComponentManager::CreateInstance(kRangeListCID,
nsnull,
kIDOMSelectionIID,
(void**) &mSelection))) {
NS_ERROR("unable to create DOM selection");
}
}*/
if (gRefCnt++ == 0) {
kIdAtom = NS_NewAtom("id");

Просмотреть файл

@ -46,29 +46,29 @@ class nsIDOMSelection : public nsISupports {
public:
static const nsIID& GetIID() { static nsIID iid = NS_IDOMSELECTION_IID; return iid; }
NS_IMETHOD GetAnchorNode(SelectionType aType, nsIDOMNode** aAnchorNode)=0;
NS_IMETHOD GetAnchorNode(nsIDOMNode** aAnchorNode)=0;
NS_IMETHOD GetAnchorOffset(SelectionType aType, PRInt32* aAnchorOffset)=0;
NS_IMETHOD GetAnchorOffset(PRInt32* aAnchorOffset)=0;
NS_IMETHOD GetFocusNode(SelectionType aType, nsIDOMNode** aFocusNode)=0;
NS_IMETHOD GetFocusNode(nsIDOMNode** aFocusNode)=0;
NS_IMETHOD GetFocusOffset(SelectionType aType, PRInt32* aFocusOffset)=0;
NS_IMETHOD GetFocusOffset(PRInt32* aFocusOffset)=0;
NS_IMETHOD GetIsCollapsed(SelectionType aType, PRBool* aIsCollapsed)=0;
NS_IMETHOD GetIsCollapsed(PRBool* aIsCollapsed)=0;
NS_IMETHOD GetRangeCount(SelectionType aType, PRInt32* aRangeCount)=0;
NS_IMETHOD GetRangeCount(PRInt32* aRangeCount)=0;
NS_IMETHOD GetRangeAt(PRInt32 aIndex, SelectionType aType, nsIDOMRange** aReturn)=0;
NS_IMETHOD GetRangeAt(PRInt32 aIndex, nsIDOMRange** aReturn)=0;
NS_IMETHOD ClearSelection(SelectionType aType)=0;
NS_IMETHOD ClearSelection()=0;
NS_IMETHOD Collapse(nsIDOMNode* aParentNode, PRInt32 aOffset, SelectionType aType)=0;
NS_IMETHOD Collapse(nsIDOMNode* aParentNode, PRInt32 aOffset)=0;
NS_IMETHOD Extend(nsIDOMNode* aParentNode, PRInt32 aOffset, SelectionType aType)=0;
NS_IMETHOD Extend(nsIDOMNode* aParentNode, PRInt32 aOffset)=0;
NS_IMETHOD DeleteFromDocument()=0;
NS_IMETHOD AddRange(nsIDOMRange* aRange, SelectionType aType)=0;
NS_IMETHOD AddRange(nsIDOMRange* aRange)=0;
NS_IMETHOD StartBatchChanges()=0;
@ -78,19 +78,19 @@ public:
NS_IMETHOD RemoveSelectionListener(nsIDOMSelectionListener* aListenerToRemove)=0;
NS_IMETHOD GetEnumerator(SelectionType aType, nsIEnumerator **aIterator)=0;
NS_IMETHOD GetEnumerator(nsIEnumerator **aIterator)=0;
};
#define NS_DECL_IDOMSELECTION \
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 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(SelectionType aType); \
NS_IMETHOD Collapse(nsIDOMNode* aParentNode, PRInt32 aOffset, SelectionType aType); \
NS_IMETHOD Extend(nsIDOMNode* aParentNode, PRInt32 aOffset, SelectionType aType); \
@ -100,18 +100,18 @@ public:
NS_IMETHOD EndBatchChanges(); \
NS_IMETHOD AddSelectionListener(nsIDOMSelectionListener* aNewListener); \
NS_IMETHOD RemoveSelectionListener(nsIDOMSelectionListener* aListenerToRemove); \
NS_IMETHOD GetEnumerator(SelectionType aType, nsIEnumerator **aIterator); \
NS_IMETHOD GetEnumerator(nsIEnumerator **aIterator); \
#define NS_FORWARD_IDOMSELECTION(_to) \
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 GetAnchorNode(nsIDOMNode** aAnchorNode) { return _to GetAnchorNode(aType, aAnchorNode); } \
NS_IMETHOD GetAnchorOffset(PRInt32* aAnchorOffset) { return _to GetAnchorOffset(aType, aAnchorOffset, aType); } \
NS_IMETHOD GetFocusNode(nsIDOMNode** aFocusNode) { return _to GetFocusNode(aType, aFocusNode, aType); } \
NS_IMETHOD GetFocusOffset(PRInt32* aFocusOffset) { return _to GetFocusOffset(aType, aFocusOffset, aType); } \
NS_IMETHOD GetIsCollapsed(PRBool* aIsCollapsed) { return _to GetIsCollapsed(aType, aIsCollapsed, aType); } \
NS_IMETHOD GetRangeCount(PRInt32* aRangeCount) { return _to GetRangeCount(aType, aRangeCount, aType); } \
NS_IMETHOD GetRangeAt(PRInt32 aIndex, 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); } \
@ -121,7 +121,7 @@ public:
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); } \
NS_IMETHOD GetEnumerator(nsIEnumerator **aIterator){ return _to GetEnumerator(aType, aIterator); } \
extern "C" NS_DOM nsresult NS_InitSelectionClass(nsIScriptContext *aContext, void **aPrototype);

Просмотреть файл

@ -88,7 +88,7 @@ GetSelectionProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
return JS_FALSE;
}
nsIDOMNode* prop;
if (NS_OK == a->GetAnchorNode(SELECTION_NORMAL, &prop)) {
if (NS_OK == a->GetAnchorNode(&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(SELECTION_NORMAL, &prop)) {
if (NS_OK == a->GetAnchorOffset(&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(SELECTION_NORMAL, &prop)) {
if (NS_OK == a->GetFocusNode(&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(SELECTION_NORMAL, &prop)) {
if (NS_OK == a->GetFocusOffset(&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(SELECTION_NORMAL, &prop)) {
if (NS_OK == a->GetIsCollapsed(&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(SELECTION_NORMAL, &prop)) {
if (NS_OK == a->GetRangeCount(&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, SELECTION_NORMAL, &nativeRet)) {
if (NS_OK != nativeThis->GetRangeAt(b0, &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(SELECTION_NORMAL)) {
if (NS_OK != nativeThis->ClearSelection()) {
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, SELECTION_NORMAL)) {
if (NS_OK != nativeThis->Collapse(b0, b1)) {
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, SELECTION_NORMAL)) {
if (NS_OK != nativeThis->Extend(b0, b1)) {
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, SELECTION_NORMAL)) {
if (NS_OK != nativeThis->AddRange(b0)) {
return JS_FALSE;
}

Просмотреть файл

@ -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, SELECTION_NORMAL);
selectionResult = selection->Collapse(mParent, offset);
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, SELECTION_NORMAL);
selectionResult = selection->Collapse(mParent, offset);
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, SELECTION_NORMAL);
nsresult selectionResult = selection->Collapse(mParent, offset);
NS_ASSERTION((NS_SUCCEEDED(selectionResult)), "selection could not be collapsed after undo of insert.");
}
}

Просмотреть файл

@ -146,7 +146,7 @@ NS_IMETHODIMP DeleteRangeTxn::Do(void)
nsCOMPtr<nsIDOMSelection> selection;
result = mEditor->GetSelection(getter_AddRefs(selection));
if (NS_SUCCEEDED(result)) {
result = selection->Collapse(mStartParent, mStartOffset, SELECTION_NORMAL);
result = selection->Collapse(mStartParent, mStartOffset);
}
}
@ -166,8 +166,8 @@ NS_IMETHODIMP DeleteRangeTxn::Undo(void)
nsCOMPtr<nsIDOMSelection> selection;
result = mEditor->GetSelection(getter_AddRefs(selection));
if (NS_SUCCEEDED(result)) {
selection->Collapse(mStartParent, mStartOffset, SELECTION_NORMAL);
selection->Extend(mEndParent, mEndOffset, SELECTION_NORMAL);
selection->Collapse(mStartParent, mStartOffset);
selection->Extend(mEndParent, mEndOffset);
}
}
@ -187,7 +187,7 @@ NS_IMETHODIMP DeleteRangeTxn::Redo(void)
nsCOMPtr<nsIDOMSelection> selection;
result = mEditor->GetSelection(getter_AddRefs(selection));
if (NS_SUCCEEDED(result)) {
result = selection->Collapse(mStartParent, mStartOffset, SELECTION_NORMAL);
result = selection->Collapse(mStartParent, mStartOffset);
}
}

Просмотреть файл

@ -61,9 +61,9 @@ NS_IMETHODIMP DeleteTableCellTxn::Do(void)
nsresult res = NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMSelection> selection;
res = mPresShell->GetSelection(getter_AddRefs(selection));
res = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if (NS_SUCCEEDED(res)) {
res = selection->Collapse(mElement, 0 /*mOffset+1*/ /*+mStringToInsert.Length()*/, SELECTION_NORMAL);
res = selection->Collapse(mElement, 0 /*mOffset+1*/ /*+mStringToInsert.Length()*/);
}
return res;
}
@ -77,9 +77,9 @@ NS_IMETHODIMP DeleteTableCellTxn::Undo(void)
if (NS_SUCCEEDED(result))
{ // set the selection to the insertion point where the string was removed
nsCOMPtr<nsIDOMSelection> selection;
result = mPresShell->GetSelection(getter_AddRefs(selection));
result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if (NS_SUCCEEDED(result)) {
result = selection->Collapse(mElement, mOffset, SELECTION_NORMAL);
result = selection->Collapse(mElement, mOffset);
}
}
#endif

Просмотреть файл

@ -61,9 +61,9 @@ NS_IMETHODIMP DeleteTableColumnTxn::Do(void)
nsresult res = NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMSelection> selection;
res = mPresShell->GetSelection(getter_AddRefs(selection));
res = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if (NS_SUCCEEDED(res)) {
res = selection->Collapse(mElement, 0 /*mOffset+1*/ /*+mStringToInsert.Length()*/, SELECTION_NORMAL);
res = selection->Collapse(mElement, 0 /*mOffset+1*/ /*+mStringToInsert.Length()*/);
}
return res;
}
@ -77,9 +77,9 @@ NS_IMETHODIMP DeleteTableColumnTxn::Undo(void)
if (NS_SUCCEEDED(result))
{ // set the selection to the insertion point where the string was removed
nsCOMPtr<nsIDOMSelection> selection;
result = mPresShell->GetSelection(getter_AddRefs(selection));
result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if (NS_SUCCEEDED(result)) {
result = selection->Collapse(mElement, mOffset, SELECTION_NORMAL);
result = selection->Collapse(mElement, mOffset);
}
}
#endif

Просмотреть файл

@ -61,9 +61,9 @@ NS_IMETHODIMP DeleteTableRowTxn::Do(void)
nsresult res = NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMSelection> selection;
res = mPresShell->GetSelection(getter_AddRefs(selection));
res = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if (NS_SUCCEEDED(res)) {
res = selection->Collapse(mElement, 0 /*mOffset+1*/ /*+mStringToInsert.Length()*/, SELECTION_NORMAL);
res = selection->Collapse(mElement, 0 /*mOffset+1*/ /*+mStringToInsert.Length()*/);
}
return res;
}
@ -77,9 +77,9 @@ NS_IMETHODIMP DeleteTableRowTxn::Undo(void)
if (NS_SUCCEEDED(result))
{ // set the selection to the insertion point where the string was removed
nsCOMPtr<nsIDOMSelection> selection;
result = mPresShell->GetSelection(getter_AddRefs(selection));
result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if (NS_SUCCEEDED(result)) {
result = selection->Collapse(mElement, mOffset, SELECTION_NORMAL);
result = selection->Collapse(mElement, mOffset);
}
}
#endif

Просмотреть файл

@ -61,9 +61,9 @@ NS_IMETHODIMP DeleteTableTxn::Do(void)
nsresult res = NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMSelection> selection;
res = mPresShell->GetSelection(getter_AddRefs(selection));
res = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if (NS_SUCCEEDED(res)) {
res = selection->Collapse(mElement, 0 /*mOffset+1*/ /*+mStringToInsert.Length()*/, SELECTION_NORMAL);
res = selection->Collapse(mElement, 0 /*mOffset+1*/ /*+mStringToInsert.Length()*/);
}
return res;
}
@ -77,9 +77,9 @@ NS_IMETHODIMP DeleteTableTxn::Undo(void)
if (NS_SUCCEEDED(result))
{ // set the selection to the insertion point where the string was removed
nsCOMPtr<nsIDOMSelection> selection;
result = mPresShell->GetSelection(getter_AddRefs(selection));
result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if (NS_SUCCEEDED(result)) {
result = selection->Collapse(mElement, mOffset, SELECTION_NORMAL);
result = selection->Collapse(mElement, mOffset);
}
}
#endif

Просмотреть файл

@ -69,7 +69,7 @@ NS_IMETHODIMP DeleteTextTxn::Do(void)
nsCOMPtr<nsIDOMSelection> selection;
nsresult selectionResult = mEditor->GetSelection(getter_AddRefs(selection));
if (NS_SUCCEEDED(selectionResult) && selection) {
selectionResult = selection->Collapse(mElement, mOffset, SELECTION_NORMAL);
selectionResult = selection->Collapse(mElement, mOffset);
NS_ASSERTION((NS_SUCCEEDED(selectionResult)), "selection could not be collapsed after undo of insert.");
}
}
@ -91,7 +91,7 @@ NS_IMETHODIMP DeleteTextTxn::Undo(void)
nsCOMPtr<nsIDOMSelection> selection;
nsresult selectionResult = mEditor->GetSelection(getter_AddRefs(selection));
if (NS_SUCCEEDED(selectionResult) && selection) {
selectionResult = selection->Collapse(mElement, mOffset, SELECTION_NORMAL);
selectionResult = selection->Collapse(mElement, mOffset);
NS_ASSERTION((NS_SUCCEEDED(selectionResult)), "selection could not be collapsed after undo of insert.");
}
}

Просмотреть файл

@ -73,7 +73,7 @@ NS_IMETHODIMP IMETextTxn::Do(void)
// advance caret: This requires the presentation shell to get the selection.
nsCOMPtr<nsIDOMSelection> selection;
nsresult result = mPresShell->GetSelection(getter_AddRefs(selection));
nsresult result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
NS_ASSERTION(selection,"Could not get selection in IMEtextTxn::Do\n");
if (NS_SUCCEEDED(result) && selection) {
if (mReplaceLength==0) {
@ -101,9 +101,9 @@ NS_IMETHODIMP IMETextTxn::Undo(void)
if (NS_SUCCEEDED(result))
{ // set the selection to the insertion point where the string was removed
nsCOMPtr<nsIDOMSelection> selection;
result = mPresShell->GetSelection(getter_AddRefs(selection));
result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if (NS_SUCCEEDED(result) && selection) {
result = selection->Collapse(mElement, mOffset, SELECTION_NORMAL);
result = selection->Collapse(mElement, mOffset);
NS_ASSERTION((NS_SUCCEEDED(result)), "selection could not be collapsed after undo of IME insert.");
}
}
@ -277,16 +277,16 @@ NS_IMETHODIMP IMETextTxn::CollapseTextSelection(void)
}
nsCOMPtr<nsIDOMSelection> selection;
result = mPresShell->GetSelection(getter_AddRefs(selection));
result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if (NS_SUCCEEDED(result) && selection){
if (haveSelectedRange) {
result = selection->Collapse(mElement,mOffset+selectionStart, SELECTION_NORMAL);
result = selection->Extend(mElement,mOffset+selectionEnd, SELECTION_NORMAL);
result = selection->Collapse(mElement,mOffset+selectionStart);
result = selection->Extend(mElement,mOffset+selectionEnd);
} else {
if (haveCaretPosition)
result = selection->Collapse(mElement,mOffset+caretPosition, SELECTION_NORMAL);
result = selection->Collapse(mElement,mOffset+caretPosition);
else
result = selection->Collapse(mElement,mOffset+mStringToInsert.Length(), SELECTION_NORMAL);
result = selection->Collapse(mElement,mOffset+mStringToInsert.Length());
}
}
@ -296,9 +296,9 @@ NS_IMETHODIMP IMETextTxn::CollapseTextSelection(void)
NS_IMETHODIMP IMETextTxn::CollapseTextSelectionOnCommit(void)
{
nsCOMPtr<nsIDOMSelection> selection;
nsresult result = mPresShell->GetSelection(getter_AddRefs(selection));
nsresult result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if (NS_SUCCEEDED(result) && selection){
result = selection->Collapse(mElement,mOffset+mStringToInsert.Length(), SELECTION_NORMAL);
result = selection->Collapse(mElement,mOffset+mStringToInsert.Length());
}
return result;

Просмотреть файл

@ -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_NORMAL);
selection->Collapse(mParent, mOffset+1);
//selection->Extend(mParent, mOffset+1);
}
}

Просмотреть файл

@ -63,9 +63,9 @@ NS_IMETHODIMP InsertTableCellTxn::Do(void)
nsresult res = NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMSelection> selection;
res = mPresShell->GetSelection(getter_AddRefs(selection));
res = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if (NS_SUCCEEDED(res)) {
res = selection->Collapse(mElement, mOffset+1 /*+mStringToInsert.Length()*/, SELECTION_NORMAL);
res = selection->Collapse(mElement, mOffset+1 /*+mStringToInsert.Length()*/);
}
return res;
}
@ -79,9 +79,9 @@ NS_IMETHODIMP InsertTableCellTxn::Undo(void)
if (NS_SUCCEEDED(result))
{ // set the selection to the insertion point where the string was removed
nsCOMPtr<nsIDOMSelection> selection;
result = mPresShell->GetSelection(getter_AddRefs(selection));
result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if (NS_SUCCEEDED(result)) {
result = selection->Collapse(mElement, mOffset, SELECTION_NORMAL);
result = selection->Collapse(mElement, mOffset);
}
}
#endif

Просмотреть файл

@ -63,9 +63,9 @@ NS_IMETHODIMP InsertTableColumnTxn::Do(void)
nsresult res = NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMSelection> selection;
res = mPresShell->GetSelection(getter_AddRefs(selection));
res = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if (NS_SUCCEEDED(res)) {
res = selection->Collapse(mElement, mOffset+1 /*+mStringToInsert.Length()*/, SELECTION_NORMAL);
res = selection->Collapse(mElement, mOffset+1 /*+mStringToInsert.Length()*/);
}
return res;
}
@ -79,9 +79,9 @@ NS_IMETHODIMP InsertTableColumnTxn::Undo(void)
if (NS_SUCCEEDED(result))
{ // set the selection to the insertion point where the string was removed
nsCOMPtr<nsIDOMSelection> selection;
result = mPresShell->GetSelection(getter_AddRefs(selection));
result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if (NS_SUCCEEDED(result)) {
result = selection->Collapse(mElement, mOffset, SELECTION_NORMAL);
result = selection->Collapse(mElement, mOffset);
}
}
#endif

Просмотреть файл

@ -63,9 +63,9 @@ NS_IMETHODIMP InsertTableRowTxn::Do(void)
nsresult res = NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMSelection> selection;
res = mPresShell->GetSelection(getter_AddRefs(selection));
res = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if (NS_SUCCEEDED(res)) {
res = selection->Collapse(mElement, mOffset+1 /*+mStringToInsert.Length()*/, SELECTION_NORMAL);
res = selection->Collapse(mElement, mOffset+1 /*+mStringToInsert.Length()*/);
}
return res;
}
@ -79,9 +79,9 @@ NS_IMETHODIMP InsertTableRowTxn::Undo(void)
if (NS_SUCCEEDED(result))
{ // set the selection to the insertion point where the string was removed
nsCOMPtr<nsIDOMSelection> selection;
result = mPresShell->GetSelection(getter_AddRefs(selection));
result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if (NS_SUCCEEDED(result)) {
result = selection->Collapse(mElement, mOffset, SELECTION_NORMAL);
result = selection->Collapse(mElement, mOffset);
}
}
#endif

Просмотреть файл

@ -63,9 +63,9 @@ NS_IMETHODIMP InsertTableTxn::Do(void)
nsresult res = NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMSelection> selection;
res = mPresShell->GetSelection(getter_AddRefs(selection));
res = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if (NS_SUCCEEDED(res)) {
res = selection->Collapse(mElement, mOffset+1 /*+mStringToInsert.Length()*/, SELECTION_NORMAL);
res = selection->Collapse(mElement, mOffset+1 /*+mStringToInsert.Length()*/);
}
return res;
}
@ -79,9 +79,9 @@ NS_IMETHODIMP InsertTableTxn::Undo(void)
if (NS_SUCCEEDED(result))
{ // set the selection to the insertion point where the string was removed
nsCOMPtr<nsIDOMSelection> selection;
result = mPresShell->GetSelection(getter_AddRefs(selection));
result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if (NS_SUCCEEDED(result)) {
result = selection->Collapse(mElement, mOffset, SELECTION_NORMAL);
result = selection->Collapse(mElement, mOffset);
}
}
#endif

Просмотреть файл

@ -74,12 +74,12 @@ NS_IMETHODIMP InsertTextTxn::Do(void)
if (gNoisy) { printf("Do Insert Text element = %p\n", mElement.get()); }
// advance caret: This requires the presentation shell to get the selection.
nsCOMPtr<nsIDOMSelection> selection;
nsresult result = mPresShell->GetSelection(getter_AddRefs(selection));
nsresult result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
NS_ASSERTION(selection,"Could not get selection in InsertTextTxn::Do\n");
if (NS_SUCCEEDED(result) && selection) {
result = mElement->InsertData(mOffset, mStringToInsert);
if (NS_SUCCEEDED(result)) {
result = selection->Collapse(mElement, mOffset+mStringToInsert.Length(), SELECTION_NORMAL);
result = selection->Collapse(mElement, mOffset+mStringToInsert.Length());
NS_ASSERTION((NS_SUCCEEDED(result)), "selection could not be collapsed after insert.");
}
}
@ -95,9 +95,9 @@ NS_IMETHODIMP InsertTextTxn::Undo(void)
if (NS_SUCCEEDED(result))
{ // set the selection to the insertion point where the string was removed
nsCOMPtr<nsIDOMSelection> selection;
result = mPresShell->GetSelection(getter_AddRefs(selection));
result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if (NS_SUCCEEDED(result) && selection) {
result = selection->Collapse(mElement, mOffset, SELECTION_NORMAL);
result = selection->Collapse(mElement, mOffset);
NS_ASSERTION((NS_SUCCEEDED(result)), "selection could not be collapsed after undo of insert.");
}
}

Просмотреть файл

@ -89,7 +89,7 @@ NS_IMETHODIMP JoinElementTxn::Do(void)
mEditor->GetSelection(getter_AddRefs(selection));
if (selection)
{
selection->Collapse(mRightNode, mOffset, SELECTION_NORMAL);
selection->Collapse(mRightNode, mOffset);
}
}
}

Просмотреть файл

@ -61,9 +61,9 @@ NS_IMETHODIMP JoinTableCellsTxn::Do(void)
nsresult res = NS_ERROR_FAILURE;
nsCOMPtr<nsIDOMSelection> selection;
res = mPresShell->GetSelection(getter_AddRefs(selection));
res = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if (NS_SUCCEEDED(res)) {
res = selection->Collapse(mElement, 0 /*mOffset+1*/ /*+mStringToInsert.Length()*/, SELECTION_NORMAL);
res = selection->Collapse(mElement, 0 /*mOffset+1*/ /*+mStringToInsert.Length()*/);
}
return res;
}
@ -77,9 +77,9 @@ NS_IMETHODIMP JoinTableCellsTxn::Undo(void)
if (NS_SUCCEEDED(result))
{ // set the selection to the insertion point where the string was removed
nsCOMPtr<nsIDOMSelection> selection;
result = mPresShell->GetSelection(getter_AddRefs(selection));
result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if (NS_SUCCEEDED(result)) {
result = selection->Collapse(mElement, mOffset, SELECTION_NORMAL);
result = selection->Collapse(mElement, mOffset);
}
}
#endif

Просмотреть файл

@ -75,7 +75,7 @@ NS_IMETHODIMP SplitElementTxn::Do(void)
mEditor->GetSelection(getter_AddRefs(selection));
if (selection)
{
selection->Collapse(mNewLeftNode, mOffset, SELECTION_NORMAL);
selection->Collapse(mNewLeftNode, mOffset);
}
}
else {
@ -112,7 +112,7 @@ NS_IMETHODIMP SplitElementTxn::Undo(void)
mEditor->GetSelection(getter_AddRefs(selection));
if (selection)
{
selection->Collapse(mExistingRightNode, mOffset, SELECTION_NORMAL);
selection->Collapse(mExistingRightNode, mOffset);
}
}
else {

Просмотреть файл

@ -112,10 +112,10 @@ nsresult TextEditorTest::TestInsertBreak()
TEST_RESULT(result);
TEST_POINTER(selection.get());
nsCOMPtr<nsIDOMNode>anchor;
result = selection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(anchor));
result = selection->GetAnchorNode(getter_AddRefs(anchor));
TEST_RESULT(result);
TEST_POINTER(anchor.get());
selection->Collapse(anchor, 0, SELECTION_NORMAL);
selection->Collapse(anchor, 0);
// insert one break
printf("inserting a break\n");
result = mTextEditor->InsertBreak();
@ -160,8 +160,8 @@ nsresult TextEditorTest::TestTextProperties()
textData = do_QueryInterface(textNode);
PRUint32 length;
textData->GetLength(&length);
selection->Collapse(textNode, 0, SELECTION_NORMAL);
selection->Extend(textNode, length, SELECTION_NORMAL);
selection->Collapse(textNode, 0);
selection->Extend(textNode, length);
PRBool any = PR_FALSE;
PRBool all = PR_FALSE;
PRBool first=PR_FALSE;
@ -192,8 +192,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_NORMAL);
selection->Extend(textNode, length-1, SELECTION_NORMAL);
selection->Collapse(textNode, 1);
selection->Extend(textNode, length-1);
result = mTextEditor->SetTextProperty(nsIEditProperty::b, nsnull, nsnull);
TEST_RESULT(result);
result = mTextEditor->GetTextProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all);
@ -229,8 +229,8 @@ nsresult TextEditorTest::TestTextProperties()
textData = do_QueryInterface(textNode);
textData->GetLength(&length);
NS_ASSERTION(length==249, "wrong text node");
selection->Collapse(textNode, 1, SELECTION_NORMAL);
selection->Extend(textNode, length-2, SELECTION_NORMAL);
selection->Collapse(textNode, 1);
selection->Extend(textNode, length-2);
result = mTextEditor->SetTextProperty(nsIEditProperty::u, nsnull, nsnull);
TEST_RESULT(result);
result = mTextEditor->GetTextProperty(nsIEditProperty::u, nsnull, nsnull, first, any, all);

Просмотреть файл

@ -482,7 +482,7 @@ nsEditor::GetSelection(nsIDOMSelection **aSelection)
if (!aSelection)
return NS_ERROR_NULL_POINTER;
*aSelection = nsnull;
nsresult result = mPresShell->GetSelection(aSelection); // does an addref
nsresult result = mPresShell->GetSelection(SELECTION_NORMAL, aSelection); // does an addref
return result;
}
@ -523,7 +523,7 @@ nsEditor::Init(nsIDOMDocument *aDoc, nsIPresShell* aPresShell)
/* Show the caret */
nsCOMPtr<nsICaret> caret;
if (NS_SUCCEEDED(mPresShell->GetCaret(getter_AddRefs(caret))))
if (NS_SUCCEEDED(mPresShell->GetCaret(getter_AddRefs(caret))) && caret)
{
caret->SetCaretVisible(PR_TRUE);
caret->SetCaretReadOnly(PR_FALSE);
@ -1040,7 +1040,7 @@ NS_IMETHODIMP nsEditor::SelectAll()
if (!mDoc || !mPresShell) { return NS_ERROR_NOT_INITIALIZED; }
nsCOMPtr<nsIDOMSelection> selection;
nsresult result = mPresShell->GetSelection(getter_AddRefs(selection));
nsresult result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if (NS_SUCCEEDED(result) && selection)
{
result = SelectEntireDocument(selection);
@ -1059,7 +1059,7 @@ NS_IMETHODIMP nsEditor::SelectEntireDocument(nsIDOMSelection *aSelection)
nsCOMPtr<nsIDOMNode>bodyNode = do_QueryInterface(bodyElement);
if (bodyNode)
{
result = aSelection->Collapse(bodyNode, 0, SELECTION_NORMAL);
result = aSelection->Collapse(bodyNode, 0);
if (NS_SUCCEEDED(result))
{
PRInt32 numBodyChildren=0;
@ -1068,7 +1068,7 @@ NS_IMETHODIMP nsEditor::SelectEntireDocument(nsIDOMSelection *aSelection)
if ((NS_SUCCEEDED(result)) && lastChild)
{
GetChildOffset(lastChild, bodyNode, numBodyChildren);
result = aSelection->Extend(bodyNode, numBodyChildren+1, SELECTION_NORMAL);
result = aSelection->Extend(bodyNode, numBodyChildren+1);
}
}
}
@ -1121,7 +1121,7 @@ NS_IMETHODIMP nsEditor::BeginningOfDocument()
if (!mDoc || !mPresShell) { return NS_ERROR_NOT_INITIALIZED; }
nsCOMPtr<nsIDOMSelection> selection;
nsresult result = mPresShell->GetSelection(getter_AddRefs(selection));
nsresult result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if (NS_SUCCEEDED(result) && selection)
{
nsCOMPtr<nsIDOMNodeList> nodeList;
@ -1140,7 +1140,7 @@ NS_IMETHODIMP nsEditor::BeginningOfDocument()
nsCOMPtr<nsIDOMNode> firstNode = GetDeepFirstChild(bodyNode);
if (firstNode)
{
result = selection->Collapse(firstNode, 0, SELECTION_NORMAL);
result = selection->Collapse(firstNode, 0);
ScrollIntoView(PR_TRUE);
}
}
@ -1199,7 +1199,7 @@ NS_IMETHODIMP nsEditor::EndOfDocument()
if (!mDoc || !mPresShell) { return NS_ERROR_NOT_INITIALIZED; }
nsCOMPtr<nsIDOMSelection> selection;
nsresult result = mPresShell->GetSelection(getter_AddRefs(selection));
nsresult result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if (NS_SUCCEEDED(result) && selection)
{
nsCOMPtr<nsIDOMNodeList> nodeList;
@ -1225,7 +1225,7 @@ NS_IMETHODIMP nsEditor::EndOfDocument()
if (text)
text->GetLength(&offset);
}
result = selection->Collapse(lastChild, offset, SELECTION_NORMAL);
result = selection->Collapse(lastChild, offset);
ScrollIntoView(PR_FALSE);
}
}
@ -1244,12 +1244,12 @@ NS_IMETHODIMP nsEditor::Cut()
#endif // ENABLE_JS_EDITOR_LOG
nsCOMPtr<nsIDOMSelection> selection;
nsresult res = mPresShell->GetSelection(getter_AddRefs(selection));
nsresult res = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if (!NS_SUCCEEDED(res))
return res;
PRBool isCollapsed;
if (NS_SUCCEEDED(selection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed)) && isCollapsed)
if (NS_SUCCEEDED(selection->GetIsCollapsed(&isCollapsed)) && isCollapsed)
return NS_ERROR_NOT_AVAILABLE;
res = Copy();
@ -1744,11 +1744,11 @@ NS_IMETHODIMP nsEditor::CreateAggregateTxnForDeleteSelection(nsIAtom *aTxnName,
// Get current selection and setup txn to delete it,
// but only if selection exists (is not a collapsed "caret" state)
nsCOMPtr<nsIDOMSelection> selection;
result = mPresShell->GetSelection(getter_AddRefs(selection));
result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if (NS_SUCCEEDED(result) && selection)
{
PRBool collapsed;
result = selection->GetIsCollapsed(SELECTION_NORMAL, &collapsed);
result = selection->GetIsCollapsed(&collapsed);
if (NS_SUCCEEDED(result) && !collapsed) {
EditAggregateTxn *delSelTxn;
result = CreateTxnForDeleteSelection(nsIEditor::eDoNothing,
@ -1803,8 +1803,8 @@ nsEditor::InsertText(const nsString& aStringToInsert)
{
nsCOMPtr<nsIDOMNode> selectedNode;
PRInt32 offset;
result = selection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(selectedNode));
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(selection->GetAnchorOffset(SELECTION_NORMAL, &offset)) && selectedNode)
result = selection->GetAnchorNode(getter_AddRefs(selectedNode));
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(selection->GetAnchorOffset(&offset)) && selectedNode)
{
nsCOMPtr<nsIDOMNode> newNode;
result = CreateNode(GetTextNodeTag(), selectedNode, offset,
@ -1817,8 +1817,8 @@ nsEditor::InsertText(const nsString& aStringToInsert)
{
nsAutoString placeholderText(" ");
newTextNode->SetData(placeholderText);
selection->Collapse(newNode, 0, SELECTION_NORMAL);
selection->Extend(newNode, 1, SELECTION_NORMAL);
selection->Collapse(newNode, 0);
selection->Extend(newNode, 1);
result = InsertText(aStringToInsert);
}
}
@ -1846,7 +1846,7 @@ NS_IMETHODIMP nsEditor::CreateTxnForInsertText(const nsString & aStringToInsert,
else
{
nsCOMPtr<nsIDOMSelection> selection;
result = mPresShell->GetSelection(getter_AddRefs(selection));
result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if ((NS_SUCCEEDED(result)) && selection)
{
#if 0
@ -1868,7 +1868,7 @@ NS_IMETHODIMP nsEditor::CreateTxnForInsertText(const nsString & aStringToInsert,
#endif
result = NS_ERROR_UNEXPECTED;
nsCOMPtr<nsIEnumerator> enumerator;
result = selection->GetEnumerator(SELECTION_NORMAL,getter_AddRefs(enumerator));
result = selection->GetEnumerator(getter_AddRefs(enumerator));
if (NS_SUCCEEDED(result) && enumerator)
{
enumerator->First();
@ -2030,7 +2030,7 @@ NS_IMETHODIMP nsEditor::DeleteSelectionAndCreateNode(const nsString& aTag,
nsCOMPtr<nsIDOMSelection> selection;
result = GetSelection(getter_AddRefs(selection));
if ((NS_SUCCEEDED(result)) && selection)
selection->Collapse(parentSelectedNode, offsetOfNewNode+1, SELECTION_NORMAL);
selection->Collapse(parentSelectedNode, offsetOfNewNode+1);
return result;
}
@ -2043,7 +2043,7 @@ NS_IMETHODIMP nsEditor::DeleteSelectionAndPrepareToCreateNode(nsCOMPtr<nsIDOMNod
if ((NS_SUCCEEDED(result)) && selection)
{
PRBool collapsed;
result = selection->GetIsCollapsed(SELECTION_NORMAL, &collapsed);
result = selection->GetIsCollapsed(&collapsed);
if (NS_SUCCEEDED(result) && !collapsed)
{
result = DeleteSelection(nsIEditor::eDoNothing);
@ -2057,13 +2057,13 @@ NS_IMETHODIMP nsEditor::DeleteSelectionAndPrepareToCreateNode(nsCOMPtr<nsIDOMNod
}
#ifdef NS_DEBUG
nsCOMPtr<nsIDOMNode>testSelectedNode;
nsresult debugResult = selection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(testSelectedNode));
nsresult debugResult = selection->GetAnchorNode(getter_AddRefs(testSelectedNode));
// no selection is ok.
// if there is a selection, it must be collapsed
if (testSelectedNode)
{
PRBool testCollapsed;
debugResult = selection->GetIsCollapsed(SELECTION_NORMAL, &testCollapsed);
debugResult = selection->GetIsCollapsed(&testCollapsed);
NS_ASSERTION((NS_SUCCEEDED(result)), "couldn't get a selection after deletion");
NS_ASSERTION(PR_TRUE==testCollapsed, "selection not reset after deletion");
}
@ -2071,8 +2071,8 @@ NS_IMETHODIMP nsEditor::DeleteSelectionAndPrepareToCreateNode(nsCOMPtr<nsIDOMNod
}
// split the selected node
PRInt32 offsetOfSelectedNode;
result = selection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(parentSelectedNode));
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(selection->GetAnchorOffset(SELECTION_NORMAL, &offsetOfSelectedNode)) && parentSelectedNode)
result = selection->GetAnchorNode(getter_AddRefs(parentSelectedNode));
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(selection->GetAnchorOffset(&offsetOfSelectedNode)) && parentSelectedNode)
{
nsCOMPtr<nsIDOMNode> selectedNode;
PRUint32 selectedNodeContentCount=0;
@ -2224,12 +2224,12 @@ NS_IMETHODIMP nsEditor::CreateTxnForDeleteSelection(nsIEditor::ECollapsedSelecti
nsresult result;
nsCOMPtr<nsIDOMSelection> selection;
result = mPresShell->GetSelection(getter_AddRefs(selection));
result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if ((NS_SUCCEEDED(result)) && selection)
{
// Check whether the selection is collapsed and we should do nothing:
PRBool isCollapsed;
result = (selection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed));
result = (selection->GetIsCollapsed(&isCollapsed));
if (NS_SUCCEEDED(result) && isCollapsed && aAction == eDoNothing)
return NS_OK;
@ -2240,7 +2240,7 @@ NS_IMETHODIMP nsEditor::CreateTxnForDeleteSelection(nsIEditor::ECollapsedSelecti
}
nsCOMPtr<nsIEnumerator> enumerator;
result = selection->GetEnumerator(SELECTION_NORMAL, getter_AddRefs(enumerator));
result = selection->GetEnumerator(getter_AddRefs(enumerator));
if (NS_SUCCEEDED(result) && enumerator)
{
for (enumerator->First(); NS_OK!=enumerator->IsDone(); enumerator->Next())
@ -3491,12 +3491,12 @@ nsEditor::BeginComposition(void)
nsCOMPtr<nsIDOMSelection> selection;
nsCOMPtr<nsIDOMCharacterData> nodeAsText;
result = mPresShell->GetSelection(getter_AddRefs(selection));
result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if ((NS_SUCCEEDED(result)) && selection)
{
result = NS_ERROR_UNEXPECTED;
nsCOMPtr<nsIEnumerator> enumerator;
result = selection->GetEnumerator(SELECTION_NORMAL, getter_AddRefs(enumerator));
result = selection->GetEnumerator(getter_AddRefs(enumerator));
if (NS_SUCCEEDED(result) && enumerator)
{
enumerator->First();
@ -3770,8 +3770,8 @@ nsEditor::SetInputMethodText(const nsString& aStringToInsert,nsIDOMTextRangeList
{
nsCOMPtr<nsIDOMNode> selectedNode;
PRInt32 offset;
result = selection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(selectedNode));
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(selection->GetAnchorOffset(SELECTION_NORMAL, &offset)) && selectedNode)
result = selection->GetAnchorNode(getter_AddRefs(selectedNode));
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(selection->GetAnchorOffset(&offset)) && selectedNode)
{
nsCOMPtr<nsIDOMNode> newNode;
result = CreateNode(GetTextNodeTag(), selectedNode, offset+1,getter_AddRefs(newNode));
@ -3783,8 +3783,8 @@ nsEditor::SetInputMethodText(const nsString& aStringToInsert,nsIDOMTextRangeList
{
nsAutoString placeholderText(" ");
newTextNode->SetData(placeholderText);
selection->Collapse(newNode, 0, SELECTION_NORMAL);
selection->Extend(newNode, 1, SELECTION_NORMAL);
selection->Collapse(newNode, 0);
selection->Extend(newNode, 1);
result = SetInputMethodText(aStringToInsert,aTextRangeList);
}
}
@ -4196,7 +4196,7 @@ nsEditor::GetStartNodeAndOffset(nsIDOMSelection *aSelection,
nsCOMPtr<nsIEnumerator> enumerator;
nsresult result;
result = aSelection->GetEnumerator(SELECTION_NORMAL, getter_AddRefs(enumerator));
result = aSelection->GetEnumerator(getter_AddRefs(enumerator));
if (NS_FAILED(result) || !enumerator)
return NS_ERROR_FAILURE;
@ -4231,7 +4231,7 @@ nsEditor::GetEndNodeAndOffset(nsIDOMSelection *aSelection,
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIEnumerator> enumerator;
nsresult result = aSelection->GetEnumerator(SELECTION_NORMAL, getter_AddRefs(enumerator));
nsresult result = aSelection->GetEnumerator(getter_AddRefs(enumerator));
if (NS_FAILED(result) || !enumerator)
return NS_ERROR_FAILURE;
@ -4575,10 +4575,10 @@ nsAutoSelectionReset::nsAutoSelectionReset(nsIDOMSelection *aSel)
mSel = do_QueryInterface(aSel);
if (mSel)
{
mSel->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(mStartNode));
mSel->GetAnchorOffset(SELECTION_NORMAL, &mStartOffset);
mSel->GetFocusNode(SELECTION_NORMAL, getter_AddRefs(mEndNode));
mSel->GetFocusOffset(SELECTION_NORMAL, &mEndOffset);
mSel->GetAnchorNode(getter_AddRefs(mStartNode));
mSel->GetAnchorOffset(&mStartOffset);
mSel->GetFocusNode(getter_AddRefs(mEndNode));
mSel->GetFocusOffset(&mEndOffset);
if (mStartNode && mEndNode)
mInitialized = PR_TRUE;
}
@ -4589,8 +4589,8 @@ nsAutoSelectionReset::~nsAutoSelectionReset()
if (mSel && mInitialized)
{
// restore original selection
mSel->Collapse(mStartNode, mStartOffset, SELECTION_NORMAL);
mSel->Extend(mEndNode, mEndOffset, SELECTION_NORMAL);
mSel->Collapse(mStartNode, mStartOffset);
mSel->Extend(mEndNode, mEndOffset);
}
}

Просмотреть файл

@ -865,7 +865,7 @@ nsTextEditorMouseListener::MouseDown(nsIDOMEvent* aMouseEvent)
nsCOMPtr<nsIDOMSelection> selection;
if (NS_SUCCEEDED(editor->GetSelection(getter_AddRefs(selection))))
(void)selection->Collapse(parent, offset, SELECTION_NORMAL);
(void)selection->Collapse(parent, offset);
// 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.

Просмотреть файл

@ -224,7 +224,7 @@ nsHTMLEditRules::WillInsertBreak(nsIDOMSelection *aSelection, PRBool *aCancel)
// if the selection isn't collapsed, delete it.
PRBool bCollapsed;
res = aSelection->GetIsCollapsed(SELECTION_NORMAL, &bCollapsed);
res = aSelection->GetIsCollapsed(&bCollapsed);
if (NS_FAILED(res)) return res;
if (!bCollapsed)
{
@ -293,7 +293,7 @@ nsHTMLEditRules::WillDeleteSelection(nsIDOMSelection *aSelection, nsIEditor::ECo
nsresult res = NS_OK;
PRBool bCollapsed;
res = aSelection->GetIsCollapsed(SELECTION_NORMAL, &bCollapsed);
res = aSelection->GetIsCollapsed(&bCollapsed);
if (NS_FAILED(res)) return res;
nsCOMPtr<nsIDOMNode> node;
@ -1292,7 +1292,7 @@ nsHTMLEditRules::GetPromotedRanges(nsIDOMSelection *inSelection,
if (NS_FAILED(res)) return res;
PRInt32 rangeCount;
res = inSelection->GetRangeCount(SELECTION_NORMAL, &rangeCount);
res = inSelection->GetRangeCount(&rangeCount);
if (NS_FAILED(res)) return res;
PRInt32 i;
@ -1303,7 +1303,7 @@ nsHTMLEditRules::GetPromotedRanges(nsIDOMSelection *inSelection,
for (i = 0; i < rangeCount; i++)
{
res = inSelection->GetRangeAt(i, SELECTION_NORMAL, getter_AddRefs(selectionRange));
res = inSelection->GetRangeAt(i, getter_AddRefs(selectionRange));
if (NS_FAILED(res)) return res;
res = selectionRange->GetStartParent(getter_AddRefs(startNode));
if (NS_FAILED(res)) return res;
@ -1713,7 +1713,7 @@ nsHTMLEditRules::ReturnInHeader(nsIDOMSelection *aSelection,
}
// position selection before inserted node
res = aSelection->Collapse(textNode,0, SELECTION_NORMAL);
res = aSelection->Collapse(textNode,0);
return res;
}
@ -1825,7 +1825,7 @@ nsHTMLEditRules::ReturnInListItem(nsIDOMSelection *aSelection,
nsresult res = mEditor->SplitNodeDeep( aListItem, aNode, aOffset);
if (NS_FAILED(res)) return res;
res = aSelection->Collapse(aNode,0, SELECTION_NORMAL);
res = aSelection->Collapse(aNode,0);
return res;
}

Просмотреть файл

@ -272,12 +272,12 @@ NS_IMETHODIMP nsHTMLEditor::InsertBreak()
nextNode->GetParentNode(getter_AddRefs(parent));
res = GetChildOffset(nextNode, parent, offsetInParent);
if (NS_SUCCEEDED(res)) {
selection->Collapse(parent, offsetInParent+1, SELECTION_NORMAL); // +1 to insert just after the break
selection->Collapse(parent, offsetInParent+1); // +1 to insert just after the break
}
}
else
{
selection->Collapse(nextNode, offsetInParent, SELECTION_NORMAL);
selection->Collapse(nextNode, offsetInParent);
}
}
}
@ -499,7 +499,7 @@ NS_IMETHODIMP nsHTMLEditor::PasteAsCitedQuotation(const nsString& aCitation)
#endif
}
res = selection->Collapse(newNode, 0, SELECTION_NORMAL);
res = selection->Collapse(newNode, 0);
if (NS_FAILED(res))
{
#ifdef DEBUG_akkana
@ -580,7 +580,7 @@ NS_IMETHODIMP nsHTMLEditor::InsertHTML(const nsString& aInputString)
// Get the first range in the selection, for context:
nsCOMPtr<nsIDOMRange> range;
res = selection->GetRangeAt(0, SELECTION_NORMAL, getter_AddRefs(range));
res = selection->GetRangeAt(0, getter_AddRefs(range));
if (NS_FAILED(res))
return res;
@ -618,7 +618,7 @@ NS_IMETHODIMP nsHTMLEditor::InsertHTML(const nsString& aInputString)
// set the selection back there after the insert.
// Unfortunately this doesn't work right yet.
nsCOMPtr<nsIDOMRange> saverange;
res = selection->GetRangeAt(0, SELECTION_NORMAL, getter_AddRefs(saverange));
res = selection->GetRangeAt(0, getter_AddRefs(saverange));
// Insert the node:
res = InsertNode(fragmentAsNode, parentNode, offsetOfNewNode);
@ -631,10 +631,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_NORMAL);
selection->Collapse(parent, offset);
}
else
selection->Collapse(parentNode, 0/*offsetOfNewNode*/, SELECTION_NORMAL);
selection->Collapse(parentNode, 0/*offsetOfNewNode*/);
#else /* INSERT_FRAGMENT_DIRECTLY */
// Loop over the contents of the fragment:
nsCOMPtr<nsIDOMNode> child;
@ -711,7 +711,7 @@ nsHTMLEditor::GetParagraphStyle(nsStringArray *aTagList)
if ((NS_SUCCEEDED(res)) && selection)
{
nsCOMPtr<nsIEnumerator> enumerator;
res = selection->GetEnumerator(SELECTION_NORMAL, getter_AddRefs(enumerator));
res = selection->GetEnumerator(getter_AddRefs(enumerator));
if (NS_SUCCEEDED(res) && enumerator)
{
enumerator->First();
@ -842,7 +842,7 @@ nsHTMLEditor::ReplaceBlockParent(nsString& aParentTag)
// set the block parent for all selected ranges
nsAutoEditBatch beginBatching(this);
nsCOMPtr<nsIEnumerator> enumerator;
res = selection->GetEnumerator(SELECTION_NORMAL, getter_AddRefs(enumerator));
res = selection->GetEnumerator(getter_AddRefs(enumerator));
if (NS_SUCCEEDED(res) && enumerator)
{
enumerator->First();
@ -1233,7 +1233,7 @@ nsHTMLEditor::RemoveParagraphStyle()
nsAutoSelectionReset selectionResetter(selection);
nsAutoEditBatch beginBatching(this);
nsCOMPtr<nsIEnumerator> enumerator;
res = selection->GetEnumerator(SELECTION_NORMAL, getter_AddRefs(enumerator));
res = selection->GetEnumerator(getter_AddRefs(enumerator));
if (NS_SUCCEEDED(res) && enumerator)
{
enumerator->First();
@ -1353,7 +1353,7 @@ nsHTMLEditor::RemoveParent(const nsString &aParentTag)
nsAutoSelectionReset selectionResetter(selection);
nsAutoEditBatch beginBatching(this);
nsCOMPtr<nsIEnumerator> enumerator;
res = selection->GetEnumerator(SELECTION_NORMAL, getter_AddRefs(enumerator));
res = selection->GetEnumerator(getter_AddRefs(enumerator));
if (NS_SUCCEEDED(res) && enumerator)
{
enumerator->First();
@ -1488,7 +1488,7 @@ nsHTMLEditor::Indent(const nsString& aIndent)
nsCOMPtr<nsIDOMNode> node;
PRInt32 offset;
PRBool isCollapsed;
res = selection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed);
res = selection->GetIsCollapsed(&isCollapsed);
if (NS_FAILED(res)) return res;
res = GetStartNodeAndOffset(selection, &node, &offset);
@ -1530,7 +1530,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, SELECTION_NORMAL);
res = selection->Collapse(newBQ,0);
if (NS_FAILED(res)) return res;
nsAutoString theText(" ");
res = InsertText(theText);
@ -1538,7 +1538,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, SELECTION_NORMAL);
res = selection->Collapse(node,0);
if (NS_FAILED(res)) return res;
}
}
@ -1604,7 +1604,7 @@ nsHTMLEditor::InsertList(const nsString& aListType)
if (NS_FAILED(res) || !selection) return res;
PRBool isCollapsed;
res = selection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed);
res = selection->GetIsCollapsed(&isCollapsed);
if (NS_FAILED(res)) return res;
nsCOMPtr<nsIDOMNode> node;
@ -1651,7 +1651,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, SELECTION_NORMAL);
res = selection->Collapse(newItem,0);
if (NS_FAILED(res)) return res;
nsAutoString theText(" ");
res = InsertText(theText);
@ -1659,7 +1659,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, SELECTION_NORMAL);
res = selection->Collapse(node,0);
if (NS_FAILED(res)) return res;
}
@ -1689,7 +1689,7 @@ nsHTMLEditor::InsertLink(nsString& aURL)
return res;
}
PRBool isCollapsed;
res = selection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed);
res = selection->GetIsCollapsed(&isCollapsed);
if (NS_FAILED(res))
isCollapsed = PR_TRUE;
@ -1737,7 +1737,7 @@ nsHTMLEditor::InsertLink(nsString& aURL)
#endif
return res;
}
res = selection->Collapse(newNode, 0, SELECTION_NORMAL);
res = selection->Collapse(newNode, 0);
if (NS_FAILED(res))
{
#ifdef DEBUG_akkana
@ -1857,7 +1857,7 @@ nsHTMLEditor::GetSelectedElement(const nsString& aTagName, nsIDOMElement** aRetu
return res;
PRBool isCollapsed;
selection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed);
selection->GetIsCollapsed(&isCollapsed);
nsCOMPtr<nsIDOMElement> selectedElement;
PRBool bNodeFound = PR_FALSE;
@ -1865,7 +1865,7 @@ nsHTMLEditor::GetSelectedElement(const nsString& aTagName, nsIDOMElement** aRetu
if (!isCollapsed)
{
nsCOMPtr<nsIEnumerator> enumerator;
res = selection->GetEnumerator(SELECTION_NORMAL,getter_AddRefs(enumerator));
res = selection->GetEnumerator(getter_AddRefs(enumerator));
if (NS_SUCCEEDED(res) && enumerator)
{
enumerator->First();
@ -2190,14 +2190,14 @@ nsHTMLEditor::InsertElement(nsIDOMElement* aElement, PRBool aDeleteSelection)
if (collapseAfter)
{
// Default behavior is to collapse to the end of the selection
selection->ClearSelection(SELECTION_NORMAL);
selection->ClearSelection();
} 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<nsIDOMRange> firstRange;
res = selection->GetRangeAt(0, SELECTION_NORMAL, getter_AddRefs(firstRange));
res = selection->GetRangeAt(0, getter_AddRefs(firstRange));
if (NS_SUCCEEDED(res) && firstRange)
{
nsCOMPtr<nsIDOMNode> parent;
@ -2206,10 +2206,10 @@ nsHTMLEditor::InsertElement(nsIDOMElement* aElement, PRBool aDeleteSelection)
{
PRInt32 startOffset;
firstRange->GetStartOffset(&startOffset);
selection->Collapse(parent, startOffset, SELECTION_NORMAL);
selection->Collapse(parent, startOffset);
} else {
// Very unlikely, but collapse to the end if we failed above
selection->ClearSelection(SELECTION_NORMAL);
selection->ClearSelection();
}
}
}
@ -2378,7 +2378,7 @@ nsHTMLEditor::InsertLinkAroundSelection(nsIDOMElement* aAnchorElement)
goto DELETE_ANCHOR;
PRBool isCollapsed;
res = selection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed);
res = selection->GetIsCollapsed(&isCollapsed);
if (NS_FAILED(res))
isCollapsed = PR_TRUE;
@ -2470,9 +2470,9 @@ nsHTMLEditor::SelectElement(nsIDOMElement* aElement)
if (NS_SUCCEEDED(res))
{
// Collapse selection to just before desired element,
selection->Collapse(parent, offsetInParent, SELECTION_NORMAL);
selection->Collapse(parent, offsetInParent);
// then extend it to just after
selection->Extend(parent, offsetInParent+1, SELECTION_NORMAL);
selection->Extend(parent, offsetInParent+1);
}
}
}
@ -2542,7 +2542,7 @@ nsHTMLEditor::SetCaretInTableCell(nsIDOMElement* aElement, PRBool* caretIsSet)
res = nsEditor::GetSelection(getter_AddRefs(selection));
if (NS_SUCCEEDED(res) && selection)
{
res = selection->Collapse(parent, offset, SELECTION_NORMAL);
res = selection->Collapse(parent, offset);
if (NS_SUCCEEDED(res) && caretIsSet)
*caretIsSet = PR_TRUE;
}
@ -2581,7 +2581,7 @@ nsHTMLEditor::SetCaretAfterElement(nsIDOMElement* aElement)
if (NS_SUCCEEDED(res))
{
// Collapse selection to just after desired element,
selection->Collapse(parent, offsetInParent+1, SELECTION_NORMAL);
selection->Collapse(parent, offsetInParent+1);
}
}
}

Просмотреть файл

@ -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, SELECTION_NORMAL, getter_AddRefs(mRange));
res = selection->GetRangeAt(0, getter_AddRefs(mRange));
if (NS_SUCCEEDED(res))
{
nsCOMPtr<nsIDOMNSRange> nsrange (do_QueryInterface(mRange));

Просмотреть файл

@ -952,12 +952,12 @@ nsJSEditorLog::PrintSelection()
if (NS_FAILED(result))
return result;
result = presShell->GetSelection(getter_AddRefs(selection));
result = presShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if (NS_FAILED(result))
return result;
result = selection->GetRangeCount(SELECTION_NORMAL, &rangeCount);
result = selection->GetRangeCount(&rangeCount);
if (NS_FAILED(result))
return result;
@ -972,7 +972,7 @@ nsJSEditorLog::PrintSelection()
for (i = 0; i < rangeCount; i++)
{
result = selection->GetRangeAt(i, SELECTION_NORMAL, getter_AddRefs(range));
result = selection->GetRangeAt(i, getter_AddRefs(range));
if (NS_FAILED(result))
return result;

Просмотреть файл

@ -35,7 +35,6 @@
#include "nsIEditProperty.h"
static NS_DEFINE_CID(kCContentIteratorCID, NS_CONTENTITERATOR_CID);
static NS_DEFINE_IID(kRangeListCID, NS_RANGELIST_CID);
#define CANCEL_OPERATION_IF_READONLY_OR_DISABLED \
if (mFlags & TEXT_EDITOR_FLAG_READONLY || mFlags & TEXT_EDITOR_FLAG_DISABLED) \
@ -195,7 +194,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(SELECTION_NORMAL);
aSelection->ClearSelection();
}
return NS_OK;
@ -338,8 +337,8 @@ nsTextEditRules::CreateStyleForInsertText(nsIDOMSelection *aSelection, TypeInSta
// Otherwise, create the text node and the new inline style parents.
nsCOMPtr<nsIDOMNode>anchor;
PRInt32 offset;
nsresult result = aSelection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(anchor));
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(SELECTION_NORMAL, &offset)) && anchor)
nsresult result = aSelection->GetAnchorNode( getter_AddRefs(anchor));
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(&offset)) && anchor)
{
nsCOMPtr<nsIDOMCharacterData>anchorAsText;
anchorAsText = do_QueryInterface(anchor);
@ -526,7 +525,7 @@ nsTextEditRules::InsertStyleNode(nsIDOMNode *aNode,
result = mEditor->InsertNode(aNode, *aNewNode, 0);
if (NS_SUCCEEDED(result)) {
if (aSelection) {
aSelection->Collapse(aNode, 0, SELECTION_NORMAL);
aSelection->Collapse(aNode, 0);
}
}
}
@ -547,8 +546,8 @@ nsTextEditRules::InsertStyleAndNewTextNode(nsIDOMNode *aParentNode, nsIAtom *aTa
{
nsCOMPtr<nsIDOMNode>anchor;
PRInt32 offset;
result = aSelection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(anchor));
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(SELECTION_NORMAL, &offset)) && anchor)
result = aSelection->GetAnchorNode(getter_AddRefs(anchor));
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(&offset)) && anchor)
{
nsCOMPtr<nsIDOMCharacterData>anchorAsText;
anchorAsText = do_QueryInterface(anchor);
@ -572,7 +571,7 @@ nsTextEditRules::InsertStyleAndNewTextNode(nsIDOMNode *aParentNode, nsIAtom *aTa
if (NS_SUCCEEDED(result))
{
if (aSelection) {
aSelection->Collapse(newTextNode, 0, SELECTION_NORMAL);
aSelection->Collapse(newTextNode, 0);
}
}
}
@ -667,7 +666,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(SELECTION_NORMAL, &isCollapsed);
aSelection->GetIsCollapsed(&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 &nbsp; character in it.
@ -679,8 +678,8 @@ nsTextEditRules::DidDeleteSelection(nsIDOMSelection *aSelection,
{
nsCOMPtr<nsIDOMNode>anchor;
PRInt32 offset;
result = aSelection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(anchor));
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(SELECTION_NORMAL, &offset)) && anchor)
result = aSelection->GetAnchorNode(getter_AddRefs(anchor));
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(&offset)) && anchor)
{
nsCOMPtr<nsIDOMNodeList> anchorChildren;
result = anchor->GetChildNodes(getter_AddRefs(anchorChildren));
@ -727,7 +726,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, SELECTION_NORMAL);
aSelection->Collapse(siblingNode, selectedNodeLength);
}
}
}
@ -767,8 +766,8 @@ nsTextEditRules:: DidUndo(nsIDOMSelection *aSelection, nsresult aResult)
{
nsCOMPtr<nsIDOMNode>node;
PRInt32 offset;
result = aSelection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(node));
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(SELECTION_NORMAL, &offset)) && node)
result = aSelection->GetAnchorNode(getter_AddRefs(node));
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(&offset)) && node)
{
nsCOMPtr<nsIDOMElement>element;
element = do_QueryInterface(node);
@ -814,8 +813,8 @@ nsTextEditRules::DidRedo(nsIDOMSelection *aSelection, nsresult aResult)
{
nsCOMPtr<nsIDOMNode>node;
PRInt32 offset;
result = aSelection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(node));
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(SELECTION_NORMAL, &offset)) && node)
result = aSelection->GetAnchorNode(getter_AddRefs(node));
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(&offset)) && node)
{
nsCOMPtr<nsIDOMElement>element;
element = do_QueryInterface(node);
@ -917,7 +916,7 @@ nsTextEditRules::CreateBogusNodeIfNeeded(nsIDOMSelection *aSelection)
nsAutoString data;
data += 160;
newNodeAsText->SetData(data);
aSelection->Collapse(newTNode, 0, SELECTION_NORMAL);
aSelection->Collapse(newTNode, 0);
}
}
// make sure we know the PNode is bogus
@ -966,7 +965,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, SELECTION_NORMAL, getter_AddRefs(selectionRange));
res = aSelection->GetRangeAt(0, getter_AddRefs(selectionRange));
if (NS_FAILED(res)) return res;
res = selectionRange->Clone(getter_AddRefs(pinRange));
if (NS_FAILED(res)) return res;
@ -1020,9 +1019,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, SELECTION_NORMAL);
res = aSelection->Collapse(startNode,startOffset);
if (NS_FAILED(res)) return res;
res = aSelection->Extend(endNode,endOffset, SELECTION_NORMAL);
res = aSelection->Extend(endNode,endOffset);
if (NS_FAILED(res)) return res;
}

Просмотреть файл

@ -399,7 +399,7 @@ NS_IMETHODIMP nsTextEditor::SetTextProperty(nsIAtom *aProperty,
if ((PR_FALSE==cancel) && (NS_SUCCEEDED(result)))
{
PRBool isCollapsed;
selection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed);
selection->GetIsCollapsed(&isCollapsed);
if (PR_TRUE==isCollapsed)
{
// manipulating text attributes on a collapsed selection only sets state for the next text insertion
@ -410,7 +410,7 @@ NS_IMETHODIMP nsTextEditor::SetTextProperty(nsIAtom *aProperty,
// set the text property for all selected ranges
nsEditor::BeginTransaction();
nsCOMPtr<nsIEnumerator> enumerator;
result = selection->GetEnumerator(SELECTION_NORMAL,getter_AddRefs(enumerator));
result = selection->GetEnumerator(getter_AddRefs(enumerator));
if (NS_SUCCEEDED(result) && enumerator)
{
enumerator->First();
@ -525,9 +525,9 @@ NS_IMETHODIMP nsTextEditor::GetTextProperty(nsIAtom *aProperty,
if ((NS_SUCCEEDED(result)) && selection)
{
PRBool isCollapsed;
selection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed);
selection->GetIsCollapsed(&isCollapsed);
nsCOMPtr<nsIEnumerator> enumerator;
result = selection->GetEnumerator(SELECTION_NORMAL, getter_AddRefs(enumerator));
result = selection->GetEnumerator(getter_AddRefs(enumerator));
if (NS_SUCCEEDED(result) && enumerator)
{
enumerator->First();
@ -735,7 +735,7 @@ NS_IMETHODIMP nsTextEditor::RemoveTextProperty(nsIAtom *aProperty, const nsStrin
if ((PR_FALSE==cancel) && (NS_SUCCEEDED(result)))
{
PRBool isCollapsed;
selection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed);
selection->GetIsCollapsed(&isCollapsed);
if (PR_TRUE==isCollapsed)
{
// manipulating text attributes on a collapsed selection only sets state for the next text insertion
@ -754,7 +754,7 @@ NS_IMETHODIMP nsTextEditor::RemoveTextProperty(nsIAtom *aProperty, const nsStrin
nsCOMPtr<nsIDOMNode> startParent, endParent;
PRInt32 startOffset, endOffset;
nsCOMPtr<nsIEnumerator> enumerator;
result = selection->GetEnumerator(SELECTION_NORMAL,getter_AddRefs(enumerator));
result = selection->GetEnumerator(getter_AddRefs(enumerator));
if (NS_SUCCEEDED(result) && enumerator)
{
enumerator->First();
@ -847,13 +847,13 @@ void nsTextEditor::GetTextSelectionOffsetsForRange(nsIDOMSelection *aSelection,
nsCOMPtr<nsIDOMNode> startNode, endNode;
PRInt32 startOffset, 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);
aSelection->GetAnchorNode(getter_AddRefs(startNode));
aSelection->GetAnchorOffset(&startOffset);
aSelection->GetFocusNode(getter_AddRefs(endNode));
aSelection->GetFocusOffset(&endOffset);
nsCOMPtr<nsIEnumerator> enumerator;
result = aSelection->GetEnumerator(SELECTION_NORMAL,getter_AddRefs(enumerator));
result = aSelection->GetEnumerator(getter_AddRefs(enumerator));
if (NS_SUCCEEDED(result) && enumerator)
{
enumerator->First();
@ -951,8 +951,8 @@ void nsTextEditor::ResetTextSelectionForRange(nsIDOMNode *aParent,
iter->Next();
iter->CurrentNode(getter_AddRefs(content));
}
aSelection->Collapse(startNode, startOffset, SELECTION_NORMAL);
aSelection->Extend(endNode, endOffset, SELECTION_NORMAL);
aSelection->Collapse(startNode, startOffset);
aSelection->Extend(endNode, endOffset);
}
}
@ -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_NORMAL);
selection->Collapse(newChildNode, 0);
PRInt32 endOffset = aEndOffset-aStartOffset;
selection->Extend(newChildNode, endOffset, SELECTION_NORMAL);
selection->Extend(newChildNode, endOffset);
}
}
}
@ -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_NORMAL);
selection->Extend(newRightNode, endOffset, SELECTION_NORMAL);
selection->Collapse(startNode, startOffset);
selection->Extend(newRightNode, endOffset);
}
}
}
@ -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(SELECTION_NORMAL, &aStartOffset);
selection->GetFocusOffset(SELECTION_NORMAL, &aEndOffset);
selection->GetAnchorOffset(&aStartOffset);
selection->GetFocusOffset(&aEndOffset);
// create new parent nodes for all the content between the start and end nodes
nsCOMPtr<nsIContentIterator>iter;
@ -2256,8 +2256,8 @@ nsTextEditor::SetTextPropertiesForNodeWithDifferentParents(nsIDOMRange *aRange,
}
if (NS_SUCCEEDED(result))
{
selection->Collapse(startNode, startOffset, SELECTION_NORMAL);
selection->Extend(endNode, aEndOffset, SELECTION_NORMAL);
selection->Collapse(startNode, startOffset);
selection->Extend(endNode, aEndOffset);
}
}
}
@ -2770,8 +2770,8 @@ nsTextEditor::RemoveTextPropertiesForNodeWithDifferentParents(nsIDOMNode *aStar
result = nsEditor::GetSelection(getter_AddRefs(selection));
if (NS_SUCCEEDED(result))
{
selection->Collapse(aStartNode, rangeStartOffset, SELECTION_NORMAL);
selection->Extend(aEndNode, rangeEndOffset, SELECTION_NORMAL);
selection->Collapse(aStartNode, rangeStartOffset);
selection->Extend(aEndNode, rangeEndOffset);
if (gNoisy) { printf("RTPFNWDP set selection.\n"); }
}
}
@ -2973,13 +2973,13 @@ nsresult nsTextEditor::GetTextSelectionOffsets(nsIDOMSelection *aSelection,
nsCOMPtr<nsIDOMNode> startNode, endNode, parentNode;
PRInt32 startOffset, 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);
aSelection->GetAnchorNode(getter_AddRefs(startNode));
aSelection->GetAnchorOffset(&startOffset);
aSelection->GetFocusNode(getter_AddRefs(endNode));
aSelection->GetFocusOffset(&endOffset);
nsCOMPtr<nsIEnumerator> enumerator;
result = aSelection->GetEnumerator(SELECTION_NORMAL,getter_AddRefs(enumerator));
result = aSelection->GetEnumerator(getter_AddRefs(enumerator));
if (NS_SUCCEEDED(result) && enumerator)
{
// don't use "result" in this block

Просмотреть файл

@ -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, SELECTION_NORMAL);
selectionResult = selection->Collapse(mParent, offset);
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, SELECTION_NORMAL);
selectionResult = selection->Collapse(mParent, offset);
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, SELECTION_NORMAL);
nsresult selectionResult = selection->Collapse(mParent, offset);
NS_ASSERTION((NS_SUCCEEDED(selectionResult)), "selection could not be collapsed after undo of insert.");
}
}

Просмотреть файл

@ -146,7 +146,7 @@ NS_IMETHODIMP DeleteRangeTxn::Do(void)
nsCOMPtr<nsIDOMSelection> selection;
result = mEditor->GetSelection(getter_AddRefs(selection));
if (NS_SUCCEEDED(result)) {
result = selection->Collapse(mStartParent, mStartOffset, SELECTION_NORMAL);
result = selection->Collapse(mStartParent, mStartOffset);
}
}
@ -166,8 +166,8 @@ NS_IMETHODIMP DeleteRangeTxn::Undo(void)
nsCOMPtr<nsIDOMSelection> selection;
result = mEditor->GetSelection(getter_AddRefs(selection));
if (NS_SUCCEEDED(result)) {
selection->Collapse(mStartParent, mStartOffset, SELECTION_NORMAL);
selection->Extend(mEndParent, mEndOffset, SELECTION_NORMAL);
selection->Collapse(mStartParent, mStartOffset);
selection->Extend(mEndParent, mEndOffset);
}
}
@ -187,7 +187,7 @@ NS_IMETHODIMP DeleteRangeTxn::Redo(void)
nsCOMPtr<nsIDOMSelection> selection;
result = mEditor->GetSelection(getter_AddRefs(selection));
if (NS_SUCCEEDED(result)) {
result = selection->Collapse(mStartParent, mStartOffset, SELECTION_NORMAL);
result = selection->Collapse(mStartParent, mStartOffset);
}
}

Просмотреть файл

@ -69,7 +69,7 @@ NS_IMETHODIMP DeleteTextTxn::Do(void)
nsCOMPtr<nsIDOMSelection> selection;
nsresult selectionResult = mEditor->GetSelection(getter_AddRefs(selection));
if (NS_SUCCEEDED(selectionResult) && selection) {
selectionResult = selection->Collapse(mElement, mOffset, SELECTION_NORMAL);
selectionResult = selection->Collapse(mElement, mOffset);
NS_ASSERTION((NS_SUCCEEDED(selectionResult)), "selection could not be collapsed after undo of insert.");
}
}
@ -91,7 +91,7 @@ NS_IMETHODIMP DeleteTextTxn::Undo(void)
nsCOMPtr<nsIDOMSelection> selection;
nsresult selectionResult = mEditor->GetSelection(getter_AddRefs(selection));
if (NS_SUCCEEDED(selectionResult) && selection) {
selectionResult = selection->Collapse(mElement, mOffset, SELECTION_NORMAL);
selectionResult = selection->Collapse(mElement, mOffset);
NS_ASSERTION((NS_SUCCEEDED(selectionResult)), "selection could not be collapsed after undo of insert.");
}
}

Просмотреть файл

@ -73,7 +73,7 @@ NS_IMETHODIMP IMETextTxn::Do(void)
// advance caret: This requires the presentation shell to get the selection.
nsCOMPtr<nsIDOMSelection> selection;
nsresult result = mPresShell->GetSelection(getter_AddRefs(selection));
nsresult result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
NS_ASSERTION(selection,"Could not get selection in IMEtextTxn::Do\n");
if (NS_SUCCEEDED(result) && selection) {
if (mReplaceLength==0) {
@ -101,9 +101,9 @@ NS_IMETHODIMP IMETextTxn::Undo(void)
if (NS_SUCCEEDED(result))
{ // set the selection to the insertion point where the string was removed
nsCOMPtr<nsIDOMSelection> selection;
result = mPresShell->GetSelection(getter_AddRefs(selection));
result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if (NS_SUCCEEDED(result) && selection) {
result = selection->Collapse(mElement, mOffset, SELECTION_NORMAL);
result = selection->Collapse(mElement, mOffset);
NS_ASSERTION((NS_SUCCEEDED(result)), "selection could not be collapsed after undo of IME insert.");
}
}
@ -277,16 +277,16 @@ NS_IMETHODIMP IMETextTxn::CollapseTextSelection(void)
}
nsCOMPtr<nsIDOMSelection> selection;
result = mPresShell->GetSelection(getter_AddRefs(selection));
result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if (NS_SUCCEEDED(result) && selection){
if (haveSelectedRange) {
result = selection->Collapse(mElement,mOffset+selectionStart, SELECTION_NORMAL);
result = selection->Extend(mElement,mOffset+selectionEnd, SELECTION_NORMAL);
result = selection->Collapse(mElement,mOffset+selectionStart);
result = selection->Extend(mElement,mOffset+selectionEnd);
} else {
if (haveCaretPosition)
result = selection->Collapse(mElement,mOffset+caretPosition, SELECTION_NORMAL);
result = selection->Collapse(mElement,mOffset+caretPosition);
else
result = selection->Collapse(mElement,mOffset+mStringToInsert.Length(), SELECTION_NORMAL);
result = selection->Collapse(mElement,mOffset+mStringToInsert.Length());
}
}
@ -296,9 +296,9 @@ NS_IMETHODIMP IMETextTxn::CollapseTextSelection(void)
NS_IMETHODIMP IMETextTxn::CollapseTextSelectionOnCommit(void)
{
nsCOMPtr<nsIDOMSelection> selection;
nsresult result = mPresShell->GetSelection(getter_AddRefs(selection));
nsresult result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if (NS_SUCCEEDED(result) && selection){
result = selection->Collapse(mElement,mOffset+mStringToInsert.Length(), SELECTION_NORMAL);
result = selection->Collapse(mElement,mOffset+mStringToInsert.Length());
}
return result;

Просмотреть файл

@ -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_NORMAL);
selection->Collapse(mParent, mOffset+1);
//selection->Extend(mParent, mOffset+1);
}
}

Просмотреть файл

@ -74,12 +74,12 @@ NS_IMETHODIMP InsertTextTxn::Do(void)
if (gNoisy) { printf("Do Insert Text element = %p\n", mElement.get()); }
// advance caret: This requires the presentation shell to get the selection.
nsCOMPtr<nsIDOMSelection> selection;
nsresult result = mPresShell->GetSelection(getter_AddRefs(selection));
nsresult result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
NS_ASSERTION(selection,"Could not get selection in InsertTextTxn::Do\n");
if (NS_SUCCEEDED(result) && selection) {
result = mElement->InsertData(mOffset, mStringToInsert);
if (NS_SUCCEEDED(result)) {
result = selection->Collapse(mElement, mOffset+mStringToInsert.Length(), SELECTION_NORMAL);
result = selection->Collapse(mElement, mOffset+mStringToInsert.Length());
NS_ASSERTION((NS_SUCCEEDED(result)), "selection could not be collapsed after insert.");
}
}
@ -95,9 +95,9 @@ NS_IMETHODIMP InsertTextTxn::Undo(void)
if (NS_SUCCEEDED(result))
{ // set the selection to the insertion point where the string was removed
nsCOMPtr<nsIDOMSelection> selection;
result = mPresShell->GetSelection(getter_AddRefs(selection));
result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if (NS_SUCCEEDED(result) && selection) {
result = selection->Collapse(mElement, mOffset, SELECTION_NORMAL);
result = selection->Collapse(mElement, mOffset);
NS_ASSERTION((NS_SUCCEEDED(result)), "selection could not be collapsed after undo of insert.");
}
}

Просмотреть файл

@ -89,7 +89,7 @@ NS_IMETHODIMP JoinElementTxn::Do(void)
mEditor->GetSelection(getter_AddRefs(selection));
if (selection)
{
selection->Collapse(mRightNode, mOffset, SELECTION_NORMAL);
selection->Collapse(mRightNode, mOffset);
}
}
}

Просмотреть файл

@ -75,7 +75,7 @@ NS_IMETHODIMP SplitElementTxn::Do(void)
mEditor->GetSelection(getter_AddRefs(selection));
if (selection)
{
selection->Collapse(mNewLeftNode, mOffset, SELECTION_NORMAL);
selection->Collapse(mNewLeftNode, mOffset);
}
}
else {
@ -112,7 +112,7 @@ NS_IMETHODIMP SplitElementTxn::Undo(void)
mEditor->GetSelection(getter_AddRefs(selection));
if (selection)
{
selection->Collapse(mExistingRightNode, mOffset, SELECTION_NORMAL);
selection->Collapse(mExistingRightNode, mOffset);
}
}
else {

Просмотреть файл

@ -482,7 +482,7 @@ nsEditor::GetSelection(nsIDOMSelection **aSelection)
if (!aSelection)
return NS_ERROR_NULL_POINTER;
*aSelection = nsnull;
nsresult result = mPresShell->GetSelection(aSelection); // does an addref
nsresult result = mPresShell->GetSelection(SELECTION_NORMAL, aSelection); // does an addref
return result;
}
@ -523,7 +523,7 @@ nsEditor::Init(nsIDOMDocument *aDoc, nsIPresShell* aPresShell)
/* Show the caret */
nsCOMPtr<nsICaret> caret;
if (NS_SUCCEEDED(mPresShell->GetCaret(getter_AddRefs(caret))))
if (NS_SUCCEEDED(mPresShell->GetCaret(getter_AddRefs(caret))) && caret)
{
caret->SetCaretVisible(PR_TRUE);
caret->SetCaretReadOnly(PR_FALSE);
@ -1040,7 +1040,7 @@ NS_IMETHODIMP nsEditor::SelectAll()
if (!mDoc || !mPresShell) { return NS_ERROR_NOT_INITIALIZED; }
nsCOMPtr<nsIDOMSelection> selection;
nsresult result = mPresShell->GetSelection(getter_AddRefs(selection));
nsresult result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if (NS_SUCCEEDED(result) && selection)
{
result = SelectEntireDocument(selection);
@ -1059,7 +1059,7 @@ NS_IMETHODIMP nsEditor::SelectEntireDocument(nsIDOMSelection *aSelection)
nsCOMPtr<nsIDOMNode>bodyNode = do_QueryInterface(bodyElement);
if (bodyNode)
{
result = aSelection->Collapse(bodyNode, 0, SELECTION_NORMAL);
result = aSelection->Collapse(bodyNode, 0);
if (NS_SUCCEEDED(result))
{
PRInt32 numBodyChildren=0;
@ -1068,7 +1068,7 @@ NS_IMETHODIMP nsEditor::SelectEntireDocument(nsIDOMSelection *aSelection)
if ((NS_SUCCEEDED(result)) && lastChild)
{
GetChildOffset(lastChild, bodyNode, numBodyChildren);
result = aSelection->Extend(bodyNode, numBodyChildren+1, SELECTION_NORMAL);
result = aSelection->Extend(bodyNode, numBodyChildren+1);
}
}
}
@ -1121,7 +1121,7 @@ NS_IMETHODIMP nsEditor::BeginningOfDocument()
if (!mDoc || !mPresShell) { return NS_ERROR_NOT_INITIALIZED; }
nsCOMPtr<nsIDOMSelection> selection;
nsresult result = mPresShell->GetSelection(getter_AddRefs(selection));
nsresult result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if (NS_SUCCEEDED(result) && selection)
{
nsCOMPtr<nsIDOMNodeList> nodeList;
@ -1140,7 +1140,7 @@ NS_IMETHODIMP nsEditor::BeginningOfDocument()
nsCOMPtr<nsIDOMNode> firstNode = GetDeepFirstChild(bodyNode);
if (firstNode)
{
result = selection->Collapse(firstNode, 0, SELECTION_NORMAL);
result = selection->Collapse(firstNode, 0);
ScrollIntoView(PR_TRUE);
}
}
@ -1199,7 +1199,7 @@ NS_IMETHODIMP nsEditor::EndOfDocument()
if (!mDoc || !mPresShell) { return NS_ERROR_NOT_INITIALIZED; }
nsCOMPtr<nsIDOMSelection> selection;
nsresult result = mPresShell->GetSelection(getter_AddRefs(selection));
nsresult result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if (NS_SUCCEEDED(result) && selection)
{
nsCOMPtr<nsIDOMNodeList> nodeList;
@ -1225,7 +1225,7 @@ NS_IMETHODIMP nsEditor::EndOfDocument()
if (text)
text->GetLength(&offset);
}
result = selection->Collapse(lastChild, offset, SELECTION_NORMAL);
result = selection->Collapse(lastChild, offset);
ScrollIntoView(PR_FALSE);
}
}
@ -1244,12 +1244,12 @@ NS_IMETHODIMP nsEditor::Cut()
#endif // ENABLE_JS_EDITOR_LOG
nsCOMPtr<nsIDOMSelection> selection;
nsresult res = mPresShell->GetSelection(getter_AddRefs(selection));
nsresult res = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if (!NS_SUCCEEDED(res))
return res;
PRBool isCollapsed;
if (NS_SUCCEEDED(selection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed)) && isCollapsed)
if (NS_SUCCEEDED(selection->GetIsCollapsed(&isCollapsed)) && isCollapsed)
return NS_ERROR_NOT_AVAILABLE;
res = Copy();
@ -1744,11 +1744,11 @@ NS_IMETHODIMP nsEditor::CreateAggregateTxnForDeleteSelection(nsIAtom *aTxnName,
// Get current selection and setup txn to delete it,
// but only if selection exists (is not a collapsed "caret" state)
nsCOMPtr<nsIDOMSelection> selection;
result = mPresShell->GetSelection(getter_AddRefs(selection));
result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if (NS_SUCCEEDED(result) && selection)
{
PRBool collapsed;
result = selection->GetIsCollapsed(SELECTION_NORMAL, &collapsed);
result = selection->GetIsCollapsed(&collapsed);
if (NS_SUCCEEDED(result) && !collapsed) {
EditAggregateTxn *delSelTxn;
result = CreateTxnForDeleteSelection(nsIEditor::eDoNothing,
@ -1803,8 +1803,8 @@ nsEditor::InsertText(const nsString& aStringToInsert)
{
nsCOMPtr<nsIDOMNode> selectedNode;
PRInt32 offset;
result = selection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(selectedNode));
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(selection->GetAnchorOffset(SELECTION_NORMAL, &offset)) && selectedNode)
result = selection->GetAnchorNode(getter_AddRefs(selectedNode));
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(selection->GetAnchorOffset(&offset)) && selectedNode)
{
nsCOMPtr<nsIDOMNode> newNode;
result = CreateNode(GetTextNodeTag(), selectedNode, offset,
@ -1817,8 +1817,8 @@ nsEditor::InsertText(const nsString& aStringToInsert)
{
nsAutoString placeholderText(" ");
newTextNode->SetData(placeholderText);
selection->Collapse(newNode, 0, SELECTION_NORMAL);
selection->Extend(newNode, 1, SELECTION_NORMAL);
selection->Collapse(newNode, 0);
selection->Extend(newNode, 1);
result = InsertText(aStringToInsert);
}
}
@ -1846,7 +1846,7 @@ NS_IMETHODIMP nsEditor::CreateTxnForInsertText(const nsString & aStringToInsert,
else
{
nsCOMPtr<nsIDOMSelection> selection;
result = mPresShell->GetSelection(getter_AddRefs(selection));
result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if ((NS_SUCCEEDED(result)) && selection)
{
#if 0
@ -1868,7 +1868,7 @@ NS_IMETHODIMP nsEditor::CreateTxnForInsertText(const nsString & aStringToInsert,
#endif
result = NS_ERROR_UNEXPECTED;
nsCOMPtr<nsIEnumerator> enumerator;
result = selection->GetEnumerator(SELECTION_NORMAL,getter_AddRefs(enumerator));
result = selection->GetEnumerator(getter_AddRefs(enumerator));
if (NS_SUCCEEDED(result) && enumerator)
{
enumerator->First();
@ -2030,7 +2030,7 @@ NS_IMETHODIMP nsEditor::DeleteSelectionAndCreateNode(const nsString& aTag,
nsCOMPtr<nsIDOMSelection> selection;
result = GetSelection(getter_AddRefs(selection));
if ((NS_SUCCEEDED(result)) && selection)
selection->Collapse(parentSelectedNode, offsetOfNewNode+1, SELECTION_NORMAL);
selection->Collapse(parentSelectedNode, offsetOfNewNode+1);
return result;
}
@ -2043,7 +2043,7 @@ NS_IMETHODIMP nsEditor::DeleteSelectionAndPrepareToCreateNode(nsCOMPtr<nsIDOMNod
if ((NS_SUCCEEDED(result)) && selection)
{
PRBool collapsed;
result = selection->GetIsCollapsed(SELECTION_NORMAL, &collapsed);
result = selection->GetIsCollapsed(&collapsed);
if (NS_SUCCEEDED(result) && !collapsed)
{
result = DeleteSelection(nsIEditor::eDoNothing);
@ -2057,13 +2057,13 @@ NS_IMETHODIMP nsEditor::DeleteSelectionAndPrepareToCreateNode(nsCOMPtr<nsIDOMNod
}
#ifdef NS_DEBUG
nsCOMPtr<nsIDOMNode>testSelectedNode;
nsresult debugResult = selection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(testSelectedNode));
nsresult debugResult = selection->GetAnchorNode(getter_AddRefs(testSelectedNode));
// no selection is ok.
// if there is a selection, it must be collapsed
if (testSelectedNode)
{
PRBool testCollapsed;
debugResult = selection->GetIsCollapsed(SELECTION_NORMAL, &testCollapsed);
debugResult = selection->GetIsCollapsed(&testCollapsed);
NS_ASSERTION((NS_SUCCEEDED(result)), "couldn't get a selection after deletion");
NS_ASSERTION(PR_TRUE==testCollapsed, "selection not reset after deletion");
}
@ -2071,8 +2071,8 @@ NS_IMETHODIMP nsEditor::DeleteSelectionAndPrepareToCreateNode(nsCOMPtr<nsIDOMNod
}
// split the selected node
PRInt32 offsetOfSelectedNode;
result = selection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(parentSelectedNode));
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(selection->GetAnchorOffset(SELECTION_NORMAL, &offsetOfSelectedNode)) && parentSelectedNode)
result = selection->GetAnchorNode(getter_AddRefs(parentSelectedNode));
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(selection->GetAnchorOffset(&offsetOfSelectedNode)) && parentSelectedNode)
{
nsCOMPtr<nsIDOMNode> selectedNode;
PRUint32 selectedNodeContentCount=0;
@ -2224,12 +2224,12 @@ NS_IMETHODIMP nsEditor::CreateTxnForDeleteSelection(nsIEditor::ECollapsedSelecti
nsresult result;
nsCOMPtr<nsIDOMSelection> selection;
result = mPresShell->GetSelection(getter_AddRefs(selection));
result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if ((NS_SUCCEEDED(result)) && selection)
{
// Check whether the selection is collapsed and we should do nothing:
PRBool isCollapsed;
result = (selection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed));
result = (selection->GetIsCollapsed(&isCollapsed));
if (NS_SUCCEEDED(result) && isCollapsed && aAction == eDoNothing)
return NS_OK;
@ -2240,7 +2240,7 @@ NS_IMETHODIMP nsEditor::CreateTxnForDeleteSelection(nsIEditor::ECollapsedSelecti
}
nsCOMPtr<nsIEnumerator> enumerator;
result = selection->GetEnumerator(SELECTION_NORMAL, getter_AddRefs(enumerator));
result = selection->GetEnumerator(getter_AddRefs(enumerator));
if (NS_SUCCEEDED(result) && enumerator)
{
for (enumerator->First(); NS_OK!=enumerator->IsDone(); enumerator->Next())
@ -3491,12 +3491,12 @@ nsEditor::BeginComposition(void)
nsCOMPtr<nsIDOMSelection> selection;
nsCOMPtr<nsIDOMCharacterData> nodeAsText;
result = mPresShell->GetSelection(getter_AddRefs(selection));
result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if ((NS_SUCCEEDED(result)) && selection)
{
result = NS_ERROR_UNEXPECTED;
nsCOMPtr<nsIEnumerator> enumerator;
result = selection->GetEnumerator(SELECTION_NORMAL, getter_AddRefs(enumerator));
result = selection->GetEnumerator(getter_AddRefs(enumerator));
if (NS_SUCCEEDED(result) && enumerator)
{
enumerator->First();
@ -3770,8 +3770,8 @@ nsEditor::SetInputMethodText(const nsString& aStringToInsert,nsIDOMTextRangeList
{
nsCOMPtr<nsIDOMNode> selectedNode;
PRInt32 offset;
result = selection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(selectedNode));
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(selection->GetAnchorOffset(SELECTION_NORMAL, &offset)) && selectedNode)
result = selection->GetAnchorNode(getter_AddRefs(selectedNode));
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(selection->GetAnchorOffset(&offset)) && selectedNode)
{
nsCOMPtr<nsIDOMNode> newNode;
result = CreateNode(GetTextNodeTag(), selectedNode, offset+1,getter_AddRefs(newNode));
@ -3783,8 +3783,8 @@ nsEditor::SetInputMethodText(const nsString& aStringToInsert,nsIDOMTextRangeList
{
nsAutoString placeholderText(" ");
newTextNode->SetData(placeholderText);
selection->Collapse(newNode, 0, SELECTION_NORMAL);
selection->Extend(newNode, 1, SELECTION_NORMAL);
selection->Collapse(newNode, 0);
selection->Extend(newNode, 1);
result = SetInputMethodText(aStringToInsert,aTextRangeList);
}
}
@ -4196,7 +4196,7 @@ nsEditor::GetStartNodeAndOffset(nsIDOMSelection *aSelection,
nsCOMPtr<nsIEnumerator> enumerator;
nsresult result;
result = aSelection->GetEnumerator(SELECTION_NORMAL, getter_AddRefs(enumerator));
result = aSelection->GetEnumerator(getter_AddRefs(enumerator));
if (NS_FAILED(result) || !enumerator)
return NS_ERROR_FAILURE;
@ -4231,7 +4231,7 @@ nsEditor::GetEndNodeAndOffset(nsIDOMSelection *aSelection,
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIEnumerator> enumerator;
nsresult result = aSelection->GetEnumerator(SELECTION_NORMAL, getter_AddRefs(enumerator));
nsresult result = aSelection->GetEnumerator(getter_AddRefs(enumerator));
if (NS_FAILED(result) || !enumerator)
return NS_ERROR_FAILURE;
@ -4575,10 +4575,10 @@ nsAutoSelectionReset::nsAutoSelectionReset(nsIDOMSelection *aSel)
mSel = do_QueryInterface(aSel);
if (mSel)
{
mSel->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(mStartNode));
mSel->GetAnchorOffset(SELECTION_NORMAL, &mStartOffset);
mSel->GetFocusNode(SELECTION_NORMAL, getter_AddRefs(mEndNode));
mSel->GetFocusOffset(SELECTION_NORMAL, &mEndOffset);
mSel->GetAnchorNode(getter_AddRefs(mStartNode));
mSel->GetAnchorOffset(&mStartOffset);
mSel->GetFocusNode(getter_AddRefs(mEndNode));
mSel->GetFocusOffset(&mEndOffset);
if (mStartNode && mEndNode)
mInitialized = PR_TRUE;
}
@ -4589,8 +4589,8 @@ nsAutoSelectionReset::~nsAutoSelectionReset()
if (mSel && mInitialized)
{
// restore original selection
mSel->Collapse(mStartNode, mStartOffset, SELECTION_NORMAL);
mSel->Extend(mEndNode, mEndOffset, SELECTION_NORMAL);
mSel->Collapse(mStartNode, mStartOffset);
mSel->Extend(mEndNode, mEndOffset);
}
}

Просмотреть файл

@ -112,10 +112,10 @@ nsresult TextEditorTest::TestInsertBreak()
TEST_RESULT(result);
TEST_POINTER(selection.get());
nsCOMPtr<nsIDOMNode>anchor;
result = selection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(anchor));
result = selection->GetAnchorNode(getter_AddRefs(anchor));
TEST_RESULT(result);
TEST_POINTER(anchor.get());
selection->Collapse(anchor, 0, SELECTION_NORMAL);
selection->Collapse(anchor, 0);
// insert one break
printf("inserting a break\n");
result = mTextEditor->InsertBreak();
@ -160,8 +160,8 @@ nsresult TextEditorTest::TestTextProperties()
textData = do_QueryInterface(textNode);
PRUint32 length;
textData->GetLength(&length);
selection->Collapse(textNode, 0, SELECTION_NORMAL);
selection->Extend(textNode, length, SELECTION_NORMAL);
selection->Collapse(textNode, 0);
selection->Extend(textNode, length);
PRBool any = PR_FALSE;
PRBool all = PR_FALSE;
PRBool first=PR_FALSE;
@ -192,8 +192,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_NORMAL);
selection->Extend(textNode, length-1, SELECTION_NORMAL);
selection->Collapse(textNode, 1);
selection->Extend(textNode, length-1);
result = mTextEditor->SetTextProperty(nsIEditProperty::b, nsnull, nsnull);
TEST_RESULT(result);
result = mTextEditor->GetTextProperty(nsIEditProperty::b, nsnull, nsnull, first, any, all);
@ -229,8 +229,8 @@ nsresult TextEditorTest::TestTextProperties()
textData = do_QueryInterface(textNode);
textData->GetLength(&length);
NS_ASSERTION(length==249, "wrong text node");
selection->Collapse(textNode, 1, SELECTION_NORMAL);
selection->Extend(textNode, length-2, SELECTION_NORMAL);
selection->Collapse(textNode, 1);
selection->Extend(textNode, length-2);
result = mTextEditor->SetTextProperty(nsIEditProperty::u, nsnull, nsnull);
TEST_RESULT(result);
result = mTextEditor->GetTextProperty(nsIEditProperty::u, nsnull, nsnull, first, any, all);

Просмотреть файл

@ -224,7 +224,7 @@ nsHTMLEditRules::WillInsertBreak(nsIDOMSelection *aSelection, PRBool *aCancel)
// if the selection isn't collapsed, delete it.
PRBool bCollapsed;
res = aSelection->GetIsCollapsed(SELECTION_NORMAL, &bCollapsed);
res = aSelection->GetIsCollapsed(&bCollapsed);
if (NS_FAILED(res)) return res;
if (!bCollapsed)
{
@ -293,7 +293,7 @@ nsHTMLEditRules::WillDeleteSelection(nsIDOMSelection *aSelection, nsIEditor::ECo
nsresult res = NS_OK;
PRBool bCollapsed;
res = aSelection->GetIsCollapsed(SELECTION_NORMAL, &bCollapsed);
res = aSelection->GetIsCollapsed(&bCollapsed);
if (NS_FAILED(res)) return res;
nsCOMPtr<nsIDOMNode> node;
@ -1292,7 +1292,7 @@ nsHTMLEditRules::GetPromotedRanges(nsIDOMSelection *inSelection,
if (NS_FAILED(res)) return res;
PRInt32 rangeCount;
res = inSelection->GetRangeCount(SELECTION_NORMAL, &rangeCount);
res = inSelection->GetRangeCount(&rangeCount);
if (NS_FAILED(res)) return res;
PRInt32 i;
@ -1303,7 +1303,7 @@ nsHTMLEditRules::GetPromotedRanges(nsIDOMSelection *inSelection,
for (i = 0; i < rangeCount; i++)
{
res = inSelection->GetRangeAt(i, SELECTION_NORMAL, getter_AddRefs(selectionRange));
res = inSelection->GetRangeAt(i, getter_AddRefs(selectionRange));
if (NS_FAILED(res)) return res;
res = selectionRange->GetStartParent(getter_AddRefs(startNode));
if (NS_FAILED(res)) return res;
@ -1713,7 +1713,7 @@ nsHTMLEditRules::ReturnInHeader(nsIDOMSelection *aSelection,
}
// position selection before inserted node
res = aSelection->Collapse(textNode,0, SELECTION_NORMAL);
res = aSelection->Collapse(textNode,0);
return res;
}
@ -1825,7 +1825,7 @@ nsHTMLEditRules::ReturnInListItem(nsIDOMSelection *aSelection,
nsresult res = mEditor->SplitNodeDeep( aListItem, aNode, aOffset);
if (NS_FAILED(res)) return res;
res = aSelection->Collapse(aNode,0, SELECTION_NORMAL);
res = aSelection->Collapse(aNode,0);
return res;
}

Просмотреть файл

@ -272,12 +272,12 @@ NS_IMETHODIMP nsHTMLEditor::InsertBreak()
nextNode->GetParentNode(getter_AddRefs(parent));
res = GetChildOffset(nextNode, parent, offsetInParent);
if (NS_SUCCEEDED(res)) {
selection->Collapse(parent, offsetInParent+1, SELECTION_NORMAL); // +1 to insert just after the break
selection->Collapse(parent, offsetInParent+1); // +1 to insert just after the break
}
}
else
{
selection->Collapse(nextNode, offsetInParent, SELECTION_NORMAL);
selection->Collapse(nextNode, offsetInParent);
}
}
}
@ -499,7 +499,7 @@ NS_IMETHODIMP nsHTMLEditor::PasteAsCitedQuotation(const nsString& aCitation)
#endif
}
res = selection->Collapse(newNode, 0, SELECTION_NORMAL);
res = selection->Collapse(newNode, 0);
if (NS_FAILED(res))
{
#ifdef DEBUG_akkana
@ -580,7 +580,7 @@ NS_IMETHODIMP nsHTMLEditor::InsertHTML(const nsString& aInputString)
// Get the first range in the selection, for context:
nsCOMPtr<nsIDOMRange> range;
res = selection->GetRangeAt(0, SELECTION_NORMAL, getter_AddRefs(range));
res = selection->GetRangeAt(0, getter_AddRefs(range));
if (NS_FAILED(res))
return res;
@ -618,7 +618,7 @@ NS_IMETHODIMP nsHTMLEditor::InsertHTML(const nsString& aInputString)
// set the selection back there after the insert.
// Unfortunately this doesn't work right yet.
nsCOMPtr<nsIDOMRange> saverange;
res = selection->GetRangeAt(0, SELECTION_NORMAL, getter_AddRefs(saverange));
res = selection->GetRangeAt(0, getter_AddRefs(saverange));
// Insert the node:
res = InsertNode(fragmentAsNode, parentNode, offsetOfNewNode);
@ -631,10 +631,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_NORMAL);
selection->Collapse(parent, offset);
}
else
selection->Collapse(parentNode, 0/*offsetOfNewNode*/, SELECTION_NORMAL);
selection->Collapse(parentNode, 0/*offsetOfNewNode*/);
#else /* INSERT_FRAGMENT_DIRECTLY */
// Loop over the contents of the fragment:
nsCOMPtr<nsIDOMNode> child;
@ -711,7 +711,7 @@ nsHTMLEditor::GetParagraphStyle(nsStringArray *aTagList)
if ((NS_SUCCEEDED(res)) && selection)
{
nsCOMPtr<nsIEnumerator> enumerator;
res = selection->GetEnumerator(SELECTION_NORMAL, getter_AddRefs(enumerator));
res = selection->GetEnumerator(getter_AddRefs(enumerator));
if (NS_SUCCEEDED(res) && enumerator)
{
enumerator->First();
@ -842,7 +842,7 @@ nsHTMLEditor::ReplaceBlockParent(nsString& aParentTag)
// set the block parent for all selected ranges
nsAutoEditBatch beginBatching(this);
nsCOMPtr<nsIEnumerator> enumerator;
res = selection->GetEnumerator(SELECTION_NORMAL, getter_AddRefs(enumerator));
res = selection->GetEnumerator(getter_AddRefs(enumerator));
if (NS_SUCCEEDED(res) && enumerator)
{
enumerator->First();
@ -1233,7 +1233,7 @@ nsHTMLEditor::RemoveParagraphStyle()
nsAutoSelectionReset selectionResetter(selection);
nsAutoEditBatch beginBatching(this);
nsCOMPtr<nsIEnumerator> enumerator;
res = selection->GetEnumerator(SELECTION_NORMAL, getter_AddRefs(enumerator));
res = selection->GetEnumerator(getter_AddRefs(enumerator));
if (NS_SUCCEEDED(res) && enumerator)
{
enumerator->First();
@ -1353,7 +1353,7 @@ nsHTMLEditor::RemoveParent(const nsString &aParentTag)
nsAutoSelectionReset selectionResetter(selection);
nsAutoEditBatch beginBatching(this);
nsCOMPtr<nsIEnumerator> enumerator;
res = selection->GetEnumerator(SELECTION_NORMAL, getter_AddRefs(enumerator));
res = selection->GetEnumerator(getter_AddRefs(enumerator));
if (NS_SUCCEEDED(res) && enumerator)
{
enumerator->First();
@ -1488,7 +1488,7 @@ nsHTMLEditor::Indent(const nsString& aIndent)
nsCOMPtr<nsIDOMNode> node;
PRInt32 offset;
PRBool isCollapsed;
res = selection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed);
res = selection->GetIsCollapsed(&isCollapsed);
if (NS_FAILED(res)) return res;
res = GetStartNodeAndOffset(selection, &node, &offset);
@ -1530,7 +1530,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, SELECTION_NORMAL);
res = selection->Collapse(newBQ,0);
if (NS_FAILED(res)) return res;
nsAutoString theText(" ");
res = InsertText(theText);
@ -1538,7 +1538,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, SELECTION_NORMAL);
res = selection->Collapse(node,0);
if (NS_FAILED(res)) return res;
}
}
@ -1604,7 +1604,7 @@ nsHTMLEditor::InsertList(const nsString& aListType)
if (NS_FAILED(res) || !selection) return res;
PRBool isCollapsed;
res = selection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed);
res = selection->GetIsCollapsed(&isCollapsed);
if (NS_FAILED(res)) return res;
nsCOMPtr<nsIDOMNode> node;
@ -1651,7 +1651,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, SELECTION_NORMAL);
res = selection->Collapse(newItem,0);
if (NS_FAILED(res)) return res;
nsAutoString theText(" ");
res = InsertText(theText);
@ -1659,7 +1659,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, SELECTION_NORMAL);
res = selection->Collapse(node,0);
if (NS_FAILED(res)) return res;
}
@ -1689,7 +1689,7 @@ nsHTMLEditor::InsertLink(nsString& aURL)
return res;
}
PRBool isCollapsed;
res = selection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed);
res = selection->GetIsCollapsed(&isCollapsed);
if (NS_FAILED(res))
isCollapsed = PR_TRUE;
@ -1737,7 +1737,7 @@ nsHTMLEditor::InsertLink(nsString& aURL)
#endif
return res;
}
res = selection->Collapse(newNode, 0, SELECTION_NORMAL);
res = selection->Collapse(newNode, 0);
if (NS_FAILED(res))
{
#ifdef DEBUG_akkana
@ -1857,7 +1857,7 @@ nsHTMLEditor::GetSelectedElement(const nsString& aTagName, nsIDOMElement** aRetu
return res;
PRBool isCollapsed;
selection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed);
selection->GetIsCollapsed(&isCollapsed);
nsCOMPtr<nsIDOMElement> selectedElement;
PRBool bNodeFound = PR_FALSE;
@ -1865,7 +1865,7 @@ nsHTMLEditor::GetSelectedElement(const nsString& aTagName, nsIDOMElement** aRetu
if (!isCollapsed)
{
nsCOMPtr<nsIEnumerator> enumerator;
res = selection->GetEnumerator(SELECTION_NORMAL,getter_AddRefs(enumerator));
res = selection->GetEnumerator(getter_AddRefs(enumerator));
if (NS_SUCCEEDED(res) && enumerator)
{
enumerator->First();
@ -2190,14 +2190,14 @@ nsHTMLEditor::InsertElement(nsIDOMElement* aElement, PRBool aDeleteSelection)
if (collapseAfter)
{
// Default behavior is to collapse to the end of the selection
selection->ClearSelection(SELECTION_NORMAL);
selection->ClearSelection();
} 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<nsIDOMRange> firstRange;
res = selection->GetRangeAt(0, SELECTION_NORMAL, getter_AddRefs(firstRange));
res = selection->GetRangeAt(0, getter_AddRefs(firstRange));
if (NS_SUCCEEDED(res) && firstRange)
{
nsCOMPtr<nsIDOMNode> parent;
@ -2206,10 +2206,10 @@ nsHTMLEditor::InsertElement(nsIDOMElement* aElement, PRBool aDeleteSelection)
{
PRInt32 startOffset;
firstRange->GetStartOffset(&startOffset);
selection->Collapse(parent, startOffset, SELECTION_NORMAL);
selection->Collapse(parent, startOffset);
} else {
// Very unlikely, but collapse to the end if we failed above
selection->ClearSelection(SELECTION_NORMAL);
selection->ClearSelection();
}
}
}
@ -2378,7 +2378,7 @@ nsHTMLEditor::InsertLinkAroundSelection(nsIDOMElement* aAnchorElement)
goto DELETE_ANCHOR;
PRBool isCollapsed;
res = selection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed);
res = selection->GetIsCollapsed(&isCollapsed);
if (NS_FAILED(res))
isCollapsed = PR_TRUE;
@ -2470,9 +2470,9 @@ nsHTMLEditor::SelectElement(nsIDOMElement* aElement)
if (NS_SUCCEEDED(res))
{
// Collapse selection to just before desired element,
selection->Collapse(parent, offsetInParent, SELECTION_NORMAL);
selection->Collapse(parent, offsetInParent);
// then extend it to just after
selection->Extend(parent, offsetInParent+1, SELECTION_NORMAL);
selection->Extend(parent, offsetInParent+1);
}
}
}
@ -2542,7 +2542,7 @@ nsHTMLEditor::SetCaretInTableCell(nsIDOMElement* aElement, PRBool* caretIsSet)
res = nsEditor::GetSelection(getter_AddRefs(selection));
if (NS_SUCCEEDED(res) && selection)
{
res = selection->Collapse(parent, offset, SELECTION_NORMAL);
res = selection->Collapse(parent, offset);
if (NS_SUCCEEDED(res) && caretIsSet)
*caretIsSet = PR_TRUE;
}
@ -2581,7 +2581,7 @@ nsHTMLEditor::SetCaretAfterElement(nsIDOMElement* aElement)
if (NS_SUCCEEDED(res))
{
// Collapse selection to just after desired element,
selection->Collapse(parent, offsetInParent+1, SELECTION_NORMAL);
selection->Collapse(parent, offsetInParent+1);
}
}
}

Просмотреть файл

@ -865,7 +865,7 @@ nsTextEditorMouseListener::MouseDown(nsIDOMEvent* aMouseEvent)
nsCOMPtr<nsIDOMSelection> selection;
if (NS_SUCCEEDED(editor->GetSelection(getter_AddRefs(selection))))
(void)selection->Collapse(parent, offset, SELECTION_NORMAL);
(void)selection->Collapse(parent, offset);
// 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.

Просмотреть файл

@ -35,7 +35,6 @@
#include "nsIEditProperty.h"
static NS_DEFINE_CID(kCContentIteratorCID, NS_CONTENTITERATOR_CID);
static NS_DEFINE_IID(kRangeListCID, NS_RANGELIST_CID);
#define CANCEL_OPERATION_IF_READONLY_OR_DISABLED \
if (mFlags & TEXT_EDITOR_FLAG_READONLY || mFlags & TEXT_EDITOR_FLAG_DISABLED) \
@ -195,7 +194,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(SELECTION_NORMAL);
aSelection->ClearSelection();
}
return NS_OK;
@ -338,8 +337,8 @@ nsTextEditRules::CreateStyleForInsertText(nsIDOMSelection *aSelection, TypeInSta
// Otherwise, create the text node and the new inline style parents.
nsCOMPtr<nsIDOMNode>anchor;
PRInt32 offset;
nsresult result = aSelection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(anchor));
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(SELECTION_NORMAL, &offset)) && anchor)
nsresult result = aSelection->GetAnchorNode( getter_AddRefs(anchor));
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(&offset)) && anchor)
{
nsCOMPtr<nsIDOMCharacterData>anchorAsText;
anchorAsText = do_QueryInterface(anchor);
@ -526,7 +525,7 @@ nsTextEditRules::InsertStyleNode(nsIDOMNode *aNode,
result = mEditor->InsertNode(aNode, *aNewNode, 0);
if (NS_SUCCEEDED(result)) {
if (aSelection) {
aSelection->Collapse(aNode, 0, SELECTION_NORMAL);
aSelection->Collapse(aNode, 0);
}
}
}
@ -547,8 +546,8 @@ nsTextEditRules::InsertStyleAndNewTextNode(nsIDOMNode *aParentNode, nsIAtom *aTa
{
nsCOMPtr<nsIDOMNode>anchor;
PRInt32 offset;
result = aSelection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(anchor));
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(SELECTION_NORMAL, &offset)) && anchor)
result = aSelection->GetAnchorNode(getter_AddRefs(anchor));
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(&offset)) && anchor)
{
nsCOMPtr<nsIDOMCharacterData>anchorAsText;
anchorAsText = do_QueryInterface(anchor);
@ -572,7 +571,7 @@ nsTextEditRules::InsertStyleAndNewTextNode(nsIDOMNode *aParentNode, nsIAtom *aTa
if (NS_SUCCEEDED(result))
{
if (aSelection) {
aSelection->Collapse(newTextNode, 0, SELECTION_NORMAL);
aSelection->Collapse(newTextNode, 0);
}
}
}
@ -667,7 +666,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(SELECTION_NORMAL, &isCollapsed);
aSelection->GetIsCollapsed(&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 &nbsp; character in it.
@ -679,8 +678,8 @@ nsTextEditRules::DidDeleteSelection(nsIDOMSelection *aSelection,
{
nsCOMPtr<nsIDOMNode>anchor;
PRInt32 offset;
result = aSelection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(anchor));
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(SELECTION_NORMAL, &offset)) && anchor)
result = aSelection->GetAnchorNode(getter_AddRefs(anchor));
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(&offset)) && anchor)
{
nsCOMPtr<nsIDOMNodeList> anchorChildren;
result = anchor->GetChildNodes(getter_AddRefs(anchorChildren));
@ -727,7 +726,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, SELECTION_NORMAL);
aSelection->Collapse(siblingNode, selectedNodeLength);
}
}
}
@ -767,8 +766,8 @@ nsTextEditRules:: DidUndo(nsIDOMSelection *aSelection, nsresult aResult)
{
nsCOMPtr<nsIDOMNode>node;
PRInt32 offset;
result = aSelection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(node));
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(SELECTION_NORMAL, &offset)) && node)
result = aSelection->GetAnchorNode(getter_AddRefs(node));
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(&offset)) && node)
{
nsCOMPtr<nsIDOMElement>element;
element = do_QueryInterface(node);
@ -814,8 +813,8 @@ nsTextEditRules::DidRedo(nsIDOMSelection *aSelection, nsresult aResult)
{
nsCOMPtr<nsIDOMNode>node;
PRInt32 offset;
result = aSelection->GetAnchorNode(SELECTION_NORMAL, getter_AddRefs(node));
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(SELECTION_NORMAL, &offset)) && node)
result = aSelection->GetAnchorNode(getter_AddRefs(node));
if (NS_SUCCEEDED(result) && NS_SUCCEEDED(aSelection->GetAnchorOffset(&offset)) && node)
{
nsCOMPtr<nsIDOMElement>element;
element = do_QueryInterface(node);
@ -917,7 +916,7 @@ nsTextEditRules::CreateBogusNodeIfNeeded(nsIDOMSelection *aSelection)
nsAutoString data;
data += 160;
newNodeAsText->SetData(data);
aSelection->Collapse(newTNode, 0, SELECTION_NORMAL);
aSelection->Collapse(newTNode, 0);
}
}
// make sure we know the PNode is bogus
@ -966,7 +965,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, SELECTION_NORMAL, getter_AddRefs(selectionRange));
res = aSelection->GetRangeAt(0, getter_AddRefs(selectionRange));
if (NS_FAILED(res)) return res;
res = selectionRange->Clone(getter_AddRefs(pinRange));
if (NS_FAILED(res)) return res;
@ -1020,9 +1019,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, SELECTION_NORMAL);
res = aSelection->Collapse(startNode,startOffset);
if (NS_FAILED(res)) return res;
res = aSelection->Extend(endNode,endOffset, SELECTION_NORMAL);
res = aSelection->Extend(endNode,endOffset);
if (NS_FAILED(res)) return res;
}

Просмотреть файл

@ -568,7 +568,7 @@ nsTextServicesDocument::FirstSelectedBlock(TSDBlockSelectionStatus *aSelStatus,
nsCOMPtr<nsIDOMSelection> selection;
PRBool isCollapsed = PR_FALSE;
result = mPresShell->GetSelection(getter_AddRefs(selection));
result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if (NS_FAILED(result))
{
@ -576,7 +576,7 @@ nsTextServicesDocument::FirstSelectedBlock(TSDBlockSelectionStatus *aSelStatus,
return result;
}
result = selection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed);
result = selection->GetIsCollapsed( &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, SELECTION_NORMAL, getter_AddRefs(range));
result = selection->GetRangeAt(0, 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(SELECTION_NORMAL, &rangeCount);
result = selection->GetRangeCount(&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, SELECTION_NORMAL, getter_AddRefs(range));
result = selection->GetRangeAt(i, 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, SELECTION_NORMAL, getter_AddRefs(range));
result = selection->GetRangeAt(0, getter_AddRefs(range));
if (NS_FAILED(result))
{
@ -1050,7 +1050,7 @@ nsTextServicesDocument::LastSelectedBlock(TSDBlockSelectionStatus *aSelStatus, P
nsCOMPtr<nsIDOMSelection> selection;
PRBool isCollapsed = PR_FALSE;
result = mPresShell->GetSelection(getter_AddRefs(selection));
result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if (NS_FAILED(result))
{
@ -1058,7 +1058,7 @@ nsTextServicesDocument::LastSelectedBlock(TSDBlockSelectionStatus *aSelStatus, P
return result;
}
result = selection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed);
result = selection->GetIsCollapsed(&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, SELECTION_NORMAL, getter_AddRefs(range));
result = selection->GetRangeAt(0, 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(SELECTION_NORMAL, &rangeCount);
result = selection->GetRangeCount(&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, SELECTION_NORMAL, getter_AddRefs(range));
result = selection->GetRangeAt(i, 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, SELECTION_NORMAL, getter_AddRefs(range));
result = selection->GetRangeAt(rangeCount - 1, getter_AddRefs(range));
if (NS_FAILED(result))
{
@ -2072,7 +2072,7 @@ nsTextServicesDocument::InsertText(const nsString *aText)
mSelStartIndex = mSelEndIndex = i;
result = mPresShell->GetSelection(getter_AddRefs(selection));
result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if (NS_FAILED(result))
{
@ -2081,7 +2081,7 @@ nsTextServicesDocument::InsertText(const nsString *aText)
return result;
}
result = selection->Collapse(itEntry->mNode, itEntry->mNodeOffset + itEntry->mLength, SELECTION_NORMAL);
result = selection->Collapse(itEntry->mNode, itEntry->mNodeOffset + itEntry->mLength);
if (NS_FAILED(result))
{
@ -2946,12 +2946,12 @@ nsTextServicesDocument::SetSelectionInternal(PRInt32 aOffset, PRInt32 aLength, P
if (aDoUpdate)
{
result = mPresShell->GetSelection(getter_AddRefs(selection));
result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if (NS_FAILED(result))
return result;
result = selection->Collapse(sNode, sOffset, SELECTION_NORMAL);
result = selection->Collapse(sNode, sOffset);
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, SELECTION_NORMAL);
result = selection->Extend(eNode, eOffset);
if (NS_FAILED(result))
return result;
@ -3042,7 +3042,7 @@ nsTextServicesDocument::GetSelection(nsITextServicesDocument::TSDBlockSelectionS
nsCOMPtr<nsIDOMSelection> selection;
PRBool isCollapsed;
result = mPresShell->GetSelection(getter_AddRefs(selection));
result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if (NS_FAILED(result))
return result;
@ -3050,7 +3050,7 @@ nsTextServicesDocument::GetSelection(nsITextServicesDocument::TSDBlockSelectionS
if (!selection)
return NS_ERROR_FAILURE;
result = selection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed);
result = selection->GetIsCollapsed(&isCollapsed);
if (NS_FAILED(result))
return result;
@ -3076,7 +3076,7 @@ nsTextServicesDocument::GetCollapsedSelection(nsITextServicesDocument::TSDBlockS
nsresult result;
nsCOMPtr<nsIDOMSelection> selection;
result = mPresShell->GetSelection(getter_AddRefs(selection));
result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
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, SELECTION_NORMAL, getter_AddRefs(range));
result = selection->GetRangeAt(0, getter_AddRefs(range));
if (NS_FAILED(result))
return result;
@ -3401,7 +3401,7 @@ nsTextServicesDocument::GetUncollapsedSelection(nsITextServicesDocument::TSDBloc
nsCOMPtr<nsIDOMRange> range;
OffsetEntry *entry;
result = mPresShell->GetSelection(getter_AddRefs(selection));
result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
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(SELECTION_NORMAL, &rangeCount);
result = selection->GetRangeCount(&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, SELECTION_NORMAL, getter_AddRefs(range));
result = selection->GetRangeAt(i, getter_AddRefs(range));
if (NS_FAILED(result))
return result;

Просмотреть файл

@ -568,7 +568,7 @@ nsTextServicesDocument::FirstSelectedBlock(TSDBlockSelectionStatus *aSelStatus,
nsCOMPtr<nsIDOMSelection> selection;
PRBool isCollapsed = PR_FALSE;
result = mPresShell->GetSelection(getter_AddRefs(selection));
result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if (NS_FAILED(result))
{
@ -576,7 +576,7 @@ nsTextServicesDocument::FirstSelectedBlock(TSDBlockSelectionStatus *aSelStatus,
return result;
}
result = selection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed);
result = selection->GetIsCollapsed( &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, SELECTION_NORMAL, getter_AddRefs(range));
result = selection->GetRangeAt(0, 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(SELECTION_NORMAL, &rangeCount);
result = selection->GetRangeCount(&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, SELECTION_NORMAL, getter_AddRefs(range));
result = selection->GetRangeAt(i, 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, SELECTION_NORMAL, getter_AddRefs(range));
result = selection->GetRangeAt(0, getter_AddRefs(range));
if (NS_FAILED(result))
{
@ -1050,7 +1050,7 @@ nsTextServicesDocument::LastSelectedBlock(TSDBlockSelectionStatus *aSelStatus, P
nsCOMPtr<nsIDOMSelection> selection;
PRBool isCollapsed = PR_FALSE;
result = mPresShell->GetSelection(getter_AddRefs(selection));
result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if (NS_FAILED(result))
{
@ -1058,7 +1058,7 @@ nsTextServicesDocument::LastSelectedBlock(TSDBlockSelectionStatus *aSelStatus, P
return result;
}
result = selection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed);
result = selection->GetIsCollapsed(&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, SELECTION_NORMAL, getter_AddRefs(range));
result = selection->GetRangeAt(0, 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(SELECTION_NORMAL, &rangeCount);
result = selection->GetRangeCount(&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, SELECTION_NORMAL, getter_AddRefs(range));
result = selection->GetRangeAt(i, 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, SELECTION_NORMAL, getter_AddRefs(range));
result = selection->GetRangeAt(rangeCount - 1, getter_AddRefs(range));
if (NS_FAILED(result))
{
@ -2072,7 +2072,7 @@ nsTextServicesDocument::InsertText(const nsString *aText)
mSelStartIndex = mSelEndIndex = i;
result = mPresShell->GetSelection(getter_AddRefs(selection));
result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if (NS_FAILED(result))
{
@ -2081,7 +2081,7 @@ nsTextServicesDocument::InsertText(const nsString *aText)
return result;
}
result = selection->Collapse(itEntry->mNode, itEntry->mNodeOffset + itEntry->mLength, SELECTION_NORMAL);
result = selection->Collapse(itEntry->mNode, itEntry->mNodeOffset + itEntry->mLength);
if (NS_FAILED(result))
{
@ -2946,12 +2946,12 @@ nsTextServicesDocument::SetSelectionInternal(PRInt32 aOffset, PRInt32 aLength, P
if (aDoUpdate)
{
result = mPresShell->GetSelection(getter_AddRefs(selection));
result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if (NS_FAILED(result))
return result;
result = selection->Collapse(sNode, sOffset, SELECTION_NORMAL);
result = selection->Collapse(sNode, sOffset);
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, SELECTION_NORMAL);
result = selection->Extend(eNode, eOffset);
if (NS_FAILED(result))
return result;
@ -3042,7 +3042,7 @@ nsTextServicesDocument::GetSelection(nsITextServicesDocument::TSDBlockSelectionS
nsCOMPtr<nsIDOMSelection> selection;
PRBool isCollapsed;
result = mPresShell->GetSelection(getter_AddRefs(selection));
result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
if (NS_FAILED(result))
return result;
@ -3050,7 +3050,7 @@ nsTextServicesDocument::GetSelection(nsITextServicesDocument::TSDBlockSelectionS
if (!selection)
return NS_ERROR_FAILURE;
result = selection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed);
result = selection->GetIsCollapsed(&isCollapsed);
if (NS_FAILED(result))
return result;
@ -3076,7 +3076,7 @@ nsTextServicesDocument::GetCollapsedSelection(nsITextServicesDocument::TSDBlockS
nsresult result;
nsCOMPtr<nsIDOMSelection> selection;
result = mPresShell->GetSelection(getter_AddRefs(selection));
result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
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, SELECTION_NORMAL, getter_AddRefs(range));
result = selection->GetRangeAt(0, getter_AddRefs(range));
if (NS_FAILED(result))
return result;
@ -3401,7 +3401,7 @@ nsTextServicesDocument::GetUncollapsedSelection(nsITextServicesDocument::TSDBloc
nsCOMPtr<nsIDOMRange> range;
OffsetEntry *entry;
result = mPresShell->GetSelection(getter_AddRefs(selection));
result = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection));
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(SELECTION_NORMAL, &rangeCount);
result = selection->GetRangeCount(&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, SELECTION_NORMAL, getter_AddRefs(range));
result = selection->GetRangeAt(i, getter_AddRefs(range));
if (NS_FAILED(result))
return result;

Просмотреть файл

@ -95,7 +95,7 @@ NS_IMETHODIMP nsCaret::Init(nsIPresShell *inPresShell)
// listener
nsCOMPtr<nsIDOMSelection> domSelection;
if (NS_SUCCEEDED(mPresShell->GetSelection(getter_AddRefs(domSelection))))
if (NS_SUCCEEDED(mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(domSelection))))
{
domSelection->AddSelectionListener(this);
}
@ -187,7 +187,7 @@ NS_IMETHODIMP nsCaret::GetWindowRelativeCoordinates(nsPoint& outCoordinates, PRB
return NS_ERROR_NOT_INITIALIZED;
nsCOMPtr<nsIDOMSelection> domSelection;
nsresult err = mPresShell->GetSelection(getter_AddRefs(domSelection));
nsresult err = mPresShell->GetSelection(SELECTION_NORMAL,getter_AddRefs(domSelection));
if (NS_FAILED(err))
return err;
@ -199,21 +199,21 @@ NS_IMETHODIMP nsCaret::GetWindowRelativeCoordinates(nsPoint& outCoordinates, PRB
outCoordinates.y = -1;
outIsCollapsed = PR_FALSE;
err = domSelection->GetIsCollapsed(SELECTION_NORMAL, &outIsCollapsed);
err = domSelection->GetIsCollapsed(&outIsCollapsed);
if (NS_FAILED(err))
return err;
// code in progress
nsCOMPtr<nsIDOMNode> focusNode;
err = domSelection->GetFocusNode(SELECTION_NORMAL, getter_AddRefs(focusNode));
err = domSelection->GetFocusNode(getter_AddRefs(focusNode));
if (NS_FAILED(err))
return err;
if (!focusNode)
return NS_ERROR_FAILURE;
PRInt32 focusOffset;
err = domSelection->GetFocusOffset(SELECTION_NORMAL, &focusOffset);
err = domSelection->GetFocusOffset(&focusOffset);
if (NS_FAILED(err))
return err;
@ -411,20 +411,20 @@ PRBool nsCaret::SetupDrawingFrameAndOffset()
}
nsCOMPtr<nsIDOMSelection> domSelection;
nsresult err = mPresShell->GetSelection(getter_AddRefs(domSelection));
nsresult err = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(domSelection));
if (!NS_SUCCEEDED(err) || !domSelection)
return PR_FALSE;
PRBool isCollapsed;
if (domSelection && NS_SUCCEEDED(domSelection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed)) && isCollapsed)
if (domSelection && NS_SUCCEEDED(domSelection->GetIsCollapsed(&isCollapsed)) && isCollapsed)
{
// start and end parent should be the same since we are collapsed
nsCOMPtr<nsIDOMNode> focusNode;
PRInt32 contentOffset;
if (NS_SUCCEEDED(domSelection->GetFocusNode(SELECTION_NORMAL, getter_AddRefs(focusNode))) && focusNode &&
NS_SUCCEEDED(domSelection->GetFocusOffset(SELECTION_NORMAL, &contentOffset)))
if (NS_SUCCEEDED(domSelection->GetFocusNode(getter_AddRefs(focusNode))) && focusNode &&
NS_SUCCEEDED(domSelection->GetFocusOffset(&contentOffset)))
{
nsCOMPtr<nsIContent>contentNode = do_QueryInterface(focusNode);

Просмотреть файл

@ -123,6 +123,12 @@ public:
*/
NS_IMETHOD GetMouseDownState(PRBool *aState)=0;
/** GetSelection
* no query interface for selection. must use this method now.
* @param aSelectionType enum value defined in nsIDOMSelection for the domseleciton you want.
*/
NS_IMETHOD GetSelection(SelectionType aSelectionType, nsIDOMSelection **aDomSelection)=0;
};

Просмотреть файл

@ -21,6 +21,7 @@
#include "nslayout.h"
#include "nsISupports.h"
#include "nsCoord.h"
#include "nsIDomSelection.h"
class nsIContent;
class nsIDocument;
@ -33,11 +34,11 @@ class nsIReflowCommand;
class nsIDeviceContext;
class nsIRenderingContext;
class nsIPageSequenceFrame;
class nsIDOMSelection;
class nsString;
class nsStringArray;
class nsICaret;
class nsIStyleContext;
class nsIFrameSelection;
#define NS_IPRESSHELL_IID \
{ 0x76e79c60, 0x944e, 0x11d1, \
@ -94,7 +95,13 @@ public:
*
* @param aSelection will hold the return value
*/
NS_IMETHOD GetSelection(nsIDOMSelection** aSelection) = 0;
NS_IMETHOD GetSelection(SelectionType aType, nsIDOMSelection** aSelection) = 0;
/**
* GetFrameSelection will return the Frame based selection API you
* cannot go back and forth anymore with QI with nsIDOM sel and nsIFrame sel.
*/
NS_IMETHOD GetFrameSelection(nsIFrameSelection** aSelection) = 0;
NS_IMETHOD EnterReflowLock() = 0;

Просмотреть файл

@ -216,7 +216,7 @@ FrameHashTable::Dump(FILE* fp)
// Class IID's
static NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
static NS_DEFINE_IID(kRangeListCID, NS_RANGELIST_CID);
static NS_DEFINE_IID(kFrameSelectionCID, NS_FRAMESELECTION_CID);
static NS_DEFINE_IID(kCRangeCID, NS_RANGE_CID);
// IID's
@ -267,7 +267,9 @@ public:
NS_IMETHOD GetActiveAlternateStyleSheet(nsString& aSheetTitle);
NS_IMETHOD SelectAlternateStyleSheet(const nsString& aSheetTitle);
NS_IMETHOD ListAlternateStyleSheets(nsStringArray& aTitleList);
NS_IMETHOD GetSelection(nsIDOMSelection** aSelection);
NS_IMETHOD GetSelection(SelectionType aType, nsIDOMSelection** aSelection);
NS_IMETHOD GetFrameSelection(nsIFrameSelection** aSelection);
NS_IMETHOD EnterReflowLock();
NS_IMETHOD ExitReflowLock();
NS_IMETHOD BeginObservingDocument();
@ -649,18 +651,15 @@ PresShell::Init(nsIDocument* aDocument,
mStyleSet = dont_QueryInterface(aStyleSet);
nsCOMPtr<nsIDOMSelection>domselection;
nsresult result = nsComponentManager::CreateInstance(kRangeListCID, nsnull,
kIDOMSelectionIID,
getter_AddRefs(domselection));
nsresult result = nsComponentManager::CreateInstance(kFrameSelectionCID, nsnull,
nsIFrameSelection::GetIID(),
getter_AddRefs(mSelection));
if (!NS_SUCCEEDED(result))
return result;
result = domselection->QueryInterface(kIFrameSelectionIID,
getter_AddRefs(mSelection));
if (!NS_SUCCEEDED(result))
return result;
domselection->AddSelectionListener(this);//possible circular reference
nsCOMPtr<nsIDOMSelection> domSelection;
mSelection->GetSelection(SELECTION_NORMAL, getter_AddRefs(domSelection));
domSelection->AddSelectionListener(this);//possible circular reference
result = mSelection->Init((nsIFocusTracker *) this);
if (!NS_SUCCEEDED(result))
@ -876,13 +875,22 @@ PresShell::ListAlternateStyleSheets(nsStringArray& aTitleList)
}
NS_IMETHODIMP
PresShell::GetSelection(nsIDOMSelection **aSelection)
PresShell::GetSelection(SelectionType aType, nsIDOMSelection **aSelection)
{
if (!aSelection || !mSelection)
return NS_ERROR_NULL_POINTER;
return mSelection->QueryInterface(kIDOMSelectionIID,(void **)aSelection);
return mSelection->GetSelection(aType, aSelection);
}
NS_IMETHODIMP
PresShell::GetFrameSelection(nsIFrameSelection** aSelection)
{
if (!aSelection || !mSelection)
return NS_ERROR_NULL_POINTER;
*aSelection = mSelection;
(*aSelection)->AddRef();
return NS_OK;
}
// Make shell be a document observer
@ -1702,7 +1710,7 @@ PresShell::DoCopy()
nsString buffer;
nsIDOMSelection* sel = nsnull;
GetSelection(&sel);
GetSelection(SELECTION_NORMAL, &sel);
if (sel != nsnull)
doc->CreateXIF(buffer,sel);

Просмотреть файл

@ -123,6 +123,12 @@ public:
*/
NS_IMETHOD GetMouseDownState(PRBool *aState)=0;
/** GetSelection
* no query interface for selection. must use this method now.
* @param aSelectionType enum value defined in nsIDOMSelection for the domseleciton you want.
*/
NS_IMETHOD GetSelection(SelectionType aSelectionType, nsIDOMSelection **aDomSelection)=0;
};

Просмотреть файл

@ -21,6 +21,7 @@
#include "nslayout.h"
#include "nsISupports.h"
#include "nsCoord.h"
#include "nsIDomSelection.h"
class nsIContent;
class nsIDocument;
@ -33,11 +34,11 @@ class nsIReflowCommand;
class nsIDeviceContext;
class nsIRenderingContext;
class nsIPageSequenceFrame;
class nsIDOMSelection;
class nsString;
class nsStringArray;
class nsICaret;
class nsIStyleContext;
class nsIFrameSelection;
#define NS_IPRESSHELL_IID \
{ 0x76e79c60, 0x944e, 0x11d1, \
@ -94,7 +95,13 @@ public:
*
* @param aSelection will hold the return value
*/
NS_IMETHOD GetSelection(nsIDOMSelection** aSelection) = 0;
NS_IMETHOD GetSelection(SelectionType aType, nsIDOMSelection** aSelection) = 0;
/**
* GetFrameSelection will return the Frame based selection API you
* cannot go back and forth anymore with QI with nsIDOM sel and nsIFrame sel.
*/
NS_IMETHOD GetFrameSelection(nsIFrameSelection** aSelection) = 0;
NS_IMETHOD EnterReflowLock() = 0;

Просмотреть файл

@ -95,7 +95,7 @@ NS_IMETHODIMP nsCaret::Init(nsIPresShell *inPresShell)
// listener
nsCOMPtr<nsIDOMSelection> domSelection;
if (NS_SUCCEEDED(mPresShell->GetSelection(getter_AddRefs(domSelection))))
if (NS_SUCCEEDED(mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(domSelection))))
{
domSelection->AddSelectionListener(this);
}
@ -187,7 +187,7 @@ NS_IMETHODIMP nsCaret::GetWindowRelativeCoordinates(nsPoint& outCoordinates, PRB
return NS_ERROR_NOT_INITIALIZED;
nsCOMPtr<nsIDOMSelection> domSelection;
nsresult err = mPresShell->GetSelection(getter_AddRefs(domSelection));
nsresult err = mPresShell->GetSelection(SELECTION_NORMAL,getter_AddRefs(domSelection));
if (NS_FAILED(err))
return err;
@ -199,21 +199,21 @@ NS_IMETHODIMP nsCaret::GetWindowRelativeCoordinates(nsPoint& outCoordinates, PRB
outCoordinates.y = -1;
outIsCollapsed = PR_FALSE;
err = domSelection->GetIsCollapsed(SELECTION_NORMAL, &outIsCollapsed);
err = domSelection->GetIsCollapsed(&outIsCollapsed);
if (NS_FAILED(err))
return err;
// code in progress
nsCOMPtr<nsIDOMNode> focusNode;
err = domSelection->GetFocusNode(SELECTION_NORMAL, getter_AddRefs(focusNode));
err = domSelection->GetFocusNode(getter_AddRefs(focusNode));
if (NS_FAILED(err))
return err;
if (!focusNode)
return NS_ERROR_FAILURE;
PRInt32 focusOffset;
err = domSelection->GetFocusOffset(SELECTION_NORMAL, &focusOffset);
err = domSelection->GetFocusOffset(&focusOffset);
if (NS_FAILED(err))
return err;
@ -411,20 +411,20 @@ PRBool nsCaret::SetupDrawingFrameAndOffset()
}
nsCOMPtr<nsIDOMSelection> domSelection;
nsresult err = mPresShell->GetSelection(getter_AddRefs(domSelection));
nsresult err = mPresShell->GetSelection(SELECTION_NORMAL, getter_AddRefs(domSelection));
if (!NS_SUCCEEDED(err) || !domSelection)
return PR_FALSE;
PRBool isCollapsed;
if (domSelection && NS_SUCCEEDED(domSelection->GetIsCollapsed(SELECTION_NORMAL, &isCollapsed)) && isCollapsed)
if (domSelection && NS_SUCCEEDED(domSelection->GetIsCollapsed(&isCollapsed)) && isCollapsed)
{
// start and end parent should be the same since we are collapsed
nsCOMPtr<nsIDOMNode> focusNode;
PRInt32 contentOffset;
if (NS_SUCCEEDED(domSelection->GetFocusNode(SELECTION_NORMAL, getter_AddRefs(focusNode))) && focusNode &&
NS_SUCCEEDED(domSelection->GetFocusOffset(SELECTION_NORMAL, &contentOffset)))
if (NS_SUCCEEDED(domSelection->GetFocusNode(getter_AddRefs(focusNode))) && focusNode &&
NS_SUCCEEDED(domSelection->GetFocusOffset(&contentOffset)))
{
nsCOMPtr<nsIContent>contentNode = do_QueryInterface(focusNode);

Просмотреть файл

@ -99,7 +99,6 @@ static NS_DEFINE_IID(kIDocumentObserverIID, NS_IDOCUMENT_OBSERVER_IID);
static NS_DEFINE_IID(kICSSStyleSheetIID, NS_ICSS_STYLE_SHEET_IID);
static NS_DEFINE_IID(kCRangeCID, NS_RANGE_CID);
static NS_DEFINE_IID(kIDOMRange, NS_IDOMRANGE_IID);
static NS_DEFINE_IID(kCRangeListCID, NS_RANGELIST_CID);
static NS_DEFINE_IID(kIEnumeratorIID, NS_IENUMERATOR_IID);
static NS_DEFINE_IID(kIDOMScriptObjectFactoryIID, NS_IDOM_SCRIPT_OBJECT_FACTORY_IID);
static NS_DEFINE_IID(kDOMScriptObjectFactoryCID, NS_DOM_SCRIPT_OBJECT_FACTORY_CID);

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -102,7 +102,7 @@
#define NS_SELECTION_CID \
{ 0x96882b72, 0x8a27, 0x11d2, { 0x8e, 0xaf, 0x0, 0x80, 0x5f, 0x29, 0xf3, 0x70 } }
#define NS_RANGELIST_CID \
#define NS_FRAMESELECTION_CID \
{/* {905F80F1-8A7B-11d2-918C-0080C8E44DB5}*/ \
0x905f80f1, 0x8a7b, 0x11d2, { 0x91, 0x8c, 0x0, 0x80, 0xc8, 0xe4, 0x4d, 0xb5 } }

Просмотреть файл

@ -47,6 +47,7 @@
#include "nsIHTMLElementFactory.h"
#include "nsIDocumentEncoder.h"
#include "nsCOMPtr.h"
#include "nsIFrameSelection.h"
#include "nsCSSKeywords.h" // to addref/release table
#include "nsCSSProps.h" // to addref/release table
@ -68,7 +69,7 @@ static NS_DEFINE_IID(kHTMLImageElementCID, NS_HTMLIMAGEELEMENT_CID);
static NS_DEFINE_IID(kHTMLOptionElementCID, NS_HTMLOPTIONELEMENT_CID);
static NS_DEFINE_CID(kSelectionCID, NS_SELECTION_CID);
static NS_DEFINE_IID(kRangeListCID, NS_RANGELIST_CID);
static NS_DEFINE_IID(kFrameSelectionCID, NS_FRAMESELECTION_CID);
static NS_DEFINE_IID(kRangeCID, NS_RANGE_CID);
static NS_DEFINE_IID(kContentIteratorCID, NS_CONTENTITERATOR_CID);
static NS_DEFINE_IID(kSubtreeIteratorCID, NS_SUBTREEITERATOR_CID);
@ -85,7 +86,7 @@ static NS_DEFINE_CID(kLayoutDebuggerCID, NS_LAYOUT_DEBUGGER_CID);
static NS_DEFINE_CID(kHTMLElementFactoryCID, NS_HTML_ELEMENT_FACTORY_CID);
static NS_DEFINE_CID(kTextEncoderCID, NS_TEXT_ENCODER_CID);
extern nsresult NS_NewRangeList(nsIDOMSelection** aResult);
extern nsresult NS_NewRangeList(nsIFrameSelection** aResult);
extern nsresult NS_NewRange(nsIDOMRange** aResult);
extern nsresult NS_NewContentIterator(nsIContentIterator** aResult);
extern nsresult NS_NewContentSubtreeIterator(nsIContentIterator** aResult);
@ -264,8 +265,8 @@ nsLayoutFactory::CreateInstance(nsISupports *aOuter,
refCounted = PR_TRUE;
}
#endif
else if (mClassID.Equals(kRangeListCID)) {
res = NS_NewRangeList((nsIDOMSelection**)&inst);
else if (mClassID.Equals(kFrameSelectionCID)) {
res = NS_NewRangeList((nsIFrameSelection**)&inst);
if (NS_FAILED(res)) {
LOG_NEW_FAILURE("NS_NewRangeList", res);
return res;
@ -671,10 +672,10 @@ NSRegisterSelf(nsISupports* aServMgr , const char* aPath)
LOG_REGISTER_FAILURE("kRangeCID", rv);
break;
}
rv = cm->RegisterComponent(kRangeListCID, NULL, NULL, aPath,
rv = cm->RegisterComponent(kFrameSelectionCID, NULL, NULL, aPath,
PR_TRUE, PR_TRUE);
if (NS_FAILED(rv)) {
LOG_REGISTER_FAILURE("kRangeListCID", rv);
LOG_REGISTER_FAILURE("kFrameSelection", rv);
break;
}
rv = cm->RegisterComponent(kContentIteratorCID, NULL, NULL, aPath,
@ -780,7 +781,7 @@ NSUnregisterSelf(nsISupports* aServMgr, const char* aPath)
rv = cm->UnregisterComponent(kTextNodeCID, aPath);
rv = cm->UnregisterComponent(kSelectionCID, aPath);
rv = cm->UnregisterComponent(kRangeCID, aPath);
rv = cm->UnregisterComponent(kRangeListCID, aPath);
rv = cm->UnregisterComponent(kFrameSelectionCID, aPath);
rv = cm->UnregisterComponent(kContentIteratorCID, aPath);
rv = cm->UnregisterComponent(kSubtreeIteratorCID, aPath);
rv = cm->UnregisterComponent(kFrameUtilCID, aPath);

Просмотреть файл

@ -196,12 +196,9 @@ nsEventStateManager::PostHandleEvent(nsIPresContext& aPresContext,
nsCOMPtr<nsIPresShell> shell;
nsresult rv = aPresContext.GetShell(getter_AddRefs(shell));
if (NS_SUCCEEDED(rv) && shell){
nsCOMPtr<nsIDOMSelection> selection;
rv = shell->GetSelection(getter_AddRefs(selection));
if (NS_SUCCEEDED(rv) && selection){
nsCOMPtr<nsIFrameSelection> frameSel;
frameSel = do_QueryInterface(selection);
if (frameSel)
nsCOMPtr<nsIFrameSelection> frameSel;
rv = shell->GetFrameSelection(getter_AddRefs(frameSel));
if (NS_SUCCEEDED(rv) && frameSel){
frameSel->SetMouseDownState(PR_FALSE);
}
}

Просмотреть файл

@ -760,15 +760,10 @@ nsFrame::Paint(nsIPresContext& aPresContext,
}
if (NS_SUCCEEDED(result) && shell){
result = shell->GetSelection(getter_AddRefs(selection));
if (NS_SUCCEEDED(result) && selection){
frameSelection = do_QueryInterface(selection);
nsCOMPtr<nsIContent> content;
result = GetContent(getter_AddRefs(content));
if (NS_SUCCEEDED(result)){
result = frameSelection->LookUpSelection(newContent, offset,
1, &details);// last param notused
}
result = shell->GetFrameSelection(getter_AddRefs(frameSelection));
if (NS_SUCCEEDED(result) && frameSelection){
result = frameSelection->LookUpSelection(newContent, offset,
1, &details);// last param notused
}
}
//}
@ -818,11 +813,8 @@ nsFrame::HandleEvent(nsIPresContext& aPresContext,
nsCOMPtr<nsIPresShell> shell;
nsresult rv = aPresContext.GetShell(getter_AddRefs(shell));
if (NS_SUCCEEDED(rv)){
nsCOMPtr<nsIDOMSelection> selection;
if (NS_SUCCEEDED(shell->GetSelection(getter_AddRefs(selection)))){
nsCOMPtr<nsIFrameSelection> frameselection;
frameselection = do_QueryInterface(selection);
if (frameselection) {
nsCOMPtr<nsIFrameSelection> frameselection;
if (NS_SUCCEEDED(shell->GetFrameSelection(getter_AddRefs(frameselection))) && frameselection){
PRBool mouseDown = PR_FALSE;
if (NS_SUCCEEDED(frameselection->GetMouseDownState(&mouseDown)) && mouseDown) {
@ -865,7 +857,6 @@ nsFrame::HandleEvent(nsIPresContext& aPresContext,
//---------------------------------------------------
#endif
}
}
}
}
@ -903,16 +894,10 @@ nsFrame::HandlePress(nsIPresContext& aPresContext,
nsCOMPtr<nsIContent> newContent;
if (NS_SUCCEEDED(GetPosition(aPresContext, aEvent->point.x, getter_AddRefs(newContent),
startPos, contentOffsetEnd))){
nsCOMPtr<nsIDOMSelection> selection;
if (NS_SUCCEEDED(shell->GetSelection(getter_AddRefs(selection)))){
nsCOMPtr<nsIFrameSelection> frameselection;
frameselection = do_QueryInterface(selection);
if (frameselection) {
if (NS_SUCCEEDED( rv )){
frameselection->SetMouseDownState(PR_TRUE);//not important if it fails here
frameselection->TakeFocus(newContent, startPos , contentOffsetEnd , inputEvent->isShift, inputEvent->isControl);
}
}
nsCOMPtr<nsIFrameSelection> frameselection;
if (NS_SUCCEEDED(shell->GetFrameSelection(getter_AddRefs(frameselection))) && frameselection){
frameselection->SetMouseDownState(PR_TRUE);//not important if it fails here
frameselection->TakeFocus(newContent, startPos , contentOffsetEnd , inputEvent->isShift, inputEvent->isControl);
}
//no release
}
@ -948,16 +933,9 @@ NS_IMETHODIMP nsFrame::HandleDrag(nsIPresContext& aPresContext,
nsCOMPtr<nsIContent> newContent;
if (NS_SUCCEEDED(GetPosition(aPresContext, aEvent->point.x, getter_AddRefs(newContent),
startPos, contentOffsetEnd))){
nsIDOMSelection *selection = nsnull;
if (NS_SUCCEEDED(shell->GetSelection(&selection))){
nsIFrameSelection* frameselection;
if (NS_SUCCEEDED(selection->QueryInterface(kIFrameSelection, (void **)&frameselection))) {
if (NS_SUCCEEDED( rv )){
frameselection->TakeFocus(newContent, startPos, contentOffsetEnd , PR_TRUE, PR_FALSE); //TRUE IS THE DIFFERENCE for continue selection
}
NS_RELEASE(frameselection);
}
NS_RELEASE(selection);
nsCOMPtr<nsIFrameSelection> frameselection;
if (NS_SUCCEEDED(shell->GetFrameSelection(getter_AddRefs(frameselection))) && frameselection){
frameselection->TakeFocus(newContent, startPos, contentOffsetEnd , PR_TRUE, PR_FALSE); //TRUE IS THE DIFFERENCE for continue selection
}
//no release
}

Просмотреть файл

@ -947,18 +947,16 @@ nsTextFrame::PaintUnicodeText(nsIPresContext* aPresContext,
}
SelectionDetails *details = nsnull;
nsCOMPtr<nsIPresShell> shell;
nsCOMPtr<nsIDOMSelection> selection;
nsCOMPtr<nsIFrameSelection> frameSelection;
PRBool drawSelected = PR_FALSE;
nsresult rv = aPresContext->GetShell(getter_AddRefs(shell));
if (NS_SUCCEEDED(rv) && shell){
rv = shell->GetSelection(getter_AddRefs(selection));
if (NS_SUCCEEDED(rv) && selection){
frameSelection = do_QueryInterface(selection);
rv = shell->GetFrameSelection(getter_AddRefs(frameSelection));
if (NS_SUCCEEDED(rv) && frameSelection){
nsCOMPtr<nsIContent> content;
rv = GetContent(getter_AddRefs(content));
if (NS_SUCCEEDED(rv)){
if (NS_SUCCEEDED(rv) && content){
rv = frameSelection->LookUpSelection(content, mContentOffset,
mContentLength , &details);// last param notused
}
@ -1405,14 +1403,12 @@ nsTextFrame::PaintTextSlowly(nsIPresContext* aPresContext,
PRInt32 selectionStartOffset = 0;//frame coordinates
PRInt32 selectionEndOffset = 0;//frame coordinates
nsCOMPtr<nsIPresShell> shell;
nsCOMPtr<nsIDOMSelection> selection;
nsCOMPtr<nsIFrameSelection> frameSelection;
PRBool drawSelected = PR_FALSE;
nsresult rv = aPresContext->GetShell(getter_AddRefs(shell));
if (NS_SUCCEEDED(rv) && shell){
rv = shell->GetSelection(getter_AddRefs(selection));
if (NS_SUCCEEDED(rv) && selection){
frameSelection = do_QueryInterface(selection);
rv = shell->GetFrameSelection(getter_AddRefs(frameSelection));
if (NS_SUCCEEDED(rv) && frameSelection){
nsCOMPtr<nsIContent> content;
rv = GetContent(getter_AddRefs(content));
if (NS_SUCCEEDED(rv)){
@ -1521,14 +1517,12 @@ nsTextFrame::PaintAsciiText(nsIPresContext* aPresContext,
PRInt32 selectionStartOffset = 0;//frame coordinates
PRInt32 selectionEndOffset = 0;//frame coordinates
nsCOMPtr<nsIPresShell> shell;
nsCOMPtr<nsIDOMSelection> selection;
nsCOMPtr<nsIFrameSelection> frameSelection;
PRBool drawSelected = PR_FALSE;
nsresult rv = aPresContext->GetShell(getter_AddRefs(shell));
if (NS_SUCCEEDED(rv) && shell){
rv = shell->GetSelection(getter_AddRefs(selection));
if (NS_SUCCEEDED(rv) && selection){
frameSelection = do_QueryInterface(selection);
rv = shell->GetFrameSelection(getter_AddRefs(frameSelection));
if (NS_SUCCEEDED(rv) && frameSelection){
nsCOMPtr<nsIContent> content;
rv = GetContent(getter_AddRefs(content));
if (NS_SUCCEEDED(rv)){
@ -2254,11 +2248,11 @@ nsTextFrame::HandleMultiplePress(nsIPresContext& aPresContext,
return rv;
nsCOMPtr<nsIDOMSelection> selection;
if (NS_SUCCEEDED(shell->GetSelection(getter_AddRefs(selection)))){
rv = selection->Collapse(startNode,startOffset, SELECTION_NORMAL);
if (NS_SUCCEEDED(shell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection)))){
rv = selection->Collapse(startNode,startOffset);
if (NS_FAILED(rv))
return rv;
rv = selection->Extend(endNode,endOffset, SELECTION_NORMAL);
rv = selection->Extend(endNode,endOffset);
if (NS_FAILED(rv))
return rv;
}

Просмотреть файл

@ -760,15 +760,10 @@ nsFrame::Paint(nsIPresContext& aPresContext,
}
if (NS_SUCCEEDED(result) && shell){
result = shell->GetSelection(getter_AddRefs(selection));
if (NS_SUCCEEDED(result) && selection){
frameSelection = do_QueryInterface(selection);
nsCOMPtr<nsIContent> content;
result = GetContent(getter_AddRefs(content));
if (NS_SUCCEEDED(result)){
result = frameSelection->LookUpSelection(newContent, offset,
1, &details);// last param notused
}
result = shell->GetFrameSelection(getter_AddRefs(frameSelection));
if (NS_SUCCEEDED(result) && frameSelection){
result = frameSelection->LookUpSelection(newContent, offset,
1, &details);// last param notused
}
}
//}
@ -818,11 +813,8 @@ nsFrame::HandleEvent(nsIPresContext& aPresContext,
nsCOMPtr<nsIPresShell> shell;
nsresult rv = aPresContext.GetShell(getter_AddRefs(shell));
if (NS_SUCCEEDED(rv)){
nsCOMPtr<nsIDOMSelection> selection;
if (NS_SUCCEEDED(shell->GetSelection(getter_AddRefs(selection)))){
nsCOMPtr<nsIFrameSelection> frameselection;
frameselection = do_QueryInterface(selection);
if (frameselection) {
nsCOMPtr<nsIFrameSelection> frameselection;
if (NS_SUCCEEDED(shell->GetFrameSelection(getter_AddRefs(frameselection))) && frameselection){
PRBool mouseDown = PR_FALSE;
if (NS_SUCCEEDED(frameselection->GetMouseDownState(&mouseDown)) && mouseDown) {
@ -865,7 +857,6 @@ nsFrame::HandleEvent(nsIPresContext& aPresContext,
//---------------------------------------------------
#endif
}
}
}
}
@ -903,16 +894,10 @@ nsFrame::HandlePress(nsIPresContext& aPresContext,
nsCOMPtr<nsIContent> newContent;
if (NS_SUCCEEDED(GetPosition(aPresContext, aEvent->point.x, getter_AddRefs(newContent),
startPos, contentOffsetEnd))){
nsCOMPtr<nsIDOMSelection> selection;
if (NS_SUCCEEDED(shell->GetSelection(getter_AddRefs(selection)))){
nsCOMPtr<nsIFrameSelection> frameselection;
frameselection = do_QueryInterface(selection);
if (frameselection) {
if (NS_SUCCEEDED( rv )){
frameselection->SetMouseDownState(PR_TRUE);//not important if it fails here
frameselection->TakeFocus(newContent, startPos , contentOffsetEnd , inputEvent->isShift, inputEvent->isControl);
}
}
nsCOMPtr<nsIFrameSelection> frameselection;
if (NS_SUCCEEDED(shell->GetFrameSelection(getter_AddRefs(frameselection))) && frameselection){
frameselection->SetMouseDownState(PR_TRUE);//not important if it fails here
frameselection->TakeFocus(newContent, startPos , contentOffsetEnd , inputEvent->isShift, inputEvent->isControl);
}
//no release
}
@ -948,16 +933,9 @@ NS_IMETHODIMP nsFrame::HandleDrag(nsIPresContext& aPresContext,
nsCOMPtr<nsIContent> newContent;
if (NS_SUCCEEDED(GetPosition(aPresContext, aEvent->point.x, getter_AddRefs(newContent),
startPos, contentOffsetEnd))){
nsIDOMSelection *selection = nsnull;
if (NS_SUCCEEDED(shell->GetSelection(&selection))){
nsIFrameSelection* frameselection;
if (NS_SUCCEEDED(selection->QueryInterface(kIFrameSelection, (void **)&frameselection))) {
if (NS_SUCCEEDED( rv )){
frameselection->TakeFocus(newContent, startPos, contentOffsetEnd , PR_TRUE, PR_FALSE); //TRUE IS THE DIFFERENCE for continue selection
}
NS_RELEASE(frameselection);
}
NS_RELEASE(selection);
nsCOMPtr<nsIFrameSelection> frameselection;
if (NS_SUCCEEDED(shell->GetFrameSelection(getter_AddRefs(frameselection))) && frameselection){
frameselection->TakeFocus(newContent, startPos, contentOffsetEnd , PR_TRUE, PR_FALSE); //TRUE IS THE DIFFERENCE for continue selection
}
//no release
}

Просмотреть файл

@ -216,7 +216,7 @@ FrameHashTable::Dump(FILE* fp)
// Class IID's
static NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
static NS_DEFINE_IID(kRangeListCID, NS_RANGELIST_CID);
static NS_DEFINE_IID(kFrameSelectionCID, NS_FRAMESELECTION_CID);
static NS_DEFINE_IID(kCRangeCID, NS_RANGE_CID);
// IID's
@ -267,7 +267,9 @@ public:
NS_IMETHOD GetActiveAlternateStyleSheet(nsString& aSheetTitle);
NS_IMETHOD SelectAlternateStyleSheet(const nsString& aSheetTitle);
NS_IMETHOD ListAlternateStyleSheets(nsStringArray& aTitleList);
NS_IMETHOD GetSelection(nsIDOMSelection** aSelection);
NS_IMETHOD GetSelection(SelectionType aType, nsIDOMSelection** aSelection);
NS_IMETHOD GetFrameSelection(nsIFrameSelection** aSelection);
NS_IMETHOD EnterReflowLock();
NS_IMETHOD ExitReflowLock();
NS_IMETHOD BeginObservingDocument();
@ -649,18 +651,15 @@ PresShell::Init(nsIDocument* aDocument,
mStyleSet = dont_QueryInterface(aStyleSet);
nsCOMPtr<nsIDOMSelection>domselection;
nsresult result = nsComponentManager::CreateInstance(kRangeListCID, nsnull,
kIDOMSelectionIID,
getter_AddRefs(domselection));
nsresult result = nsComponentManager::CreateInstance(kFrameSelectionCID, nsnull,
nsIFrameSelection::GetIID(),
getter_AddRefs(mSelection));
if (!NS_SUCCEEDED(result))
return result;
result = domselection->QueryInterface(kIFrameSelectionIID,
getter_AddRefs(mSelection));
if (!NS_SUCCEEDED(result))
return result;
domselection->AddSelectionListener(this);//possible circular reference
nsCOMPtr<nsIDOMSelection> domSelection;
mSelection->GetSelection(SELECTION_NORMAL, getter_AddRefs(domSelection));
domSelection->AddSelectionListener(this);//possible circular reference
result = mSelection->Init((nsIFocusTracker *) this);
if (!NS_SUCCEEDED(result))
@ -876,13 +875,22 @@ PresShell::ListAlternateStyleSheets(nsStringArray& aTitleList)
}
NS_IMETHODIMP
PresShell::GetSelection(nsIDOMSelection **aSelection)
PresShell::GetSelection(SelectionType aType, nsIDOMSelection **aSelection)
{
if (!aSelection || !mSelection)
return NS_ERROR_NULL_POINTER;
return mSelection->QueryInterface(kIDOMSelectionIID,(void **)aSelection);
return mSelection->GetSelection(aType, aSelection);
}
NS_IMETHODIMP
PresShell::GetFrameSelection(nsIFrameSelection** aSelection)
{
if (!aSelection || !mSelection)
return NS_ERROR_NULL_POINTER;
*aSelection = mSelection;
(*aSelection)->AddRef();
return NS_OK;
}
// Make shell be a document observer
@ -1702,7 +1710,7 @@ PresShell::DoCopy()
nsString buffer;
nsIDOMSelection* sel = nsnull;
GetSelection(&sel);
GetSelection(SELECTION_NORMAL, &sel);
if (sel != nsnull)
doc->CreateXIF(buffer,sel);

Просмотреть файл

@ -947,18 +947,16 @@ nsTextFrame::PaintUnicodeText(nsIPresContext* aPresContext,
}
SelectionDetails *details = nsnull;
nsCOMPtr<nsIPresShell> shell;
nsCOMPtr<nsIDOMSelection> selection;
nsCOMPtr<nsIFrameSelection> frameSelection;
PRBool drawSelected = PR_FALSE;
nsresult rv = aPresContext->GetShell(getter_AddRefs(shell));
if (NS_SUCCEEDED(rv) && shell){
rv = shell->GetSelection(getter_AddRefs(selection));
if (NS_SUCCEEDED(rv) && selection){
frameSelection = do_QueryInterface(selection);
rv = shell->GetFrameSelection(getter_AddRefs(frameSelection));
if (NS_SUCCEEDED(rv) && frameSelection){
nsCOMPtr<nsIContent> content;
rv = GetContent(getter_AddRefs(content));
if (NS_SUCCEEDED(rv)){
if (NS_SUCCEEDED(rv) && content){
rv = frameSelection->LookUpSelection(content, mContentOffset,
mContentLength , &details);// last param notused
}
@ -1405,14 +1403,12 @@ nsTextFrame::PaintTextSlowly(nsIPresContext* aPresContext,
PRInt32 selectionStartOffset = 0;//frame coordinates
PRInt32 selectionEndOffset = 0;//frame coordinates
nsCOMPtr<nsIPresShell> shell;
nsCOMPtr<nsIDOMSelection> selection;
nsCOMPtr<nsIFrameSelection> frameSelection;
PRBool drawSelected = PR_FALSE;
nsresult rv = aPresContext->GetShell(getter_AddRefs(shell));
if (NS_SUCCEEDED(rv) && shell){
rv = shell->GetSelection(getter_AddRefs(selection));
if (NS_SUCCEEDED(rv) && selection){
frameSelection = do_QueryInterface(selection);
rv = shell->GetFrameSelection(getter_AddRefs(frameSelection));
if (NS_SUCCEEDED(rv) && frameSelection){
nsCOMPtr<nsIContent> content;
rv = GetContent(getter_AddRefs(content));
if (NS_SUCCEEDED(rv)){
@ -1521,14 +1517,12 @@ nsTextFrame::PaintAsciiText(nsIPresContext* aPresContext,
PRInt32 selectionStartOffset = 0;//frame coordinates
PRInt32 selectionEndOffset = 0;//frame coordinates
nsCOMPtr<nsIPresShell> shell;
nsCOMPtr<nsIDOMSelection> selection;
nsCOMPtr<nsIFrameSelection> frameSelection;
PRBool drawSelected = PR_FALSE;
nsresult rv = aPresContext->GetShell(getter_AddRefs(shell));
if (NS_SUCCEEDED(rv) && shell){
rv = shell->GetSelection(getter_AddRefs(selection));
if (NS_SUCCEEDED(rv) && selection){
frameSelection = do_QueryInterface(selection);
rv = shell->GetFrameSelection(getter_AddRefs(frameSelection));
if (NS_SUCCEEDED(rv) && frameSelection){
nsCOMPtr<nsIContent> content;
rv = GetContent(getter_AddRefs(content));
if (NS_SUCCEEDED(rv)){
@ -2254,11 +2248,11 @@ nsTextFrame::HandleMultiplePress(nsIPresContext& aPresContext,
return rv;
nsCOMPtr<nsIDOMSelection> selection;
if (NS_SUCCEEDED(shell->GetSelection(getter_AddRefs(selection)))){
rv = selection->Collapse(startNode,startOffset, SELECTION_NORMAL);
if (NS_SUCCEEDED(shell->GetSelection(SELECTION_NORMAL, getter_AddRefs(selection)))){
rv = selection->Collapse(startNode,startOffset);
if (NS_FAILED(rv))
return rv;
rv = selection->Extend(endNode,endOffset, SELECTION_NORMAL);
rv = selection->Extend(endNode,endOffset);
if (NS_FAILED(rv))
return rv;
}

Просмотреть файл

@ -913,13 +913,13 @@ nsGfxTextControlFrame::SelectAllTextContent(nsIDOMNode *aBodyNode, nsIDOMSelecti
result = aBodyNode->GetLastChild(getter_AddRefs(lastChild));
if ((NS_SUCCEEDED(result)) && lastChild)
{
aSelection->Collapse(firstChild, 0, SELECTION_NORMAL);
aSelection->Collapse(firstChild, 0);
nsCOMPtr<nsIDOMCharacterData>text = do_QueryInterface(lastChild);
if (text)
{
PRUint32 length;
text->GetLength(&length);
aSelection->Extend(lastChild, length, SELECTION_NORMAL);
aSelection->Extend(lastChild, length);
}
}
}
@ -1220,7 +1220,7 @@ nsGfxTextControlFrame::InitializeTextControl(nsIPresShell *aPresShell, nsIDOMDoc
result = mEditor->InsertText(value);
result = SelectAllTextContent(bodyNode, selection);
}
selection->ClearSelection(SELECTION_NORMAL);
selection->ClearSelection();
}
}
}

Просмотреть файл

@ -174,7 +174,7 @@ static NS_DEFINE_CID(kRDFContainerUtilsCID, NS_RDFCONTAINERUTILS_CID);
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
static NS_DEFINE_CID(kRDFXMLDataSourceCID, NS_RDFXMLDATASOURCE_CID);
static NS_DEFINE_CID(kRDFXULBuilderCID, NS_RDFXULBUILDER_CID);
static NS_DEFINE_CID(kRangeListCID, NS_RANGELIST_CID);
static NS_DEFINE_CID(kFrameSelectionCID, NS_FRAMESELECTION_CID);
static NS_DEFINE_CID(kTextNodeCID, NS_TEXTNODE_CID);
static NS_DEFINE_CID(kWellFormedDTDCID, NS_WELLFORMEDDTD_CID);
static NS_DEFINE_CID(kXULContentSinkCID, NS_XULCONTENTSINK_CID);
@ -836,12 +836,12 @@ XULDocumentImpl::XULDocumentImpl(void)
nsresult rv;
// construct a selection object
if (NS_FAILED(rv = nsComponentManager::CreateInstance(kRangeListCID,
/* if (NS_FAILED(rv = nsComponentManager::CreateInstance(kRangeListCID,
nsnull,
kIDOMSelectionIID,
(void**) &mSelection))) {
NS_ERROR("unable to create DOM selection");
}
}*/
if (gRefCnt++ == 0) {
kIdAtom = NS_NewAtom("id");