r44652 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44651‎ | r44652 | r44653 >
Date:05:45, 16 December 2008
Author:brion
Status:ok
Tags:
Comment:
Follow-up to r44651 -- stay in floats until we finish the SVG size, so aspect ratios in silly tiny units are preserved better.
Modified paths:
  • /trunk/phase3/includes/ImageFunctions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/ImageFunctions.php
@@ -5,7 +5,7 @@
66 *
77 * @param $length String: CSS/SVG length.
88 * @param $viewpoerSize: Float optional scale for percentage units...
9 - * @return Integer: length in pixels
 9+ * @return float: length in pixels
1010 */
1111 function wfScaleSVGUnit( $length, $viewportSize=512 ) {
1212 static $unitLength = array(
@@ -24,13 +24,13 @@
2525 $length = floatval( $matches[1] );
2626 $unit = $matches[2];
2727 if( $unit == '%' ) {
28 - return round( $length * 0.01 * $viewportSize );
 28+ return $length * 0.01 * $viewportSize;
2929 } else {
30 - return round( $length * $unitLength[$unit] );
 30+ return $length * $unitLength[$unit];
3131 }
3232 } else {
3333 // Assume pixels
34 - return round( floatval( $length ) );
 34+ return floatval( $length );
3535 }
3636 }
3737
@@ -76,8 +76,11 @@
7777 $width = $height * $aspect;
7878 }
7979
80 - $this->width = $width;
81 - $this->height = $height;
 80+ if( $width > 0 && $height > 0 ) {
 81+ $this->width = intval( round( $width ) );
 82+ $this->height = intval( round( $height ) );
 83+ }
 84+
8285 $this->first = false;
8386 }
8487 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r44651* (bug 3691) Aspect ratio from viewBox attribute is now preserved for SVG...brion05:39, 16 December 2008

Status & tagging log