@@ -170,6 +170,9 @@ nsresult nsMathMLmfracFrame::PlaceInternal(DrawTarget* aDrawTarget,
170
170
GetReflowAndBoundingMetricsFor (frameNum, sizeNum, bmNum);
171
171
GetReflowAndBoundingMetricsFor (frameDen, sizeDen, bmDen);
172
172
173
+ nsMargin numMargin = GetMarginForPlace (aFlags, frameNum),
174
+ denMargin = GetMarginForPlace (aFlags, frameDen);
175
+
173
176
nsPresContext* presContext = PresContext ();
174
177
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits (1 );
175
178
@@ -206,13 +209,12 @@ nsresult nsMathMLmfracFrame::PlaceInternal(DrawTarget* aDrawTarget,
206
209
207
210
mLineRect .height = mLineThickness ;
208
211
209
- // by default, leave at least one-pixel padding at either end, and add
210
- // lspace & rspace that may come from if we are an outermost
212
+ // Add lspace & rspace that may come from if we are an outermost
211
213
// embellished container (we fetch values from the core since they may use
212
214
// units that depend on style data, and style changes could have occurred
213
215
// in the core since our last visit there)
214
- nscoord leftSpace = onePixel ;
215
- nscoord rightSpace = onePixel ;
216
+ nscoord leftSpace = 0 ;
217
+ nscoord rightSpace = 0 ;
216
218
if (outermostEmbellished) {
217
219
const bool isRTL = StyleVisibility ()->mDirection == StyleDirection::Rtl;
218
220
nsEmbellishData coreData;
@@ -276,8 +278,8 @@ nsresult nsMathMLmfracFrame::PlaceInternal(DrawTarget* aDrawTarget,
276
278
oneDevPixel);
277
279
}
278
280
279
- nscoord actualClearance =
280
- (numShift - bmNum. descent ) - (bmDen.ascent - denShift);
281
+ nscoord actualClearance = (numShift - bmNum. descent - numMargin. bottom ) -
282
+ (bmDen.ascent + denMargin. top - denShift);
281
283
// actualClearance should be >= minClearance
282
284
if (actualClearance < minClearance) {
283
285
nscoord halfGap = (minClearance - actualClearance) / 2 ;
@@ -313,14 +315,14 @@ nsresult nsMathMLmfracFrame::PlaceInternal(DrawTarget* aDrawTarget,
313
315
}
314
316
315
317
// adjust numShift to maintain minClearanceNum if needed
316
- nscoord actualClearanceNum =
317
- (numShift - bmNum. descent ) - (axisHeight + actualRuleThickness / 2 );
318
+ nscoord actualClearanceNum = (numShift - bmNum. descent - numMargin. bottom ) -
319
+ (axisHeight + actualRuleThickness / 2 );
318
320
if (actualClearanceNum < minClearanceNum) {
319
321
numShift += (minClearanceNum - actualClearanceNum);
320
322
}
321
323
// adjust denShift to maintain minClearanceDen if needed
322
- nscoord actualClearanceDen =
323
- (axisHeight - actualRuleThickness / 2 ) - (bmDen.ascent - denShift);
324
+ nscoord actualClearanceDen = (axisHeight - actualRuleThickness / 2 ) -
325
+ (bmDen.ascent + denMargin. top - denShift);
324
326
if (actualClearanceDen < minClearanceDen) {
325
327
denShift += (minClearanceDen - actualClearanceDen);
326
328
}
@@ -331,40 +333,59 @@ nsresult nsMathMLmfracFrame::PlaceInternal(DrawTarget* aDrawTarget,
331
333
332
334
// XXX Need revisiting the width. TeX uses the exact width
333
335
// e.g. in $$\huge\frac{\displaystyle\int}{i}$$
334
- nscoord width = std::max (bmNum.width , bmDen.width );
335
- nscoord dxNum = leftSpace + (width - sizeNum.Width ()) / 2 ;
336
- nscoord dxDen = leftSpace + (width - sizeDen.Width ()) / 2 ;
336
+ nscoord width = std::max (bmNum.width + numMargin.LeftRight (),
337
+ bmDen.width + denMargin.LeftRight ());
338
+ nscoord dxNum =
339
+ leftSpace + (width - sizeNum.Width () - numMargin.LeftRight ()) / 2 ;
340
+ nscoord dxDen =
341
+ leftSpace + (width - sizeDen.Width () - denMargin.LeftRight ()) / 2 ;
337
342
width += leftSpace + rightSpace;
338
343
339
344
mBoundingMetrics .rightBearing =
340
- std::max (dxNum + bmNum.rightBearing , dxDen + bmDen.rightBearing );
345
+ std::max (dxNum + bmNum.rightBearing + numMargin.LeftRight (),
346
+ dxDen + bmDen.rightBearing + denMargin.LeftRight ());
341
347
if (mBoundingMetrics .rightBearing < width - rightSpace)
342
348
mBoundingMetrics .rightBearing = width - rightSpace;
343
349
mBoundingMetrics .leftBearing =
344
350
std::min (dxNum + bmNum.leftBearing , dxDen + bmDen.leftBearing );
345
351
if (mBoundingMetrics .leftBearing > leftSpace)
346
352
mBoundingMetrics .leftBearing = leftSpace;
347
- mBoundingMetrics .ascent = bmNum.ascent + numShift;
348
- mBoundingMetrics .descent = bmDen.descent + denShift;
353
+ mBoundingMetrics .ascent = bmNum.ascent + numShift + numMargin. top ;
354
+ mBoundingMetrics .descent = bmDen.descent + denShift + denMargin. bottom ;
349
355
mBoundingMetrics .width = width;
350
356
351
- aDesiredSize.SetBlockStartAscent (sizeNum.BlockStartAscent () + numShift);
352
- aDesiredSize.Height () = aDesiredSize.BlockStartAscent () + sizeDen.Height () -
353
- sizeDen.BlockStartAscent () + denShift;
357
+ aDesiredSize.SetBlockStartAscent (numMargin.top + sizeNum.BlockStartAscent () +
358
+ numShift);
359
+ aDesiredSize.Height () = aDesiredSize.BlockStartAscent () + sizeDen.Height () +
360
+ denMargin.bottom - sizeDen.BlockStartAscent () +
361
+ denShift;
354
362
aDesiredSize.Width () = mBoundingMetrics .width ;
355
363
aDesiredSize.mBoundingMetrics = mBoundingMetrics ;
356
364
365
+ // Add padding+border.
366
+ auto borderPadding = GetBorderPaddingForPlace (aFlags);
367
+ InflateReflowAndBoundingMetrics (borderPadding, aDesiredSize,
368
+ mBoundingMetrics );
369
+ leftSpace += borderPadding.left ;
370
+ rightSpace += borderPadding.right ;
371
+ width += borderPadding.LeftRight ();
372
+ dxNum += borderPadding.left ;
373
+ dxDen += borderPadding.left ;
374
+
357
375
mReference .x = 0 ;
358
376
mReference .y = aDesiredSize.BlockStartAscent ();
359
377
360
378
if (!aFlags.contains (PlaceFlag::MeasureOnly)) {
361
379
nscoord dy;
362
380
// place numerator
363
- dy = 0 ;
381
+ dxNum += numMargin.left ;
382
+ dy = borderPadding.top + numMargin.top ;
364
383
FinishReflowChild (frameNum, presContext, sizeNum, nullptr , dxNum, dy,
365
384
ReflowChildFlags::Default);
366
385
// place denominator
367
- dy = aDesiredSize.Height () - sizeDen.Height ();
386
+ dxDen += denMargin.left ;
387
+ dy = aDesiredSize.Height () - sizeDen.Height () - denMargin.bottom -
388
+ borderPadding.bottom ;
368
389
FinishReflowChild (frameDen, presContext, sizeDen, nullptr , dxDen, dy,
369
390
ReflowChildFlags::Default);
370
391
// place the fraction bar - dy is top of bar
0 commit comments