Bug 1445929 - Make Editor(Raw)DOMPoint::IsEndOfContainer() check if mParent is container node before checking mChild. r=m_kato, a=jcristau
authorMasayuki Nakano <masayuki@d-toybox.com>
Thu, 15 Mar 2018 22:08:19 +0900
changeset 462785 ee4ed3b4b94532184cc60db11dbcb52034b560d9
parent 462784 b3e6be69e432949d8707bb9f94c40ee7c2aaff2b
child 462786 2fee5cc3ec3a477802f2a8dddb46b98c9cfef00e
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersm_kato, jcristau
bugs1445929
milestone60.0
Bug 1445929 - Make Editor(Raw)DOMPoint::IsEndOfContainer() check if mParent is container node before checking mChild. r=m_kato, a=jcristau Editor(Raw)DOMPoint::IsEndOfContainer() checks mIsChildInitialized before referring mChild. However, it may be true even if mParent is not a container node like a text node. Therefore, if mParent is a text node and mIsChildInitialized is true, it always returns true (i.e., even if mOffset isn't same as length of mParent). This patch makes it check mParent->IsContainerNode() before checking mIsChildInitialized because after checking mIsChildInitialized, it validates the relation of the members. So, this keeps the validation simple. MozReview-Commit-ID: K2XrAZoNv2I
editor/libeditor/EditorDOMPoint.h
--- a/editor/libeditor/EditorDOMPoint.h
+++ b/editor/libeditor/EditorDOMPoint.h
@@ -588,16 +588,19 @@ public:
     //   If mParent is not a container like text node, mOffset is same as the
     //   length of the container.
     //   If mChild is initialized and it's nullptr.
     //   If mChild isn't initialized and mOffset is same as the length of the
     //   container.
     if (NS_WARN_IF(!mParent)) {
       return false;
     }
+    if (!mParent->IsContainerNode()) {
+      return mOffset.value() == mParent->Length();
+    }
     if (mIsChildInitialized) {
       if (!mChild) {
         NS_WARNING_ASSERTION(!mOffset.isSome() ||
                              mOffset.value() == mParent->Length(),
           "If mOffset was initialized, it should be length of the container");
         return true;
       }
       NS_WARNING_ASSERTION(!mOffset.isSome() ||