Title: [204022] trunk/Source/WebCore
Revision
204022
Author
[email protected]
Date
2016-08-02 04:27:19 -0700 (Tue, 02 Aug 2016)

Log Message

Move parsing of the form attribute to MathMLOperatorElement
https://bugs.webkit.org/show_bug.cgi?id=160239

Patch by Frederic Wang <[email protected]> on 2016-07-28
Reviewed by Darin Adler.

We move the parsing of the mo@form attribute to the MathMLOperatorElement class. Note that
when the attribute is not explicit, the form may also be guessed by searching into the
operator dictionary. Hence we also start moving the determination of the default dictionary
properties. Moving the actual parsing of the corresponding attributes will be done in
follow-up commits.

No new tests, already covered by existing tests.

* mathml/MathMLInlineContainerElement.cpp:
(WebCore::MathMLInlineContainerElement::childrenChanged): Make the form of operators dirty
if its siblings have changed.
* mathml/MathMLOperatorDictionary.cpp:
(WebCore::MathMLOperatorDictionary::search): Merge old getEntry functions into one helper
function that returns an Optional<Entry>.
(WebCore::MathMLOperatorDictionary::getEntry): Deleted
* mathml/MathMLOperatorDictionary.h: Declare MathMLOperatorDictionary::find.
* mathml/MathMLOperatorElement.cpp:
(WebCore::MathMLOperatorElement::dictionaryProperty): We determine the operator form by
parsing the corresponding attribute or by using heuristics if that attribute is not
specified. We also read dictionary the corresponding dictionary properties.
(WebCore::MathMLOperatorElement::flags): Return the flags read from the dictionary.
(WebCore::MathMLOperatorElement::defaultLeadingSpace): Return the space read from the dictionary.
(WebCore::MathMLOperatorElement::defaultTrailingSpace): Return the space read from the dictionary.
(WebCore::MathMLOperatorElement::childrenChanged): Make the dictionary properties dirty.
(WebCore::MathMLOperatorElement::parseAttribute): Make the dictionary properties dirty when
the form changes.
* mathml/MathMLOperatorElement.h: New member to store dictionary properties and expose them.
* rendering/mathml/RenderMathMLFencedOperator.cpp:
(WebCore::RenderMathMLFencedOperator::setOperatorProperties): We implement the case specific
to anonymous mfenced operators here.
* rendering/mathml/RenderMathMLFencedOperator.h: Move the m_operatorForm member here and
declare the overriden function setOperatorProperties.
* rendering/mathml/RenderMathMLOperator.cpp:
(WebCore::RenderMathMLOperator::setOperatorProperties): Simplify this code since the logic
has been moved to the element classes.
(WebCore::RenderMathMLOperator::setOperatorPropertiesFromOpDictEntry): Deleted.
* rendering/mathml/RenderMathMLOperator.h: Remove setOperatorPropertiesFromOpDictEntry, make
members accessible to RenderMathMLFencedOperator and remove m_operatorForm.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (204021 => 204022)


