munderover.js 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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. Object.defineProperty(exports, "__esModule", { value: true });
  43. exports.CommonMunderoverMixin = exports.CommonMoverMixin = exports.CommonMunderMixin = void 0;
  44. function CommonMunderMixin(Base) {
  45. return (function (_super) {
  46. __extends(class_1, _super);
  47. function class_1() {
  48. var args = [];
  49. for (var _i = 0; _i < arguments.length; _i++) {
  50. args[_i] = arguments[_i];
  51. }
  52. var _this = _super.apply(this, __spreadArray([], __read(args), false)) || this;
  53. _this.stretchChildren();
  54. return _this;
  55. }
  56. Object.defineProperty(class_1.prototype, "scriptChild", {
  57. get: function () {
  58. return this.childNodes[this.node.under];
  59. },
  60. enumerable: false,
  61. configurable: true
  62. });
  63. class_1.prototype.computeBBox = function (bbox, recompute) {
  64. if (recompute === void 0) { recompute = false; }
  65. if (this.hasMovableLimits()) {
  66. _super.prototype.computeBBox.call(this, bbox, recompute);
  67. return;
  68. }
  69. bbox.empty();
  70. var basebox = this.baseChild.getOuterBBox();
  71. var underbox = this.scriptChild.getOuterBBox();
  72. var v = this.getUnderKV(basebox, underbox)[1];
  73. var delta = (this.isLineBelow ? 0 : this.getDelta(true));
  74. var _a = __read(this.getDeltaW([basebox, underbox], [0, -delta]), 2), bw = _a[0], uw = _a[1];
  75. bbox.combine(basebox, bw, 0);
  76. bbox.combine(underbox, uw, v);
  77. bbox.d += this.font.params.big_op_spacing5;
  78. bbox.clean();
  79. this.setChildPWidths(recompute);
  80. };
  81. return class_1;
  82. }(Base));
  83. }
  84. exports.CommonMunderMixin = CommonMunderMixin;
  85. function CommonMoverMixin(Base) {
  86. return (function (_super) {
  87. __extends(class_2, _super);
  88. function class_2() {
  89. var args = [];
  90. for (var _i = 0; _i < arguments.length; _i++) {
  91. args[_i] = arguments[_i];
  92. }
  93. var _this = _super.apply(this, __spreadArray([], __read(args), false)) || this;
  94. _this.stretchChildren();
  95. return _this;
  96. }
  97. Object.defineProperty(class_2.prototype, "scriptChild", {
  98. get: function () {
  99. return this.childNodes[this.node.over];
  100. },
  101. enumerable: false,
  102. configurable: true
  103. });
  104. class_2.prototype.computeBBox = function (bbox) {
  105. if (this.hasMovableLimits()) {
  106. _super.prototype.computeBBox.call(this, bbox);
  107. return;
  108. }
  109. bbox.empty();
  110. var basebox = this.baseChild.getOuterBBox();
  111. var overbox = this.scriptChild.getOuterBBox();
  112. if (this.node.attributes.get('accent')) {
  113. basebox.h = Math.max(basebox.h, this.font.params.x_height * basebox.scale);
  114. }
  115. var u = this.getOverKU(basebox, overbox)[1];
  116. var delta = (this.isLineAbove ? 0 : this.getDelta());
  117. var _a = __read(this.getDeltaW([basebox, overbox], [0, delta]), 2), bw = _a[0], ow = _a[1];
  118. bbox.combine(basebox, bw, 0);
  119. bbox.combine(overbox, ow, u);
  120. bbox.h += this.font.params.big_op_spacing5;
  121. bbox.clean();
  122. };
  123. return class_2;
  124. }(Base));
  125. }
  126. exports.CommonMoverMixin = CommonMoverMixin;
  127. function CommonMunderoverMixin(Base) {
  128. return (function (_super) {
  129. __extends(class_3, _super);
  130. function class_3() {
  131. var args = [];
  132. for (var _i = 0; _i < arguments.length; _i++) {
  133. args[_i] = arguments[_i];
  134. }
  135. var _this = _super.apply(this, __spreadArray([], __read(args), false)) || this;
  136. _this.stretchChildren();
  137. return _this;
  138. }
  139. Object.defineProperty(class_3.prototype, "underChild", {
  140. get: function () {
  141. return this.childNodes[this.node.under];
  142. },
  143. enumerable: false,
  144. configurable: true
  145. });
  146. Object.defineProperty(class_3.prototype, "overChild", {
  147. get: function () {
  148. return this.childNodes[this.node.over];
  149. },
  150. enumerable: false,
  151. configurable: true
  152. });
  153. Object.defineProperty(class_3.prototype, "subChild", {
  154. get: function () {
  155. return this.underChild;
  156. },
  157. enumerable: false,
  158. configurable: true
  159. });
  160. Object.defineProperty(class_3.prototype, "supChild", {
  161. get: function () {
  162. return this.overChild;
  163. },
  164. enumerable: false,
  165. configurable: true
  166. });
  167. class_3.prototype.computeBBox = function (bbox) {
  168. if (this.hasMovableLimits()) {
  169. _super.prototype.computeBBox.call(this, bbox);
  170. return;
  171. }
  172. bbox.empty();
  173. var overbox = this.overChild.getOuterBBox();
  174. var basebox = this.baseChild.getOuterBBox();
  175. var underbox = this.underChild.getOuterBBox();
  176. if (this.node.attributes.get('accent')) {
  177. basebox.h = Math.max(basebox.h, this.font.params.x_height * basebox.scale);
  178. }
  179. var u = this.getOverKU(basebox, overbox)[1];
  180. var v = this.getUnderKV(basebox, underbox)[1];
  181. var delta = this.getDelta();
  182. var _a = __read(this.getDeltaW([basebox, underbox, overbox], [0, this.isLineBelow ? 0 : -delta, this.isLineAbove ? 0 : delta]), 3), bw = _a[0], uw = _a[1], ow = _a[2];
  183. bbox.combine(basebox, bw, 0);
  184. bbox.combine(overbox, ow, u);
  185. bbox.combine(underbox, uw, v);
  186. var z = this.font.params.big_op_spacing5;
  187. bbox.h += z;
  188. bbox.d += z;
  189. bbox.clean();
  190. };
  191. return class_3;
  192. }(Base));
  193. }
  194. exports.CommonMunderoverMixin = CommonMunderoverMixin;
  195. //# sourceMappingURL=munderover.js.map