Title: [259785] trunk/Source/WebCore
Revision
259785
Author
[email protected]
Date
2020-04-09 00:57:16 -0700 (Thu, 09 Apr 2020)

Log Message

Remove unnecessary explicit parsing for mo@maxsize value "infinity"
https://bugs.webkit.org/show_bug.cgi?id=202720

Patch by Delan Azabani <[email protected]> on 2020-04-09
Reviewed by Frédéric Wang.

In MathML 2, the default mo@maxsize was infinity [1], unless some other
default was given by mstyle@maxsize [2]. The sole purpose of "infinity"
was to give authors a way to set mo@maxsize to infinity when some other
mstyle@maxsize was set.

MathML Core removes mstyle@maxsize [3][4], such that "infinity" has the
same semantics as any other missing or invalid mo@maxsize, so the spec
has been simplified to make infinity an anonymous value [5][6].

No functional change, because WebKit has never supported mstyle@maxsize
anyway. To verify that there's no functional change:

1.  Search for references to LengthType::Infinity, and observe that the
    mo@maxsize parser in MathMLOperatorElement::maxSize is the only
    place where a Length of ::type infinity is created
2.  Search for references to that method, and observe that the only
    caller (RenderMathMLOperator::maxSize) passes intMaxForLayoutUnit
    (infinity) to toUserUnits as the referenceValue
3.  Go to the definition of toUserUnits, and observe that the refer-
    enceValue is used as the ParsingFailed default
4.  Step 1 shows that no other attributes would be affected by removing
    LengthType::Infinity, and steps 2 and 3 show that mo@maxsize treats
    invalid values as infinity, therefore it's safe to remove both the
    "infinity" parsing code and the underlying LengthType variant

[1] https://www.w3.org/TR/MathML2/chapter3.html#id.3.2.5.2
[2] https://www.w3.org/TR/MathML2/chapter3.html#presm.mstyle
[3] https://mathml-refresh.github.io/mathml-core/#style-change-mstyle
[4] https://github.com/mathml-refresh/mathml/issues/1
[5] https://mathml-refresh.github.io/mathml-core/#dictionary-based-attributes
[6] https://github.com/mathml-refresh/mathml/issues/107

No new tests, because no functional change.

* mathml/MathMLElement.h: Remove LengthType::Infinity.
* mathml/MathMLOperatorElement.cpp:
(WebCore::MathMLOperatorElement::maxSize): Remove explicit branch on "infinity". Replace what remains with an equivalent cachedMathMLLength call.
* rendering/mathml/RenderMathMLBlock.cpp:
(WebCore::toUserUnits): Remove explicit branch on LengthType::Infinity.
* rendering/mathml/RenderMathMLOperator.cpp:
(WebCore::RenderMathMLOperator::maxSize): Update comment to refer to the default value in the same way as the spec.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (259784 => 259785)


--- trunk/Source/WebCore/ChangeLog	2020-04-09 07:34:46 UTC (rev 259784)
+++ trunk/Source/WebCore/ChangeLog	2020-04-09 07:57:16 UTC (rev 259785)
@@ -1,3 +1,52 @@
+2020-04-09  Delan Azabani  <[email protected]>
+
+        Remove unnecessary explicit parsing for mo@maxsize value "infinity"
+        https://bugs.webkit.org/show_bug.cgi?id=202720
+
+        Reviewed by Frédéric Wang.
+
+        In MathML 2, the default mo@maxsize was infinity [1], unless some other
+        default was given by mstyle@maxsize [2]. The sole purpose of "infinity"
+        was to give authors a way to set mo@maxsize to infinity when some other
+        mstyle@maxsize was set.
+
+        MathML Core removes mstyle@maxsize [3][4], such that "infinity" has the
+        same semantics as any other missing or invalid mo@maxsize, so the spec
+        has been simplified to make infinity an anonymous value [5][6].
+
+        No functional change, because WebKit has never supported mstyle@maxsize
+        anyway. To verify that there's no functional change:
+
+        1.  Search for references to LengthType::Infinity, and observe that the
+            mo@maxsize parser in MathMLOperatorElement::maxSize is the only
+            place where a Length of ::type infinity is created
+        2.  Search for references to that method, and observe that the only
+            caller (RenderMathMLOperator::maxSize) passes intMaxForLayoutUnit
+            (infinity) to toUserUnits as the referenceValue
+        3.  Go to the definition of toUserUnits, and observe that the refer-
+            enceValue is used as the ParsingFailed default
+        4.  Step 1 shows that no other attributes would be affected by removing
+            LengthType::Infinity, and steps 2 and 3 show that mo@maxsize treats
+            invalid values as infinity, therefore it's safe to remove both the
+            "infinity" parsing code and the underlying LengthType variant
+
+        [1] https://www.w3.org/TR/MathML2/chapter3.html#id.3.2.5.2
+        [2] https://www.w3.org/TR/MathML2/chapter3.html#presm.mstyle
+        [3] https://mathml-refresh.github.io/mathml-core/#style-change-mstyle
+        [4] https://github.com/mathml-refresh/mathml/issues/1
+        [5] https://mathml-refresh.github.io/mathml-core/#dictionary-based-attributes
+        [6] https://github.com/mathml-refresh/mathml/issues/107
+
+        No new tests, because no functional change.
+
+        * mathml/MathMLElement.h: Remove LengthType::Infinity.
+        * mathml/MathMLOperatorElement.cpp:
+        (WebCore::MathMLOperatorElement::maxSize): Remove explicit branch on "infinity". Replace what remains with an equivalent cachedMathMLLength call.
+        * rendering/mathml/RenderMathMLBlock.cpp:
+        (WebCore::toUserUnits): Remove explicit branch on LengthType::Infinity.
+        * rendering/mathml/RenderMathMLOperator.cpp:
+        (WebCore::RenderMathMLOperator::maxSize): Update comment to refer to the default value in the same way as the spec.
+
 2020-04-08  Chris Dumez  <[email protected]>
 
         querySelector("#\u0000") should match an element with ID U+FFFD

