Change the createPromiseCapability helper function into a PromiseCapability class

This is not only slightly more compact, but it also simplifies the handling of the `settled` getter.
This commit is contained in:
Jonas Jenwald 2022-03-07 17:41:41 +01:00
parent f9c2a8d437
commit 317abd6d07
24 changed files with 117 additions and 122 deletions

View file

@ -18,8 +18,8 @@
import {
AbortException,
createPromiseCapability,
FeatureTest,
PromiseCapability,
Util,
} from "../shared/util.js";
import { deprecated, setLayerDimensions } from "./display_utils.js";
@ -317,7 +317,7 @@ class TextLayerRenderTask {
this._reader = null;
this._textDivProperties = textDivProperties || new WeakMap();
this._canceled = false;
this._capability = createPromiseCapability();
this._capability = new PromiseCapability();
this._layoutTextParams = {
prevFontSize: null,
prevFontFamily: null,
@ -417,7 +417,7 @@ class TextLayerRenderTask {
* @private
*/
_render() {
const capability = createPromiseCapability();
const capability = new PromiseCapability();
let styleCache = Object.create(null);
if (this._isReadableStream) {