Bug 1399626 - Part 3: Add a variant of ComparePoints to nsContentUtils which takes RangeBoundaries, r=masayuki

This is a temporary implementation, which will hopefully be fleshed out in the
future to not require calling the `Offset()` methods. Currently it just
dispatches to the existing implementation using Container() and Offset().

MozReview-Commit-ID: 9Zssbhzrnz3
This commit is contained in:
Nika Layzell 2017-10-02 10:58:29 -04:00
Родитель 80c94fabbf
Коммит 7a623e996f
2 изменённых файлов: 18 добавлений и 0 удалений

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

@ -2884,6 +2884,20 @@ nsContentUtils::ComparePoints(nsIDOMNode* aParent1, int32_t aOffset1,
return ComparePoints(parent1, aOffset1, parent2, aOffset2);
}
/* static */
int32_t
nsContentUtils::ComparePoints(const RawRangeBoundary& aFirst,
const RawRangeBoundary& aSecond,
bool* aDisconnected)
{
if (NS_WARN_IF(!aFirst.IsSet()) || NS_WARN_IF(!aSecond.IsSet())) {
return -1;
}
return ComparePoints(aFirst.Container(), aFirst.Offset(),
aSecond.Container(), aSecond.Offset(),
aDisconnected);
}
inline bool
IsCharInSet(const char* aSet,
const char16_t aChar)

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

@ -37,6 +37,7 @@
#include "mozilla/Logging.h"
#include "mozilla/NotNull.h"
#include "mozilla/Maybe.h"
#include "mozilla/RangeBoundary.h"
#include "nsIContentPolicy.h"
#include "nsIDocument.h"
#include "nsIDOMMouseEvent.h"
@ -447,6 +448,9 @@ public:
static int32_t ComparePoints(nsIDOMNode* aParent1, int32_t aOffset1,
nsIDOMNode* aParent2, int32_t aOffset2,
bool* aDisconnected = nullptr);
static int32_t ComparePoints(const mozilla::RawRangeBoundary& aFirst,
const mozilla::RawRangeBoundary& aSecond,
bool* aDisconnected = nullptr);
/**
* Brute-force search of the element subtree rooted at aContent for