Attachment #8366499: Patch V6 for bug #945254

View | Details | Raw Unified | Return to bug 945254
Collapse All | Expand All

(-)a/layout/mathml/nsMathMLmmultiscriptsFrame.cpp (-5 / +10 lines)
Line     Link Here 
 Lines 352-369   nsMathMLmmultiscriptsFrame::PlaceMultiSc Link Here 
352
        // If italics correction is applied, we always add "a little to spare"
352
        // If italics correction is applied, we always add "a little to spare"
353
        // (see TeXbook Ch.11, p.64), as we estimate the italic creation
353
        // (see TeXbook Ch.11, p.64), as we estimate the italic creation
354
        // ourselves and it isn't the same as TeX.
354
        // ourselves and it isn't the same as TeX.
355
        italicCorrection += onePixel;
355
        italicCorrection += onePixel;
356
      }
356
      }
357
357
358
      // we update boundingMetrics.{ascent,descent} with that
358
      // we update boundingMetrics.{ascent,descent} with that
359
      // of the baseFrame only after processing all the sup/sub pairs
359
      // of the baseFrame only after processing all the sup/sub pairs
360
      // XXX need italic correction only *if* there are postscripts ?
360
      boundingMetrics.width = bmBase.width;
361
      boundingMetrics.width = bmBase.width + italicCorrection;
362
      boundingMetrics.rightBearing = bmBase.rightBearing;
361
      boundingMetrics.rightBearing = bmBase.rightBearing;
363
      boundingMetrics.leftBearing = bmBase.leftBearing; // until overwritten
362
      boundingMetrics.leftBearing = bmBase.leftBearing; // until overwritten
364
    } else {
363
    } else {
365
      // super/subscript block
364
      // super/subscript block
366
      if ( childTag == nsGkAtoms::none) {
365
      if ( childTag == nsGkAtoms::none) {
367
        foundNoneTag = true;
366
        foundNoneTag = true;
368
      }
367
      }
369
368
 Lines 420-441   nsMathMLmmultiscriptsFrame::PlaceMultiSc Link Here 
420
        bmMultiSup.ascent = std::max(bmMultiSup.ascent, bmSupScript.ascent);
419
        bmMultiSup.ascent = std::max(bmMultiSup.ascent, bmSupScript.ascent);
421
        bmMultiSup.descent = std::max(bmMultiSup.descent, bmSupScript.descent);
420
        bmMultiSup.descent = std::max(bmMultiSup.descent, bmSupScript.descent);
422
        multiSupSize.Height() = 
421
        multiSupSize.Height() = 
423
          std::max(multiSupSize.Height(),
422
          std::max(multiSupSize.Height(),
424
                   supScriptSize.Height() - supScriptSize.TopAscent());
423
                   supScriptSize.Height() - supScriptSize.TopAscent());
425
424
426
        if (bmSupScript.width)
425
        if (bmSupScript.width)
427
          width = std::max(width, bmSupScript.width + aScriptSpace);
426
          width = std::max(width, bmSupScript.width + aScriptSpace);
428
        rightBearing = std::max(rightBearing, bmSupScript.rightBearing);
429
427
430
        if (!prescriptsFrame) { // we are still looping over base & postscripts
428
        if (!prescriptsFrame) { // we are still looping over base & postscripts
429
          rightBearing = std::max(rightBearing,
430
                                  italicCorrection + bmSupScript.rightBearing);
431
          boundingMetrics.rightBearing = boundingMetrics.width + rightBearing;
431
          boundingMetrics.rightBearing = boundingMetrics.width + rightBearing;
432
          boundingMetrics.width += width;
432
          boundingMetrics.width += width;
433
        } else {
433
        } else {
434
          rightBearing = std::max(rightBearing, bmSupScript.rightBearing);
434
          prescriptsWidth += width;
435
          prescriptsWidth += width;
435
          if (firstPrescriptsPair) {
436
          if (firstPrescriptsPair) {
436
            firstPrescriptsPair = false;
437
            firstPrescriptsPair = false;
437
            boundingMetrics.leftBearing =
438
            boundingMetrics.leftBearing =
438
              std::min(bmSubScript.leftBearing, bmSupScript.leftBearing);
439
              std::min(bmSubScript.leftBearing, bmSupScript.leftBearing);
439
          }
440
          }
440
        }
441
        }
441
        width = rightBearing = 0;
442
        width = rightBearing = 0;
 Lines 565-581   nsMathMLmmultiscriptsFrame::PlaceMultiSc Link Here 
565
        // place the base ...
566
        // place the base ...
566
        childFrame = baseFrame;
567
        childFrame = baseFrame;
567
        dy = aDesiredSize.TopAscent() - baseSize.TopAscent();
568
        dy = aDesiredSize.TopAscent() - baseSize.TopAscent();
568
        FinishReflowChild (baseFrame, aPresContext, baseSize, nullptr,
569
        FinishReflowChild (baseFrame, aPresContext, baseSize, nullptr,
569
                           aFrame->MirrorIfRTL(aDesiredSize.Width(),
570
                           aFrame->MirrorIfRTL(aDesiredSize.Width(),
570
                                               baseSize.Width(),
571
                                               baseSize.Width(),
571
                                               dx),
572
                                               dx),
572
                           dy, 0);
573
                           dy, 0);
573
        dx += bmBase.width + italicCorrection;
574
        dx += bmBase.width;
574
      } else if (prescriptsFrame != childFrame) {
575
      } else if (prescriptsFrame != childFrame) {
575
        // process each sup/sub pair
576
        // process each sup/sub pair
576
        if (0 == count) {
577
        if (0 == count) {
577
          subScriptFrame = childFrame;
578
          subScriptFrame = childFrame;
578
          count = 1;
579
          count = 1;
579
        } else if (1 == count) {
580
        } else if (1 == count) {
580
          if (tag != nsGkAtoms::msub_)
581
          if (tag != nsGkAtoms::msub_)
581
            supScriptFrame = childFrame;
582
            supScriptFrame = childFrame;
 Lines 603-620   nsMathMLmmultiscriptsFrame::PlaceMultiSc Link Here 
603
                               aFrame->MirrorIfRTL(aDesiredSize.Width(),
604
                               aFrame->MirrorIfRTL(aDesiredSize.Width(),
604
                                                   subScriptSize.Width(),
605
                                                   subScriptSize.Width(),
605
                                                   x),
606
                                                   x),
606
                               dy, 0);
607
                               dy, 0);
607
          }
