Merge "One more tweak for comparing comment ranges to transclusion/DOM ranges"

This commit is contained in:
jenkins-bot 2022-01-24 23:37:07 +00:00 committed by Gerrit Code Review
commit 0b52563b53
3 changed files with 46 additions and 28 deletions

View file

@ -635,32 +635,41 @@ class CommentUtils {
$from = $boundary === 'end' ? self::getRangeLastNode( $a ) : self::getRangeFirstNode( $a );
$to = $boundary === 'end' ? self::getRangeLastNode( $b ) : self::getRangeFirstNode( $b );
$skippingFrom = $boundary === 'end';
$skipNode = null;
if ( $boundary === 'end' ) {
$skipNode = $from;
}
$foundContent = false;
self::linearWalk(
$from,
static function ( string $event, Node $n ) use (
$from, $to, $boundary, &$skippingFrom, &$foundContent
$from, $to, $boundary, &$skipNode, &$foundContent
) {
if ( $n === $to && $event === ( $boundary === 'end' ? 'leave' : 'enter' ) ) {
return true;
}
if ( $skippingFrom ) {
$skippingFrom = !( $n === $from && $event === 'leave' );
if ( $skipNode ) {
if ( $n === $skipNode && $event === 'leave' ) {
$skipNode = null;
}
return;
}
if (
$event === 'enter' &&
(
!CommentUtils::isCommentSeparator( $n ) &&
!CommentUtils::isRenderingTransparentNode( $n ) &&
!CommentUtils::isOurGeneratedNode( $n ) &&
if ( $event === 'enter' ) {
if (
CommentUtils::isCommentSeparator( $n ) ||
CommentUtils::isRenderingTransparentNode( $n ) ||
CommentUtils::isOurGeneratedNode( $n )
) {
$skipNode = $n;
} elseif (
CommentUtils::isCommentContent( $n )
)
) {
$foundContent = true;
return true;
) {
$foundContent = true;
return true;
}
}
}
);

View file

@ -561,7 +561,11 @@ function compareRangesAlmostEqualBoundaries( a, b, boundary ) {
var from = boundary === 'end' ? getRangeLastNode( a ) : getRangeFirstNode( a );
var to = boundary === 'end' ? getRangeLastNode( b ) : getRangeFirstNode( b );
var skippingFrom = boundary === 'end';
var skipNode = null;
if ( boundary === 'end' ) {
skipNode = from;
}
var foundContent = false;
linearWalk(
from,
@ -569,22 +573,27 @@ function compareRangesAlmostEqualBoundaries( a, b, boundary ) {
if ( n === to && event === ( boundary === 'end' ? 'leave' : 'enter' ) ) {
return true;
}
if ( skippingFrom ) {
skippingFrom = !( n === from && event === 'leave' );
if ( skipNode ) {
if ( n === skipNode && event === 'leave' ) {
skipNode = null;
}
return;
}
if (
event === 'enter' &&
(
!isCommentSeparator( n ) &&
!isRenderingTransparentNode( n ) &&
!isOurGeneratedNode( n ) &&
if ( event === 'enter' ) {
if (
isCommentSeparator( n ) ||
isRenderingTransparentNode( n ) ||
isOurGeneratedNode( n )
) {
skipNode = n;
} else if (
isCommentContent( n )
)
) {
foundContent = true;
return true;
) {
foundContent = true;
return true;
}
}
}
);

View file

@ -49,7 +49,7 @@
"c-Xaosflux-2019-06-29T19:38:00.000Z-Bishonen-2019-06-29T19:30:00.000Z": false,
"c-Suffusion_of_Yellow-2019-06-29T19:42:00.000Z-Bishonen-2019-06-29T19:30:00.000Z": false,
"c-Suffusion_of_Yellow-2019-06-29T19:45:00.000Z-Suffusion_of_Yellow-2019-06-29T19:42:00.000Z": false,
"c-Suffusion_of_Yellow-2019-06-29T19:54:00.000Z-Missing_notification_icons_in_MonoBook": true,
"c-Suffusion_of_Yellow-2019-06-29T19:54:00.000Z-Missing_notification_icons_in_MonoBook": false,
"c-Bishonen-2019-06-29T20:20:00.000Z-Suffusion_of_Yellow-2019-06-29T19:54:00.000Z": false,
"c-Xaosflux-2019-06-26T03:14:00.000Z-Excessive_width_on_monobook": false,
"c-Xaosflux-2019-06-26T03:41:00.000Z-Xaosflux-2019-06-26T03:14:00.000Z": false,