Prettified Code!
This commit is contained in:
parent
c1614edf99
commit
20d8d70c51
1 changed files with 23 additions and 25 deletions
48
js/index.js
48
js/index.js
|
@ -3,14 +3,14 @@
|
|||
|
||||
/**
|
||||
* Workaround for Firefox bug #733698
|
||||
*
|
||||
*
|
||||
* https://bugzilla.mozilla.org/show_bug.cgi?id=733698
|
||||
*
|
||||
*
|
||||
* Workaround by https://github.com/subzey on https://gist.github.com/subzey/2030480
|
||||
*
|
||||
*
|
||||
* Replaces and handles NS_ERROR_FAILURE errors triggered by 733698.
|
||||
*/
|
||||
(function(){
|
||||
(function () {
|
||||
var FakeTextMetrics,
|
||||
proto,
|
||||
fontSetterNative,
|
||||
|
@ -24,65 +24,63 @@
|
|||
!(proto = window.CanvasRenderingContext2D.prototype) ||
|
||||
!proto.hasOwnProperty("font") ||
|
||||
!proto.hasOwnProperty("mozTextStyle") ||
|
||||
typeof proto.__lookupSetter__ !== "function" ||
|
||||
typeof proto.__lookupSetter__ !== "function" ||
|
||||
!(fontSetterNative = proto.__lookupSetter__("font"))
|
||||
){
|
||||
return;
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
proto.__defineSetter__("font", function(value){
|
||||
|
||||
proto.__defineSetter__("font", function (value) {
|
||||
try {
|
||||
return fontSetterNative.call(this, value);
|
||||
} catch (e){
|
||||
if (e.name !== 'NS_ERROR_FAILURE'){
|
||||
throw e;
|
||||
} catch (e) {
|
||||
if (e.name !== "NS_ERROR_FAILURE") {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
measureTextNative = proto.measureText;
|
||||
FakeTextMetrics = function(){
|
||||
FakeTextMetrics = function () {
|
||||
this.width = 0;
|
||||
this.isFake = true;
|
||||
this.__proto__ = window.TextMetrics.prototype;
|
||||
};
|
||||
proto.measureText = function($0){
|
||||
proto.measureText = function ($0) {
|
||||
try {
|
||||
return measureTextNative.apply(this, arguments);
|
||||
} catch (e) {
|
||||
if (e.name !== 'NS_ERROR_FAILURE'){
|
||||
throw e;
|
||||
if (e.name !== "NS_ERROR_FAILURE") {
|
||||
throw e;
|
||||
} else {
|
||||
return new FakeTextMetrics();
|
||||
return new FakeTextMetrics();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
fillTextNative = proto.fillText;
|
||||
proto.fillText = function($0, $1, $2, $3){
|
||||
proto.fillText = function ($0, $1, $2, $3) {
|
||||
try {
|
||||
fillTextNative.apply(this, arguments);
|
||||
} catch (e) {
|
||||
if (e.name !== 'NS_ERROR_FAILURE'){
|
||||
throw e;
|
||||
if (e.name !== "NS_ERROR_FAILURE") {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
strokeTextNative = proto.strokeText;
|
||||
proto.strokeText = function($0, $1, $2, $3){
|
||||
proto.strokeText = function ($0, $1, $2, $3) {
|
||||
try {
|
||||
strokeTextNative.apply(this, arguments);
|
||||
} catch (e) {
|
||||
if (e.name !== 'NS_ERROR_FAILURE'){
|
||||
throw e;
|
||||
if (e.name !== "NS_ERROR_FAILURE") {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
})();
|
||||
|
||||
|
||||
window.onload = startup;
|
||||
|
||||
var stableDiffusionData = {
|
||||
|
|
Loading…
Reference in a new issue