⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 259785 in webkit


Ignore:
Timestamp:
Apr 9, 2020, 12:57:16 AM (6 years ago)
Author:
commit-queue@webkit.org
Message:

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

Patch by Delan Azabani <dazabani@igalia.com> 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

  1. Search for references to that method, and observe that the only

caller (RenderMathMLOperator::maxSize) passes intMaxForLayoutUnit
(infinity) to toUserUnits as the referenceValue

  1. Go to the definition of toUserUnits, and observe that the refer-

enceValue is used as the ParsingFailed default

  1. 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.

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r259773 r259785  
     12020-04-09  Delan Azabani  <dazabani@igalia.com>
     2
     3        Remove unnecessary explicit parsing for mo@maxsize value "infinity"
     4        https://bugs.webkit.org/show_bug.cgi?id=202720
     5
     6        Reviewed by Frédéric Wang.
     7
     8        In MathML 2, the default mo@maxsize was infinity [1], unless some other
     9        default was given by mstyle@maxsize [2]. The sole purpose of "infinity"
     10        was to give authors a way to set mo@maxsize to infinity when some other
     11        mstyle@maxsize was set.
     12
     13        MathML Core removes mstyle@maxsize [3][4], such that "infinity" has the
     14        same semantics as any other missing or invalid mo@maxsize, so the spec
     15        has been simplified to make infinity an anonymous value [5][6].
     16
     17        No functional change, because WebKit has never supported mstyle@maxsize
     18        anyway. To verify that there's no functional change:
     19
     20        1.  Search for references to LengthType::Infinity, and observe that the
     21            mo@maxsize parser in MathMLOperatorElement::maxSize is the only
     22            place where a Length of ::type infinity is created
     23        2.  Search for references to that method, and observe that the only
     24            caller (RenderMathMLOperator::maxSize) passes intMaxForLayoutUnit
     25            (infinity) to toUserUnits as the referenceValue
     26        3.  Go to the definition of toUserUnits, and observe that the refer-
     27            enceValue is used as the ParsingFailed default
     28        4.  Step 1 shows that no other attributes would be affected by removing
     29            LengthType::Infinity, and steps 2 and 3 show that mo@maxsize treats
     30            invalid values as infinity, therefore it's safe to remove both the
     31            "infinity" parsing code and the underlying LengthType variant
     32
     33        [1] https://www.w3.org/TR/MathML2/chapter3.html#id.3.2.5.2
     34        [2] https://www.w3.org/TR/MathML2/chapter3.html#presm.mstyle
     35        [3] https://mathml-refresh.github.io/mathml-core/#style-change-mstyle
     36        [4] https://github.com/mathml-refresh/mathml/issues/1
     37        [5] https://mathml-refresh.github.io/mathml-core/#dictionary-based-attributes
     38        [6] https://github.com/mathml-refresh/mathml/issues/107
     39
     40        No new tests, because no functional change.
     41
     42        * mathml/MathMLElement.h: Remove LengthType::Infinity.
     43        * mathml/MathMLOperatorElement.cpp:
     44        (WebCore::MathMLOperatorElement::maxSize): Remove explicit branch on "infinity". Replace what remains with an equivalent cachedMathMLLength call.
     45        * rendering/mathml/RenderMathMLBlock.cpp:
     46        (WebCore::toUserUnits): Remove explicit branch on LengthType::Infinity.
     47        * rendering/mathml/RenderMathMLOperator.cpp:
     48        (WebCore::RenderMathMLOperator::maxSize): Update comment to refer to the default value in the same way as the spec.
     49
    1502020-04-08  Chris Dumez  <cdumez@apple.com>
    251
  • trunk/Source/WebCore/mathml/MathMLElement.h

    r248931 r259785  
    5353    // TeX's Math Unit is used internally for named spaces (1 mu = 1/18 em).
    5454    // Unitless values are interpreted as a multiple of a reference value.
    55     enum class LengthType { Cm, Em, Ex, In, MathUnit, Mm, ParsingFailed, Pc, Percentage, Pt, Px, UnitLess, Infinity };
     55    enum class LengthType { Cm, Em, Ex, In, MathUnit, Mm, ParsingFailed, Pc, Percentage, Pt, Px, UnitLess };
    5656    struct Length {
    5757        LengthType type { LengthType::ParsingFailed };
  • trunk/Source/WebCore/mathml/MathMLOperatorElement.cpp

    r246490 r259785  
    199199const MathMLElement::Length& MathMLOperatorElement::maxSize()
    200200{
    201     if (m_maxSize)
    202         return m_maxSize.value();
    203 
    204     const AtomString& value = attributeWithoutSynchronization(MathMLNames::maxsizeAttr);
    205     if (value == "infinity") {
    206         Length maxsize;
    207         maxsize.type = LengthType::Infinity;
    208         m_maxSize = maxsize;
    209     } else
    210         m_maxSize = parseMathMLLength(value);
    211 
    212     return m_maxSize.value();
     201    return cachedMathMLLength(MathMLNames::maxsizeAttr, m_maxSize);
    213202}
    214203
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLBlock.cpp

    r245543 r259785  
    171171    case MathMLElement::LengthType::ParsingFailed:
    172172        return referenceValue;
    173     case MathMLElement::LengthType::Infinity:
    174         return intMaxForLayoutUnit;
    175173    default:
    176174        ASSERT_NOT_REACHED();
  • trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp

    r245543 r259785  
    108108LayoutUnit RenderMathMLOperator::maxSize() const
    109109{
    110     LayoutUnit maxSize = intMaxForLayoutUnit; // Default maxsize is "infinity".
     110    LayoutUnit maxSize = intMaxForLayoutUnit; // Default maxsize is .
    111111    maxSize = toUserUnits(element().maxSize(), style(), maxSize);
    112112    return std::max<LayoutUnit>(0, maxSize);
Note: See TracChangeset for help on using the changeset viewer.