Diff
Modified: trunk/LayoutTests/ChangeLog (203284 => 203285)
--- trunk/LayoutTests/ChangeLog 2016-07-15 18:06:17 UTC (rev 203284)
+++ trunk/LayoutTests/ChangeLog 2016-07-15 18:24:47 UTC (rev 203285)
@@ -1,3 +1,16 @@
+2016-07-15 Frederic Wang <[email protected]>
+
+ Move parsing of mfrac attributes into a MathMLFractionElementClass
+ https://bugs.webkit.org/show_bug.cgi?id=159624
+
+ Reviewed by Brent Fulgham.
+
+ We update the expectation for negative linethickness. As indicated in the MathML
+ recommendation, it should be rounded up to the nearest valid value, which is 0.
+
+ * mathml/presentation/mfrac-linethickness2.html: Update the comment to reflect the new behavior.
+ * mathml/presentation/mfrac-linethickness2-expected.html: Use 0px as the reference for negative values.
+
2016-07-15 Brent Fulgham <[email protected]>
Merge InlineBidiResolver end-of-line Blink test case
Modified: trunk/LayoutTests/mathml/presentation/mfrac-linethickness2-expected.html (203284 => 203285)
--- trunk/LayoutTests/mathml/presentation/mfrac-linethickness2-expected.html 2016-07-15 18:06:17 UTC (rev 203284)
+++ trunk/LayoutTests/mathml/presentation/mfrac-linethickness2-expected.html 2016-07-15 18:24:47 UTC (rev 203285)
@@ -6,7 +6,7 @@
<body>
<math>
- <mfrac>
+ <mfrac linethickness="0px">
<mi>x</mi>
<mi>y</mi>
</mfrac>
Modified: trunk/LayoutTests/mathml/presentation/mfrac-linethickness2.html (203284 => 203285)
--- trunk/LayoutTests/mathml/presentation/mfrac-linethickness2.html 2016-07-15 18:06:17 UTC (rev 203284)
+++ trunk/LayoutTests/mathml/presentation/mfrac-linethickness2.html 2016-07-15 18:24:47 UTC (rev 203285)
@@ -5,7 +5,7 @@
</head>
<body>
- <!-- The linethickness should be ignored -->
+ <!-- Negative values are not accepted. We treat them as zero. -->
<math>
<mfrac linethickness="-1.23em">
<mi>x</mi>
Modified: trunk/Source/WebCore/CMakeLists.txt (203284 => 203285)
--- trunk/Source/WebCore/CMakeLists.txt 2016-07-15 18:06:17 UTC (rev 203284)
+++ trunk/Source/WebCore/CMakeLists.txt 2016-07-15 18:24:47 UTC (rev 203285)
@@ -1985,6 +1985,7 @@
loader/icon/PageURLRecord.cpp
mathml/MathMLElement.cpp
+ mathml/MathMLFractionElement.cpp
mathml/MathMLInlineContainerElement.cpp
mathml/MathMLMathElement.cpp
mathml/MathMLMencloseElement.cpp
Modified: trunk/Source/WebCore/ChangeLog (203284 => 203285)
--- trunk/Source/WebCore/ChangeLog 2016-07-15 18:06:17 UTC (rev 203284)
+++ trunk/Source/WebCore/ChangeLog 2016-07-15 18:24:47 UTC (rev 203285)
@@ -1,5 +1,54 @@
2016-07-15 Frederic Wang <[email protected]>
+ Move parsing of mfrac attributes into a MathMLFractionElement class
+ https://bugs.webkit.org/show_bug.cgi?id=159624
+
+ Reviewed by Brent Fulgham.
+
+ We move the parsing of mfrac attributes to a MathMLFractionElement class. This allows to
+ minimize the updates in RenderMathMLFraction and to remove the alignment members. Many of
+ the members in updateLayoutParameters are actually only used in layoutBlock and could be
+ removed in a follow-up patch. We also improve the resolution of negative line thickness value
+ since the MathML recommendation says it should be rounded up to the nearest valid
+ value (which is zero) instead of ignoring the attribute and using the line thickness.
+
+ No new tests, already covered by existing tests.
+
+ * CMakeLists.txt: Add MathMLFractionElement.
+ * WebCore.xcodeproj/project.pbxproj: Ditto.
+ * mathml/MathMLAllInOne.cpp: Ditto.
+ * mathml/MathMLFractionElement.cpp: Added.
+ (WebCore::MathMLFractionElement::MathMLFractionElement):
+ (WebCore::MathMLFractionElement::create):
+ (WebCore::MathMLFractionElement::lineThickness): Return the cached linethickness length,
+ parsing it again if it is dirty. This handles the special values "thin", "medium" and "thick"
+ or fallback to the general parseMathMLLength for MathML lengths.
+ (WebCore::MathMLFractionElement::cachedFractionAlignment): Return the cached alignment value,
+ parsing it again if it is dirty.
+ (WebCore::MathMLFractionElement::numeratorAlignment): Return the cached alignment.
+ (WebCore::MathMLFractionElement::denominatorAlignment): Ditto.
+ (WebCore::MathMLFractionElement::parseAttribute): Make attributes dirty.
+ (WebCore::MathMLFractionElement::createElementRenderer): Create a RenderMathMLFraction.
+ * mathml/MathMLFractionElement.h: Added.
+ * mathml/MathMLInlineContainerElement.cpp: We no longer need to handle fraction here.
+ (WebCore::MathMLInlineContainerElement::createElementRenderer):
+ * mathml/mathtags.in: Use MathMLFractionElement for mfrac.
+ * rendering/mathml/RenderMathMLFraction.cpp:
+ (WebCore::RenderMathMLFraction::updateLayoutParameters): New helper function to set the
+ layout parameters, replacing updateFromElement. We no longer parse and store the alignment
+ values here. We also change the resolution of negative values.
+ (WebCore::RenderMathMLFraction::horizontalOffset): Use the enum from MathMLFractionElement.
+ (WebCore::RenderMathMLFraction::layoutBlock): We call updateLayoutParameters instead of
+ updateFromElement. The numerator and denominator alignments are resolved here.
+ (WebCore::RenderMathMLFraction::parseAlignmentAttribute): Deleted. Parsing of alignment
+ attribute is now handled in MathMLFractionElement.
+ (WebCore::RenderMathMLFraction::updateFromElement): Deleted. Attribute changes are now
+ handled in MathMLFractionElement.
+ (WebCore::RenderMathMLFraction::styleDidChange): Deleted. Font changes are properly handled.
+ * rendering/mathml/RenderMathMLFraction.h: Update declarations.
+
+2016-07-15 Frederic Wang <[email protected]>
+
Check whether font is nonnull for GlyphData instead of calling GlyphData::isValid()
https://bugs.webkit.org/show_bug.cgi?id=159783
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (203284 => 203285)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-07-15 18:06:17 UTC (rev 203284)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-07-15 18:24:47 UTC (rev 203285)
@@ -6903,6 +6903,8 @@
FA654A6C1108ABED002615E0 /* MathMLTextElement.h in Headers */ = {isa = PBXBuildFile; fileRef = FA654A6A1108ABED002615E0 /* MathMLTextElement.h */; };
FABE72F41059C1EB00D999DD /* MathMLElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FABE72ED1059C1EB00D999DD /* MathMLElement.cpp */; };
FABE72F51059C1EB00D999DD /* MathMLElement.h in Headers */ = {isa = PBXBuildFile; fileRef = FABE72EE1059C1EB00D999DD /* MathMLElement.h */; };
+ 0BCF83F61059C1EB00D999DD /* MathMLFractionElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0BCF83EF1059C1EB00D999DD /* MathMLFractionElement.cpp */; };
+ 0BCF83F71059C1EB00D999DD /* MathMLFractionElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 0BCF83F01059C1EB00D999DD /* MathMLFractionElement.h */; };
FABE72F61059C1EB00D999DD /* MathMLInlineContainerElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FABE72EF1059C1EB00D999DD /* MathMLInlineContainerElement.cpp */; };
FABE72F71059C1EB00D999DD /* MathMLInlineContainerElement.h in Headers */ = {isa = PBXBuildFile; fileRef = FABE72F01059C1EB00D999DD /* MathMLInlineContainerElement.h */; };
FABE72F81059C1EB00D999DD /* MathMLMathElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FABE72F11059C1EB00D999DD /* MathMLMathElement.cpp */; };
@@ -15074,6 +15076,8 @@
FA6E466FCD0418A9966A5B60 /* DNSResolveQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DNSResolveQueue.h; sourceTree = "<group>"; };
FABE72ED1059C1EB00D999DD /* MathMLElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MathMLElement.cpp; sourceTree = "<group>"; };
FABE72EE1059C1EB00D999DD /* MathMLElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MathMLElement.h; sourceTree = "<group>"; };
+ 0BCF83EF1059C1EB00D999DD /* MathMLFractionElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MathMLFractionElement.cpp; sourceTree = "<group>"; };
+ 0BCF83F01059C1EB00D999DD /* MathMLFractionElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MathMLFractionElement.h; sourceTree = "<group>"; };
FABE72EF1059C1EB00D999DD /* MathMLInlineContainerElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MathMLInlineContainerElement.cpp; sourceTree = "<group>"; };
FABE72F01059C1EB00D999DD /* MathMLInlineContainerElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MathMLInlineContainerElement.h; sourceTree = "<group>"; };
FABE72F11059C1EB00D999DD /* MathMLMathElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MathMLMathElement.cpp; sourceTree = "<group>"; };
@@ -24870,6 +24874,8 @@
FA654A671108ABE2002615E0 /* mathattrs.in */,
FABE72ED1059C1EB00D999DD /* MathMLElement.cpp */,
FABE72EE1059C1EB00D999DD /* MathMLElement.h */,
+ 0BCF83EF1059C1EB00D999DD /* MathMLFractionElement.cpp */,
+ 0BCF83F01059C1EB00D999DD /* MathMLFractionElement.h */,
FABE72EF1059C1EB00D999DD /* MathMLInlineContainerElement.cpp */,
FABE72F01059C1EB00D999DD /* MathMLInlineContainerElement.h */,
FABE72F11059C1EB00D999DD /* MathMLMathElement.cpp */,
@@ -27416,6 +27422,7 @@
00C60E3F13D76D7E0092A275 /* MarkupTokenizerInlines.h in Headers */,
FABE72F51059C1EB00D999DD /* MathMLElement.h in Headers */,
44A28AAC12DFB8AC00AE923B /* MathMLElementFactory.h in Headers */,
+ 0BCF83F71059C1EB00D999DD /* MathMLFractionElement.h in Headers */,
FABE72F71059C1EB00D999DD /* MathMLInlineContainerElement.h in Headers */,
FABE72F91059C1EB00D999DD /* MathMLMathElement.h in Headers */,
44A28AAF12DFB8BF00AE923B /* MathMLNames.h in Headers */,
@@ -31240,6 +31247,7 @@
9728C3131268E4390041E89B /* MarkupAccumulator.cpp in Sources */,
FABE72F41059C1EB00D999DD /* MathMLElement.cpp in Sources */,
FABE72FD1059C21100D999DD /* MathMLElementFactory.cpp in Sources */,
+ 0BCF83F61059C1EB00D999DD /* MathMLFractionElement.cpp in Sources */,
FABE72F61059C1EB00D999DD /* MathMLInlineContainerElement.cpp in Sources */,
FABE72F81059C1EB00D999DD /* MathMLMathElement.cpp in Sources */,
05D913CEEAB2A60534218ACF /* MathMLMencloseElement.cpp in Sources */,
Modified: trunk/Source/WebCore/mathml/MathMLAllInOne.cpp (203284 => 203285)
--- trunk/Source/WebCore/mathml/MathMLAllInOne.cpp 2016-07-15 18:06:17 UTC (rev 203284)
+++ trunk/Source/WebCore/mathml/MathMLAllInOne.cpp 2016-07-15 18:24:47 UTC (rev 203285)
@@ -26,6 +26,7 @@
// This all-in-one cpp file cuts down on template bloat to allow us to build our Windows release build.
#include "MathMLElement.cpp"
+#include "MathMLFractionElement.cpp"
#include "MathMLInlineContainerElement.cpp"
#include "MathMLMathElement.cpp"
#include "MathMLMencloseElement.cpp"
Added: trunk/Source/WebCore/mathml/MathMLFractionElement.cpp (0 => 203285)
--- trunk/Source/WebCore/mathml/MathMLFractionElement.cpp (rev 0)
+++ trunk/Source/WebCore/mathml/MathMLFractionElement.cpp 2016-07-15 18:24:47 UTC (rev 203285)
@@ -0,0 +1,118 @@
+/*
+ * 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 "MathMLFractionElement.h"
+
+#include "RenderMathMLFraction.h"
+
+namespace WebCore {
+
+using namespace MathMLNames;
+
+inline MathMLFractionElement::MathMLFractionElement(const QualifiedName& tagName, Document& document)
+ : MathMLInlineContainerElement(tagName, document)
+{
+}
+
+Ref<MathMLFractionElement> MathMLFractionElement::create(const QualifiedName& tagName, Document& document)
+{
+ return adoptRef(*new MathMLFractionElement(tagName, document));
+}
+
+const MathMLElement::Length& MathMLFractionElement::lineThickness()
+{
+ if (!m_lineThickness.dirty)
+ return m_lineThickness;
+
+ // The MathML3 recommendation states that "medium" is the default thickness.
+ // However, it only states that "thin" and "thick" are respectively thiner and thicker.
+ // The MathML in HTML5 implementation note suggests 50% and 200% and these values are also used in Gecko.
+ String thickness = fastGetAttribute(linethicknessAttr);
+ if (equalLettersIgnoringASCIICase(thickness, "thin")) {
+ m_lineThickness.type = LengthType::UnitLess;
+ m_lineThickness.value = .5;
+ } else if (equalLettersIgnoringASCIICase(thickness, "medium")) {
+ m_lineThickness.type = LengthType::UnitLess;
+ m_lineThickness.value = 1;
+ } else if (equalLettersIgnoringASCIICase(thickness, "thick")) {
+ m_lineThickness.type = LengthType::UnitLess;
+ m_lineThickness.value = 2;
+ } else
+ m_lineThickness = parseMathMLLength(thickness);
+ m_lineThickness.dirty = false;
+ return m_lineThickness;
+}
+
+MathMLFractionElement::FractionAlignment MathMLFractionElement::cachedFractionAlignment(const QualifiedName& name, FractionAlignmentAttribute& alignment)
+{
+ if (!alignment.dirty)
+ return alignment.value;
+
+ String value = fastGetAttribute(name);
+ if (equalLettersIgnoringASCIICase(value, "left"))
+ alignment.value = FractionAlignmentLeft;
+ else if (equalLettersIgnoringASCIICase(value, "right"))
+ alignment.value = FractionAlignmentRight;
+ else
+ alignment.value = FractionAlignmentCenter;
+ alignment.dirty = false;
+ return alignment.value;
+}
+
+MathMLFractionElement::FractionAlignment MathMLFractionElement::numeratorAlignment()
+{
+ return cachedFractionAlignment(numalignAttr, m_numeratorAlignment);
+}
+
+MathMLFractionElement::FractionAlignment MathMLFractionElement::denominatorAlignment()
+{
+ return cachedFractionAlignment(denomalignAttr, m_denominatorAlignment);
+}
+
+void MathMLFractionElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
+{
+ if (name == linethicknessAttr)
+ m_lineThickness.dirty = true;
+ else if (name == numalignAttr)
+ m_numeratorAlignment.dirty = true;
+ else if (name == denomalignAttr)
+ m_denominatorAlignment.dirty = true;
+
+ MathMLElement::parseAttribute(name, value);
+}
+
+RenderPtr<RenderElement> MathMLFractionElement::createElementRenderer(RenderStyle&& style, const RenderTreePosition&)
+{
+ ASSERT(hasTagName(MathMLNames::mfracTag));
+ return createRenderer<RenderMathMLFraction>(*this, WTFMove(style));
+}
+
+}
+
+#endif // ENABLE(MATHML)
Property changes on: trunk/Source/WebCore/mathml/MathMLFractionElement.cpp
___________________________________________________________________
Added: svn:eol-style
+LF
\ No newline at end of property
Added: trunk/Source/WebCore/mathml/MathMLFractionElement.h (0 => 203285)
--- trunk/Source/WebCore/mathml/MathMLFractionElement.h (rev 0)
+++ trunk/Source/WebCore/mathml/MathMLFractionElement.h 2016-07-15 18:24:47 UTC (rev 203285)
@@ -0,0 +1,63 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+#if ENABLE(MATHML)
+#include "MathMLInlineContainerElement.h"
+
+namespace WebCore {
+
+class MathMLFractionElement final : public MathMLInlineContainerElement {
+public:
+ static Ref<MathMLFractionElement> create(const QualifiedName& tagName, Document&);
+ const Length& lineThickness();
+ enum FractionAlignment {
+ FractionAlignmentCenter,
+ FractionAlignmentLeft,
+ FractionAlignmentRight
+ };
+ FractionAlignment numeratorAlignment();
+ FractionAlignment denominatorAlignment();
+
+private:
+ MathMLFractionElement(const QualifiedName& tagName, Document&);
+ RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) final;
+ void parseAttribute(const QualifiedName&, const AtomicString&) final;
+
+ struct FractionAlignmentAttribute {
+ FractionAlignment value { FractionAlignmentCenter };
+ bool dirty { true };
+ };
+ FractionAlignment cachedFractionAlignment(const QualifiedName&, FractionAlignmentAttribute&);
+
+ Length m_lineThickness;
+ FractionAlignmentAttribute m_numeratorAlignment;
+ FractionAlignmentAttribute m_denominatorAlignment;
+};
+
+}
+
+#endif // ENABLE(MATHML)
Property changes on: trunk/Source/WebCore/mathml/MathMLFractionElement.h
___________________________________________________________________
Added: svn:eol-style
+LF
\ No newline at end of property
Modified: trunk/Source/WebCore/mathml/MathMLInlineContainerElement.cpp (203284 => 203285)
--- trunk/Source/WebCore/mathml/MathMLInlineContainerElement.cpp 2016-07-15 18:06:17 UTC (rev 203284)
+++ trunk/Source/WebCore/mathml/MathMLInlineContainerElement.cpp 2016-07-15 18:24:47 UTC (rev 203285)
@@ -33,7 +33,6 @@
#include "MathMLNames.h"
#include "RenderMathMLBlock.h"
#include "RenderMathMLFenced.h"
-#include "RenderMathMLFraction.h"
#include "RenderMathMLMenclose.h"
#include "RenderMathMLRoot.h"
#include "RenderMathMLRow.h"
@@ -71,8 +70,6 @@
return createRenderer<RenderMathMLScripts>(*this, WTFMove(style));
if (hasTagName(moverTag) || hasTagName(munderTag) || hasTagName(munderoverTag))
return createRenderer<RenderMathMLUnderOver>(*this, WTFMove(style));
- if (hasTagName(mfracTag))
- return createRenderer<RenderMathMLFraction>(*this, WTFMove(style));
if (hasTagName(msqrtTag) || hasTagName(mrootTag))
return createRenderer<RenderMathMLRoot>(*this, WTFMove(style));
if (hasTagName(mfencedTag))
Modified: trunk/Source/WebCore/mathml/mathtags.in (203284 => 203285)
--- trunk/Source/WebCore/mathml/mathtags.in 2016-07-15 18:06:17 UTC (rev 203284)
+++ trunk/Source/WebCore/mathml/mathtags.in 2016-07-15 18:24:47 UTC (rev 203285)
@@ -7,7 +7,7 @@
annotation-xml interfaceName=MathMLInlineContainerElement
maction interfaceName=MathMLSelectElement
math
-mfrac interfaceName=MathMLInlineContainerElement
+mfrac interfaceName=MathMLFractionElement
mfenced interfaceName=MathMLInlineContainerElement
msubsup interfaceName=MathMLInlineContainerElement
merror interfaceName=MathMLInlineContainerElement
Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp (203284 => 203285)
--- trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp 2016-07-15 18:06:17 UTC (rev 203284)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp 2016-07-15 18:24:47 UTC (rev 203285)
@@ -44,15 +44,6 @@
{
}
-RenderMathMLFraction::FractionAlignment RenderMathMLFraction::parseAlignmentAttribute(const String& value)
-{
- if (equalLettersIgnoringASCIICase(value, "left"))
- return FractionAlignmentLeft;
- if (equalLettersIgnoringASCIICase(value, "right"))
- return FractionAlignmentRight;
- return FractionAlignmentCenter;
-}
-
bool RenderMathMLFraction::isValid() const
{
// Verify whether the list of children is valid:
@@ -76,11 +67,8 @@
return *firstChildBox()->nextSiblingBox();
}
-void RenderMathMLFraction::updateFromElement()
+void RenderMathMLFraction::updateLayoutParameters()
{
- if (isEmpty())
- return;
-
// We try and read constants to draw the fraction from the OpenType MATH and use fallback values otherwise.
// We also parse presentation attributes of the <mfrac> element.
@@ -92,22 +80,10 @@
else
m_defaultLineThickness = ruleThicknessFallback();
- // Next, we parse the linethickness attribute.
- // The MathML3 recommendation states that "medium" is the default thickness.
- // However, it only states that "thin" and "thick" are respectively thiner and thicker.
- // The MathML in HTML5 implementation note suggests 50% and 200% and these values are also used in Gecko.
- String thickness = element().getAttribute(MathMLNames::linethicknessAttr);
- if (equalLettersIgnoringASCIICase(thickness, "thin"))
- m_lineThickness = m_defaultLineThickness / 2;
- else if (equalLettersIgnoringASCIICase(thickness, "medium"))
- m_lineThickness = m_defaultLineThickness;
- else if (equalLettersIgnoringASCIICase(thickness, "thick"))
- m_lineThickness = m_defaultLineThickness * 2;
- else {
- // Parse the thickness using m_defaultLineThickness as the default value.
- m_lineThickness = m_defaultLineThickness;
- parseMathMLLength(thickness, m_lineThickness, &style(), false);
- }
+ // Resolve the thickness using m_defaultLineThickness as the default value.
+ m_lineThickness = toUserUnits(element().lineThickness(), style(), m_defaultLineThickness);
+ if (m_lineThickness < 0)
+ m_lineThickness = 0;
// We now know whether we should layout as a normal fraction or as a stack (fraction without bar) and so determine the relevant constants.
bool display = mathMLStyle()->displayStyle();
@@ -137,19 +113,8 @@
m_numeratorMinShiftUp = m_denominatorMinShiftDown = 0;
}
}
-
- // Parse alignment attributes.
- m_numeratorAlign = parseAlignmentAttribute(element().getAttribute(MathMLNames::numalignAttr));
- m_denominatorAlign = parseAlignmentAttribute(element().getAttribute(MathMLNames::denomalignAttr));
}
-void RenderMathMLFraction::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
-{
- RenderMathMLBlock::styleDidChange(diff, oldStyle);
-
- updateFromElement();
-}
-
RenderMathMLOperator* RenderMathMLFraction::unembellishedOperator()
{
if (!isValid() || !is<RenderMathMLBlock>(numerator()))
@@ -173,14 +138,14 @@
setPreferredLogicalWidthsDirty(false);
}
-LayoutUnit RenderMathMLFraction::horizontalOffset(RenderBox& child, FractionAlignment align)
+LayoutUnit RenderMathMLFraction::horizontalOffset(RenderBox& child, MathMLFractionElement::FractionAlignment align)
{
switch (align) {
- case FractionAlignmentRight:
+ case MathMLFractionElement::FractionAlignmentRight:
return LayoutUnit(logicalWidth() - child.logicalWidth());
- case FractionAlignmentCenter:
+ case MathMLFractionElement::FractionAlignmentCenter:
return LayoutUnit((logicalWidth() - child.logicalWidth()) / 2);
- case FractionAlignmentLeft:
+ case MathMLFractionElement::FractionAlignmentLeft:
return LayoutUnit(0);
}
@@ -192,9 +157,6 @@
{
ASSERT(needsLayout());
- // FIXME: We should be able to remove this.
- updateFromElement();
-
if (!relayoutChildren && simplifiedLayout())
return;
@@ -210,8 +172,9 @@
setLogicalWidth(std::max(numerator().logicalWidth(), denominator().logicalWidth()));
+ updateLayoutParameters();
LayoutUnit verticalOffset = 0; // This is the top of the renderer.
- LayoutPoint numeratorLocation(horizontalOffset(numerator(), m_numeratorAlign), verticalOffset);
+ LayoutPoint numeratorLocation(horizontalOffset(numerator(), element().numeratorAlignment()), verticalOffset);
numerator().setLocation(numeratorLocation);
LayoutUnit numeratorAscent = ascentForChild(numerator());
@@ -237,7 +200,7 @@
verticalOffset += std::max(m_lineThickness / 2 + m_denominatorGapMin, m_denominatorMinShiftDown - denominatorAscent);
}
- LayoutPoint denominatorLocation(horizontalOffset(denominator(), m_denominatorAlign), verticalOffset);
+ LayoutPoint denominatorLocation(horizontalOffset(denominator(), element().denominatorAlignment()), verticalOffset);
denominator().setLocation(denominatorLocation);
verticalOffset = std::max(verticalOffset + denominator().logicalHeight(), m_ascent + denominatorDescent); // This is the bottom of our renderer.
Modified: trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.h (203284 => 203285)
--- trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.h 2016-07-15 18:06:17 UTC (rev 203284)
+++ trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.h 2016-07-15 18:24:47 UTC (rev 203285)
@@ -29,6 +29,7 @@
#if ENABLE(MATHML)
+#include "MathMLFractionElement.h"
#include "MathMLInlineContainerElement.h"
#include "RenderMathMLBlock.h"
@@ -38,11 +39,8 @@
public:
RenderMathMLFraction(MathMLInlineContainerElement&, RenderStyle&&);
- MathMLInlineContainerElement& element() { return static_cast<MathMLInlineContainerElement&>(nodeForNonAnonymous()); }
float relativeLineThickness() const { return m_defaultLineThickness ? m_lineThickness / m_defaultLineThickness : LayoutUnit(0); }
- void updateFromElement() final;
-
private:
bool isRenderMathMLFraction() const final { return true; }
const char* renderName() const final { return "RenderMathMLFraction"; }
@@ -52,19 +50,15 @@
Optional<int> firstLineBaseline() const final;
void paint(PaintInfo&, const LayoutPoint&) final;
RenderMathMLOperator* unembellishedOperator() final;
- void styleDidChange(StyleDifference, const RenderStyle* oldStyle) final;
+ MathMLFractionElement& element() const { return static_cast<MathMLFractionElement&>(nodeForNonAnonymous()); }
+
bool isStack() const { return !m_lineThickness; }
bool isValid() const;
RenderBox& numerator() const;
RenderBox& denominator() const;
- enum FractionAlignment {
- FractionAlignmentCenter,
- FractionAlignmentLeft,
- FractionAlignmentRight
- };
- FractionAlignment parseAlignmentAttribute(const String& value);
- LayoutUnit horizontalOffset(RenderBox&, FractionAlignment);
+ LayoutUnit horizontalOffset(RenderBox&, MathMLFractionElement::FractionAlignment);
+ void updateLayoutParameters();
LayoutUnit m_ascent;
LayoutUnit m_defaultLineThickness { 1 };
@@ -82,8 +76,6 @@
LayoutUnit m_denominatorMinShiftDown;
LayoutUnit m_bottomShiftDown;
};
- FractionAlignment m_numeratorAlign { FractionAlignmentCenter };
- FractionAlignment m_denominatorAlign { FractionAlignmentCenter };
};
} // namespace WebCore