Changes from branches/4.4/src/wp-includes/js/wp-emoji-loader.js at r36410 to trunk/src/wp-includes/js/wp-emoji-loader.js at r35606
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/js/wp-emoji-loader.js
r36410 r35606 13 13 function browserSupportsEmoji( type ) { 14 14 var canvas = document.createElement( 'canvas' ), 15 context = canvas.getContext && canvas.getContext( '2d' ), 16 stringFromCharCode = String.fromCharCode, 17 tone; 15 context = canvas.getContext && canvas.getContext( '2d' ); 18 16 19 17 if ( ! context || ! context.fillText ) { … … 39 37 * to a larger image (4-5KB data URL). 40 38 */ 41 context.fillText( stringFromCharCode( 55356, 56806, 55356, 56826 ), 0, 0 );39 context.fillText( String.fromCharCode( 55356, 56806, 55356, 56826 ), 0, 0 ); 42 40 return canvas.toDataURL().length > 3000; 43 } else if ( 'diversity' === type ) {44 /*45 * This tests if the browser supports the Emoji Diversity specification, by rendering an46 * emoji with no skin tone specified (in this case, Santa). It then adds a skin tone, and47 * compares if the emoji rendering has changed.48 */49 context.fillText( stringFromCharCode( 55356, 57221 ), 0, 0 );50 tone = context.getImageData( 16, 16, 1, 1 ).data.toString();51 context.fillText( stringFromCharCode( 55356, 57221, 55356, 57343 ), 0, 0 );52 // Chrome has issues comparing arrays, so we compare it as a string, instead.53 return tone !== context.getImageData( 16, 16, 1, 1 ).data.toString();54 41 } else { 55 42 if ( 'simple' === type ) { … … 59 46 * as an empty square, so the center pixel will be blank. 60 47 */ 61 context.fillText( stringFromCharCode( 55357, 56835 ), 0, 0 );48 context.fillText( String.fromCharCode( 55357, 56835 ), 0, 0 ); 62 49 } else { 63 50 /* … … 65 52 * that the Unicode Consortium have made in years: the burrito. 66 53 */ 67 context.fillText( stringFromCharCode( 55356, 57135 ), 0, 0 );54 context.fillText( String.fromCharCode( 55356, 57135 ), 0, 0 ); 68 55 } 69 56 return context.getImageData( 16, 16, 1, 1 ).data[0] !== 0; … … 80 67 81 68 settings.supports = { 82 simple: browserSupportsEmoji( 'simple' ), 83 flag: browserSupportsEmoji( 'flag' ), 84 unicode8: browserSupportsEmoji( 'unicode8' ), 85 diversity: browserSupportsEmoji( 'diversity' ) 69 simple: browserSupportsEmoji( 'simple' ), 70 flag: browserSupportsEmoji( 'flag' ), 71 unicode8: browserSupportsEmoji( 'unicode8' ) 86 72 }; 87 73 … … 91 77 }; 92 78 93 if ( ! settings.supports.simple || ! settings.supports.flag || ! settings.supports.unicode8 || ! settings.supports.diversity) {79 if ( ! settings.supports.simple || ! settings.supports.flag || ! settings.supports.unicode8 ) { 94 80 ready = function() { 95 81 settings.readyCallback();
Note: See TracChangeset
for help on using the changeset viewer.