--- trunk/Source/WebCore/ChangeLog	2016-08-02 09:43:01 UTC (rev 204021)
+++ trunk/Source/WebCore/ChangeLog	2016-08-02 11:27:19 UTC (rev 204022)
@@ -1,3 +1,49 @@
+2016-07-28  Frederic Wang  <[email protected]>
+
+        Move parsing of the form attribute to MathMLOperatorElement
+        https://bugs.webkit.org/show_bug.cgi?id=160239
+
+        Reviewed by Darin Adler.
+
+        We move the parsing of the mo@form attribute to the MathMLOperatorElement class. Note that
+        when the attribute is not explicit, the form may also be guessed by searching into the
+        operator dictionary. Hence we also start moving the determination of the default dictionary
+        properties. Moving the actual parsing of the corresponding attributes will be done in
+        follow-up commits.
+
+        No new tests, already covered by existing tests.
+
+        * mathml/MathMLInlineContainerElement.cpp:
+        (WebCore::MathMLInlineContainerElement::childrenChanged): Make the form of operators dirty
+        if its siblings have changed.
+        * mathml/MathMLOperatorDictionary.cpp:
+        (WebCore::MathMLOperatorDictionary::search): Merge old getEntry functions into one helper
+        function that returns an Optional<Entry>.
+        (WebCore::MathMLOperatorDictionary::getEntry): Deleted
+        * mathml/MathMLOperatorDictionary.h: Declare MathMLOperatorDictionary::find.
+        * mathml/MathMLOperatorElement.cpp:
+        (WebCore::MathMLOperatorElement::dictionaryProperty): We determine the operator form by
+        parsing the corresponding attribute or by using heuristics if that attribute is not
+        specified. We also read dictionary the corresponding dictionary properties.
+        (WebCore::MathMLOperatorElement::flags): Return the flags read from the dictionary.
+        (WebCore::MathMLOperatorElement::defaultLeadingSpace): Return the space read from the dictionary.
+        (WebCore::MathMLOperatorElement::defaultTrailingSpace): Return the space read from the dictionary.
+        (WebCore::MathMLOperatorElement::childrenChanged): Make the dictionary properties dirty.
+        (WebCore::MathMLOperatorElement::parseAttribute): Make the dictionary properties dirty when
+        the form changes.
+        * mathml/MathMLOperatorElement.h: New member to store dictionary properties and expose them.
+        * rendering/mathml/RenderMathMLFencedOperator.cpp:
+        (WebCore::RenderMathMLFencedOperator::setOperatorProperties): We implement the case specific
+        to anonymous mfenced operators here.
+        * rendering/mathml/RenderMathMLFencedOperator.h: Move the m_operatorForm member here and
+        declare the overriden function setOperatorProperties.
+        * rendering/mathml/RenderMathMLOperator.cpp:
+        (WebCore::RenderMathMLOperator::setOperatorProperties): Simplify this code since the logic
+        has been moved to the element classes.
+        (WebCore::RenderMathMLOperator::setOperatorPropertiesFromOpDictEntry): Deleted.
+        * rendering/mathml/RenderMathMLOperator.h: Remove setOperatorPropertiesFromOpDictEntry, make
+        members accessible to RenderMathMLFencedOperator and remove m_operatorForm.
+
 2016-08-02  Frederic Wang  <fwang.igalia.com>
 
         Use Optional members to store parsed MathML attributes.

Modified: trunk/Source/WebCore/mathml/MathMLInlineContainerElement.cpp (204021 => 204022)


--- trunk/Source/WebCore/mathml/MathMLInlineContainerElement.cpp	2016-08-02 09:43:01 UTC (rev 204021)
+++ trunk/Source/WebCore/mathml/MathMLInlineContainerElement.cpp	2016-08-02 11:27:19 UTC (rev 204022)
@@ -32,6 +32,7 @@
 #include "MathMLInlineContainerElement.h"
 
 #include "MathMLNames.h"
+#include "MathMLOperatorElement.h"
 #include "RenderMathMLBlock.h"
 #include "RenderMathMLFenced.h"
 #include "RenderMathMLMenclose.h"
