NS_IMETHODIMP TextEditRules::DidDoAction(Selection* aSelection, RulesInfo* aInfo, nsresult aResult) { NS_ENSURE_STATE(mTextEditor); // don't let any txns in here move the selection around behind our back. // Note that this won't prevent explicit selection setting from working. AutoTransactionsConserveSelection dontChangeMySelection(mTextEditor); NS_ENSURE_TRUE(aSelection && aInfo, NS_ERROR_NULL_POINTER); // my kingdom for dynamic cast TextRulesInfo* info = static_cast<TextRulesInfo*>(aInfo); switch (info->action) { case EditAction::insertBreak: return DidInsertBreak(aSelection, aResult); case EditAction::insertText: case EditAction::insertIMEText: return DidInsertText(aSelection, aResult); case EditAction::setText: return DidSetText(*aSelection, aResult); case EditAction::deleteSelection: return DidDeleteSelection(aSelection, info->collapsedAction, aResult); case EditAction::undo: return DidUndo(aSelection, aResult); case EditAction::redo: return DidRedo(aSelection, aResult); case EditAction::setTextProperty: return DidSetTextProperty(aSelection, aResult); case EditAction::removeTextProperty: return DidRemoveTextProperty(aSelection, aResult); case EditAction::outputText: return DidOutputText(aSelection, aResult); default: // Don't fail on transactions we don't handle here! return NS_OK; } }
NS_IMETHODIMP nsTextEditRules::DidDoAction(nsISelection *aSelection, nsRulesInfo *aInfo, nsresult aResult) { // don't let any txns in here move the selection around behind our back. // Note that this won't prevent explicit selection setting from working. nsAutoTxnsConserveSelection dontSpazMySelection(mEditor); if (!aSelection || !aInfo) return NS_ERROR_NULL_POINTER; // my kingdom for dynamic cast nsTextRulesInfo *info = static_cast<nsTextRulesInfo*>(aInfo); switch (info->action) { case kInsertBreak: return DidInsertBreak(aSelection, aResult); case kInsertText: case kInsertTextIME: return DidInsertText(aSelection, aResult); case kDeleteSelection: return DidDeleteSelection(aSelection, info->collapsedAction, aResult); case kUndo: return DidUndo(aSelection, aResult); case kRedo: return DidRedo(aSelection, aResult); case kSetTextProperty: return DidSetTextProperty(aSelection, aResult); case kRemoveTextProperty: return DidRemoveTextProperty(aSelection, aResult); case kOutputText: return DidOutputText(aSelection, aResult); } // Don't fail on transactions we don't handle here! return NS_OK; }