mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-04 13:07:52 +00:00
Bug 572618 - Make debugging the editor easier - Part 4: multiline version of part 1; r=roc
This commit is contained in:
parent
9f32e5a757
commit
a98243d830
@ -262,11 +262,9 @@ nsStyleUpdatingCommand::ToggleState(nsIEditor *aEditor, const char* aTagName)
|
||||
{
|
||||
// check current selection; set doTagRemoval if formatting should be removed
|
||||
rv = GetCurrentState(aEditor, aTagName, params);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = params->GetBooleanValue(STATE_ALL, &doTagRemoval);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
if (doTagRemoval)
|
||||
@ -340,8 +338,7 @@ nsListCommand::ToggleState(nsIEditor *aEditor, const char* aTagName)
|
||||
|
||||
rv = GetCurrentState(aEditor, mTagName, params);
|
||||
rv = params->GetBooleanValue(STATE_ALL,&inList);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsAutoString listType; listType.AssignWithConversion(mTagName);
|
||||
if (inList)
|
||||
@ -406,8 +403,7 @@ nsListItemCommand::ToggleState(nsIEditor *aEditor, const char* aTagName)
|
||||
return rv;
|
||||
rv = GetCurrentState(aEditor, mTagName, params);
|
||||
rv = params->GetBooleanValue(STATE_ALL,&inList);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (inList)
|
||||
@ -1038,8 +1034,7 @@ nsAlignCommand::GetCurrentState(nsIEditor *aEditor, nsICommandParams *aParams)
|
||||
PRBool outMixed;
|
||||
nsresult rv = htmlEditor->GetAlignment(&outMixed, &firstAlign);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsAutoString outStateString;
|
||||
switch (firstAlign)
|
||||
@ -1122,8 +1117,7 @@ nsAbsolutePositioningCommand::GetCurrentState(nsIEditor *aEditor, const char* aT
|
||||
|
||||
nsCOMPtr<nsIDOMElement> elt;
|
||||
nsresult rv = htmlEditor->GetAbsolutelyPositionedSelectionContainer(getter_AddRefs(elt));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsAutoString outStateString;
|
||||
if (elt)
|
||||
@ -1519,8 +1513,7 @@ nsInsertTagCommand::DoCommand(const char *aCmdName, nsISupports *refCon)
|
||||
nsresult rv;
|
||||
rv = editor->CreateElementWithDefaults(NS_ConvertASCIItoUTF16(mTagName),
|
||||
getter_AddRefs(domElem));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return editor->InsertElementAtSelection(domElem, PR_TRUE);
|
||||
}
|
||||
@ -1566,12 +1559,10 @@ nsInsertTagCommand::DoCommandParams(const char *aCommandName,
|
||||
nsCOMPtr<nsIDOMElement> domElem;
|
||||
rv = editor->CreateElementWithDefaults(NS_ConvertASCIItoUTF16(mTagName),
|
||||
getter_AddRefs(domElem));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = domElem->SetAttribute(attributeType, attrib);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// do actual insertion
|
||||
if (0 == nsCRT::strcmp(mTagName, "a"))
|
||||
|
@ -246,8 +246,7 @@ nsSetDocumentStateCommand::DoCommandParams(const char *aCommandName,
|
||||
|
||||
// Should we fail if this param wasn't set?
|
||||
// I'm not sure we should be that strict
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (modified)
|
||||
return editor->IncrementModificationCount(1);
|
||||
@ -260,8 +259,7 @@ nsSetDocumentStateCommand::DoCommandParams(const char *aCommandName,
|
||||
NS_ENSURE_ARG_POINTER(aParams);
|
||||
PRBool isReadOnly;
|
||||
nsresult rvRO = aParams->GetBooleanValue(STATE_ATTRIBUTE, &isReadOnly);
|
||||
if (NS_FAILED(rvRO))
|
||||
return rvRO;
|
||||
NS_ENSURE_SUCCESS(rvRO, rvRO);
|
||||
|
||||
PRUint32 flags;
|
||||
editor->GetFlags(&flags);
|
||||
@ -281,8 +279,7 @@ nsSetDocumentStateCommand::DoCommandParams(const char *aCommandName,
|
||||
|
||||
PRBool desireCSS;
|
||||
nsresult rvCSS = aParams->GetBooleanValue(STATE_ATTRIBUTE, &desireCSS);
|
||||
if (NS_FAILED(rvCSS))
|
||||
return rvCSS;
|
||||
NS_ENSURE_SUCCESS(rvCSS, rvCSS);
|
||||
|
||||
return htmleditor->SetIsCSSEnabled(desireCSS);
|
||||
}
|
||||
@ -296,8 +293,7 @@ nsSetDocumentStateCommand::DoCommandParams(const char *aCommandName,
|
||||
PRBool insertBrOnReturn;
|
||||
nsresult rvBR = aParams->GetBooleanValue(STATE_ATTRIBUTE,
|
||||
&insertBrOnReturn);
|
||||
if (NS_FAILED(rvBR))
|
||||
return rvBR;
|
||||
NS_ENSURE_SUCCESS(rvBR, rvBR);
|
||||
|
||||
return htmleditor->SetReturnInParagraphCreatesNewParagraph(!insertBrOnReturn);
|
||||
}
|
||||
@ -310,8 +306,7 @@ nsSetDocumentStateCommand::DoCommandParams(const char *aCommandName,
|
||||
|
||||
PRBool enabled;
|
||||
nsresult rvOR = aParams->GetBooleanValue(STATE_ATTRIBUTE, &enabled);
|
||||
if (NS_FAILED(rvOR))
|
||||
return rvOR;
|
||||
NS_ENSURE_SUCCESS(rvOR, rvOR);
|
||||
|
||||
return resizer->SetObjectResizingEnabled(enabled);
|
||||
}
|
||||
@ -324,8 +319,7 @@ nsSetDocumentStateCommand::DoCommandParams(const char *aCommandName,
|
||||
|
||||
PRBool enabled;
|
||||
nsresult rvOR = aParams->GetBooleanValue(STATE_ATTRIBUTE, &enabled);
|
||||
if (NS_FAILED(rvOR))
|
||||
return rvOR;
|
||||
NS_ENSURE_SUCCESS(rvOR, rvOR);
|
||||
|
||||
return editor->SetInlineTableEditingEnabled(enabled);
|
||||
}
|
||||
|
@ -1029,8 +1029,7 @@ nsEditingSession::EndDocumentLoad(nsIWebProgress *aWebProgress,
|
||||
// do we already have an editor here?
|
||||
nsCOMPtr<nsIEditor> editor;
|
||||
rv = editorDocShell->GetEditor(getter_AddRefs(editor));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
needsSetup = !editor;
|
||||
}
|
||||
|
@ -381,8 +381,7 @@ nsEditorSpellCheck::GetDictionaryList(PRUnichar ***aDictionaryList, PRUint32 *aC
|
||||
|
||||
nsresult rv = mSpellChecker->GetDictionaryList(&dictList);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
PRUnichar **tmpPtr = 0;
|
||||
|
||||
|
@ -989,8 +989,7 @@ NS_IMETHODIMP nsEditor::BeginningOfDocument()
|
||||
// get the selection
|
||||
nsCOMPtr<nsISelection> selection;
|
||||
nsresult result = GetSelection(getter_AddRefs(selection));
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
// get the root element
|
||||
@ -1956,8 +1955,7 @@ nsEditor::GetWidget(nsIWidget **aWidget)
|
||||
|
||||
nsCOMPtr<nsIWidget> widget;
|
||||
nsresult res = GetEditorContentWindow(GetRoot(), getter_AddRefs(widget));
|
||||
if (NS_FAILED(res))
|
||||
return res;
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
NS_ENSURE_TRUE(widget, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
NS_ADDREF(*aWidget = widget);
|
||||
@ -1988,13 +1986,11 @@ nsEditor::ForceCompositionEnd()
|
||||
|
||||
nsCOMPtr<nsIWidget> widget;
|
||||
nsresult res = GetWidget(getter_AddRefs(widget));
|
||||
if (NS_FAILED(res))
|
||||
return res;
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
if (widget) {
|
||||
res = widget->ResetInputState();
|
||||
if (NS_FAILED(res))
|
||||
return res;
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
@ -2101,8 +2097,7 @@ nsEditor::CloneAttribute(const nsAString & aAttribute,
|
||||
aAttribute,
|
||||
attrValue,
|
||||
&isAttrSet);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
if (isAttrSet)
|
||||
rv = SetAttribute(destElement, aAttribute, attrValue);
|
||||
else
|
||||
@ -4200,8 +4195,7 @@ nsEditor::DeleteSelectionAndCreateNode(const nsAString& aTag,
|
||||
PRInt32 offsetOfNewNode;
|
||||
nsresult result = DeleteSelectionAndPrepareToCreateNode(parentSelectedNode,
|
||||
offsetOfNewNode);
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
nsCOMPtr<nsIDOMNode> newNode;
|
||||
result = CreateNode(aTag, parentSelectedNode, offsetOfNewNode,
|
||||
@ -4361,8 +4355,7 @@ nsEditor::DoAfterDoTransaction(nsITransaction *aTxn)
|
||||
|
||||
PRBool isTransientTransaction;
|
||||
rv = aTxn->GetIsTransient(&isTransientTransaction);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!isTransientTransaction)
|
||||
{
|
||||
@ -4626,13 +4619,11 @@ nsEditor::CreateTxnForDeleteInsertionPoint(nsIDOMRange *aRange,
|
||||
// get the node and offset of the insertion point
|
||||
nsCOMPtr<nsIDOMNode> node;
|
||||
nsresult result = aRange->GetStartContainer(getter_AddRefs(node));
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
PRInt32 offset;
|
||||
result = aRange->GetStartOffset(&offset);
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
// determine if the insertion point is at the beginning, middle, or end of the node
|
||||
nsCOMPtr<nsIDOMCharacterData> nodeAsText = do_QueryInterface(node);
|
||||
@ -4814,8 +4805,7 @@ nsEditor::CreateRange(nsIDOMNode *aStartParent, PRInt32 aStartOffset,
|
||||
{
|
||||
nsresult result;
|
||||
result = CallCreateInstance("@mozilla.org/content/range;1", aRange);
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
NS_ENSURE_TRUE(*aRange, NS_ERROR_NULL_POINTER);
|
||||
|
||||
@ -5076,8 +5066,7 @@ nsEditor::SwitchTextDirection()
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(rootElement, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsIFrame *frame = content->GetPrimaryFrame();
|
||||
NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE);
|
||||
|
@ -679,8 +679,7 @@ nsSelectionMoveCommands::DoCommand(const char *aCommandName,
|
||||
|
||||
nsCOMPtr<nsISelectionController> selCont;
|
||||
nsresult rv = editor->GetSelectionController(getter_AddRefs(selCont));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_TRUE(selCont, NS_ERROR_FAILURE);
|
||||
|
||||
// complete scroll commands
|
||||
|
@ -1087,8 +1087,7 @@ NS_IMETHODIMP nsHTMLEditor::PrepareHTMLTransferable(nsITransferable **aTransfera
|
||||
{
|
||||
// Create generic Transferable for getting the data
|
||||
nsresult rv = CallCreateInstance("@mozilla.org/widget/transferable;1", aTransferable);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Get the nsITransferable interface for getting the data from the clipboard
|
||||
if (aTransferable)
|
||||
@ -1347,8 +1346,7 @@ NS_IMETHODIMP nsHTMLEditor::InsertFromTransferable(nsITransferable *transferable
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
rv = NS_NewFileURI(getter_AddRefs(uri), fileObj);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIURL> fileURL(do_QueryInterface(uri));
|
||||
if (fileURL)
|
||||
@ -1636,8 +1634,7 @@ NS_IMETHODIMP nsHTMLEditor::InsertFromDrop(nsIDOMEvent* aDropEvent)
|
||||
{
|
||||
PRInt32 rangeCount;
|
||||
rv = selection->GetRangeCount(&rangeCount);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
for (PRInt32 j = 0; j < rangeCount; j++)
|
||||
{
|
||||
@ -1841,8 +1838,7 @@ NS_IMETHODIMP nsHTMLEditor::Paste(PRInt32 aSelectionType)
|
||||
// Get Clipboard Service
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIClipboard> clipboard(do_GetService("@mozilla.org/widget/clipboard;1", &rv));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// find out if we have our internal html flavor on the clipboard. We don't want to mess
|
||||
// around with cfhtml if we do.
|
||||
@ -1943,8 +1939,7 @@ NS_IMETHODIMP nsHTMLEditor::PasteNoFormatting(PRInt32 aSelectionType)
|
||||
// Get Clipboard Service
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIClipboard> clipboard(do_GetService("@mozilla.org/widget/clipboard;1", &rv));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Get the nsITransferable interface for getting the data from the clipboard.
|
||||
// use nsPlaintextEditor::PrepareTransferable() to force unicode plaintext data.
|
||||
@ -2571,8 +2566,7 @@ nsresult FindTargetNode(nsIDOMNode *aStart, nsCOMPtr<nsIDOMNode> &aResult)
|
||||
// inicate that we found the magical cookie and we don't want to spam the
|
||||
// console.
|
||||
rv = FindTargetNode(child, aResult);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = child->GetNextSibling(getter_AddRefs(tmp));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
@ -562,15 +562,13 @@ nsHTMLEditRules::AfterEditInner(PRInt32 action, nsIEditor::EDirection aDirection
|
||||
mRangeItem.startNode, mRangeItem.startOffset,
|
||||
rangeStartParent, rangeStartOffset,
|
||||
rangeEndParent, rangeEndOffset);
|
||||
if (NS_FAILED(res))
|
||||
return res;
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
// detect empty doc
|
||||
res = CreateBogusNodeIfNeeded(selection);
|
||||
|
||||
// adjust selection HINT if needed
|
||||
if (NS_FAILED(res))
|
||||
return res;
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
if (!mDidExplicitlySetInterline)
|
||||
{
|
||||
@ -2746,8 +2744,7 @@ nsHTMLEditRules::JoinBlocks(nsCOMPtr<nsIDOMNode> *aLeftBlock,
|
||||
{
|
||||
childToMove = do_QueryInterface(child);
|
||||
res = mHTMLEditor->MoveNode(childToMove, leftList, -1);
|
||||
if (NS_FAILED(res))
|
||||
return res;
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
child = parent->GetChildAt(rightOffset);
|
||||
}
|
||||
|
@ -535,8 +535,7 @@ nsHTMLEditor::BeginningOfDocument()
|
||||
// get the selection
|
||||
nsCOMPtr<nsISelection> selection;
|
||||
nsresult res = GetSelection(getter_AddRefs(selection));
|
||||
if (NS_FAILED(res))
|
||||
return res;
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
// get the root element
|
||||
@ -925,8 +924,7 @@ nsHTMLEditor::SetDocumentTitle(const nsAString &aTitle)
|
||||
NS_ENSURE_TRUE(txn, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nsresult result = txn->Init(this, &aTitle);
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
//Don't let Rules System change the selection
|
||||
nsAutoTxnsConserveSelection dontChangeSelection(this);
|
||||
@ -1131,8 +1129,7 @@ nsHTMLEditor::NextNodeInBlock(nsIDOMNode *aNode, IterDirection aDir)
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIContentIterator> iter =
|
||||
do_CreateInstance("@mozilla.org/content/post-content-iterator;1", &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return nullNode;
|
||||
NS_ENSURE_SUCCESS(rv, nullNode);
|
||||
|
||||
// much gnashing of teeth as we twit back and forth between content and domnode types
|
||||
content = do_QueryInterface(aNode);
|
||||
@ -1748,8 +1745,7 @@ nsHTMLEditor::ReplaceHeadContentsWithHTML(const nsAString& aSourceToInsert)
|
||||
// Get the first range in the selection, for context:
|
||||
nsCOMPtr<nsIDOMRange> range;
|
||||
res = selection->GetRangeAt(0, getter_AddRefs(range));
|
||||
if (NS_FAILED(res))
|
||||
return res;
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
nsCOMPtr<nsIDOMNSRange> nsrange (do_QueryInterface(range));
|
||||
NS_ENSURE_TRUE(nsrange, NS_ERROR_NO_INTERFACE);
|
||||
@ -1882,17 +1878,14 @@ nsHTMLEditor::RebuildDocumentFromSource(const nsAString& aSourceString)
|
||||
res = LoadHTML(body);
|
||||
else // assume there is no head, the entire source is body
|
||||
res = LoadHTML(body + aSourceString);
|
||||
if (NS_FAILED(res))
|
||||
return res;
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
nsCOMPtr<nsIDOMElement> divElement;
|
||||
res = CreateElementWithDefaults(NS_LITERAL_STRING("div"), getter_AddRefs(divElement));
|
||||
if (NS_FAILED(res))
|
||||
return res;
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
res = CloneAttributes(bodyElement, divElement);
|
||||
if (NS_FAILED(res))
|
||||
return res;
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
return BeginningOfDocument();
|
||||
}
|
||||
@ -2051,8 +2044,7 @@ nsHTMLEditor::InsertElementAtSelection(nsIDOMElement* aElement, PRBool aDeleteSe
|
||||
nsCOMPtr<nsIDOMNode> tempNode;
|
||||
PRInt32 tempOffset;
|
||||
nsresult result = DeleteSelectionAndPrepareToCreateNode(tempNode,tempOffset);
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
}
|
||||
|
||||
// If deleting, selection will be collapsed.
|
||||
@ -2169,8 +2161,7 @@ nsHTMLEditor::InsertNodeAtPoint(nsIDOMNode *aNode,
|
||||
{
|
||||
// we need to split some levels above the original selection parent
|
||||
res = SplitNodeDeep(topChild, *ioParent, *ioOffset, &offsetOfInsert, aNoEmptyNodes);
|
||||
if (NS_FAILED(res))
|
||||
return res;
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
*ioParent = parent;
|
||||
*ioOffset = offsetOfInsert;
|
||||
}
|
||||
@ -3648,8 +3639,7 @@ nsHTMLEditor::EnableExistingStyleSheet(const nsAString &aURL)
|
||||
{
|
||||
nsRefPtr<nsCSSStyleSheet> sheet;
|
||||
nsresult rv = GetStyleSheetForURL(aURL, getter_AddRefs(sheet));
|
||||
if (NS_FAILED(rv))
|
||||
return PR_FALSE;
|
||||
NS_ENSURE_SUCCESS(rv, PR_FALSE);
|
||||
|
||||
// Enable sheet if already loaded.
|
||||
if (sheet)
|
||||
|
@ -833,8 +833,7 @@ nsHTMLEditorLog::StartLogging(nsIFile *aLogFile)
|
||||
{
|
||||
result = StopLogging();
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
}
|
||||
|
||||
result = NS_NewLocalFileOutputStream(getter_AddRefs(mFileStream), aLogFile);
|
||||
@ -893,15 +892,13 @@ nsHTMLEditorLog::Write(const char *aBuffer)
|
||||
|
||||
result = mFileStream->Write(aBuffer, len, &retval);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
#ifdef VERY_SLOW
|
||||
|
||||
result = mFileStream->Flush();
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
#endif // VERY_SLOW
|
||||
}
|
||||
@ -951,8 +948,7 @@ nsHTMLEditorLog::PrintUnicode(const nsAString &aString)
|
||||
|
||||
nsresult result = Write(buf);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
++beginIter;
|
||||
}
|
||||
|
||||
@ -968,13 +964,11 @@ nsHTMLEditorLog::PrintSelection()
|
||||
|
||||
result = GetSelection(getter_AddRefs(selection));
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
result = selection->GetRangeCount(&rangeCount);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
Write("selRanges = [ ");
|
||||
|
||||
@ -988,40 +982,34 @@ nsHTMLEditorLog::PrintSelection()
|
||||
{
|
||||
result = selection->GetRangeAt(i, getter_AddRefs(range));
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
result = range->GetStartContainer(getter_AddRefs(startNode));
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
NS_ENSURE_TRUE(startNode, NS_ERROR_NULL_POINTER);
|
||||
|
||||
result = range->GetStartOffset(&startOffset);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
result = range->GetEndContainer(getter_AddRefs(endNode));
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
NS_ENSURE_TRUE(endNode, NS_ERROR_NULL_POINTER);
|
||||
|
||||
result = range->GetEndOffset(&endOffset);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
PRInt32 *offsetArray = 0;
|
||||
PRInt32 arrayLength = 0;
|
||||
|
||||
result = GetNodeTreeOffsets(startNode, &offsetArray, &arrayLength);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
if (i != 0)
|
||||
Write(",\n ");
|
||||
@ -1047,8 +1035,7 @@ nsHTMLEditorLog::PrintSelection()
|
||||
|
||||
result = GetNodeTreeOffsets(endNode, &offsetArray, &arrayLength);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
}
|
||||
|
||||
Write("[[");
|
||||
@ -1086,8 +1073,7 @@ nsHTMLEditorLog::PrintElementNode(nsIDOMNode *aNode, PRInt32 aDepth)
|
||||
|
||||
result = ele->GetTagName(tag);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
Write("n");
|
||||
WriteInt(aDepth);
|
||||
@ -1097,8 +1083,7 @@ nsHTMLEditorLog::PrintElementNode(nsIDOMNode *aNode, PRInt32 aDepth)
|
||||
|
||||
result = aNode->GetAttributes(getter_AddRefs(map));
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
NS_ENSURE_TRUE(map, NS_ERROR_NULL_POINTER);
|
||||
|
||||
@ -1107,22 +1092,19 @@ nsHTMLEditorLog::PrintElementNode(nsIDOMNode *aNode, PRInt32 aDepth)
|
||||
|
||||
result = map->GetLength(&len);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
result = map->Item(i, getter_AddRefs(attr));
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
NS_ENSURE_TRUE(attr, NS_ERROR_NULL_POINTER);
|
||||
|
||||
result = PrintAttributeNode(attr, aDepth);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
}
|
||||
|
||||
result = PrintNodeChildren(aNode, aDepth);
|
||||
@ -1142,8 +1124,7 @@ nsHTMLEditorLog::PrintAttributeNode(nsIDOMNode *aNode, PRInt32 aDepth)
|
||||
|
||||
result = attr->GetName(str);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
Write("a");
|
||||
WriteInt(aDepth);
|
||||
@ -1153,8 +1134,7 @@ nsHTMLEditorLog::PrintAttributeNode(nsIDOMNode *aNode, PRInt32 aDepth)
|
||||
|
||||
result = attr->GetValue(str);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
Write("a");
|
||||
WriteInt(aDepth);
|
||||
@ -1182,8 +1162,7 @@ nsHTMLEditorLog::PrintNodeChildren(nsIDOMNode *aNode, PRInt32 aDepth)
|
||||
|
||||
result = aNode->GetChildNodes(getter_AddRefs(list));
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
if (!list)
|
||||
{
|
||||
@ -1196,20 +1175,17 @@ nsHTMLEditorLog::PrintNodeChildren(nsIDOMNode *aNode, PRInt32 aDepth)
|
||||
|
||||
result = list->GetLength(&len);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
result = list->Item(i, getter_AddRefs(node));
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
result = PrintNode(node, aDepth + 1);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
Write("n");
|
||||
WriteInt(aDepth);
|
||||
@ -1234,8 +1210,7 @@ nsHTMLEditorLog::PrintTextNode(nsIDOMNode *aNode, PRInt32 aDepth)
|
||||
|
||||
result = cd->GetData(str);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
Write("n");
|
||||
WriteInt(aDepth);
|
||||
@ -1305,8 +1280,7 @@ nsHTMLEditorLog::GetNodeTreeOffsets(nsIDOMNode *aNode, PRInt32 **aResult, PRInt3
|
||||
{
|
||||
result = parent->GetParentNode(&parent);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
if (parent)
|
||||
++i;
|
||||
|
@ -691,14 +691,11 @@ nsresult nsHTMLEditor::RemoveStyleInside(nsIDOMNode *aNode,
|
||||
nsCOMPtr<nsIDOMNode> spanNode;
|
||||
res = InsertContainerAbove(aNode, address_of(spanNode),
|
||||
NS_LITERAL_STRING("span"));
|
||||
if (NS_FAILED(res))
|
||||
return res;
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
res = CloneAttribute(styleAttr, spanNode, aNode);
|
||||
if (NS_FAILED(res))
|
||||
return res;
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
res = CloneAttribute(classAttr, spanNode, aNode);
|
||||
if (NS_FAILED(res))
|
||||
return res;
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
if (hasStyleAttr)
|
||||
{
|
||||
// we need to remove the styles property corresponding to
|
||||
|
@ -134,8 +134,7 @@ nsHTMLURIRefObject::GetNextURI(nsAString & aURI)
|
||||
|
||||
nsAutoString tagName;
|
||||
nsresult rv = mNode->GetNodeName(tagName);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Loop over attribute list:
|
||||
if (!mAttributes)
|
||||
|
@ -73,8 +73,7 @@ NS_IMETHODIMP nsPlaintextEditor::PrepareTransferable(nsITransferable **transfera
|
||||
{
|
||||
// Create generic Transferable for getting the data
|
||||
nsresult rv = CallCreateInstance("@mozilla.org/widget/transferable;1", transferable);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Get the nsITransferable interface for getting the data from the clipboard
|
||||
if (transferable) {
|
||||
|
@ -300,8 +300,7 @@ nsPlaintextEditor::SetDocumentCharacterSet(const nsACString & characterSet)
|
||||
nsCOMPtr<nsIDOMNode>resultNode;
|
||||
// Create a new meta charset tag
|
||||
result = CreateNode(NS_LITERAL_STRING("meta"), headNode, 0, getter_AddRefs(resultNode));
|
||||
if (NS_FAILED(result))
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ENSURE_SUCCESS(result, NS_ERROR_FAILURE);
|
||||
|
||||
// Set attributes to the created element
|
||||
if (resultNode && !characterSet.IsEmpty()) {
|
||||
@ -1358,8 +1357,7 @@ nsPlaintextEditor::OutputToString(const nsAString& aFormatType,
|
||||
|
||||
nsCOMPtr<nsIDocumentEncoder> encoder;
|
||||
rv = GetAndInitDocEncoder(aFormatType, aFlags, charsetStr, getter_AddRefs(encoder));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return encoder->EncodeToString(aOutputString);
|
||||
}
|
||||
|
||||
@ -1388,8 +1386,7 @@ nsPlaintextEditor::OutputToStream(nsIOutputStream* aOutputStream,
|
||||
rv = GetAndInitDocEncoder(aFormatType, aFlags, aCharset,
|
||||
getter_AddRefs(encoder));
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return encoder->EncodeToStream(aOutputStream);
|
||||
}
|
||||
@ -1473,8 +1470,7 @@ nsPlaintextEditor::InsertAsQuotation(const nsAString& aQuotedText,
|
||||
// Let the citer quote it for us:
|
||||
nsString quotedStuff;
|
||||
nsresult rv = citer->GetCiteString(aQuotedText, quotedStuff);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// It's best to put a blank line after the quoted text so that mails
|
||||
// written without thinking won't be so ugly.
|
||||
@ -1551,8 +1547,7 @@ nsPlaintextEditor::Rewrap(PRBool aRespectNewlines)
|
||||
{
|
||||
PRInt32 wrapCol;
|
||||
nsresult rv = GetWrapWidth(&wrapCol);
|
||||
if (NS_FAILED(rv))
|
||||
return NS_OK;
|
||||
NS_ENSURE_SUCCESS(rv, NS_OK);
|
||||
|
||||
// Rewrap makes no sense if there's no wrap column; default to 72.
|
||||
if (wrapCol <= 0)
|
||||
|
@ -225,8 +225,7 @@ nsTextEditRules::BeforeEdit(PRInt32 action, nsIEditor::EDirection aDirection)
|
||||
// get the selection and cache the position before editing
|
||||
nsCOMPtr<nsISelection> selection;
|
||||
nsresult res = mEditor->GetSelection(getter_AddRefs(selection));
|
||||
if (NS_FAILED(res))
|
||||
return res;
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
selection->GetAnchorNode(getter_AddRefs(mCachedSelectionNode));
|
||||
selection->GetAnchorOffset(&mCachedSelectionOffset);
|
||||
@ -259,18 +258,15 @@ nsTextEditRules::AfterEdit(PRInt32 action, nsIEditor::EDirection aDirection)
|
||||
res = mEditor->HandleInlineSpellCheck(action, selection,
|
||||
mCachedSelectionNode, mCachedSelectionOffset,
|
||||
nsnull, 0, nsnull, 0);
|
||||
if (NS_FAILED(res))
|
||||
return res;
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
// detect empty doc
|
||||
res = CreateBogusNodeIfNeeded(selection);
|
||||
if (NS_FAILED(res))
|
||||
return res;
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
// insure trailing br node
|
||||
res = CreateTrailingBRIfNeeded();
|
||||
if (NS_FAILED(res))
|
||||
return res;
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
|
||||
/* After inserting text the cursor Bidi level must be set to the level of the inserted text.
|
||||
* This is difficult, because we cannot know what the level is until after the Bidi algorithm
|
||||
|
@ -58,8 +58,7 @@ nsTextEditRules::CheckBidiLevelForDeletion(nsISelection *aSelection,
|
||||
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
nsresult res = mEditor->GetPresShell(getter_AddRefs(shell));
|
||||
if (NS_FAILED(res))
|
||||
return res;
|
||||
NS_ENSURE_SUCCESS(res, res);
|
||||
NS_ENSURE_TRUE(shell, NS_ERROR_NULL_POINTER);
|
||||
|
||||
nsPresContext *context = shell->GetPresContext();
|
||||
|
@ -151,13 +151,11 @@ nsTransactionItem::GetNumberOfChildren(PRInt32 *aNumChildren)
|
||||
|
||||
result = GetNumberOfUndoItems(&ui);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
result = GetNumberOfRedoItems(&ri);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
*aNumChildren = ui + ri;
|
||||
|
||||
@ -174,8 +172,7 @@ nsTransactionItem::GetChild(PRInt32 aIndex, nsTransactionItem **aChild)
|
||||
PRInt32 numItems = 0;
|
||||
nsresult result = GetNumberOfChildren(&numItems);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
if (aIndex < 0 || aIndex >= numItems)
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -187,8 +184,7 @@ nsTransactionItem::GetChild(PRInt32 aIndex, nsTransactionItem **aChild)
|
||||
|
||||
result = GetNumberOfUndoItems(&numItems);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
if (numItems > 0 && aIndex < numItems) {
|
||||
NS_ENSURE_TRUE(mUndoStack, NS_ERROR_FAILURE);
|
||||
@ -202,8 +198,7 @@ nsTransactionItem::GetChild(PRInt32 aIndex, nsTransactionItem **aChild)
|
||||
|
||||
result = GetNumberOfRedoItems(&numItems);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
NS_ENSURE_TRUE(mRedoStack && numItems != 0 && aIndex < numItems, NS_ERROR_FAILURE);
|
||||
|
||||
@ -256,8 +251,7 @@ nsTransactionItem::UndoChildren(nsTransactionManager *aTxMgr)
|
||||
/* Undo all of the transaction items children! */
|
||||
result = mUndoStack->GetSize(&sz);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
while (sz-- > 0) {
|
||||
result = mUndoStack->Peek(getter_AddRefs(item));
|
||||
@ -320,8 +314,7 @@ nsTransactionItem::RedoTransaction(nsTransactionManager *aTxMgr)
|
||||
if (mTransaction) {
|
||||
result = mTransaction->RedoTransaction();
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
}
|
||||
|
||||
result = RedoChildren(aTxMgr);
|
||||
@ -346,8 +339,7 @@ nsTransactionItem::RedoChildren(nsTransactionManager *aTxMgr)
|
||||
/* Redo all of the transaction items children! */
|
||||
result = mRedoStack->GetSize(&sz);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
|
||||
while (sz-- > 0) {
|
||||
|
@ -105,8 +105,7 @@ NS_IMETHODIMP nsTransactionList::ItemIsBatch(PRInt32 aIndex, PRBool *aIsBatch)
|
||||
else if (mTxnItem)
|
||||
result = mTxnItem->GetChild(aIndex, getter_AddRefs(item));
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
NS_ENSURE_TRUE(item, NS_ERROR_FAILURE);
|
||||
|
||||
@ -133,8 +132,7 @@ NS_IMETHODIMP nsTransactionList::GetItem(PRInt32 aIndex, nsITransaction **aItem)
|
||||
else if (mTxnItem)
|
||||
result = mTxnItem->GetChild(aIndex, getter_AddRefs(item));
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
NS_ENSURE_TRUE(item, NS_ERROR_FAILURE);
|
||||
|
||||
@ -161,8 +159,7 @@ NS_IMETHODIMP nsTransactionList::GetNumChildrenForItem(PRInt32 aIndex, PRInt32 *
|
||||
else if (mTxnItem)
|
||||
result = mTxnItem->GetChild(aIndex, getter_AddRefs(item));
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
NS_ENSURE_TRUE(item, NS_ERROR_FAILURE);
|
||||
|
||||
@ -189,8 +186,7 @@ NS_IMETHODIMP nsTransactionList::GetChildListForItem(PRInt32 aIndex, nsITransact
|
||||
else if (mTxnItem)
|
||||
result = mTxnItem->GetChild(aIndex, getter_AddRefs(item));
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
NS_ENSURE_TRUE(item, NS_ERROR_FAILURE);
|
||||
|
||||
|
@ -1031,8 +1031,7 @@ nsTransactionManager::EndTransaction()
|
||||
|
||||
result = WillMergeNotify(topTransaction, tint, &doInterrupt);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
if (!doInterrupt) {
|
||||
result = topTransaction->Merge(tint, &didMerge);
|
||||
|
@ -131,14 +131,12 @@ nsTransactionStack::Clear(void)
|
||||
|
||||
result = Pop(getter_AddRefs(tx));
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
while (tx) {
|
||||
result = Pop(getter_AddRefs(tx));
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
@ -184,14 +182,12 @@ nsTransactionRedoStack::Clear(void)
|
||||
|
||||
result = PopBottom(getter_AddRefs(tx));
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
while (tx) {
|
||||
result = PopBottom(getter_AddRefs(tx));
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -1542,8 +1542,7 @@ nsTextServicesDocument::InsertText(const nsString *aText)
|
||||
|
||||
result = SetSelection(mSelStartOffset, 0);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
}
|
||||
|
||||
|
||||
@ -1798,8 +1797,7 @@ nsTextServicesDocument::DidInsertNode(nsIDOMNode *aNode,
|
||||
NS_IMETHODIMP
|
||||
nsTextServicesDocument::DidDeleteNode(nsIDOMNode *aChild, nsresult aResult)
|
||||
{
|
||||
if (NS_FAILED(aResult))
|
||||
return NS_OK;
|
||||
NS_ENSURE_SUCCESS(aResult, NS_OK);
|
||||
|
||||
NS_ENSURE_TRUE(mIterator, NS_ERROR_FAILURE);
|
||||
|
||||
@ -1889,8 +1887,7 @@ nsTextServicesDocument::DidJoinNodes(nsIDOMNode *aLeftNode,
|
||||
nsIDOMNode *aParent,
|
||||
nsresult aResult)
|
||||
{
|
||||
if (NS_FAILED(aResult))
|
||||
return NS_OK;
|
||||
NS_ENSURE_SUCCESS(aResult, NS_OK);
|
||||
|
||||
PRInt32 i;
|
||||
PRUint16 type;
|
||||
@ -1905,8 +1902,7 @@ nsTextServicesDocument::DidJoinNodes(nsIDOMNode *aLeftNode,
|
||||
|
||||
result = aLeftNode->GetNodeType(&type);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return PR_FALSE;
|
||||
NS_ENSURE_SUCCESS(result, PR_FALSE);
|
||||
|
||||
if (nsIDOMNode::TEXT_NODE != type)
|
||||
{
|
||||
@ -1916,8 +1912,7 @@ nsTextServicesDocument::DidJoinNodes(nsIDOMNode *aLeftNode,
|
||||
|
||||
result = aRightNode->GetNodeType(&type);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return PR_FALSE;
|
||||
NS_ENSURE_SUCCESS(result, PR_FALSE);
|
||||
|
||||
if (nsIDOMNode::TEXT_NODE != type)
|
||||
{
|
||||
@ -1933,8 +1928,7 @@ nsTextServicesDocument::DidJoinNodes(nsIDOMNode *aLeftNode,
|
||||
|
||||
result = NodeHasOffsetEntry(&mOffsetTable, aLeftNode, &leftHasEntry, &leftIndex);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
if (!leftHasEntry)
|
||||
{
|
||||
@ -1945,8 +1939,7 @@ nsTextServicesDocument::DidJoinNodes(nsIDOMNode *aLeftNode,
|
||||
|
||||
result = NodeHasOffsetEntry(&mOffsetTable, aRightNode, &rightHasEntry, &rightIndex);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
if (!rightHasEntry)
|
||||
{
|
||||
@ -2082,8 +2075,7 @@ nsTextServicesDocument::GetDocumentContentRootNode(nsIDOMNode **aNode)
|
||||
|
||||
result = htmlDoc->GetBody(getter_AddRefs(bodyElement));
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
NS_ENSURE_TRUE(bodyElement, NS_ERROR_FAILURE);
|
||||
|
||||
@ -2097,8 +2089,7 @@ nsTextServicesDocument::GetDocumentContentRootNode(nsIDOMNode **aNode)
|
||||
|
||||
result = mDOMDocument->GetDocumentElement(getter_AddRefs(docElement));
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
NS_ENSURE_TRUE(docElement, NS_ERROR_FAILURE);
|
||||
|
||||
@ -2121,14 +2112,12 @@ nsTextServicesDocument::CreateDocumentContentRange(nsIDOMRange **aRange)
|
||||
|
||||
result = GetDocumentContentRootNode(getter_AddRefs(node));
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
NS_ENSURE_TRUE(node, NS_ERROR_NULL_POINTER);
|
||||
|
||||
result = CallCreateInstance("@mozilla.org/content/range;1", aRange);
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
NS_ENSURE_TRUE(*aRange, NS_ERROR_NULL_POINTER);
|
||||
|
||||
@ -2162,8 +2151,7 @@ nsTextServicesDocument::CreateDocumentContentRootToNodeOffsetRange(nsIDOMNode *a
|
||||
|
||||
result = GetDocumentContentRootNode(getter_AddRefs(bodyNode));
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
NS_ENSURE_TRUE(bodyNode, NS_ERROR_NULL_POINTER);
|
||||
|
||||
@ -2196,23 +2184,20 @@ nsTextServicesDocument::CreateDocumentContentRootToNodeOffsetRange(nsIDOMNode *a
|
||||
|
||||
result = bodyNode->GetChildNodes(getter_AddRefs(nodeList));
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ENSURE_SUCCESS(result, NS_ERROR_FAILURE);
|
||||
|
||||
if (nodeList)
|
||||
{
|
||||
result = nodeList->GetLength(&nodeListLength);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ENSURE_SUCCESS(result, NS_ERROR_FAILURE);
|
||||
|
||||
endOffset = (PRInt32)nodeListLength;
|
||||
}
|
||||
}
|
||||
|
||||
result = CallCreateInstance("@mozilla.org/content/range;1", aRange);
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
NS_ENSURE_TRUE(*aRange, NS_ERROR_NULL_POINTER);
|
||||
|
||||
@ -2241,8 +2226,7 @@ nsTextServicesDocument::CreateDocumentContentIterator(nsIContentIterator **aIter
|
||||
|
||||
result = CreateDocumentContentRange(getter_AddRefs(range));
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
result = CreateContentIterator(range, aIterator);
|
||||
|
||||
@ -2462,8 +2446,7 @@ nsTextServicesDocument::IsTextNode(nsIDOMNode *aNode)
|
||||
|
||||
nsresult result = aNode->GetNodeType(&type);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return PR_FALSE;
|
||||
NS_ENSURE_SUCCESS(result, PR_FALSE);
|
||||
|
||||
return nsIDOMNode::TEXT_NODE == type;
|
||||
}
|
||||
@ -2551,13 +2534,11 @@ nsTextServicesDocument::SetSelectionInternal(PRInt32 aOffset, PRInt32 aLength, P
|
||||
{
|
||||
result = mSelCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection));
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
result = selection->Collapse(sNode, sOffset);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
}
|
||||
|
||||
if (aLength <= 0)
|
||||
@ -2613,8 +2594,7 @@ nsTextServicesDocument::SetSelectionInternal(PRInt32 aOffset, PRInt32 aLength, P
|
||||
{
|
||||
result = selection->Extend(eNode, eOffset);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
}
|
||||
|
||||
//**** KDEBUG ****
|
||||
@ -2645,15 +2625,13 @@ nsTextServicesDocument::GetSelection(nsITextServicesDocument::TSDBlockSelectionS
|
||||
|
||||
result = mSelCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection));
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_FAILURE);
|
||||
|
||||
result = selection->GetIsCollapsed(&isCollapsed);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
// XXX: If we expose this method publicly, we need to
|
||||
// add LOCK_DOC/UNLOCK_DOC calls!
|
||||
@ -2678,8 +2656,7 @@ nsTextServicesDocument::GetCollapsedSelection(nsITextServicesDocument::TSDBlockS
|
||||
|
||||
result = mSelCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection));
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_FAILURE);
|
||||
|
||||
@ -2719,28 +2696,23 @@ nsTextServicesDocument::GetCollapsedSelection(nsITextServicesDocument::TSDBlockS
|
||||
|
||||
result = selection->GetRangeAt(0, getter_AddRefs(range));
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
result = range->GetStartContainer(getter_AddRefs(parent));
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
result = range->GetStartOffset(&offset);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
result = ComparePoints(eStart->mNode, eStartOffset, parent, offset, &e1s1);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
result = ComparePoints(eEnd->mNode, eEndOffset, parent, offset, &e2s1);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
if (e1s1 > 0 || e2s1 < 0)
|
||||
{
|
||||
@ -2793,18 +2765,15 @@ nsTextServicesDocument::GetCollapsedSelection(nsITextServicesDocument::TSDBlockS
|
||||
|
||||
result = CreateRange(eStart->mNode, eStartOffset, eEnd->mNode, eEndOffset, getter_AddRefs(range));
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
result = CreateContentIterator(range, getter_AddRefs(iter));
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
result = parent->HasChildNodes(&hasChildren);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
if (hasChildren)
|
||||
{
|
||||
@ -2818,8 +2787,7 @@ nsTextServicesDocument::GetCollapsedSelection(nsITextServicesDocument::TSDBlockS
|
||||
|
||||
result = parent->GetChildNodes(getter_AddRefs(children));
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
NS_ENSURE_TRUE(children, NS_ERROR_FAILURE);
|
||||
|
||||
@ -2829,8 +2797,7 @@ nsTextServicesDocument::GetCollapsedSelection(nsITextServicesDocument::TSDBlockS
|
||||
|
||||
result = children->GetLength(&numChildren);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
NS_ASSERTION(childIndex <= numChildren, "Invalid selection offset!");
|
||||
|
||||
@ -2842,8 +2809,7 @@ nsTextServicesDocument::GetCollapsedSelection(nsITextServicesDocument::TSDBlockS
|
||||
|
||||
result = children->Item(childIndex, getter_AddRefs(saveNode));
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
nsCOMPtr<nsIContent> content(do_QueryInterface(saveNode));
|
||||
|
||||
@ -2851,8 +2817,7 @@ nsTextServicesDocument::GetCollapsedSelection(nsITextServicesDocument::TSDBlockS
|
||||
|
||||
result = iter->PositionAt(content);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2865,8 +2830,7 @@ nsTextServicesDocument::GetCollapsedSelection(nsITextServicesDocument::TSDBlockS
|
||||
|
||||
result = iter->PositionAt(content);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
saveNode = parent;
|
||||
}
|
||||
@ -2901,8 +2865,7 @@ nsTextServicesDocument::GetCollapsedSelection(nsITextServicesDocument::TSDBlockS
|
||||
nsAutoString str;
|
||||
result = node->GetNodeValue(str);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
offset = str.Length();
|
||||
}
|
||||
@ -2919,8 +2882,7 @@ nsTextServicesDocument::GetCollapsedSelection(nsITextServicesDocument::TSDBlockS
|
||||
|
||||
result = iter->PositionAt(content);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
}
|
||||
|
||||
while (!iter->IsDone())
|
||||
@ -2988,8 +2950,7 @@ nsTextServicesDocument::GetUncollapsedSelection(nsITextServicesDocument::TSDBloc
|
||||
|
||||
result = mSelCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection));
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
NS_ENSURE_TRUE(selection, NS_ERROR_FAILURE);
|
||||
|
||||
@ -3022,8 +2983,7 @@ nsTextServicesDocument::GetUncollapsedSelection(nsITextServicesDocument::TSDBloc
|
||||
|
||||
result = selection->GetRangeCount(&rangeCount);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
// Find the first range in the selection that intersects
|
||||
// the current text block.
|
||||
@ -3032,25 +2992,21 @@ nsTextServicesDocument::GetUncollapsedSelection(nsITextServicesDocument::TSDBloc
|
||||
{
|
||||
result = selection->GetRangeAt(i, getter_AddRefs(range));
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
result = GetRangeEndPoints(range,
|
||||
getter_AddRefs(startParent), &startOffset,
|
||||
getter_AddRefs(endParent), &endOffset);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
result = ComparePoints(eStart->mNode, eStartOffset, endParent, endOffset, &e1s2);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
result = ComparePoints(eEnd->mNode, eEndOffset, startParent, startOffset, &e2s1);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
// Break out of the loop if the text block intersects the current range.
|
||||
|
||||
@ -3071,13 +3027,11 @@ nsTextServicesDocument::GetUncollapsedSelection(nsITextServicesDocument::TSDBloc
|
||||
|
||||
result = ComparePoints(eStart->mNode, eStartOffset, startParent, startOffset, &e1s1);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
result = ComparePoints(eEnd->mNode, eEndOffset, endParent, endOffset, &e2s2);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
if (rangeCount > 1)
|
||||
{
|
||||
@ -3144,8 +3098,7 @@ nsTextServicesDocument::GetUncollapsedSelection(nsITextServicesDocument::TSDBloc
|
||||
|
||||
result = CreateRange(p1, o1, p2, o2, getter_AddRefs(range));
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
// Now iterate over this range to figure out the selection's
|
||||
// block offset and length.
|
||||
@ -3154,8 +3107,7 @@ nsTextServicesDocument::GetUncollapsedSelection(nsITextServicesDocument::TSDBloc
|
||||
|
||||
result = CreateContentIterator(range, getter_AddRefs(iter));
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
// Find the first text node in the range.
|
||||
|
||||
@ -3212,8 +3164,7 @@ nsTextServicesDocument::GetUncollapsedSelection(nsITextServicesDocument::TSDBloc
|
||||
|
||||
result = p2->GetNodeValue(str);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
o2 = str.Length();
|
||||
found = PR_TRUE;
|
||||
@ -3327,20 +3278,17 @@ nsTextServicesDocument::GetRangeEndPoints(nsIDOMRange *aRange,
|
||||
|
||||
result = aRange->GetStartContainer(aStartParent);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
NS_ENSURE_TRUE(aStartParent, NS_ERROR_FAILURE);
|
||||
|
||||
result = aRange->GetStartOffset(aStartOffset);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
result = aRange->GetEndContainer(aEndParent);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
NS_ENSURE_TRUE(aEndParent, NS_ERROR_FAILURE);
|
||||
|
||||
@ -3358,8 +3306,7 @@ nsTextServicesDocument::CreateRange(nsIDOMNode *aStartParent, PRInt32 aStartOffs
|
||||
nsresult result;
|
||||
|
||||
result = CallCreateInstance("@mozilla.org/content/range;1", aRange);
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
NS_ENSURE_TRUE(*aRange, NS_ERROR_NULL_POINTER);
|
||||
|
||||
@ -3488,8 +3435,7 @@ nsTextServicesDocument::FirstTextNodeInPrevBlock(nsIContentIterator *aIterator)
|
||||
|
||||
result = FirstTextNodeInCurrentBlock(aIterator);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return NS_ERROR_FAILURE;
|
||||
NS_ENSURE_SUCCESS(result, NS_ERROR_FAILURE);
|
||||
|
||||
// Point mIterator to the first node before the first text node:
|
||||
|
||||
@ -3647,8 +3593,7 @@ nsTextServicesDocument::CreateOffsetTable(nsTArray<OffsetEntry*> *aOffsetTable,
|
||||
|
||||
result = FirstTextNodeInCurrentBlock(aIterator);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
PRInt32 offset = 0;
|
||||
|
||||
@ -3670,8 +3615,7 @@ nsTextServicesDocument::CreateOffsetTable(nsTArray<OffsetEntry*> *aOffsetTable,
|
||||
|
||||
result = node->GetNodeValue(str);
|
||||
|
||||
if (NS_FAILED(result))
|
||||
return result;
|
||||
NS_ENSURE_SUCCESS(result, result);
|
||||
|
||||
// Add an entry for this text node into the offset table:
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user