@@ -54,6 +55,11 @@
 
 void MathMLInlineContainerElement::childrenChanged(const ChildChange& change)
 {
+    for (auto child = firstChild(); child; child = child->nextSibling()) {
+        if (child->hasTagName(MathMLNames::moTag))
+            static_cast<MathMLOperatorElement*>(child)->setOperatorFormDirty();
+    }
+
     // FIXME: Parsing of operator properties should be done in the element classes rather than in the renderer classes.
     // See https://webkit.org/b/156537
     if (renderer() && is<RenderMathMLRow>(*renderer()))

Modified: trunk/Source/WebCore/mathml/MathMLOperatorDictionary.cpp (204021 => 204022)


--- trunk/Source/WebCore/mathml/MathMLOperatorDictionary.cpp	2016-08-02 09:43:01 UTC (rev 204021)
+++ trunk/Source/WebCore/mathml/MathMLOperatorDictionary.cpp	2016-08-02 11:27:19 UTC (rev 204022)
@@ -1089,23 +1089,30 @@
     0x003D, 0x005E, 0x005F, 0x007E, 0x00AF, 0x02C6, 0x02C7, 0x02C9, 0x02CD, 0x02DC, 0x02F7, 0x0302, 0x0332, 0x203E, 0x20D0, 0x20D1, 0x20D6, 0x20D7, 0x20E1, 0x2190, 0x2192, 0x2194, 0x2198, 0x2199, 0x219C, 0x219D, 0x219E, 0x21A0, 0x21A2, 0x21A3, 0x21A4, 0x21A6, 0x21A9, 0x21AA, 0x21AB, 0x21AC, 0x21AD, 0x21B4, 0x21B9, 0x21BC, 0x21BD, 0x21C0, 0x21C1, 0x21C4, 0x21C6, 0x21C7, 0x21C9, 0x21CB, 0x21CC, 0x21D0, 0x21D2, 0x21D4, 0x21DA, 0x21DB, 0x21DC, 0x21DD, 0x21E0, 0x21E2, 0x21E4, 0x21E5, 0x21E6, 0x21E8, 0x21F0, 0x21F6, 0x21FD, 0x21FE, 0x21FF, 0x23B4, 0x23B5, 0x23DC, 0x23DD, 0x23DE, 0x23DF, 0x23E0, 0x23E1, 0x2500, 0x27F5, 0x27F6, 0x27F7, 0x27F8, 0x27F9, 0x27FA, 0x27FB, 0x27FC, 0x27FD, 0x27FE, 0x27FF, 0x290C, 0x290D, 0x290E, 0x290F, 0x2910, 0x294E, 0x2950, 0x2952, 0x2953, 0x2956, 0x2957, 0x295A, 0x295B, 0x295E, 0x295F, 0x2B45, 0x2B46, 0xFE35, 0xFE36, 0xFE37, 0xFE38
 };
 
-const Entry* MathMLOperatorDictionary::getEntry(UChar textContent, Form form)
+Optional<Entry> MathMLOperatorDictionary::search(UChar character, Form form, bool explicitForm)
 {
-    return tryBinarySearch<const Entry, Key>(dictionary, dictionarySize, Key(textContent, form), ExtractKey);
-}
+    if (!character)
+        return Nullopt;
 
-const Entry* MathMLOperatorDictionary::getEntry(UChar textContent)
-{
-    // For each operator, the dictionary has at most three form in the following order: Infix, Prefix, Postfix.
-    if (const Entry* entry = tryBinarySearch<const Entry, UChar>(dictionary, dictionarySize, textContent, ExtractChar)) {
+    // We try and find the default values from the operator dictionary.
+    if (auto* entry = tryBinarySearch<const Entry, Key>(dictionary, dictionarySize, Key(character, form), ExtractKey))
+        return *entry;
+
+    if (explicitForm)
+        return Nullopt;
+
+    // If we did not find the desired operator form and if it was not set explicitely, we use the first one in the following order: Infix, Prefix, Postfix.
+    // This is to handle bad MathML markup without explicit <mrow> delimiters like "<mo>(</mo><mi>a</mi><mo>)</mo><mo>(</mo><mi>b</mi><mo>)</mo>" where innerfences should not be considered infix.
+    if (auto* entry = tryBinarySearch<const Entry, UChar>(dictionary, dictionarySize, character, ExtractChar)) {
         // There are at most two other entries before the one found.
-        if (entry != dictionary && (entry - 1)->character == textContent)
+        if (entry != dictionary && (entry - 1)->character == character)
             entry--;
-        if (entry != dictionary && (entry - 1)->character == textContent)
+        if (entry != dictionary && (entry - 1)->character == character)
             entry--;
-        return entry;
+        return *entry;
     }
-    return nullptr;
+
+    return Nullopt;
 }
 
 bool MathMLOperatorDictionary::isVertical(UChar textContent)

Modified: trunk/Source/WebCore/mathml/MathMLOperatorDictionary.h (204021 => 204022)


--- trunk/Source/WebCore/mathml/MathMLOperatorDictionary.h	2016-08-02 09:43:01 UTC (rev 204021)
+++ trunk/Source/WebCore/mathml/MathMLOperatorDictionary.h	2016-08-02 11:27:19 UTC (rev 204022)
@@ -28,6 +28,7 @@
 #if ENABLE(MATHML)
 
 #include <unicode/utypes.h>
+#include <wtf/Optional.h>
 
 namespace WebCore {
 
@@ -49,8 +50,7 @@
     unsigned rspace : 3;
     unsigned flags : 8;
 };
-const Entry* getEntry(UChar, Form);
-const Entry* getEntry(UChar);
+Optional<Entry> search(UChar, Form, bool explicitForm);
 bool isVertical(UChar);
 }
 

Modified: trunk/Source/WebCore/mathml/MathMLOperatorElement.cpp (204021 => 204022)


--- trunk/Source/WebCore/mathml/MathMLOperatorElement.cpp	2016-08-02 09:43:01 UTC (rev 204021)
+++ trunk/Source/WebCore/mathml/MathMLOperatorElement.cpp	2016-08-02 11:27:19 UTC (rev 204022)
@@ -35,6 +35,7 @@
 namespace WebCore {
 
 using namespace MathMLNames;
+using namespace MathMLOperatorDictionary;
 
 MathMLOperatorElement::MathMLOperatorElement(const QualifiedName& tagName, Document& document)
     : MathMLTextElement(tagName, document)
@@ -60,21 +61,87 @@
 
 UChar MathMLOperatorElement::operatorText()
 {
-    if (m_operatorText)
-        return m_operatorText.value();
-
-    m_operatorText = parseOperatorText(textContent());
+    if (!m_operatorText)
+        m_operatorText = parseOperatorText(textContent());
     return m_operatorText.value();
 }
 
+MathMLOperatorElement::DictionaryProperty MathMLOperatorElement::computeDictionaryProperty()
+{
+    DictionaryProperty dictionaryProperty;
+
+    // We first determine the form attribute and use the default spacing and properties.
+    const auto& value = attributeWithoutSynchronization(formAttr);
+    bool explicitForm = true;
+    if (value == "prefix")
+        dictionaryProperty.form = Prefix;
+    else if (value == "infix")
+        dictionaryProperty.form = Infix;
+    else if (value == "postfix")
+        dictionaryProperty.form = Postfix;
+    else {
+        // FIXME: We should use more advanced heuristics indicated in the specification to determine the operator form (https://bugs.webkit.org/show_bug.cgi?id=124829).
+        explicitForm = false;
+        if (!previousSibling() && nextSibling())
+            dictionaryProperty.form = Prefix;
+        else if (previousSibling() && !nextSibling())
+            dictionaryProperty.form = Postfix;
+        else
+            dictionaryProperty.form = Infix;
+    }
+
+    // We then try and find an entry in the operator dictionary to override the default values.
+    if (auto entry = search(operatorText(), dictionaryProperty.form, explicitForm)) {
+        dictionaryProperty.form = static_cast<MathMLOperatorDictionary::Form>(entry.value().form);
+        dictionaryProperty.leadingSpaceInMathUnit = entry.value().lspace;
+        dictionaryProperty.trailingSpaceInMathUnit = entry.value().rspace;
+        dictionaryProperty.flags = entry.value().flags;
+    }
+
+    return dictionaryProperty;
+}
+
+const MathMLOperatorElement::DictionaryProperty& MathMLOperatorElement::dictionaryProperty()
+{
+    if (!m_dictionaryProperty)
+        m_dictionaryProperty = computeDictionaryProperty();
+    return m_dictionaryProperty.value();
+}
+
+unsigned short MathMLOperatorElement::flags()
+{
+    // FIXME: We should also handle boolean attributes here (https://webkit.org/b/160190).
+    return dictionaryProperty().flags;
+}
+
+MathMLElement::Length MathMLOperatorElement::defaultLeadingSpace()
+{
+    Length space;
+    space.type = LengthType::MathUnit;
+    space.value = static_cast<float>(dictionaryProperty().leadingSpaceInMathUnit);
+    return space;
+}
+
+MathMLElement::Length MathMLOperatorElement::defaultTrailingSpace()
+{
+    Length space;
+    space.type = LengthType::MathUnit;
+    space.value = static_cast<float>(dictionaryProperty().trailingSpaceInMathUnit);
+    return space;
+}
+
 void MathMLOperatorElement::childrenChanged(const ChildChange& change)
 {
     m_operatorText = Nullopt;
+    m_dictionaryProperty = Nullopt;
     MathMLTextElement::childrenChanged(change);
 }
 
 void MathMLOperatorElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
 {
+    if (name == formAttr)
+        m_dictionaryProperty = Nullopt;
+
     if ((name == stretchyAttr || name == lspaceAttr || name == rspaceAttr || name == movablelimitsAttr) && renderer()) {
         downcast<RenderMathMLOperator>(*renderer()).updateFromElement();
         return;

Modified: trunk/Source/WebCore/mathml/MathMLOperatorElement.h (204021 => 204022)


--- trunk/Source/WebCore/mathml/MathMLOperatorElement.h	2016-08-02 09:43:01 UTC (rev 204021)
+++ trunk/Source/WebCore/mathml/MathMLOperatorElement.h	2016-08-02 11:27:19 UTC (rev 204022)
@@ -26,6 +26,7 @@
 #pragma once
 
 #if ENABLE(MATHML)
+#include "MathMLOperatorDictionary.h"
 #include "MathMLTextElement.h"
 
 namespace WebCore {
@@ -35,6 +36,11 @@
     static Ref<MathMLOperatorElement> create(const QualifiedName& tagName, Document&);
     static UChar parseOperatorText(const String&);
     UChar operatorText();
+    void setOperatorFormDirty() { m_dictionaryProperty = Nullopt; }
+    MathMLOperatorDictionary::Form form() { return dictionaryProperty().form; }
+    unsigned short flags();
+    Length defaultLeadingSpace();
+    Length defaultTrailingSpace();
 
 private:
     MathMLOperatorElement(const QualifiedName& tagName, Document&);
@@ -43,6 +49,18 @@
     void parseAttribute(const QualifiedName&, const AtomicString&) final;
 
     Optional<UChar> m_operatorText;
+
+    struct DictionaryProperty {
+        MathMLOperatorDictionary::Form form;
+        // Default leading and trailing spaces are "thickmathspace".
+        unsigned short leadingSpaceInMathUnit { 5 };
+        unsigned short trailingSpaceInMathUnit { 5 };
+        // Default operator properties are all set to "false".
+        unsigned short flags { 0 };
+    };
+    Optional<DictionaryProperty> m_dictionaryProperty;
+    DictionaryProperty computeDictionaryProperty();
+    const DictionaryProperty& dictionaryProperty();
 };
 
 }

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLFencedOperator.cpp (204021 => 204022)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLFencedOperator.cpp	2016-08-02 09:43:01 UTC (rev 204021)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLFencedOperator.cpp	2016-08-02 11:27:19 UTC (rev 204022)
@@ -26,16 +26,24 @@
 #include "config.h"
 
 #if ENABLE(MATHML)
+
 #include "RenderMathMLFencedOperator.h"
 
+#include "MathMLOperatorDictionary.h"
 #include "MathMLOperatorElement.h"
 
 namespace WebCore {
 
+using namespace MathMLOperatorDictionary;
+
 RenderMathMLFencedOperator::RenderMathMLFencedOperator(Document& document, RenderStyle&& style, const String& operatorString, MathMLOperatorDictionary::Form form, unsigned short flags)
-    : RenderMathMLOperator(document, WTFMove(style), form, flags)
+    : RenderMathMLOperator(document, WTFMove(style), flags)
+    , m_operatorForm(form)
 {
     updateOperatorContent(operatorString);
+
+    // maxsize always has the default value "infinity" value for mfenced operators.
+    m_maxSize = intMaxForLayoutUnit;
 }
 
 void RenderMathMLFencedOperator::updateOperatorContent(const String& operatorString)
@@ -44,6 +52,37 @@
     rebuildTokenContent();
 }
 
+void RenderMathMLFencedOperator::setOperatorProperties()
+{
+    // We determine the stretch direction (default is vertical).
+    m_isVertical = MathMLOperatorDictionary::isVertical(m_textContent);
+
+    // Resets all but the Fence and Separator properties.
+    m_operatorFlags &= MathMLOperatorDictionary::Fence | MathMLOperatorDictionary::Separator;
+
+    // minsize always has the default value "1em" value for mfenced operators.
+    m_minSize = style().fontCascade().size();
+
+    // Default spacing is thickmathspace.
+    MathMLElement::Length leadingSpace;
+    leadingSpace.type = MathMLElement::LengthType::MathUnit;
+    leadingSpace.value = 5;
+    MathMLElement::Length trailingSpace = leadingSpace;
+
+    if (auto entry = search(m_textContent, m_operatorForm, true)) {
+        // We use the space specified in the operator dictionary.
+        leadingSpace.value = static_cast<float>(entry.value().lspace);
+        trailingSpace.value = static_cast<float>(entry.value().rspace);
+
+        // We use the dictionary but preserve the Fence and Separator properties.
+        m_operatorFlags = (m_operatorFlags & (MathMLOperatorDictionary::Fence | MathMLOperatorDictionary::Separator)) | entry.value().flags;
+    }
+
+    // Resolve the leading and trailing spaces.
+    m_leadingSpace = toUserUnits(leadingSpace, style(), 0);
+    m_trailingSpace = toUserUnits(trailingSpace, style(), 0);
 }
 
+}
+
 #endif

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLFencedOperator.h (204021 => 204022)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLFencedOperator.h	2016-08-02 09:43:01 UTC (rev 204021)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLFencedOperator.h	2016-08-02 11:27:19 UTC (rev 204022)
@@ -39,9 +39,11 @@
 
 private:
     bool isRenderMathMLFencedOperator() const final { return true; }
+    void setOperatorProperties() final;
     UChar textContent() const final { return m_textContent; }
 
     UChar m_textContent { 0 };
+    MathMLOperatorDictionary::Form m_operatorForm;
 };
 
 }; // namespace WebCore

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp (204021 => 204022)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp	2016-08-02 09:43:01 UTC (rev 204021)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp	2016-08-02 11:27:19 UTC (rev 204022)
@@ -53,9 +53,8 @@
     updateTokenContent();
 }
 
