kopia lustrzana https://github.com/backface/turtlestitch
work around a dreaded FF NS_ERROR_FAILURE for supporting retina
it’s a terrible and ugly hack with who-knows-which side-effects. I hate computers.pull/29/head
rodzic
64efff58cf
commit
c1668c4f15
|
@ -3130,3 +3130,7 @@ http://snap.berkeley.edu/run#cloud:Username=jens&ProjectName=rotation
|
|||
161123
|
||||
------
|
||||
* Blocks, Morphic: “Undrop / Redrop” support for sticky comments
|
||||
|
||||
161124
|
||||
------
|
||||
* Morphic, Store: work around a dreaded FF NS_ERROR_FAILURE for supporting retina
|
||||
|
|
32
morphic.js
32
morphic.js
|
@ -1103,7 +1103,7 @@
|
|||
|
||||
/*global window, HTMLCanvasElement, FileReader, Audio, FileList*/
|
||||
|
||||
var morphicVersion = '2016-November-23';
|
||||
var morphicVersion = '2016-November-24';
|
||||
var modules = {}; // keep track of additional loaded modules
|
||||
var useBlurredShadows = getBlurredShadowSupport(); // check for Chrome-bug
|
||||
|
||||
|
@ -1508,9 +1508,9 @@ function enableRetinaSupport() {
|
|||
return this._isRetinaEnabled;
|
||||
},
|
||||
set: function(enabled) {
|
||||
var prevPixelRatio = getPixelRatio(this);
|
||||
var prevWidth = this.width;
|
||||
var prevHeight = this.height;
|
||||
var prevPixelRatio = getPixelRatio(this),
|
||||
prevWidth = this.width,
|
||||
prevHeight = this.height;
|
||||
|
||||
this._isRetinaEnabled = enabled;
|
||||
if (getPixelRatio(this) != prevPixelRatio) {
|
||||
|
@ -1526,12 +1526,19 @@ function enableRetinaSupport() {
|
|||
return uber.width.get.call(this) / getPixelRatio(this);
|
||||
},
|
||||
set: function(width) {
|
||||
var pixelRatio = getPixelRatio(this);
|
||||
uber.width.set.call(this, width * pixelRatio);
|
||||
var context = this.getContext('2d');
|
||||
context.restore();
|
||||
context.save();
|
||||
context.scale(pixelRatio, pixelRatio);
|
||||
try { // workaround one of FF's dreaded NS_ERROR_FAILURE bugs
|
||||
// this should be taken out as soon as FF gets fixed again
|
||||
var pixelRatio = getPixelRatio(this),
|
||||
context;
|
||||
uber.width.set.call(this, width * pixelRatio);
|
||||
context = this.getContext('2d');
|
||||
context.restore();
|
||||
context.save();
|
||||
context.scale(pixelRatio, pixelRatio);
|
||||
} catch (err) {
|
||||
console.log('Retina Display Support Problem', err);
|
||||
uber.width.set.call(this, width);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1540,9 +1547,10 @@ function enableRetinaSupport() {
|
|||
return uber.height.get.call(this) / getPixelRatio(this);
|
||||
},
|
||||
set: function(height) {
|
||||
var pixelRatio = getPixelRatio(this);
|
||||
var pixelRatio = getPixelRatio(this),
|
||||
context;
|
||||
uber.height.set.call(this, height * pixelRatio);
|
||||
var context = this.getContext('2d');
|
||||
context = this.getContext('2d');
|
||||
context.restore();
|
||||
context.save();
|
||||
context.scale(pixelRatio, pixelRatio);
|
||||
|
|
12
store.js
12
store.js
|
@ -61,7 +61,7 @@ normalizeCanvas*/
|
|||
|
||||
// Global stuff ////////////////////////////////////////////////////////
|
||||
|
||||
modules.store = '2016-November-22';
|
||||
modules.store = '2016-November-24';
|
||||
|
||||
|
||||
// XML_Serializer ///////////////////////////////////////////////////////
|
||||
|
@ -390,10 +390,12 @@ SnapSerializer.prototype.rawLoadProjectModel = function (xmlNode) {
|
|||
if (model.pentrails) {
|
||||
project.pentrails = new Image();
|
||||
project.pentrails.onload = function () {
|
||||
normalizeCanvas(project.stage.trailsCanvas);
|
||||
var context = project.stage.trailsCanvas.getContext('2d');
|
||||
context.drawImage(project.pentrails, 0, 0);
|
||||
project.stage.changed();
|
||||
if (project.stage.trailsCanvas) { // work-around a bug in FF
|
||||
normalizeCanvas(project.stage.trailsCanvas);
|
||||
var context = project.stage.trailsCanvas.getContext('2d');
|
||||
context.drawImage(project.pentrails, 0, 0);
|
||||
project.stage.changed();
|
||||
}
|
||||
};
|
||||
project.pentrails.src = model.pentrails.contents;
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue