Title: [203108] trunk/Source/WebCore
Revision
203108
Author
[email protected]
Date
2016-07-11 22:59:55 -0700 (Mon, 11 Jul 2016)

Log Message

Move parsing of mspace attributes to a MathMLSpaceElement class
https://bugs.webkit.org/show_bug.cgi?id=156795

Patch by Frederic Wang <[email protected]> on 2016-07-11
Reviewed by Brent Fulgham.

No new tests, already covered by existing tests.

* CMakeLists.txt: Add MathMLSpaceElement to the build system.
* WebCore.xcodeproj/project.pbxproj: Ditto.
* mathml/MathMLElement.cpp:
(WebCore::MathMLElement::cachedMathMLLength): Helper function to returned the cached parsed
value of a MathML length and parsing the corresponding attribute value if the cache is dirty.
* mathml/MathMLElement.h: Add a dirty boolean to MathML Length structure. Declare cachedMathMLLength.
* mathml/MathMLSpaceElement.cpp: New class for the <mspace> element.
(WebCore::MathMLSpaceElement::MathMLSpaceElement):
(WebCore::MathMLSpaceElement::create):
(WebCore::MathMLSpaceElement::parseAttribute): Make width, height, depth attributes dirty.
(WebCore::MathMLSpaceElement::createElementRenderer):
* mathml/MathMLSpaceElement.h: New class for the <mspace> element.
We define MathML lengths for width, height and depth attributes are on the class and expose
with the corresponding helper functions via memoization.
* mathml/MathMLTextElement.cpp: Remove handling of mspace from this class.
(WebCore::MathMLTextElement::createElementRenderer):
* mathml/mathtags.in: Change the interface for mspace to use the new class.
* rendering/mathml/RenderMathMLSpace.cpp: Do not store width/height/depth values on the
renderer and instead just use the corresponding MathML lengths on the element class.
(WebCore::RenderMathMLSpace::RenderMathMLSpace): Use MathMLSpaceElement and remove member
initialization.
(WebCore::RenderMathMLSpace::computePreferredLogicalWidths): Use spaceWidth().
(WebCore::RenderMathMLSpace::spaceWidth): Helper function to resolve the width attribute value.
(WebCore::RenderMathMLSpace::getSpaceHeightAndDepth): Ditto for height and depth.
(WebCore::RenderMathMLSpace::layoutBlock): Use the helper functions to get the mspace metrics.
(WebCore::RenderMathMLSpace::firstLineBaseline): Ditto.
(WebCore::RenderMathMLSpace::updateFromElement): Deleted.
(WebCore::RenderMathMLSpace::styleDidChange): Deleted.
* rendering/mathml/RenderMathMLSpace.h: Use MathMLSpaceElement, replace members with helper
functions and and make element() usable from a const instance.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/CMakeLists.txt (203107 => 203108)


--- trunk/Source/WebCore/CMakeLists.txt	2016-07-12 05:06:25 UTC (rev 203107)
+++ trunk/Source/WebCore/CMakeLists.txt	2016-07-12 05:59:55 UTC (rev 203108)
@@ -1987,6 +1987,7 @@
     mathml/MathMLMathElement.cpp
     mathml/MathMLMencloseElement.cpp
     mathml/MathMLSelectElement.cpp
+    mathml/MathMLSpaceElement.cpp
     mathml/MathMLTextElement.cpp
 
     page/AutoscrollController.cpp

Modified: trunk/Source/WebCore/ChangeLog (203107 => 203108)


--- trunk/Source/WebCore/ChangeLog	2016-07-12 05:06:25 UTC (rev 203107)
+++ trunk/Source/WebCore/ChangeLog	2016-07-12 05:59:55 UTC (rev 203108)
@@ -1,5 +1,45 @@
 2016-07-11  Frederic Wang  <[email protected]>
 
+        Move parsing of mspace attributes to a MathMLSpaceElement class
+        https://bugs.webkit.org/show_bug.cgi?id=156795
+
+        Reviewed by Brent Fulgham.
+
+        No new tests, already covered by existing tests.
+
+        * CMakeLists.txt: Add MathMLSpaceElement to the build system.
+        * WebCore.xcodeproj/project.pbxproj: Ditto.
+        * mathml/MathMLElement.cpp:
+        (WebCore::MathMLElement::cachedMathMLLength): Helper function to returned the cached parsed
+        value of a MathML length and parsing the corresponding attribute value if the cache is dirty.
+        * mathml/MathMLElement.h: Add a dirty boolean to MathML Length structure. Declare cachedMathMLLength.
+        * mathml/MathMLSpaceElement.cpp: New class for the <mspace> element.
+        (WebCore::MathMLSpaceElement::MathMLSpaceElement):
+        (WebCore::MathMLSpaceElement::create):
+        (WebCore::MathMLSpaceElement::parseAttribute): Make width, height, depth attributes dirty.
+        (WebCore::MathMLSpaceElement::createElementRenderer):
+        * mathml/MathMLSpaceElement.h: New class for the <mspace> element.
+        We define MathML lengths for width, height and depth attributes are on the class and expose
+        with the corresponding helper functions via memoization.
+        * mathml/MathMLTextElement.cpp: Remove handling of mspace from this class.
+        (WebCore::MathMLTextElement::createElementRenderer):
+        * mathml/mathtags.in: Change the interface for mspace to use the new class.
+        * rendering/mathml/RenderMathMLSpace.cpp: Do not store width/height/depth values on the
+        renderer and instead just use the corresponding MathML lengths on the element class.
+        (WebCore::RenderMathMLSpace::RenderMathMLSpace): Use MathMLSpaceElement and remove member
+        initialization.
+        (WebCore::RenderMathMLSpace::computePreferredLogicalWidths): Use spaceWidth().
+        (WebCore::RenderMathMLSpace::spaceWidth): Helper function to resolve the width attribute value.
+        (WebCore::RenderMathMLSpace::getSpaceHeightAndDepth): Ditto for height and depth.
+        (WebCore::RenderMathMLSpace::layoutBlock): Use the helper functions to get the mspace metrics.
+        (WebCore::RenderMathMLSpace::firstLineBaseline): Ditto.
+        (WebCore::RenderMathMLSpace::updateFromElement): Deleted.
+        (WebCore::RenderMathMLSpace::styleDidChange): Deleted.
+        * rendering/mathml/RenderMathMLSpace.h: Use MathMLSpaceElement, replace members with helper
+        functions and and make element() usable from a const instance.
+
+2016-07-11  Frederic Wang  <[email protected]>
+
         Create a MathMLLength struct to handle the parsing of MathML length.
         https://bugs.webkit.org/show_bug.cgi?id=156792
 

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (203107 => 203108)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-07-12 05:06:25 UTC (rev 203107)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2016-07-12 05:59:55 UTC (rev 203108)
@@ -6893,6 +6893,8 @@
 		F98FFF4411A2676200F548E8 /* CSSOMUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F98FFF4211A2676200F548E8 /* CSSOMUtils.cpp */; };
 		F98FFF4511A2676200F548E8 /* CSSOMUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = F98FFF4311A2676200F548E8 /* CSSOMUtils.h */; };
 		F9F0ED7A0DB50CA200D16DB9 /* XMLHttpRequestProgressEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = F9F0ED770DB50CA200D16DB9 /* XMLHttpRequestProgressEvent.h */; };
+		4FA65A6B1108ABED002615E0 /* MathMLSpaceElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4FA65A691108ABED002615E0 /* MathMLSpaceElement.cpp */; };
+		4FA65A6C1108ABED002615E0 /* MathMLSpaceElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 4FA65A6A1108ABED002615E0 /* MathMLSpaceElement.h */; };
 		FA654A6B1108ABED002615E0 /* MathMLTextElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA654A691108ABED002615E0 /* MathMLTextElement.cpp */; };
 		FA654A6C1108ABED002615E0 /* MathMLTextElement.h in Headers */ = {isa = PBXBuildFile; fileRef = FA654A6A1108ABED002615E0 /* MathMLTextElement.h */; };
 		FABE72F41059C1EB00D999DD /* MathMLElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FABE72ED1059C1EB00D999DD /* MathMLElement.cpp */; };
