зеркало из https://github.com/mozilla/gecko-dev.git
Bug 748307 part 2 - Make WillDoAction take an nsTypedSelection; r=ehsan
This commit is contained in:
Родитель
aea5e1e969
Коммит
6d1d67ffa0
|
@ -46,7 +46,8 @@ public:
|
|||
nsIEditor::EDirection aDirection) = 0;
|
||||
NS_IMETHOD AfterEdit(nsEditor::OperationID action,
|
||||
nsIEditor::EDirection aDirection) = 0;
|
||||
NS_IMETHOD WillDoAction(nsISelection *aSelection, nsRulesInfo *aInfo, bool *aCancel, bool *aHandled)=0;
|
||||
NS_IMETHOD WillDoAction(nsTypedSelection* aSelection, nsRulesInfo* aInfo,
|
||||
bool* aCancel, bool* aHandled) = 0;
|
||||
NS_IMETHOD DidDoAction(nsISelection *aSelection, nsRulesInfo *aInfo, nsresult aResult)=0;
|
||||
NS_IMETHOD DocumentIsEmpty(bool *aDocumentIsEmpty)=0;
|
||||
NS_IMETHOD DocumentModified()=0;
|
||||
|
|
|
@ -46,15 +46,13 @@ nsHTMLEditor::AbsolutePositionSelection(bool aEnabled)
|
|||
|
||||
// the line below does not match the code; should it be removed?
|
||||
// Find out if the selection is collapsed:
|
||||
nsCOMPtr<nsISelection> selection;
|
||||
nsresult res = GetSelection(getter_AddRefs(selection));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
nsRefPtr<nsTypedSelection> selection = GetTypedSelection();
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
|
||||
|
||||
nsTextRulesInfo ruleInfo(aEnabled ? kOpSetAbsolutePosition :
|
||||
kOpRemoveAbsolutePosition);
|
||||
bool cancel, handled;
|
||||
res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||
nsresult res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||
if (NS_FAILED(res) || cancel)
|
||||
return res;
|
||||
|
||||
|
@ -161,14 +159,12 @@ nsHTMLEditor::RelativeChangeZIndex(PRInt32 aChange)
|
|||
|
||||
// brade: can we get rid of this comment?
|
||||
// Find out if the selection is collapsed:
|
||||
nsCOMPtr<nsISelection> selection;
|
||||
nsresult res = GetSelection(getter_AddRefs(selection));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
nsRefPtr<nsTypedSelection> selection = GetTypedSelection();
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
|
||||
nsTextRulesInfo ruleInfo(aChange < 0 ? kOpDecreaseZIndex :
|
||||
kOpIncreaseZIndex);
|
||||
bool cancel, handled;
|
||||
res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||
nsresult res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||
if (cancel || NS_FAILED(res))
|
||||
return res;
|
||||
|
||||
|
|
|
@ -153,13 +153,12 @@ NS_IMETHODIMP nsHTMLEditor::LoadHTML(const nsAString & aInputString)
|
|||
nsAutoRules beginRulesSniffing(this, kOpLoadHTML, nsIEditor::eNext);
|
||||
|
||||
// Get selection
|
||||
nsCOMPtr<nsISelection>selection;
|
||||
nsresult rv = GetSelection(getter_AddRefs(selection));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsRefPtr<nsTypedSelection> selection = GetTypedSelection();
|
||||
NS_ENSURE_STATE(selection);
|
||||
|
||||
nsTextRulesInfo ruleInfo(kOpLoadHTML);
|
||||
bool cancel, handled;
|
||||
rv = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||
nsresult rv = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (cancel) {
|
||||
return NS_OK; // rules canceled the operation
|
||||
|
@ -1725,15 +1724,13 @@ NS_IMETHODIMP nsHTMLEditor::PasteAsCitedQuotation(const nsAString & aCitation,
|
|||
nsAutoRules beginRulesSniffing(this, kOpInsertQuotation, nsIEditor::eNext);
|
||||
|
||||
// get selection
|
||||
nsCOMPtr<nsISelection> selection;
|
||||
nsresult rv = GetSelection(getter_AddRefs(selection));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsRefPtr<nsTypedSelection> selection = GetTypedSelection();
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
|
||||
|
||||
// give rules a chance to handle or cancel
|
||||
nsTextRulesInfo ruleInfo(kOpInsertElement);
|
||||
bool cancel, handled;
|
||||
rv = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||
nsresult rv = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (cancel || handled) {
|
||||
return NS_OK; // rules canceled the operation
|
||||
|
@ -1924,9 +1921,7 @@ nsHTMLEditor::InsertAsPlaintextQuotation(const nsAString & aQuotedText,
|
|||
|
||||
nsCOMPtr<nsIDOMNode> newNode;
|
||||
// get selection
|
||||
nsCOMPtr<nsISelection> selection;
|
||||
nsresult rv = GetSelection(getter_AddRefs(selection));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsRefPtr<nsTypedSelection> selection = GetTypedSelection();
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
|
||||
|
||||
nsAutoEditBatch beginBatching(this);
|
||||
|
@ -1935,7 +1930,7 @@ nsHTMLEditor::InsertAsPlaintextQuotation(const nsAString & aQuotedText,
|
|||
// give rules a chance to handle or cancel
|
||||
nsTextRulesInfo ruleInfo(kOpInsertElement);
|
||||
bool cancel, handled;
|
||||
rv = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||
nsresult rv = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (cancel || handled) {
|
||||
return NS_OK; // rules canceled the operation
|
||||
|
@ -2018,9 +2013,7 @@ nsHTMLEditor::InsertAsCitedQuotation(const nsAString & aQuotedText,
|
|||
nsCOMPtr<nsIDOMNode> newNode;
|
||||
|
||||
// get selection
|
||||
nsCOMPtr<nsISelection> selection;
|
||||
nsresult rv = GetSelection(getter_AddRefs(selection));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsRefPtr<nsTypedSelection> selection = GetTypedSelection();
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
|
||||
|
||||
nsAutoEditBatch beginBatching(this);
|
||||
|
@ -2029,7 +2022,7 @@ nsHTMLEditor::InsertAsCitedQuotation(const nsAString & aQuotedText,
|
|||
// give rules a chance to handle or cancel
|
||||
nsTextRulesInfo ruleInfo(kOpInsertElement);
|
||||
bool cancel, handled;
|
||||
rv = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||
nsresult rv = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (cancel || handled) {
|
||||
return NS_OK; // rules canceled the operation
|
||||
|
|
|
@ -515,7 +515,7 @@ nsHTMLEditRules::AfterEditInner(nsEditor::OperationID action,
|
|||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLEditRules::WillDoAction(nsISelection *aSelection,
|
||||
nsHTMLEditRules::WillDoAction(nsTypedSelection *aSelection,
|
||||
nsRulesInfo *aInfo,
|
||||
bool *aCancel,
|
||||
bool *aHandled)
|
||||
|
|
|
@ -60,7 +60,8 @@ public:
|
|||
nsIEditor::EDirection aDirection);
|
||||
NS_IMETHOD AfterEdit(nsEditor::OperationID action,
|
||||
nsIEditor::EDirection aDirection);
|
||||
NS_IMETHOD WillDoAction(nsISelection *aSelection, nsRulesInfo *aInfo, bool *aCancel, bool *aHandled);
|
||||
NS_IMETHOD WillDoAction(nsTypedSelection* aSelection, nsRulesInfo* aInfo,
|
||||
bool* aCancel, bool* aHandled);
|
||||
NS_IMETHOD DidDoAction(nsISelection *aSelection, nsRulesInfo *aInfo, nsresult aResult);
|
||||
NS_IMETHOD DocumentModified();
|
||||
|
||||
|
|
|
@ -1699,10 +1699,10 @@ nsHTMLEditor::InsertElementAtSelection(nsIDOMElement* aElement, bool aDeleteSele
|
|||
nsAutoEditBatch beginBatching(this);
|
||||
nsAutoRules beginRulesSniffing(this, kOpInsertElement, nsIEditor::eNext);
|
||||
|
||||
nsCOMPtr<nsISelection>selection;
|
||||
res = GetSelection(getter_AddRefs(selection));
|
||||
if (NS_FAILED(res) || !selection)
|
||||
nsRefPtr<nsTypedSelection> selection = GetTypedSelection();
|
||||
if (!selection) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// hand off to the rules system, see if it has anything to say about this
|
||||
bool cancel, handled;
|
||||
|
@ -2178,15 +2178,13 @@ nsHTMLEditor::MakeOrChangeList(const nsAString& aListType, bool entireList, cons
|
|||
// Protect the edit rules object from dying
|
||||
nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
|
||||
|
||||
nsCOMPtr<nsISelection> selection;
|
||||
bool cancel, handled;
|
||||
|
||||
nsAutoEditBatch beginBatching(this);
|
||||
nsAutoRules beginRulesSniffing(this, kOpMakeList, nsIEditor::eNext);
|
||||
|
||||
// pre-process
|
||||
res = GetSelection(getter_AddRefs(selection));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
nsRefPtr<nsTypedSelection> selection = GetTypedSelection();
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
|
||||
|
||||
nsTextRulesInfo ruleInfo(kOpMakeList);
|
||||
|
@ -2256,15 +2254,13 @@ nsHTMLEditor::RemoveList(const nsAString& aListType)
|
|||
// Protect the edit rules object from dying
|
||||
nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
|
||||
|
||||
nsCOMPtr<nsISelection> selection;
|
||||
bool cancel, handled;
|
||||
|
||||
nsAutoEditBatch beginBatching(this);
|
||||
nsAutoRules beginRulesSniffing(this, kOpRemoveList, nsIEditor::eNext);
|
||||
|
||||
// pre-process
|
||||
res = GetSelection(getter_AddRefs(selection));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
nsRefPtr<nsTypedSelection> selection = GetTypedSelection();
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
|
||||
|
||||
nsTextRulesInfo ruleInfo(kOpRemoveList);
|
||||
|
@ -2289,15 +2285,13 @@ nsHTMLEditor::MakeDefinitionItem(const nsAString& aItemType)
|
|||
// Protect the edit rules object from dying
|
||||
nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
|
||||
|
||||
nsCOMPtr<nsISelection> selection;
|
||||
bool cancel, handled;
|
||||
|
||||
nsAutoEditBatch beginBatching(this);
|
||||
nsAutoRules beginRulesSniffing(this, kOpMakeDefListItem, nsIEditor::eNext);
|
||||
|
||||
// pre-process
|
||||
res = GetSelection(getter_AddRefs(selection));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
nsRefPtr<nsTypedSelection> selection = GetTypedSelection();
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
|
||||
nsTextRulesInfo ruleInfo(kOpMakeDefListItem);
|
||||
ruleInfo.blockType = &aItemType;
|
||||
|
@ -2322,15 +2316,13 @@ nsHTMLEditor::InsertBasicBlock(const nsAString& aBlockType)
|
|||
// Protect the edit rules object from dying
|
||||
nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
|
||||
|
||||
nsCOMPtr<nsISelection> selection;
|
||||
bool cancel, handled;
|
||||
|
||||
nsAutoEditBatch beginBatching(this);
|
||||
nsAutoRules beginRulesSniffing(this, kOpMakeBasicBlock, nsIEditor::eNext);
|
||||
|
||||
// pre-process
|
||||
res = GetSelection(getter_AddRefs(selection));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
nsRefPtr<nsTypedSelection> selection = GetTypedSelection();
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
|
||||
nsTextRulesInfo ruleInfo(kOpMakeBasicBlock);
|
||||
ruleInfo.blockType = &aBlockType;
|
||||
|
@ -2404,9 +2396,7 @@ nsHTMLEditor::Indent(const nsAString& aIndent)
|
|||
nsAutoRules beginRulesSniffing(this, opID, nsIEditor::eNext);
|
||||
|
||||
// pre-process
|
||||
nsCOMPtr<nsISelection> selection;
|
||||
res = GetSelection(getter_AddRefs(selection));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
nsRefPtr<nsTypedSelection> selection = GetTypedSelection();
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
|
||||
|
||||
nsTextRulesInfo ruleInfo(opID);
|
||||
|
@ -2483,13 +2473,11 @@ nsHTMLEditor::Align(const nsAString& aAlignType)
|
|||
bool cancel, handled;
|
||||
|
||||
// Find out if the selection is collapsed:
|
||||
nsCOMPtr<nsISelection> selection;
|
||||
nsresult res = GetSelection(getter_AddRefs(selection));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
nsRefPtr<nsTypedSelection> selection = GetTypedSelection();
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
|
||||
nsTextRulesInfo ruleInfo(kOpAlign);
|
||||
ruleInfo.alignType = &aAlignType;
|
||||
res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||
nsresult res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||
if (cancel || NS_FAILED(res))
|
||||
return res;
|
||||
|
||||
|
@ -4896,12 +4884,7 @@ nsHTMLEditor::SetCSSBackgroundColor(const nsAString& aColor)
|
|||
// Protect the edit rules object from dying
|
||||
nsCOMPtr<nsIEditRules> kungFuDeathGrip(mRules);
|
||||
|
||||
nsresult res;
|
||||
nsCOMPtr<nsISelection>selection;
|
||||
res = GetSelection(getter_AddRefs(selection));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
|
||||
nsCOMPtr<nsISelectionPrivate> selPriv(do_QueryInterface(selection));
|
||||
nsRefPtr<nsTypedSelection> selection = GetTypedSelection();
|
||||
|
||||
bool isCollapsed = selection->Collapsed();
|
||||
|
||||
|
@ -4912,13 +4895,13 @@ nsHTMLEditor::SetCSSBackgroundColor(const nsAString& aColor)
|
|||
|
||||
bool cancel, handled;
|
||||
nsTextRulesInfo ruleInfo(kOpSetTextProperty);
|
||||
res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||
nsresult res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
if (!cancel && !handled)
|
||||
{
|
||||
// get selection range enumerator
|
||||
nsCOMPtr<nsIEnumerator> enumerator;
|
||||
res = selPriv->GetEnumerator(getter_AddRefs(enumerator));
|
||||
res = selection->GetEnumerator(getter_AddRefs(enumerator));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
NS_ENSURE_TRUE(enumerator, NS_ERROR_FAILURE);
|
||||
|
||||
|
|
|
@ -88,11 +88,8 @@ nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty,
|
|||
}
|
||||
ForceCompositionEnd();
|
||||
|
||||
nsCOMPtr<nsISelection> selection;
|
||||
nsresult res = GetSelection(getter_AddRefs(selection));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
nsRefPtr<nsTypedSelection> selection = GetTypedSelection();
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
|
||||
nsCOMPtr<nsISelectionPrivate> selPriv(do_QueryInterface(selection));
|
||||
|
||||
if (selection->Collapsed()) {
|
||||
// manipulating text attributes on a collapsed selection only sets state
|
||||
|
@ -108,12 +105,12 @@ nsHTMLEditor::SetInlineProperty(nsIAtom *aProperty,
|
|||
|
||||
bool cancel, handled;
|
||||
nsTextRulesInfo ruleInfo(kOpSetTextProperty);
|
||||
res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||
nsresult res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
if (!cancel && !handled) {
|
||||
// get selection range enumerator
|
||||
nsCOMPtr<nsIEnumerator> enumerator;
|
||||
res = selPriv->GetEnumerator(getter_AddRefs(enumerator));
|
||||
res = selection->GetEnumerator(getter_AddRefs(enumerator));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
NS_ENSURE_TRUE(enumerator, NS_ERROR_FAILURE);
|
||||
|
||||
|
@ -1295,11 +1292,8 @@ nsresult nsHTMLEditor::RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsAStr
|
|||
ForceCompositionEnd();
|
||||
|
||||
nsresult res;
|
||||
nsCOMPtr<nsISelection>selection;
|
||||
res = GetSelection(getter_AddRefs(selection));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
nsRefPtr<nsTypedSelection> selection = GetTypedSelection();
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
|
||||
nsCOMPtr<nsISelectionPrivate> selPriv(do_QueryInterface(selection));
|
||||
|
||||
bool useCSS = IsCSSEnabled();
|
||||
if (selection->Collapsed()) {
|
||||
|
@ -1331,7 +1325,7 @@ nsresult nsHTMLEditor::RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsAStr
|
|||
{
|
||||
// get selection range enumerator
|
||||
nsCOMPtr<nsIEnumerator> enumerator;
|
||||
res = selPriv->GetEnumerator(getter_AddRefs(enumerator));
|
||||
res = selection->GetEnumerator(getter_AddRefs(enumerator));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
NS_ENSURE_TRUE(enumerator, NS_ERROR_FAILURE);
|
||||
|
||||
|
|
|
@ -718,9 +718,7 @@ nsPlaintextEditor::DeleteSelection(EDirection aAction,
|
|||
nsAutoRules beginRulesSniffing(this, kOpDeleteSelection, aAction);
|
||||
|
||||
// pre-process
|
||||
nsCOMPtr<nsISelection> selection;
|
||||
result = GetSelection(getter_AddRefs(selection));
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
nsRefPtr<nsTypedSelection> selection = GetTypedSelection();
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
|
||||
|
||||
// If there is an existing selection when an extended delete is requested,
|
||||
|
@ -778,9 +776,7 @@ NS_IMETHODIMP nsPlaintextEditor::InsertText(const nsAString &aStringToInsert)
|
|||
nsAutoRules beginRulesSniffing(this, opID, nsIEditor::eNext);
|
||||
|
||||
// pre-process
|
||||
nsCOMPtr<nsISelection> selection;
|
||||
nsresult result = GetSelection(getter_AddRefs(selection));
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
nsRefPtr<nsTypedSelection> selection = GetTypedSelection();
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
|
||||
nsAutoString resultString;
|
||||
// XXX can we trust instring to outlive ruleInfo,
|
||||
|
@ -792,8 +788,8 @@ NS_IMETHODIMP nsPlaintextEditor::InsertText(const nsAString &aStringToInsert)
|
|||
ruleInfo.maxLength = mMaxTextLength;
|
||||
|
||||
bool cancel, handled;
|
||||
result = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
nsresult res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
if (!cancel && !handled)
|
||||
{
|
||||
// we rely on rules code for now - no default implementation
|
||||
|
@ -801,9 +797,9 @@ NS_IMETHODIMP nsPlaintextEditor::InsertText(const nsAString &aStringToInsert)
|
|||
if (!cancel)
|
||||
{
|
||||
// post-process
|
||||
result = mRules->DidDoAction(selection, &ruleInfo, result);
|
||||
res = mRules->DidDoAction(selection, &ruleInfo, res);
|
||||
}
|
||||
return result;
|
||||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsPlaintextEditor::InsertLineBreak()
|
||||
|
@ -817,10 +813,7 @@ NS_IMETHODIMP nsPlaintextEditor::InsertLineBreak()
|
|||
nsAutoRules beginRulesSniffing(this, kOpInsertBreak, nsIEditor::eNext);
|
||||
|
||||
// pre-process
|
||||
nsCOMPtr<nsISelection> selection;
|
||||
nsresult res;
|
||||
res = GetSelection(getter_AddRefs(selection));
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
nsRefPtr<nsTypedSelection> selection = GetTypedSelection();
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
|
||||
|
||||
// Batching the selection and moving nodes out from under the caret causes
|
||||
|
@ -832,7 +825,7 @@ NS_IMETHODIMP nsPlaintextEditor::InsertLineBreak()
|
|||
nsTextRulesInfo ruleInfo(kOpInsertBreak);
|
||||
ruleInfo.maxLength = mMaxTextLength;
|
||||
bool cancel, handled;
|
||||
res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||
nsresult res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
if (!cancel && !handled)
|
||||
{
|
||||
|
@ -876,8 +869,7 @@ NS_IMETHODIMP nsPlaintextEditor::InsertLineBreak()
|
|||
// We want the caret to stick to whatever is past the break. This is
|
||||
// because the break is on the same line we were on, but the next content
|
||||
// will be on the following line.
|
||||
nsCOMPtr<nsISelectionPrivate> selPriv(do_QueryInterface(selection));
|
||||
selPriv->SetInterlinePosition(true);
|
||||
selection->SetInterlinePosition(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1169,8 +1161,7 @@ nsPlaintextEditor::Undo(PRUint32 aCount)
|
|||
nsAutoRules beginRulesSniffing(this, kOpUndo, nsIEditor::eNone);
|
||||
|
||||
nsTextRulesInfo ruleInfo(kOpUndo);
|
||||
nsCOMPtr<nsISelection> selection;
|
||||
GetSelection(getter_AddRefs(selection));
|
||||
nsRefPtr<nsTypedSelection> selection = GetTypedSelection();
|
||||
bool cancel, handled;
|
||||
nsresult result = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||
|
||||
|
@ -1199,8 +1190,7 @@ nsPlaintextEditor::Redo(PRUint32 aCount)
|
|||
nsAutoRules beginRulesSniffing(this, kOpRedo, nsIEditor::eNone);
|
||||
|
||||
nsTextRulesInfo ruleInfo(kOpRedo);
|
||||
nsCOMPtr<nsISelection> selection;
|
||||
GetSelection(getter_AddRefs(selection));
|
||||
nsRefPtr<nsTypedSelection> selection = GetTypedSelection();
|
||||
bool cancel, handled;
|
||||
nsresult result = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||
|
||||
|
@ -1474,9 +1464,7 @@ nsPlaintextEditor::InsertAsQuotation(const nsAString& aQuotedText,
|
|||
quotedStuff.Append(PRUnichar('\n'));
|
||||
|
||||
// get selection
|
||||
nsCOMPtr<nsISelection> selection;
|
||||
rv = GetSelection(getter_AddRefs(selection));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsRefPtr<nsTypedSelection> selection = GetTypedSelection();
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
|
||||
|
||||
nsAutoEditBatch beginBatching(this);
|
||||
|
|
|
@ -209,7 +209,7 @@ nsTextEditRules::AfterEdit(nsEditor::OperationID action,
|
|||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsTextEditRules::WillDoAction(nsISelection *aSelection,
|
||||
nsTextEditRules::WillDoAction(nsTypedSelection* aSelection,
|
||||
nsRulesInfo *aInfo,
|
||||
bool *aCancel,
|
||||
bool *aHandled)
|
||||
|
|
|
@ -42,7 +42,8 @@ public:
|
|||
nsIEditor::EDirection aDirection);
|
||||
NS_IMETHOD AfterEdit(nsEditor::OperationID action,
|
||||
nsIEditor::EDirection aDirection);
|
||||
NS_IMETHOD WillDoAction(nsISelection *aSelection, nsRulesInfo *aInfo, bool *aCancel, bool *aHandled);
|
||||
NS_IMETHOD WillDoAction(nsTypedSelection* aSelection, nsRulesInfo* aInfo,
|
||||
bool* aCancel, bool* aHandled);
|
||||
NS_IMETHOD DidDoAction(nsISelection *aSelection, nsRulesInfo *aInfo, nsresult aResult);
|
||||
NS_IMETHOD DocumentIsEmpty(bool *aDocumentIsEmpty);
|
||||
NS_IMETHOD DocumentModified();
|
||||
|
|
Загрузка…
Ссылка в новой задаче