Bug 723252 - Various nsHTMLEditor cleanup; r=ehsan

This commit is contained in:
Ms2ger 2012-02-10 11:04:46 +01:00
Родитель a44db1e4d4
Коммит 85a19c84ad
1 изменённых файлов: 26 добавлений и 31 удалений

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

@ -4074,7 +4074,7 @@ nsCOMPtr<nsIDOMElement> nsHTMLEditor::FindPreElement()
nsString prestr ("PRE"); // GetFirstNodeOfType requires capitals
nsCOMPtr<nsIDOMNode> preNode;
if (NS_FAILED(nsEditor::GetFirstNodeOfType(rootNode, prestr,
getter_AddRefs(preNode))))
getter_AddRefs(preNode))))
return 0;
return do_QueryInterface(preNode);
@ -4108,10 +4108,11 @@ nsHTMLEditor::CollapseAdjacentTextNodes(nsIDOMRange *aInRange)
while (!iter->IsDone())
{
nsCOMPtr<nsIDOMCharacterData> text = do_QueryInterface(iter->GetCurrentNode());
if (text && IsEditable(text))
{
textNodes.AppendElement(text);
nsINode* node = iter->GetCurrentNode();
if (node->NodeType() == nsIDOMNode::TEXT_NODE &&
IsEditable(static_cast<nsIContent*>(node))) {
nsCOMPtr<nsIDOMNode> domNode = do_QueryInterface(node);
textNodes.AppendElement(domNode);
}
iter->Next();
@ -4150,10 +4151,10 @@ nsHTMLEditor::CollapseAdjacentTextNodes(nsIDOMRange *aInRange)
NS_IMETHODIMP
nsHTMLEditor::SetSelectionAtDocumentStart(nsISelection *aSelection)
{
nsCOMPtr<nsIDOMElement> rootElement = do_QueryInterface(GetRoot());
dom::Element* rootElement = GetRoot();
NS_ENSURE_TRUE(rootElement, NS_ERROR_NULL_POINTER);
return aSelection->Collapse(rootElement,0);
return aSelection->CollapseNative(rootElement, 0);
}
@ -4920,26 +4921,24 @@ nsHTMLEditor::RemoveAttributeOrEquivalent(nsIDOMElement * aElement,
nsresult
nsHTMLEditor::SetIsCSSEnabled(bool aIsCSSPrefChecked)
{
nsresult err = NS_ERROR_NOT_INITIALIZED;
if (mHTMLCSSUtils)
{
err = mHTMLCSSUtils->SetCSSEnabled(aIsCSSPrefChecked);
if (!mHTMLCSSUtils) {
return NS_ERROR_NOT_INITIALIZED;
}
// Disable the eEditorNoCSSMask flag if we're enabling StyleWithCSS.
if (NS_SUCCEEDED(err)) {
PRUint32 flags = mFlags;
if (aIsCSSPrefChecked) {
// Turn off NoCSS as we're enabling CSS
flags &= ~eEditorNoCSSMask;
} else {
// Turn on NoCSS, as we're disabling CSS.
flags |= eEditorNoCSSMask;
}
err = SetFlags(flags);
NS_ENSURE_SUCCESS(err, err);
nsresult rv = mHTMLCSSUtils->SetCSSEnabled(aIsCSSPrefChecked);
NS_ENSURE_SUCCESS(rv, rv);
// Disable the eEditorNoCSSMask flag if we're enabling StyleWithCSS.
PRUint32 flags = mFlags;
if (aIsCSSPrefChecked) {
// Turn off NoCSS as we're enabling CSS
flags &= ~eEditorNoCSSMask;
} else {
// Turn on NoCSS, as we're disabling CSS.
flags |= eEditorNoCSSMask;
}
return err;
return SetFlags(flags);
}
// Set the block background color
@ -5265,8 +5264,7 @@ nsHTMLEditor::CopyLastEditableChildStyles(nsIDOMNode * aPreviousBlock, nsIDOMNod
res = CreateBR(deepestStyle, 0, address_of(outBRNode));
NS_ENSURE_SUCCESS(res, res);
// Getters must addref
*aOutBrNode = outBRNode;
NS_ADDREF(*aOutBrNode);
outBRNode.forget(aOutBrNode);
}
return NS_OK;
}
@ -5410,9 +5408,7 @@ nsHTMLEditor::GetSelectionContainer(nsIDOMElement ** aReturn)
}
nsCOMPtr<nsIDOMElement> focusElement = do_QueryInterface(focusNode);
*aReturn = focusElement;
NS_IF_ADDREF(*aReturn);
focusElement.forget(aReturn);
return NS_OK;
}
@ -5639,8 +5635,7 @@ nsHTMLEditor::GetFocusedNode()
}
nsCOMPtr<nsIDocument> doc = do_QueryReferent(mDocWeak);
nsCOMPtr<nsINode> node = do_QueryInterface(doc);
return node.forget();
return doc.forget();
}
bool