Closed
Bug 717546
Opened 12 years ago
Closed 11 years ago
Implement mspace with negative width
Categories
(Core :: MathML, defect, P3)
Core
MathML
Tracking
()
RESOLVED
FIXED
mozilla23
People
(Reporter: fredw, Assigned: fredw)
References
(Depends on 1 open bug, Blocks 1 open bug)
Details
(Keywords: dev-doc-complete, helpwanted)
Attachments
(3 files, 4 obsolete files)
506 bytes,
text/html
|
Details | |
3.09 KB,
patch
|
karlt
:
review+
|
Details | Diff | Splinter Review |
2.91 KB,
patch
|
Details | Diff | Splinter Review |
Follow-up of bug 716349.
Assignee | ||
Updated•12 years ago
|
Assignee | ||
Updated•12 years ago
|
Assignee | ||
Updated•12 years ago
|
Blocks: mathml-in-mathjax
Assignee | ||
Comment 2•11 years ago
|
||
A patch partially implementing negative spaces. It only enables negative spacing via mspace (not mpadded or mo) and within mrow-like elements (not math or mtd). A negative space moving a child to a negative X coordinate (I don't think that happens in practice) is treated as if the child was moved to 0. I don't plan to do something more general at the moment. My goal is just to support MathJax's use cases where negative spaces are used to make a child closer to its previous sibling. MathJax always adds an <mrow> so no need to consider the cases of math & mtd, which seem more involved.
Attachment #686709 -
Flags: review?(karlt)
Assignee | ||
Comment 3•11 years ago
|
||
Assignee | ||
Comment 4•11 years ago
|
||
Attachment #686725 -
Flags: review?(karlt)
Assignee | ||
Updated•11 years ago
|
Attachment #686711 -
Attachment is patch: false
Attachment #686711 -
Attachment mime type: text/plain → text/html
Assignee | ||
Comment 5•11 years ago
|
||
If later we want to implement negative width for <mspace/> children of <math> or <mtd>, we should probably move the work of nsMathMLContainerFrame::FixInterFrameSpacing to Place before. Making this dependent on bug 433064.
Depends on: 433064
Assignee | ||
Comment 6•11 years ago
|
||
Mass change: setting priority to 3 for bugs preventing Gecko's Native MathML to be enabled by default in MathJax.
Keywords: helpwanted
Assignee | ||
Updated•11 years ago
|
Priority: -- → P3
Comment 7•11 years ago
|
||
Comment on attachment 686709 [details] [diff] [review] Partial support for negative mspace@width > mX += space * GetThinSpace(font); > return *this; > } > > nsIFrame* Frame() const { return mChildFrame; } >- nscoord X() const { return mX; } >+ nscoord X() const { return NS_MAX(0, mX); } NS_MAX needs to be changed to std::max here. > const nsHTMLReflowMetrics& ReflowMetrics() const { return mSize; } > nscoord Ascent() const { return mSize.ascent; } > nscoord Descent() const { return mSize.height - mSize.ascent; } > const nsBoundingMetrics& BoundingMetrics() const { > return mSize.mBoundingMetrics; > } > > private: >diff --git a/layout/mathml/nsMathMLmspaceFrame.cpp b/layout/mathml/nsMathMLmspaceFrame.cpp >--- a/layout/mathml/nsMathMLmspaceFrame.cpp >+++ b/layout/mathml/nsMathMLmspaceFrame.cpp >@@ -55,16 +55,17 @@ nsMathMLmspaceFrame::ProcessAttributes(n > mWidth = 0; > GetAttribute(mContent, mPresentationData.mstyle, nsGkAtoms::width, > value); > if (!value.IsEmpty()) { > ParseNumericValue(value, &mWidth, > nsMathMLElement::PARSE_ALLOW_NEGATIVE, > aPresContext, mStyleContext); > } >+ mPresentationData.negativeLeadingSpace = NS_MAX(0, -mWidth); and here (see bug Bug 786533)
Assignee | ||
Comment 8•11 years ago
|
||
Assignee: nobody → fred.wang
Attachment #686725 -
Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #686725 -
Flags: review?(karlt)
Attachment #734252 -
Flags: review?(karlt)
Assignee | ||
Comment 9•11 years ago
|
||
Attachment #686709 -
Attachment is obsolete: true
Attachment #686709 -
Flags: review?(karlt)
Attachment #734253 -
Flags: review?(karlt)
Assignee | ||
Comment 10•11 years ago
|
||
I just unbitrot the patches. This still allows to address MathJax's use cases, to pass the reftest as well as the MathML Acid2 test: http://fred-wang.github.io/AcidTestsMathML/acid2/
Updated•11 years ago
|
Attachment #734252 -
Flags: review?(karlt) → review+
Comment 11•11 years ago
|
||
Comment on attachment 734253 [details] [diff] [review] Patch V2 >+ // negative leading space of the frame. >+ nscoord negativeLeadingSpace; Please adjust the comment here to clarify that this is a positive value when the offset is negative. > nscoord space = > GetInterFrameSpacing(font->mScriptLevel, > prevFrameType, mChildFrameType, > &mFromFrameType, &mCarrySpace); >+ >+ nsIMathMLFrame* mathMLFrame = do_QueryFrame(mChildFrame); >+ if (mathMLFrame) { >+ nsPresentationData presentationData; >+ mathMLFrame->GetPresentationData(presentationData); >+ mX -= presentationData.negativeLeadingSpace; >+ } > mX += space * GetThinSpace(font); > return *this; Please leave the "mX += space * GetThinSpace(font);" line adjacent to the code that initializes "space". >- nscoord X() const { return mX; } >+ nscoord X() const { return std::max(0, mX); Imagine: <mrow> <mspace width="-1em"/> <mspace width="1em" mathbackground="red"/> <mspace width="1em" mathbackground="blue"/> I think there is an effect here that the position of the blue element is offset, but the position of the red element is not, which is probably not expected. Another situation is: <mrow> <mspace width="2em" mathbackground="red"/> <mrow> <mspace> width="-1em"/> <mspace width="1em" mathbackground="blue"/> </mrow> </mrow> I'd expect width="-1em" to be effective here, which requires some propagation of the negative space to the mrow. Does anything go wrong if X() returns a negative nscoord? Perhaps it is only aDesiredSize.width that need be non-negative? Can mBoundingMetrics.width be used instead of nsPresentationData::negativeLeadingSpace to store negative offsets? Looks like nsBoundingMetrics::width is really an advance rather than a width (and perhaps would be better named "advance"). I expect aDesiredSize.width would still need to be non-negative.
Attachment #734253 -
Flags: review?(karlt) → review-
Comment 12•11 years ago
|
||
The comment "// XXXfredw Negative spaces are not implemented. See bug 717546" can be removed when this is fixed.
Assignee | ||
Comment 13•11 years ago
|
||
Yes, I considered the two cases you mention. I think that can get even more complicated in situations like <mrow> <mspace width="2em" mathbackground="red"/> <mrow> <mspace width="1em"/> <mspace width="1em"/> <mspace width="-4em"/> <mspace width="2em" mathbackground="blue"/> </mrow> </mrow> where the blue rectangle should be over the red rectangle or when you combine that with several nested mrow's. I think I tried to propagate the negative space at some point but that didn't work very well. As I said in comment 2, my plan was really to consider the cases that happen in practice. Negative space are generally just used to adjust distance between two elements so basically you have X <mspace width="-.3em"/> Y where Y is never moves farther than X. Hence that seems a bit overkill to implement the whole negative spaces for MathJax purpose only (there would be other cases to consider like negative mpadded, negative mo@lspace/mo@rspace, how to handle the topmost math/mtd etc). I'll try to reconsider this. Using negative mBoundingMetrics.width might help, but I need to check that we don't assume in some place that it is nonnegative. That could lead to more issues like bug 567718. I'm still wondering if bug 433064 should be fixed before (Actually, I now agree adding an anonymous mrow frame as a child of the <math> element would solve many issues and make the code cleaner and more consistent but line breaking should probably be reimplemented before too, which will take some work).
Assignee | ||
Comment 14•11 years ago
|
||
Attachment #736785 -
Flags: review?(karlt)
Assignee | ||
Comment 15•11 years ago
|
||
Comment on attachment 734253 [details] [diff] [review] Patch V2 https://tbpl.mozilla.org/?tree=Try&rev=e8bcce0a2c2d
Attachment #734253 -
Attachment is obsolete: true
Comment 16•11 years ago
|
||
Comment on attachment 736785 [details] [diff] [review] Patch V3 Now that mRowChildFrameIterator::X() can return -ve, nsMathMLContainerFrame::Place() needs to ensure that aDesiredSize.width is non-negative, or there will be assertions like bug 716349 when an mspace is the single child of an mrow. r+ with a std::max(0, mBoundingMetrics.width) to address that. Perhaps nsMathMLmspaceFrame::Reflow() should be ensuring that rightBearing >= leftBearing, which would require that GetItalicCorrection handle empty metrics specially, but we can see how this works out with rightBearing < leftBearing.
Attachment #736785 -
Flags: review?(karlt) → review+
Assignee | ||
Comment 17•11 years ago
|
||
Attachment #736785 -
Attachment is obsolete: true
Assignee | ||
Updated•11 years ago
|
Keywords: checkin-needed,
dev-doc-needed
Comment 18•11 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/e542d6f1abae https://hg.mozilla.org/integration/mozilla-inbound/rev/adbcf488cebf
Flags: in-testsuite+
Keywords: checkin-needed
Comment 19•11 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/e542d6f1abae https://hg.mozilla.org/mozilla-central/rev/adbcf488cebf
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla23
Comment 20•11 years ago
|
||
https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Releases/23 https://developer.mozilla.org/en-US/docs/MathML/Element/mspace
Keywords: dev-doc-needed → dev-doc-complete
You need to log in
before you can comment on or make changes to this bug.
Description
•