Changeset 204037 in webkit
- Timestamp:
- Aug 2, 2016 12:53:57 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r204028 r204037 1 2016-08-02 Frederic Wang <fwang@igalia.com> 2 3 Move parsing of operator length attributes to MathMLOperatorElement 4 https://bugs.webkit.org/show_bug.cgi?id=160301 5 6 Reviewed by Darin Adler. 7 8 * mathml/presentation/stretchy-minsize-maxsize-expected.html: Update the test for negative 9 minsize and maxsize to align on the behavior suggested in the MathML recommendation. 10 * mathml/presentation/stretchy-minsize-maxsize.html: Ditto. 11 1 12 2016-08-02 Chris Dumez <cdumez@apple.com> 2 13 -
trunk/LayoutTests/mathml/presentation/stretchy-minsize-maxsize-expected.html
r164700 r204037 44 44 <math> 45 45 <mrow> 46 <mo symmetric="false" >|</mo>46 <mo symmetric="false" minsize="0em">|</mo> 47 47 <mspace height="4em" depth="4em"/> 48 48 </mrow> … … 50 50 <math> 51 51 <mrow> 52 <mo symmetric="false" >|</mo>52 <mo symmetric="false" maxsize="0em">|</mo> 53 53 <mspace height="4em" depth="4em"/> 54 54 </mrow> -
trunk/LayoutTests/mathml/presentation/stretchy-minsize-maxsize.html
r164700 r204037 46 46 </math> 47 47 48 <!-- We verify that negative values are ignored. -->48 <!-- We verify that negative values are treated as 0. --> 49 49 <math> 50 50 <mrow> -
trunk/Source/WebCore/ChangeLog
r204036 r204037 1 2016-08-02 Frederic Wang <fwang@igalia.com> 2 3 Move parsing of operator length attributes to MathMLOperatorElement 4 https://bugs.webkit.org/show_bug.cgi?id=160301 5 6 Reviewed by Darin Adler. 7 8 We move parsing of operator attributes lspace, rspace minsize, maxsize into the class 9 MathMLOperatorElement. We rely on the existing MathMLElement::Length structure and expand 10 it to handle the "infinity" case of maxsize that we always resolve as intMaxForLayoutUnit. 11 We also improve the resolution of a negative value for minsize and maxsize since the MathML 12 recommendation says it should be rounded up to the nearest valid value (which is zero) 13 instead of ignoring the attribute and using the default value. This is similar to r203285 14 for mfrac@linethickness. We also update the existing test for minsize/maxsize to take into 15 account that change. 16 17 No new tests, already covered by existing tests. 18 19 * mathml/MathMLElement.h: Add an "Infinity" type for MathML Length. 20 * mathml/MathMLOperatorElement.cpp: 21 (WebCore::MathMLOperatorElement::leadingSpace): Helper function to retrieve the cached value 22 for the lspace attribute, parse it if necessary. 23 (WebCore::MathMLOperatorElement::trailingSpace): Ditto for rspace. 24 (WebCore::MathMLOperatorElement::minSize): Ditto for minsize. 25 (WebCore::MathMLOperatorElement::maxSize): Ditto for maxsize. This attribute also accepts the 26 "infinity" value. 27 (WebCore::MathMLOperatorElement::parseAttribute): Mark attributes dirty. 28 * mathml/MathMLOperatorElement.h: Declare Length members and accessors. 29 * rendering/mathml/RenderMathMLBlock.cpp: 30 (WebCore::toUserUnits): Resolve Infinity as intMaxForLayoutUnit. 31 * rendering/mathml/RenderMathMLOperator.cpp: 32 (WebCore::RenderMathMLOperator::setOperatorProperties): We use toUserUnits to resolve the 33 lengths. Negative maxsize and minsize values now fallback to 0 instead of their default 34 values. We also remove the !isAnonymous() check since setOperatorProperties is overriden 35 in the RenderMathMLFencedOperator class. 36 1 37 2016-08-02 Frederic Wang <fred.wang@free.fr> 2 38 -
trunk/Source/WebCore/mathml/MathMLElement.h
r204021 r204037 60 60 // TeX's Math Unit is used internally for named spaces (1 mu = 1/18 em). 61 61 // Unitless values are interpreted as a multiple of a reference value. 62 enum class LengthType { Cm, Em, Ex, In, MathUnit, Mm, ParsingFailed, Pc, Percentage, Pt, Px, UnitLess };62 enum class LengthType { Cm, Em, Ex, In, MathUnit, Mm, ParsingFailed, Pc, Percentage, Pt, Px, UnitLess, Infinity }; 63 63 struct Length { 64 64 LengthType type { LengthType::ParsingFailed }; -
trunk/Source/WebCore/mathml/MathMLOperatorElement.cpp
r204036 r204037 180 180 } 181 181 182 const MathMLElement::Length& MathMLOperatorElement::leadingSpace() 183 { 184 return cachedMathMLLength(MathMLNames::lspaceAttr, m_leadingSpace); 185 } 186 187 const MathMLElement::Length& MathMLOperatorElement::trailingSpace() 188 { 189 return cachedMathMLLength(MathMLNames::rspaceAttr, m_trailingSpace); 190 } 191 192 const MathMLElement::Length& MathMLOperatorElement::minSize() 193 { 194 return cachedMathMLLength(MathMLNames::minsizeAttr, m_minSize); 195 } 196 197 const MathMLElement::Length& MathMLOperatorElement::maxSize() 198 { 199 if (m_maxSize) 200 return m_maxSize.value(); 201 202 const AtomicString& value = attributeWithoutSynchronization(MathMLNames::maxsizeAttr); 203 if (value == "infinity") { 204 Length maxsize; 205 maxsize.type = LengthType::Infinity; 206 m_maxSize = maxsize; 207 } else 208 m_maxSize = parseMathMLLength(value); 209 210 return m_maxSize.value(); 211 } 212 182 213 void MathMLOperatorElement::childrenChanged(const ChildChange& change) 183 214 { … … 214 245 } else if (auto flag = attributeNameToPropertyFlag(name)) 215 246 m_properties.dirtyFlags |= flag.value(); 247 else if (name == lspaceAttr) 248 m_leadingSpace = Nullopt; 249 else if (name == rspaceAttr) 250 m_trailingSpace = Nullopt; 251 else if (name == minsizeAttr) 252 m_minSize = Nullopt; 253 else if (name == maxsizeAttr) 254 m_maxSize = Nullopt; 216 255 217 256 if ((name == stretchyAttr || name == lspaceAttr || name == rspaceAttr || name == movablelimitsAttr) && renderer()) { -
trunk/Source/WebCore/mathml/MathMLOperatorElement.h
r204032 r204037 42 42 Length defaultLeadingSpace(); 43 43 Length defaultTrailingSpace(); 44 const Length& leadingSpace(); 45 const Length& trailingSpace(); 46 const Length& minSize(); 47 const Length& maxSize(); 44 48 45 49 private: … … 69 73 OperatorProperties m_properties; 70 74 void computeOperatorFlag(MathMLOperatorDictionary::Flag); 75 76 Optional<Length> m_leadingSpace; 77 Optional<Length> m_trailingSpace; 78 Optional<Length> m_minSize; 79 Optional<Length> m_maxSize; 71 80 }; 72 81 -
trunk/Source/WebCore/rendering/mathml/RenderMathMLBlock.cpp
r203106 r204037 166 166 case MathMLElement::LengthType::ParsingFailed: 167 167 return referenceValue; 168 case MathMLElement::LengthType::Infinity: 169 return intMaxForLayoutUnit; 168 170 default: 169 171 ASSERT_NOT_REACHED(); -
trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp
r204032 r204037 80 80 m_isVertical = MathMLOperatorDictionary::isVertical(textContent()); 81 81 82 // Initialize with the default values.82 // FIXME: Negative leading spaces must be implemented (https://webkit.org/b/124830). 83 83 m_leadingSpace = toUserUnits(element().defaultLeadingSpace(), style(), 0); 84 m_leadingSpace = std::max<LayoutUnit>(0, toUserUnits(element().leadingSpace(), style(), m_leadingSpace)); 85 86 // FIXME: Negative trailing spaces must be implemented (https://webkit.org/b/124830). 84 87 m_trailingSpace = toUserUnits(element().defaultTrailingSpace(), style(), 0); 85 m_minSize = style().fontCascade().size(); // This sets minsize to "1em". 86 m_maxSize = intMaxForLayoutUnit; // This sets maxsize to "infinity". 87 88 if (!isAnonymous()) { 89 // Finally, we make the attribute values override the default. 90 parseMathMLLength(element().attributeWithoutSynchronization(MathMLNames::lspaceAttr), m_leadingSpace, &style(), false); // FIXME: Negative leading space must be implemented (https://bugs.webkit.org/show_bug.cgi?id=124830). 91 parseMathMLLength(element().attributeWithoutSynchronization(MathMLNames::rspaceAttr), m_trailingSpace, &style(), false); // FIXME: Negative trailing space must be implemented (https://bugs.webkit.org/show_bug.cgi?id=124830). 92 93 parseMathMLLength(element().attributeWithoutSynchronization(MathMLNames::minsizeAttr), m_minSize, &style(), false); 94 const AtomicString& maxsize = element().attributeWithoutSynchronization(MathMLNames::maxsizeAttr); 95 if (maxsize != "infinity") 96 parseMathMLLength(maxsize, m_maxSize, &style(), false); 97 } 88 m_trailingSpace = std::max<LayoutUnit>(0, toUserUnits(element().trailingSpace(), style(), m_trailingSpace)); 89 90 m_minSize = style().fontCascade().size(); // Default minsize is "1em". 91 m_minSize = std::max<LayoutUnit>(0, toUserUnits(element().minSize(), style(), m_minSize)); 92 93 m_maxSize = intMaxForLayoutUnit; // Default maxsize is "infinity". 94 m_maxSize = std::max<LayoutUnit>(0, toUserUnits(element().maxSize(), style(), m_maxSize)); 98 95 } 99 96
Note: See TracChangeset
for help on using the changeset viewer.