Remove IconImage color fallback for IE

This commit is contained in:
Maximilian Krög
2022-07-31 02:29:20 +02:00
parent f276f3f47f
commit 7c81cb41a8

View File

@@ -250,42 +250,23 @@ class IconImage extends EventTarget {
return; return;
} }
const image = this.image_;
const canvas = document.createElement('canvas'); const canvas = document.createElement('canvas');
this.canvas_[pixelRatio] = canvas; canvas.width = Math.ceil(image.width * pixelRatio);
canvas.height = Math.ceil(image.height * pixelRatio);
canvas.width = Math.ceil(this.image_.width * pixelRatio);
canvas.height = Math.ceil(this.image_.height * pixelRatio);
const ctx = canvas.getContext('2d'); const ctx = canvas.getContext('2d');
ctx.scale(pixelRatio, pixelRatio); ctx.scale(pixelRatio, pixelRatio);
ctx.drawImage(this.image_, 0, 0); ctx.drawImage(image, 0, 0);
ctx.globalCompositeOperation = 'multiply'; ctx.globalCompositeOperation = 'multiply';
// Internet Explorer 11 does not support the multiply operation.
// If the canvas is tainted in Internet Explorer this still produces
// a solid color image with the shape of the icon.
if (ctx.globalCompositeOperation === 'multiply' || this.isTainted_()) {
ctx.fillStyle = asString(this.color_); ctx.fillStyle = asString(this.color_);
ctx.fillRect(0, 0, canvas.width / pixelRatio, canvas.height / pixelRatio); ctx.fillRect(0, 0, canvas.width / pixelRatio, canvas.height / pixelRatio);
ctx.globalCompositeOperation = 'destination-in'; ctx.globalCompositeOperation = 'destination-in';
ctx.drawImage(this.image_, 0, 0); ctx.drawImage(image, 0, 0);
} else {
const imgData = ctx.getImageData(0, 0, canvas.width, canvas.height);
const data = imgData.data;
const r = this.color_[0] / 255.0;
const g = this.color_[1] / 255.0;
const b = this.color_[2] / 255.0;
const a = this.color_[3];
for (let i = 0, ii = data.length; i < ii; i += 4) { this.canvas_[pixelRatio] = canvas;
data[i] *= r;
data[i + 1] *= g;
data[i + 2] *= b;
data[i + 3] *= a;
}
ctx.putImageData(imgData, 0, 0);
}
} }
/** /**