Bug 1446533 part 3. Remove nsIDOMCharacterData::Get/SetData. r=mystor

MozReview-Commit-ID: 5YeaCPwvIJH
This commit is contained in:
Boris Zbarsky 2018-03-19 15:18:07 -04:00
parent 971ee6f9cb
commit 000840f44a
15 changed files with 29 additions and 55 deletions

View File

@ -139,8 +139,7 @@ NS_IMPL_MAIN_THREAD_ONLY_CYCLE_COLLECTING_RELEASE_WITH_LAST_RELEASE(CharacterDat
void
CharacterData::GetNodeValueInternal(nsAString& aNodeValue)
{
DebugOnly<nsresult> rv = GetData(aNodeValue);
NS_ASSERTION(NS_SUCCEEDED(rv), "GetData() failed!");
GetData(aNodeValue);
}
void
@ -155,7 +154,7 @@ CharacterData::SetNodeValueInternal(const nsAString& aNodeValue,
// Implementation of nsIDOMCharacterData
nsresult
void
CharacterData::GetData(nsAString& aData) const
{
if (mText.Is2b()) {
@ -173,15 +172,16 @@ CharacterData::GetData(nsAString& aData) const
aData.Truncate();
}
}
return NS_OK;
}
nsresult
CharacterData::SetData(const nsAString& aData)
void
CharacterData::SetData(const nsAString& aData, ErrorResult& aRv)
{
return SetTextInternal(0, mText.GetLength(), aData.BeginReading(),
aData.Length(), true);
nsresult rv = SetTextInternal(0, mText.GetLength(), aData.BeginReading(),
aData.Length(), true);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
}
}
nsresult

View File

@ -94,8 +94,6 @@ public:
ErrorResult& aError) override;
// Implementation for nsIDOMCharacterData
nsresult GetData(nsAString& aData) const;
nsresult SetData(const nsAString& aData);
nsresult GetLength(uint32_t* aLength);
nsresult SubstringData(uint32_t aOffset, uint32_t aCount,
nsAString& aReturn);
@ -181,11 +179,8 @@ public:
}
// WebIDL API
// Our XPCOM GetData is just fine for WebIDL
virtual void SetData(const nsAString& aData, ErrorResult& rv)
{
rv = SetData(aData);
}
void GetData(nsAString& aData) const;
virtual void SetData(const nsAString& aData, ErrorResult& rv);
// nsINode::Length() returns the right thing for our length attribute
void SubstringData(uint32_t aStart, uint32_t aCount, nsAString& aReturn,
ErrorResult& rv);

View File

@ -44,7 +44,6 @@ public:
// nsIDOMCharacterData
NS_FORWARD_NSIDOMCHARACTERDATA(CharacterData::)
using CharacterData::SetData; // Prevent hiding overloaded virtual function.
// nsINode
virtual bool IsNodeOfType(uint32_t aFlags) const override;

View File

@ -49,7 +49,6 @@ public:
// nsIDOMCharacterData
NS_FORWARD_NSIDOMCHARACTERDATA(mozilla::dom::CharacterData::)
using CharacterData::SetData; // Prevent hiding overloaded virtual function.
// nsINode
virtual bool IsNodeOfType(uint32_t aFlags) const override;

View File