@@ -15055,6 +15057,8 @@
 		F9F0ED780DB50CA200D16DB9 /* XMLHttpRequestProgressEvent.idl */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = XMLHttpRequestProgressEvent.idl; sourceTree = "<group>"; };
 		FA654A631108ABB7002615E0 /* mathml.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; path = mathml.css; sourceTree = "<group>"; };
 		FA654A671108ABE2002615E0 /* mathattrs.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = mathattrs.in; sourceTree = "<group>"; };
+		4FA65A691108ABED002615E0 /* MathMLSpaceElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MathMLSpaceElement.cpp; sourceTree = "<group>"; };
+		4FA65A6A1108ABED002615E0 /* MathMLSpaceElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MathMLSpaceElement.h; sourceTree = "<group>"; };
 		FA654A691108ABED002615E0 /* MathMLTextElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MathMLTextElement.cpp; sourceTree = "<group>"; };
 		FA654A6A1108ABED002615E0 /* MathMLTextElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MathMLTextElement.h; sourceTree = "<group>"; };
 		FA6E466FCD0418A9966A5B60 /* DNSResolveQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DNSResolveQueue.h; sourceTree = "<group>"; };
@@ -24862,6 +24866,8 @@
 				CE6D89294C7AACE0AD89B3DD /* MathMLMencloseElement.h */,
 				F75A059AF170D8FAA5B8CABE /* MathMLSelectElement.cpp */,
 				59780849D41E6F65D81198BC /* MathMLSelectElement.h */,
+				4FA65A691108ABED002615E0 /* MathMLSpaceElement.cpp */,
+				4FA65A6A1108ABED002615E0 /* MathMLSpaceElement.h */,
 				FA654A691108ABED002615E0 /* MathMLTextElement.cpp */,
 				FA654A6A1108ABED002615E0 /* MathMLTextElement.h */,
 				FABE72F31059C1EB00D999DD /* mathtags.in */,
@@ -27398,6 +27404,7 @@
 				44A28AAF12DFB8BF00AE923B /* MathMLNames.h in Headers */,
 				439046E012DA25E17BAF80A2 /* MathMLOperatorDictionary.h in Headers */,
 				439176E012DA25E17BAF80A2 /* MathMLStyle.h in Headers */,
+				4FA65A6C1108ABED002615E0 /* MathMLSpaceElement.h in Headers */,
 				FA654A6C1108ABED002615E0 /* MathMLTextElement.h in Headers */,
 				439046EA12DA25E812AF80AC /* MathOperator.h in Headers */,
 				49D5DC2C0F423A73008F20FD /* Matrix3DTransformOperation.h in Headers */,
@@ -31221,6 +31228,7 @@
 				439046DF12DA25E17BAF80A2 /* MathMLOperatorDictionary.cpp in Sources */,
 				439176DF12DA25E17BAF80A2 /* MathMLStyle.cpp in Sources */,
 				FED48390CED66C3255F72C59 /* MathMLSelectElement.cpp in Sources */,
+				4FA65A6B1108ABED002615E0 /* MathMLSpaceElement.cpp in Sources */,
 				FA654A6B1108ABED002615E0 /* MathMLTextElement.cpp in Sources */,
 				439046E912DA25E812AF80AC /* MathOperator.cpp in Sources */,
 				49D5DC2B0F423A73008F20FD /* Matrix3DTransformOperation.cpp in Sources */,

Modified: trunk/Source/WebCore/mathml/MathMLElement.cpp (203107 => 203108)


--- trunk/Source/WebCore/mathml/MathMLElement.cpp	2016-07-12 05:06:25 UTC (rev 203107)
+++ trunk/Source/WebCore/mathml/MathMLElement.cpp	2016-07-12 05:59:55 UTC (rev 203108)
@@ -516,6 +516,15 @@
     return parseNamedSpace(stringView);
 }
 
