Bug 1433566 part 8. Convert nsGenericDOMDataNode::GetWholeText to webidl-style calling convention. r=mystor

MozReview-Commit-ID: 1ueFgT3ANRS
This commit is contained in:
Boris Zbarsky 2018-03-19 15:15:38 -04:00
Родитель b5773bb87d
Коммит 3cf3cb7f7f
3 изменённых файлов: 21 добавлений и 25 удалений

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

@ -30,7 +30,7 @@ public:
already_AddRefed<Text> SplitText(uint32_t aOffset, ErrorResult& rv);
void GetWholeText(nsAString& aWholeText, ErrorResult& rv)
{
rv = GetWholeText(aWholeText);
nsGenericDOMDataNode::GetWholeText(aWholeText, rv);
}
static already_AddRefed<Text>

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

@ -720,52 +720,49 @@ nsGenericDOMDataNode::IsLink(nsIURI** aURI) const
static nsIContent*
FirstLogicallyAdjacentTextNode(nsIContent* aNode)
{
nsCOMPtr<nsIContent> parent = aNode->GetParent();
while (aNode) {
do {
nsIContent* sibling = aNode->GetPreviousSibling();
if (!sibling || !sibling->IsNodeOfType(nsINode::eTEXT)) {
if (!sibling || !sibling->IsText()) {
return aNode;
}
aNode = sibling;
}
return parent->GetFirstChild();
} while (1); // Must run out of previous siblings eventually!
}
static nsIContent*
LastLogicallyAdjacentTextNode(nsIContent* aNode)
{
nsCOMPtr<nsIContent> parent = aNode->GetParent();
while (aNode) {
do {
nsIContent* sibling = aNode->GetNextSibling();
if (!sibling) break;
if (!sibling->IsNodeOfType(nsINode::eTEXT)) {
if (!sibling || !sibling->IsText()) {
return aNode;
}
aNode = sibling;
}
return parent->GetLastChild();
} while (1); // Must run out of next siblings eventually!
}
nsresult
nsGenericDOMDataNode::GetWholeText(nsAString& aWholeText)
void
nsGenericDOMDataNode::GetWholeText(nsAString& aWholeText,
ErrorResult& aRv)
{
nsIContent* parent = GetParent();
// Handle parent-less nodes
if (!parent)
return GetData(aWholeText);
if (!parent) {
GetData(aWholeText);
return;
}
int32_t index = parent->ComputeIndexOf(this);
NS_WARNING_ASSERTION(index >= 0,
"Trying to use .wholeText with an anonymous"
"text node child of a binding parent?");
NS_ENSURE_TRUE(index >= 0, NS_ERROR_DOM_NOT_SUPPORTED_ERR);
if (NS_WARN_IF(index < 0)) {
aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
return;
}
nsCOMPtr<nsIContent> first = FirstLogicallyAdjacentTextNode(this);
nsCOMPtr<nsIContent> last = LastLogicallyAdjacentTextNode(this);
@ -785,8 +782,6 @@ nsGenericDOMDataNode::GetWholeText(nsAString& aWholeText)
first = first->GetNextSibling();
}
return NS_OK;
}
//----------------------------------------------------------------------

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

@ -229,7 +229,8 @@ protected:
return parent && parent->IsElement() ? parent->AsElement() : nullptr;
}
nsresult GetWholeText(nsAString& aWholeText);
void GetWholeText(nsAString& aWholeText,
mozilla::ErrorResult& aRv);
nsresult SetTextInternal(uint32_t aOffset, uint32_t aCount,
const char16_t* aBuffer, uint32_t aLength,