Closed Bug 1790009 Opened 3 years ago Closed 3 years ago

Implement special handling for operators using U+0338 and U+20D2

Categories

(Core :: MathML, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
107 Branch
Tracking Status
firefox107 --- fixed

People

(Reporter: fredw, Assigned: fredw)

References

(Blocks 2 open bugs)

Details

Attachments

(3 files, 1 obsolete file)

After bug 1789583, I noticed we still have many obsolete entries for "negation" operators.

egrep 'u0338|u20D2' layout/mathml/mathfont.properties
operator.\u003C\u20D2.infix = lspace:5 rspace:5 # <⃒
operator.\u003E\u20D2.infix = lspace:5 rspace:5 # >⃒
operator.\u2242\u0338.infix = lspace:5 rspace:5 # ≂̸
operator.\u224E\u0338.infix = lspace:5 rspace:5 # ≎̸
operator.\u224F\u0338.infix = lspace:5 rspace:5 # ≏̸
operator.\u2266\u0338.infix = lspace:5 rspace:5 # ≧̸
operator.\u226A\u0338.infix = lspace:5 rspace:5 # ≪̸
operator.\u226B\u0338.infix = lspace:5 rspace:5 # ≫̸
operator.\u227F\u0338.infix = lspace:5 rspace:5 # ≿̸
operator.\u2282\u20D2.infix = lspace:5 rspace:5 # subset of with vertical line
operator.\u2283\u20D2.infix = lspace:5 rspace:5 # superset of with vertical line
operator.\u228F\u0338.infix = lspace:5 rspace:5 # ⊏̸
operator.\u2290\u0338.infix = lspace:5 rspace:5 # ⊐̸
operator.\u29CF\u0338.infix = lspace:5 rspace:5 # ⧏̸
operator.\u29D0\u0338.infix = lspace:5 rspace:5 # ⧐̸
operator.\u2A7D\u0338.infix = lspace:5 rspace:5 # ⩽̸
operator.\u2A7E\u0338.infix = lspace:5 rspace:5 # ⩾̸
operator.\u2AA1\u0338.infix = lspace:5 rspace:5 # ⪡̸
operator.\u2AA2\u0338.infix = lspace:5 rspace:5 # ⪢̸
operator.\u2AAF\u0338.infix = lspace:5 rspace:5 # ⪯̸
operator.\u2AB0\u0338.infix = lspace:5 rspace:5 # ⪰̸
operator.\u2AC5\u0338.infix = lspace:5 rspace:5 # ⫅̸
operator.\u2AC6\u0338.infix = lspace:5 rspace:5 # ⫅̸
operator.\u2ADD\u0338.infix = lspace:5 rspace:5 # nonforking with slash

I believe they can just be removed once we implement the thing from MathML Core:

If the second character is U+0338 COMBINING LONG SOLIDUS OVERLAY or U+20D2 COMBINING LONG VERTICAL LINE OVERLAY then replace Content with the first character and move to step 3.

https://w3c.github.io/mathml-core/#dfn-algorithm-to-determine-the-category-of-an-operator

nsMathMLOperators::LookupOperators(s) methods are currently use in three
places:

(1) In nsMathMLmoFrame::ProcessTextData(), where we need to check the
flags for each form of the operator and take the bitwise-or of all
of them, ignoring lspace/rspace.

(2) In nsMathMLOperators::GetStretchyDirection::ProcessTextData(), where
we need to check the direction for each form of the operator (in any
order) and return the first found, ignoring lspace/rspace.

(3) In nsMathMLmoFrame::ProcessOperatorData, where need to check the
specified form, and try fallback forms in the order prefix, postfix,
infix. When an entry is found, the code also clears the form bits of
mFlags and bitwise-or the found flags.

This commit modifies nsMathMLOperators::LookupOperator to only check
one form at once and can be used to easily implement (1) and (2). This
removes the need for nsMathMLOperators::LookupOperators.

A new method nsMathMLOperators::LookupOperatorWithFallback is introduced
to preserve the fallback prefix/postfix/infix check that is needed for
(3). Undocumented bitwise logic is moved out of that method.

MathML Core specifies that operators containing a UTF-16 strings whose
length is not 1 or 2 should use the default properties [1]. This
commit removes the obsolete strings of length 3 from our operator
dictionary and tweak updateOperatorDictionary.pl to ensure it only
accepts strings of 1 or 2 characters. This also adds an early return
in LookupOperator to immediately fallback to default properties.

[1] https://w3c.github.io/mathml-core/#dfn-algorithm-to-determine-the-category-of-an-operator

MathML Core specifies that operators containing a UTF-16 strings of
length 2 ending with U+0338 COMBINING LONG SOLIDUS OVERLAY or U+20D2
COMBINING LONG VERTICAL LINE OVERLAY should just use the properties of
the first character. This commit implements that behavior. It removes
obsolete entries that are superseded by this rule and modifies
updateOperatorDictionary.pl to ensure that no such entries are present.

Existing WPT test operator-dictionary-combining.html is already passing
after bug 1789583 because the operators tested use the default spacing.
So extend it to try operators with different spacing.

[1] https://w3c.github.io/mathml-core/#dfn-algorithm-to-determine-the-category-of-an-operator

Attachment #9294434 - Attachment is obsolete: true
Assignee: nobody → fwang
Attachment #9295377 - Attachment description: WIP: Bug 1790009, part 1: Refactor nsMathMLOperators::LookupOperator(s). r=emilio → Bug 1790009, part 1: Refactor nsMathMLOperators::LookupOperator(s). r=emilio
Status: NEW → ASSIGNED
Attachment #9295378 - Attachment description: WIP: Bug 1790009, part 2 - Operator dictionary: Only accept UTF-16 strings of 1 or 2 characters. r=emilio → Bug 1790009, part 2 - Operator dictionary: Only accept UTF-16 strings of 1 or 2 characters. r=emilio
Attachment #9295379 - Attachment description: WIP: Bug 1790009, part 3 - Implement special handling for operators using U+0338 and U+20D2. r=emilio → Bug 1790009, part 3 - Implement special handling for operators using U+0338 and U+20D2. r=emilio
Pushed by fred.wang@free.fr: https://hg.mozilla.org/integration/autoland/rev/90ee5367d506 part 1: Refactor nsMathMLOperators::LookupOperator(s). r=emilio https://hg.mozilla.org/integration/autoland/rev/236e1d9535ed part 2 - Operator dictionary: Only accept UTF-16 strings of 1 or 2 characters. r=emilio https://hg.mozilla.org/integration/autoland/rev/73ff5b4bf98c part 3 - Implement special handling for operators using U+0338 and U+20D2. r=emilio
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/35990 for changes under testing/web-platform/tests
Upstream PR was closed without merging

This seems to be an existing problem in mathfonts.properties (not one added by my patches) since it uses double-quote and three periods in comments. I guess the easiest approach for now is to add it to the exception list for now. Hopefully we can get rid of this file in the future...

Flags: needinfo?(fwang)

I stand corrected, there is already an exception for mathfont.properties, but we can remove it now:

{
file: "mathfont.properties",
key: "operator.\u002E\u002E\u002E.postfix",
type: "ellipsis",
},

Pushed by fred.wang@free.fr: https://hg.mozilla.org/integration/autoland/rev/d1d90ef37546 part 1: Refactor nsMathMLOperators::LookupOperator(s). r=emilio https://hg.mozilla.org/integration/autoland/rev/c11bfdb26abb part 2 - Operator dictionary: Only accept UTF-16 strings of 1 or 2 characters. r=emilio https://hg.mozilla.org/integration/autoland/rev/35725e846f2e part 3 - Implement special handling for operators using U+0338 and U+20D2. r=emilio
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 107 Branch
Upstream PR merged by moz-wptsync-bot
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: