mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 17:30:09 +02:00
Move most functionality in the create
methods into the BaseCanvasFactory
This *slightly* reduces the amount of code duplication in the `DOMCanvasFactory.create` and `NodeCanvasFactory.create` methods.
This commit is contained in:
parent
7b4fa0a038
commit
d10b850916
3 changed files with 19 additions and 19 deletions
|
@ -37,18 +37,11 @@ class DOMCanvasFactory extends BaseCanvasFactory {
|
|||
this._document = ownerDocument;
|
||||
}
|
||||
|
||||
create(width, height) {
|
||||
if (width <= 0 || height <= 0) {
|
||||
throw new Error("Invalid canvas size");
|
||||
}
|
||||
_createCanvas(width, height) {
|
||||
const canvas = this._document.createElement("canvas");
|
||||
const context = canvas.getContext("2d");
|
||||
canvas.width = width;
|
||||
canvas.height = height;
|
||||
return {
|
||||
canvas,
|
||||
context,
|
||||
};
|
||||
return canvas;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue