Mozilla Home
Privacy
Cookies
Legal
Bugzilla
Browse
Advanced Search
New Bug
Reports
Documentation
Log In
Log In with GitHub
or
Remember me
Browse
Advanced Search
New Bug
Reports
Documentation
Attachment 8364313 Details for
Bug 945254
[patch]
Patch V4
945254.diff (text/plain), 10.40 KB, created by
Frédéric Wang (:fredw)
(
hide
)
Description:
Patch V4
Filename:
MIME Type:
Creator:
Frédéric Wang (:fredw)
Size:
10.40 KB
patch
obsolete
># HG changeset patch ># Parent b7098c93555c2a22fefcfb93f40c98598c94f1fe ># User Frédéric Wang <fred.wang@free.fr> >Bug 945254 - Take italic correction into account when positioning subscripts. r=roc > >diff --git a/layout/mathml/nsMathMLmmultiscriptsFrame.cpp b/layout/mathml/nsMathMLmmultiscriptsFrame.cpp >--- a/layout/mathml/nsMathMLmmultiscriptsFrame.cpp >+++ b/layout/mathml/nsMathMLmmultiscriptsFrame.cpp >@@ -277,16 +277,17 @@ nsMathMLmmultiscriptsFrame::PlaceMultiSc > nsHTMLReflowMetrics supScriptSize(wm); > nsHTMLReflowMetrics multiSubSize(wm), multiSupSize(wm); > baseFrame = nullptr; > nsIFrame* subScriptFrame = nullptr; > nsIFrame* supScriptFrame = nullptr; > nsIFrame* prescriptsFrame = nullptr; // frame of <mprescripts/>, if there. > > bool firstPrescriptsPair = false; >+ bool firstPostscriptsPair = false; > nsBoundingMetrics bmBase, bmSubScript, bmSupScript, bmMultiSub, bmMultiSup; > multiSubSize.SetTopAscent(-0x7FFFFFFF); > multiSupSize.SetTopAscent(-0x7FFFFFFF); > bmMultiSub.ascent = bmMultiSup.ascent = -0x7FFFFFFF; > bmMultiSub.descent = bmMultiSup.descent = -0x7FFFFFFF; > nscoord italicCorrection = 0; > > nsBoundingMetrics boundingMetrics; >@@ -352,20 +353,21 @@ nsMathMLmmultiscriptsFrame::PlaceMultiSc > // If italics correction is applied, we always add "a little to spare" > // (see TeXbook Ch.11, p.64), as we estimate the italic creation > // ourselves and it isn't the same as TeX. > italicCorrection += onePixel; > } > > // we update boundingMetrics.{ascent,descent} with that > // of the baseFrame only after processing all the sup/sub pairs >- // XXX need italic correction only *if* there are postscripts ? >- boundingMetrics.width = bmBase.width + italicCorrection; >+ boundingMetrics.width = bmBase.width; > boundingMetrics.rightBearing = bmBase.rightBearing; > boundingMetrics.leftBearing = bmBase.leftBearing; // until overwritten >+ >+ firstPostscriptsPair = true; > } else { > // super/subscript block > if ( childTag == nsGkAtoms::none) { > foundNoneTag = true; > } > > if (isSubScript) { > // subscript >@@ -420,17 +422,25 @@ nsMathMLmmultiscriptsFrame::PlaceMultiSc > bmMultiSup.ascent = std::max(bmMultiSup.ascent, bmSupScript.ascent); > bmMultiSup.descent = std::max(bmMultiSup.descent, bmSupScript.descent); > multiSupSize.Height() = > std::max(multiSupSize.Height(), > supScriptSize.Height() - supScriptSize.TopAscent()); > > if (bmSupScript.width) > width = std::max(width, bmSupScript.width + aScriptSpace); >- rightBearing = std::max(rightBearing, bmSupScript.rightBearing); >+ >+ if (firstPostscriptsPair) { >+ // we add the italic correction to the first superscript >+ rightBearing = std::max(rightBearing, italicCorrection + >+ bmSupScript.rightBearing); >+ firstPostscriptsPair = false; >+ } else { >+ rightBearing = std::max(rightBearing, bmSupScript.rightBearing); >+ } > > if (!prescriptsFrame) { // we are still looping over base & postscripts > boundingMetrics.rightBearing = boundingMetrics.width + rightBearing; > boundingMetrics.width += width; > } else { > prescriptsWidth += width; > if (firstPrescriptsPair) { > firstPrescriptsPair = false; >@@ -565,17 +575,17 @@ nsMathMLmmultiscriptsFrame::PlaceMultiSc > // place the base ... > childFrame = baseFrame; > dy = aDesiredSize.TopAscent() - baseSize.TopAscent(); > FinishReflowChild (baseFrame, aPresContext, baseSize, nullptr, > aFrame->MirrorIfRTL(aDesiredSize.Width(), > baseSize.Width(), > dx), > dy, 0); >- dx += bmBase.width + italicCorrection; >+ dx += bmBase.width; > } else if (prescriptsFrame != childFrame) { > // process each sup/sub pair > if (0 == count) { > subScriptFrame = childFrame; > count = 1; > } else if (1 == count) { > if (tag != nsGkAtoms::msub_) > supScriptFrame = childFrame; >@@ -603,18 +613,22 @@ nsMathMLmmultiscriptsFrame::PlaceMultiSc > aFrame->MirrorIfRTL(aDesiredSize.Width(), > subScriptSize.Width(), > x), > dy, 0); > } > > if (supScriptFrame) { > nscoord x = dx; >- if (isPreScript) >+ if (isPreScript) { > x += width - supScriptSize.Width(); >+ } else { >+ // post superscripts are shifted by the italic correction value >+ x += italicCorrection; >+ } > dy = aDesiredSize.TopAscent() - supScriptSize.TopAscent() - > maxSupScriptShift; > FinishReflowChild (supScriptFrame, aPresContext, supScriptSize, > nullptr, > aFrame->MirrorIfRTL(aDesiredSize.Width(), > supScriptSize.Width(), > x), > dy, 0); >diff --git a/layout/reftests/mathml/multiscripts-1-ref.html b/layout/reftests/mathml/multiscripts-1-ref.html >--- a/layout/reftests/mathml/multiscripts-1-ref.html >+++ b/layout/reftests/mathml/multiscripts-1-ref.html >@@ -57,16 +57,18 @@ > </math> > > <br><br> > > msup / msupsub: > <math> > <mmultiscripts style="background: red;"> > <mtext style="background-color: rgba(0, 0, 255, 0.4);">AAA</mtext> >+ <none /> >+ <none /> > </mmultiscripts> > </math> > > <math> > <mmultiscripts style="background: red;"> > <mtext style="background-color: rgba(0, 0, 255, 0.4);">AAA</mtext> > <none /> > <none /> >diff --git a/layout/reftests/mathml/reftest.list b/layout/reftests/mathml/reftest.list >--- a/layout/reftests/mathml/reftest.list >+++ b/layout/reftests/mathml/reftest.list >@@ -150,16 +150,17 @@ fails == whitespace-trim-4.html whitespa > == operator-1.xhtml operator-1-ref.xhtml > == scriptshift-1.xhtml scriptshift-1-ref.xhtml > == number-size-1.xhtml number-size-1-ref.xhtml > == multiscripts-1.html multiscripts-1-ref.html > == mathml-mmultiscript-base.html mathml-mmultiscript-base-ref.html > == mathml-mmultiscript-mprescript.html mathml-mmultiscript-mprescript-ref.html > != menclose-1.html menclose-1-ref.html > == mmultiscript-align.html mmultiscript-align-ref.html >+== subscript-italic-correction.html subscript-italic-correction-ref.html > == mathvariant-1a.html mathvariant-1a-ref.html > == mathvariant-1b.html mathvariant-1b-ref.html > == mathvariant-1c.html mathvariant-1c-ref.html > == mathvariant-1d.html mathvariant-1d-ref.html > == mathvariant-2.html mathvariant-2-ref.html > == mathvariant-3.html mathvariant-3-ref.html > == mathvariant-4.html mathvariant-4-ref.html > == mathvariant-5.html mathvariant-5-ref.html >diff --git a/layout/reftests/mathml/subscript-italic-correction-ref.html b/layout/reftests/mathml/subscript-italic-correction-ref.html >new file mode 100644 >--- /dev/null >+++ b/layout/reftests/mathml/subscript-italic-correction-ref.html >@@ -0,0 +1,36 @@ >+<!doctype html> >+<html> >+ <head> >+ <title>subscript</title> >+ <meta charset="utf-8"/> >+ </head> >+ <body style="background: #5f5; font-size: 50px;"> >+ >+ <div> >+ <math> >+ <msubsup> >+ <mi>f</mi> >+ <mspace id="s0" width="50px" height="50px" mathbackground="blue"/> >+ <mspace id="s1" width="50px" height="50px" mathbackground="blue"/> >+ </msubsup> >+ </math> >+ </div> >+ >+ <br/> >+ >+ <div> >+ <math> >+ <mmultiscripts> >+ <mi>f</mi> >+ <mspace id="s2" width="50px" height="50px" mathbackground="blue"/> >+ <mspace id="s3" width="50px" height="50px" mathbackground="blue"/> >+ <mspace id="s4" width="50px" height="50px" mathbackground="blue"/> >+ <mspace id="s5" width="50px" height="50px" mathbackground="blue"/> >+ <mspace id="s6" width="50px" height="50px" mathbackground="blue"/> >+ <mspace id="s7" width="50px" height="50px" mathbackground="blue"/> >+ </mmultiscripts> >+ </math> >+ </div> >+ >+ </body> >+</html> >diff --git a/layout/reftests/mathml/subscript-italic-correction.html b/layout/reftests/mathml/subscript-italic-correction.html >new file mode 100644 >--- /dev/null >+++ b/layout/reftests/mathml/subscript-italic-correction.html >@@ -0,0 +1,61 @@ >+<!doctype html> >+<html class="reftest-wait"> >+ <head> >+ <title>subscript</title> >+ <meta charset="utf-8"/> >+ <script type="text/javascript"> >+ function verifyItalicCorrections() >+ { >+ var epsilon = 5; >+ for (var i = 0; i < 8; i += 2) { >+ var sub = document.getElementById("s" + i); >+ var sup = document.getElementById("s" + (i+1)); >+ var italicCorrection = >+ sup.getBoundingClientRect().left - sub.getBoundingClientRect().left; >+ if (italicCorrection < epsilon) { >+ return false; >+ } >+ } >+ return true; >+ } >+ >+ function doTest() >+ { >+ if (verifyItalicCorrections()) { >+ document.body.style.background = "#5f5"; >+ } >+ document.documentElement.removeAttribute("class"); >+ } >+ window.addEventListener("MozReftestInvalidate", doTest, false); >+ </script> >+ </head> >+ <body style="background: #f00; font-size: 50px;"> >+ >+ <div> >+ <math> >+ <msubsup> >+ <mi>f</mi> >+ <mspace id="s0" width="50px" height="50px" mathbackground="blue"/> >+ <mspace id="s1" width="50px" height="50px" mathbackground="blue"/> >+ </msubsup> >+ </math> >+ </div> >+ >+ <br/> >+ >+ <div> >+ <math> >+ <mmultiscripts> >+ <mi>f</mi> >+ <mspace id="s2" width="50px" height="50px" mathbackground="blue"/> >+ <mspace id="s3" width="50px" height="50px" mathbackground="blue"/> >+ <mspace id="s4" width="50px" height="50px" mathbackground="blue"/> >+ <mspace id="s5" width="50px" height="50px" mathbackground="blue"/> >+ <mspace id="s6" width="50px" height="50px" mathbackground="blue"/> >+ <mspace id="s7" width="50px" height="50px" mathbackground="blue"/> >+ </mmultiscripts> >+ </math> >+ </div> >+ >+ </body> >+</html>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Actions:
View
|
Diff
|
Review
Attachments on
bug 945254
:
8341085
|
8360599
|
8361047
|
8361049
|
8362062
|
8363541
|
8364313
|
8365926
|
8366499
|
8366580