Emoji: Pass functions as arguments in loader to account for minification and worker script.
Amends [56074]. Fixes #58472. Props joemcgill, westonruter, azaozz. Built from https://develop.svn.wordpress.org/trunk@56095 git-svn-id: http://core.svn.wordpress.org/trunk@55607 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
e9004a5b48
commit
10c6e2e0e8
|
@ -179,10 +179,11 @@
|
||||||
*
|
*
|
||||||
* @param {CanvasRenderingContext2D} context 2D Context.
|
* @param {CanvasRenderingContext2D} context 2D Context.
|
||||||
* @param {string} type Whether to test for support of "flag" or "emoji".
|
* @param {string} type Whether to test for support of "flag" or "emoji".
|
||||||
|
* @param {Function} emojiSetsRenderIdentically Reference to emojiSetsRenderIdentically function, needed due to minification.
|
||||||
*
|
*
|
||||||
* @return {boolean} True if the browser can render emoji, false if it cannot.
|
* @return {boolean} True if the browser can render emoji, false if it cannot.
|
||||||
*/
|
*/
|
||||||
function browserSupportsEmoji( context, type ) {
|
function browserSupportsEmoji( context, type, emojiSetsRenderIdentically ) {
|
||||||
var isIdentical;
|
var isIdentical;
|
||||||
|
|
||||||
switch ( type ) {
|
switch ( type ) {
|
||||||
|
@ -278,10 +279,12 @@
|
||||||
* @private
|
* @private
|
||||||
*
|
*
|
||||||
* @param {string[]} tests Tests.
|
* @param {string[]} tests Tests.
|
||||||
|
* @param {Function} browserSupportsEmoji Reference to browserSupportsEmoji function, needed due to minification.
|
||||||
|
* @param {Function} emojiSetsRenderIdentically Reference to emojiSetsRenderIdentically function, needed due to minification.
|
||||||
*
|
*
|
||||||
* @return {SupportTests} Support tests.
|
* @return {SupportTests} Support tests.
|
||||||
*/
|
*/
|
||||||
function testEmojiSupports( tests ) {
|
function testEmojiSupports( tests, browserSupportsEmoji, emojiSetsRenderIdentically ) {
|
||||||
var canvas;
|
var canvas;
|
||||||
if (
|
if (
|
||||||
typeof WorkerGlobalScope !== 'undefined' &&
|
typeof WorkerGlobalScope !== 'undefined' &&
|
||||||
|
@ -304,7 +307,7 @@
|
||||||
|
|
||||||
var supports = {};
|
var supports = {};
|
||||||
tests.forEach( function ( test ) {
|
tests.forEach( function ( test ) {
|
||||||
supports[ test ] = browserSupportsEmoji( context, test );
|
supports[ test ] = browserSupportsEmoji( context, test, emojiSetsRenderIdentically );
|
||||||
} );
|
} );
|
||||||
return supports;
|
return supports;
|
||||||
}
|
}
|
||||||
|
@ -349,20 +352,17 @@
|
||||||
|
|
||||||
if ( supportsWorkerOffloading() ) {
|
if ( supportsWorkerOffloading() ) {
|
||||||
try {
|
try {
|
||||||
/*
|
// Note that the functions are being passed as arguments due to minification.
|
||||||
* Note that this string contains the real source code for the
|
|
||||||
* copied functions, _not_ a string representation of them. This
|
|
||||||
* is because it's not possible to transfer a Function across
|
|
||||||
* threads. The lack of quotes is intentional. The function names
|
|
||||||
* are copied to variable names since minification will munge the
|
|
||||||
* function names, thus breaking the ability for the functions to
|
|
||||||
* refer to each other.
|
|
||||||
*/
|
|
||||||
var workerScript =
|
var workerScript =
|
||||||
'var emojiSetsRenderIdentically = ' + emojiSetsRenderIdentically + ';' +
|
'postMessage(' +
|
||||||
'var browserSupportsEmoji = ' + browserSupportsEmoji + ';' +
|
testEmojiSupports.toString() +
|
||||||
'var testEmojiSupports = ' + testEmojiSupports + ';' +
|
'(' +
|
||||||
'postMessage(testEmojiSupports(' + JSON.stringify(tests) + '));';
|
[
|
||||||
|
JSON.stringify( tests ),
|
||||||
|
browserSupportsEmoji.toString(),
|
||||||
|
emojiSetsRenderIdentically.toString()
|
||||||
|
].join( ',' ) +
|
||||||
|
'));';
|
||||||
var blob = new Blob( [ workerScript ], {
|
var blob = new Blob( [ workerScript ], {
|
||||||
type: 'text/javascript'
|
type: 'text/javascript'
|
||||||
} );
|
} );
|
||||||
|
@ -376,7 +376,7 @@
|
||||||
} catch ( e ) {}
|
} catch ( e ) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
supportTests = testEmojiSupports( tests );
|
supportTests = testEmojiSupports( tests, browserSupportsEmoji, emojiSetsRenderIdentically );
|
||||||
setSessionSupportTests( supportTests );
|
setSessionSupportTests( supportTests );
|
||||||
resolve( supportTests );
|
resolve( supportTests );
|
||||||
} )
|
} )
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
/*! This file is auto-generated */
|
/*! This file is auto-generated */
|
||||||
!function(a,n){var o,s,e;function i(e){if("undefined"!=typeof sessionStorage)try{var t={supportTests:e,timestamp:(new Date).valueOf()};sessionStorage.setItem(o,JSON.stringify(t))}catch(e){}}function p(e,t,n){e.clearRect(0,0,e.canvas.width,e.canvas.height),e.fillText(t,0,0);var t=new Uint32Array(e.getImageData(0,0,e.canvas.width,e.canvas.height).data),r=(e.clearRect(0,0,e.canvas.width,e.canvas.height),e.fillText(n,0,0),new Uint32Array(e.getImageData(0,0,e.canvas.width,e.canvas.height).data));return t.every(function(e,t){return e===r[t]})}function c(e,t){switch(t){case"flag":return p(e,"\ud83c\udff3\ufe0f\u200d\u26a7\ufe0f","\ud83c\udff3\ufe0f\u200b\u26a7\ufe0f")?!1:!p(e,"\ud83c\uddfa\ud83c\uddf3","\ud83c\uddfa\u200b\ud83c\uddf3")&&!p(e,"\ud83c\udff4\udb40\udc67\udb40\udc62\udb40\udc65\udb40\udc6e\udb40\udc67\udb40\udc7f","\ud83c\udff4\u200b\udb40\udc67\u200b\udb40\udc62\u200b\udb40\udc65\u200b\udb40\udc6e\u200b\udb40\udc67\u200b\udb40\udc7f");case"emoji":return!p(e,"\ud83e\udef1\ud83c\udffb\u200d\ud83e\udef2\ud83c\udfff","\ud83e\udef1\ud83c\udffb\u200b\ud83e\udef2\ud83c\udfff")}return!1}function f(e){var t="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?new OffscreenCanvas(300,150):a.createElement("canvas"),n=t.getContext("2d",{willReadFrequently:!0}),r=(n.textBaseline="top",n.font="600 32px Arial",{});return e.forEach(function(e){r[e]=c(n,e)}),r}function t(e){var t=a.createElement("script");t.src=e,t.defer=!0,a.head.appendChild(t)}"undefined"!=typeof Promise&&(o="wpEmojiSettingsSupports",s=["flag","emoji"],n.supports={everything:!0,everythingExceptFlag:!0},e=new Promise(function(e){a.addEventListener("DOMContentLoaded",e,{once:!0})}),new Promise(function(t){var n=function(){if("undefined"!=typeof sessionStorage&&o in sessionStorage)try{var e=JSON.parse(sessionStorage.getItem(o));if("object"==typeof e&&"number"==typeof e.timestamp&&(new Date).valueOf()<e.timestamp+604800&&"object"==typeof e.supportTests)return e.supportTests}catch(e){}return null}();if(!n){if("undefined"!=typeof Worker&&"undefined"!=typeof OffscreenCanvas&&"undefined"!=typeof URL&&URL.createObjectURL&&"undefined"!=typeof Blob)try{var e="var emojiSetsRenderIdentically = "+p+";var browserSupportsEmoji = "+c+";var testEmojiSupports = "+f+";postMessage(testEmojiSupports("+JSON.stringify(s)+"));",r=new Blob([e],{type:"text/javascript"});return void(new Worker(URL.createObjectURL(r)).onmessage=function(e){i(n=e.data),t(n)})}catch(e){}i(n=f(s))}t(n)}).then(function(e){for(var t in e)n.supports[t]=e[t],n.supports.everything=n.supports.everything&&n.supports[t],"flag"!==t&&(n.supports.everythingExceptFlag=n.supports.everythingExceptFlag&&n.supports[t]);n.supports.everythingExceptFlag=n.supports.everythingExceptFlag&&!n.supports.flag,n.DOMReady=!1,n.readyCallback=function(){n.DOMReady=!0}}).then(function(){return e}).then(function(){var e;n.supports.everything||(n.readyCallback(),(e=n.source||{}).concatemoji?t(e.concatemoji):e.wpemoji&&e.twemoji&&(t(e.twemoji),t(e.wpemoji)))}))}((window,document),window._wpemojiSettings);
|
!function(i,n){var a,o,e;function s(e){if("undefined"!=typeof sessionStorage)try{var t={supportTests:e,timestamp:(new Date).valueOf()};sessionStorage.setItem(a,JSON.stringify(t))}catch(e){}}function c(e,t,n){e.clearRect(0,0,e.canvas.width,e.canvas.height),e.fillText(t,0,0);var t=new Uint32Array(e.getImageData(0,0,e.canvas.width,e.canvas.height).data),r=(e.clearRect(0,0,e.canvas.width,e.canvas.height),e.fillText(n,0,0),new Uint32Array(e.getImageData(0,0,e.canvas.width,e.canvas.height).data));return t.every(function(e,t){return e===r[t]})}function p(e,t,n){switch(t){case"flag":return n(e,"\ud83c\udff3\ufe0f\u200d\u26a7\ufe0f","\ud83c\udff3\ufe0f\u200b\u26a7\ufe0f")?!1:!n(e,"\ud83c\uddfa\ud83c\uddf3","\ud83c\uddfa\u200b\ud83c\uddf3")&&!n(e,"\ud83c\udff4\udb40\udc67\udb40\udc62\udb40\udc65\udb40\udc6e\udb40\udc67\udb40\udc7f","\ud83c\udff4\u200b\udb40\udc67\u200b\udb40\udc62\u200b\udb40\udc65\u200b\udb40\udc6e\u200b\udb40\udc67\u200b\udb40\udc7f");case"emoji":return!n(e,"\ud83e\udef1\ud83c\udffb\u200d\ud83e\udef2\ud83c\udfff","\ud83e\udef1\ud83c\udffb\u200b\ud83e\udef2\ud83c\udfff")}return!1}function f(e,t,n){var r="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?new OffscreenCanvas(300,150):i.createElement("canvas"),a=r.getContext("2d",{willReadFrequently:!0}),o=(a.textBaseline="top",a.font="600 32px Arial",{});return e.forEach(function(e){o[e]=t(a,e,n)}),o}function t(e){var t=i.createElement("script");t.src=e,t.defer=!0,i.head.appendChild(t)}"undefined"!=typeof Promise&&(a="wpEmojiSettingsSupports",o=["flag","emoji"],n.supports={everything:!0,everythingExceptFlag:!0},e=new Promise(function(e){i.addEventListener("DOMContentLoaded",e,{once:!0})}),new Promise(function(t){var n=function(){if("undefined"!=typeof sessionStorage&&a in sessionStorage)try{var e=JSON.parse(sessionStorage.getItem(a));if("object"==typeof e&&"number"==typeof e.timestamp&&(new Date).valueOf()<e.timestamp+604800&&"object"==typeof e.supportTests)return e.supportTests}catch(e){}return null}();if(!n){if("undefined"!=typeof Worker&&"undefined"!=typeof OffscreenCanvas&&"undefined"!=typeof URL&&URL.createObjectURL&&"undefined"!=typeof Blob)try{var e="postMessage("+f.toString()+"("+[JSON.stringify(o),p.toString(),c.toString()].join(",")+"));",r=new Blob([e],{type:"text/javascript"});return void(new Worker(URL.createObjectURL(r)).onmessage=function(e){s(n=e.data),t(n)})}catch(e){}s(n=f(o,p,c))}t(n)}).then(function(e){for(var t in e)n.supports[t]=e[t],n.supports.everything=n.supports.everything&&n.supports[t],"flag"!==t&&(n.supports.everythingExceptFlag=n.supports.everythingExceptFlag&&n.supports[t]);n.supports.everythingExceptFlag=n.supports.everythingExceptFlag&&!n.supports.flag,n.DOMReady=!1,n.readyCallback=function(){n.DOMReady=!0}}).then(function(){return e}).then(function(){var e;n.supports.everything||(n.readyCallback(),(e=n.source||{}).concatemoji?t(e.concatemoji):e.wpemoji&&e.twemoji&&(t(e.twemoji),t(e.wpemoji)))}))}((window,document),window._wpemojiSettings);
|
|
@ -16,7 +16,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '6.3-alpha-56094';
|
$wp_version = '6.3-alpha-56095';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue