Source/WebCore/ChangeLog

 12016-04-22 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 NOBODY (OOPS!).
 7
 8 No new tests, this is only minor refactoring that does not change the code.
 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
1162016-04-21 Frederic Wang <fwang@igalia.com>
217
318 More improvements and explanations regarding resetting CSS properties on the <math> element

Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp

@@bool RenderMathMLOperator::getGlyphAssemblyFallBack(Vector<OpenTypeMathData::Ass
406406 if (nonExtenderCount > 3)
407407 return false; // This is not supported: there are too many pieces.
408408
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 expected = Start;
418419 extension.glyph = 0;
419420 middle.glyph = 0;
420421 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 (expected == ExtenderBetweenStartAndMiddle)
 425 expected = ExtenderBetweenMiddleAndEnd;
 426 else if (expected == Middle)
 427 expected = End;
424428 }
425429 if (part.isExtender) {
426430 if (!extension.glyph)

@@bool RenderMathMLOperator::getGlyphAssemblyFallBack(Vector<OpenTypeMathData::Ass
428432 else if (extension.glyph != part.glyph)
429433 return false; // This is not supported: the assembly has different extenders.
430434
431  if (state == 1) {
 435 if (expected == Start) {
432436 // We ignore left/bottom piece and multiple successive extenders.
433  state = 2;
434  } else if (state == 3) {
 437 expected = ExtenderBetweenStartAndMiddle;
 438 } else if (expected == Middle) {
435439 // We ignore middle piece and multiple successive extenders.
436  state = 4;
437  } else if (state >= 5)
 440 expected = ExtenderBetweenMiddleAndEnd;
 441 } else if (expected >= End)
438442 return false; // This is not supported: we got an unexpected extender.
439443 continue;
440444 }
441445
442  if (state == 1) {
 446 if (expected == Start) {
443447 // We copy the left/bottom part.
444448 bottom.glyph = part.glyph;
445  state = 2;
 449 expected = ExtenderBetweenStartAndMiddle;
446450 continue;
447451 }
448452
449  if (state == 2 || state == 3) {
 453 if (expected == ExtenderBetweenStartAndMiddle || expected == Middle) {
450454 // We copy the middle part.
451455 middle.glyph = part.glyph;
452  state = 4;
 456 expected = ExtenderBetweenMiddleAndEnd;
453457 continue;
454458 }
455459
456  if (state == 4 || state == 5) {
 460 if (expected == ExtenderBetweenMiddleAndEnd || expected == End) {
457461 // We copy the right/top part.
458462 top.glyph = part.glyph;
459  state = 6;
 463 expected = None;
460464 }
461465 }
462466

@@LayoutRect RenderMathMLOperator::paintGlyph(PaintInfo& info, const GlyphData& da
708712
709713 // In order to have glyphs fit snugly with one another we snap the connecting edges to pixel boundaries
710714 // 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
 715 // than full coverage. These edge pixels can introduce small seams between connected glyphs.
712716 FloatRect clipBounds = info.rect;
713717 switch (trim) {
714718 case TrimTop:

@@LayoutRect RenderMathMLOperator::paintGlyph(PaintInfo& info, const GlyphData& da
719723 glyphPaintRect.shiftMaxYEdgeTo(glyphPaintRect.maxY().floor() - 1);
720724 clipBounds.shiftMaxYEdgeTo(glyphPaintRect.maxY());
721725 break;
722  case TrimTopAndBottom: {
723  LayoutUnit temp = glyphPaintRect.y() + 1;
724  glyphPaintRect.shiftYEdgeTo(temp.ceil());
 726 case TrimTopAndBottom:
 727 glyphPaintRect.shiftYEdgeTo(glyphPaintRect.y().ceil() + 1);
725728 glyphPaintRect.shiftMaxYEdgeTo(glyphPaintRect.maxY().floor() - 1);
726729 clipBounds.shiftYEdgeTo(glyphPaintRect.y());
727730 clipBounds.shiftMaxYEdgeTo(glyphPaintRect.maxY());
728  }
729731 break;
730732 case TrimLeft:
731733 glyphPaintRect.shiftXEdgeTo(glyphPaintRect.x().ceil() + 1);

@@LayoutRect RenderMathMLOperator::paintGlyph(PaintInfo& info, const GlyphData& da
735737 glyphPaintRect.shiftMaxXEdgeTo(glyphPaintRect.maxX().floor() - 1);
736738 clipBounds.shiftMaxXEdgeTo(glyphPaintRect.maxX());
737739 break;
738  case TrimLeftAndRight: {
739  LayoutUnit temp = glyphPaintRect.x() + 1;
740  glyphPaintRect.shiftXEdgeTo(temp.ceil());
 740 case TrimLeftAndRight:
 741 glyphPaintRect.shiftXEdgeTo(glyphPaintRect.x().ceil() + 1);
741742 glyphPaintRect.shiftMaxXEdgeTo(glyphPaintRect.maxX().floor() - 1);
742743 clipBounds.shiftXEdgeTo(glyphPaintRect.x());
743744 clipBounds.shiftMaxXEdgeTo(glyphPaintRect.maxX());
744745 }
745  }
746746
747747 // Clipping the enclosing IntRect avoids any potential issues at joined edges.
748748 GraphicsContextStateSaver stateSaver(info.context());