mrow.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. "use strict";
  2. var __extends = (this && this.__extends) || (function () {
  3. var extendStatics = function (d, b) {
  4. extendStatics = Object.setPrototypeOf ||
  5. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  6. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  7. return extendStatics(d, b);
  8. };
  9. return function (d, b) {
  10. if (typeof b !== "function" && b !== null)
  11. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  12. extendStatics(d, b);
  13. function __() { this.constructor = d; }
  14. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  15. };
  16. })();
  17. var __read = (this && this.__read) || function (o, n) {
  18. var m = typeof Symbol === "function" && o[Symbol.iterator];
  19. if (!m) return o;
  20. var i = m.call(o), r, ar = [], e;
  21. try {
  22. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  23. }
  24. catch (error) { e = { error: error }; }
  25. finally {
  26. try {
  27. if (r && !r.done && (m = i["return"])) m.call(i);
  28. }
  29. finally { if (e) throw e.error; }
  30. }
  31. return ar;
  32. };
  33. var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
  34. if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
  35. if (ar || !(i in from)) {
  36. if (!ar) ar = Array.prototype.slice.call(from, 0, i);
  37. ar[i] = from[i];
  38. }
  39. }
  40. return to.concat(ar || Array.prototype.slice.call(from));
  41. };
  42. var __values = (this && this.__values) || function(o) {
  43. var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
  44. if (m) return m.call(o);
  45. if (o && typeof o.length === "number") return {
  46. next: function () {
  47. if (o && i >= o.length) o = void 0;
  48. return { value: o && o[i++], done: !o };
  49. }
  50. };
  51. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  52. };
  53. Object.defineProperty(exports, "__esModule", { value: true });
  54. exports.CommonInferredMrowMixin = exports.CommonMrowMixin = void 0;
  55. var BBox_js_1 = require("../../../util/BBox.js");
  56. function CommonMrowMixin(Base) {
  57. return (function (_super) {
  58. __extends(class_1, _super);
  59. function class_1() {
  60. var e_1, _a;
  61. var args = [];
  62. for (var _i = 0; _i < arguments.length; _i++) {
  63. args[_i] = arguments[_i];
  64. }
  65. var _this = _super.apply(this, __spreadArray([], __read(args), false)) || this;
  66. _this.stretchChildren();
  67. try {
  68. for (var _b = __values(_this.childNodes), _c = _b.next(); !_c.done; _c = _b.next()) {
  69. var child = _c.value;
  70. if (child.bbox.pwidth) {
  71. _this.bbox.pwidth = BBox_js_1.BBox.fullWidth;
  72. break;
  73. }
  74. }
  75. }
  76. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  77. finally {
  78. try {
  79. if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
  80. }
  81. finally { if (e_1) throw e_1.error; }
  82. }
  83. return _this;
  84. }
  85. Object.defineProperty(class_1.prototype, "fixesPWidth", {
  86. get: function () {
  87. return false;
  88. },
  89. enumerable: false,
  90. configurable: true
  91. });
  92. class_1.prototype.stretchChildren = function () {
  93. var e_2, _a, e_3, _b, e_4, _c;
  94. var stretchy = [];
  95. try {
  96. for (var _d = __values(this.childNodes), _e = _d.next(); !_e.done; _e = _d.next()) {
  97. var child = _e.value;
  98. if (child.canStretch(1)) {
  99. stretchy.push(child);
  100. }
  101. }
  102. }
  103. catch (e_2_1) { e_2 = { error: e_2_1 }; }
  104. finally {
  105. try {
  106. if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
  107. }
  108. finally { if (e_2) throw e_2.error; }
  109. }
  110. var count = stretchy.length;
  111. var nodeCount = this.childNodes.length;
  112. if (count && nodeCount > 1) {
  113. var H = 0, D = 0;
  114. var all = (count > 1 && count === nodeCount);
  115. try {
  116. for (var _f = __values(this.childNodes), _g = _f.next(); !_g.done; _g = _f.next()) {
  117. var child = _g.value;
  118. var noStretch = (child.stretch.dir === 0);
  119. if (all || noStretch) {
  120. var _h = child.getOuterBBox(noStretch), h = _h.h, d = _h.d, rscale = _h.rscale;
  121. h *= rscale;
  122. d *= rscale;
  123. if (h > H)
  124. H = h;
  125. if (d > D)
  126. D = d;
  127. }
  128. }
  129. }
  130. catch (e_3_1) { e_3 = { error: e_3_1 }; }
  131. finally {
  132. try {
  133. if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
  134. }
  135. finally { if (e_3) throw e_3.error; }
  136. }
  137. try {
  138. for (var stretchy_1 = __values(stretchy), stretchy_1_1 = stretchy_1.next(); !stretchy_1_1.done; stretchy_1_1 = stretchy_1.next()) {
  139. var child = stretchy_1_1.value;
  140. child.coreMO().getStretchedVariant([H, D]);
  141. }
  142. }
  143. catch (e_4_1) { e_4 = { error: e_4_1 }; }
  144. finally {
  145. try {
  146. if (stretchy_1_1 && !stretchy_1_1.done && (_c = stretchy_1.return)) _c.call(stretchy_1);
  147. }
  148. finally { if (e_4) throw e_4.error; }
  149. }
  150. }
  151. };
  152. return class_1;
  153. }(Base));
  154. }
  155. exports.CommonMrowMixin = CommonMrowMixin;
  156. function CommonInferredMrowMixin(Base) {
  157. return (function (_super) {
  158. __extends(class_2, _super);
  159. function class_2() {
  160. return _super !== null && _super.apply(this, arguments) || this;
  161. }
  162. class_2.prototype.getScale = function () {
  163. this.bbox.scale = this.parent.bbox.scale;
  164. this.bbox.rscale = 1;
  165. };
  166. return class_2;
  167. }(Base));
  168. }
  169. exports.CommonInferredMrowMixin = CommonInferredMrowMixin;
  170. //# sourceMappingURL=mrow.js.map