+const MathMLElement::Length& MathMLElement::cachedMathMLLength(const QualifiedName& name, Length& length)
+{
+    if (length.dirty) {
+        length = parseMathMLLength(fastGetAttribute(name));
+        length.dirty = false;
+    }
+    return length;
 }
 
+}
+
 #endif // ENABLE(MATHML)

Modified: trunk/Source/WebCore/mathml/MathMLElement.h (203107 => 203108)


--- trunk/Source/WebCore/mathml/MathMLElement.h	2016-07-12 05:06:25 UTC (rev 203107)
+++ trunk/Source/WebCore/mathml/MathMLElement.h	2016-07-12 05:59:55 UTC (rev 203108)
@@ -63,6 +63,7 @@
     struct Length {
         LengthType type { LengthType::ParsingFailed };
         float value { 0 };
+        bool dirty { true };
     };
     static Length parseMathMLLength(const String&);
 
@@ -82,6 +83,8 @@
     bool willRespondToMouseClickEvents() override;
     void defaultEventHandler(Event*) override;
 
+    const Length& cachedMathMLLength(const QualifiedName&, Length&);
+
 private:
     virtual void updateSelectedChild() { }
     static Length parseNumberAndUnit(const StringView&);

Added: trunk/Source/WebCore/mathml/MathMLSpaceElement.cpp (0 => 203108)


--- trunk/Source/WebCore/mathml/MathMLSpaceElement.cpp	                        (rev 0)
+++ trunk/Source/WebCore/mathml/MathMLSpaceElement.cpp	2016-07-12 05:59:55 UTC (rev 203108)
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2016 Igalia S.L. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include "config.h"
+
+#if ENABLE(MATHML)
+#include "MathMLSpaceElement.h"
+
+#include "RenderMathMLSpace.h"
+
+namespace WebCore {
+
+using namespace MathMLNames;
+
+MathMLSpaceElement::MathMLSpaceElement(const QualifiedName& tagName, Document& document)
+    : MathMLElement(tagName, document)
+{
+}
+
+Ref<MathMLSpaceElement> MathMLSpaceElement::create(const QualifiedName& tagName, Document& document)
+{
+    return adoptRef(*new MathMLSpaceElement(tagName, document));
+}
+
+const MathMLElement::Length& MathMLSpaceElement::width()
+{
+    return cachedMathMLLength(MathMLNames::widthAttr, m_width);
+}
+
+const MathMLElement::Length& MathMLSpaceElement::height()
+{
+    return cachedMathMLLength(MathMLNames::heightAttr, m_height);
+}
+
+const MathMLElement::Length& MathMLSpaceElement::depth()
+{
+    return cachedMathMLLength(MathMLNames::depthAttr, m_depth);
+}
+
+void MathMLSpaceElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
+{
+    if (name == widthAttr)
+        m_width.dirty = true;
+    else if (name == heightAttr)
+        m_height.dirty = true;
+    else if (name == depthAttr)
+        m_depth.dirty = true;
+
+    MathMLElement::parseAttribute(name, value);
+}
+
+RenderPtr<RenderElement> MathMLSpaceElement::createElementRenderer(RenderStyle&& style, const RenderTreePosition&)
+{
+    ASSERT(hasTagName(MathMLNames::mspaceTag));
+    return createRenderer<RenderMathMLSpace>(*this, WTFMove(style));
+}
+
+}
+
+#endif // ENABLE(MATHML)
Property changes on: trunk/Source/WebCore/mathml/MathMLSpaceElement.cpp
___________________________________________________________________

Added: svn:eol-style

+LF \ No newline at end of property

Copied: trunk/Source/WebCore/mathml/MathMLSpaceElement.h (from rev 203107, trunk/Source/WebCore/rendering/mathml/RenderMathMLSpace.h) (0 => 203108)


