Closed
Bug 914031
Opened 11 years ago
Closed 11 years ago
Implement menclose notation "phasorangle"
Categories
(Core :: MathML, defect)
Core
MathML
Tracking
()
RESOLVED
FIXED
mozilla32
People
(Reporter: fredw, Assigned: bkrzno)
References
(Blocks 1 open bug)
Details
(Keywords: dev-doc-complete, Whiteboard: [mentor=fredw][lang=c++])
Attachments
(2 files, 12 obsolete files)
(deleted),
text/html
|
Details | |
(deleted),
patch
|
Details | Diff | Splinter Review |
A future version of MathML3 will add "phasorangle" to the list of suggested notations:
http://www.w3.org/Math/draft-spec/chapter3-d.html#id.3.3.9.3
Comment from Neil Soiffer: "The key part (at least for me to implement it in MathPlayer) was to see that it uses a slope of 2 (angle = tan^-1(2)) for the angled line and that value seems to work reasonably well. It was relatively simple to implement in MathPlayer. I and the rest of the MathML WG hope that it will be easy to add to MathJax, FireFox, and Webkit."
For people willing to work on this: the code to modify is
http://dxr.mozilla.org/mozilla-central/source/layout/mathml/nsMathMLmencloseFrame.cpp
probably the bottom line will be drawn with the same line as NOTATION_BOTTOM while the other line will need a specific drawing in nsDisplayNotation::Paint. This will be very similar to bug 875294, so attachment 757830 [details] [diff] [review] should help to find the places to modify.
Comment 1•11 years ago
|
||
I'd like to take it up.
I don't have knowledge of the layout. So, it take time to understand. Please pardon me developing slow.
Reporter | ||
Comment 3•11 years ago
|
||
Thanks, I haven't tested but the patch looks good. I'm not familiar with this phasorangle notation, but it seems to me that with your code the slanted line may be drawn over the content. Is that what we want? If not, I think you must update dx_left to leave some space to draw that slanted line.
Also, can you please create a reftest:
https://developer.mozilla.org/en-US/docs/Creating_reftest-based_unit_tests
For example a != reftest <menclose> vs <menclose notation="phasorangle">
You can also do something more complicated to get a == reftest. First, draw your notation in a phasorangle.html page with
<div style="position: absolute; top: 20px; left; 20px">
<math>
<mspace height="100px" depth="100px"/>
<menclose notation="phasorangle"><mspace width="100px" height="50px" mathbackground="red"/></menclose>
</math>
</div>
then on the same page, use
<div style="position: absolute; top: 20px; left; 20px">
<math>
<mspace height="100px" depth="100px"/>
???
</math>
</div>
where ??? are <mspace> rectangles (with a mathbackground) positioned with <mpadded> at the places you expect to see your phasorangle lines (i.e. on the left and at the bottom). So your rectangles should hide the phasorangle lines. The <mspace height="100px" depth="100px"/> ensures that the two <math> elements have the same height.
This means that if you copy this in a phasorangle-ref.html page and just modify the color of the phasorangle lines (e.g. by using <menclose notation="phasorangle" mathcolor="red">) then the two pages should still be the same, unless the phasorangle lines are outside the area you delimited with your rectangles.
You can do something even more accurate using SVG and Javascript to hide the phasorangle lines. See the testcase for MathJax: https://github.com/mathjax/MathJax-test/tree/master/testsuite/MathMLToDisplay/Presentation/GeneralLayout/menclose
Actually, I don't think we have such tests for the other menclose notations, so that would be great if you can write tests for these notations too or import those from MathJax.
Assignee: nobody → bkrzno
Reporter | ||
Updated•11 years ago
|
Attachment #819007 -
Flags: review?(fred.wang) → feedback+
Reporter | ||
Updated•11 years ago
|
Flags: needinfo?(bkrzno)
Assignee | ||
Comment 5•11 years ago
|
||
Attachment #8371124 -
Flags: review?(fred.wang)
Assignee | ||
Comment 6•11 years ago
|
||
Hi Frédéric,
Thank you for your explanation the other day!
I hope this patch is fine now.
I will create the reftest.
Cheers,
Branko
Attachment #819007 -
Attachment is obsolete: true
Attachment #8371137 -
Flags: review?(fred.wang)
Updated•11 years ago
|
Keywords: dev-doc-needed
Reporter | ||
Comment 7•11 years ago
|
||
Comment on attachment 8371124 [details]
testcase
No need to ask review for a testcase.
Attachment #8371124 -
Flags: review?(fred.wang)
Reporter | ||
Comment 8•11 years ago
|
||
Comment on attachment 8371137 [details] [diff] [review]
patch 2
Review of attachment 8371137 [details] [diff] [review]:
-----------------------------------------------------------------
Thanks Branko. I have left some comments.
Since you use the BOTTOM notation to draw the horizontal line, I now think this will be a bit different than LONGDIV and RADICAL.
What you want is
- adding kPhasorangleWidth * mRuleThickness to dx_left to leave room for the notation (what you did)
- set the bottom metrics (ink and logical). This will be automatically be done by the BOTTOM notation.
- update the top metrics if necessary. You can only compute it once you have the final logical bottom. Then it is obtained by moving up from the bottom by the angled line height (2 * kPhasorangleWidth * mRuleThickness).
::: layout/mathml/nsMathMLmencloseFrame.cpp
@@ +289,5 @@
> + if (IsToDraw(NOTATION_PHASORANGLE)) {
> + DisplayNotation(aBuilder, this, mencloseRect, aLists,
> + mRuleThickness, NOTATION_PHASORANGLE);
> + }
> +
The empty lines should not contain whitespace.
Please verify the indentation level of content of the if statement. See https://developer.mozilla.org/en-US/docs/Developer_Guide/Coding_Style
@@ +447,5 @@
> + phasorangleAscent);
> + mBoundingMetrics.descent = std::max(mBoundingMetrics.descent,
> + phasorangleDescent);
> + }
> + }
The computation of the vertical metrics might be a bit different (see my initial comment). I suspect this should be adapted and moved below.
@@ +644,1 @@
> mBoundingMetrics.ascent = aDesiredSize.TopAscent();
I don't think that's appropriate to do that for NOTATION_PHASORANGLE since we don't have "top" notation. I think you will need to compute the vertical metrics differently (see my initial comment).
@@ +651,5 @@
> IsToDraw(NOTATION_DOWNDIAGONALSTRIKE) ||
> IsToDraw(NOTATION_VERTICALSTRIKE) ||
> IsToDraw(NOTATION_CIRCLE) ||
> + IsToDraw(NOTATION_ROUNDEDBOX) ||
> + IsToDraw(NOTATION_PHASORANGLE))
This is redundant since you set NOTATION_BOTTOM above.
@@ +850,5 @@
> + // that uses a slope of 2 (angle = tan^-1(2)).
> + // H = w * tan(angle) = w * 2
> +
> + gfxFloat H = rect.Height();
> + gfxFloat w = .5*H;
there should be space around the * operator.
It's possible that the height of the frame is no longer the one you originally computed so you won't get the desired slope (try notation="phasorangle top circle"). I think what you want is
w = gfxFloat(kPhasorangleWidth) * e;
and H = 2 * w
then the line is now from rect.BottomLeft() to rect.BottomLeft() - gfxPoint(w, H)
(note that you actually didn't use H in your code)
@@ +859,5 @@
> + gfxCtx->Stroke();
> +
> + }
> + break;
> +
Please remove the whitespace at the end of lines (https://developer.mozilla.org/en-US/docs/Developer_Guide/Coding_Style#Whitespace) and put the break inside the braces (https://developer.mozilla.org/en-US/docs/Developer_Guide/Coding_Style#Control_Structures)
Attachment #8371137 -
Flags: review?(fred.wang) → review-
Reporter | ||
Comment 9•11 years ago
|
||
Note: alternatively, if you don't want to use the BOTTOM line and do as radical/longdiv, you will need to call DisplayBar to draw the bottom line. And the coordinates of the angled line should be computed from the position of that bar rather than from the bottom of the frame.
Assignee | ||
Comment 10•11 years ago
|
||
Thanks for the comments, Frédéric. I have added another patch.
Attachment #8371137 -
Attachment is obsolete: true
Attachment #8376743 -
Flags: review?(fred.wang)
Reporter | ||
Comment 11•11 years ago
|
||
Comment on attachment 8376743 [details] [diff] [review]
menclose-phasorangle-v3.patch
Review of attachment 8376743 [details] [diff] [review]:
-----------------------------------------------------------------
Thanks Branko. That's almost ready.
For the reftests, cf bug 963453 and those already available in http://mxr.mozilla.org/mozilla-central/source/layout/reftests/mathml/
::: layout/mathml/nsMathMLmencloseFrame.cpp
@@ +431,5 @@
> +
> + // Update horizontal parameters
> + dx_left = std::max(dx_left, phasorangleWidth);
> + }
> +
No need for this empty line before the "Update horizontal parameters" comment. Also please check the alignment and remove extra trailing space at the end of lines (in other places too).
@@ +638,5 @@
>
> + // phasorangle notation:
> + // move up from the bottom by the angled line height
> + if (IsToDraw(NOTATION_PHASORANGLE) && !aWidthOnly)
> + mBoundingMetrics.ascent = 2 * kPhasorangleWidth * mRuleThickness - mBoundingMetrics.descent;
So I think this should be
mBoundingMetrics.ascent = std::max(mBoundingMetrics.ascent, 2 * kPhasorangleWidth * mRuleThickness - mBoundingMetrics.descent)
to take into account other notations with larger ascent.
Also, don't bother testing aWidthOnly. If we are only measuring the width, mBoundingMetrics.ascent will be set with irrelevant value but won't be used anyway.
Attachment #8376743 -
Flags: review?(fred.wang) → feedback+
Reporter | ||
Comment 12•11 years ago
|
||
I'm cc'ing Anuj since he worked on menclose tests.
Assignee | ||
Comment 13•11 years ago
|
||
Thanks, Frédéric. Updated patch.
Attachment #8376743 -
Attachment is obsolete: true
Attachment #8378654 -
Flags: review?(fred.wang)
Assignee | ||
Comment 14•11 years ago
|
||
Oooups, I have just noticed the misalignment in the patch v4. It was aligned properly on my system. I had a tab char there which was differently interpreted. OK, I have fixed it now. Patch v5.
Attachment #8378654 -
Attachment is obsolete: true
Attachment #8378654 -
Flags: review?(fred.wang)
Attachment #8378674 -
Flags: review?(fred.wang)
Reporter | ||
Comment 15•11 years ago
|
||
Comment on attachment 8378674 [details] [diff] [review]
patch v5
Review of attachment 8378674 [details] [diff] [review]:
-----------------------------------------------------------------
OK, that looks good, thanks. Would you mind waiting that bug 963453 is fixed (hopefully soon) and update your patch again. I think it would be best to combine the != test menclose-1r with a == test menclose-2-phasorangle (you can already start to write such a reftest). I'll then submit your patch to try server.
Attachment #8378674 -
Flags: review?(fred.wang) → review+
Reporter | ||
Comment 16•11 years ago
|
||
@Branko: now that bug 963453 is fixed, can you try to write menclose2-* menclose-5, menclose-6 tests for phasorangle?
Flags: needinfo?(bkrzno)
Comment 17•11 years ago
|
||
@fredw: Any updates here?
Comment 18•11 years ago
|
||
This is the patch for menclose 5 and menclose 6 tests. Please review.
Attachment #8400513 -
Flags: review?(fred.wang)
Reporter | ||
Comment 19•11 years ago
|
||
Comment on attachment 8400513 [details] [diff] [review]
phasorangle.patch
Review of attachment 8400513 [details] [diff] [review]:
-----------------------------------------------------------------
The tests look good. However, your patch is weird: the menclose-5-phasorangle.html and menclose-6-phasorangle.html are marked as deletion and reftest.list is marked as a new file.
Could you try to use to get a proper format:
https://developer.mozilla.org/en-US/docs/Mercurial_Queues
You could import Branko's patch and either directly do the modifications or create a separate patch on top of it.
Also, could you try to write a menclose-2-phasorangle test (see what Anuj did for the other notations).
Attachment #8400513 -
Flags: review?(fred.wang) → feedback+
Comment 20•11 years ago
|
||
Submitting revised patch with added menclose-2 tests. Please review.
Thank you.
Aniket.
Attachment #8409780 -
Flags: review?(fred.wang)
Reporter | ||
Comment 21•11 years ago
|
||
Comment on attachment 8409780 [details] [diff] [review]
Revised patch
Review of attachment 8409780 [details] [diff] [review]:
-----------------------------------------------------------------
The patch seems to delete menclose-6-ref.html...
I think you don't need to add menclose-6-phasorangle-ref.html, but instead just reuse the existing menclose-6-ref.html.
::: layout/reftests/mathml/menclose-2-phasorangle.html
@@ +8,5 @@
> + {
> + var box = document.getElementById("box").getBoundingClientRect();
> + document.getElementById("path").setAttribute("d",
> + "M" + (box.left + "," + (box.top + box.bottom)/2 ) + " " +
> + "l" + (box.width + "," + (-box.height)));
I'm not sure I understand that one. This is supposed to cover the drawing of the phasorangle implemented by Branko's patch. I only see a diagonal line here.
::: layout/reftests/mathml/reftest.list
@@ +260,5 @@
> != rowlines-3-1.html rowlines-3-1-ref.html
> == rowlines-3-2.html rowlines-3-2-ref.html
> +== menclose-6-phasorangle.html menclose-6-phasorangle-ref.html
> +== menclose-5-phasorangle.html menclose-5-phasorangle-ref.html
> +== menclose-2-phasorangle.html menclose-2-phasorangle-ref.html
perhaps you can add these lines at a logical place (near the existing menclose-* tests and preserving the order)
Attachment #8409780 -
Flags: review?(fred.wang) → feedback+
Comment 22•11 years ago
|
||
Okay! Will make the said changes and will submit the patch soon!
Thank you!
Comment 23•11 years ago
|
||
Attachment #8400513 -
Attachment is obsolete: true
Attachment #8409780 -
Attachment is obsolete: true
Attachment #8419289 -
Flags: review?(fred.wang)
Reporter | ||
Updated•11 years ago
|
Attachment #8419289 -
Flags: review?(fred.wang) → review+
Comment 24•11 years ago
|
||
Attachment #8419555 -
Flags: review?(fred.wang)
Reporter | ||
Comment 25•11 years ago
|
||
Comment on attachment 8419555 [details] [diff] [review]
added menclose notation phasorangle with reftest
Review of attachment 8419555 [details] [diff] [review]:
-----------------------------------------------------------------
thanks
Attachment #8419555 -
Flags: review?(fred.wang) → review+
Reporter | ||
Updated•11 years ago
|
Attachment #8419289 -
Attachment is obsolete: true
Reporter | ||
Updated•11 years ago
|
Attachment #8378674 -
Attachment is obsolete: true
Reporter | ||
Updated•11 years ago
|
Flags: needinfo?(bkrzno)
Reporter | ||
Comment 26•11 years ago
|
||
Reporter | ||
Comment 27•11 years ago
|
||
@Anuj: it seems that there are a few test failures for the phasorangle test. As usual, we probably want to increase a bit the length and thickness of the bar, as necessary.
Flags: needinfo?(anujagarwal464)
Comment 28•11 years ago
|
||
(In reply to Frédéric Wang (:fredw) from comment #27)
> @Anuj: it seems that there are a few test failures for the phasorangle test.
> As usual, we probably want to increase a bit the length and thickness of the
> bar, as necessary.
Tests are failing on Android Build and B2G ICS Emulator Opt, I think we should mark them fails-if.
Flags: needinfo?(fred.wang)
Reporter | ||
Comment 29•11 years ago
|
||
(In reply to Anuj Agarwal [:anujagarwal464] from comment #28)
> Tests are failing on Android Build and B2G ICS Emulator Opt, I think we
> should mark them fails-if.
Did you try to use the reftest-analyser? I checked a few of them and I only saw small pixel diffs due to antialiasing. So increasing a bit the length/thickness should work in these cases.
Flags: needinfo?(fred.wang)
Comment 30•11 years ago
|
||
B2G ICS Emulator Opt
> max difference: 255, number of differing pixels: 81
Increased the stroke width and length of sloped line.
Attachment #8419555 -
Attachment is obsolete: true
Flags: needinfo?(anujagarwal464)
Comment 31•11 years ago
|
||
By mistake uploaded old patch.
Attachment #8420491 -
Attachment is obsolete: true
Reporter | ||
Comment 32•11 years ago
|
||
https://tbpl.mozilla.org/?tree=Try&rev=b8cd25bbe94f
For this and bug 848725, see https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Committing_Rules_and_Responsibilities#Checkin_comment for commit message format.
Reporter | ||
Comment 33•11 years ago
|
||
Still seems to fail on B2G ICS Emulator Opt.
The problem seems to be that the rulethicness is > 1 so the length of the sloped line is larger. Perhaps you should do w = 8 * 2 to be less strict.
Comment 34•11 years ago
|
||
Attachment #8420492 -
Attachment is obsolete: true
Attachment #8420619 -
Flags: review?(fred.wang)
Reporter | ||
Updated•11 years ago
|
Attachment #8420619 -
Flags: review?(fred.wang) → review+
Reporter | ||
Comment 35•11 years ago
|
||
Reporter | ||
Comment 36•11 years ago
|
||
Trying with stroke-width=5px:
https://tbpl.mozilla.org/?tree=Try&rev=dae2a679d2aa
Updated•11 years ago
|
Keywords: checkin-needed
Comment 38•11 years ago
|
||
Keywords: checkin-needed
Comment 39•11 years ago
|
||
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla32
Updated•11 years ago
|
Flags: in-testsuite+
Reporter | ||
Comment 40•11 years ago
|
||
https://developer.mozilla.org/en-US/Firefox/Releases/32
https://developer.mozilla.org/en-US/docs/Web/MathML/Element/menclose
You need to log in
before you can comment on or make changes to this bug.
Description
•