Skip to content

Commit 49ea3d0

Browse files
committed
Remove unneeded this.lines, and only set fSpace when frame is used.
1 parent dcae9f2 commit 49ea3d0

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

mathjax3-ts/output/chtml/Wrappers/mtable.ts

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ export class CHTMLmtable<N, T, D> extends CHTMLWrapper<N, T, D> {
7676
* The spacing and line data
7777
*/
7878
protected frame: boolean;
79-
protected lines: boolean;
8079
protected fSpace: number[];
8180
protected cSpace: number[];
8281
protected rSpace: number[];
@@ -108,8 +107,7 @@ export class CHTMLmtable<N, T, D> extends CHTMLWrapper<N, T, D> {
108107
//
109108
const attributes = node.attributes;
110109
this.frame = attributes.get('frame') !== 'none';
111-
this.lines = this.frame || attributes.get('columnlines') !== 'none' || attributes.get('rowlines') !== 'none';
112-
this.fSpace = (this.lines ? this.convertLengths(this.getAttributeArray('framespacing')) : [0, 0]);
110+
this.fSpace = (this.frame ? this.convertLengths(this.getAttributeArray('framespacing')) : [0, 0]);
113111
this.cSpace = this.convertLengths(this.getColumnAttributes('columnspacing'));
114112
this.rSpace = this.convertLengths(this.getRowAttributes('rowspacing'));
115113
this.cLines = this.getColumnAttributes('columnlines').map(x => (x === 'none' ? 0 : .07));
@@ -434,6 +432,10 @@ export class CHTMLmtable<N, T, D> extends CHTMLWrapper<N, T, D> {
434432
}
435433
}
436434

435+
/*
436+
* Set the heights of all rows to be the same, and properly center
437+
* baseline or axis rows within the newly sized
438+
*/
437439
protected handleEqualRows() {
438440
if (!this.node.attributes.get('equalrows')) return;
439441
const space = this.rSpace.map(x => x / 2);
@@ -442,17 +444,27 @@ export class CHTMLmtable<N, T, D> extends CHTMLWrapper<N, T, D> {
442444
const {H, D} = this.getTableData();
443445
const HD = this.getEqualRowHeight();
444446
const HDem = this.em(HD);
447+
//
448+
// Loop through the rows and set their heights
449+
//
445450
for (const i of Array.from(this.childNodes.keys())) {
446451
const row = this.childNodes[i];
447-
this.adaptor.setStyle(row.chtml, 'height', this.em(space[i] + HD + space[i + 1]));
448-
const ralign = row.node.attributes.get('rowalign');
449-
for (const cell of row.childNodes) {
450-
const calign = cell.node.attributes.get('rowalign');
451-
if (calign === 'baseline' || calign === 'axis') {
452-
const child = this.adaptor.lastChild(cell.chtml) as N;
453-
this.adaptor.setStyle(child, 'height', HDem);
454-
this.adaptor.setStyle(child, 'verticalAlign', this.em(-((HD - H[i] + D[i]) / 2)));
455-
if (ralign === 'baseline' || ralign === 'axis') break;
452+
if (HD !== H[i] + D[i]) {
453+
this.adaptor.setStyle(row.chtml, 'height', this.em(space[i] + HD + space[i + 1]));
454+
const ralign = row.node.attributes.get('rowalign');
455+
//
456+
// Loop through the cells and set the strut height and depth to spread
457+
// the extra height equally above and below the baseline. The strut
458+
// is the last element in the cell.
459+
//
460+
for (const cell of row.childNodes) {
461+
const calign = cell.node.attributes.get('rowalign');
462+
if (calign === 'baseline' || calign === 'axis') {
463+
const child = this.adaptor.lastChild(cell.chtml) as N;
464+
this.adaptor.setStyle(child, 'height', HDem);
465+
this.adaptor.setStyle(child, 'verticalAlign', this.em(-((HD - H[i] + D[i]) / 2)));
466+
if (ralign === 'baseline' || ralign === 'axis') break;
467+
}
456468
}
457469
}
458470
}

0 commit comments

Comments
 (0)