--- trunk/Source/WebCore/mathml/MathMLSpaceElement.h	                        (rev 0)
+++ trunk/Source/WebCore/mathml/MathMLSpaceElement.h	2016-07-12 05:59:55 UTC (rev 203108)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2016 Igalia S.L. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef MathMLSpaceElement_h
+#define MathMLSpaceElement_h
+
+#if ENABLE(MATHML)
+#include "MathMLElement.h"
+
+namespace WebCore {
+
+class MathMLSpaceElement final : public MathMLElement {
+public:
+    static Ref<MathMLSpaceElement> create(const QualifiedName& tagName, Document&);
+    const Length& width();
+    const Length& height();
+    const Length& depth();
+private:
+    MathMLSpaceElement(const QualifiedName& tagName, Document&);
+    bool isPresentationMathML() const final { return true; }
+    RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) final;
+    void parseAttribute(const QualifiedName&, const AtomicString&) final;
+
+    Length m_width;
+    Length m_height;
+    Length m_depth;
+};
+
+}
+
+#endif // ENABLE(MATHML)
+#endif // MathMLSpaceElement_h

Modified: trunk/Source/WebCore/mathml/MathMLTextElement.cpp (203107 => 203108)


--- trunk/Source/WebCore/mathml/MathMLTextElement.cpp	2016-07-12 05:06:25 UTC (rev 203107)
+++ trunk/Source/WebCore/mathml/MathMLTextElement.cpp	2016-07-12 05:59:55 UTC (rev 203108)
@@ -32,7 +32,6 @@
 
 #include "MathMLNames.h"
 #include "RenderMathMLOperator.h"
