Changeset 203285 in webkit
- Timestamp:
- Jul 15, 2016 11:24:47 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r203283 r203285 1 2016-07-15 Frederic Wang <fwang@igalia.com> 2 3 Move parsing of mfrac attributes into a MathMLFractionElementClass 4 https://bugs.webkit.org/show_bug.cgi?id=159624 5 6 Reviewed by Brent Fulgham. 7 8 We update the expectation for negative linethickness. As indicated in the MathML 9 recommendation, it should be rounded up to the nearest valid value, which is 0. 10 11 * mathml/presentation/mfrac-linethickness2.html: Update the comment to reflect the new behavior. 12 * mathml/presentation/mfrac-linethickness2-expected.html: Use 0px as the reference for negative values. 13 1 14 2016-07-15 Brent Fulgham <bfulgham@apple.com> 2 15 -
trunk/LayoutTests/mathml/presentation/mfrac-linethickness2-expected.html
r152140 r203285 7 7 8 8 <math> 9 <mfrac >9 <mfrac linethickness="0px"> 10 10 <mi>x</mi> 11 11 <mi>y</mi> -
trunk/LayoutTests/mathml/presentation/mfrac-linethickness2.html
r152140 r203285 6 6 <body> 7 7 8 <!-- The linethickness should be ignored-->8 <!-- Negative values are not accepted. We treat them as zero. --> 9 9 <math> 10 10 <mfrac linethickness="-1.23em"> -
trunk/Source/WebCore/CMakeLists.txt
r203244 r203285 1986 1986 1987 1987 mathml/MathMLElement.cpp 1988 mathml/MathMLFractionElement.cpp 1988 1989 mathml/MathMLInlineContainerElement.cpp 1989 1990 mathml/MathMLMathElement.cpp -
trunk/Source/WebCore/ChangeLog
r203280 r203285 1 2016-07-15 Frederic Wang <fwang@igalia.com> 2 3 Move parsing of mfrac attributes into a MathMLFractionElement class 4 https://bugs.webkit.org/show_bug.cgi?id=159624 5 6 Reviewed by Brent Fulgham. 7 8 We move the parsing of mfrac attributes to a MathMLFractionElement class. This allows to 9 minimize the updates in RenderMathMLFraction and to remove the alignment members. Many of 10 the members in updateLayoutParameters are actually only used in layoutBlock and could be 11 removed in a follow-up patch. We also improve the resolution of negative line thickness value 12 since the MathML recommendation says it should be rounded up to the nearest valid 13 value (which is zero) instead of ignoring the attribute and using the line thickness. 14 15 No new tests, already covered by existing tests. 16 17 * CMakeLists.txt: Add MathMLFractionElement. 18 * WebCore.xcodeproj/project.pbxproj: Ditto. 19 * mathml/MathMLAllInOne.cpp: Ditto. 20 * mathml/MathMLFractionElement.cpp: Added. 21 (WebCore::MathMLFractionElement::MathMLFractionElement): 22 (WebCore::MathMLFractionElement::create): 23 (WebCore::MathMLFractionElement::lineThickness): Return the cached linethickness length, 24 parsing it again if it is dirty. This handles the special values "thin", "medium" and "thick" 25 or fallback to the general parseMathMLLength for MathML lengths. 26 (WebCore::MathMLFractionElement::cachedFractionAlignment): Return the cached alignment value, 27 parsing it again if it is dirty. 28 (WebCore::MathMLFractionElement::numeratorAlignment): Return the cached alignment. 29 (WebCore::MathMLFractionElement::denominatorAlignment): Ditto. 30 (WebCore::MathMLFractionElement::parseAttribute): Make attributes dirty. 31 (WebCore::MathMLFractionElement::createElementRenderer): Create a RenderMathMLFraction. 32 * mathml/MathMLFractionElement.h: Added. 33 * mathml/MathMLInlineContainerElement.cpp: We no longer need to handle fraction here. 34 (WebCore::MathMLInlineContainerElement::createElementRenderer): 35 * mathml/mathtags.in: Use MathMLFractionElement for mfrac. 36 * rendering/mathml/RenderMathMLFraction.cpp: 37 (WebCore::RenderMathMLFraction::updateLayoutParameters): New helper function to set the 38 layout parameters, replacing updateFromElement. We no longer parse and store the alignment 39 values here. We also change the resolution of negative values. 40 (WebCore::RenderMathMLFraction::horizontalOffset): Use the enum from MathMLFractionElement. 41 (WebCore::RenderMathMLFraction::layoutBlock): We call updateLayoutParameters instead of 42 updateFromElement. The numerator and denominator alignments are resolved here. 43 (WebCore::RenderMathMLFraction::parseAlignmentAttribute): Deleted. Parsing of alignment 44 attribute is now handled in MathMLFractionElement. 45 (WebCore::RenderMathMLFraction::updateFromElement): Deleted. Attribute changes are now 46 handled in MathMLFractionElement. 47 (WebCore::RenderMathMLFraction::styleDidChange): Deleted. Font changes are properly handled. 48 * rendering/mathml/RenderMathMLFraction.h: Update declarations. 49 1 50 2016-07-15 Frederic Wang <fwang@igalia.com> 2 51 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r203244 r203285 6904 6904 FABE72F41059C1EB00D999DD /* MathMLElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FABE72ED1059C1EB00D999DD /* MathMLElement.cpp */; }; 6905 6905 FABE72F51059C1EB00D999DD /* MathMLElement.h in Headers */ = {isa = PBXBuildFile; fileRef = FABE72EE1059C1EB00D999DD /* MathMLElement.h */; }; 6906 0BCF83F61059C1EB00D999DD /* MathMLFractionElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0BCF83EF1059C1EB00D999DD /* MathMLFractionElement.cpp */; }; 6907 0BCF83F71059C1EB00D999DD /* MathMLFractionElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 0BCF83F01059C1EB00D999DD /* MathMLFractionElement.h */; }; 6906 6908 FABE72F61059C1EB00D999DD /* MathMLInlineContainerElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FABE72EF1059C1EB00D999DD /* MathMLInlineContainerElement.cpp */; }; 6907 6909 FABE72F71059C1EB00D999DD /* MathMLInlineContainerElement.h in Headers */ = {isa = PBXBuildFile; fileRef = FABE72F01059C1EB00D999DD /* MathMLInlineContainerElement.h */; }; … … 15075 15077 FABE72ED1059C1EB00D999DD /* MathMLElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MathMLElement.cpp; sourceTree = "<group>"; }; 15076 15078 FABE72EE1059C1EB00D999DD /* MathMLElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MathMLElement.h; sourceTree = "<group>"; }; 15079 0BCF83EF1059C1EB00D999DD /* MathMLFractionElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MathMLFractionElement.cpp; sourceTree = "<group>"; }; 15080 0BCF83F01059C1EB00D999DD /* MathMLFractionElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MathMLFractionElement.h; sourceTree = "<group>"; }; 15077 15081 FABE72EF1059C1EB00D999DD /* MathMLInlineContainerElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MathMLInlineContainerElement.cpp; sourceTree = "<group>"; }; 15078 15082 FABE72F01059C1EB00D999DD /* MathMLInlineContainerElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MathMLInlineContainerElement.h; sourceTree = "<group>"; }; … … 24871 24875 FABE72ED1059C1EB00D999DD /* MathMLElement.cpp */, 24872 24876 FABE72EE1059C1EB00D999DD /* MathMLElement.h */, 24877 0BCF83EF1059C1EB00D999DD /* MathMLFractionElement.cpp */, 24878 0BCF83F01059C1EB00D999DD /* MathMLFractionElement.h */, 24873 24879 FABE72EF1059C1EB00D999DD /* MathMLInlineContainerElement.cpp */, 24874 24880 FABE72F01059C1EB00D999DD /* MathMLInlineContainerElement.h */, … … 27417 27423 FABE72F51059C1EB00D999DD /* MathMLElement.h in Headers */, 27418 27424 44A28AAC12DFB8AC00AE923B /* MathMLElementFactory.h in Headers */, 27425 0BCF83F71059C1EB00D999DD /* MathMLFractionElement.h in Headers */, 27419 27426 FABE72F71059C1EB00D999DD /* MathMLInlineContainerElement.h in Headers */, 27420 27427 FABE72F91059C1EB00D999DD /* MathMLMathElement.h in Headers */, … … 31241 31248 FABE72F41059C1EB00D999DD /* MathMLElement.cpp in Sources */, 31242 31249 FABE72FD1059C21100D999DD /* MathMLElementFactory.cpp in Sources */, 31250 0BCF83F61059C1EB00D999DD /* MathMLFractionElement.cpp in Sources */, 31243 31251 FABE72F61059C1EB00D999DD /* MathMLInlineContainerElement.cpp in Sources */, 31244 31252 FABE72F81059C1EB00D999DD /* MathMLMathElement.cpp in Sources */, -
trunk/Source/WebCore/mathml/MathMLAllInOne.cpp
r203150 r203285 27 27 28 28 #include "MathMLElement.cpp" 29 #include "MathMLFractionElement.cpp" 29 30 #include "MathMLInlineContainerElement.cpp" 30 31 #include "MathMLMathElement.cpp" -
trunk/Source/WebCore/mathml/MathMLInlineContainerElement.cpp
r203150 r203285 34 34 #include "RenderMathMLBlock.h" 35 35 #include "RenderMathMLFenced.h" 36 #include "RenderMathMLFraction.h"37 36 #include "RenderMathMLMenclose.h" 38 37 #include "RenderMathMLRoot.h" … … 72 71 if (hasTagName(moverTag) || hasTagName(munderTag) || hasTagName(munderoverTag)) 73 72 return createRenderer<RenderMathMLUnderOver>(*this, WTFMove(style)); 74 if (hasTagName(mfracTag))75 return createRenderer<RenderMathMLFraction>(*this, WTFMove(style));76 73 if (hasTagName(msqrtTag) || hasTagName(mrootTag)) 77 74 return createRenderer<RenderMathMLRoot>(*this, WTFMove(style)); -
trunk/Source/WebCore/mathml/mathtags.in
r203150 r203285 8 8 maction interfaceName=MathMLSelectElement 9 9 math 10 mfrac interfaceName=MathML InlineContainerElement10 mfrac interfaceName=MathMLFractionElement 11 11 mfenced interfaceName=MathMLInlineContainerElement 12 12 msubsup interfaceName=MathMLInlineContainerElement -
trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.cpp
r203073 r203285 45 45 } 46 46 47 RenderMathMLFraction::FractionAlignment RenderMathMLFraction::parseAlignmentAttribute(const String& value)48 {49 if (equalLettersIgnoringASCIICase(value, "left"))50 return FractionAlignmentLeft;51 if (equalLettersIgnoringASCIICase(value, "right"))52 return FractionAlignmentRight;53 return FractionAlignmentCenter;54 }55 56 47 bool RenderMathMLFraction::isValid() const 57 48 { … … 77 68 } 78 69 79 void RenderMathMLFraction::updateFromElement() 80 { 81 if (isEmpty()) 82 return; 83 70 void RenderMathMLFraction::updateLayoutParameters() 71 { 84 72 // We try and read constants to draw the fraction from the OpenType MATH and use fallback values otherwise. 85 73 // We also parse presentation attributes of the <mfrac> element. … … 93 81 m_defaultLineThickness = ruleThicknessFallback(); 94 82 95 // Next, we parse the linethickness attribute. 96 // The MathML3 recommendation states that "medium" is the default thickness. 97 // However, it only states that "thin" and "thick" are respectively thiner and thicker. 98 // The MathML in HTML5 implementation note suggests 50% and 200% and these values are also used in Gecko. 99 String thickness = element().getAttribute(MathMLNames::linethicknessAttr); 100 if (equalLettersIgnoringASCIICase(thickness, "thin")) 101 m_lineThickness = m_defaultLineThickness / 2; 102 else if (equalLettersIgnoringASCIICase(thickness, "medium")) 103 m_lineThickness = m_defaultLineThickness; 104 else if (equalLettersIgnoringASCIICase(thickness, "thick")) 105 m_lineThickness = m_defaultLineThickness * 2; 106 else { 107 // Parse the thickness using m_defaultLineThickness as the default value. 108 m_lineThickness = m_defaultLineThickness; 109 parseMathMLLength(thickness, m_lineThickness, &style(), false); 110 } 83 // Resolve the thickness using m_defaultLineThickness as the default value. 84 m_lineThickness = toUserUnits(element().lineThickness(), style(), m_defaultLineThickness); 85 if (m_lineThickness < 0) 86 m_lineThickness = 0; 111 87 112 88 // We now know whether we should layout as a normal fraction or as a stack (fraction without bar) and so determine the relevant constants. … … 138 114 } 139 115 } 140 141 // Parse alignment attributes.142 m_numeratorAlign = parseAlignmentAttribute(element().getAttribute(MathMLNames::numalignAttr));143 m_denominatorAlign = parseAlignmentAttribute(element().getAttribute(MathMLNames::denomalignAttr));144 }145 146 void RenderMathMLFraction::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)147 {148 RenderMathMLBlock::styleDidChange(diff, oldStyle);149 150 updateFromElement();151 116 } 152 117 … … 174 139 } 175 140 176 LayoutUnit RenderMathMLFraction::horizontalOffset(RenderBox& child, FractionAlignment align)141 LayoutUnit RenderMathMLFraction::horizontalOffset(RenderBox& child, MathMLFractionElement::FractionAlignment align) 177 142 { 178 143 switch (align) { 179 case FractionAlignmentRight:144 case MathMLFractionElement::FractionAlignmentRight: 180 145 return LayoutUnit(logicalWidth() - child.logicalWidth()); 181 case FractionAlignmentCenter:146 case MathMLFractionElement::FractionAlignmentCenter: 182 147 return LayoutUnit((logicalWidth() - child.logicalWidth()) / 2); 183 case FractionAlignmentLeft:148 case MathMLFractionElement::FractionAlignmentLeft: 184 149 return LayoutUnit(0); 185 150 } … … 192 157 { 193 158 ASSERT(needsLayout()); 194 195 // FIXME: We should be able to remove this.196 updateFromElement();197 159 198 160 if (!relayoutChildren && simplifiedLayout()) … … 211 173 setLogicalWidth(std::max(numerator().logicalWidth(), denominator().logicalWidth())); 212 174 175 updateLayoutParameters(); 213 176 LayoutUnit verticalOffset = 0; // This is the top of the renderer. 214 LayoutPoint numeratorLocation(horizontalOffset(numerator(), m_numeratorAlign), verticalOffset);177 LayoutPoint numeratorLocation(horizontalOffset(numerator(), element().numeratorAlignment()), verticalOffset); 215 178 numerator().setLocation(numeratorLocation); 216 179 … … 238 201 } 239 202 240 LayoutPoint denominatorLocation(horizontalOffset(denominator(), m_denominatorAlign), verticalOffset);203 LayoutPoint denominatorLocation(horizontalOffset(denominator(), element().denominatorAlignment()), verticalOffset); 241 204 denominator().setLocation(denominatorLocation); 242 205 -
trunk/Source/WebCore/rendering/mathml/RenderMathMLFraction.h
r203228 r203285 30 30 #if ENABLE(MATHML) 31 31 32 #include "MathMLFractionElement.h" 32 33 #include "MathMLInlineContainerElement.h" 33 34 #include "RenderMathMLBlock.h" … … 39 40 RenderMathMLFraction(MathMLInlineContainerElement&, RenderStyle&&); 40 41 41 MathMLInlineContainerElement& element() { return static_cast<MathMLInlineContainerElement&>(nodeForNonAnonymous()); }42 42 float relativeLineThickness() const { return m_defaultLineThickness ? m_lineThickness / m_defaultLineThickness : LayoutUnit(0); } 43 44 void updateFromElement() final;45 43 46 44 private: … … 53 51 void paint(PaintInfo&, const LayoutPoint&) final; 54 52 RenderMathMLOperator* unembellishedOperator() final; 55 void styleDidChange(StyleDifference, const RenderStyle* oldStyle) final; 53 54 MathMLFractionElement& element() const { return static_cast<MathMLFractionElement&>(nodeForNonAnonymous()); } 56 55 57 56 bool isStack() const { return !m_lineThickness; } … … 59 58 RenderBox& numerator() const; 60 59 RenderBox& denominator() const; 61 enum FractionAlignment { 62 FractionAlignmentCenter, 63 FractionAlignmentLeft, 64 FractionAlignmentRight 65 }; 66 FractionAlignment parseAlignmentAttribute(const String& value); 67 LayoutUnit horizontalOffset(RenderBox&, FractionAlignment); 60 LayoutUnit horizontalOffset(RenderBox&, MathMLFractionElement::FractionAlignment); 61 void updateLayoutParameters(); 68 62 69 63 LayoutUnit m_ascent; … … 83 77 LayoutUnit m_bottomShiftDown; 84 78 }; 85 FractionAlignment m_numeratorAlign { FractionAlignmentCenter };86 FractionAlignment m_denominatorAlign { FractionAlignmentCenter };87 79 }; 88 80
Note: See TracChangeset
for help on using the changeset viewer.