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