mrow.js 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 __values = (this && this.__values) || function(o) {
  18. var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
  19. if (m) return m.call(o);
  20. if (o && typeof o.length === "number") return {
  21. next: function () {
  22. if (o && i >= o.length) o = void 0;
  23. return { value: o && o[i++], done: !o };
  24. }
  25. };
  26. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  27. };
  28. Object.defineProperty(exports, "__esModule", { value: true });
  29. exports.CHTMLinferredMrow = exports.CHTMLmrow = void 0;
  30. var Wrapper_js_1 = require("../Wrapper.js");
  31. var mrow_js_1 = require("../../common/Wrappers/mrow.js");
  32. var mrow_js_2 = require("../../common/Wrappers/mrow.js");
  33. var mrow_js_3 = require("../../../core/MmlTree/MmlNodes/mrow.js");
  34. var CHTMLmrow = (function (_super) {
  35. __extends(CHTMLmrow, _super);
  36. function CHTMLmrow() {
  37. return _super !== null && _super.apply(this, arguments) || this;
  38. }
  39. CHTMLmrow.prototype.toCHTML = function (parent) {
  40. var e_1, _a;
  41. var chtml = (this.node.isInferred ? (this.chtml = parent) : this.standardCHTMLnode(parent));
  42. var hasNegative = false;
  43. try {
  44. for (var _b = __values(this.childNodes), _c = _b.next(); !_c.done; _c = _b.next()) {
  45. var child = _c.value;
  46. child.toCHTML(chtml);
  47. if (child.bbox.w < 0) {
  48. hasNegative = true;
  49. }
  50. }
  51. }
  52. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  53. finally {
  54. try {
  55. if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
  56. }
  57. finally { if (e_1) throw e_1.error; }
  58. }
  59. if (hasNegative) {
  60. var w = this.getBBox().w;
  61. if (w) {
  62. this.adaptor.setStyle(chtml, 'width', this.em(Math.max(0, w)));
  63. if (w < 0) {
  64. this.adaptor.setStyle(chtml, 'marginRight', this.em(w));
  65. }
  66. }
  67. }
  68. };
  69. CHTMLmrow.kind = mrow_js_3.MmlMrow.prototype.kind;
  70. return CHTMLmrow;
  71. }((0, mrow_js_1.CommonMrowMixin)(Wrapper_js_1.CHTMLWrapper)));
  72. exports.CHTMLmrow = CHTMLmrow;
  73. var CHTMLinferredMrow = (function (_super) {
  74. __extends(CHTMLinferredMrow, _super);
  75. function CHTMLinferredMrow() {
  76. return _super !== null && _super.apply(this, arguments) || this;
  77. }
  78. CHTMLinferredMrow.kind = mrow_js_3.MmlInferredMrow.prototype.kind;
  79. return CHTMLinferredMrow;
  80. }((0, mrow_js_2.CommonInferredMrowMixin)(CHTMLmrow)));
  81. exports.CHTMLinferredMrow = CHTMLinferredMrow;
  82. //# sourceMappingURL=mrow.js.map