Changeset 201862 in webkit
- Timestamp:
- Jun 9, 2016 7:50:19 AM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r201861 r201862 1 2016-06-09 Frederic Wang <fwang@igalia.com> 2 3 Introduce MathOperator::Type 4 https://bugs.webkit.org/show_bug.cgi?id=156950 5 6 Reviewed by Sergio Villar Senin. 7 8 No new tests, behavior is not change. 9 10 An enum Type is introduced in MathOperator in order to indicate 11 which kind of stretching is requested. In follow-up work, this will 12 allow to just call setOperator and stretchTo without having to 13 explicitly call calculateDisplayStyleLargeOperator or calculateStretchyData. 14 15 * rendering/mathml/MathOperator.cpp: 16 (WebCore::MathOperator::setOperator): Use Type instead of a boolean. 17 (WebCore::MathOperator::setGlyphAssembly): Add an assert to ensure that the function is correctly used. 18 (WebCore::MathOperator::calculateDisplayStyleLargeOperator): Ditto, this makes the assert more accurate. 19 (WebCore::MathOperator::calculateStretchyData): Ditto and replace m_isVertical with a local isVertical variable. 20 (WebCore::MathOperator::fillWithVerticalExtensionGlyph): Ditto. 21 (WebCore::MathOperator::fillWithHorizontalExtensionGlyph): Ditto. 22 (WebCore::MathOperator::paintVerticalGlyphAssembly): Ditto. 23 (WebCore::MathOperator::paintHorizontalGlyphAssembly): Ditto. 24 * rendering/mathml/MathOperator.h: Add the Type enum. 25 (WebCore::MathOperator::stretchSize): Use Type instead of a boolean and add an 26 assert to ensure that the function is correctly used. 27 * rendering/mathml/RenderMathMLOperator.cpp: 28 (WebCore::RenderMathMLOperator::computePreferredLogicalWidths): Call setOperator with the correct value. 29 (WebCore::RenderMathMLOperator::updateStyle): Ditto. 30 1 31 2016-06-09 Commit Queue <commit-queue@webkit.org> 2 32 -
trunk/Source/WebCore/rendering/mathml/MathOperator.cpp
r201854 r201862 76 76 }; 77 77 78 void MathOperator::setOperator(UChar baseCharacter, bool isVertical)78 void MathOperator::setOperator(UChar baseCharacter, Type operatorType) 79 79 { 80 80 m_baseCharacter = baseCharacter; 81 m_isVertical = isVertical; 81 m_operatorType = operatorType; 82 } 83 84 LayoutUnit MathOperator::stretchSize() const 85 { 86 ASSERT(m_operatorType == Type::VerticalOperator || m_operatorType == Type::HorizontalOperator); 87 return m_operatorType == Type::VerticalOperator ? m_ascent + m_descent : m_width; 82 88 } 83 89 … … 98 104 void MathOperator::setGlyphAssembly(const GlyphAssemblyData& assemblyData) 99 105 { 106 ASSERT(m_operatorType == Type::VerticalOperator || m_operatorType == Type::HorizontalOperator); 100 107 m_stretchType = StretchType::GlyphAssembly; 101 108 m_assembly = assemblyData; … … 104 111 void MathOperator::calculateDisplayStyleLargeOperator(const RenderStyle& style) 105 112 { 106 ASSERT(m_ isVertical);113 ASSERT(m_operatorType == Type::DisplayOperator); 107 114 108 115 GlyphData baseGlyph; … … 231 238 void MathOperator::calculateStretchyData(const RenderStyle& style, float* maximumGlyphWidth, LayoutUnit targetSize) 232 239 { 233 ASSERT(!maximumGlyphWidth || m_isVertical); 240 ASSERT(m_operatorType == Type::VerticalOperator || m_operatorType == Type::HorizontalOperator); 241 ASSERT(!maximumGlyphWidth || m_operatorType == Type::VerticalOperator); 242 bool isVertical = m_operatorType == Type::VerticalOperator; 234 243 235 244 GlyphData baseGlyph; … … 239 248 if (!maximumGlyphWidth) { 240 249 // We do not stretch if the base glyph is large enough. 241 float baseSize = m_isVertical ? heightForGlyph(baseGlyph) : advanceWidthForGlyph(baseGlyph);250 float baseSize = isVertical ? heightForGlyph(baseGlyph) : advanceWidthForGlyph(baseGlyph); 242 251 if (targetSize <= baseSize) 243 252 return; … … 248 257 Vector<Glyph> sizeVariants; 249 258 Vector<OpenTypeMathData::AssemblyPart> assemblyParts; 250 baseGlyph.font->mathData()->getMathVariants(baseGlyph.glyph, m_isVertical, sizeVariants, assemblyParts);259 baseGlyph.font->mathData()->getMathVariants(baseGlyph.glyph, isVertical, sizeVariants, assemblyParts); 251 260 // We verify the size variants. 252 261 for (auto& sizeVariant : sizeVariants) { … … 256 265 else { 257 266 setSizeVariant(glyphData); 258 float size = m_isVertical ? heightForGlyph(glyphData) : advanceWidthForGlyph(glyphData);267 float size = isVertical ? heightForGlyph(glyphData) : advanceWidthForGlyph(glyphData); 259 268 if (size >= targetSize) 260 269 return; … … 266 275 return; 267 276 } else { 268 if (! m_isVertical)277 if (!isVertical) 269 278 return; 270 279 … … 304 313 305 314 // We ensure that the size is large enough to avoid glyph overlaps. 306 float minSize = m_isVertical ?315 float minSize = isVertical ? 307 316 heightForGlyph(assemblyData.topOrRight) + heightForGlyph(assemblyData.middle) + heightForGlyph(assemblyData.bottomOrLeft) 308 317 : advanceWidthForGlyph(assemblyData.bottomOrLeft) + advanceWidthForGlyph(assemblyData.middle) + advanceWidthForGlyph(assemblyData.topOrRight); … … 367 376 void MathOperator::fillWithVerticalExtensionGlyph(const RenderStyle& style, PaintInfo& info, const LayoutPoint& from, const LayoutPoint& to) 368 377 { 369 ASSERT(m_ isVertical);378 ASSERT(m_operatorType == Type::VerticalOperator); 370 379 ASSERT(m_stretchType == StretchType::GlyphAssembly); 371 380 ASSERT(m_assembly.extension.isValid()); … … 405 414 void MathOperator::fillWithHorizontalExtensionGlyph(const RenderStyle& style, PaintInfo& info, const LayoutPoint& from, const LayoutPoint& to) 406 415 { 407 ASSERT( !m_isVertical);416 ASSERT(m_operatorType == Type::HorizontalOperator); 408 417 ASSERT(m_stretchType == StretchType::GlyphAssembly); 409 418 ASSERT(m_assembly.extension.isValid()); … … 441 450 void MathOperator::paintVerticalGlyphAssembly(const RenderStyle& style, PaintInfo& info, const LayoutPoint& paintOffset) 442 451 { 443 ASSERT(m_ isVertical);452 ASSERT(m_operatorType == Type::VerticalOperator); 444 453 ASSERT(m_stretchType == StretchType::GlyphAssembly); 445 454 ASSERT(m_assembly.topOrRight.isValid()); … … 473 482 void MathOperator::paintHorizontalGlyphAssembly(const RenderStyle& style, PaintInfo& info, const LayoutPoint& paintOffset) 474 483 { 475 ASSERT( !m_isVertical);484 ASSERT(m_operatorType == Type::HorizontalOperator); 476 485 ASSERT(m_stretchType == StretchType::GlyphAssembly); 477 486 ASSERT(m_assembly.bottomOrLeft.isValid()); -
trunk/Source/WebCore/rendering/mathml/MathOperator.h
r201854 r201862 41 41 public: 42 42 MathOperator() { } 43 void setOperator(UChar baseCharacter, bool isVertical); 43 enum class Type { UndefinedOperator, DisplayOperator, VerticalOperator, HorizontalOperator }; 44 void setOperator(UChar baseCharacter, Type); 44 45 45 46 LayoutUnit italicCorrection() const { return m_italicCorrection; } … … 66 67 }; 67 68 68 LayoutUnit stretchSize() const { return m_isVertical ? m_ascent + m_descent : m_width; };69 LayoutUnit stretchSize() const; 69 70 bool getBaseGlyph(const RenderStyle&, GlyphData&) const; 70 71 void setSizeVariant(const GlyphData&); … … 81 82 82 83 UChar m_baseCharacter = 0; 83 bool m_isVertical = false;84 Type m_operatorType { Type::UndefinedOperator }; 84 85 StretchType m_stretchType = StretchType::Unstretched; 85 86 union { -
trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp
r201854 r201862 268 268 } 269 269 270 m_mathOperator.setOperator(m_textContent, m_isVertical); 270 MathOperator::Type type; 271 if (isLargeOperatorInDisplayStyle()) 272 type = MathOperator::Type::DisplayOperator; 273 else 274 type = m_isVertical ? MathOperator::Type::VerticalOperator : MathOperator::Type::HorizontalOperator; 275 m_mathOperator.setOperator(m_textContent, type); 271 276 GlyphData baseGlyph; 272 277 float maximumGlyphWidth = m_mathOperator.getBaseGlyph(style(), baseGlyph) ? advanceWidthForGlyph(baseGlyph) : 0; … … 370 375 return; 371 376 372 m_mathOperator.setOperator(m_textContent, m_isVertical); 377 MathOperator::Type type; 378 if (isLargeOperatorInDisplayStyle()) 379 type = MathOperator::Type::DisplayOperator; 380 else 381 type = m_isVertical ? MathOperator::Type::VerticalOperator : MathOperator::Type::HorizontalOperator; 382 m_mathOperator.setOperator(m_textContent, type); 373 383 if (m_isVertical && isLargeOperatorInDisplayStyle()) 374 384 m_mathOperator.calculateDisplayStyleLargeOperator(style());
Note: See TracChangeset
for help on using the changeset viewer.