|
@@ -0,0 +1,2642 @@
|
|
|
+# HG changeset patch
|
|
|
+# User Andrea Marchesini <amarchesini@mozilla.com>
|
|
|
+# Date 1516714218 -3600
|
|
|
+# Node ID 149124e4fde985158d5d78a87ade1cced1a2410b
|
|
|
+# Parent a89f28254bc7517716778fa2ccb22ee02e67ab7c
|
|
|
+Bug 1430997 - Rename nsINode::IndexOf to nsINode::ComputeIndexOf, r=catalinb
|
|
|
+
|
|
|
+diff --git a/accessible/base/Logging.cpp b/accessible/base/Logging.cpp
|
|
|
+--- a/accessible/base/Logging.cpp
|
|
|
++++ b/accessible/base/Logging.cpp
|
|
|
+@@ -829,17 +829,17 @@ logging::Node(const char* aDescr, nsINod
|
|
|
+ }
|
|
|
+
|
|
|
+ if (aNode->IsNodeOfType(nsINode::eDOCUMENT)) {
|
|
|
+ printf("%s: %p, document\n", aDescr, static_cast<void*>(aNode));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ nsINode* parentNode = aNode->GetParentNode();
|
|
|
+- int32_t idxInParent = parentNode ? parentNode->IndexOf(aNode) : - 1;
|
|
|
++ int32_t idxInParent = parentNode ? parentNode->ComputeIndexOf(aNode) : - 1;
|
|
|
+
|
|
|
+ if (aNode->IsNodeOfType(nsINode::eTEXT)) {
|
|
|
+ printf("%s: %p, text node, idx in parent: %d\n",
|
|
|
+ aDescr, static_cast<void*>(aNode), idxInParent);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!aNode->IsElement()) {
|
|
|
+diff --git a/accessible/generic/HyperTextAccessible.cpp b/accessible/generic/HyperTextAccessible.cpp
|
|
|
+--- a/accessible/generic/HyperTextAccessible.cpp
|
|
|
++++ b/accessible/generic/HyperTextAccessible.cpp
|
|
|
+@@ -423,17 +423,17 @@ HyperTextAccessible::OffsetToDOMPoint(in
|
|
|
+ innerOffset = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Case of embedded object. The point is either before or after the element.
|
|
|
+ NS_ASSERTION(innerOffset == 0 || innerOffset == 1, "A wrong inner offset!");
|
|
|
+ nsINode* node = child->GetNode();
|
|
|
+ nsINode* parentNode = node->GetParentNode();
|
|
|
+ return parentNode ?
|
|
|
+- DOMPoint(parentNode, parentNode->IndexOf(node) + innerOffset) :
|
|
|
++ DOMPoint(parentNode, parentNode->ComputeIndexOf(node) + innerOffset) :
|
|
|
+ DOMPoint();
|
|
|
+ }
|
|
|
+
|
|
|
+ DOMPoint
|
|
|
+ HyperTextAccessible::ClosestNotGeneratedDOMPoint(const DOMPoint& aDOMPoint,
|
|
|
+ nsIContent* aElementContent)
|
|
|
+ {
|
|
|
+ MOZ_ASSERT(aDOMPoint.node, "The node must not be null");
|
|
|
+@@ -2076,17 +2076,17 @@ HyperTextAccessible::GetDOMPointByFrameO
|
|
|
+ NS_ASSERTION(!aAccessible->IsDoc(),
|
|
|
+ "Shouldn't be called on document accessible!");
|
|
|
+
|
|
|
+ nsIContent* content = aAccessible->GetContent();
|
|
|
+ NS_ASSERTION(content, "Shouldn't operate on defunct accessible!");
|
|
|
+
|
|
|
+ nsIContent* parent = content->GetParent();
|
|
|
+
|
|
|
+- aPoint->idx = parent->IndexOf(content) + 1;
|
|
|
++ aPoint->idx = parent->ComputeIndexOf(content) + 1;
|
|
|
+ aPoint->node = parent;
|
|
|
+
|
|
|
+ } else if (aFrame->IsTextFrame()) {
|
|
|
+ nsIContent* content = aFrame->GetContent();
|
|
|
+ NS_ENSURE_STATE(content);
|
|
|
+
|
|
|
+ nsIFrame *primaryFrame = content->GetPrimaryFrame();
|
|
|
+ nsresult rv = RenderedToContentOffset(primaryFrame, aOffset, &(aPoint->idx));
|
|
|
+@@ -2096,17 +2096,17 @@ HyperTextAccessible::GetDOMPointByFrameO
|
|
|
+
|
|
|
+ } else {
|
|
|
+ nsIContent* content = aFrame->GetContent();
|
|
|
+ NS_ENSURE_STATE(content);
|
|
|
+
|
|
|
+ nsIContent* parent = content->GetParent();
|
|
|
+ NS_ENSURE_STATE(parent);
|
|
|
+
|
|
|
+- aPoint->idx = parent->IndexOf(content);
|
|
|
++ aPoint->idx = parent->ComputeIndexOf(content);
|
|
|
+ aPoint->node = parent;
|
|
|
+ }
|
|
|
+
|
|
|
+ return NS_OK;
|
|
|
+ }
|
|
|
+
|
|
|
+ // HyperTextAccessible
|
|
|
+ void
|
|
|
+diff --git a/dom/base/Attr.cpp b/dom/base/Attr.cpp
|
|
|
+--- a/dom/base/Attr.cpp
|
|
|
++++ b/dom/base/Attr.cpp
|
|
|
+@@ -309,17 +309,17 @@ Attr::GetChildCount() const
|
|
|
+
|
|
|
+ nsIContent *
|
|
|
+ Attr::GetChildAt_Deprecated(uint32_t aIndex) const
|
|
|
+ {
|
|
|
+ return nullptr;
|
|
|
+ }
|
|
|
+
|
|
|
+ int32_t
|
|
|
+-Attr::IndexOf(const nsINode* aPossibleChild) const
|
|
|
++Attr::ComputeIndexOf(const nsINode* aPossibleChild) const
|
|
|
+ {
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ nsresult
|
|
|
+ Attr::InsertChildAt(nsIContent* aKid, uint32_t aIndex,
|
|
|
+ bool aNotify)
|
|
|
+ {
|
|
|
+diff --git a/dom/base/Attr.h b/dom/base/Attr.h
|
|
|
+--- a/dom/base/Attr.h
|
|
|
++++ b/dom/base/Attr.h
|
|
|
+@@ -61,17 +61,17 @@ public:
|
|
|
+ void SetMap(nsDOMAttributeMap *aMap) override;
|
|
|
+ Element* GetElement() const;
|
|
|
+ nsresult SetOwnerDocument(nsIDocument* aDocument) override;
|
|
|
+
|
|
|
+ // nsINode interface
|
|
|
+ virtual bool IsNodeOfType(uint32_t aFlags) const override;
|
|
|
+ virtual uint32_t GetChildCount() const override;
|
|
|
+ virtual nsIContent *GetChildAt_Deprecated(uint32_t aIndex) const override;
|
|
|
+- virtual int32_t IndexOf(const nsINode* aPossibleChild) const override;
|
|
|
++ virtual int32_t ComputeIndexOf(const nsINode* aPossibleChild) const override;
|
|
|
+ virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,
|
|
|
+ bool aNotify) override;
|
|
|
+ virtual void RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify) override;
|
|
|
+ virtual void RemoveChildNode(nsIContent* aKid, bool aNotify) override;
|
|
|
+ virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
|
|
|
+ bool aPreallocateChildren) const override;
|
|
|
+ virtual already_AddRefed<nsIURI> GetBaseURI(bool aTryUseXHRDocBaseURI = false) const override;
|
|
|
+
|
|
|
+diff --git a/dom/base/FragmentOrElement.cpp b/dom/base/FragmentOrElement.cpp
|
|
|
+--- a/dom/base/FragmentOrElement.cpp
|
|
|
++++ b/dom/base/FragmentOrElement.cpp
|
|
|
+@@ -553,17 +553,17 @@ nsAttrChildContentList::Item(uint32_t aI
|
|
|
+
|
|
|
+ return nullptr;
|
|
|
+ }
|
|
|
+
|
|
|
+ int32_t
|
|
|
+ nsAttrChildContentList::IndexOf(nsIContent* aContent)
|
|
|
+ {
|
|
|
+ if (mNode) {
|
|
|
+- return mNode->IndexOf(aContent);
|
|
|
++ return mNode->ComputeIndexOf(aContent);
|
|
|
+ }
|
|
|
+
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ //----------------------------------------------------------------------
|
|
|
+ NS_IMETHODIMP
|
|
|
+ nsParentNodeChildContentList::GetLength(uint32_t* aLength)
|
|
|
+@@ -1171,17 +1171,17 @@ FragmentOrElement::RemoveChildAt_Depreca
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ void
|
|
|
+ FragmentOrElement::RemoveChildNode(nsIContent* aKid, bool aNotify)
|
|
|
+ {
|
|
|
+ // Let's keep the node alive.
|
|
|
+ nsCOMPtr<nsIContent> kungFuDeathGrip = aKid;
|
|
|
+- doRemoveChildAt(IndexOf(aKid), aNotify, aKid, mAttrsAndChildren);
|
|
|
++ doRemoveChildAt(ComputeIndexOf(aKid), aNotify, aKid, mAttrsAndChildren);
|
|
|
+ }
|
|
|
+
|
|
|
+ void
|
|
|
+ FragmentOrElement::GetTextContentInternal(nsAString& aTextContent,
|
|
|
+ OOMReporter& aError)
|
|
|
+ {
|
|
|
+ if (!nsContentUtils::GetNodeTextContent(this, true, aTextContent, fallible)) {
|
|
|
+ aError.ReportOOM();
|
|
|
+@@ -2132,17 +2132,17 @@ FragmentOrElement::GetChildCount() const
|
|
|
+
|
|
|
+ nsIContent *
|
|
|
+ FragmentOrElement::GetChildAt_Deprecated(uint32_t aIndex) const
|
|
|
+ {
|
|
|
+ return mAttrsAndChildren.GetSafeChildAt(aIndex);
|
|
|
+ }
|
|
|
+
|
|
|
+ int32_t
|
|
|
+-FragmentOrElement::IndexOf(const nsINode* aPossibleChild) const
|
|
|
++FragmentOrElement::ComputeIndexOf(const nsINode* aPossibleChild) const
|
|
|
+ {
|
|
|
+ return mAttrsAndChildren.IndexOfChild(aPossibleChild);
|
|
|
+ }
|
|
|
+
|
|
|
+ static inline bool
|
|
|
+ IsVoidTag(nsIAtom* aTag)
|
|
|
+ {
|
|
|
+ static const nsIAtom* voidElements[] = {
|
|
|
+diff --git a/dom/base/FragmentOrElement.h b/dom/base/FragmentOrElement.h
|
|
|
+--- a/dom/base/FragmentOrElement.h
|
|
|
++++ b/dom/base/FragmentOrElement.h
|
|
|
+@@ -114,17 +114,17 @@ public:
|
|
|
+
|
|
|
+ NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
+
|
|
|
+ NS_DECL_ADDSIZEOFEXCLUDINGTHIS
|
|
|
+
|
|
|
+ // nsINode interface methods
|
|
|
+ virtual uint32_t GetChildCount() const override;
|
|
|
+ virtual nsIContent *GetChildAt_Deprecated(uint32_t aIndex) const override;
|
|
|
+- virtual int32_t IndexOf(const nsINode* aPossibleChild) const override;
|
|
|
++ virtual int32_t ComputeIndexOf(const nsINode* aPossibleChild) const override;
|
|
|
+ virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,
|
|
|
+ bool aNotify) override;
|
|
|
+ virtual void RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify) override;
|
|
|
+ virtual void RemoveChildNode(nsIContent* aKid, bool aNotify) override;
|
|
|
+ virtual void GetTextContentInternal(nsAString& aTextContent,
|
|
|
+ mozilla::OOMReporter& aError) override;
|
|
|
+ virtual void SetTextContentInternal(const nsAString& aTextContent,
|
|
|
+ nsIPrincipal* aSubjectPrincipal,
|
|
|
+diff --git a/dom/base/RangeBoundary.h b/dom/base/RangeBoundary.h
|
|
|
+--- a/dom/base/RangeBoundary.h
|
|
|
++++ b/dom/base/RangeBoundary.h
|
|
|
+@@ -173,17 +173,17 @@ public:
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!mParent) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ MOZ_ASSERT(mRef);
|
|
|
+ MOZ_ASSERT(mRef->GetParentNode() == mParent);
|
|
|
+- mOffset = mozilla::Some(mParent->IndexOf(mRef) + 1);
|
|
|
++ mOffset = mozilla::Some(mParent->ComputeIndexOf(mRef) + 1);
|
|
|
+
|
|
|
+ return mOffset.value();
|
|
|
+ }
|
|
|
+
|
|
|
+ void
|
|
|
+ InvalidateOffset()
|
|
|
+ {
|
|
|
+ MOZ_ASSERT(mParent);
|
|
|
+diff --git a/dom/base/Selection.cpp b/dom/base/Selection.cpp
|
|
|
+--- a/dom/base/Selection.cpp
|
|
|
++++ b/dom/base/Selection.cpp
|
|
|
+@@ -1681,17 +1681,17 @@ Selection::GetPrimaryFrameForFocusNode(n
|
|
|
+ if (!content->TextIsOnlyWhitespace()) {
|
|
|
+ return NS_ERROR_FAILURE;
|
|
|
+ }
|
|
|
+
|
|
|
+ nsCOMPtr<nsIContent> parent = content->GetParent();
|
|
|
+ if (NS_WARN_IF(!parent)) {
|
|
|
+ return NS_ERROR_FAILURE;
|
|
|
+ }
|
|
|
+- int32_t offset = parent->IndexOf(content);
|
|
|
++ int32_t offset = parent->ComputeIndexOf(content);
|
|
|
+
|
|
|
+ return GetPrimaryOrCaretFrameForNodeOffset(parent, offset, aReturnFrame,
|
|
|
+ aOffsetUsed, aVisual);
|
|
|
+ }
|
|
|
+
|
|
|
+ nsresult
|
|
|
+ Selection::GetPrimaryOrCaretFrameForNodeOffset(nsIContent* aContent,
|
|
|
+ uint32_t aOffset,
|
|
|
+@@ -2580,17 +2580,17 @@ Selection::Collapse(const RawRangeBounda
|
|
|
+ nsTextFrame* f =
|
|
|
+ do_QueryFrame(nsCaret::GetFrameAndOffset(this, aPoint.Container(),
|
|
|
+ aPoint.Offset(), &frameOffset));
|
|
|
+ if (f && f->IsAtEndOfLine() && f->HasSignificantTerminalNewline()) {
|
|
|
+ // RawRangeBounary::Offset() causes computing offset if it's not been
|
|
|
+ // done yet. However, it's called only when the container is a text
|
|
|
+ // node. In such case, offset has always been set since it cannot have
|
|
|
+ // any children. So, this doesn't cause computing offset with expensive
|
|
|
+- // method, nsINode::IndexOf().
|
|
|
++ // method, nsINode::ComputeIndexOf().
|
|
|
+ if ((aPoint.Container()->AsContent() == f->GetContent() &&
|
|
|
+ f->GetContentEnd() == static_cast<int32_t>(aPoint.Offset())) ||
|
|
|
+ (aPoint.Container() == f->GetContent()->GetParentNode() &&
|
|
|
+ f->GetContent() == aPoint.GetPreviousSiblingOfChildAtOffset())) {
|
|
|
+ frameSelection->SetHint(CARET_ASSOCIATE_AFTER);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+diff --git a/dom/base/nsContentIterator.cpp b/dom/base/nsContentIterator.cpp
|
|
|
+--- a/dom/base/nsContentIterator.cpp
|
|
|
++++ b/dom/base/nsContentIterator.cpp
|
|
|
+@@ -177,18 +177,18 @@ protected:
|
|
|
+ // iterators do not do much transitioning between parents and children. They
|
|
|
+ // tend to stay at the same level. In fact, you can prove (though I won't
|
|
|
+ // attempt it here) that they change levels at most n+m times, where n is the
|
|
|
+ // height of the parent hierarchy from the range start to the common
|
|
|
+ // ancestor, and m is the the height of the parent hierarchy from the range
|
|
|
+ // end to the common ancestor. If we used the index array, we would pay the
|
|
|
+ // price up front for n, and then pay the cost for m on the fly later on.
|
|
|
+ // With the simple cache, we only "pay as we go". Either way, we call
|
|
|
+- // IndexOf() once for each change of level in the hierarchy. Since a trivial
|
|
|
+- // index is much simpler, we use it for the subtree iterator.
|
|
|
++ // ComputeIndexOf() once for each change of level in the hierarchy. Since
|
|
|
++ // a trivial index is much simpler, we use it for the subtree iterator.
|
|
|
+
|
|
|
+ bool mIsDone;
|
|
|
+ bool mPre;
|
|
|
+
|
|
|
+ private:
|
|
|
+
|
|
|
+ // no copies or assigns FIX ME
|
|
|
+ nsContentIterator(const nsContentIterator&);
|
|
|
+@@ -558,17 +558,17 @@ nsContentIterator::RebuildIndexStack()
|
|
|
+
|
|
|
+ while (current != mCommonParent) {
|
|
|
+ parent = current->GetParentNode();
|
|
|
+
|
|
|
+ if (NS_WARN_IF(!parent)) {
|
|
|
+ return NS_ERROR_FAILURE;
|
|
|
+ }
|
|
|
+
|
|
|
+- mIndexes.InsertElementAt(0, parent->IndexOf(current));
|
|
|
++ mIndexes.InsertElementAt(0, parent->ComputeIndexOf(current));
|
|
|
+
|
|
|
+ current = parent;
|
|
|
+ }
|
|
|
+
|
|
|
+ return NS_OK;
|
|
|
+ }
|
|
|
+
|
|
|
+ void
|
|
|
+@@ -684,22 +684,22 @@ nsContentIterator::GetNextSibling(nsINod
|
|
|
+ // use the last entry on the Indexes array for the current index
|
|
|
+ indx = (*aIndexes)[aIndexes->Length()-1];
|
|
|
+ } else {
|
|
|
+ indx = mCachedIndex;
|
|
|
+ }
|
|
|
+ NS_WARNING_ASSERTION(indx >= 0, "bad indx");
|
|
|
+
|
|
|
+ // reverify that the index of the current node hasn't changed.
|
|
|
+- // not super cheap, but a lot cheaper than IndexOf(), and still O(1).
|
|
|
+- // ignore result this time - the index may now be out of range.
|
|
|
++ // not super cheap, but a lot cheaper than ComputeIndexOf(), and still
|
|
|
++ // O(1). ignore result this time - the index may now be out of range.
|
|
|
+ nsIContent* sib = parent->GetChildAt_Deprecated(indx);
|
|
|
+ if (sib != aNode) {
|
|
|
+ // someone changed our index - find the new index the painful way
|
|
|
+- indx = parent->IndexOf(aNode);
|
|
|
++ indx = parent->ComputeIndexOf(aNode);
|
|
|
+ NS_WARNING_ASSERTION(indx >= 0, "bad indx");
|
|
|
+ }
|
|
|
+
|
|
|
+ // indx is now canonically correct
|
|
|
+ if ((sib = parent->GetChildAt_Deprecated(++indx))) {
|
|
|
+ // update index cache
|
|
|
+ if (aIndexes && !aIndexes->IsEmpty()) {
|
|
|
+ aIndexes->ElementAt(aIndexes->Length()-1) = indx;
|
|
|
+@@ -750,17 +750,17 @@ nsContentIterator::GetPrevSibling(nsINod
|
|
|
+ indx = mCachedIndex;
|
|
|
+ }
|
|
|
+
|
|
|
+ // reverify that the index of the current node hasn't changed
|
|
|
+ // ignore result this time - the index may now be out of range.
|
|
|
+ nsIContent* sib = parent->GetChildAt_Deprecated(indx);
|
|
|
+ if (sib != aNode) {
|
|
|
+ // someone changed our index - find the new index the painful way
|
|
|
+- indx = parent->IndexOf(aNode);
|
|
|
++ indx = parent->ComputeIndexOf(aNode);
|
|
|
+ NS_WARNING_ASSERTION(indx >= 0, "bad indx");
|
|
|
+ }
|
|
|
+
|
|
|
+ // indx is now canonically correct
|
|
|
+ if (indx > 0 && (sib = parent->GetChildAt_Deprecated(--indx))) {
|
|
|
+ // update index cache
|
|
|
+ if (aIndexes && !aIndexes->IsEmpty()) {
|
|
|
+ aIndexes->ElementAt(aIndexes->Length()-1) = indx;
|
|
|
+@@ -821,24 +821,24 @@ nsContentIterator::NextNode(nsINode* aNo
|
|
|
+ if (aIndexes && !aIndexes->IsEmpty()) {
|
|
|
+ // use the last entry on the Indexes array for the current index
|
|
|
+ indx = (*aIndexes)[aIndexes->Length()-1];
|
|
|
+ } else {
|
|
|
+ indx = mCachedIndex;
|
|
|
+ }
|
|
|
+
|
|
|
+ // reverify that the index of the current node hasn't changed. not super
|
|
|
+- // cheap, but a lot cheaper than IndexOf(), and still O(1). ignore result
|
|
|
+- // this time - the index may now be out of range.
|
|
|
++ // cheap, but a lot cheaper than ComputeIndexOf(), and still O(1). ignore
|
|
|
++ // result this time - the index may now be out of range.
|
|
|
+ if (indx >= 0) {
|
|
|
+ sibling = parent->GetChildAt_Deprecated(indx);
|
|
|
+ }
|
|
|
+ if (sibling != node) {
|
|
|
+ // someone changed our index - find the new index the painful way
|
|
|
+- indx = parent->IndexOf(node);
|
|
|
++ indx = parent->ComputeIndexOf(node);
|
|
|
+ NS_WARNING_ASSERTION(indx >= 0, "bad indx");
|
|
|
+ }
|
|
|
+
|
|
|
+ // indx is now canonically correct
|
|
|
+ sibling = parent->GetChildAt_Deprecated(++indx);
|
|
|
+ if (sibling) {
|
|
|
+ // update cache
|
|
|
+ if (aIndexes && !aIndexes->IsEmpty()) {
|
|
|
+@@ -890,26 +890,26 @@ nsContentIterator::PrevNode(nsINode* aNo
|
|
|
+ if (aIndexes && !aIndexes->IsEmpty()) {
|
|
|
+ // use the last entry on the Indexes array for the current index
|
|
|
+ indx = (*aIndexes)[aIndexes->Length()-1];
|
|
|
+ } else {
|
|
|
+ indx = mCachedIndex;
|
|
|
+ }
|
|
|
+
|
|
|
+ // reverify that the index of the current node hasn't changed. not super
|
|
|
+- // cheap, but a lot cheaper than IndexOf(), and still O(1). ignore result
|
|
|
+- // this time - the index may now be out of range.
|
|
|
++ // cheap, but a lot cheaper than ComputeIndexOf(), and still O(1).
|
|
|
++ // ignore result this time - the index may now be out of range.
|
|
|
+ if (indx >= 0) {
|
|
|
+ sibling = parent->GetChildAt_Deprecated(indx);
|
|
|
+ NS_WARNING_ASSERTION(sibling, "GetChildAt_Deprecated returned null");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (sibling != node) {
|
|
|
+ // someone changed our index - find the new index the painful way
|
|
|
+- indx = parent->IndexOf(node);
|
|
|
++ indx = parent->ComputeIndexOf(node);
|
|
|
+ NS_WARNING_ASSERTION(indx >= 0, "bad indx");
|
|
|
+ }
|
|
|
+
|
|
|
+ // indx is now canonically correct
|
|
|
+ if (indx && (sibling = parent->GetChildAt_Deprecated(--indx))) {
|
|
|
+ // update cache
|
|
|
+ if (aIndexes && !aIndexes->IsEmpty()) {
|
|
|
+ // replace an entry on the index stack
|
|
|
+@@ -1093,19 +1093,19 @@ nsContentIterator::PositionAt(nsINode* a
|
|
|
+
|
|
|
+ // We can be at ANY node in the sequence. Need to regenerate the array of
|
|
|
+ // indexes back to the root or common parent!
|
|
|
+ AutoTArray<nsINode*, 8> oldParentStack;
|
|
|
+ AutoTArray<int32_t, 8> newIndexes;
|
|
|
+
|
|
|
+ // Get a list of the parents up to the root, then compare the new node with
|
|
|
+ // entries in that array until we find a match (lowest common ancestor). If
|
|
|
+- // no match, use IndexOf, take the parent, and repeat. This avoids using
|
|
|
+- // IndexOf() N times on possibly large arrays. We still end up doing it a
|
|
|
+- // fair bit. It's better to use Clone() if possible.
|
|
|
++ // no match, use ComputeIndexOf, take the parent, and repeat. This avoids
|
|
|
++ // using ComputeIndexOf() N times on possibly large arrays. We still end
|
|
|
++ // up doing it a fair bit. It's better to use Clone() if possible.
|
|
|
+
|
|
|
+ // we know the depth we're down (though we may not have started at the top).
|
|
|
+ oldParentStack.SetCapacity(mIndexes.Length() + 1);
|
|
|
+
|
|
|
+ // We want to loop mIndexes.Length() + 1 times here, because we want to make
|
|
|
+ // sure we include mCommonParent in the oldParentStack, for use in the next
|
|
|
+ // for loop, and mIndexes only has entries for nodes from tempNode up through
|
|
|
+ // an ancestor of tempNode that's a child of mCommonParent.
|
|
|
+@@ -1135,17 +1135,17 @@ nsContentIterator::PositionAt(nsINode* a
|
|
|
+ while (newCurNode) {
|
|
|
+ nsINode* parent = newCurNode->GetParentNode();
|
|
|
+
|
|
|
+ if (NS_WARN_IF(!parent)) {
|
|
|
+ // this node has no parent, and thus no index
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+- int32_t indx = parent->IndexOf(newCurNode);
|
|
|
++ int32_t indx = parent->ComputeIndexOf(newCurNode);
|
|
|
+ NS_WARNING_ASSERTION(indx >= 0, "bad indx");
|
|
|
+
|
|
|
+ // insert at the head!
|
|
|
+ newIndexes.InsertElementAt(0, indx);
|
|
|
+
|
|
|
+ // look to see if the parent is in the stack
|
|
|
+ indx = oldParentStack.IndexOf(parent);
|
|
|
+ if (indx >= 0) {
|
|
|
+diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp
|
|
|
+--- a/dom/base/nsContentUtils.cpp
|
|
|
++++ b/dom/base/nsContentUtils.cpp
|
|
|
+@@ -2408,17 +2408,17 @@ nsContentUtils::InProlog(nsINode *aNode)
|
|
|
+ nsINode* parent = aNode->GetParentNode();
|
|
|
+ if (!parent || !parent->IsNodeOfType(nsINode::eDOCUMENT)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ nsIDocument* doc = static_cast<nsIDocument*>(parent);
|
|
|
+ nsIContent* root = doc->GetRootElement();
|
|
|
+
|
|
|
+- return !root || doc->IndexOf(aNode) < doc->IndexOf(root);
|
|
|
++ return !root || doc->ComputeIndexOf(aNode) < doc->ComputeIndexOf(root);
|
|
|
+ }
|
|
|
+
|
|
|
+ nsIDocument*
|
|
|
+ nsContentUtils::GetDocumentFromCaller()
|
|
|
+ {
|
|
|
+ AutoJSContext cx;
|
|
|
+
|
|
|
+ nsCOMPtr<nsPIDOMWindowInner> win =
|
|
|
+@@ -2753,17 +2753,17 @@ nsContentUtils::GetAncestorsAndOffsets(n
|
|
|
+ aAncestorNodes->AppendElement(content.get());
|
|
|
+ aAncestorOffsets->AppendElement(aOffset);
|
|
|
+
|
|
|
+ // insert all the ancestors
|
|
|
+ nsIContent* child = content;
|
|
|
+ nsIContent* parent = child->GetParent();
|
|
|
+ while (parent) {
|
|
|
+ aAncestorNodes->AppendElement(parent);
|
|
|
+- aAncestorOffsets->AppendElement(parent->IndexOf(child));
|
|
|
++ aAncestorOffsets->AppendElement(parent->ComputeIndexOf(child));
|
|
|
+ child = parent;
|
|
|
+ parent = parent->GetParent();
|
|
|
+ }
|
|
|
+
|
|
|
+ return NS_OK;
|
|
|
+ }
|
|
|
+
|
|
|
+ // static
|
|
|
+@@ -2863,18 +2863,18 @@ nsContentUtils::PositionIsBefore(nsINode
|
|
|
+ /* static */
|
|
|
+ int32_t
|
|
|
+ nsContentUtils::ComparePoints(nsINode* aParent1, int32_t aOffset1,
|
|
|
+ nsINode* aParent2, int32_t aOffset2,
|
|
|
+ bool* aDisconnected)
|
|
|
+ {
|
|
|
+ if (aParent1 == aParent2) {
|
|
|
+ // XXX This is odd. aOffset1 and/or aOffset2 may be -1, e.g., it's result
|
|
|
+- // of nsINode::IndexOf(), but this compares such invalid offset with
|
|
|
+- // valid offset.
|
|
|
++ // of nsINode::ComputeIndexOf(), but this compares such invalid
|
|
|
++ // offset with valid offset.
|
|
|
+ return aOffset1 < aOffset2 ? -1 :
|
|
|
+ aOffset1 > aOffset2 ? 1 :
|
|
|
+ 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ AutoTArray<nsINode*, 32> parents1, parents2;
|
|
|
+ nsINode* node1 = aParent1;
|
|
|
+ nsINode* node2 = aParent2;
|
|
|
+@@ -2901,39 +2901,39 @@ nsContentUtils::ComparePoints(nsINode* a
|
|
|
+
|
|
|
+ // Find where the parent chains differ
|
|
|
+ nsINode* parent = parents1.ElementAt(pos1);
|
|
|
+ uint32_t len;
|
|
|
+ for (len = std::min(pos1, pos2); len > 0; --len) {
|
|
|
+ nsINode* child1 = parents1.ElementAt(--pos1);
|
|
|
+ nsINode* child2 = parents2.ElementAt(--pos2);
|
|
|
+ if (child1 != child2) {
|
|
|
+- return parent->IndexOf(child1) < parent->IndexOf(child2) ? -1 : 1;
|
|
|
++ return parent->ComputeIndexOf(child1) < parent->ComputeIndexOf(child2) ? -1 : 1;
|
|
|
+ }
|
|
|
+ parent = child1;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // The parent chains never differed, so one of the nodes is an ancestor of
|
|
|
+ // the other
|
|
|
+
|
|
|
+ NS_ASSERTION(!pos1 || !pos2,
|
|
|
+ "should have run out of parent chain for one of the nodes");
|
|
|
+
|
|
|
+ if (!pos1) {
|
|
|
+ nsINode* child2 = parents2.ElementAt(--pos2);
|
|
|
+ // XXX aOffset1 may be -1 as mentioned above. So, why does this return
|
|
|
+ // it's *before* of the valid DOM point?
|
|
|
+- return aOffset1 <= parent->IndexOf(child2) ? -1 : 1;
|
|
|
++ return aOffset1 <= parent->ComputeIndexOf(child2) ? -1 : 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ nsINode* child1 = parents1.ElementAt(--pos1);
|
|
|
+ // XXX aOffset2 may be -1 as mentioned above. So, why does this return it's
|
|
|
+ // *after* of the valid DOM point?
|
|
|
+- return parent->IndexOf(child1) < aOffset2 ? -1 : 1;
|
|
|
++ return parent->ComputeIndexOf(child1) < aOffset2 ? -1 : 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ /* static */
|
|
|
+ int32_t
|
|
|
+ nsContentUtils::ComparePoints(nsIDOMNode* aParent1, int32_t aOffset1,
|
|
|
+ nsIDOMNode* aParent2, int32_t aOffset2,
|
|
|
+ bool* aDisconnected)
|
|
|
+ {
|
|
|
+@@ -3238,17 +3238,17 @@ nsContentUtils::GenerateStateKey(nsICont
|
|
|
+ }
|
|
|
+
|
|
|
+ // Now start at aContent and append the indices of it and all its ancestors
|
|
|
+ // in their containers. That should at least pin down its position in the
|
|
|
+ // DOM...
|
|
|
+ nsINode* parent = aContent->GetParentNode();
|
|
|
+ nsINode* content = aContent;
|
|
|
+ while (parent) {
|
|
|
+- KeyAppendInt(parent->IndexOf(content), aKey);
|
|
|
++ KeyAppendInt(parent->ComputeIndexOf(content), aKey);
|
|
|
+ content = parent;
|
|
|
+ parent = content->GetParentNode();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return NS_OK;
|
|
|
+ }
|
|
|
+
|
|
|
+diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp
|
|
|
+--- a/dom/base/nsDocument.cpp
|
|
|
++++ b/dom/base/nsDocument.cpp
|
|
|
+@@ -4265,17 +4265,17 @@ nsDocument::GetRootElementInternal() con
|
|
|
+
|
|
|
+ nsIContent *
|
|
|
+ nsDocument::GetChildAt_Deprecated(uint32_t aIndex) const
|
|
|
+ {
|
|
|
+ return mChildren.GetSafeChildAt(aIndex);
|
|
|
+ }
|
|
|
+
|
|
|
+ int32_t
|
|
|
+-nsDocument::IndexOf(const nsINode* aPossibleChild) const
|
|
|
++nsDocument::ComputeIndexOf(const nsINode* aPossibleChild) const
|
|
|
+ {
|
|
|
+ return mChildren.IndexOfChild(aPossibleChild);
|
|
|
+ }
|
|
|
+
|
|
|
+ uint32_t
|
|
|
+ nsDocument::GetChildCount() const
|
|
|
+ {
|
|
|
+ return mChildren.ChildCount();
|
|
|
+@@ -4331,17 +4331,17 @@ nsDocument::RemoveChildNode(nsIContent*
|
|
|
+ // Preemptively clear mCachedRootElement, since we may be about to remove it
|
|
|
+ // from our child list, and we don't want to return this maybe-obsolete value
|
|
|
+ // from any GetRootElement() calls that happen inside of doRemoveChildAt().
|
|
|
+ // (NOTE: for this to be useful, doRemoveChildAt() must NOT trigger any
|
|
|
+ // GetRootElement() calls until after it's removed the child from mChildren.
|
|
|
+ // Any call before that point would restore this soon-to-be-obsolete cached
|
|
|
+ // answer, and our clearing here would be fruitless.)
|
|
|
+ mCachedRootElement = nullptr;
|
|
|
+- doRemoveChildAt(IndexOf(aKid), aNotify, aKid, mChildren);
|
|
|
++ doRemoveChildAt(ComputeIndexOf(aKid), aNotify, aKid, mChildren);
|
|
|
+ MOZ_ASSERT(mCachedRootElement != aKid,
|
|
|
+ "Stale pointer in mCachedRootElement, after we tried to clear it "
|
|
|
+ "(maybe somebody called GetRootElement() too early?)");
|
|
|
+ }
|
|
|
+
|
|
|
+ void
|
|
|
+ nsDocument::EnsureOnDemandBuiltInUASheet(StyleSheet* aSheet)
|
|
|
+ {
|
|
|
+diff --git a/dom/base/nsDocument.h b/dom/base/nsDocument.h
|
|
|
+--- a/dom/base/nsDocument.h
|
|
|
++++ b/dom/base/nsDocument.h
|
|
|
+@@ -546,17 +546,17 @@ public:
|
|
|
+ virtual void OnPageHide(bool aPersisted, mozilla::dom::EventTarget* aDispatchStartTarget) override;
|
|
|
+
|
|
|
+ virtual void WillDispatchMutationEvent(nsINode* aTarget) override;
|
|
|
+ virtual void MutationEventDispatched(nsINode* aTarget) override;
|
|
|
+
|
|
|
+ // nsINode
|
|
|
+ virtual bool IsNodeOfType(uint32_t aFlags) const override;
|
|
|
+ virtual nsIContent *GetChildAt_Deprecated(uint32_t aIndex) const override;
|
|
|
+- virtual int32_t IndexOf(const nsINode* aPossibleChild) const override;
|
|
|
++ virtual int32_t ComputeIndexOf(const nsINode* aPossibleChild) const override;
|
|
|
+ virtual uint32_t GetChildCount() const override;
|
|
|
+ virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,
|
|
|
+ bool aNotify) override;
|
|
|
+ virtual void RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify) override;
|
|
|
+ virtual void RemoveChildNode(nsIContent* aKid, bool aNotify) override;
|
|
|
+ virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
|
|
|
+ bool aPreallocateChildren) const override
|
|
|
+ {
|
|
|
+diff --git a/dom/base/nsDocumentEncoder.cpp b/dom/base/nsDocumentEncoder.cpp
|
|
|
+--- a/dom/base/nsDocumentEncoder.cpp
|
|
|
++++ b/dom/base/nsDocumentEncoder.cpp
|
|
|
+@@ -1792,17 +1792,17 @@ nsHTMLCopyEncoder::GetNodeLocation(nsIDO
|
|
|
+ result = inChild->GetParentNode(getter_AddRefs(*outParent));
|
|
|
+ if ((NS_SUCCEEDED(result)) && (*outParent))
|
|
|
+ {
|
|
|
+ nsCOMPtr<nsIContent> content = do_QueryInterface(*outParent);
|
|
|
+ nsCOMPtr<nsIContent> cChild = do_QueryInterface(inChild);
|
|
|
+ if (!cChild || !content)
|
|
|
+ return NS_ERROR_NULL_POINTER;
|
|
|
+
|
|
|
+- *outOffset = content->IndexOf(cChild);
|
|
|
++ *outOffset = content->ComputeIndexOf(cChild);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ bool
|
|
|
+ nsHTMLCopyEncoder::IsRoot(nsIDOMNode* aNode)
|
|
|
+ {
|
|
|
+diff --git a/dom/base/nsFocusManager.cpp b/dom/base/nsFocusManager.cpp
|
|
|
+--- a/dom/base/nsFocusManager.cpp
|
|
|
++++ b/dom/base/nsFocusManager.cpp
|
|
|
+@@ -3310,17 +3310,17 @@ nsFocusManager::GetNextTabbableMapArea(b
|
|
|
+ nsCOMPtr<nsIDocument> doc = aImageContent->GetComposedDoc();
|
|
|
+ if (doc) {
|
|
|
+ nsCOMPtr<nsIContent> mapContent = doc->FindImageMap(useMap);
|
|
|
+ if (!mapContent)
|
|
|
+ return nullptr;
|
|
|
+ uint32_t count = mapContent->GetChildCount();
|
|
|
+ // First see if the the start content is in this map
|
|
|
+
|
|
|
+- int32_t index = mapContent->IndexOf(aStartContent);
|
|
|
++ int32_t index = mapContent->ComputeIndexOf(aStartContent);
|
|
|
+ int32_t tabIndex;
|
|
|
+ if (index < 0 || (aStartContent->IsFocusable(&tabIndex) &&
|
|
|
+ tabIndex != aCurrentTabIndex)) {
|
|
|
+ // If aStartContent is in this map we must start iterating past it.
|
|
|
+ // We skip the case where aStartContent has tabindex == aStartContent
|
|
|
+ // since the next tab ordered element might be before it
|
|
|
+ // (or after for backwards) in the child list.
|
|
|
+ index = aForward ? -1 : (int32_t)count;
|
|
|
+diff --git a/dom/base/nsGenericDOMDataNode.cpp b/dom/base/nsGenericDOMDataNode.cpp
|
|
|
+--- a/dom/base/nsGenericDOMDataNode.cpp
|
|
|
++++ b/dom/base/nsGenericDOMDataNode.cpp
|
|
|
+@@ -641,17 +641,17 @@ nsGenericDOMDataNode::GetChildCount() co
|
|
|
+ nsIContent *
|
|
|
+ nsGenericDOMDataNode::GetChildAt_Deprecated(uint32_t aIndex) const
|
|
|
+ {
|
|
|
+ return nullptr;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ int32_t
|
|
|
+-nsGenericDOMDataNode::IndexOf(const nsINode* aPossibleChild) const
|
|
|
++nsGenericDOMDataNode::ComputeIndexOf(const nsINode* aPossibleChild) const
|
|
|
+ {
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ nsresult
|
|
|
+ nsGenericDOMDataNode::InsertChildAt(nsIContent* aKid, uint32_t aIndex,
|
|
|
+ bool aNotify)
|
|
|
+ {
|
|
|
+@@ -749,17 +749,17 @@ nsGenericDOMDataNode::SplitData(uint32_t
|
|
|
+ rv = SetTextInternal(cutStartOffset, cutLength, nullptr, 0, true,
|
|
|
+ aCloneAfterOriginal ? &details : nullptr);
|
|
|
+ if (NS_FAILED(rv)) {
|
|
|
+ return rv;
|
|
|
+ }
|
|
|
+
|
|
|
+ nsCOMPtr<nsINode> parent = GetParentNode();
|
|
|
+ if (parent) {
|
|
|
+- int32_t insertionIndex = parent->IndexOf(this);
|
|
|
++ int32_t insertionIndex = parent->ComputeIndexOf(this);
|
|
|
+ if (aCloneAfterOriginal) {
|
|
|
+ ++insertionIndex;
|
|
|
+ }
|
|
|
+ parent->InsertChildAt(newContent, insertionIndex, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ newContent.swap(*aReturn);
|
|
|
+ return rv;
|
|
|
+@@ -815,17 +815,17 @@ nsresult
|
|
|
+ nsGenericDOMDataNode::GetWholeText(nsAString& aWholeText)
|
|
|
+ {
|
|
|
+ nsIContent* parent = GetParent();
|
|
|
+
|
|
|
+ // Handle parent-less nodes
|
|
|
+ if (!parent)
|
|
|
+ return GetData(aWholeText);
|
|
|
+
|
|
|
+- int32_t index = parent->IndexOf(this);
|
|
|
++ 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);
|
|
|
+ nsCOMPtr<nsIContent> first = FirstLogicallyAdjacentTextNode(this);
|
|
|
+ nsCOMPtr<nsIContent> last = LastLogicallyAdjacentTextNode(this);
|
|
|
+
|
|
|
+ aWholeText.Truncate();
|
|
|
+diff --git a/dom/base/nsGenericDOMDataNode.h b/dom/base/nsGenericDOMDataNode.h
|
|
|
+--- a/dom/base/nsGenericDOMDataNode.h
|
|
|
++++ b/dom/base/nsGenericDOMDataNode.h
|
|
|
+@@ -101,17 +101,17 @@ public:
|
|
|
+ nsresult InsertData(uint32_t aOffset, const nsAString& aArg);
|
|
|
+ nsresult DeleteData(uint32_t aOffset, uint32_t aCount);
|
|
|
+ nsresult ReplaceData(uint32_t aOffset, uint32_t aCount,
|
|
|
+ const nsAString& aArg);
|
|
|
+
|
|
|
+ // nsINode methods
|
|
|
+ virtual uint32_t GetChildCount() const override;
|
|
|
+ virtual nsIContent *GetChildAt_Deprecated(uint32_t aIndex) const override;
|
|
|
+- virtual int32_t IndexOf(const nsINode* aPossibleChild) const override;
|
|
|
++ virtual int32_t ComputeIndexOf(const nsINode* aPossibleChild) const override;
|
|
|
+ virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,
|
|
|
+ bool aNotify) override;
|
|
|
+ virtual void RemoveChildAt_Deprecated(uint32_t aIndex, bool aNotify) override;
|
|
|
+ virtual void RemoveChildNode(nsIContent* aKid, bool aNotify) override;
|
|
|
+ virtual void GetTextContentInternal(nsAString& aTextContent,
|
|
|
+ mozilla::OOMReporter& aError) override
|
|
|
+ {
|
|
|
+ GetNodeValue(aTextContent);
|
|
|
+diff --git a/dom/base/nsINode.cpp b/dom/base/nsINode.cpp
|
|
|
+--- a/dom/base/nsINode.cpp
|
|
|
++++ b/dom/base/nsINode.cpp
|
|
|
+@@ -612,17 +612,17 @@ nsINode::RemoveChild(nsINode& aOldChild,
|
|
|
+ aError.Throw(NS_ERROR_DOM_NOT_FOUND_ERR);
|
|
|
+ return nullptr;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (aOldChild.GetParentNode() == this) {
|
|
|
+ nsContentUtils::MaybeFireNodeRemoved(&aOldChild, this, OwnerDoc());
|
|
|
+ }
|
|
|
+
|
|
|
+- int32_t index = IndexOf(&aOldChild);
|
|
|
++ int32_t index = ComputeIndexOf(&aOldChild);
|
|
|
+ if (index == -1) {
|
|
|
+ // aOldChild isn't one of our children.
|
|
|
+ aError.Throw(NS_ERROR_DOM_NOT_FOUND_ERR);
|
|
|
+ return nullptr;
|
|
|
+ }
|
|
|
+
|
|
|
+ RemoveChildAt_Deprecated(index, true);
|
|
|
+ return &aOldChild;
|
|
|
+@@ -726,17 +726,17 @@ nsINode::Normalize()
|
|
|
+ }
|
|
|
+
|
|
|
+ // Remove node
|
|
|
+ nsCOMPtr<nsINode> parent = node->GetParentNode();
|
|
|
+ NS_ASSERTION(parent || hasRemoveListeners,
|
|
|
+ "Should always have a parent unless "
|
|
|
+ "mutation events messed us up");
|
|
|
+ if (parent) {
|
|
|
+- parent->RemoveChildAt_Deprecated(parent->IndexOf(node), true);
|
|
|
++ parent->RemoveChildAt_Deprecated(parent->ComputeIndexOf(node), true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ nsresult
|
|
|
+ nsINode::GetBaseURI(nsAString &aURI) const
|
|
|
+ {
|
|
|
+ nsCOMPtr<nsIURI> baseURI = GetBaseURI();
|
|
|
+@@ -1010,19 +1010,19 @@ nsINode::CompareDocumentPosition(nsINode
|
|
|
+ // Find where the parent chain differs and check indices in the parent.
|
|
|
+ const nsINode* parent = top1;
|
|
|
+ uint32_t len;
|
|
|
+ for (len = std::min(pos1, pos2); len > 0; --len) {
|
|
|
+ const nsINode* child1 = parents1.ElementAt(--pos1);
|
|
|
+ const nsINode* child2 = parents2.ElementAt(--pos2);
|
|
|
+ if (child1 != child2) {
|
|
|
+ // child1 or child2 can be an attribute here. This will work fine since
|
|
|
+- // IndexOf will return -1 for the attribute making the attribute be
|
|
|
+- // considered before any child.
|
|
|
+- return parent->IndexOf(child1) < parent->IndexOf(child2) ?
|
|
|
++ // ComputeIndexOf will return -1 for the attribute making the
|
|
|
++ // attribute be considered before any child.
|
|
|
++ return parent->ComputeIndexOf(child1) < parent->ComputeIndexOf(child2) ?
|
|
|
+ static_cast<uint16_t>(nsIDOMNode::DOCUMENT_POSITION_PRECEDING) :
|
|
|
+ static_cast<uint16_t>(nsIDOMNode::DOCUMENT_POSITION_FOLLOWING);
|
|
|
+ }
|
|
|
+ parent = child1;
|
|
|
+ }
|
|
|
+
|
|
|
+ // We hit the end of one of the parent chains without finding a difference
|
|
|
+ // between the chains. That must mean that one node is an ancestor of the
|
|
|
+@@ -1479,17 +1479,17 @@ nsINode::Traverse(nsINode *tmp, nsCycleC
|
|
|
+ if ((currentDoc && currentDoc->HasKnownLiveWrapper())) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ // If we're not in anonymous content and we have a black parent,
|
|
|
+ // return early.
|
|
|
+ nsIContent* parent = tmp->GetParent();
|
|
|
+ if (parent && !parent->UnoptimizableCCNode() &&
|
|
|
+ parent->HasKnownLiveWrapper()) {
|
|
|
+- MOZ_ASSERT(parent->IndexOf(tmp) >= 0, "Parent doesn't own us?");
|
|
|
++ MOZ_ASSERT(parent->ComputeIndexOf(tmp) >= 0, "Parent doesn't own us?");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mNodeInfo)
|
|
|
+ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_RAWPTR(GetParent())
|
|
|
+@@ -1971,17 +1971,17 @@ nsINode::doRemoveChildAt(uint32_t aIndex
|
|
|
+ {
|
|
|
+ // NOTE: This function must not trigger any calls to
|
|
|
+ // nsIDocument::GetRootElement() calls until *after* it has removed aKid from
|
|
|
+ // aChildArray. Any calls before then could potentially restore a stale
|
|
|
+ // value for our cached root element, per note in
|
|
|
+ // nsDocument::RemoveChildNode().
|
|
|
+ MOZ_ASSERT(aKid && aKid->GetParentNode() == this &&
|
|
|
+ aKid == GetChildAt_Deprecated(aIndex) &&
|
|
|
+- IndexOf(aKid) == (int32_t)aIndex, "Bogus aKid");
|
|
|
++ ComputeIndexOf(aKid) == (int32_t)aIndex, "Bogus aKid");
|
|
|
+ MOZ_ASSERT(!IsNodeOfType(nsINode::eATTRIBUTE));
|
|
|
+
|
|
|
+ nsMutationGuard::DidMutate();
|
|
|
+ mozAutoDocUpdate updateBatch(GetComposedDoc(), UPDATE_CONTENT_MODEL, aNotify);
|
|
|
+
|
|
|
+ nsIContent* previousSibling = aKid->GetPreviousSibling();
|
|
|
+
|
|
|
+ if (GetFirstChild() == aKid) {
|
|
|
+@@ -2066,18 +2066,18 @@ bool IsAllowedAsChild(nsIContent* aNewCh
|
|
|
+ }
|
|
|
+
|
|
|
+ nsIContent* docTypeContent = parentDocument->GetDoctype();
|
|
|
+ if (!docTypeContent) {
|
|
|
+ // It's all good.
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+- int32_t doctypeIndex = aParent->IndexOf(docTypeContent);
|
|
|
+- int32_t insertIndex = aParent->IndexOf(aRefChild);
|
|
|
++ int32_t doctypeIndex = aParent->ComputeIndexOf(docTypeContent);
|
|
|
++ int32_t insertIndex = aParent->ComputeIndexOf(aRefChild);
|
|
|
+
|
|
|
+ // Now we're OK in the following two cases only:
|
|
|
+ // 1) We're replacing something that's not before the doctype
|
|
|
+ // 2) We're inserting before something that comes after the doctype
|
|
|
+ return aIsReplace ? (insertIndex >= doctypeIndex) :
|
|
|
+ insertIndex > doctypeIndex;
|
|
|
+ }
|
|
|
+ case nsIDOMNode::DOCUMENT_TYPE_NODE :
|
|
|
+@@ -2102,18 +2102,18 @@ bool IsAllowedAsChild(nsIContent* aNewCh
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!aRefChild) {
|
|
|
+ // Trying to append a doctype, but have a documentElement
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+- int32_t rootIndex = aParent->IndexOf(rootElement);
|
|
|
+- int32_t insertIndex = aParent->IndexOf(aRefChild);
|
|
|
++ int32_t rootIndex = aParent->ComputeIndexOf(rootElement);
|
|
|
++ int32_t insertIndex = aParent->ComputeIndexOf(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
|
|
|
+ // ok as long as aRefChild is not after rootElement.
|
|
|
+ return insertIndex <= rootIndex;
|
|
|
+ }
|
|
|
+ case nsIDOMNode::DOCUMENT_FRAGMENT_NODE :
|
|
|
+ {
|
|
|
+@@ -2221,17 +2221,18 @@ nsINode::ReplaceOrInsertBefore(bool aRep
|
|
|
+ uint16_t nodeType = aNewChild->NodeType();
|
|
|
+
|
|
|
+ // Before we do anything else, fire all DOMNodeRemoved mutation events
|
|
|
+ // We do this up front as to avoid having to deal with script running
|
|
|
+ // at random places further down.
|
|
|
+ // Scope firing mutation events so that we don't carry any state that
|
|
|
+ // might be stale
|
|
|
+ {
|
|
|
+- // This check happens again further down (though then using IndexOf).
|
|
|
++ // This check happens again further down (though then using
|
|
|
++ // ComputeIndexOf).
|
|
|
+ // We're only checking this here to avoid firing mutation events when
|
|
|
+ // none should be fired.
|
|
|
+ // It's ok that we do the check twice in the case when firing mutation
|
|
|
+ // events as we need to recheck after running script anyway.
|
|
|
+ if (aRefChild && aRefChild->GetParentNode() != this) {
|
|
|
+ aError.Throw(NS_ERROR_DOM_NOT_FOUND_ERR);
|
|
|
+ return nullptr;
|
|
|
+ }
|
|
|
+@@ -2281,17 +2282,17 @@ nsINode::ReplaceOrInsertBefore(bool aRep
|
|
|
+ }
|
|
|
+
|
|
|
+ Maybe<AutoTArray<nsCOMPtr<nsIContent>, 50> > fragChildren;
|
|
|
+
|
|
|
+ // Remove the new child from the old parent if one exists
|
|
|
+ nsIContent* newContent = aNewChild->AsContent();
|
|
|
+ nsCOMPtr<nsINode> oldParent = newContent->GetParentNode();
|
|
|
+ if (oldParent) {
|
|
|
+- int32_t removeIndex = oldParent->IndexOf(newContent);
|
|
|
++ int32_t removeIndex = oldParent->ComputeIndexOf(newContent);
|
|
|
+ if (removeIndex < 0) {
|
|
|
+ // newContent is anonymous. We can't deal with this, so just bail
|
|
|
+ NS_ERROR("How come our flags didn't catch this?");
|
|
|
+ aError.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
|
|
+ return nullptr;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Hold a strong ref to nodeToInsertBefore across the removal of newContent
|
|
|
+@@ -2456,17 +2457,17 @@ nsINode::ReplaceOrInsertBefore(bool aRep
|
|
|
+ nsAutoMutationBatch mb;
|
|
|
+
|
|
|
+ // Figure out which index we want to insert at. Note that we use
|
|
|
+ // nodeToInsertBefore to determine this, because it's possible that
|
|
|
+ // aRefChild == aNewChild, in which case we just removed it from the
|
|
|
+ // parent list.
|
|
|
+ int32_t insPos;
|
|
|
+ if (nodeToInsertBefore) {
|
|
|
+- insPos = IndexOf(nodeToInsertBefore);
|
|
|
++ insPos = ComputeIndexOf(nodeToInsertBefore);
|
|
|
+ if (insPos < 0) {
|
|
|
+ // XXXbz How the heck would _that_ happen, exactly?
|
|
|
+ aError.Throw(NS_ERROR_DOM_NOT_FOUND_ERR);
|
|
|
+ return nullptr;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ insPos = GetChildCount();
|
|
|
+diff --git a/dom/base/nsINode.h b/dom/base/nsINode.h
|
|
|
+--- a/dom/base/nsINode.h
|
|
|
++++ b/dom/base/nsINode.h
|
|
|
+@@ -518,17 +518,17 @@ public:
|
|
|
+ /**
|
|
|
+ * Get the index of a child within this content
|
|
|
+ * @param aPossibleChild the child to get the index of.
|
|
|
+ * @return the index of the child, or -1 if not a child
|
|
|
+ *
|
|
|
+ * If the return value is not -1, then calling GetChildAt_Deprecated() with
|
|
|
+ * that value will return aPossibleChild.
|
|
|
+ */
|
|
|
+- virtual int32_t IndexOf(const nsINode* aPossibleChild) const = 0;
|
|
|
++ virtual int32_t ComputeIndexOf(const nsINode* aPossibleChild) const = 0;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Returns the "node document" of this node.
|
|
|
+ *
|
|
|
+ * https://dom.spec.whatwg.org/#concept-node-document
|
|
|
+ *
|
|
|
+ * Note that in the case that this node is a document node this method
|
|
|
+ * will return |this|. That is different to the Node.ownerDocument DOM
|
|
|
+diff --git a/dom/base/nsRange.cpp b/dom/base/nsRange.cpp
|
|
|
+--- a/dom/base/nsRange.cpp
|
|
|
++++ b/dom/base/nsRange.cpp
|
|
|
+@@ -118,17 +118,17 @@ nsRange::CompareNodeToRange(nsINode* aNo
|
|
|
+ parent = aNode;
|
|
|
+ nodeStart = 0;
|
|
|
+ uint32_t childCount = aNode->GetChildCount();
|
|
|
+ MOZ_ASSERT(childCount <= INT32_MAX,
|
|
|
+ "There shouldn't be over INT32_MAX children");
|
|
|
+ nodeEnd = static_cast<int32_t>(childCount);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+- nodeStart = parent->IndexOf(aNode);
|
|
|
++ nodeStart = parent->ComputeIndexOf(aNode);
|
|
|
+ nodeEnd = nodeStart + 1;
|
|
|
+ MOZ_ASSERT(nodeStart < nodeEnd, "nodeStart shouldn't be INT32_MAX");
|
|
|
+ }
|
|
|
+
|
|
|
+ nsINode* rangeStartContainer = aRange->GetStartContainer();
|
|
|
+ nsINode* rangeEndContainer = aRange->GetEndContainer();
|
|
|
+ uint32_t rangeStartOffset = aRange->StartOffset();
|
|
|
+ uint32_t rangeEndOffset = aRange->EndOffset();
|
|
|
+@@ -964,17 +964,17 @@ nsRange::IntersectsNode(nsINode& aNode,
|
|
|
+ nsINode* parent = aNode.GetParentNode();
|
|
|
+ if (!parent) {
|
|
|
+ // Steps 2 and 4.
|
|
|
+ // |parent| is null, so |node|'s root is |node| itself.
|
|
|
+ return GetRoot() == &aNode;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Step 5.
|
|
|
+- int32_t nodeIndex = parent->IndexOf(&aNode);
|
|
|
++ int32_t nodeIndex = parent->ComputeIndexOf(&aNode);
|
|
|
+
|
|
|
+ // Steps 6-7.
|
|
|
+ // Note: if disconnected is true, ComparePoints returns 1.
|
|
|
+ bool disconnected = false;
|
|
|
+ bool result = nsContentUtils::ComparePoints(mStart.Container(), mStart.Offset(),
|
|
|
+ parent, nodeIndex + 1,
|
|
|
+ &disconnected) < 0 &&
|
|
|
+ nsContentUtils::ComparePoints(parent, nodeIndex,
|
|
|
+@@ -1099,17 +1099,17 @@ nsRange::DoSetRange(const RawRangeBounda
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ static int32_t
|
|
|
+ IndexOf(nsINode* aChild)
|
|
|
+ {
|
|
|
+ nsINode* parent = aChild->GetParentNode();
|
|
|
+
|
|
|
+- return parent ? parent->IndexOf(aChild) : -1;
|
|
|
++ return parent ? parent->ComputeIndexOf(aChild) : -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ void
|
|
|
+ nsRange::SetSelection(mozilla::dom::Selection* aSelection)
|
|
|
+ {
|
|
|
+ if (mSelection == aSelection) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+@@ -1566,19 +1566,20 @@ nsRange::SetEnd(const RawRangeBoundary&
|
|
|
+ }
|
|
|
+
|
|
|
+ void
|
|
|
+ nsRange::SelectNodesInContainer(nsINode* aContainer,
|
|
|
+ nsIContent* aStartContent,
|
|
|
+ nsIContent* aEndContent)
|
|
|
+ {
|
|
|
+ MOZ_ASSERT(aContainer);
|
|
|
+- MOZ_ASSERT(aContainer->IndexOf(aStartContent) <= aContainer->IndexOf(aEndContent));
|
|
|
+- MOZ_ASSERT(aStartContent && aContainer->IndexOf(aStartContent) != -1);
|
|
|
+- MOZ_ASSERT(aEndContent && aContainer->IndexOf(aEndContent) != -1);
|
|
|
++ MOZ_ASSERT(aContainer->ComputeIndexOf(aStartContent) <=
|
|
|
++ aContainer->ComputeIndexOf(aEndContent));
|
|
|
++ MOZ_ASSERT(aStartContent && aContainer->ComputeIndexOf(aStartContent) != -1);
|
|
|
++ MOZ_ASSERT(aEndContent && aContainer->ComputeIndexOf(aEndContent) != -1);
|
|
|
+
|
|
|
+ nsINode* newRoot = ComputeRootNode(aContainer, mMaySpanAnonymousSubtrees);
|
|
|
+ MOZ_ASSERT(newRoot);
|
|
|
+ if (!newRoot) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ RawRangeBoundary start(aContainer, aStartContent->GetPreviousSibling());
|
|
|
+@@ -1775,17 +1776,17 @@ nsRange::SelectNode(nsINode& aNode, Erro
|
|
|
+
|
|
|
+ nsINode* container = aNode.GetParentNode();
|
|
|
+ nsINode* newRoot = IsValidBoundary(container);
|
|
|
+ if (!newRoot) {
|
|
|
+ aRv.Throw(NS_ERROR_DOM_INVALID_NODE_TYPE_ERR);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+- int32_t index = container->IndexOf(&aNode);
|
|
|
++ int32_t index = container->ComputeIndexOf(&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
|
|
|
+ // actually containing it.
|
|
|
+ if (NS_WARN_IF(index < 0) ||
|
|
|
+ !IsValidOffset(static_cast<uint32_t>(index)) ||
|
|
|
+ !IsValidOffset(static_cast<uint32_t>(index) + 1)) {
|
|
|
+ aRv.Throw(NS_ERROR_DOM_INVALID_NODE_TYPE_ERR);
|
|
|
+@@ -3664,17 +3665,17 @@ nsRange::ExcludeNonSelectableNodes(nsTAr
|
|
|
+ // Create a new range for the remainder.
|
|
|
+ nsINode* startContainer = node;
|
|
|
+ int32_t startOffset = 0;
|
|
|
+ // Don't start *inside* a node with independent selection though
|
|
|
+ // (e.g. <input>).
|
|
|
+ if (content && content->HasIndependentSelection()) {
|
|
|
+ nsINode* parent = startContainer->GetParent();
|
|
|
+ if (parent) {
|
|
|
+- startOffset = parent->IndexOf(startContainer);
|
|
|
++ startOffset = parent->ComputeIndexOf(startContainer);
|
|
|
+ startContainer = parent;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ rv = CreateRange(startContainer, startOffset, endContainer, endOffset,
|
|
|
+ getter_AddRefs(newRange));
|
|
|
+ if (NS_FAILED(rv) || newRange->Collapsed()) {
|
|
|
+ newRange = nullptr;
|
|
|
+ }
|
|
|
+diff --git a/dom/base/nsRange.h b/dom/base/nsRange.h
|
|
|
+--- a/dom/base/nsRange.h
|
|
|
++++ b/dom/base/nsRange.h
|
|
|
+@@ -251,33 +251,33 @@ public:
|
|
|
+ {
|
|
|
+ MOZ_ASSERT(aNode);
|
|
|
+ MOZ_ASSERT(aOffset);
|
|
|
+ *aOffset = 0;
|
|
|
+ nsINode* parentNode = aNode->GetParentNode();
|
|
|
+ if (!parentNode) {
|
|
|
+ return nullptr;
|
|
|
+ }
|
|
|
+- int32_t indexInParent = parentNode->IndexOf(aNode);
|
|
|
++ int32_t indexInParent = parentNode->ComputeIndexOf(aNode);
|
|
|
+ if (NS_WARN_IF(indexInParent < 0)) {
|
|
|
+ return nullptr;
|
|
|
+ }
|
|
|
+ *aOffset = static_cast<uint32_t>(indexInParent) + 1;
|
|
|
+ return parentNode;
|
|
|
+ }
|
|
|
+ static nsINode* GetContainerAndOffsetBefore(nsINode* aNode, uint32_t* aOffset)
|
|
|
+ {
|
|
|
+ MOZ_ASSERT(aNode);
|
|
|
+ MOZ_ASSERT(aOffset);
|
|
|
+ *aOffset = 0;
|
|
|
+ nsINode* parentNode = aNode->GetParentNode();
|
|
|
+ if (!parentNode) {
|
|
|
+ return nullptr;
|
|
|
+ }
|
|
|
+- int32_t indexInParent = parentNode->IndexOf(aNode);
|
|
|
++ int32_t indexInParent = parentNode->ComputeIndexOf(aNode);
|
|
|
+ if (NS_WARN_IF(indexInParent < 0)) {
|
|
|
+ return nullptr;
|
|
|
+ }
|
|
|
+ *aOffset = static_cast<uint32_t>(indexInParent);
|
|
|
+ return parentNode;
|
|
|
+ }
|
|
|
+
|
|
|
+ NS_IMETHOD GetUsedFontFaces(nsIDOMFontFaceList** aResult);
|
|
|
+@@ -468,18 +468,18 @@ protected:
|
|
|
+ nsINode* IsValidBoundary(nsINode* aNode) const
|
|
|
+ {
|
|
|
+ return ComputeRootNode(aNode, mMaySpanAnonymousSubtrees);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 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::IndexOf() use int32_t. Therefore, nsRange should
|
|
|
+- * accept only 0 - INT32_MAX as valid offset for now.
|
|
|
++ * APIs like nsINode::ComputeIndexOf() 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;
|
|
|
+ }
|
|
|
+ static bool IsValidOffset(nsINode* aNode, uint32_t aOffset);
|
|
|
+
|
|
|
+ static nsINode* ComputeRootNode(nsINode* aNode,
|
|
|
+diff --git a/dom/events/ContentEventHandler.cpp b/dom/events/ContentEventHandler.cpp
|
|
|
+--- a/dom/events/ContentEventHandler.cpp
|
|
|
++++ b/dom/events/ContentEventHandler.cpp
|
|
|
+@@ -1195,28 +1195,28 @@ ContentEventHandler::SetRawRangeFromFlat
|
|
|
+ startNode = content;
|
|
|
+ startNodeOffset = static_cast<int32_t>(xpOffset);
|
|
|
+ } else if (aOffset < offset + textLength) {
|
|
|
+ // Rule #1.2 [<element>
|
|
|
+ startNode = content->GetParent();
|
|
|
+ if (NS_WARN_IF(!startNode)) {
|
|
|
+ return NS_ERROR_FAILURE;
|
|
|
+ }
|
|
|
+- startNodeOffset = startNode->IndexOf(content);
|
|
|
++ startNodeOffset = startNode->ComputeIndexOf(content);
|
|
|
+ if (NS_WARN_IF(startNodeOffset == -1)) {
|
|
|
+ // The content is being removed from the parent!
|
|
|
+ return NS_ERROR_FAILURE;
|
|
|
+ }
|
|
|
+ } else if (!content->HasChildren()) {
|
|
|
+ // Rule #1.3: <element/>[
|
|
|
+ startNode = content->GetParent();
|
|
|
+ if (NS_WARN_IF(!startNode)) {
|
|
|
+ return NS_ERROR_FAILURE;
|
|
|
+ }
|
|
|
+- startNodeOffset = startNode->IndexOf(content) + 1;
|
|
|
++ startNodeOffset = startNode->ComputeIndexOf(content) + 1;
|
|
|
+ if (NS_WARN_IF(startNodeOffset == 0)) {
|
|
|
+ // The content is being removed from the parent!
|
|
|
+ return NS_ERROR_FAILURE;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // Rule #1.4: <element>[
|
|
|
+ startNode = content;
|
|
|
+ startNodeOffset = 0;
|
|
|
+@@ -1299,17 +1299,17 @@ ContentEventHandler::SetRawRangeFromFlat
|
|
|
+ return NS_OK;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Rule #2.4: <element/>]
|
|
|
+ nsINode* endNode = content->GetParent();
|
|
|
+ if (NS_WARN_IF(!endNode)) {
|
|
|
+ return NS_ERROR_FAILURE;
|
|
|
+ }
|
|
|
+- int32_t indexInParent = endNode->IndexOf(content);
|
|
|
++ int32_t indexInParent = endNode->ComputeIndexOf(content);
|
|
|
+ if (NS_WARN_IF(indexInParent == -1)) {
|
|
|
+ // The content is being removed from the parent!
|
|
|
+ return NS_ERROR_FAILURE;
|
|
|
+ }
|
|
|
+ rv = aRawRange->SetEnd(endNode, indexInParent + 1);
|
|
|
+ if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
+ return rv;
|
|
|
+ }
|
|
|
+@@ -2853,17 +2853,17 @@ ContentEventHandler::GetFlatTextLengthIn
|
|
|
+ NodePosition endPosition(aEndPosition);
|
|
|
+
|
|
|
+ // This may be called for retrieving the text of removed nodes. Even in this
|
|
|
+ // case, the node thinks it's still in the tree because UnbindFromTree() will
|
|
|
+ // be called after here. However, the node was already removed from the
|
|
|
+ // array of children of its parent. So, be careful to handle this case.
|
|
|
+ if (aIsRemovingNode) {
|
|
|
+ DebugOnly<nsIContent*> parent = aStartPosition.Container()->GetParent();
|
|
|
+- MOZ_ASSERT(parent && parent->IndexOf(aStartPosition.Container()) == -1,
|
|
|
++ MOZ_ASSERT(parent && parent->ComputeIndexOf(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(),
|
|
|
+ "At removing the node, start and end node should be same");
|
|
|
+ MOZ_ASSERT(aStartPosition.Offset() == 0,
|
|
|
+ "When the node is being removed, the start offset should be 0");
|
|
|
+ MOZ_ASSERT(static_cast<uint32_t>(endPosition.Offset()) ==
|
|
|
+ endPosition.Container()->GetChildCount(),
|
|
|
+@@ -2894,17 +2894,17 @@ ContentEventHandler::GetFlatTextLengthIn
|
|
|
+ }
|
|
|
+ endPosition = NodePositionBefore(firstChild, 0);
|
|
|
+ } else {
|
|
|
+ // When the end node is empty, move the end position after the node.
|
|
|
+ nsIContent* parentContent = endPosition.Container()->GetParent();
|
|
|
+ if (NS_WARN_IF(!parentContent)) {
|
|
|
+ return NS_ERROR_FAILURE;
|
|
|
+ }
|
|
|
+- int32_t indexInParent = parentContent->IndexOf(endPosition.Container());
|
|
|
++ int32_t indexInParent = parentContent->ComputeIndexOf(endPosition.Container());
|
|
|
+ if (NS_WARN_IF(indexInParent < 0)) {
|
|
|
+ return NS_ERROR_FAILURE;
|
|
|
+ }
|
|
|
+ endPosition = NodePositionBefore(parentContent, indexInParent + 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (endPosition.IsSetAndValid()) {
|
|
|
+@@ -3140,18 +3140,18 @@ static void AdjustRangeForSelection(nsIC
|
|
|
+ // do this hack. If you did this, ContentEventHandler couldn't distinguish
|
|
|
+ // if the range includes open tag of the next node in some cases, e.g.,
|
|
|
+ // textNode]<p></p> vs. textNode<p>]</p>
|
|
|
+ if (!aRootParent->IsHTMLElement(nsGkAtoms::textarea)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ *aNode = node->GetParent();
|
|
|
+- MOZ_ASSERT((*aNode)->IndexOf(node) != -1);
|
|
|
+- *aNodeOffset = (*aNode)->IndexOf(node) + 1;
|
|
|
++ MOZ_ASSERT((*aNode)->ComputeIndexOf(node) != -1);
|
|
|
++ *aNodeOffset = (*aNode)->ComputeIndexOf(node) + 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ nsresult
|
|
|
+ ContentEventHandler::OnSelectionEvent(WidgetSelectionEvent* aEvent)
|
|
|
+ {
|
|
|
+ aEvent->mSucceeded = false;
|
|
|
+
|
|
|
+ // Get selection to manipulate
|
|
|
+diff --git a/dom/html/HTMLFieldSetElement.cpp b/dom/html/HTMLFieldSetElement.cpp
|
|
|
+--- a/dom/html/HTMLFieldSetElement.cpp
|
|
|
++++ b/dom/html/HTMLFieldSetElement.cpp
|
|
|
+@@ -147,17 +147,17 @@ HTMLFieldSetElement::InsertChildAt(nsICo
|
|
|
+
|
|
|
+ if (aChild->IsHTMLElement(nsGkAtoms::legend)) {
|
|
|
+ if (!mFirstLegend) {
|
|
|
+ mFirstLegend = aChild;
|
|
|
+ // We do not want to notify the first time mFirstElement is set.
|
|
|
+ } else {
|
|
|
+ // If mFirstLegend is before aIndex, we do not change it.
|
|
|
+ // Otherwise, mFirstLegend is now aChild.
|
|
|
+- if (int32_t(aIndex) <= IndexOf(mFirstLegend)) {
|
|
|
++ if (int32_t(aIndex) <= ComputeIndexOf(mFirstLegend)) {
|
|
|
+ mFirstLegend = aChild;
|
|
|
+ firstLegendHasChanged = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ nsresult rv = nsGenericHTMLFormElement::InsertChildAt(aChild, aIndex, aNotify);
|
|
|
+ NS_ENSURE_SUCCESS(rv, rv);
|
|
|
+diff --git a/dom/html/HTMLImageElement.cpp b/dom/html/HTMLImageElement.cpp
|
|
|
+--- a/dom/html/HTMLImageElement.cpp
|
|
|
++++ b/dom/html/HTMLImageElement.cpp
|
|
|
+@@ -57,17 +57,17 @@ NS_IMPL_NS_NEW_HTML_ELEMENT(Image)
|
|
|
+ static bool IsPreviousSibling(nsINode *aSubject, nsINode *aNode)
|
|
|
+ {
|
|
|
+ if (aSubject == aNode) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ nsINode *parent = aSubject->GetParentNode();
|
|
|
+ if (parent && parent == aNode->GetParentNode()) {
|
|
|
+- return parent->IndexOf(aSubject) < parent->IndexOf(aNode);
|
|
|
++ return parent->ComputeIndexOf(aSubject) < parent->ComputeIndexOf(aNode);
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ #endif
|
|
|
+
|
|
|
+ namespace mozilla {
|
|
|
+ namespace dom {
|
|
|
+diff --git a/dom/html/HTMLOptGroupElement.cpp b/dom/html/HTMLOptGroupElement.cpp
|
|
|
+--- a/dom/html/HTMLOptGroupElement.cpp
|
|
|
++++ b/dom/html/HTMLOptGroupElement.cpp
|
|
|
+@@ -92,18 +92,18 @@ HTMLOptGroupElement::RemoveChildAt_Depre
|
|
|
+ SafeOptionListMutation safeMutation(GetSelect(), this, nullptr, aIndex,
|
|
|
+ aNotify);
|
|
|
+ nsGenericHTMLElement::RemoveChildAt_Deprecated(aIndex, aNotify);
|
|
|
+ }
|
|
|
+
|
|
|
+ void
|
|
|
+ HTMLOptGroupElement::RemoveChildNode(nsIContent* aKid, bool aNotify)
|
|
|
+ {
|
|
|
+- SafeOptionListMutation safeMutation(GetSelect(), this, nullptr, IndexOf(aKid),
|
|
|
+- aNotify);
|
|
|
++ SafeOptionListMutation safeMutation(GetSelect(), this, nullptr,
|
|
|
++ ComputeIndexOf(aKid), aNotify);
|
|
|
+ nsGenericHTMLElement::RemoveChildNode(aKid, aNotify);
|
|
|
+ }
|
|
|
+
|
|
|
+ nsresult
|
|
|
+ HTMLOptGroupElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
|
|
+ const nsAttrValue* aValue,
|
|
|
+ const nsAttrValue* aOldValue,
|
|
|
+ nsIPrincipal* aSubjectPrincipal,
|
|
|
+diff --git a/dom/html/HTMLSelectElement.cpp b/dom/html/HTMLSelectElement.cpp
|
|
|
+--- a/dom/html/HTMLSelectElement.cpp
|
|
|
++++ b/dom/html/HTMLSelectElement.cpp
|
|
|
+@@ -222,17 +222,18 @@ HTMLSelectElement::RemoveChildAt_Depreca
|
|
|
+ {
|
|
|
+ SafeOptionListMutation safeMutation(this, this, nullptr, aIndex, aNotify);
|
|
|
+ nsGenericHTMLFormElementWithState::RemoveChildAt_Deprecated(aIndex, aNotify);
|
|
|
+ }
|
|
|
+
|
|
|
+ void
|
|
|
+ HTMLSelectElement::RemoveChildNode(nsIContent* aKid, bool aNotify)
|
|
|
+ {
|
|
|
+- SafeOptionListMutation safeMutation(this, this, nullptr, IndexOf(aKid), aNotify);
|
|
|
++ SafeOptionListMutation safeMutation(this, this, nullptr,
|
|
|
++ ComputeIndexOf(aKid), aNotify);
|
|
|
+ nsGenericHTMLFormElementWithState::RemoveChildNode(aKid, aNotify);
|
|
|
+ }
|
|
|
+
|
|
|
+ void
|
|
|
+ HTMLSelectElement::InsertOptionsIntoList(nsIContent* aOptions,
|
|
|
+ int32_t aListIndex,
|
|
|
+ int32_t aDepth,
|
|
|
+ bool aNotify)
|
|
|
+@@ -494,17 +495,17 @@ HTMLSelectElement::GetOptionIndexAfter(n
|
|
|
+ return Length();
|
|
|
+ }
|
|
|
+
|
|
|
+ int32_t retval = -1;
|
|
|
+
|
|
|
+ nsCOMPtr<nsIContent> parent = aOptions->GetParent();
|
|
|
+
|
|
|
+ if (parent) {
|
|
|
+- int32_t index = parent->IndexOf(aOptions);
|
|
|
++ int32_t index = parent->ComputeIndexOf(aOptions);
|
|
|
+ int32_t count = parent->GetChildCount();
|
|
|
+
|
|
|
+ retval = GetFirstChildOptionIndex(parent, index+1, count);
|
|
|
+
|
|
|
+ if (retval == -1) {
|
|
|
+ retval = GetOptionIndexAfter(parent);
|
|
|
+ }
|
|
|
+ }
|
|
|
+diff --git a/dom/html/TextTrackManager.cpp b/dom/html/TextTrackManager.cpp
|
|
|
+--- a/dom/html/TextTrackManager.cpp
|
|
|
++++ b/dom/html/TextTrackManager.cpp
|
|
|
+@@ -46,17 +46,17 @@ CompareTextTracks::CompareTextTracks(HTM
|
|
|
+
|
|
|
+ int32_t
|
|
|
+ CompareTextTracks::TrackChildPosition(TextTrack* aTextTrack) const {
|
|
|
+ MOZ_DIAGNOSTIC_ASSERT(aTextTrack);
|
|
|
+ HTMLTrackElement* trackElement = aTextTrack->GetTrackElement();
|
|
|
+ if (!trackElement) {
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+- return mMediaElement->IndexOf(trackElement);
|
|
|
++ return mMediaElement->ComputeIndexOf(trackElement);
|
|
|
+ }
|
|
|
+
|
|
|
+ bool
|
|
|
+ CompareTextTracks::Equals(TextTrack* aOne, TextTrack* aTwo) const {
|
|
|
+ // Two tracks can never be equal. If they have corresponding TrackElements
|
|
|
+ // they would need to occupy the same tree position (impossible) and in the
|
|
|
+ // case of tracks coming from AddTextTrack source we put the newest at the
|
|
|
+ // last position, so they won't be equal as well.
|
|
|
+@@ -530,17 +530,17 @@ private:
|
|
|
+
|
|
|
+ class CompareSimpleTextTrackEvents {
|
|
|
+ private:
|
|
|
+ int32_t TrackChildPosition(SimpleTextTrackEvent* aEvent) const
|
|
|
+ {
|
|
|
+ if (aEvent->mTrack) {
|
|
|
+ HTMLTrackElement* trackElement = aEvent->mTrack->GetTrackElement();
|
|
|
+ if (trackElement) {
|
|
|
+- return mMediaElement->IndexOf(trackElement);
|
|
|
++ return mMediaElement->ComputeIndexOf(trackElement);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ HTMLMediaElement* mMediaElement;
|
|
|
+ public:
|
|
|
+ explicit CompareSimpleTextTrackEvents(HTMLMediaElement* aMediaElement)
|
|
|
+ {
|
|
|
+diff --git a/dom/html/nsGenericHTMLElement.cpp b/dom/html/nsGenericHTMLElement.cpp
|
|
|
+--- a/dom/html/nsGenericHTMLElement.cpp
|
|
|
++++ b/dom/html/nsGenericHTMLElement.cpp
|
|
|
+@@ -499,17 +499,17 @@ nsGenericHTMLElement::FindAncestorForm(H
|
|
|
+ if (content->IsHTMLElement(nsGkAtoms::form)) {
|
|
|
+ #ifdef DEBUG
|
|
|
+ if (!nsContentUtils::IsInSameAnonymousTree(this, content)) {
|
|
|
+ // It's possible that we started unbinding at |content| or
|
|
|
+ // some ancestor of it, and |content| and |this| used to all be
|
|
|
+ // anonymous. Check for this the hard way.
|
|
|
+ for (nsIContent* child = this; child != content;
|
|
|
+ child = child->GetParent()) {
|
|
|
+- NS_ASSERTION(child->GetParent()->IndexOf(child) != -1,
|
|
|
++ NS_ASSERTION(child->GetParent()->ComputeIndexOf(child) != -1,
|
|
|
+ "Walked too far?");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ #endif
|
|
|
+ return static_cast<HTMLFormElement*>(content);
|
|
|
+ }
|
|
|
+
|
|
|
+ nsIContent *prevContent = content;
|
|
|
+diff --git a/dom/html/nsHTMLContentSink.cpp b/dom/html/nsHTMLContentSink.cpp
|
|
|
+--- a/dom/html/nsHTMLContentSink.cpp
|
|
|
++++ b/dom/html/nsHTMLContentSink.cpp
|
|
|
+@@ -978,17 +978,17 @@ HTMLContentSink::NotifyRootInsertion()
|
|
|
+ // Now make sure to notify that we have now inserted our root. If
|
|
|
+ // there has been no initial reflow yet it'll be a no-op, but if
|
|
|
+ // there has been one we need this to get its frames constructed.
|
|
|
+ // Note that if mNotifiedRootInsertion is true we don't notify here,
|
|
|
+ // since that just means there are multiple <html> tags in the
|
|
|
+ // document; in those cases we just want to put all the attrs on one
|
|
|
+ // tag.
|
|
|
+ mNotifiedRootInsertion = true;
|
|
|
+- int32_t index = mDocument->IndexOf(mRoot);
|
|
|
++ int32_t index = mDocument->ComputeIndexOf(mRoot);
|
|
|
+ NS_ASSERTION(index != -1, "mRoot not child of document?");
|
|
|
+ NotifyInsert(nullptr, mRoot, index);
|
|
|
+
|
|
|
+ // Now update the notification information in all our
|
|
|
+ // contexts, since we just inserted the root and notified on
|
|
|
+ // our whole tree
|
|
|
+ UpdateChildCounts();
|
|
|
+ }
|
|
|
+diff --git a/dom/xbl/XBLChildrenElement.cpp b/dom/xbl/XBLChildrenElement.cpp
|
|
|
+--- a/dom/xbl/XBLChildrenElement.cpp
|
|
|
++++ b/dom/xbl/XBLChildrenElement.cpp
|
|
|
+@@ -159,17 +159,17 @@ nsAnonymousContentList::IndexOf(nsIConte
|
|
|
+ if (point->HasInsertedChildren()) {
|
|
|
+ int32_t insIndex = point->IndexOfInsertedChild(aContent);
|
|
|
+ if (insIndex != -1) {
|
|
|
+ return index + insIndex;
|
|
|
+ }
|
|
|
+ index += point->InsertedChildrenLength();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+- int32_t insIndex = point->IndexOf(aContent);
|
|
|
++ int32_t insIndex = point->ComputeIndexOf(aContent);
|
|
|
+ if (insIndex != -1) {
|
|
|
+ return index + insIndex;
|
|
|
+ }
|
|
|
+ index += point->GetChildCount();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ if (child == aContent) {
|
|
|
+diff --git a/dom/xbl/nsXBLPrototypeBinding.cpp b/dom/xbl/nsXBLPrototypeBinding.cpp
|
|
|
+--- a/dom/xbl/nsXBLPrototypeBinding.cpp
|
|
|
++++ b/dom/xbl/nsXBLPrototypeBinding.cpp
|
|
|
+@@ -486,17 +486,18 @@ nsXBLPrototypeBinding::LocateInstance(El
|
|
|
+
|
|
|
+ nsIContent *copyParent =
|
|
|
+ templParent == aTemplRoot ? aCopyRoot :
|
|
|
+ LocateInstance(aBoundElement, aTemplRoot, aCopyRoot, templParent);
|
|
|
+
|
|
|
+ if (!copyParent)
|
|
|
+ return nullptr;
|
|
|
+
|
|
|
+- nsIContent* child = copyParent->GetChildAt_Deprecated(templParent->IndexOf(aTemplChild));
|
|
|
++ nsIContent* child =
|
|
|
++ copyParent->GetChildAt_Deprecated(templParent->ComputeIndexOf(aTemplChild));
|
|
|
+ if (child && child->IsElement()) {
|
|
|
+ return child->AsElement();
|
|
|
+ }
|
|
|
+ return nullptr;
|
|
|
+ }
|
|
|
+
|
|
|
+ void
|
|
|
+ nsXBLPrototypeBinding::SetInitialAttributes(
|
|
|
+diff --git a/dom/xml/nsXMLContentSink.cpp b/dom/xml/nsXMLContentSink.cpp
|
|
|
+--- a/dom/xml/nsXMLContentSink.cpp
|
|
|
++++ b/dom/xml/nsXMLContentSink.cpp
|
|
|
+@@ -380,17 +380,17 @@ nsXMLContentSink::OnTransformDone(nsresu
|
|
|
+ }
|
|
|
+
|
|
|
+ // Notify document observers that all the content has been stuck
|
|
|
+ // into the document.
|
|
|
+ // XXX do we need to notify for things like PIs? Or just the
|
|
|
+ // documentElement?
|
|
|
+ nsIContent *rootElement = mDocument->GetRootElement();
|
|
|
+ if (rootElement) {
|
|
|
+- NS_ASSERTION(mDocument->IndexOf(rootElement) != -1,
|
|
|
++ NS_ASSERTION(mDocument->ComputeIndexOf(rootElement) != -1,
|
|
|
+ "rootElement not in doc?");
|
|
|
+ mDocument->BeginUpdate(UPDATE_CONTENT_MODEL);
|
|
|
+ nsNodeUtils::ContentInserted(mDocument, rootElement);
|
|
|
+ mDocument->EndUpdate(UPDATE_CONTENT_MODEL);
|
|
|
+ }
|
|
|
+
|
|
|
+ // Start the layout process
|
|
|
+ StartLayout(false);
|
|
|
+diff --git a/dom/xslt/xpath/txMozillaXPathTreeWalker.cpp b/dom/xslt/xpath/txMozillaXPathTreeWalker.cpp
|
|
|
+--- a/dom/xslt/xpath/txMozillaXPathTreeWalker.cpp
|
|
|
++++ b/dom/xslt/xpath/txMozillaXPathTreeWalker.cpp
|
|
|
+@@ -572,17 +572,17 @@ txXPathNodeUtils::comparePosition(const
|
|
|
+ // Hopefully this is a common case.
|
|
|
+ if (parent == otherParent) {
|
|
|
+ if (!parent) {
|
|
|
+ // Both node and otherNode are root nodes in respective orphan
|
|
|
+ // tree.
|
|
|
+ return node < otherNode ? -1 : 1;
|
|
|
+ }
|
|
|
+
|
|
|
+- return parent->IndexOf(node) < parent->IndexOf(otherNode) ?
|
|
|
++ return parent->ComputeIndexOf(node) < parent->ComputeIndexOf(otherNode) ?
|
|
|
+ -1 : 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ parents.AppendElement(node);
|
|
|
+ otherParents.AppendElement(otherNode);
|
|
|
+ node = parent;
|
|
|
+ otherNode = otherParent;
|
|
|
+ }
|
|
|
+@@ -609,18 +609,18 @@ txXPathNodeUtils::comparePosition(const
|
|
|
+ otherNode = otherParents.ElementAt(otherTotal - i);
|
|
|
+ if (node != otherNode) {
|
|
|
+ if (!parent) {
|
|
|
+ // The two nodes are in different orphan subtrees.
|
|
|
+ NS_ASSERTION(i == 0, "this shouldn't happen");
|
|
|
+ return node < otherNode ? -1 : 1;
|
|
|
+ }
|
|
|
+
|
|
|
+- int32_t index = parent->IndexOf(node);
|
|
|
+- int32_t otherIndex = parent->IndexOf(otherNode);
|
|
|
++ int32_t index = parent->ComputeIndexOf(node);
|
|
|
++ int32_t otherIndex = parent->ComputeIndexOf(otherNode);
|
|
|
+ NS_ASSERTION(index != otherIndex && index >= 0 && otherIndex >= 0,
|
|
|
+ "invalid index in compareTreePosition");
|
|
|
+
|
|
|
+ return index < otherIndex ? -1 : 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ parent = node;
|
|
|
+ }
|
|
|
+diff --git a/dom/xul/XULDocument.cpp b/dom/xul/XULDocument.cpp
|
|
|
+--- a/dom/xul/XULDocument.cpp
|
|
|
++++ b/dom/xul/XULDocument.cpp
|
|
|
+@@ -2276,17 +2276,17 @@ XULDocument::PrepareToWalk()
|
|
|
+ ("xul: error parsing '%s'", urlspec.get()));
|
|
|
+ }
|
|
|
+
|
|
|
+ return NS_OK;
|
|
|
+ }
|
|
|
+
|
|
|
+ uint32_t piInsertionPoint = 0;
|
|
|
+ if (mState != eState_Master) {
|
|
|
+- int32_t indexOfRoot = IndexOf(GetRootElement());
|
|
|
++ int32_t indexOfRoot = ComputeIndexOf(GetRootElement());
|
|
|
+ NS_ASSERTION(indexOfRoot >= 0,
|
|
|
+ "No root content when preparing to walk overlay!");
|
|
|
+ piInsertionPoint = indexOfRoot;
|
|
|
+ }
|
|
|
+
|
|
|
+ const nsTArray<RefPtr<nsXULPrototypePI> >& processingInstructions =
|
|
|
+ mCurrentPrototype->GetProcessingInstructions();
|
|
|
+
|
|
|
+@@ -4290,17 +4290,17 @@ XULDocument::InsertElement(nsINode* aPar
|
|
|
+ if (content)
|
|
|
+ break;
|
|
|
+
|
|
|
+ token = nsCRT::strtok(rest, ", ", &rest);
|
|
|
+ }
|
|
|
+ free(str);
|
|
|
+
|
|
|
+ if (content) {
|
|
|
+- int32_t pos = aParent->IndexOf(content);
|
|
|
++ int32_t pos = aParent->ComputeIndexOf(content);
|
|
|
+
|
|
|
+ if (pos != -1) {
|
|
|
+ pos = isInsertAfter ? pos + 1 : pos;
|
|
|
+ nsresult rv = aParent->InsertChildAt(aChild, pos, aNotify);
|
|
|
+ if (NS_FAILED(rv))
|
|
|
+ return rv;
|
|
|
+
|
|
|
+ wasInserted = true;
|
|
|
+diff --git a/dom/xul/XULDocument.cpp.1430997-1.later b/dom/xul/XULDocument.cpp.1430997-1.later
|
|
|
+new file mode 100644
|
|
|
+--- /dev/null
|
|
|
++++ b/dom/xul/XULDocument.cpp.1430997-1.later
|
|
|
+@@ -0,0 +1,21 @@
|
|
|
++--- XULDocument.cpp
|
|
|
+++++ XULDocument.cpp
|
|
|
++@@ -4024,17 +4024,17 @@ XULDocument::InsertElement(nsINode* aPar
|
|
|
++ return aParent->AppendChildTo(aChild, aNotify);
|
|
|
++ }
|
|
|
++ return NS_OK;
|
|
|
++ }
|
|
|
++
|
|
|
++ nsresult
|
|
|
++ XULDocument::RemoveElement(nsINode* aParent, nsINode* aChild)
|
|
|
++ {
|
|
|
++- int32_t nodeOffset = aParent->IndexOf(aChild);
|
|
|
+++ int32_t nodeOffset = aParent->ComputeIndexOf(aChild);
|
|
|
++
|
|
|
++ aParent->RemoveChildAt_Deprecated(nodeOffset, true);
|
|
|
++ return NS_OK;
|
|
|
++ }
|
|
|
++
|
|
|
++ //----------------------------------------------------------------------
|
|
|
++ //
|
|
|
++ // CachedChromeStreamListener
|
|
|
+diff --git a/dom/xul/templates/nsXULContentBuilder.cpp b/dom/xul/templates/nsXULContentBuilder.cpp
|
|
|
+--- a/dom/xul/templates/nsXULContentBuilder.cpp
|
|
|
++++ b/dom/xul/templates/nsXULContentBuilder.cpp
|
|
|
+@@ -905,17 +905,17 @@ nsXULContentBuilder::SynchronizeUsingTem
|
|
|
+ return NS_OK;
|
|
|
+ }
|
|
|
+
|
|
|
+ nsresult
|
|
|
+ nsXULContentBuilder::RemoveMember(nsIContent* aContent)
|
|
|
+ {
|
|
|
+ nsCOMPtr<nsIContent> parent = aContent->GetParent();
|
|
|
+ if (parent) {
|
|
|
+- int32_t pos = parent->IndexOf(aContent);
|
|
|
++ int32_t pos = parent->ComputeIndexOf(aContent);
|
|
|
+
|
|
|
+ NS_ASSERTION(pos >= 0, "parent doesn't think this child has an index");
|
|
|
+ if (pos < 0) return NS_OK;
|
|
|
+
|
|
|
+ // Note: RemoveChildAt_Deprecated sets |child|'s document to null so
|
|
|
+ // that it'll get knocked out of the XUL doc's resource-to-element map.
|
|
|
+ parent->RemoveChildAt_Deprecated(pos, true);
|
|
|
+ }
|
|
|
+diff --git a/editor/libeditor/EditorBase.cpp b/editor/libeditor/EditorBase.cpp
|
|
|
+--- a/editor/libeditor/EditorBase.cpp
|
|
|
++++ b/editor/libeditor/EditorBase.cpp
|
|
|
+@@ -1147,17 +1147,17 @@ EditorBase::BeginningOfDocument()
|
|
|
+ }
|
|
|
+
|
|
|
+ // Otherwise, it's a leaf node and we set the selection just in front of it.
|
|
|
+ nsCOMPtr<nsIContent> parent = firstNode->GetParent();
|
|
|
+ if (!parent) {
|
|
|
+ return NS_ERROR_NULL_POINTER;
|
|
|
+ }
|
|
|
+
|
|
|
+- MOZ_ASSERT(parent->IndexOf(firstNode) == 0,
|
|
|
++ MOZ_ASSERT(parent->ComputeIndexOf(firstNode) == 0,
|
|
|
+ "How come the first node isn't the left most child in its parent?");
|
|
|
+ return selection->Collapse(parent, 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ NS_IMETHODIMP
|
|
|
+ EditorBase::EndOfDocument()
|
|
|
+ {
|
|
|
+ RefPtr<Selection> selection = GetSelection();
|
|
|
+@@ -1640,17 +1640,17 @@ EditorBase::JoinNodes(nsINode& aLeftNode
|
|
|
+ nsCOMPtr<nsINode> parent = aLeftNode.GetParentNode();
|
|
|
+ MOZ_ASSERT(parent);
|
|
|
+
|
|
|
+ AutoRules beginRulesSniffing(this, EditAction::joinNode,
|
|
|
+ nsIEditor::ePrevious);
|
|
|
+
|
|
|
+ // Remember some values; later used for saved selection updating.
|
|
|
+ // Find the offset between the nodes to be joined.
|
|
|
+- int32_t offset = parent->IndexOf(&aRightNode);
|
|
|
++ int32_t offset = parent->ComputeIndexOf(&aRightNode);
|
|
|
+ // Find the number of children of the lefthand node
|
|
|
+ uint32_t oldLeftNodeLen = aLeftNode.Length();
|
|
|
+
|
|
|
+ if (mRules && mRules->AsHTMLEditRules()) {
|
|
|
+ RefPtr<HTMLEditRules> htmlEditRules = mRules->AsHTMLEditRules();
|
|
|
+ htmlEditRules->WillJoinNodes(aLeftNode, aRightNode);
|
|
|
+ }
|
|
|
+
|
|
|
+@@ -1934,17 +1934,17 @@ EditorBase::MoveNode(nsIContent* aNode,
|
|
|
+ MOZ_ASSERT(aOffset == -1 ||
|
|
|
+ (0 <= aOffset &&
|
|
|
+ AssertedCast<uint32_t>(aOffset) <= aParent->Length()));
|
|
|
+
|
|
|
+ nsCOMPtr<nsINode> oldParent = aNode->GetParentNode();
|
|
|
+ if (NS_WARN_IF(!oldParent)) {
|
|
|
+ return NS_ERROR_FAILURE;
|
|
|
+ }
|
|
|
+- int32_t oldOffset = oldParent->IndexOf(aNode);
|
|
|
++ int32_t oldOffset = oldParent->ComputeIndexOf(aNode);
|
|
|
+
|
|
|
+ if (aOffset == -1) {
|
|
|
+ // Magic value meaning "move to end of aParent"
|
|
|
+ aOffset = AssertedCast<int32_t>(aParent->Length());
|
|
|
+ }
|
|
|
+
|
|
|
+ // Don't do anything if it's already in right place
|
|
|
+ if (aParent == oldParent && aOffset == oldOffset) {
|
|
|
+@@ -3512,33 +3512,33 @@ EditorBase::GetChildOffset(nsIDOMNode* a
|
|
|
+ // static
|
|
|
+ int32_t
|
|
|
+ EditorBase::GetChildOffset(nsINode* aChild,
|
|
|
+ nsINode* aParent)
|
|
|
+ {
|
|
|
+ MOZ_ASSERT(aChild);
|
|
|
+ MOZ_ASSERT(aParent);
|
|
|
+
|
|
|
+- // nsINode::IndexOf() is expensive. So, if we can return index without
|
|
|
+- // calling it, we should do that.
|
|
|
++ // nsINode::ComputeIndexOf() is expensive. So, if we can return index
|
|
|
++ // without calling it, we should do that.
|
|
|
+
|
|
|
+ // If there is no previous siblings, it means that it's the first child.
|
|
|
+ if (aParent->GetFirstChild() == aChild) {
|
|
|
+- MOZ_ASSERT(aParent->IndexOf(aChild) == 0);
|
|
|
++ MOZ_ASSERT(aParent->ComputeIndexOf(aChild) == 0);
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ // If there is no next siblings, it means that it's the last child.
|
|
|
+ if (aParent->GetLastChild() == aChild) {
|
|
|
+ int32_t lastChildIndex = static_cast<int32_t>(aParent->Length() - 1);
|
|
|
+- MOZ_ASSERT(aParent->IndexOf(aChild) == lastChildIndex);
|
|
|
++ MOZ_ASSERT(aParent->ComputeIndexOf(aChild) == lastChildIndex);
|
|
|
+ return lastChildIndex;
|
|
|
+ }
|
|
|
+
|
|
|
+- int32_t index = aParent->IndexOf(aChild);
|
|
|
++ int32_t index = aParent->ComputeIndexOf(aChild);
|
|
|
+ MOZ_ASSERT(index != -1);
|
|
|
+ return index;
|
|
|
+ }
|
|
|
+
|
|
|
+ // static
|
|
|
+ already_AddRefed<nsIDOMNode>
|
|
|
+ EditorBase::GetNodeLocation(nsIDOMNode* aChild,
|
|
|
+ int32_t* outOffset)
|
|
|
+diff --git a/editor/libeditor/EditorDOMPoint.h b/editor/libeditor/EditorDOMPoint.h
|
|
|
+--- a/editor/libeditor/EditorDOMPoint.h
|
|
|
++++ b/editor/libeditor/EditorDOMPoint.h
|
|
|
+@@ -347,17 +347,17 @@ public:
|
|
|
+ return mOffset.value();
|
|
|
+ }
|
|
|
+ MOZ_ASSERT(mChild->GetParentNode() == mParent);
|
|
|
+ // Fix offset now.
|
|
|
+ if (mChild == mParent->GetFirstChild()) {
|
|
|
+ const_cast<SelfType*>(this)->mOffset = mozilla::Some(0);
|
|
|
+ } else {
|
|
|
+ const_cast<SelfType*>(this)->mOffset =
|
|
|
+- mozilla::Some(mParent->IndexOf(mChild));
|
|
|
++ mozilla::Some(mParent->ComputeIndexOf(mChild));
|
|
|
+ }
|
|
|
+ return mOffset.value();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Set() sets a point to aOffset or aChild.
|
|
|
+ * If it's set with aOffset, mChild is invalidated. If it's set with aChild,
|
|
|
+ * mOffset may be invalidated.
|
|
|
+diff --git a/editor/libeditor/HTMLEditRules.cpp b/editor/libeditor/HTMLEditRules.cpp
|
|
|
+--- a/editor/libeditor/HTMLEditRules.cpp
|
|
|
++++ b/editor/libeditor/HTMLEditRules.cpp
|
|
|
+@@ -831,17 +831,17 @@ HTMLEditRules::GetAlignment(bool* aMixed
|
|
|
+ NS_ENSURE_STATE(htmlEditor->GetSelection());
|
|
|
+ OwningNonNull<Selection> selection = *htmlEditor->GetSelection();
|
|
|
+
|
|
|
+ // Get selection location
|
|
|
+ NS_ENSURE_TRUE(htmlEditor->GetRoot(), NS_ERROR_FAILURE);
|
|
|
+ OwningNonNull<Element> root = *htmlEditor->GetRoot();
|
|
|
+
|
|
|
+ int32_t rootOffset = root->GetParentNode() ?
|
|
|
+- root->GetParentNode()->IndexOf(root) : -1;
|
|
|
++ root->GetParentNode()->ComputeIndexOf(root) : -1;
|
|
|
+
|
|
|
+ nsRange* firstRange = selection->GetRangeAt(0);
|
|
|
+ if (NS_WARN_IF(!firstRange)) {
|
|
|
+ return NS_ERROR_FAILURE;
|
|
|
+ }
|
|
|
+ EditorRawDOMPoint atStartOfSelection(firstRange->StartRef());
|
|
|
+ if (NS_WARN_IF(!atStartOfSelection.IsSet())) {
|
|
|
+ return NS_ERROR_FAILURE;
|
|
|
+@@ -2374,17 +2374,17 @@ HTMLEditRules::WillDeleteSelection(Selec
|
|
|
+ // interline position is false (left)
|
|
|
+ //
|
|
|
+ // In any other case we set the position to startnode -1 and
|
|
|
+ // interlineposition to false, only moving the caret to the
|
|
|
+ // end-of-hr-line position.
|
|
|
+ bool moveOnly = true;
|
|
|
+
|
|
|
+ selNode = visNode->GetParentNode();
|
|
|
+- selOffset = selNode ? selNode->IndexOf(visNode) : -1;
|
|
|
++ selOffset = selNode ? selNode->ComputeIndexOf(visNode) : -1;
|
|
|
+
|
|
|
+ bool interLineIsRight;
|
|
|
+ rv = aSelection->GetInterlinePosition(&interLineIsRight);
|
|
|
+ NS_ENSURE_SUCCESS(rv, rv);
|
|
|
+
|
|
|
+ if (startNode == selNode && startOffset - 1 == selOffset &&
|
|
|
+ !interLineIsRight) {
|
|
|
+ moveOnly = false;
|
|
|
+@@ -5455,22 +5455,22 @@ HTMLEditRules::CheckForInvisibleBR(Eleme
|
|
|
+ mHTMLEditor->GetRightmostChild(&aBlock, true);
|
|
|
+
|
|
|
+ if (!rightmostNode) {
|
|
|
+ return nullptr;
|
|
|
+ }
|
|
|
+
|
|
|
+ testNode = rightmostNode->GetParentNode();
|
|
|
+ // Since rightmostNode is always the last child, its index is equal to the
|
|
|
+- // child count, so instead of IndexOf() we use the faster GetChildCount(),
|
|
|
+- // and assert the equivalence below.
|
|
|
++ // child count, so instead of ComputeIndexOf() we use the faster
|
|
|
++ // GetChildCount(), and assert the equivalence below.
|
|
|
+ testOffset = testNode->GetChildCount();
|
|
|
+
|
|
|
+ // Use offset + 1, so last node is included in our evaluation
|
|
|
+- MOZ_ASSERT(testNode->IndexOf(rightmostNode) + 1 == testOffset);
|
|
|
++ MOZ_ASSERT(testNode->ComputeIndexOf(rightmostNode) + 1 == testOffset);
|
|
|
+ } else if (aOffset) {
|
|
|
+ testNode = &aBlock;
|
|
|
+ // We'll check everything to the left of the input position
|
|
|
+ testOffset = aOffset;
|
|
|
+ } else {
|
|
|
+ return nullptr;
|
|
|
+ }
|
|
|
+
|
|
|
+@@ -5564,17 +5564,17 @@ HTMLEditRules::ExpandSelectionForDeletio
|
|
|
+ // element boundaries, or if we hit the root.
|
|
|
+ if (HTMLEditUtils::IsTableElement(wsObj.mStartReasonNode) ||
|
|
|
+ selCommon == wsObj.mStartReasonNode ||
|
|
|
+ root == wsObj.mStartReasonNode) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ selStartNode = wsObj.mStartReasonNode->GetParentNode();
|
|
|
+ selStartOffset = selStartNode ?
|
|
|
+- selStartNode->IndexOf(wsObj.mStartReasonNode) : -1;
|
|
|
++ selStartNode->ComputeIndexOf(wsObj.mStartReasonNode) : -1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // Find next visible thingy after end of selection
|
|
|
+ if (selEndNode != selCommon && selEndNode != root) {
|
|
|
+ for (;;) {
|
|
|
+ WSRunObject wsObj(mHTMLEditor, selEndNode, selEndOffset);
|
|
|
+ wsObj.NextVisibleNode(selEndNode, selEndOffset, address_of(unused),
|
|
|
+@@ -5584,27 +5584,27 @@ HTMLEditRules::ExpandSelectionForDeletio
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if (!firstBRParent) {
|
|
|
+ firstBRParent = selEndNode;
|
|
|
+ firstBROffset = selEndOffset;
|
|
|
+ }
|
|
|
+ selEndNode = wsObj.mEndReasonNode->GetParentNode();
|
|
|
+ selEndOffset = selEndNode
|
|
|
+- ? selEndNode->IndexOf(wsObj.mEndReasonNode) + 1 : 0;
|
|
|
++ ? selEndNode->ComputeIndexOf(wsObj.mEndReasonNode) + 1 : 0;
|
|
|
+ } else if (wsType == WSType::thisBlock) {
|
|
|
+ // We want to keep looking up. But stop if we are crossing table
|
|
|
+ // element boundaries, or if we hit the root.
|
|
|
+ if (HTMLEditUtils::IsTableElement(wsObj.mEndReasonNode) ||
|
|
|
+ selCommon == wsObj.mEndReasonNode ||
|
|
|
+ root == wsObj.mEndReasonNode) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ selEndNode = wsObj.mEndReasonNode->GetParentNode();
|
|
|
+- selEndOffset = 1 + selEndNode->IndexOf(wsObj.mEndReasonNode);
|
|
|
++ selEndOffset = 1 + selEndNode->ComputeIndexOf(wsObj.mEndReasonNode);
|
|
|
+ } else {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // Now set the selection to the new range
|
|
|
+ aSelection.Collapse(selStartNode, selStartOffset);
|
|
|
+
|
|
|
+@@ -6789,17 +6789,17 @@ HTMLEditRules::ReturnInHeader(Selection&
|
|
|
+ nsINode& aNode,
|
|
|
+ int32_t aOffset)
|
|
|
+ {
|
|
|
+ NS_ENSURE_STATE(mHTMLEditor);
|
|
|
+ RefPtr<HTMLEditor> htmlEditor(mHTMLEditor);
|
|
|
+
|
|
|
+ // Remember where the header is
|
|
|
+ nsCOMPtr<nsINode> headerParent = aHeader.GetParentNode();
|
|
|
+- int32_t offset = headerParent ? headerParent->IndexOf(&aHeader) : -1;
|
|
|
++ int32_t offset = headerParent ? headerParent->ComputeIndexOf(&aHeader) : -1;
|
|
|
+
|
|
|
+ // Get ws code to adjust any ws
|
|
|
+ nsCOMPtr<nsINode> node = &aNode;
|
|
|
+ nsresult rv = WSRunObject::PrepareToSplitAcrossBlocks(htmlEditor,
|
|
|
+ address_of(node),
|
|
|
+ &aOffset);
|
|
|
+ NS_ENSURE_SUCCESS(rv, rv);
|
|
|
+ if (NS_WARN_IF(!node->IsContent())) {
|
|
|
+@@ -7269,17 +7269,17 @@ HTMLEditRules::ReturnInListItem(Selectio
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ rv = htmlEditor->IsEmptyNode(&aListItem, &isEmptyNode, true);
|
|
|
+ NS_ENSURE_SUCCESS(rv, rv);
|
|
|
+ if (isEmptyNode) {
|
|
|
+ nsCOMPtr<nsIAtom> nodeAtom = aListItem.NodeInfo()->NameAtom();
|
|
|
+ if (nodeAtom == nsGkAtoms::dd || nodeAtom == nsGkAtoms::dt) {
|
|
|
+ nsCOMPtr<nsINode> list = aListItem.GetParentNode();
|
|
|
+- int32_t itemOffset = list ? list->IndexOf(&aListItem) : -1;
|
|
|
++ int32_t itemOffset = list ? list->ComputeIndexOf(&aListItem) : -1;
|
|
|
+
|
|
|
+ nsIAtom* listAtom = nodeAtom == nsGkAtoms::dt ? nsGkAtoms::dd
|
|
|
+ : nsGkAtoms::dt;
|
|
|
+ MOZ_DIAGNOSTIC_ASSERT(itemOffset != -1);
|
|
|
+ EditorRawDOMPoint atNextListItem(list, aListItem.GetNextSibling(),
|
|
|
+ itemOffset + 1);
|
|
|
+ RefPtr<Element> newListItem =
|
|
|
+ htmlEditor->CreateNode(listAtom, atNextListItem);
|
|
|
+@@ -7731,17 +7731,17 @@ EditorDOMPoint
|
|
|
+ HTMLEditRules::JoinNodesSmart(nsIContent& aNodeLeft,
|
|
|
+ nsIContent& aNodeRight)
|
|
|
+ {
|
|
|
+ // Caller responsible for left and right node being the same type
|
|
|
+ nsCOMPtr<nsINode> parent = aNodeLeft.GetParentNode();
|
|
|
+ if (NS_WARN_IF(!parent)) {
|
|
|
+ return EditorDOMPoint();
|
|
|
+ }
|
|
|
+- int32_t parOffset = parent->IndexOf(&aNodeLeft);
|
|
|
++ int32_t parOffset = parent->ComputeIndexOf(&aNodeLeft);
|
|
|
+ nsCOMPtr<nsINode> rightParent = aNodeRight.GetParentNode();
|
|
|
+
|
|
|
+ // If they don't have the same parent, first move the right node to after the
|
|
|
+ // left one
|
|
|
+ if (parent != rightParent) {
|
|
|
+ if (NS_WARN_IF(!mHTMLEditor)) {
|
|
|
+ return EditorDOMPoint();
|
|
|
+ }
|
|
|
+diff --git a/editor/libeditor/HTMLEditor.cpp b/editor/libeditor/HTMLEditor.cpp
|
|
|
+--- a/editor/libeditor/HTMLEditor.cpp
|
|
|
++++ b/editor/libeditor/HTMLEditor.cpp
|
|
|
+@@ -541,42 +541,42 @@ HTMLEditor::BeginningOfDocument()
|
|
|
+ wsObj.NextVisibleNode(curNode, curOffset, address_of(visNode), &visOffset,
|
|
|
+ &visType);
|
|
|
+ if (visType == WSType::normalWS || visType == WSType::text) {
|
|
|
+ selNode = visNode;
|
|
|
+ selOffset = visOffset;
|
|
|
+ done = true;
|
|
|
+ } else if (visType == WSType::br || visType == WSType::special) {
|
|
|
+ selNode = visNode->GetParentNode();
|
|
|
+- selOffset = selNode ? selNode->IndexOf(visNode) : -1;
|
|
|
++ selOffset = selNode ? selNode->ComputeIndexOf(visNode) : -1;
|
|
|
+ done = true;
|
|
|
+ } else if (visType == WSType::otherBlock) {
|
|
|
+ // By definition of WSRunObject, a block element terminates a
|
|
|
+ // whitespace run. That is, although we are calling a method that is
|
|
|
+ // named "NextVisibleNode", the node returned might not be
|
|
|
+ // visible/editable!
|
|
|
+ //
|
|
|
+ // If the given block does not contain any visible/editable items, we
|
|
|
+ // want to skip it and continue our search.
|
|
|
+
|
|
|
+ if (!IsContainer(visNode)) {
|
|
|
+ // However, we were given a block that is not a container. Since the
|
|
|
+ // block can not contain anything that's visible, such a block only
|
|
|
+ // makes sense if it is visible by itself, like a <hr>. We want to
|
|
|
+ // place the caret in front of that block.
|
|
|
+ selNode = visNode->GetParentNode();
|
|
|
+- selOffset = selNode ? selNode->IndexOf(visNode) : -1;
|
|
|
++ selOffset = selNode ? selNode->ComputeIndexOf(visNode) : -1;
|
|
|
+ done = true;
|
|
|
+ } else {
|
|
|
+ bool isEmptyBlock;
|
|
|
+ if (NS_SUCCEEDED(IsEmptyNode(visNode, &isEmptyBlock)) &&
|
|
|
+ isEmptyBlock) {
|
|
|
+ // Skip the empty block
|
|
|
+ curNode = visNode->GetParentNode();
|
|
|
+- curOffset = curNode ? curNode->IndexOf(visNode) : -1;
|
|
|
++ curOffset = curNode ? curNode->ComputeIndexOf(visNode) : -1;
|
|
|
+ curOffset++;
|
|
|
+ } else {
|
|
|
+ curNode = visNode;
|
|
|
+ curOffset = 0;
|
|
|
+ }
|
|
|
+ // Keep looping
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+@@ -1606,17 +1606,17 @@ HTMLEditor::SelectElement(nsIDOMElement*
|
|
|
+
|
|
|
+ RefPtr<Selection> selection = GetSelection();
|
|
|
+ NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
|
|
|
+ nsINode* parent = element->GetParentNode();
|
|
|
+ if (NS_WARN_IF(!parent)) {
|
|
|
+ return NS_ERROR_FAILURE;
|
|
|
+ }
|
|
|
+
|
|
|
+- int32_t offsetInParent = parent->IndexOf(element);
|
|
|
++ int32_t offsetInParent = parent->ComputeIndexOf(element);
|
|
|
+
|
|
|
+ // Collapse selection to just before desired element,
|
|
|
+ nsresult rv = selection->Collapse(parent, offsetInParent);
|
|
|
+ if (NS_SUCCEEDED(rv)) {
|
|
|
+ // then extend it to just after
|
|
|
+ rv = selection->Extend(parent, offsetInParent + 1);
|
|
|
+ }
|
|
|
+ return rv;
|
|
|
+diff --git a/editor/libeditor/HTMLStyleEditor.cpp b/editor/libeditor/HTMLStyleEditor.cpp
|
|
|
+--- a/editor/libeditor/HTMLStyleEditor.cpp
|
|
|
++++ b/editor/libeditor/HTMLStyleEditor.cpp
|
|
|
+@@ -842,29 +842,29 @@ HTMLEditor::PromoteRangeIfStartsOrEndsIn
|
|
|
+ while (parent && !parent->IsHTMLElement(nsGkAtoms::body) &&
|
|
|
+ !HTMLEditUtils::IsNamedAnchor(parent)) {
|
|
|
+ parent = parent->GetParentNode();
|
|
|
+ }
|
|
|
+ NS_ENSURE_TRUE(parent, NS_ERROR_NULL_POINTER);
|
|
|
+
|
|
|
+ if (HTMLEditUtils::IsNamedAnchor(parent)) {
|
|
|
+ startNode = parent->GetParentNode();
|
|
|
+- startOffset = startNode ? startNode->IndexOf(parent) : -1;
|
|
|
++ startOffset = startNode ? startNode->ComputeIndexOf(parent) : -1;
|
|
|
+ }
|
|
|
+
|
|
|
+ parent = endNode;
|
|
|
+ while (parent && !parent->IsHTMLElement(nsGkAtoms::body) &&
|
|
|
+ !HTMLEditUtils::IsNamedAnchor(parent)) {
|
|
|
+ parent = parent->GetParentNode();
|
|
|
+ }
|
|
|
+ NS_ENSURE_TRUE(parent, NS_ERROR_NULL_POINTER);
|
|
|
+
|
|
|
+ if (HTMLEditUtils::IsNamedAnchor(parent)) {
|
|
|
+ endNode = parent->GetParentNode();
|
|
|
+- endOffset = endNode ? endNode->IndexOf(parent) + 1 : 0;
|
|
|
++ endOffset = endNode ? endNode->ComputeIndexOf(parent) + 1 : 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ nsresult rv = aRange.SetStartAndEnd(startNode, startOffset,
|
|
|
+ endNode, endOffset);
|
|
|
+ if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
+ return rv;
|
|
|
+ }
|
|
|
+
|
|
|
+@@ -878,26 +878,26 @@ HTMLEditor::PromoteInlineRange(nsRange&
|
|
|
+ int32_t startOffset = aRange.StartOffset();
|
|
|
+ nsCOMPtr<nsINode> endNode = aRange.GetEndContainer();
|
|
|
+ int32_t endOffset = aRange.EndOffset();
|
|
|
+
|
|
|
+ while (startNode && !startNode->IsHTMLElement(nsGkAtoms::body) &&
|
|
|
+ IsEditable(startNode) && IsAtFrontOfNode(*startNode, startOffset)) {
|
|
|
+ nsCOMPtr<nsINode> parent = startNode->GetParentNode();
|
|
|
+ NS_ENSURE_TRUE(parent, NS_ERROR_NULL_POINTER);
|
|
|
+- startOffset = parent->IndexOf(startNode);
|
|
|
++ startOffset = parent->ComputeIndexOf(startNode);
|
|
|
+ startNode = parent;
|
|
|
+ }
|
|
|
+
|
|
|
+ while (endNode && !endNode->IsHTMLElement(nsGkAtoms::body) &&
|
|
|
+ IsEditable(endNode) && IsAtEndOfNode(*endNode, endOffset)) {
|
|
|
+ nsCOMPtr<nsINode> parent = endNode->GetParentNode();
|
|
|
+ NS_ENSURE_TRUE(parent, NS_ERROR_NULL_POINTER);
|
|
|
+ // We are AFTER this node
|
|
|
+- endOffset = 1 + parent->IndexOf(endNode);
|
|
|
++ endOffset = 1 + parent->ComputeIndexOf(endNode);
|
|
|
+ endNode = parent;
|
|
|
+ }
|
|
|
+
|
|
|
+ nsresult rv = aRange.SetStartAndEnd(startNode, startOffset,
|
|
|
+ endNode, endOffset);
|
|
|
+ if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
+ return rv;
|
|
|
+ }
|
|
|
+@@ -914,17 +914,17 @@ HTMLEditor::IsAtFrontOfNode(nsINode& aNo
|
|
|
+ }
|
|
|
+
|
|
|
+ if (IsTextNode(&aNode)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ nsCOMPtr<nsIContent> firstNode = GetFirstEditableChild(aNode);
|
|
|
+ NS_ENSURE_TRUE(firstNode, true);
|
|
|
+- if (aNode.IndexOf(firstNode) < aOffset) {
|
|
|
++ if (aNode.ComputeIndexOf(firstNode) < aOffset) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ bool
|
|
|
+ HTMLEditor::IsAtEndOfNode(nsINode& aNode,
|
|
|
+ int32_t aOffset)
|
|
|
+@@ -934,17 +934,17 @@ HTMLEditor::IsAtEndOfNode(nsINode& aNode
|
|
|
+ }
|
|
|
+
|
|
|
+ if (IsTextNode(&aNode)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ nsCOMPtr<nsIContent> lastNode = GetLastEditableChild(aNode);
|
|
|
+ NS_ENSURE_TRUE(lastNode, true);
|
|
|
+- if (aNode.IndexOf(lastNode) < aOffset) {
|
|
|
++ if (aNode.ComputeIndexOf(lastNode) < aOffset) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ nsresult
|
|
|
+ HTMLEditor::GetInlinePropertyBase(nsIAtom& aProperty,
|
|
|
+diff --git a/editor/libeditor/HTMLTableEditor.cpp b/editor/libeditor/HTMLTableEditor.cpp
|
|
|
+--- a/editor/libeditor/HTMLTableEditor.cpp
|
|
|
++++ b/editor/libeditor/HTMLTableEditor.cpp
|
|
|
+@@ -667,17 +667,17 @@ HTMLEditor::InsertTableRow(int32_t aNumb
|
|
|
+
|
|
|
+ nsCOMPtr<Element> parentRow =
|
|
|
+ GetElementOrParentByTagName(trStr, cellNodeForRowParent);
|
|
|
+ NS_ENSURE_TRUE(parentRow, NS_ERROR_NULL_POINTER);
|
|
|
+
|
|
|
+ // The row parent and offset where we will insert new row
|
|
|
+ nsCOMPtr<nsINode> parentOfRow = parentRow->GetParentNode();
|
|
|
+ NS_ENSURE_TRUE(parentOfRow, NS_ERROR_NULL_POINTER);
|
|
|
+- int32_t newRowOffset = parentOfRow->IndexOf(parentRow);
|
|
|
++ int32_t newRowOffset = parentOfRow->ComputeIndexOf(parentRow);
|
|
|
+
|
|
|
+ // Adjust for when adding past the end
|
|
|
+ if (aAfter && startRowIndex >= rowCount) {
|
|
|
+ newRowOffset++;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int32_t row = 0; row < aNumber; row++) {
|
|
|
+ // Create a new row
|
|
|
+diff --git a/editor/libeditor/SelectionState.cpp b/editor/libeditor/SelectionState.cpp
|
|
|
+--- a/editor/libeditor/SelectionState.cpp
|
|
|
++++ b/editor/libeditor/SelectionState.cpp
|
|
|
+@@ -259,17 +259,17 @@ RangeUpdater::SelAdjDeleteNode(nsINode*
|
|
|
+ }
|
|
|
+ MOZ_ASSERT(aNode);
|
|
|
+ size_t count = mArray.Length();
|
|
|
+ if (!count) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ nsCOMPtr<nsINode> parent = aNode->GetParentNode();
|
|
|
+- int32_t offset = parent ? parent->IndexOf(aNode) : -1;
|
|
|
++ int32_t offset = parent ? parent->ComputeIndexOf(aNode) : -1;
|
|
|
+
|
|
|
+ // check for range endpoints that are after aNode and in the same parent
|
|
|
+ for (size_t i = 0; i < count; i++) {
|
|
|
+ RangeItem* item = mArray[i];
|
|
|
+ MOZ_ASSERT(item);
|
|
|
+
|
|
|
+ if (item->mStartContainer == parent && item->mStartOffset > offset) {
|
|
|
+ item->mStartOffset--;
|
|
|
+diff --git a/editor/libeditor/WSRunObject.cpp b/editor/libeditor/WSRunObject.cpp
|
|
|
+--- a/editor/libeditor/WSRunObject.cpp
|
|
|
++++ b/editor/libeditor/WSRunObject.cpp
|
|
|
+@@ -138,17 +138,17 @@ WSRunObject::PrepareToDeleteRange(HTMLEd
|
|
|
+ nsresult
|
|
|
+ WSRunObject::PrepareToDeleteNode(HTMLEditor* aHTMLEditor,
|
|
|
+ nsIContent* aContent)
|
|
|
+ {
|
|
|
+ NS_ENSURE_TRUE(aContent && aHTMLEditor, NS_ERROR_NULL_POINTER);
|
|
|
+
|
|
|
+ nsCOMPtr<nsINode> parent = aContent->GetParentNode();
|
|
|
+ NS_ENSURE_STATE(parent);
|
|
|
+- int32_t offset = parent->IndexOf(aContent);
|
|
|
++ int32_t offset = parent->ComputeIndexOf(aContent);
|
|
|
+
|
|
|
+ WSRunObject leftWSObj(aHTMLEditor, parent, offset);
|
|
|
+ WSRunObject rightWSObj(aHTMLEditor, parent, offset + 1);
|
|
|
+
|
|
|
+ return leftWSObj.PrepareToDeleteRangePriv(&rightWSObj);
|
|
|
+ }
|
|
|
+
|
|
|
+ nsresult
|
|
|
+diff --git a/editor/txtsvc/nsFilteredContentIterator.cpp b/editor/txtsvc/nsFilteredContentIterator.cpp
|
|
|
+--- a/editor/txtsvc/nsFilteredContentIterator.cpp
|
|
|
++++ b/editor/txtsvc/nsFilteredContentIterator.cpp
|
|
|
+@@ -245,17 +245,17 @@ ContentToParentOffset(nsIContent* aConte
|
|
|
+
|
|
|
+ if (!aContent)
|
|
|
+ return;
|
|
|
+
|
|
|
+ nsCOMPtr<nsIContent> parent = aContent->GetParent();
|
|
|
+ if (!parent)
|
|
|
+ return;
|
|
|
+
|
|
|
+- *aOffset = parent->IndexOf(aContent);
|
|
|
++ *aOffset = parent->ComputeIndexOf(aContent);
|
|
|
+ parent.forget(aParent);
|
|
|
+ }
|
|
|
+
|
|
|
+ ///////////////////////////////////////////////////////////////////////////
|
|
|
+ // ContentIsInTraversalRange: returns true if content is visited during
|
|
|
+ // the traversal of the range in the specified mode.
|
|
|
+ //
|
|
|
+ static bool
|
|
|
+diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp
|
|
|
+--- a/layout/base/nsLayoutUtils.cpp
|
|
|
++++ b/layout/base/nsLayoutUtils.cpp
|
|
|
+@@ -1869,18 +1869,18 @@ nsLayoutUtils::DoCompareTreePosition(nsI
|
|
|
+ // TODO: remove the uglyness, see bug 598468.
|
|
|
+ NS_ASSERTION(gPreventAssertInCompareTreePosition || parent,
|
|
|
+ "no common ancestor at all???");
|
|
|
+ #endif // DEBUG
|
|
|
+ if (!parent) { // different documents??
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+- int32_t index1 = parent->IndexOf(content1Ancestor);
|
|
|
+- int32_t index2 = parent->IndexOf(content2Ancestor);
|
|
|
++ int32_t index1 = parent->ComputeIndexOf(content1Ancestor);
|
|
|
++ int32_t index2 = parent->ComputeIndexOf(content2Ancestor);
|
|
|
+ if (index1 < 0 || index2 < 0) {
|
|
|
+ // one of them must be anonymous; we can't determine the order
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ return index1 - index2;
|
|
|
+ }
|
|
|
+
|
|
|
+diff --git a/layout/generic/BRFrame.cpp b/layout/generic/BRFrame.cpp
|
|
|
+--- a/layout/generic/BRFrame.cpp
|
|
|
++++ b/layout/generic/BRFrame.cpp
|
|
|
+@@ -217,17 +217,17 @@ BRFrame::GetLogicalBaseline(mozilla::Wri
|
|
|
+ return mAscent;
|
|
|
+ }
|
|
|
+
|
|
|
+ nsIFrame::ContentOffsets BRFrame::CalcContentOffsetsFromFramePoint(const nsPoint& aPoint)
|
|
|
+ {
|
|
|
+ ContentOffsets offsets;
|
|
|
+ offsets.content = mContent->GetParent();
|
|
|
+ if (offsets.content) {
|
|
|
+- offsets.offset = offsets.content->IndexOf(mContent);
|
|
|
++ offsets.offset = offsets.content->ComputeIndexOf(mContent);
|
|
|
+ offsets.secondaryOffset = offsets.offset;
|
|
|
+ offsets.associate = CARET_ASSOCIATE_AFTER;
|
|
|
+ }
|
|
|
+ return offsets;
|
|
|
+ }
|
|
|
+
|
|
|
+ nsIFrame::FrameSearchResult
|
|
|
+ BRFrame::PeekOffsetNoAmount(bool aForward, int32_t* aOffset)
|
|
|
+diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp
|
|
|
+--- a/layout/generic/nsFrame.cpp
|
|
|
++++ b/layout/generic/nsFrame.cpp
|
|
|
+@@ -2291,17 +2291,17 @@ nsFrame::DisplaySelectionOverlay(nsDispl
|
|
|
+ return; // selection is hidden or off
|
|
|
+
|
|
|
+ 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->IndexOf(mContent);
|
|
|
++ offset = newContent->ComputeIndexOf(mContent);
|
|
|
+ }
|
|
|
+
|
|
|
+ //look up to see what selection(s) are on this frame
|
|
|
+ UniquePtr<SelectionDetails> details
|
|
|
+ = frameSelection->LookUpSelection(newContent, offset, 1, false);
|
|
|
+ if (!details)
|
|
|
+ return;
|
|
|
+
|
|
|
+@@ -4024,17 +4024,17 @@ nsFrame::GetDataForTableSelection(const
|
|
|
+ if (!foundCell && !foundTable) return NS_OK;
|
|
|
+
|
|
|
+ nsIContent* tableOrCellContent = frame->GetContent();
|
|
|
+ if (!tableOrCellContent) return NS_ERROR_FAILURE;
|
|
|
+
|
|
|
+ nsCOMPtr<nsIContent> parentContent = tableOrCellContent->GetParent();
|
|
|
+ if (!parentContent) return NS_ERROR_FAILURE;
|
|
|
+
|
|
|
+- int32_t offset = parentContent->IndexOf(tableOrCellContent);
|
|
|
++ int32_t offset = parentContent->ComputeIndexOf(tableOrCellContent);
|
|
|
+ // Not likely?
|
|
|
+ if (offset < 0) return NS_ERROR_FAILURE;
|
|
|
+
|
|
|
+ // Everything is OK -- set the return values
|
|
|
+ parentContent.forget(aParentContent);
|
|
|
+
|
|
|
+ *aContentOffset = offset;
|
|
|
+
|
|
|
+@@ -4759,25 +4759,25 @@ static FrameContentRange GetRangeForFram
|
|
|
+ LayoutFrameType type = aFrame->Type();
|
|
|
+ if (type == LayoutFrameType::Text) {
|
|
|
+ int32_t offset, offsetEnd;
|
|
|
+ aFrame->GetOffsets(offset, offsetEnd);
|
|
|
+ return FrameContentRange(content, offset, offsetEnd);
|
|
|
+ }
|
|
|
+ if (type == LayoutFrameType::Br) {
|
|
|
+ parent = content->GetParent();
|
|
|
+- int32_t beginOffset = parent->IndexOf(content);
|
|
|
++ int32_t beginOffset = parent->ComputeIndexOf(content);
|
|
|
+ return FrameContentRange(parent, beginOffset, beginOffset);
|
|
|
+ }
|
|
|
+ // Loop to deal with anonymous content, which has no index; this loop
|
|
|
+ // probably won't run more than twice under normal conditions
|
|
|
+ do {
|
|
|
+ parent = content->GetParent();
|
|
|
+ if (parent) {
|
|
|
+- int32_t beginOffset = parent->IndexOf(content);
|
|
|
++ int32_t beginOffset = parent->ComputeIndexOf(content);
|
|
|
+ if (beginOffset >= 0)
|
|
|
+ return FrameContentRange(parent, beginOffset, beginOffset + 1);
|
|
|
+ content = parent;
|
|
|
+ }
|
|
|
+ } while (parent);
|
|
|
+
|
|
|
+ // The root content node must act differently
|
|
|
+ return FrameContentRange(content, 0, content->GetChildCount());
|
|
|
+@@ -7676,17 +7676,17 @@ nsIFrame::GetContainingBlock(uint32_t aF
|
|
|
+ int32_t nsFrame::ContentIndexInContainer(const nsIFrame* aFrame)
|
|
|
+ {
|
|
|
+ int32_t result = -1;
|
|
|
+
|
|
|
+ nsIContent* content = aFrame->GetContent();
|
|
|
+ if (content) {
|
|
|
+ nsIContent* parentContent = content->GetParent();
|
|
|
+ if (parentContent) {
|
|
|
+- result = parentContent->IndexOf(content);
|
|
|
++ result = parentContent->ComputeIndexOf(content);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * List a frame tree to stderr. Meant to be called from gdb.
|
|
|
+@@ -8022,17 +8022,17 @@ nsFrame::GetPointFromOffset(int32_t inOf
|
|
|
+ {
|
|
|
+ NS_PRECONDITION(outPoint != nullptr, "Null parameter");
|
|
|
+ nsRect contentRect = GetContentRectRelativeToSelf();
|
|
|
+ nsPoint pt = contentRect.TopLeft();
|
|
|
+ if (mContent)
|
|
|
+ {
|
|
|
+ nsIContent* newContent = mContent->GetParent();
|
|
|
+ if (newContent){
|
|
|
+- int32_t newOffset = newContent->IndexOf(mContent);
|
|
|
++ int32_t newOffset = newContent->ComputeIndexOf(mContent);
|
|
|
+
|
|
|
+ // Find the direction of the frame from the EmbeddingLevelProperty,
|
|
|
+ // which is the resolved bidi level set in
|
|
|
+ // nsBidiPresUtils::ResolveParagraph (odd levels = right-to-left).
|
|
|
+ // If the embedding level isn't set, just use the CSS direction
|
|
|
+ // property.
|
|
|
+ bool hasBidiData;
|
|
|
+ FrameBidiData bidiData = GetProperty(BidiDataProperty(), &hasBidiData);
|
|
|
+@@ -8231,17 +8231,17 @@ nsFrame::GetNextPrevLineFromeBlockFrame(
|
|
|
+ {
|
|
|
+ nsIContent* content = resultFrame->GetContent();
|
|
|
+ if (content)
|
|
|
+ {
|
|
|
+ nsIContent* parent = content->GetParent();
|
|
|
+ if (parent)
|
|
|
+ {
|
|
|
+ aPos->mResultContent = parent;
|
|
|
+- aPos->mContentOffset = parent->IndexOf(content);
|
|
|
++ aPos->mContentOffset = parent->ComputeIndexOf(content);
|
|
|
+ aPos->mAttach = CARET_ASSOCIATE_BEFORE;
|
|
|
+ if ((point.x - offset.x+ tempRect.x)>tempRect.width)
|
|
|
+ {
|
|
|
+ aPos->mContentOffset++;//go to end of this frame
|
|
|
+ aPos->mAttach = CARET_ASSOCIATE_AFTER;
|
|
|
+ }
|
|
|
+ //result frame is the result frames parent.
|
|
|
+ aPos->mResultFrame = resultFrame->GetParent();
|
|
|
+@@ -8382,17 +8382,17 @@ FindBlockFrameOrBR(nsIFrame* aFrame, nsD
|
|
|
+ aFrame->IsBrFrame()) {
|
|
|
+ nsIContent* content = aFrame->GetContent();
|
|
|
+ result.mContent = content->GetParent();
|
|
|
+ // In some cases (bug 310589, bug 370174) we end up here with a null 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->IndexOf(content) +
|
|
|
++ result.mOffset = result.mContent->ComputeIndexOf(content) +
|
|
|
+ (aDirection == eDirPrevious ? 1 : 0);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ // If this is a preformatted text frame, see if it ends with a newline
|
|
|
+ if (aFrame->HasSignificantTerminalNewline()) {
|
|
|
+ int32_t startOffset, endOffset;
|
|
|
+ aFrame->GetOffsets(startOffset, endOffset);
|
|
|
+diff --git a/layout/generic/nsFrameSelection.cpp b/layout/generic/nsFrameSelection.cpp
|
|
|
+--- a/layout/generic/nsFrameSelection.cpp
|
|
|
++++ b/layout/generic/nsFrameSelection.cpp
|
|
|
+@@ -619,17 +619,17 @@ nsINode*
|
|
|
+ ParentOffset(nsINode *aNode, int32_t *aChildOffset)
|
|
|
+ {
|
|
|
+ if (!aNode || !aChildOffset)
|
|
|
+ return nullptr;
|
|
|
+
|
|
|
+ nsIContent* parent = aNode->GetParent();
|
|
|
+ if (parent)
|
|
|
+ {
|
|
|
+- *aChildOffset = parent->IndexOf(aNode);
|
|
|
++ *aChildOffset = parent->ComputeIndexOf(aNode);
|
|
|
+
|
|
|
+ return parent;
|
|
|
+ }
|
|
|
+
|
|
|
+ return nullptr;
|
|
|
+ }
|
|
|
+
|
|
|
+ static nsINode*
|
|
|
+@@ -2860,17 +2860,17 @@ nsFrameSelection::GetParentTable(nsICont
|
|
|
+ }
|
|
|
+
|
|
|
+ nsresult
|
|
|
+ nsFrameSelection::SelectCellElement(nsIContent *aCellElement)
|
|
|
+ {
|
|
|
+ nsIContent *parent = aCellElement->GetParent();
|
|
|
+
|
|
|
+ // Get child offset
|
|
|
+- int32_t offset = parent->IndexOf(aCellElement);
|
|
|
++ int32_t offset = parent->ComputeIndexOf(aCellElement);
|
|
|
+
|
|
|
+ return CreateAndAddRange(parent, offset);
|
|
|
+ }
|
|
|
+
|
|
|
+ nsresult
|
|
|
+ nsFrameSelection::CreateAndAddRange(nsINode* aContainer, int32_t aOffset)
|
|
|
+ {
|
|
|
+ if (!aContainer) {
|
|
|
+diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp
|
|
|
+--- a/layout/generic/nsImageFrame.cpp
|
|
|
++++ b/layout/generic/nsImageFrame.cpp
|
|
|
+@@ -1938,17 +1938,17 @@ nsImageFrame::ShouldDisplaySelection()
|
|
|
+ {
|
|
|
+ int32_t rangeCount;
|
|
|
+ selection->GetRangeCount(&rangeCount);
|
|
|
+ if (rangeCount == 1) //if not one then let code drop to nsFrame::Paint
|
|
|
+ {
|
|
|
+ nsCOMPtr<nsIContent> parentContent = mContent->GetParent();
|
|
|
+ if (parentContent)
|
|
|
+ {
|
|
|
+- int32_t thisOffset = parentContent->IndexOf(mContent);
|
|
|
++ int32_t thisOffset = parentContent->ComputeIndexOf(mContent);
|
|
|
+ nsCOMPtr<nsIDOMNode> parentNode = do_QueryInterface(parentContent);
|
|
|
+ nsCOMPtr<nsIDOMNode> rangeNode;
|
|
|
+ uint32_t rangeOffset;
|
|
|
+ nsCOMPtr<nsIDOMRange> range;
|
|
|
+ selection->GetRangeAt(0,getter_AddRefs(range));
|
|
|
+ if (range)
|
|
|
+ {
|
|
|
+ range->GetStartContainer(getter_AddRefs(rangeNode));
|
|
|
+diff --git a/layout/printing/nsPrintJob.cpp b/layout/printing/nsPrintJob.cpp
|
|
|
+--- a/layout/printing/nsPrintJob.cpp
|
|
|
++++ b/layout/printing/nsPrintJob.cpp
|
|
|
+@@ -2526,17 +2526,17 @@ GetCorrespondingNodeInDocument(const nsI
|
|
|
+ // Selections in anonymous subtrees aren't supported.
|
|
|
+ if (aNode->IsInAnonymousSubtree()) {
|
|
|
+ return nullptr;
|
|
|
+ }
|
|
|
+
|
|
|
+ nsTArray<int32_t> indexArray;
|
|
|
+ const nsINode* child = aNode;
|
|
|
+ while (const nsINode* parent = child->GetParentNode()) {
|
|
|
+- int32_t index = parent->IndexOf(child);
|
|
|
++ int32_t index = parent->ComputeIndexOf(child);
|
|
|
+ MOZ_ASSERT(index >= 0);
|
|
|
+ indexArray.AppendElement(index);
|
|
|
+ child = parent;
|
|
|
+ }
|
|
|
+ MOZ_ASSERT(child->IsNodeOfType(nsINode::eDOCUMENT));
|
|
|
+
|
|
|
+ nsINode* correspondingNode = aDoc;
|
|
|
+ for (int32_t i = indexArray.Length() - 1; i >= 0; --i) {
|
|
|
+diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp
|
|
|
+--- a/layout/tables/nsTableFrame.cpp
|
|
|
++++ b/layout/tables/nsTableFrame.cpp
|
|
|
+@@ -2660,17 +2660,17 @@ nsTableFrame::HomogenousInsertFrames(Chi
|
|
|
+ nsIContent* content = nullptr;
|
|
|
+ aPrevFrame = nullptr;
|
|
|
+ while (pseudoFrame && (parentContent ==
|
|
|
+ (content = pseudoFrame->GetContent()))) {
|
|
|
+ pseudoFrame = pseudoFrame->PrincipalChildList().FirstChild();
|
|
|
+ }
|
|
|
+ nsCOMPtr<nsIContent> container = content->GetParent();
|
|
|
+ if (MOZ_LIKELY(container)) { // XXX need this null-check, see bug 411823.
|
|
|
+- int32_t newIndex = container->IndexOf(content);
|
|
|
++ int32_t newIndex = container->ComputeIndexOf(content);
|
|
|
+ nsIFrame* kidFrame;
|
|
|
+ nsTableColGroupFrame* lastColGroup = nullptr;
|
|
|
+ if (isColGroup) {
|
|
|
+ kidFrame = mColGroups.FirstChild();
|
|
|
+ lastColGroup = nsTableColGroupFrame::GetLastRealColGroup(this);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ kidFrame = mFrames.FirstChild();
|
|
|
+@@ -2684,17 +2684,17 @@ nsTableFrame::HomogenousInsertFrames(Chi
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ pseudoFrame = kidFrame;
|
|
|
+ while (pseudoFrame && (parentContent ==
|
|
|
+ (content = pseudoFrame->GetContent()))) {
|
|
|
+ pseudoFrame = pseudoFrame->PrincipalChildList().FirstChild();
|
|
|
+ }
|
|
|
+- int32_t index = container->IndexOf(content);
|
|
|
++ int32_t index = container->ComputeIndexOf(content);
|
|
|
+ if (index > lastIndex && index < newIndex) {
|
|
|
+ lastIndex = index;
|
|
|
+ aPrevFrame = kidFrame;
|
|
|
+ }
|
|
|
+ kidFrame = kidFrame->GetNextSibling();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+diff --git a/layout/xul/nsListBoxBodyFrame.cpp b/layout/xul/nsListBoxBodyFrame.cpp
|
|
|
+--- a/layout/xul/nsListBoxBodyFrame.cpp
|
|
|
++++ b/layout/xul/nsListBoxBodyFrame.cpp
|
|
|
+@@ -1151,17 +1151,17 @@ nsListBoxBodyFrame::GetFirstItemBox(int3
|
|
|
+ // to be created at the top. Let's determine which
|
|
|
+ // content needs a new frame first.
|
|
|
+
|
|
|
+ nsCOMPtr<nsIContent> startContent;
|
|
|
+ if (mTopFrame && mRowsToPrepend > 0) {
|
|
|
+ // We need to insert rows before the top frame
|
|
|
+ nsIContent* topContent = mTopFrame->GetContent();
|
|
|
+ nsIContent* topParent = topContent->GetParent();
|
|
|
+- int32_t contentIndex = topParent->IndexOf(topContent);
|
|
|
++ int32_t contentIndex = topParent->ComputeIndexOf(topContent);
|
|
|
+ contentIndex -= aOffset;
|
|
|
+ if (contentIndex < 0)
|
|
|
+ return nullptr;
|
|
|
+ startContent = topParent->GetChildAt_Deprecated(contentIndex - mRowsToPrepend);
|
|
|
+ } else {
|
|
|
+ // This will be the first item frame we create. Use the content
|
|
|
+ // at the current index, which is the first index scrolled into view
|
|
|
+ GetListItemContentAt(mCurrentIndex+aOffset, getter_AddRefs(startContent));
|
|
|
+@@ -1212,17 +1212,17 @@ nsListBoxBodyFrame::GetNextItemBox(nsIFr
|
|
|
+
|
|
|
+ nsIFrame* result = aBox->GetNextSibling();
|
|
|
+
|
|
|
+ if (!result || result == mLinkupFrame || mRowsToPrepend > 0) {
|
|
|
+ // No result found. See if there's a content node that wants a frame.
|
|
|
+ nsIContent* prevContent = aBox->GetContent();
|
|
|
+ nsIContent* parentContent = prevContent->GetParent();
|
|
|
+
|
|
|
+- int32_t i = parentContent->IndexOf(prevContent);
|
|
|
++ int32_t i = parentContent->ComputeIndexOf(prevContent);
|
|
|
+
|
|
|
+ uint32_t childCount = parentContent->GetChildCount();
|
|
|
+ if (((uint32_t)i + aOffset + 1) < childCount) {
|
|
|
+ // There is a content node that wants a frame.
|
|
|
+ nsIContent *nextContent = parentContent->GetChildAt_Deprecated(i + aOffset + 1);
|
|
|
+
|
|
|
+ nsIFrame* existingFrame;
|
|
|
+ if (!IsListItemChild(this, nextContent, &existingFrame)) {
|
|
|
+diff --git a/parser/html/nsHtml5TreeOperation.cpp b/parser/html/nsHtml5TreeOperation.cpp
|
|
|
+--- a/parser/html/nsHtml5TreeOperation.cpp
|
|
|
++++ b/parser/html/nsHtml5TreeOperation.cpp
|
|
|
+@@ -280,17 +280,17 @@ nsHtml5TreeOperation::FosterParent(nsICo
|
|
|
+ MOZ_ASSERT(aBuilder->IsInDocUpdate());
|
|
|
+ nsIContent* foster = aTable->GetParent();
|
|
|
+
|
|
|
+ if (IsElementOrTemplateContent(foster)) {
|
|
|
+
|
|
|
+ nsHtml5OtherDocUpdate update(foster->OwnerDoc(),
|
|
|
+ aBuilder->GetDocument());
|
|
|
+
|
|
|
+- uint32_t pos = foster->IndexOf(aTable);
|
|
|
++ uint32_t pos = foster->ComputeIndexOf(aTable);
|
|
|
+ nsresult rv = foster->InsertChildAt(aNode, pos, false);
|
|
|
+ NS_ENSURE_SUCCESS(rv, rv);
|
|
|
+ nsNodeUtils::ContentInserted(foster, aNode);
|
|
|
+ return rv;
|
|
|
+ }
|
|
|
+
|
|
|
+ return Append(aNode, aParent, aBuilder);
|
|
|
+ }
|
|
|
+@@ -675,17 +675,17 @@ nsHtml5TreeOperation::FosterParentText(n
|
|
|
+ MOZ_ASSERT(aBuilder->IsInDocUpdate());
|
|
|
+ nsresult rv = NS_OK;
|
|
|
+ nsIContent* foster = aTable->GetParent();
|
|
|
+
|
|
|
+ if (IsElementOrTemplateContent(foster)) {
|
|
|
+ nsHtml5OtherDocUpdate update(foster->OwnerDoc(),
|
|
|
+ aBuilder->GetDocument());
|
|
|
+
|
|
|
+- uint32_t pos = foster->IndexOf(aTable);
|
|
|
++ uint32_t pos = foster->ComputeIndexOf(aTable);
|
|
|
+
|
|
|
+ nsIContent* previousSibling = aTable->GetPreviousSibling();
|
|
|
+ if (previousSibling && previousSibling->IsNodeOfType(nsINode::eTEXT)) {
|
|
|
+ return AppendTextToTextNode(aBuffer,
|
|
|
+ aLength,
|
|
|
+ previousSibling,
|
|
|
+ aBuilder);
|
|
|
+ }
|