Closed Bug 537916 Opened 15 years ago Closed 14 years ago

MathML mfenced: Whitespaces in separators are not ignored

Categories

(Core :: MathML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.9.3a4

People

(Reporter: fredw, Assigned: wesongathedeveloper)

Details

(Whiteboard: [good first bug])

Attachments

(3 files, 3 obsolete files)

Attached file Testcase
The MathML REC indicates:

"The value of separators is a sequence of zero or more separator characters (or entity references), optionally separated by whitespace."

In the testcase, the separators should be a comma, semi-comma and a period. Currently, the spaces are treated as separator.

See http://mxr.mozilla.org/mozilla-central/source/layout/mathml/nsMathMLmfencedFrame.cpp#170
Whiteboard: [good first bug]
Attached patch Patch (obsolete) — Splinter Review
Assignee: nobody → wesongathedeveloper
Status: NEW → ASSIGNED
Attachment #420873 - Flags: review?(roc)
(In reply to comment #1)
> Created an attachment (id=420873) [details]
> Patch

Thanks.

The MathML REC says "In MathML, as in XML, "whitespace" means simple spaces, tabs, newlines, or carriage returns, i.e., characters with hexadecimal Unicode codes U+0020, U+0009, U+000A, or U+000D, respectively." but I think your code only removes spaces. I think you can simply use nsAutoString::StripWhitespace

BTW, I'm not even sure that what is made for opening/closing fences (value.Trim(" ")) is correct. The REC says "The "opening-fence" and "closing-fence" are arbitrary strings. (Since they are used as the content of mo elements, any whitespace they contain will be trimmed and collapsed as described in Section 2.4.6 Collapsing Whitespace in Input.)"
Attached patch PatchSplinter Review
Definitely didn't look at all the nsAutoString methods...
Attachment #420873 - Attachment is obsolete: true
Attachment #420907 - Flags: review?(roc)
Attachment #420873 - Flags: review?(roc)
(In reply to comment #2)
> BTW, I'm not even sure that what is made for opening/closing fences
> (value.Trim(" ")) is correct. The REC says "The "opening-fence" and
> "closing-fence" are arbitrary strings. (Since they are used as the content of
> mo elements, any whitespace they contain will be trimmed and collapsed as
> described in Section 2.4.6 Collapsing Whitespace in Input.)"

Shouldn't that be Section 2.3.5? So, based on this interpretation we need to ensure opening/closing fence whitespaces are "collapsed" internally in addition to the value.Trim(" ") that we are doing, right?
> Shouldn't that be Section 2.3.5?

2.4.6 is this section:
http://www.w3.org/TR/MathML/chapter2.html#fund.collapse

>So, based on this interpretation we need to
> ensure opening/closing fence whitespaces are "collapsed" internally in addition
> to the value.Trim(" ") that we are doing, right?

Yes, but again I think value.Trim(" ") only eliminates spaces and not other whitespaces (tab, newlines etc).
I don't know all the string functions, but nsAutoString::CompressWhitespace seems to do the job:

https://developer.mozilla.org/En/NsAutoString#CompressWhitespace
(In reply to comment #5)
> > Shouldn't that be Section 2.3.5?
> 
> 2.4.6 is this section:
> http://www.w3.org/TR/MathML/chapter2.html#fund.collapse
> 
I
Seems we should file this as a separate bug, no?
(In reply to comment #6)
> (In reply to comment #5)
> > > Shouldn't that be Section 2.3.5?
> > 
> > 2.4.6 is this section:
> > http://www.w3.org/TR/MathML/chapter2.html#fund.collapse
> > 
> I
> Seems we should file this as a separate bug, no?

Yes, probably.
Comment on attachment 420907 [details] [diff] [review]
Patch

Thanks!! How about a test?
Attachment #420907 - Flags: review?(roc) → review+
(In reply to comment #8)
> (From update of attachment 420907 [details] [diff] [review])
> Thanks!! How about a test?

Attachment 420067 [details] is currently displayed "(a, b  ; c  d)" without patch applied.
The correct rendering should be "(a, b; c. d)".
(In reply to comment #9)
> (In reply to comment #8)
> > (From update of attachment 420907 [details] [diff] [review] [details])
> > Thanks!! How about a test?
> 
> Attachment 420067 [details] is currently displayed "(a, b  ; c  d)" without patch
> applied.
> The correct rendering should be "(a, b; c. d)".

Saint, are you working on making a reftest or can I make one from attachment 420067 [details]?
Attached patch RefTest (obsolete) — Splinter Review
Attachment #424443 - Flags: review?(roc)
(In reply to comment #10)
> Saint, are you working on making a reftest or can I make one from attachment
> 420067?

Sorry for the lag here...
(In reply to comment #11)
> Created an attachment (id=424443) [details]
> RefTest

Thanks. In addition to checking that whitespaces are collapsed, you are testing the equivalence of <mo>'s and separators. I guess the only thing you need for this bug is to compare two <mfenced/>'s with different values for "separators". However, your idea to check the equivalence is good, so maybe we could create many mfence-*.xhtml tests, including one for bug 538965. I will probably open another bug to list some ideas of reftests for mfence, but for the present bug, I suppose the following is enough:

- compare separators="WS;WS" with ";"
- compare separators=",;." and separator=",WS;WS." 

where WS are whitespaces that include other characters than spaces (tab, linefeed etc)

Also, I don't believe you need all the header and <p>'s generated by Amaya. Just a minimal tree html->body->math as the other refests do.
Attached patch RefTest (obsolete) — Splinter Review
What is the best way to handle inserting newlines in content that's added as a patch? I'm getting this odd interaction between the content and the patch format.
Attachment #424443 - Attachment is obsolete: true
(In reply to comment #15)
> Created an attachment (id=428107) [details]
> RefTest

Maybe you could add a comment before the two <mfenced/>'s of bug537916.xhtml to indicate that each blank is a whitespace sequence "U+0020 U+0009 U+000a U+000d" and must not be modified.

Also, you should update the <title/>'s to say that this reftest checks whether the whitespaces are ignored in the "separators" attribute of <mfenced/>.

Otherwise it looks good, thanks.
Also, I think it would be fine if you could rename bug537916*.xhtml to mfenced-1*.xhtml to be consistent with the other reftests.
Attached patch RefTestSplinter Review
How about this?
Attachment #428107 - Attachment is obsolete: true
Comment on attachment 433853 [details] [diff] [review]
RefTest

Looks good to me. Thanks.
Attachment #433853 - Flags: review?(roc)
Keywords: checkin-needed
I'm curious..., what tool (if any) would anyone recommend for editing whitespaces changes in text files such as the attached test cases? Can this be efficiently done without a hex editor?
http://hg.mozilla.org/mozilla-central/rev/e9b7e0b5821d
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Flags: in-testsuite+
Keywords: checkin-needed
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9.3a4
(In reply to comment #20)
> I'm curious..., what tool (if any) would anyone recommend for editing
> whitespaces changes in text files such as the attached test cases? Can this be
> efficiently done without a hex editor?

I don't really know... the "classical" editors emacs/vim have an hexadecimal mode and other tools probably also have one.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: