mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-22 10:27:03 +00:00
Bug 1741148 - part 1: Rename nsINode::ComputeIndexOf
to ComputeIndexOf_Deprecated
r=smaug
It's hard to fix some callers. Therefore, in this bug, we should fix only simple cases. Therefore, we should rename existing API first. Differential Revision: https://phabricator.services.mozilla.com/D131334
This commit is contained in:
parent
897c5338b4
commit
f2baf0d9ab
@ -858,7 +858,8 @@ void logging::Address(const char* aDescr, LocalAccessible* aAcc) {
|
||||
|
||||
void logging::Node(const char* aDescr, nsINode* aNode) {
|
||||
nsINode* parentNode = aNode ? aNode->GetParentNode() : nullptr;
|
||||
int32_t idxInParent = parentNode ? parentNode->ComputeIndexOf(aNode) : -1;
|
||||
const int32_t idxInParent =
|
||||
parentNode ? parentNode->ComputeIndexOf_Deprecated(aNode) : -1;
|
||||
|
||||
nsAutoString nodeDesc;
|
||||
DescribeNode(aNode, nodeDesc);
|
||||
|
@ -439,7 +439,8 @@ DOMPoint HyperTextAccessible::OffsetToDOMPoint(int32_t aOffset) const {
|
||||
nsINode* node = child->GetNode();
|
||||
nsINode* parentNode = node->GetParentNode();
|
||||
return parentNode ? DOMPoint(parentNode,
|
||||
parentNode->ComputeIndexOf(node) + innerOffset)
|
||||
parentNode->ComputeIndexOf_Deprecated(node) +
|
||||
innerOffset)
|
||||
: DOMPoint();
|
||||
}
|
||||
|
||||
@ -2286,7 +2287,7 @@ nsresult HyperTextAccessible::GetDOMPointByFrameOffset(
|
||||
|
||||
nsIContent* parent = content->GetParent();
|
||||
|
||||
aPoint->idx = parent->ComputeIndexOf(content) + 1;
|
||||
aPoint->idx = parent->ComputeIndexOf_Deprecated(content) + 1;
|
||||
aPoint->node = parent;
|
||||
|
||||
} else if (aFrame->IsTextFrame()) {
|
||||
@ -2307,7 +2308,7 @@ nsresult HyperTextAccessible::GetDOMPointByFrameOffset(
|
||||
nsIContent* parent = content->GetParent();
|
||||
NS_ENSURE_STATE(parent);
|
||||
|
||||
aPoint->idx = parent->ComputeIndexOf(content);
|
||||
aPoint->idx = parent->ComputeIndexOf_Deprecated(content);
|
||||
aPoint->node = parent;
|
||||
}
|
||||
|
||||
|
@ -12983,7 +12983,7 @@ static nsINode* GetCorrespondingNodeInDocument(const nsINode* aOrigNode,
|
||||
nsTArray<int32_t> indexArray;
|
||||
const nsINode* current = aOrigNode;
|
||||
while (const nsINode* parent = current->GetParentNode()) {
|
||||
int32_t index = parent->ComputeIndexOf(current);
|
||||
const int32_t index = parent->ComputeIndexOf_Deprecated(current);
|
||||
MOZ_ASSERT(index >= 0);
|
||||
indexArray.AppendElement(index);
|
||||
current = parent;
|
||||
|
@ -412,7 +412,7 @@ nsIContent* nsAttrChildContentList::Item(uint32_t aIndex) {
|
||||
|
||||
int32_t nsAttrChildContentList::IndexOf(nsIContent* aContent) {
|
||||
if (mNode) {
|
||||
return mNode->ComputeIndexOf(aContent);
|
||||
return mNode->ComputeIndexOf_Deprecated(aContent);
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
@ -203,7 +203,7 @@ class RangeBoundaryBase {
|
||||
MOZ_ASSERT(mRef);
|
||||
MOZ_ASSERT(mRef->GetParentNode() == mParent);
|
||||
|
||||
const int32_t index = mParent->ComputeIndexOf(mRef);
|
||||
const int32_t index = mParent->ComputeIndexOf_Deprecated(mRef);
|
||||
MOZ_ASSERT(index >= 0);
|
||||
mOffset.emplace(static_cast<uint32_t>(index + 1));
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ nsresult RangeUtils::CompareNodeToRange(nsINode* aNode,
|
||||
nodeStart = 0;
|
||||
nodeEnd = aNode->GetChildCount();
|
||||
} else {
|
||||
nodeStart = parent->ComputeIndexOf(aNode);
|
||||
nodeStart = parent->ComputeIndexOf_Deprecated(aNode);
|
||||
NS_WARNING_ASSERTION(
|
||||
nodeStart >= 0,
|
||||
"aNode has the parent node but it does not have aNode!");
|
||||
|
@ -62,7 +62,7 @@ class RangeUtils final {
|
||||
// If aNode isn't in the child nodes of its parent node, we hit this case.
|
||||
// This may occur when we're called by a mutation observer while aNode is
|
||||
// removed from the parent node.
|
||||
int32_t indexInParent = parentNode->ComputeIndexOf(aNode);
|
||||
const int32_t indexInParent = parentNode->ComputeIndexOf_Deprecated(aNode);
|
||||
if (NS_WARN_IF(indexInParent < 0)) {
|
||||
return RawRangeBoundary();
|
||||
}
|
||||
@ -81,7 +81,7 @@ class RangeUtils final {
|
||||
/**
|
||||
* XXX nsRange should accept 0 - UINT32_MAX as offset. However, users of
|
||||
* nsRange treat offset as int32_t. Additionally, some other internal
|
||||
* APIs like nsINode::ComputeIndexOf() use int32_t. Therefore,
|
||||
* APIs like nsINode::ComputeIndexOf_Deprecated() use int32_t. Therefore,
|
||||
* nsRange should accept only 0 - INT32_MAX as valid offset for now.
|
||||
*/
|
||||
static bool IsValidOffset(uint32_t aOffset) { return aOffset <= INT32_MAX; }
|
||||
|
@ -1346,7 +1346,7 @@ nsIFrame* Selection::GetPrimaryFrameForFocusNode(bool aVisual,
|
||||
if (NS_WARN_IF(!parent)) {
|
||||
return nullptr;
|
||||
}
|
||||
int32_t offset = parent->ComputeIndexOf(content);
|
||||
const int32_t offset = parent->ComputeIndexOf_Deprecated(content);
|
||||
|
||||
return GetPrimaryOrCaretFrameForNodeOffset(parent, offset, aOffsetUsed,
|
||||
aVisual);
|
||||
|
@ -2089,7 +2089,8 @@ bool nsContentUtils::InProlog(nsINode* aNode) {
|
||||
Document* doc = parent->AsDocument();
|
||||
nsIContent* root = doc->GetRootElement();
|
||||
|
||||
return !root || doc->ComputeIndexOf(aNode) < doc->ComputeIndexOf(root);
|
||||
return !root || doc->ComputeIndexOf_Deprecated(aNode) <
|
||||
doc->ComputeIndexOf_Deprecated(root);
|
||||
}
|
||||
|
||||
bool nsContentUtils::IsCallerChrome() {
|
||||
@ -2563,7 +2564,7 @@ nsresult nsContentUtils::GetInclusiveAncestorsAndOffsets(
|
||||
nsIContent* parent = child->GetParent();
|
||||
while (parent) {
|
||||
aAncestorNodes->AppendElement(parent);
|
||||
aAncestorOffsets->AppendElement(parent->ComputeIndexOf(child));
|
||||
aAncestorOffsets->AppendElement(parent->ComputeIndexOf_Deprecated(child));
|
||||
child = parent;
|
||||
parent = parent->GetParent();
|
||||
}
|
||||
@ -2692,10 +2693,10 @@ int32_t nsContentUtils::ComparePoints_Deprecated(
|
||||
const nsINode* child1 = parents1.ElementAt(--pos1);
|
||||
const nsINode* child2 = parents2.ElementAt(--pos2);
|
||||
if (child1 != child2) {
|
||||
int32_t child1index = aParent1Cache
|
||||
? aParent1Cache->ComputeIndexOf(parent, child1)
|
||||
: parent->ComputeIndexOf(child1);
|
||||
return child1index < parent->ComputeIndexOf(child2) ? -1 : 1;
|
||||
const int32_t child1index =
|
||||
aParent1Cache ? aParent1Cache->ComputeIndexOf(parent, child1)
|
||||
: parent->ComputeIndexOf_Deprecated(child1);
|
||||
return child1index < parent->ComputeIndexOf_Deprecated(child2) ? -1 : 1;
|
||||
}
|
||||
parent = child1;
|
||||
}
|
||||
@ -2708,7 +2709,7 @@ int32_t nsContentUtils::ComparePoints_Deprecated(
|
||||
|
||||
if (!pos1) {
|
||||
const nsINode* child2 = parents2.ElementAt(--pos2);
|
||||
const int32_t child2Index = parent->ComputeIndexOf(child2);
|
||||
const int32_t child2Index = parent->ComputeIndexOf_Deprecated(child2);
|
||||
if (MOZ_UNLIKELY(NS_WARN_IF(child2Index < 0))) {
|
||||
return 1;
|
||||
}
|
||||
@ -2718,7 +2719,7 @@ int32_t nsContentUtils::ComparePoints_Deprecated(
|
||||
const nsINode* child1 = parents1.ElementAt(--pos1);
|
||||
const int32_t child1Index =
|
||||
aParent1Cache ? aParent1Cache->ComputeIndexOf(parent, child1)
|
||||
: parent->ComputeIndexOf(child1);
|
||||
: parent->ComputeIndexOf_Deprecated(child1);
|
||||
if (MOZ_UNLIKELY(NS_WARN_IF(child1Index < 0))) {
|
||||
return -1;
|
||||
}
|
||||
@ -3125,7 +3126,7 @@ void nsContentUtils::GenerateStateKey(nsIContent* aContent, Document* aDocument,
|
||||
nsINode* parent = aContent->GetParentNode();
|
||||
nsINode* content = aContent;
|
||||
while (parent) {
|
||||
KeyAppendInt(parent->ComputeIndexOf(content), aKey);
|
||||
KeyAppendInt(parent->ComputeIndexOf_Deprecated(content), aKey);
|
||||
content = parent;
|
||||
parent = content->GetParentNode();
|
||||
}
|
||||
|
@ -524,7 +524,7 @@ class nsContentUtils {
|
||||
return mIndex;
|
||||
}
|
||||
|
||||
mIndex = aParent->ComputeIndexOf(aChild);
|
||||
mIndex = aParent->ComputeIndexOf_Deprecated(aChild);
|
||||
mParent = aParent;
|
||||
mChild = aChild;
|
||||
return mIndex;
|
||||
|
@ -4517,7 +4517,7 @@ nsIContent* nsFocusManager::GetNextTabbableMapArea(bool aForward,
|
||||
uint32_t count = mapContent->GetChildCount();
|
||||
// First see if the the start content is in this map
|
||||
|
||||
int32_t index = mapContent->ComputeIndexOf(aStartContent);
|
||||
int32_t index = mapContent->ComputeIndexOf_Deprecated(aStartContent);
|
||||
int32_t tabIndex;
|
||||
if (index < 0 || (aStartContent->IsFocusable(&tabIndex) &&
|
||||
tabIndex != aCurrentTabIndex)) {
|
||||
|
@ -1079,26 +1079,28 @@ uint16_t nsINode::CompareDocumentPosition(nsINode& aOtherNode,
|
||||
const nsINode* child2 = parents2.ElementAt(--pos2);
|
||||
if (child1 != child2) {
|
||||
// child1 or child2 can be an attribute here. This will work fine since
|
||||
// ComputeIndexOf will return -1 for the attribute making the
|
||||
// ComputeIndexOf_Deprecated will return -1 for the attribute making the
|
||||
// attribute be considered before any child.
|
||||
int32_t child1Index;
|
||||
bool cachedChild1Index = false;
|
||||
if (&aOtherNode == child1 && aOtherIndex) {
|
||||
cachedChild1Index = true;
|
||||
child1Index =
|
||||
*aOtherIndex != -1 ? *aOtherIndex : parent->ComputeIndexOf(child1);
|
||||
child1Index = *aOtherIndex != -1
|
||||
? *aOtherIndex
|
||||
: parent->ComputeIndexOf_Deprecated(child1);
|
||||
} else {
|
||||
child1Index = parent->ComputeIndexOf(child1);
|
||||
child1Index = parent->ComputeIndexOf_Deprecated(child1);
|
||||
}
|
||||
|
||||
int32_t child2Index;
|
||||
bool cachedChild2Index = false;
|
||||
if (this == child2 && aThisIndex) {
|
||||
cachedChild2Index = true;
|
||||
child2Index =
|
||||
*aThisIndex != -1 ? *aThisIndex : parent->ComputeIndexOf(child2);
|
||||
child2Index = *aThisIndex != -1
|
||||
? *aThisIndex
|
||||
: parent->ComputeIndexOf_Deprecated(child2);
|
||||
} else {
|
||||
child2Index = parent->ComputeIndexOf(child2);
|
||||
child2Index = parent->ComputeIndexOf_Deprecated(child2);
|
||||
}
|
||||
|
||||
uint16_t retVal = child1Index < child2Index
|
||||
@ -1414,7 +1416,7 @@ bool nsINode::Traverse(nsINode* tmp, nsCycleCollectionTraversalCallback& cb) {
|
||||
nsIContent* parent = tmp->GetParent();
|
||||
if (parent && !parent->UnoptimizableCCNode() &&
|
||||
parent->HasKnownLiveWrapper()) {
|
||||
MOZ_ASSERT(parent->ComputeIndexOf(tmp) >= 0,
|
||||
MOZ_ASSERT(parent->ComputeIndexOf_Deprecated(tmp) >= 0,
|
||||
"Parent doesn't own us?");
|
||||
return false;
|
||||
}
|
||||
@ -1737,16 +1739,17 @@ nsIContent* nsINode::GetChildAt_Deprecated(uint32_t aIndex) const {
|
||||
return child;
|
||||
}
|
||||
|
||||
int32_t nsINode::ComputeIndexOf(const nsINode* aChild) const {
|
||||
if (!aChild) {
|
||||
int32_t nsINode::ComputeIndexOf_Deprecated(
|
||||
const nsINode* aPossibleChild) const {
|
||||
if (!aPossibleChild) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (aChild->GetParentNode() != this) {
|
||||
if (aPossibleChild->GetParentNode() != this) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (aChild == GetLastChild()) {
|
||||
if (aPossibleChild == GetLastChild()) {
|
||||
return GetChildCount() - 1;
|
||||
}
|
||||
|
||||
@ -1755,7 +1758,7 @@ int32_t nsINode::ComputeIndexOf(const nsINode* aChild) const {
|
||||
int32_t childIndex;
|
||||
GetChildAndIndexFromCache(this, &child, &childIndex);
|
||||
if (child) {
|
||||
if (child == aChild) {
|
||||
if (child == aPossibleChild) {
|
||||
return childIndex;
|
||||
}
|
||||
|
||||
@ -1766,16 +1769,16 @@ int32_t nsINode::ComputeIndexOf(const nsINode* aChild) const {
|
||||
do {
|
||||
if (next) {
|
||||
++nextIndex;
|
||||
if (next == aChild) {
|
||||
AddChildAndIndexToCache(this, aChild, nextIndex);
|
||||
if (next == aPossibleChild) {
|
||||
AddChildAndIndexToCache(this, aPossibleChild, nextIndex);
|
||||
return nextIndex;
|
||||
}
|
||||
next = next->GetNextSibling();
|
||||
}
|
||||
if (prev) {
|
||||
--prevIndex;
|
||||
if (prev == aChild) {
|
||||
AddChildAndIndexToCache(this, aChild, prevIndex);
|
||||
if (prev == aPossibleChild) {
|
||||
AddChildAndIndexToCache(this, aPossibleChild, prevIndex);
|
||||
return prevIndex;
|
||||
}
|
||||
prev = prev->GetPreviousSibling();
|
||||
@ -1788,7 +1791,7 @@ int32_t nsINode::ComputeIndexOf(const nsINode* aChild) const {
|
||||
nsINode* current = mFirstChild;
|
||||
while (current) {
|
||||
MOZ_ASSERT(current->GetParentNode() == this);
|
||||
if (current == aChild) {
|
||||
if (current == aPossibleChild) {
|
||||
if (mChildCount >= CACHE_CHILD_LIMIT) {
|
||||
AddChildAndIndexToCache(this, current, index);
|
||||
}
|
||||
@ -2239,8 +2242,9 @@ static void EnsureAllowedAsChild(nsINode* aNewChild, nsINode* aParent,
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t doctypeIndex = aParent->ComputeIndexOf(docTypeContent);
|
||||
int32_t insertIndex = aParent->ComputeIndexOf(aRefChild);
|
||||
const int32_t doctypeIndex =
|
||||
aParent->ComputeIndexOf_Deprecated(docTypeContent);
|
||||
const int32_t insertIndex = aParent->ComputeIndexOf_Deprecated(aRefChild);
|
||||
|
||||
// Now we're OK in the following two cases only:
|
||||
// 1) We're replacing something that's not before the doctype
|
||||
@ -2288,8 +2292,8 @@ static void EnsureAllowedAsChild(nsINode* aNewChild, nsINode* aParent,
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t rootIndex = aParent->ComputeIndexOf(rootElement);
|
||||
int32_t insertIndex = aParent->ComputeIndexOf(aRefChild);
|
||||
const int32_t rootIndex = aParent->ComputeIndexOf_Deprecated(rootElement);
|
||||
const int32_t insertIndex = aParent->ComputeIndexOf_Deprecated(aRefChild);
|
||||
|
||||
// Now we're OK if and only if insertIndex <= rootIndex. Indeed, either
|
||||
// we end up replacing aRefChild or we end up before it. Either one is
|
||||
|
@ -627,7 +627,7 @@ class nsINode : public mozilla::dom::EventTarget {
|
||||
* If the return value is not -1, then calling GetChildAt_Deprecated() with
|
||||
* that value will return aPossibleChild.
|
||||
*/
|
||||
virtual int32_t ComputeIndexOf(const nsINode* aPossibleChild) const;
|
||||
int32_t ComputeIndexOf_Deprecated(const nsINode* aPossibleChild) const;
|
||||
|
||||
/**
|
||||
* Returns the "node document" of this node.
|
||||
|
@ -805,7 +805,7 @@ bool nsRange::IntersectsNode(nsINode& aNode, ErrorResult& aRv) {
|
||||
return GetRoot() == &aNode;
|
||||
}
|
||||
|
||||
const int32_t nodeIndex = parent->ComputeIndexOf(&aNode);
|
||||
const int32_t nodeIndex = parent->ComputeIndexOf_Deprecated(&aNode);
|
||||
if (nodeIndex < 0) {
|
||||
return false;
|
||||
}
|
||||
@ -962,7 +962,7 @@ void nsRange::DoSetRange(const RangeBoundaryBase<SPT, SRT>& aStartBoundary,
|
||||
static int32_t IndexOf(nsINode* aChild) {
|
||||
nsINode* parent = aChild->GetParentNode();
|
||||
|
||||
return parent ? parent->ComputeIndexOf(aChild) : -1;
|
||||
return parent ? parent->ComputeIndexOf_Deprecated(aChild) : -1;
|
||||
}
|
||||
|
||||
void nsRange::RegisterSelection(Selection& aSelection) {
|
||||
@ -1167,10 +1167,12 @@ void nsRange::SelectNodesInContainer(nsINode* aContainer,
|
||||
nsIContent* aStartContent,
|
||||
nsIContent* aEndContent) {
|
||||
MOZ_ASSERT(aContainer);
|
||||
MOZ_ASSERT(aContainer->ComputeIndexOf(aStartContent) <=
|
||||
aContainer->ComputeIndexOf(aEndContent));
|
||||
MOZ_ASSERT(aStartContent && aContainer->ComputeIndexOf(aStartContent) != -1);
|
||||
MOZ_ASSERT(aEndContent && aContainer->ComputeIndexOf(aEndContent) != -1);
|
||||
MOZ_ASSERT(aContainer->ComputeIndexOf_Deprecated(aStartContent) <=
|
||||
aContainer->ComputeIndexOf_Deprecated(aEndContent));
|
||||
MOZ_ASSERT(aStartContent &&
|
||||
aContainer->ComputeIndexOf_Deprecated(aStartContent) != -1);
|
||||
MOZ_ASSERT(aEndContent &&
|
||||
aContainer->ComputeIndexOf_Deprecated(aEndContent) != -1);
|
||||
|
||||
nsINode* newRoot = RangeUtils::ComputeRootNode(aContainer);
|
||||
MOZ_ASSERT(newRoot);
|
||||
@ -1257,7 +1259,7 @@ void nsRange::SelectNode(nsINode& aNode, ErrorResult& aRv) {
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t index = container->ComputeIndexOf(&aNode);
|
||||
const int32_t index = container->ComputeIndexOf_Deprecated(&aNode);
|
||||
// MOZ_ASSERT(index != -1);
|
||||
// We need to compute the index here unfortunately, because, while we have
|
||||
// support for XBL, |container| may be the node's binding parent without
|
||||
@ -3058,7 +3060,7 @@ void nsRange::ExcludeNonSelectableNodes(nsTArray<RefPtr<nsRange>>* aOutRanges) {
|
||||
if (content && content->HasIndependentSelection()) {
|
||||
nsINode* parent = startContainer->GetParent();
|
||||
if (parent) {
|
||||
startOffset = parent->ComputeIndexOf(startContainer);
|
||||
startOffset = parent->ComputeIndexOf_Deprecated(startContainer);
|
||||
startContainer = parent;
|
||||
}
|
||||
}
|
||||
|
@ -1073,7 +1073,7 @@ nsresult ContentEventHandler::SetRawRangeFromFlatTextOffset(
|
||||
if (NS_WARN_IF(!startNode)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
startNodeOffset = startNode->ComputeIndexOf(content);
|
||||
startNodeOffset = startNode->ComputeIndexOf_Deprecated(content);
|
||||
if (NS_WARN_IF(startNodeOffset == -1)) {
|
||||
// The content is being removed from the parent!
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -1084,7 +1084,7 @@ nsresult ContentEventHandler::SetRawRangeFromFlatTextOffset(
|
||||
if (NS_WARN_IF(!startNode)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
startNodeOffset = startNode->ComputeIndexOf(content) + 1;
|
||||
startNodeOffset = startNode->ComputeIndexOf_Deprecated(content) + 1;
|
||||
if (NS_WARN_IF(startNodeOffset == 0)) {
|
||||
// The content is being removed from the parent!
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -1179,7 +1179,7 @@ nsresult ContentEventHandler::SetRawRangeFromFlatTextOffset(
|
||||
if (NS_WARN_IF(!endNode)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
int32_t indexInParent = endNode->ComputeIndexOf(content);
|
||||
const int32_t indexInParent = endNode->ComputeIndexOf_Deprecated(content);
|
||||
if (NS_WARN_IF(indexInParent == -1)) {
|
||||
// The content is being removed from the parent!
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -2738,7 +2738,8 @@ nsresult ContentEventHandler::GetFlatTextLengthInRange(
|
||||
if (aIsRemovingNode) {
|
||||
DebugOnly<nsIContent*> parent = aStartPosition.Container()->GetParent();
|
||||
MOZ_ASSERT(
|
||||
parent && parent->ComputeIndexOf(aStartPosition.Container()) == -1,
|
||||
parent &&
|
||||
parent->ComputeIndexOf_Deprecated(aStartPosition.Container()) == -1,
|
||||
"At removing the node, the node shouldn't be in the array of children "
|
||||
"of its parent");
|
||||
MOZ_ASSERT(aStartPosition.Container() == endPosition.Container(),
|
||||
@ -2780,8 +2781,8 @@ nsresult ContentEventHandler::GetFlatTextLengthInRange(
|
||||
if (NS_WARN_IF(!parentContent)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
int32_t indexInParent =
|
||||
parentContent->ComputeIndexOf(endPosition.Container());
|
||||
const int32_t indexInParent =
|
||||
parentContent->ComputeIndexOf_Deprecated(endPosition.Container());
|
||||
if (NS_WARN_IF(indexInParent < 0)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
@ -2999,8 +3000,8 @@ static void AdjustRangeForSelection(nsIContent* aRoot, nsINode** aNode,
|
||||
}
|
||||
|
||||
*aNode = node->GetParent();
|
||||
MOZ_ASSERT((*aNode)->ComputeIndexOf(node) != -1);
|
||||
*aNodeOffset = (*aNode)->ComputeIndexOf(node) + 1;
|
||||
MOZ_ASSERT((*aNode)->ComputeIndexOf_Deprecated(node) != -1);
|
||||
*aNodeOffset = (*aNode)->ComputeIndexOf_Deprecated(node) + 1;
|
||||
}
|
||||
|
||||
nsresult ContentEventHandler::OnSelectionEvent(WidgetSelectionEvent* aEvent) {
|
||||
|
@ -128,9 +128,9 @@ void HTMLFieldSetElement::InsertChildBefore(nsIContent* aChild,
|
||||
} else {
|
||||
// If mFirstLegend is before aIndex, we do not change it.
|
||||
// Otherwise, mFirstLegend is now aChild.
|
||||
int32_t index =
|
||||
aBeforeThis ? ComputeIndexOf(aBeforeThis) : GetChildCount();
|
||||
if (index <= ComputeIndexOf(mFirstLegend)) {
|
||||
const int32_t index = aBeforeThis ? ComputeIndexOf_Deprecated(aBeforeThis)
|
||||
: static_cast<int32_t>(GetChildCount());
|
||||
if (index <= ComputeIndexOf_Deprecated(mFirstLegend)) {
|
||||
mFirstLegend = aChild;
|
||||
firstLegendHasChanged = true;
|
||||
}
|
||||
|
@ -60,7 +60,8 @@ static bool IsPreviousSibling(nsINode* aSubject, nsINode* aNode) {
|
||||
|
||||
nsINode* parent = aSubject->GetParentNode();
|
||||
if (parent && parent == aNode->GetParentNode()) {
|
||||
return parent->ComputeIndexOf(aSubject) < parent->ComputeIndexOf(aNode);
|
||||
return parent->ComputeIndexOf_Deprecated(aSubject) <
|
||||
parent->ComputeIndexOf_Deprecated(aNode);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -58,7 +58,8 @@ Element* HTMLOptGroupElement::GetSelect() {
|
||||
void HTMLOptGroupElement::InsertChildBefore(nsIContent* aKid,
|
||||
nsIContent* aBeforeThis,
|
||||
bool aNotify, ErrorResult& aRv) {
|
||||
int32_t index = aBeforeThis ? ComputeIndexOf(aBeforeThis) : GetChildCount();
|
||||
const int32_t index = aBeforeThis ? ComputeIndexOf_Deprecated(aBeforeThis)
|
||||
: static_cast<int32_t>(GetChildCount());
|
||||
SafeOptionListMutation safeMutation(GetSelect(), this, aKid, index, aNotify);
|
||||
nsGenericHTMLElement::InsertChildBefore(aKid, aBeforeThis, aNotify, aRv);
|
||||
if (aRv.Failed()) {
|
||||
@ -68,7 +69,7 @@ void HTMLOptGroupElement::InsertChildBefore(nsIContent* aKid,
|
||||
|
||||
void HTMLOptGroupElement::RemoveChildNode(nsIContent* aKid, bool aNotify) {
|
||||
SafeOptionListMutation safeMutation(GetSelect(), this, nullptr,
|
||||
ComputeIndexOf(aKid), aNotify);
|
||||
ComputeIndexOf_Deprecated(aKid), aNotify);
|
||||
nsGenericHTMLElement::RemoveChildNode(aKid, aNotify);
|
||||
}
|
||||
|
||||
|
@ -180,7 +180,8 @@ void HTMLSelectElement::GetAutocompleteInfo(AutocompleteInfo& aInfo) {
|
||||
void HTMLSelectElement::InsertChildBefore(nsIContent* aKid,
|
||||
nsIContent* aBeforeThis, bool aNotify,
|
||||
ErrorResult& aRv) {
|
||||
int32_t index = aBeforeThis ? ComputeIndexOf(aBeforeThis) : GetChildCount();
|
||||
const int32_t index = aBeforeThis ? ComputeIndexOf_Deprecated(aBeforeThis)
|
||||
: static_cast<int32_t>(GetChildCount());
|
||||
SafeOptionListMutation safeMutation(this, this, aKid, index, aNotify);
|
||||
nsGenericHTMLFormControlElementWithState::InsertChildBefore(aKid, aBeforeThis,
|
||||
aNotify, aRv);
|
||||
@ -190,8 +191,8 @@ void HTMLSelectElement::InsertChildBefore(nsIContent* aKid,
|
||||
}
|
||||
|
||||
void HTMLSelectElement::RemoveChildNode(nsIContent* aKid, bool aNotify) {
|
||||
SafeOptionListMutation safeMutation(this, this, nullptr, ComputeIndexOf(aKid),
|
||||
aNotify);
|
||||
SafeOptionListMutation safeMutation(this, this, nullptr,
|
||||
ComputeIndexOf_Deprecated(aKid), aNotify);
|
||||
nsGenericHTMLFormControlElementWithState::RemoveChildNode(aKid, aNotify);
|
||||
}
|
||||
|
||||
@ -447,8 +448,8 @@ int32_t HTMLSelectElement::GetOptionIndexAfter(nsIContent* aOptions) {
|
||||
nsCOMPtr<nsIContent> parent = aOptions->GetParent();
|
||||
|
||||
if (parent) {
|
||||
int32_t index = parent->ComputeIndexOf(aOptions);
|
||||
int32_t count = parent->GetChildCount();
|
||||
const int32_t index = parent->ComputeIndexOf_Deprecated(aOptions);
|
||||
const int32_t count = static_cast<int32_t>(parent->GetChildCount());
|
||||
|
||||
retval = GetFirstChildOptionIndex(parent, index + 1, count);
|
||||
|
||||
|
@ -50,7 +50,7 @@ int32_t CompareTextTracks::TrackChildPosition(TextTrack* aTextTrack) const {
|
||||
if (!trackElement) {
|
||||
return -1;
|
||||
}
|
||||
return mMediaElement->ComputeIndexOf(trackElement);
|
||||
return mMediaElement->ComputeIndexOf_Deprecated(trackElement);
|
||||
}
|
||||
|
||||
bool CompareTextTracks::Equals(TextTrack* aOne, TextTrack* aTwo) const {
|
||||
@ -473,7 +473,7 @@ class CompareSimpleTextTrackEvents {
|
||||
if (aEvent->mTrack) {
|
||||
HTMLTrackElement* trackElement = aEvent->mTrack->GetTrackElement();
|
||||
if (trackElement) {
|
||||
return mMediaElement->ComputeIndexOf(trackElement);
|
||||
return mMediaElement->ComputeIndexOf_Deprecated(trackElement);
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
|
@ -526,8 +526,9 @@ HTMLFormElement* nsGenericHTMLElement::FindAncestorForm(
|
||||
// anonymous. Check for this the hard way.
|
||||
for (nsIContent* child = this; child != content;
|
||||
child = child->GetParent()) {
|
||||
NS_ASSERTION(child->GetParent()->ComputeIndexOf(child) != -1,
|
||||
"Walked too far?");
|
||||
NS_ASSERTION(
|
||||
child->GetParent()->ComputeIndexOf_Deprecated(child) != -1,
|
||||
"Walked too far?");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -2025,7 +2025,7 @@ nsresult nsHTMLCopyEncoder::GetNodeLocation(nsINode* inChild,
|
||||
}
|
||||
|
||||
*outParent = parent;
|
||||
*outOffset = parent->ComputeIndexOf(child);
|
||||
*outOffset = parent->ComputeIndexOf_Deprecated(child);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
@ -371,7 +371,7 @@ nsXMLContentSink::OnTransformDone(nsresult aResult, Document* aResultDocument) {
|
||||
// documentElement?
|
||||
nsIContent* rootElement = mDocument->GetRootElement();
|
||||
if (rootElement) {
|
||||
NS_ASSERTION(mDocument->ComputeIndexOf(rootElement) != -1,
|
||||
NS_ASSERTION(mDocument->ComputeIndexOf_Deprecated(rootElement) != -1,
|
||||
"rootElement not in doc?");
|
||||
mDocument->BeginUpdate();
|
||||
MutationObservers::NotifyContentInserted(mDocument, rootElement);
|
||||
|
@ -520,7 +520,8 @@ int txXPathNodeUtils::comparePosition(const txXPathNode& aNode,
|
||||
return node < otherNode ? -1 : 1;
|
||||
}
|
||||
|
||||
return parent->ComputeIndexOf(node) < parent->ComputeIndexOf(otherNode)
|
||||
return parent->ComputeIndexOf_Deprecated(node) <
|
||||
parent->ComputeIndexOf_Deprecated(otherNode)
|
||||
? -1
|
||||
: 1;
|
||||
}
|
||||
@ -558,8 +559,8 @@ int txXPathNodeUtils::comparePosition(const txXPathNode& aNode,
|
||||
return node < otherNode ? -1 : 1;
|
||||
}
|
||||
|
||||
int32_t index = parent->ComputeIndexOf(node);
|
||||
int32_t otherIndex = parent->ComputeIndexOf(otherNode);
|
||||
const int32_t index = parent->ComputeIndexOf_Deprecated(node);
|
||||
const int32_t otherIndex = parent->ComputeIndexOf_Deprecated(otherNode);
|
||||
NS_ASSERTION(index != otherIndex && index >= 0 && otherIndex >= 0,
|
||||
"invalid index in compareTreePosition");
|
||||
|
||||
|
@ -1335,7 +1335,7 @@ MOZ_CAN_RUN_SCRIPT_BOUNDARY NS_IMETHODIMP EditorBase::BeginningOfDocument() {
|
||||
}
|
||||
|
||||
MOZ_ASSERT(
|
||||
parent->ComputeIndexOf(firstEditableLeaf) == 0,
|
||||
parent->ComputeIndexOf_Deprecated(firstEditableLeaf) == 0,
|
||||
"How come the first node isn't the left most child in its parent?");
|
||||
nsresult rv = SelectionRef().CollapseInLimiter(parent, 0);
|
||||
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
|
||||
|
@ -498,7 +498,7 @@ class EditorDOMPointBase final {
|
||||
const_cast<SelfType*>(this)->mOffset = mozilla::Some(0);
|
||||
} else {
|
||||
const_cast<SelfType*>(this)->mOffset =
|
||||
mozilla::Some(mParent->ComputeIndexOf(mChild));
|
||||
mozilla::Some(mParent->ComputeIndexOf_Deprecated(mChild));
|
||||
}
|
||||
return mOffset.value();
|
||||
}
|
||||
|
@ -7384,7 +7384,8 @@ nsresult HTMLEditor::HandleInsertParagraphInListItemElement(
|
||||
if (HTMLEditUtils::IsEmptyNode(aListItem)) {
|
||||
if (aListItem.IsAnyOfHTMLElements(nsGkAtoms::dd, nsGkAtoms::dt)) {
|
||||
nsCOMPtr<nsINode> list = aListItem.GetParentNode();
|
||||
int32_t itemOffset = list ? list->ComputeIndexOf(&aListItem) : -1;
|
||||
const int32_t itemOffset =
|
||||
list ? list->ComputeIndexOf_Deprecated(&aListItem) : -1;
|
||||
|
||||
nsStaticAtom* nextDefinitionListItemTagName =
|
||||
aListItem.IsHTMLElement(nsGkAtoms::dt) ? nsGkAtoms::dd
|
||||
|
@ -201,7 +201,7 @@ static bool ContentIsInTraversalRange(nsIContent* aContent, bool aIsPreMode,
|
||||
if (MOZ_UNLIKELY(NS_WARN_IF(!parentContent))) {
|
||||
return false;
|
||||
}
|
||||
int32_t offsetInParent = parentContent->ComputeIndexOf(aContent);
|
||||
int32_t offsetInParent = parentContent->ComputeIndexOf_Deprecated(aContent);
|
||||
NS_WARNING_ASSERTION(
|
||||
offsetInParent >= 0,
|
||||
"Content is not in the parent, is this called during a DOM mutation?");
|
||||
|
@ -1180,8 +1180,8 @@ int32_t nsLayoutUtils::DoCompareTreePosition(
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t index1 = parent->ComputeIndexOf(content1Ancestor);
|
||||
int32_t index2 = parent->ComputeIndexOf(content2Ancestor);
|
||||
const int32_t index1 = parent->ComputeIndexOf_Deprecated(content1Ancestor);
|
||||
const int32_t index2 = parent->ComputeIndexOf_Deprecated(content2Ancestor);
|
||||
|
||||
// None of the nodes are anonymous, just do a regular comparison.
|
||||
if (index1 >= 0 && index2 >= 0) {
|
||||
|
@ -210,7 +210,7 @@ nsIFrame::ContentOffsets BRFrame::CalcContentOffsetsFromFramePoint(
|
||||
ContentOffsets offsets;
|
||||
offsets.content = mContent->GetParent();
|
||||
if (offsets.content) {
|
||||
offsets.offset = offsets.content->ComputeIndexOf(mContent);
|
||||
offsets.offset = offsets.content->ComputeIndexOf_Deprecated(mContent);
|
||||
offsets.secondaryOffset = offsets.offset;
|
||||
offsets.associate = CARET_ASSOCIATE_AFTER;
|
||||
}
|
||||
|
@ -498,11 +498,9 @@ void nsContainerFrame::DisplaySelectionOverlay(nsDisplayListBuilder* aBuilder,
|
||||
nsIContent* newContent = mContent->GetParent();
|
||||
|
||||
// check to see if we are anonymous content
|
||||
int32_t offset = 0;
|
||||
if (newContent) {
|
||||
// XXXbz there has GOT to be a better way of determining this!
|
||||
offset = newContent->ComputeIndexOf(mContent);
|
||||
}
|
||||
// XXXbz there has GOT to be a better way of determining this!
|
||||
uint32_t offset =
|
||||
newContent ? newContent->ComputeIndexOf_Deprecated(mContent) : 0;
|
||||
|
||||
// look up to see what selection(s) are on this frame
|
||||
UniquePtr<SelectionDetails> details =
|
||||
|
@ -1332,7 +1332,7 @@ namespace {
|
||||
struct ParentAndOffset {
|
||||
explicit ParentAndOffset(const nsINode& aNode)
|
||||
: mParent{aNode.GetParent()},
|
||||
mOffset{mParent ? mParent->ComputeIndexOf(&aNode) : 0} {}
|
||||
mOffset{mParent ? mParent->ComputeIndexOf_Deprecated(&aNode) : 0} {}
|
||||
|
||||
nsINode* mParent;
|
||||
|
||||
@ -2724,7 +2724,7 @@ nsresult SelectCellElement(nsIContent* aCellElement,
|
||||
nsIContent* parent = aCellElement->GetParent();
|
||||
|
||||
// Get child offset
|
||||
int32_t offset = parent->ComputeIndexOf(aCellElement);
|
||||
const int32_t offset = parent->ComputeIndexOf_Deprecated(aCellElement);
|
||||
|
||||
return CreateAndAddRange(parent, offset, aNormalSelection);
|
||||
}
|
||||
|
@ -4526,9 +4526,12 @@ nsresult nsIFrame::GetDataForTableSelection(
|
||||
nsCOMPtr<nsIContent> parentContent = tableOrCellContent->GetParent();
|
||||
if (!parentContent) return NS_ERROR_FAILURE;
|
||||
|
||||
int32_t offset = parentContent->ComputeIndexOf(tableOrCellContent);
|
||||
const int32_t offset =
|
||||
parentContent->ComputeIndexOf_Deprecated(tableOrCellContent);
|
||||
// Not likely?
|
||||
if (offset < 0) return NS_ERROR_FAILURE;
|
||||
if (offset < 0) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// Everything is OK -- set the return values
|
||||
parentContent.forget(aParentContent);
|
||||
@ -5292,7 +5295,7 @@ static FrameContentRange GetRangeForFrame(const nsIFrame* aFrame) {
|
||||
|
||||
if (type == LayoutFrameType::Br) {
|
||||
nsIContent* parent = content->GetParent();
|
||||
int32_t beginOffset = parent->ComputeIndexOf(content);
|
||||
const int32_t beginOffset = parent->ComputeIndexOf_Deprecated(content);
|
||||
return FrameContentRange(parent, beginOffset, beginOffset);
|
||||
}
|
||||
|
||||
@ -5308,7 +5311,7 @@ static FrameContentRange GetRangeForFrame(const nsIFrame* aFrame) {
|
||||
// TODO(emilio): Revise this in presence of Shadow DOM / display: contents,
|
||||
// it's likely that we don't want to just walk the light tree, and we need to
|
||||
// change the representation of FrameContentRange.
|
||||
int32_t index = parent->ComputeIndexOf(content);
|
||||
const int32_t index = parent->ComputeIndexOf_Deprecated(content);
|
||||
MOZ_ASSERT(index >= 0);
|
||||
return FrameContentRange(parent, index, index + 1);
|
||||
}
|
||||
@ -7828,7 +7831,7 @@ int32_t nsIFrame::ContentIndexInContainer(const nsIFrame* aFrame) {
|
||||
if (content) {
|
||||
nsIContent* parentContent = content->GetParent();
|
||||
if (parentContent) {
|
||||
result = parentContent->ComputeIndexOf(content);
|
||||
result = parentContent->ComputeIndexOf_Deprecated(content);
|
||||
}
|
||||
}
|
||||
|
||||
@ -8133,7 +8136,7 @@ nsresult nsIFrame::GetPointFromOffset(int32_t inOffset, nsPoint* outPoint) {
|
||||
if (mContent) {
|
||||
nsIContent* newContent = mContent->GetParent();
|
||||
if (newContent) {
|
||||
int32_t newOffset = newContent->ComputeIndexOf(mContent);
|
||||
const int32_t newOffset = newContent->ComputeIndexOf_Deprecated(mContent);
|
||||
|
||||
// Find the direction of the frame from the EmbeddingLevelProperty,
|
||||
// which is the resolved bidi level set in
|
||||
@ -8348,7 +8351,8 @@ nsresult nsIFrame::GetNextPrevLineFromeBlockFrame(nsPresContext* aPresContext,
|
||||
nsIContent* parent = content->GetParent();
|
||||
if (parent) {
|
||||
aPos->mResultContent = parent;
|
||||
aPos->mContentOffset = parent->ComputeIndexOf(content);
|
||||
aPos->mContentOffset =
|
||||
parent->ComputeIndexOf_Deprecated(content);
|
||||
aPos->mAttach = CARET_ASSOCIATE_BEFORE;
|
||||
if ((point.x - offset.x + tempRect.x) > tempRect.width) {
|
||||
aPos->mContentOffset++; // go to end of this frame
|
||||
@ -8499,9 +8503,10 @@ static nsContentAndOffset FindLineBreakingFrame(nsIFrame* aFrame,
|
||||
// content. This probably shouldn't ever happen, but since it sometimes
|
||||
// does, we want to avoid crashing here.
|
||||
NS_ASSERTION(result.mContent, "Unexpected orphan content");
|
||||
if (result.mContent)
|
||||
result.mOffset = result.mContent->ComputeIndexOf(content) +
|
||||
if (result.mContent) {
|
||||
result.mOffset = result.mContent->ComputeIndexOf_Deprecated(content) +
|
||||
(aDirection == eDirPrevious ? 1 : 0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -2289,7 +2289,7 @@ void nsTableFrame::HomogenousInsertFrames(ChildListID aListID,
|
||||
}
|
||||
nsCOMPtr<nsIContent> container = content->GetParent();
|
||||
if (MOZ_LIKELY(container)) { // XXX need this null-check, see bug 411823.
|
||||
int32_t newIndex = container->ComputeIndexOf(content);
|
||||
const int32_t newIndex = container->ComputeIndexOf_Deprecated(content);
|
||||
nsIFrame* kidFrame;
|
||||
nsTableColGroupFrame* lastColGroup = nullptr;
|
||||
if (isColGroup) {
|
||||
@ -2313,7 +2313,7 @@ void nsTableFrame::HomogenousInsertFrames(ChildListID aListID,
|
||||
(parentContent == (content = pseudoFrame->GetContent()))) {
|
||||
pseudoFrame = pseudoFrame->PrincipalChildList().FirstChild();
|
||||
}
|
||||
int32_t index = container->ComputeIndexOf(content);
|
||||
const int32_t index = container->ComputeIndexOf_Deprecated(content);
|
||||
if (index > lastIndex && index < newIndex) {
|
||||
lastIndex = index;
|
||||
aPrevFrame = kidFrame;
|
||||
|
@ -263,14 +263,14 @@ void nsMenuBarX::ObserveContentRemoved(mozilla::dom::Document* aDocument, nsICon
|
||||
nsIContent* aChild, nsIContent* aPreviousSibling) {
|
||||
nsINode* parent = NODE_FROM(aContainer, aDocument);
|
||||
MOZ_ASSERT(parent);
|
||||
int32_t index = parent->ComputeIndexOf(aPreviousSibling) + 1;
|
||||
const int32_t index = parent->ComputeIndexOf_Deprecated(aPreviousSibling) + 1;
|
||||
RemoveMenuAtIndex(index);
|
||||
}
|
||||
|
||||
void nsMenuBarX::ObserveContentInserted(mozilla::dom::Document* aDocument, nsIContent* aContainer,
|
||||
nsIContent* aChild) {
|
||||
InsertMenuAtIndex(MakeRefPtr<nsMenuX>(this, mMenuGroupOwner, aChild),
|
||||
aContainer->ComputeIndexOf(aChild));
|
||||
aContainer->ComputeIndexOf_Deprecated(aChild));
|
||||
}
|
||||
|
||||
void nsMenuBarX::ForceUpdateNativeMenuAt(const nsAString& aIndexString) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user