Modified: trunk/Source/WebCore/mathml/MathMLElement.h (259784 => 259785)


--- trunk/Source/WebCore/mathml/MathMLElement.h	2020-04-09 07:34:46 UTC (rev 259784)
+++ trunk/Source/WebCore/mathml/MathMLElement.h	2020-04-09 07:57:16 UTC (rev 259785)
@@ -52,7 +52,7 @@
     // MathML lengths (https://www.w3.org/TR/MathML3/chapter2.html#fund.units)
     // TeX's Math Unit is used internally for named spaces (1 mu = 1/18 em).
     // Unitless values are interpreted as a multiple of a reference value.
-    enum class LengthType { Cm, Em, Ex, In, MathUnit, Mm, ParsingFailed, Pc, Percentage, Pt, Px, UnitLess, Infinity };
+    enum class LengthType { Cm, Em, Ex, In, MathUnit, Mm, ParsingFailed, Pc, Percentage, Pt, Px, UnitLess };
     struct Length {
         LengthType type { LengthType::ParsingFailed };
         float value { 0 };

Modified: trunk/Source/WebCore/mathml/MathMLOperatorElement.cpp (259784 => 259785)


--- trunk/Source/WebCore/mathml/MathMLOperatorElement.cpp	2020-04-09 07:34:46 UTC (rev 259784)
+++ trunk/Source/WebCore/mathml/MathMLOperatorElement.cpp	2020-04-09 07:57:16 UTC (rev 259785)
@@ -198,18 +198,7 @@
 
 const MathMLElement::Length& MathMLOperatorElement::maxSize()
 {
-    if (m_maxSize)
-        return m_maxSize.value();
-
-    const AtomString& value = attributeWithoutSynchronization(MathMLNames::maxsizeAttr);
-    if (value == "infinity") {
-        Length maxsize;
-        maxsize.type = LengthType::Infinity;
-        m_maxSize = maxsize;
-    } else
-        m_maxSize = parseMathMLLength(value);
-
-    return m_maxSize.value();
+    return cachedMathMLLength(MathMLNames::maxsizeAttr, m_maxSize);
 }
 
 void MathMLOperatorElement::childrenChanged(const ChildChange& change)

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLBlock.cpp (259784 => 259785)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLBlock.cpp	2020-04-09 07:34:46 UTC (rev 259784)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLBlock.cpp	2020-04-09 07:57:16 UTC (rev 259785)
@@ -170,8 +170,6 @@
         return LayoutUnit(referenceValue * length.value);
     case MathMLElement::LengthType::ParsingFailed:
         return referenceValue;
-    case MathMLElement::LengthType::Infinity:
-        return intMaxForLayoutUnit;
     default:
         ASSERT_NOT_REACHED();
         return referenceValue;

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp (259784 => 259785)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp	2020-04-09 07:34:46 UTC (rev 259784)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp	2020-04-09 07:57:16 UTC (rev 259785)
@@ -107,7 +107,7 @@
 
 LayoutUnit RenderMathMLOperator::maxSize() const
 {
-    LayoutUnit maxSize = intMaxForLayoutUnit; // Default maxsize is "infinity".
+    LayoutUnit maxSize = intMaxForLayoutUnit; // Default maxsize is ∞.
     maxSize = toUserUnits(element().maxSize(), style(), maxSize);
     return std::max<LayoutUnit>(0, maxSize);
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to