-#include "RenderMathMLSpace.h"
 #include "RenderMathMLToken.h"
 
 namespace WebCore {
@@ -82,8 +81,6 @@
 {
     if (hasTagName(MathMLNames::moTag))
         return createRenderer<RenderMathMLOperator>(*this, WTFMove(style));
-    if (hasTagName(MathMLNames::mspaceTag))
-        return createRenderer<RenderMathMLSpace>(*this, WTFMove(style));
     if (hasTagName(MathMLNames::annotationTag))
         return MathMLElement::createElementRenderer(WTFMove(style), insertionPosition);
 

Modified: trunk/Source/WebCore/mathml/mathtags.in (203107 => 203108)


--- trunk/Source/WebCore/mathml/mathtags.in	2016-07-12 05:06:25 UTC (rev 203107)
+++ trunk/Source/WebCore/mathml/mathtags.in	2016-07-12 05:59:55 UTC (rev 203108)
@@ -25,7 +25,7 @@
 mo interfaceName=MathMLTextElement
 mtext interfaceName=MathMLTextElement
 ms interfaceName=MathMLTextElement
-mspace interfaceName=MathMLTextElement
+mspace interfaceName=MathMLSpaceElement
 msub interfaceName=MathMLInlineContainerElement
 msup interfaceName=MathMLInlineContainerElement
 mtable interfaceName=MathMLInlineContainerElement

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLSpace.cpp (203107 => 203108)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLSpace.cpp	2016-07-12 05:06:25 UTC (rev 203107)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLSpace.cpp	2016-07-12 05:59:55 UTC (rev 203108)
@@ -36,11 +36,8 @@
 
 using namespace MathMLNames;
 
-RenderMathMLSpace::RenderMathMLSpace(MathMLTextElement& element, RenderStyle&& style)
+RenderMathMLSpace::RenderMathMLSpace(MathMLSpaceElement& element, RenderStyle&& style)
     : RenderMathMLBlock(element, WTFMove(style))
-    , m_width(0)
-    , m_height(0)
-    , m_depth(0)
 {
 }
 
@@ -48,34 +45,29 @@
 {
     ASSERT(preferredLogicalWidthsDirty());
 
-    m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = m_width;
+    m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = spaceWidth();
 
     setPreferredLogicalWidthsDirty(false);
 }
 
-void RenderMathMLSpace::updateFromElement()
+LayoutUnit RenderMathMLSpace::spaceWidth() const
 {
-    const auto& spaceElement = element();
+    auto& spaceElement = element();
+    // FIXME: Negative width values are not supported yet.
+    return std::max<LayoutUnit>(0, toUserUnits(spaceElement.width(), style(), 0));
+}
 
-    // This parses the mspace attributes, using 0 as the default values.
-    m_width = 0;
-    m_height = 0;
-    m_depth = 0;
-    parseMathMLLength(spaceElement.getAttribute(MathMLNames::widthAttr), m_width, &style());
-    parseMathMLLength(spaceElement.getAttribute(MathMLNames::heightAttr), m_height, &style());
-    parseMathMLLength(spaceElement.getAttribute(MathMLNames::depthAttr), m_depth, &style());
+void RenderMathMLSpace::getSpaceHeightAndDepth(LayoutUnit& height, LayoutUnit& depth) const
+{
+    auto& spaceElement = element();
+    height = toUserUnits(spaceElement.height(), style(), 0);
+    depth = toUserUnits(spaceElement.depth(), style(), 0);
 
-    // FIXME: Negative width values should be accepted.
-    if (m_width < 0)
-        m_width = 0;
-
     // If the total height is negative, set vertical dimensions to 0.
-    if (m_height + m_depth < 0) {
-        m_height = 0;
-        m_depth = 0;
+    if (height + depth < 0) {
+        height = 0;
+        depth = 0;
     }
-
-    setNeedsLayoutAndPrefWidthsRecalc();
 }
 
 void RenderMathMLSpace::layoutBlock(bool relayoutChildren, LayoutUnit)
@@ -85,21 +77,19 @@
     if (!relayoutChildren && simplifiedLayout())
         return;
 
-    setLogicalWidth(m_width);
-    setLogicalHeight(m_height + m_depth);
+    setLogicalWidth(spaceWidth());
+    LayoutUnit height, depth;
+    getSpaceHeightAndDepth(height, depth);
+    setLogicalHeight(height + depth);
 
     clearNeedsLayout();
 }
 
-void RenderMathMLSpace::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
-{
-    RenderMathMLBlock::styleDidChange(diff, oldStyle);
-    updateFromElement();
-}
-
 Optional<int> RenderMathMLSpace::firstLineBaseline() const
 {
-    return Optional<int>(m_height);
+    LayoutUnit height, depth;
+    getSpaceHeightAndDepth(height, depth);
+    return Optional<int>(height);
 }
 
 }

Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLSpace.h (203107 => 203108)


--- trunk/Source/WebCore/rendering/mathml/RenderMathMLSpace.h	2016-07-12 05:06:25 UTC (rev 203107)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLSpace.h	2016-07-12 05:59:55 UTC (rev 203108)
@@ -28,7 +28,7 @@
 
 #if ENABLE(MATHML)
 
-#include "MathMLTextElement.h"
+#include "MathMLSpaceElement.h"
 #include "RenderMathMLBlock.h"
 
 namespace WebCore {
@@ -35,22 +35,19 @@
 
 class RenderMathMLSpace final : public RenderMathMLBlock {
 public:
-    RenderMathMLSpace(MathMLTextElement&, RenderStyle&&);
-    MathMLTextElement& element() { return static_cast<MathMLTextElement&>(nodeForNonAnonymous()); }
+    RenderMathMLSpace(MathMLSpaceElement&, RenderStyle&&);
+    MathMLSpaceElement& element() const { return static_cast<MathMLSpaceElement&>(nodeForNonAnonymous()); }
 
 private:
     const char* renderName() const final { return "RenderMathMLSpace"; }
     bool isRenderMathMLSpace() const final { return true; }
-    void styleDidChange(StyleDifference, const RenderStyle* oldStyle) final;
     bool isChildAllowed(const RenderObject&, const RenderStyle&) const final { return false; }
-    void updateFromElement() final;
     void computePreferredLogicalWidths() final;
     void layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight = 0) final;
     Optional<int> firstLineBaseline() const final;
 
-    LayoutUnit m_width;
-    LayoutUnit m_height;
-    LayoutUnit m_depth;
+    LayoutUnit spaceWidth() const;
+    void getSpaceHeightAndDepth(LayoutUnit& height, LayoutUnit& depth) const;
 };
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to