@ -259,15 +259,13 @@ nsXMLContentSerializer::AppendProcessingInstruction(ProcessingInstruction* aPI,
int32_t aEndOffset,
nsAString& aStr)
{
nsresult rv;
nsAutoString target, data, start;
NS_ENSURE_TRUE(MaybeAddNewlineForRootNode(aStr), NS_ERROR_OUT_OF_MEMORY);
aPI->GetTarget(target);
rv = aPI->GetData(data);
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
aPI->GetData(data);
NS_ENSURE_TRUE(start.AppendLiteral("<?", mozilla::fallible), NS_ERROR_OUT_OF_MEMORY);
NS_ENSURE_TRUE(start.Append(target, mozilla::fallible), NS_ERROR_OUT_OF_MEMORY);
@ -305,11 +303,8 @@ nsXMLContentSerializer::AppendComment(Comment* aComment,
int32_t aEndOffset,
nsAString& aStr)
{
nsresult rv;
nsAutoString data;
rv = aComment->GetData(data);
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
aComment->GetData(data);
int32_t dataLength = data.Length();
if (aStartOffset || (aEndOffset != -1 && aEndOffset < dataLength)) {

View File

@ -16,10 +16,6 @@
[uuid(4109a2d2-e7af-445d-bb72-c7c9b875f35e)]
interface nsIDOMCharacterData : nsIDOMNode
{
attribute DOMString data;
// raises(DOMException) on setting
// raises(DOMException) on retrieval
readonly attribute unsigned long length;
DOMString substringData(in unsigned long offset,
in unsigned long count)

View File

@ -432,10 +432,8 @@ ResourceReader::OnWalkAttribute(nsIDOMNode* aNode,
static nsresult
GetXMLStyleSheetLink(dom::ProcessingInstruction *aPI, nsAString &aHref)
{
nsresult rv;
nsAutoString data;
rv = aPI->GetData(data);
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
aPI->GetData(data);
nsContentUtils::GetPseudoAttributeValue(data, nsGkAtoms::href, aHref);
return NS_OK;
@ -786,11 +784,9 @@ PersistNodeFixup::FixupXMLStyleSheetLink(dom::ProcessingInstruction* aPI,
const nsAString& aHref)
{
NS_ENSURE_ARG_POINTER(aPI);
nsresult rv = NS_OK;
nsAutoString data;
rv = aPI->GetData(data);
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
aPI->GetData(data);
nsAutoString href;
nsContentUtils::GetPseudoAttributeValue(data,
@ -839,10 +835,10 @@ PersistNodeFixup::FixupXMLStyleSheetLink(dom::ProcessingInstruction* aPI,
if (!alternate.IsEmpty()) {
AppendXMLAttr(NS_LITERAL_STRING("alternate"), alternate, newData);
}
aPI->SetData(newData);
aPI->SetData(newData, IgnoreErrors());
}
return rv;
return NS_OK;
}
NS_IMETHODIMP

View File

@ -46,8 +46,6 @@ public:
// nsIDOMCharacterData
NS_FORWARD_NSIDOMCHARACTERDATA(CharacterData::)
using CharacterData::SetData; // Prevent hiding overloaded virtual function.
using CharacterData::GetData;
// nsINode
virtual bool IsNodeOfType(uint32_t aFlags) const override;

View File

@ -27,8 +27,6 @@ public:
// nsIDOMCharacterData
NS_FORWARD_NSIDOMCHARACTERDATA(CharacterData::)
using CharacterData::SetData; // Prevent hiding overloaded virtual function.
using CharacterData::GetData;
// nsINode
virtual bool IsNodeOfType(uint32_t aFlags) const override;

View File

@ -70,8 +70,6 @@ public:
}
UpdateStyleSheetInternal(nullptr, nullptr, true);
}
using ProcessingInstruction::SetData; // Prevent hiding overloaded virtual function.
using ProcessingInstruction::GetData;
protected:
virtual ~XMLStylesheetProcessingInstruction();

View File

@ -3051,7 +3051,9 @@ EditorBase::SetTextImpl(Selection& aSelection, const nsAString& aString,
// We don't support undo here, so we don't really need all of the transaction
// machinery, therefore we can run our transaction directly, breaking all of
// the rules!
nsresult rv = aCharData.SetData(aString);
ErrorResult res;
aCharData.SetData(aString, res);
nsresult rv = res.StealNSResult();
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -3222,7 +3224,7 @@ EditorBase::SplitNodeImpl(const EditorDOMPoint& aStartOfRightNode,
leftText);
rightAsText->DeleteData(0, aStartOfRightNode.Offset());
// Fix left node
leftAsText->GetAsText()->SetData(leftText);
leftAsText->GetAsText()->SetData(leftText, IgnoreErrors());
} else {
MOZ_DIAGNOSTIC_ASSERT(!rightAsText && !leftAsText);
// Otherwise it's an interior node, so shuffle around the children. Go
@ -3389,7 +3391,7 @@ EditorBase::JoinNodesImpl(nsINode* aNodeToKeep,
aNodeToKeep->GetAsText()->GetData(rightText);
aNodeToJoin->GetAsText()->GetData(leftText);
leftText += rightText;
aNodeToKeep->GetAsText()->SetData(leftText);
aNodeToKeep->GetAsText()->SetData(leftText, IgnoreErrors());
} else {
// Otherwise it's an interior node, so shuffle around the children.
nsCOMPtr<nsINodeList> childNodes = aNodeToJoin->ChildNodes();

View File

@ -2008,8 +2008,7 @@ nsresult FindTargetNode(nsINode *aStart, nsCOMPtr<nsINode> &aResult)
// Is this child the magical cookie?
if (child->IsNodeOfType(nsINode::eCOMMENT)) {
nsAutoString data;
nsresult rv = static_cast<Comment*>(child.get())->GetData(data);
NS_ENSURE_SUCCESS(rv, rv);
static_cast<Comment*>(child.get())->GetData(data);
if (data.EqualsLiteral(kInsertCookie)) {
// Yes it is! Return an error so we bubble out and short-circuit the

View File

@ -1300,11 +1300,7 @@ TextEditRules::WillOutputText(Selection* aSelection,
}
// Otherwise, the text is the value.
nsresult rv = text->GetData(*aOutString);
if (NS_WARN_IF(NS_FAILED(rv))) {
// Fall back to the expensive path if it fails.
return NS_OK;
}
text->GetData(*aOutString);
*aHandled = true;
return NS_OK;

View File

@ -178,7 +178,7 @@ nsCounterList::RecalcAll()
if (useNode->mText) {
nsAutoString text;
useNode->GetText(text);
useNode->mText->SetData(text);
useNode->mText->SetData(text, IgnoreErrors());
}
}
}

View File

@ -9,6 +9,9 @@
#include "nsQuoteList.h"
#include "nsReadableUtils.h"
#include "nsIContent.h"
#include "mozilla/ErrorResult.h"
using namespace mozilla;
bool
nsQuoteNode::InitTextFrame(nsGenConList* aList, nsIFrame* aPseudoFrame,
@ -79,7 +82,7 @@ nsQuoteList::RecalcAll()
Calc(node);
if (node->mDepthBefore != oldDepth && node->mText && node->IsRealQuote())
node->mText->SetData(*node->Text());
node->mText->SetData(*node->Text(), IgnoreErrors());
}
}