Issue #2135 - Bug 1066965: Make contentEditable and spellchecking to work in Shadow DOM

This commit is contained in:
FranklinDM 2023-03-03 23:42:46 +08:00 committed by roytam1
commit 010db07bf3
10 changed files with 60 additions and 30 deletions

View file

@ -3679,10 +3679,11 @@ CompareToRangeStart(nsINode* aCompareNode, int32_t aCompareOffset,
{
nsINode* start = aRange->GetStartParent();
NS_ENSURE_STATE(aCompareNode && start);
// If the nodes that we're comparing are not in the same document,
// assume that aCompareNode will fall at the end of the ranges.
// If the nodes that we're comparing are not in the same document or in the
// same subtree, assume that aCompareNode will fall at the end of the ranges.
if (aCompareNode->GetComposedDoc() != start->GetComposedDoc() ||
!start->GetComposedDoc()) {
!start->GetComposedDoc() ||
aCompareNode->SubtreeRoot() != start->SubtreeRoot()) {
*aCmp = 1;
} else {
*aCmp = nsContentUtils::ComparePoints(aCompareNode, aCompareOffset,
@ -3697,10 +3698,11 @@ CompareToRangeEnd(nsINode* aCompareNode, int32_t aCompareOffset,
{
nsINode* end = aRange->GetEndParent();
NS_ENSURE_STATE(aCompareNode && end);
// If the nodes that we're comparing are not in the same document,
// assume that aCompareNode will fall at the end of the ranges.
// If the nodes that we're comparing are not in the same document or in the
// same subtree, assume that aCompareNode will fall at the end of the ranges.
if (aCompareNode->GetComposedDoc() != end->GetComposedDoc() ||
!end->GetComposedDoc()) {
!end->GetComposedDoc() ||
aCompareNode->SubtreeRoot() != end->SubtreeRoot()) {
*aCmp = 1;
} else {
*aCmp = nsContentUtils::ComparePoints(aCompareNode, aCompareOffset,