diff options
author | Brian Wolff <bawolff+wn@gmail.com> | 2024-05-02 23:24:43 -0700 |
---|---|---|
committer | Brian Wolff <bawolff+wn@gmail.com> | 2024-05-02 23:33:27 -0700 |
commit | 8314c2a008789e789609499f122f2d8fcb63295b (patch) | |
tree | 5a4f03550782461be262df65d00f8ec345c0f2d3 /tests/phpunit/includes/media/SVGReaderTest.php | |
parent | b66a1bf1dfc9c92c3bddba9b9aeac7f1ad94aa1a (diff) | |
download | mediawikicore-8314c2a008789e789609499f122f2d8fcb63295b.tar.gz mediawikicore-8314c2a008789e789609499f122f2d8fcb63295b.zip |
Make SVGReader::scaleSVGUnit comply with SVG2 & CSS3 spec
Per the SVG2 spec, these units should be interpreted following
CSS units level 3. We had a number of differences:
* Units are supposed to be case-insensitive (previously required lowercase)
* Missing the units q, rem, ch
* ex is supposed to be 0.5em if UA does not know what it is (previously 0.75em)
* Absolute units are supposed to assume 96 dpi (previously was 90dpi)
Additionally the spec mentions the units vw, vh, vmin, vmax which are missing.
Support for those are left as a future TODO.
Bug: T364066
Change-Id: Ie18e4fe38c0ab7f8fc861839783a4758fdb09a8b
Diffstat (limited to 'tests/phpunit/includes/media/SVGReaderTest.php')
-rw-r--r-- | tests/phpunit/includes/media/SVGReaderTest.php | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/tests/phpunit/includes/media/SVGReaderTest.php b/tests/phpunit/includes/media/SVGReaderTest.php index 86a755de4c20..6c87e05e5af3 100644 --- a/tests/phpunit/includes/media/SVGReaderTest.php +++ b/tests/phpunit/includes/media/SVGReaderTest.php @@ -102,8 +102,8 @@ class SVGReaderTest extends \MediaWikiIntegrationTestCase { [ "$base/Speech_bubbles.svg", [ - 'width' => 627, - 'height' => 461, + 'width' => 669, + 'height' => 491, 'originalWidth' => '17.7cm', 'originalHeight' => '13cm', 'translations' => [ @@ -190,13 +190,18 @@ class SVGReaderTest extends \MediaWikiIntegrationTestCase { [ '1e+2', 100 ], [ '1e-2', 0.01 ], [ '10px', 10 ], - [ '10pt', 10 * 1.25 ], - [ '10pc', 10 * 15 ], - [ '10mm', 10 * 3.543307 ], - [ '10cm', 10 * 35.43307 ], - [ '10in', 10 * 90 ], + [ '10.2cm', 10.2 * 37.795275 ], + [ '10pt', 10 * 1.333333 ], + [ '10pc', 10 * 16 ], + [ '10mm', 10 * 3.7795275 ], + [ '10q', 10 * 0.944881 ], + [ '10Q', 10 * 0.944881 ], + [ '10cm', 10 * 37.795275 ], + [ '10in', 10 * 96 ], [ '10em', 10 * 16 ], - [ '10ex', 10 * 12 ], + [ '10rem', 10 * 16 ], + [ '10ex', 10 * 8 ], + [ '10ch', 10 * 8 ], [ '10%', 51.2 ], [ '10 px', 10 ], // Invalid values |