r53648 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r53647‎ | r53648 | r53649 >
Date:15:48, 22 July 2009
Author:j
Status:deferred (Comments)
Tags:
Comment:
Safari 4.0.2 no longer crashes if <video controls> is dynamicaly injected into the dom, detect safari version and include controls for newer version of webkit.
Modified paths:
  • /trunk/extensions/OggHandler/OggPlayer.js (modified) (history)

Diff [purge]

Index: trunk/extensions/OggHandler/OggPlayer.js
@@ -346,7 +346,52 @@
347347 }
348348 return hasObj;
349349 },
 350+ 'webkitVersionIsAtLeast' : function ( minimumString ) {
 351+ var version = function() {
 352+ // grab (AppleWebKit/)(xxx.x.x)
 353+ var webKitFields = RegExp("( AppleWebKit/)([^ ]+)").exec(navigator.userAgent);
 354+ if (!webKitFields || webKitFields.length < 3)
 355+ return null;
 356+ var versionString = webKitFields[2];
 357+ var isNightlyBuild = versionString.indexOf("+") != -1;
350358
 359+ // Remove '+' or any other stray characters
 360+ var invalidCharacter = RegExp("[^\\.0-9]").exec(versionString);
 361+ if (invalidCharacter)
 362+ versionString = versionString.slice(0, invalidCharacter.index);
 363+
 364+ var version = versionString.split(".");
 365+ version.isNightlyBuild = isNightlyBuild;
 366+ return version;
 367+ }
 368+ var toIntOrZero = function (s) {
 369+ var toInt = parseInt(s);
 370+ return isNaN(toInt) ? 0 : toInt;
 371+ }
 372+
 373+ if (minimumString === undefined)
 374+ minimumString = "";
 375+
 376+ var minimum = minimumString.split(".");
 377+ var version = version();
 378+
 379+ if (!version)
 380+ return false;
 381+
 382+ if (version.isNightlyBuild)
 383+ return true;
 384+
 385+ for (var i = 0; i < minimum.length; i++) {
 386+ var versionField = toIntOrZero(version[i]);
 387+ var minimumField = toIntOrZero(minimum[i]);
 388+
 389+ if (versionField > minimumField)
 390+ return true;
 391+ if (versionField < minimumField)
 392+ return false;
 393+ }
 394+ return true;
 395+ },
351396 'addOption' : function ( select, value, text, selected ) {
352397 var option = document.createElement( 'option' );
353398 option.value = value;
@@ -550,7 +595,7 @@
551596 ' height=' + this.hq( (params.height>0)?params.height:this.controlsHeightGuess ) +
552597 ' src=' + this.hq( params.videoUrl ) +
553598 ' autoplay';
554 - if (!this.safari)
 599+ if (!this.safari || this.webkitVersionIsAtLeast('530.19.2'))
555600 html += ' controls';
556601 html += ' ></' + mtag + '></div>';
557602 elt.innerHTML = html;

Follow-up revisions

RevisionCommit summaryAuthorDate
r62236* Various style, whitespace and documentation fixes...tstarling11:28, 10 February 2010

Comments

#Comment by Tim Starling (talk | contribs)   07:04, 10 February 2010

I figure this was for https://bugs.webkit.org/show_bug.cgi?id=25575 , the timing is about right. I'm figuring out whether we need to keep this check.

Status & tagging log