Don't insert comment markers inside <figure>

…when wgParserEnableLegacyMediaDOM=false. See task for details.

Bug: T320285
Change-Id: I397cb70f915bb8d974fe2796198d252b1be9a368
This commit is contained in:
Bartosz Dziewoński 2022-10-08 22:23:31 +02:00
parent 0e6cd67d16
commit 8664de52d1
6 changed files with 36 additions and 30 deletions

View file

@ -126,15 +126,18 @@ class CommentUtils {
// for compatibility with TimedMediaHandler.
// There is no better way to detect them, and we can't insert markers here,
// because the media DOM CSS depends on specific tag names and their order :(
// We also can't return true for the whole 'figure' (or '.thumb' in legacy DOM),
// because we might want to handle content in the caption.
// TODO See if we can remove this condition when wgParserEnableLegacyMediaDOM=false
// is enabled everywhere.
(
in_array( strtolower( $node->tagName ), [ 'a', 'span' ] ) &&
$node->firstChild &&
// We always step inside a child node so this can't be infinite, silly Phan
// @phan-suppress-next-line PhanInfiniteRecursion
static::cantHaveElementChildren( $node->firstChild )
)
) ||
// Do not insert anything inside figures when using wgParserEnableLegacyMediaDOM=false,
// because their CSS can't handle it (T320285).
strtolower( $node->tagName ) === 'figure'
)
);
}

View file

@ -92,13 +92,16 @@ function cantHaveElementChildren( node ) {
// for compatibility with TimedMediaHandler.
// There is no better way to detect them, and we can't insert markers here,
// because the media DOM CSS depends on specific tag names and their order :(
// We also can't return true for the whole 'figure' (or '.thumb' in legacy DOM),
// because we might want to handle content in the caption.
// TODO See if we can remove this condition when wgParserEnableLegacyMediaDOM=false
// is enabled everywhere.
(
[ 'a', 'span' ].indexOf( node.tagName.toLowerCase() ) !== -1 &&
node.firstChild &&
cantHaveElementChildren( node.firstChild )
)
) ||
// Do not insert anything inside figures when using wgParserEnableLegacyMediaDOM=false,
// because their CSS can't handle it (T320285).
node.tagName.toLowerCase() === 'figure'
)
);
}

View file

