Changeset 199978 in webkit
- Timestamp:
- Apr 25, 2016 12:04:46 AM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r199976 r199978 1 2016-04-25 Frederic Wang <fwang@igalia.com> 2 3 Minor refactoring in RenderMathMLOperator 4 https://bugs.webkit.org/show_bug.cgi?id=156906 5 6 Reviewed by Martin Robinson. 7 8 No new tests, this is only minor refactoring that does not change the behavior. 9 10 * rendering/mathml/RenderMathMLOperator.cpp: 11 (WebCore::RenderMathMLOperator::getGlyphAssemblyFallBack): 12 We rename the "state" integer to an "expected" enum indicating the next expected part. 13 (WebCore::RenderMathMLOperator::paintGlyph): We add a missing dot at the end of a sequence. 14 We also replace ceil(x+1) with ceil(x)+1 to get rid of the temporary variable. 15 1 16 2016-04-24 Chris Dumez <cdumez@apple.com> 2 17 -
trunk/Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp
r199964 r199978 407 407 return false; // This is not supported: there are too many pieces. 408 408 409 // We now browse the list of pieces. 410 // 1 = look for a left/bottom glyph 411 // 2 = look for an extender between left/bottom and mid 412 // 4 = look for a middle glyph 413 // 5 = look for an extender between middle and right/top 414 // 5 = look for a right/top glyph 415 // 6 = no more piece expected 416 unsigned state = 1; 417 409 // We now browse the list of pieces from left to right for horizontal operators and from bottom to top for vertical operators. 410 enum PartType { 411 Start, 412 ExtenderBetweenStartAndMiddle, 413 Middle, 414 ExtenderBetweenMiddleAndEnd, 415 End, 416 None 417 }; 418 PartType expectedPartType = Start; 418 419 extension.glyph = 0; 419 420 middle.glyph = 0; 420 421 for (auto& part : assemblyParts) { 421 if ((state == 2 || state == 3) && nonExtenderCount < 3) { 422 // We do not try to find a middle glyph. 423 state += 2; 422 if (nonExtenderCount < 3) { 423 // If we only have at most two non-extenders then we skip the middle glyph. 424 if (expectedPartType == ExtenderBetweenStartAndMiddle) 425 expectedPartType = ExtenderBetweenMiddleAndEnd; 426 else if (expectedPartType == Middle) 427 expectedPartType = End; 424 428 } 425 429 if (part.isExtender) { 426 430 if (!extension.glyph) 427 extension.glyph = part.glyph; 431 extension.glyph = part.glyph; // We copy the extender part. 428 432 else if (extension.glyph != part.glyph) 429 433 return false; // This is not supported: the assembly has different extenders. 430 434 431 if (state == 1) { 432 // We ignore left/bottom piece and multiple successive extenders. 433 state = 2; 434 } else if (state == 3) { 435 // We ignore middle piece and multiple successive extenders. 436 state = 4; 437 } else if (state >= 5) 438 return false; // This is not supported: we got an unexpected extender. 439 continue; 440 } 441 442 if (state == 1) { 435 switch (expectedPartType) { 436 case Start: 437 // We ignore the left/bottom part. 438 expectedPartType = ExtenderBetweenStartAndMiddle; 439 continue; 440 case Middle: 441 // We ignore the middle part. 442 expectedPartType = ExtenderBetweenMiddleAndEnd; 443 continue; 444 case End: 445 case None: 446 // This is not supported: we got an unexpected extender. 447 return false; 448 case ExtenderBetweenStartAndMiddle: 449 case ExtenderBetweenMiddleAndEnd: 450 // We ignore multiple consecutive extenders. 451 continue; 452 } 453 } 454 455 switch (expectedPartType) { 456 case Start: 443 457 // We copy the left/bottom part. 444 458 bottom.glyph = part.glyph; 445 state = 2;459 expectedPartType = ExtenderBetweenStartAndMiddle; 446 460 continue; 447 } 448 449 if (state == 2 || state == 3) { 461 case ExtenderBetweenStartAndMiddle: 462 case Middle: 450 463 // We copy the middle part. 451 464 middle.glyph = part.glyph; 452 state = 4;465 expectedPartType = ExtenderBetweenMiddleAndEnd; 453 466 continue; 454 } 455 456 if (state == 4 || state == 5) { 467 case ExtenderBetweenMiddleAndEnd: 468 case End: 457 469 // We copy the right/top part. 458 470 top.glyph = part.glyph; 459 state = 6; 471 expectedPartType = None; 472 continue; 473 case None: 474 // This is not supported: we got an unexpected non-extender part. 475 return false; 460 476 } 461 477 } … … 709 725 // In order to have glyphs fit snugly with one another we snap the connecting edges to pixel boundaries 710 726 // and trim off one pixel. The pixel trim is to account for fonts that have edge pixels that have less 711 // than full coverage. These edge pixels can introduce small seams between connected glyphs 727 // than full coverage. These edge pixels can introduce small seams between connected glyphs. 712 728 FloatRect clipBounds = info.rect; 713 729 switch (trim) { … … 720 736 clipBounds.shiftMaxYEdgeTo(glyphPaintRect.maxY()); 721 737 break; 722 case TrimTopAndBottom: { 723 LayoutUnit temp = glyphPaintRect.y() + 1; 724 glyphPaintRect.shiftYEdgeTo(temp.ceil()); 738 case TrimTopAndBottom: 739 glyphPaintRect.shiftYEdgeTo(glyphPaintRect.y().ceil() + 1); 725 740 glyphPaintRect.shiftMaxYEdgeTo(glyphPaintRect.maxY().floor() - 1); 726 741 clipBounds.shiftYEdgeTo(glyphPaintRect.y()); 727 742 clipBounds.shiftMaxYEdgeTo(glyphPaintRect.maxY()); 728 }729 743 break; 730 744 case TrimLeft: … … 736 750 clipBounds.shiftMaxXEdgeTo(glyphPaintRect.maxX()); 737 751 break; 738 case TrimLeftAndRight: { 739 LayoutUnit temp = glyphPaintRect.x() + 1; 740 glyphPaintRect.shiftXEdgeTo(temp.ceil()); 752 case TrimLeftAndRight: 753 glyphPaintRect.shiftXEdgeTo(glyphPaintRect.x().ceil() + 1); 741 754 glyphPaintRect.shiftMaxXEdgeTo(glyphPaintRect.maxX().floor() - 1); 742 755 clipBounds.shiftXEdgeTo(glyphPaintRect.x()); 743 756 clipBounds.shiftMaxXEdgeTo(glyphPaintRect.maxX()); 744 }745 757 } 746 758
Note: See TracChangeset
for help on using the changeset viewer.