608
          }
608
609
609
          if (supScriptFrame) {
610
          if (supScriptFrame) {
610
            nscoord x = dx;
611
            nscoord x = dx;
611
            if (isPreScript)
612
            if (isPreScript) {
612
              x += width - supScriptSize.Width();
613
              x += width - supScriptSize.Width();
614
            } else {
615
              // post superscripts are shifted by the italic correction value
616
              x += italicCorrection;
617
            }
613
            dy = aDesiredSize.TopAscent() - supScriptSize.TopAscent() -
618
            dy = aDesiredSize.TopAscent() - supScriptSize.TopAscent() -
614
              maxSupScriptShift;
619
              maxSupScriptShift;
615
            FinishReflowChild (supScriptFrame, aPresContext, supScriptSize,
620
            FinishReflowChild (supScriptFrame, aPresContext, supScriptSize,
616
                               nullptr,
621
                               nullptr,
617
                               aFrame->MirrorIfRTL(aDesiredSize.Width(),
622
                               aFrame->MirrorIfRTL(aDesiredSize.Width(),
618
                                                   supScriptSize.Width(),
623
                                                   supScriptSize.Width(),
619
                                                   x),
624
                                                   x),
620
                               dy, 0);
625
                               dy, 0);
(-)a/layout/reftests/mathml/reftest.list (+1 lines)
Line     Link Here 
 Lines 150-165   fails == whitespace-trim-4.html whitespa Link Here 
150
== operator-1.xhtml operator-1-ref.xhtml
150
== operator-1.xhtml operator-1-ref.xhtml
151
== scriptshift-1.xhtml scriptshift-1-ref.xhtml
151
== scriptshift-1.xhtml scriptshift-1-ref.xhtml
152
== number-size-1.xhtml number-size-1-ref.xhtml
152
== number-size-1.xhtml number-size-1-ref.xhtml
153
== multiscripts-1.html multiscripts-1-ref.html
153
== multiscripts-1.html multiscripts-1-ref.html
154
== mathml-mmultiscript-base.html mathml-mmultiscript-base-ref.html
154
== mathml-mmultiscript-base.html mathml-mmultiscript-base-ref.html
155
== mathml-mmultiscript-mprescript.html mathml-mmultiscript-mprescript-ref.html
155
== mathml-mmultiscript-mprescript.html mathml-mmultiscript-mprescript-ref.html
156
!= menclose-1.html menclose-1-ref.html
156
!= menclose-1.html menclose-1-ref.html
157
== mmultiscript-align.html mmultiscript-align-ref.html
157
== mmultiscript-align.html mmultiscript-align-ref.html
158
== subscript-italic-correction.html subscript-italic-correction-ref.html
158
== mathvariant-1a.html mathvariant-1a-ref.html
159
== mathvariant-1a.html mathvariant-1a-ref.html
159
== mathvariant-1b.html mathvariant-1b-ref.html
160
== mathvariant-1b.html mathvariant-1b-ref.html
160
== mathvariant-1c.html mathvariant-1c-ref.html
161
== mathvariant-1c.html mathvariant-1c-ref.html
161
== mathvariant-1d.html mathvariant-1d-ref.html
162
== mathvariant-1d.html mathvariant-1d-ref.html
162
== mathvariant-2.html mathvariant-2-ref.html
163
== mathvariant-2.html mathvariant-2-ref.html
163
== mathvariant-3.html mathvariant-3-ref.html
164
== mathvariant-3.html mathvariant-3-ref.html
164
== mathvariant-4.html mathvariant-4-ref.html
165
== mathvariant-4.html mathvariant-4-ref.html
165
== mathvariant-5.html mathvariant-5-ref.html
166
== mathvariant-5.html mathvariant-5-ref.html
(-)a/layout/reftests/mathml/subscript-italic-correction-ref.html (+36 lines)
Line     Link Here 
Line 0    Link Here 
1
<!doctype html>
2
<html>
3
  <head>
4
    <title>subscript</title>
5
    <meta charset="utf-8"/>
6
  </head>
7
  <body style="background: #5f5; font-size: 50px;">
8
9
    <div>
10
      <math>
11
        <msubsup>
12
          <mi>f</mi>
13
          <mspace id="s0" width="50px" height="50px" mathbackground="blue"/>
14
          <mspace id="s1" width="50px" height="50px" mathbackground="blue"/>
15
        </msubsup>
16
      </math>
17
    </div>
18
19
    <br/>
20
21
    <div>
22
      <math>
23
        <mmultiscripts>
24
          <mi>f</mi>
25
          <mspace id="s2" width="50px" height="50px" mathbackground="blue"/>
26
          <mspace id="s3" width="50px" height="50px" mathbackground="blue"/>
27
          <mspace id="s4" width="50px" height="50px" mathbackground="blue"/>
28
          <mspace id="s5" width="50px" height="50px" mathbackground="blue"/>
29
          <mspace id="s6" width="50px" height="50px" mathbackground="blue"/>
30
          <mspace id="s7" width="50px" height="50px" mathbackground="blue"/>
31
        </mmultiscripts>
32
      </math>
33
    </div>
34
35
  </body>
36
</html>
(-)a/layout/reftests/mathml/subscript-italic-correction.html (+61 lines)
Line     Link Here 
Line 0    Link Here 
1
<!doctype html>
2
<html class="reftest-wait">
3
  <head>
4
    <title>subscript</title>
5
    <meta charset="utf-8"/>
6
    <script type="text/javascript">
7
      function verifyItalicCorrections()
8
      {
9
        var epsilon = 5;
10
        for (var i = 0; i < 8; i += 2) {
11
          var sub = document.getElementById("s" + i);
12
          var sup = document.getElementById("s" + (i+1));
13
          var italicCorrection =
14
           sup.getBoundingClientRect().left - sub.getBoundingClientRect().left;
15
           if (italicCorrection < epsilon) {
16
             return false;
17
           }
18
        }
19
        return true;
20
      }
21
22
      function doTest()
23
      {
24
        if (verifyItalicCorrections()) {
25
          document.body.style.background = "#5f5";
26
        }
27
        document.documentElement.removeAttribute("class");
28
      }
29
      window.addEventListener("MozReftestInvalidate", doTest, false);
30
    </script>
31
  </head>
32
  <body style="background: #f00; font-size: 50px;">
33
34
    <div>
35
      <math>
36
        <msubsup>
37
          <mi>f</mi>
38
          <mspace id="s0" width="50px" height="50px" mathbackground="blue"/>
39
          <mspace id="s1" width="50px" height="50px" mathbackground="blue"/>
40
        </msubsup>
41
      </math>
42
    </div>
43
44
    <br/>
45
46
    <div>
47
      <math>
48
        <mmultiscripts>
49
          <mi>f</mi>
50
          <mspace id="s2" width="50px" height="50px" mathbackground="blue"/>
51
          <mspace id="s3" width="50px" height="50px" mathbackground="blue"/>
52
          <mspace id="s4" width="50px" height="50px" mathbackground="blue"/>
53
          <mspace id="s5" width="50px" height="50px" mathbackground="blue"/>
54
          <mspace id="s6" width="50px" height="50px" mathbackground="blue"/>
55
          <mspace id="s7" width="50px" height="50px" mathbackground="blue"/>
56
        </mmultiscripts>
57
      </math>
58
    </div>
59
60
  </body>
61
</html>

Return to bug 945254