mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-13 18:37:07 +00:00
Merge "One more tweak for comparing comment ranges to transclusion/DOM ranges"
This commit is contained in:
commit
0b52563b53
|
@ -635,32 +635,41 @@ class CommentUtils {
|
||||||
$from = $boundary === 'end' ? self::getRangeLastNode( $a ) : self::getRangeFirstNode( $a );
|
$from = $boundary === 'end' ? self::getRangeLastNode( $a ) : self::getRangeFirstNode( $a );
|
||||||
$to = $boundary === 'end' ? self::getRangeLastNode( $b ) : self::getRangeFirstNode( $b );
|
$to = $boundary === 'end' ? self::getRangeLastNode( $b ) : self::getRangeFirstNode( $b );
|
||||||
|
|
||||||
$skippingFrom = $boundary === 'end';
|
$skipNode = null;
|
||||||
|
if ( $boundary === 'end' ) {
|
||||||
|
$skipNode = $from;
|
||||||
|
}
|
||||||
|
|
||||||
$foundContent = false;
|
$foundContent = false;
|
||||||
self::linearWalk(
|
self::linearWalk(
|
||||||
$from,
|
$from,
|
||||||
static function ( string $event, Node $n ) use (
|
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' ) ) {
|
if ( $n === $to && $event === ( $boundary === 'end' ? 'leave' : 'enter' ) ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if ( $skippingFrom ) {
|
if ( $skipNode ) {
|
||||||
$skippingFrom = !( $n === $from && $event === 'leave' );
|
if ( $n === $skipNode && $event === 'leave' ) {
|
||||||
|
$skipNode = null;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if ( $event === 'enter' ) {
|
||||||
$event === 'enter' &&
|
if (
|
||||||
(
|
CommentUtils::isCommentSeparator( $n ) ||
|
||||||
!CommentUtils::isCommentSeparator( $n ) &&
|
CommentUtils::isRenderingTransparentNode( $n ) ||
|
||||||
!CommentUtils::isRenderingTransparentNode( $n ) &&
|
CommentUtils::isOurGeneratedNode( $n )
|
||||||
!CommentUtils::isOurGeneratedNode( $n ) &&
|
) {
|
||||||
|
$skipNode = $n;
|
||||||
|
|
||||||
|
} elseif (
|
||||||
CommentUtils::isCommentContent( $n )
|
CommentUtils::isCommentContent( $n )
|
||||||
)
|
) {
|
||||||
) {
|
$foundContent = true;
|
||||||
$foundContent = true;
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -561,7 +561,11 @@ function compareRangesAlmostEqualBoundaries( a, b, boundary ) {
|
||||||
var from = boundary === 'end' ? getRangeLastNode( a ) : getRangeFirstNode( a );
|
var from = boundary === 'end' ? getRangeLastNode( a ) : getRangeFirstNode( a );
|
||||||
var to = boundary === 'end' ? getRangeLastNode( b ) : getRangeFirstNode( b );
|
var to = boundary === 'end' ? getRangeLastNode( b ) : getRangeFirstNode( b );
|
||||||
|
|
||||||
var skippingFrom = boundary === 'end';
|
var skipNode = null;
|
||||||
|
if ( boundary === 'end' ) {
|
||||||
|
skipNode = from;
|
||||||
|
}
|
||||||
|
|
||||||
var foundContent = false;
|
var foundContent = false;
|
||||||
linearWalk(
|
linearWalk(
|
||||||
from,
|
from,
|
||||||
|
@ -569,22 +573,27 @@ function compareRangesAlmostEqualBoundaries( a, b, boundary ) {
|
||||||
if ( n === to && event === ( boundary === 'end' ? 'leave' : 'enter' ) ) {
|
if ( n === to && event === ( boundary === 'end' ? 'leave' : 'enter' ) ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if ( skippingFrom ) {
|
if ( skipNode ) {
|
||||||
skippingFrom = !( n === from && event === 'leave' );
|
if ( n === skipNode && event === 'leave' ) {
|
||||||
|
skipNode = null;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if ( event === 'enter' ) {
|
||||||
event === 'enter' &&
|
if (
|
||||||
(
|
isCommentSeparator( n ) ||
|
||||||
!isCommentSeparator( n ) &&
|
isRenderingTransparentNode( n ) ||
|
||||||
!isRenderingTransparentNode( n ) &&
|
isOurGeneratedNode( n )
|
||||||
!isOurGeneratedNode( n ) &&
|
) {
|
||||||
|
skipNode = n;
|
||||||
|
|
||||||
|
} else if (
|
||||||
isCommentContent( n )
|
isCommentContent( n )
|
||||||
)
|
) {
|
||||||
) {
|
foundContent = true;
|
||||||
foundContent = true;
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -49,7 +49,7 @@
|
||||||
"c-Xaosflux-2019-06-29T19:38:00.000Z-Bishonen-2019-06-29T19:30:00.000Z": false,
|
"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: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: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-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:14:00.000Z-Excessive_width_on_monobook": false,
|
||||||
"c-Xaosflux-2019-06-26T03:41:00.000Z-Xaosflux-2019-06-26T03:14:00.000Z": false,
|
"c-Xaosflux-2019-06-26T03:41:00.000Z-Xaosflux-2019-06-26T03:14:00.000Z": false,
|
||||||
|
|
Loading…
Reference in a new issue