Bug 1445929 - Make Editor(Raw)DOMPoint::IsEndOfContainer() check if mParent is container node before checking mChild r?m_kato
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
--- 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() ||