-RenderMathMLOperator::RenderMathMLOperator(Document& document, RenderStyle&& style, MathMLOperatorDictionary::Form form, unsigned short flags)
+RenderMathMLOperator::RenderMathMLOperator(Document& document, RenderStyle&& style, unsigned short flags)
     : RenderMathMLToken(document, WTFMove(style))
-    , m_operatorForm(form)
     , m_operatorFlags(flags)
 {
 }
@@ -87,72 +86,18 @@
     // We ignore absent or invalid attributes.
 }
 
-void RenderMathMLOperator::setOperatorPropertiesFromOpDictEntry(const MathMLOperatorDictionary::Entry* entry)
-{
-    // If this operator is anonymous, we preserve the Fence and Separator properties. This is to handle the case of RenderMathMLFenced.
-    if (isAnonymous())
-        m_operatorFlags = (m_operatorFlags & (MathMLOperatorDictionary::Fence | MathMLOperatorDictionary::Separator)) | entry->flags;
-    else
-        m_operatorFlags = entry->flags;
-
-    // Leading and trailing space is specified as multiple of 1/18em.
-    m_leadingSpace = entry->lspace * style().fontCascade().size() / 18;
-    m_trailingSpace = entry->rspace * style().fontCascade().size() / 18;
-}
-
 void RenderMathMLOperator::setOperatorProperties()
 {
     // We determine the stretch direction (default is vertical).
     m_isVertical = MathMLOperatorDictionary::isVertical(textContent());
 
-    // We determine the form of the operator.
-    bool explicitForm = true;
-    if (!isAnonymous()) {
-        const AtomicString& form = element().attributeWithoutSynchronization(MathMLNames::formAttr);
-        if (form == "prefix")
-            m_operatorForm = MathMLOperatorDictionary::Prefix;
-        else if (form == "infix")
-            m_operatorForm = MathMLOperatorDictionary::Infix;
-        else if (form == "postfix")
-            m_operatorForm = MathMLOperatorDictionary::Postfix;
-        else {
-            // FIXME: We should use more advanced heuristics indicated in the specification to determine the operator form (https://bugs.webkit.org/show_bug.cgi?id=124829).
-            explicitForm = false;
-            if (!element().previousSibling() && element().nextSibling())
-                m_operatorForm = MathMLOperatorDictionary::Prefix;
-            else if (element().previousSibling() && !element().nextSibling())
-                m_operatorForm = MathMLOperatorDictionary::Postfix;
-            else
-                m_operatorForm = MathMLOperatorDictionary::Infix;
-        }
-    }
-
-    // We determine the default values of the operator properties.
-
-    // First we initialize with the default values for unknown operators.
-    if (isAnonymous())
-        m_operatorFlags &= MathMLOperatorDictionary::Fence | MathMLOperatorDictionary::Separator; // This resets all but the Fence and Separator properties.
-    else
-        m_operatorFlags = 0; // This resets all the operator properties.
-    m_leadingSpace = 5 * style().fontCascade().size() / 18; // This sets leading space to "thickmathspace".
-    m_trailingSpace = 5 * style().fontCascade().size() / 18; // This sets trailing space to "thickmathspace".
+    // Initialize with the default values.
+    m_operatorFlags = element().flags();
+    m_leadingSpace = toUserUnits(element().defaultLeadingSpace(), style(), 0);
+    m_trailingSpace = toUserUnits(element().defaultTrailingSpace(), style(), 0);
     m_minSize = style().fontCascade().size(); // This sets minsize to "1em".
     m_maxSize = intMaxForLayoutUnit; // This sets maxsize to "infinity".
 
-    if (textContent()) {
-        // Then we try to find the default values from the operator dictionary.
-        if (const MathMLOperatorDictionary::Entry* entry = MathMLOperatorDictionary::getEntry(textContent(), m_operatorForm))
-            setOperatorPropertiesFromOpDictEntry(entry);
-        else if (!explicitForm) {
-            // If we did not find the desired operator form and if it was not set explicitely, we use the first one in the following order: Infix, Prefix, Postfix.
-            // This is to handle bad MathML markup without explicit <mrow> delimiters like "<mo>(</mo><mi>a</mi><mo>)</mo><mo>(</mo><mi>b</mi><mo>)</mo>" where the inner parenthesis should not be considered infix.
-            if (const MathMLOperatorDictionary::Entry* entry = MathMLOperatorDictionary::getEntry(textContent())) {
-                m_operatorForm = static_cast<MathMLOperatorDictionary::Form>(entry->form); // We override the form previously determined.
-                setOperatorPropertiesFromOpDictEntry(entry);
-            }
-        }
-    }
-
     if (!isAnonymous()) {
         // Finally, we make the attribute values override the default.
 

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.h (204021 => 204022)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.h	2016-08-02 09:43:01 UTC (rev 204021)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.h	2016-08-02 11:27:19 UTC (rev 204022)
@@ -39,7 +39,7 @@
 class RenderMathMLOperator : public RenderMathMLToken {
 public:
     RenderMathMLOperator(MathMLOperatorElement&, RenderStyle&&);
-    RenderMathMLOperator(Document&, RenderStyle&&, MathMLOperatorDictionary::Form, unsigned short flags = 0);
+    RenderMathMLOperator(Document&, RenderStyle&&, unsigned short flags = 0);
     MathMLOperatorElement& element() const;
 
     void stretchTo(LayoutUnit heightAboveBaseline, LayoutUnit depthBelowBaseline);
@@ -60,12 +60,16 @@
 
 protected:
     void rebuildTokenContent();
+    virtual void setOperatorProperties();
 
-    MathMLOperatorDictionary::Form m_operatorForm;
+    bool m_isVertical { true };
+    LayoutUnit m_leadingSpace;
+    LayoutUnit m_trailingSpace;
+    LayoutUnit m_minSize;
+    LayoutUnit m_maxSize;
     unsigned short m_operatorFlags;
 
 private:
-    virtual void setOperatorProperties();
     void styleDidChange(StyleDifference, const RenderStyle* oldStyle) final;
     void computePreferredLogicalWidths() final;
     void layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight = 0) final;
@@ -88,7 +92,6 @@
 
     void setOperatorFlagFromAttribute(MathMLOperatorDictionary::Flag, const QualifiedName&);
     void setOperatorFlagFromAttributeValue(MathMLOperatorDictionary::Flag, const AtomicString& attributeValue);
-    void setOperatorPropertiesFromOpDictEntry(const MathMLOperatorDictionary::Entry*);
 
     LayoutUnit verticalStretchedOperatorShift() const;
 
@@ -96,11 +99,6 @@
     LayoutUnit m_stretchDepthBelowBaseline { 0 };
     LayoutUnit m_stretchWidth;
 
-    bool m_isVertical { true };
-    LayoutUnit m_leadingSpace;
-    LayoutUnit m_trailingSpace;
-    LayoutUnit m_minSize;
-    LayoutUnit m_maxSize;
     MathOperator m_mathOperator;
 };
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to