@ -1098,7 +1098,7 @@
"timestamp": "2018-08-10T16:54:00.000Z",
"author": "JarBot",
"range": [
"0/5/1/24/2/0",
"0/5/1/24/2",
"0/5/1/24/15/30"
],
"signatureRanges": [
@ -1420,7 +1420,7 @@
"timestamp": "2018-09-04T17:48:00.000Z",
"author": "JarBot",
"range": [
"0/5/1/38/2/0",
"0/5/1/38/2",
"0/5/1/38/15/30"
],
"signatureRanges": [
@ -1455,7 +1455,7 @@
"timestamp": "2018-10-10T15:30:00.000Z",
"author": "JarBot",
"range": [
"0/5/1/39/2/0",
"0/5/1/39/2",
"0/5/1/39/15/31"
],
"signatureRanges": [
@ -1525,7 +1525,7 @@
"timestamp": "2019-01-04T21:06:00.000Z",
"author": "JarBot",
"range": [
"0/5/1/41/2/0",
"0/5/1/41/2",
"0/5/1/41/15/29"
],
"signatureRanges": [
@ -1560,7 +1560,7 @@
"timestamp": "2019-03-01T13:37:00.000Z",
"author": "JarBot",
"range": [
"0/5/1/42/2/0",
"0/5/1/42/2",
"0/5/1/42/15/28"
],
"signatureRanges": [
@ -1595,7 +1595,7 @@
"timestamp": "2019-03-12T17:02:00.000Z",
"author": "JarBot",
"range": [
"0/5/1/43/2/0",
"0/5/1/43/2",
"0/5/1/43/15/29"
],
"signatureRanges": [
@ -1679,7 +1679,7 @@
"timestamp": "2019-09-26T19:22:00.000Z",
"author": "FPP",
"range": [
"0/5/1/46/2/0",
"0/5/1/46/2",
"0/5/1/46/15/30"
],
"signatureRanges": [
@ -2302,7 +2302,7 @@
"timestamp": "2020-02-19T14:13:00.000Z",
"author": "مصعب العبود",
"range": [
"0/5/1/71/2/0",
"0/5/1/71/2",
"0/5/1/71/13/31"
],
"signatureRanges": [
@ -2337,7 +2337,7 @@
"timestamp": "2020-02-19T14:36:00.000Z",
"author": "JarBot",
"range": [
"0/5/1/72/2/0",
"0/5/1/72/2",
"0/5/1/72/15/31"
],
"signatureRanges": [
@ -2484,7 +2484,7 @@
"timestamp": "2020-03-11T21:01:00.000Z",
"author": "وهراني",
"range": [
"0/5/1/78/2/0",
"0/5/1/78/2",
"0/5/1/78/13/28"
],
"signatureRanges": [
@ -2568,7 +2568,7 @@
"timestamp": "2020-03-20T13:30:00.000Z",
"author": "JarBot",
"range": [
"0/5/1/81/2/0",
"0/5/1/81/2",
"0/5/1/81/15/29"
],
"signatureRanges": [
@ -2687,7 +2687,7 @@
"timestamp": "2020-03-24T20:15:00.000Z",
"author": "فيصل",
"range": [
"0/5/1/85/3/1/0/0/0/0",
"0/5/1/85/3/1/0/0/0",
"0/5/1/85/6/2/28"
],
"signatureRanges": [

View file

@ -1189,7 +1189,7 @@
"timestamp": "2016-03-03T14:26:00.000Z",
"author": "Serchia",
"range": [
"15/2/0",
"15/2",
"15/6/4/29"
],
"signatureRanges": [

View file

@ -2018,7 +2018,7 @@
"timestamp": "2019-06-27T14:52:00.000Z",
"author": "Nthep",
"range": [
"10/4/4/0",
"10/4/4",
"10/4/6/4/27"
],
"signatureRanges": [
@ -4064,7 +4064,7 @@
"timestamp": "2019-06-27T14:52:00.000Z",
"author": "Nthep",
"range": [
"10/4/4/0",
"10/4/4",
"10/4/6/4/27"
],
"signatureRanges": [
@ -12187,7 +12187,7 @@
"timestamp": "2019-07-09T05:05:00.000Z",
"author": "Anthonyhcole",
"range": [
"51/4/0",
"51/4",
"51/6/8/27"
],
"signatureRanges": [
@ -14018,7 +14018,7 @@
"timestamp": "2019-07-17T11:33:00.000Z",
"author": "Dweller",
"range": [
"65/2/0",
"65/2",
"65/6/8/26"
],
"signatureRanges": [
@ -14528,7 +14528,7 @@
"timestamp": "2019-07-16T01:11:00.000Z",
"author": "Whatamidoing (WMF)",
"range": [
"70/2/0",
"70/2",
"70/4/5/27"
],
"signatureRanges": [
@ -20601,7 +20601,7 @@
"timestamp": "2019-08-04T14:31:00.000Z",
"author": "Davey2010",
"range": [
"108/2/0",
"108/2",
"108/4/11/27"
],
"signatureRanges": [
@ -23500,7 +23500,7 @@
"timestamp": "2019-08-10T12:26:00.000Z",
"author": "Davey2010",
"range": [
"136/2/0",
"136/2",
"136/10/3/28"
],
"signatureRanges": [
@ -28975,7 +28975,7 @@
"timestamp": "2019-08-15T10:51:00.000Z",
"author": "Incnis Mrsi",
"range": [
"168/2/0",
"168/2",
"168/4/18/29"
],
"signatureRanges": [
@ -29016,7 +29016,7 @@
"timestamp": "2019-08-15T12:03:00.000Z",
"author": "PrimeHunter",
"range": [
"168/8/0",
"168/8",
"168/10/0/0/0/4/29"
],
"signatureRanges": [
@ -29102,7 +29102,7 @@
"timestamp": "2019-08-15T16:41:00.000Z",
"author": "PrimeHunter",
"range": [
"168/12/0",
"168/12",
"168/16/0/0/0/0/0/0/0/6/29"
],
"signatureRanges": [

View file

@ -691,7 +691,7 @@
"timestamp": "2008-09-03T16:46:00.000Z",
"author": "Cchantep",
"range": [
"16/6/1/0",
"16/6/1",
"16/8/6/33"
],
"signatureRanges": [