Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(300)

Side by Side Diff: Source/core/rendering/InlineTextBox.cpp

Issue 187783002: Fix incorrect indices for emphasis marks drawing in InlineTextBox::paint (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Keeping previous FIXME Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « LayoutTests/fast/text/emphasis-combined-text.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * (C) 1999 Lars Knoll (knoll@kde.org) 2 * (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Dirk Mueller (mueller@kde.org) 3 * (C) 2000 Dirk Mueller (mueller@kde.org)
4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. 4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 698
699 if (!emphasisMark.isEmpty()) { 699 if (!emphasisMark.isEmpty()) {
700 updateGraphicsContext(context, emphasisMarkColor, textStrokeColor, t extStrokeWidth); 700 updateGraphicsContext(context, emphasisMarkColor, textStrokeColor, t extStrokeWidth);
701 701
702 DEFINE_STATIC_LOCAL(TextRun, objectReplacementCharacterTextRun, (&ob jectReplacementCharacter, 1)); 702 DEFINE_STATIC_LOCAL(TextRun, objectReplacementCharacterTextRun, (&ob jectReplacementCharacter, 1));
703 TextRun& emphasisMarkTextRun = combinedText ? objectReplacementChara cterTextRun : textRun; 703 TextRun& emphasisMarkTextRun = combinedText ? objectReplacementChara cterTextRun : textRun;
704 FloatPoint emphasisMarkTextOrigin = combinedText ? FloatPoint(boxOri gin.x() + boxRect.width() / 2, boxOrigin.y() + font.fontMetrics().ascent()) : te xtOrigin; 704 FloatPoint emphasisMarkTextOrigin = combinedText ? FloatPoint(boxOri gin.x() + boxRect.width() / 2, boxOrigin.y() + font.fontMetrics().ascent()) : te xtOrigin;
705 if (combinedText) 705 if (combinedText)
706 context->concatCTM(rotation(boxRect, Clockwise)); 706 context->concatCTM(rotation(boxRect, Clockwise));
707 707
708 if (!paintSelectedTextSeparately || ePos <= sPos) { 708 int startOffset = 0;
709 // FIXME: Truncate right-to-left text correctly. 709 int endOffset = length;
710 paintTextWithShadows(context, rendererToUse, combinedText ? comb inedText->originalFont() : font, emphasisMarkTextRun, emphasisMark, emphasisMark Offset, 0, length, length, emphasisMarkTextOrigin, boxRect, textShadow, textStro keWidth > 0, isHorizontal()); 710 int paintRunLength = length;
711 } else { 711 if (combinedText) {
712 paintTextWithShadows(context, rendererToUse, combinedText ? comb inedText->originalFont() : font, emphasisMarkTextRun, emphasisMark, emphasisMark Offset, ePos, sPos, length, emphasisMarkTextOrigin, boxRect, textShadow, textStr okeWidth > 0, isHorizontal()); 712 startOffset = 0;
713 endOffset = objectReplacementCharacterTextRun.length();
714 paintRunLength = endOffset;
715 } else if (paintSelectedTextSeparately && ePos > sPos) {
716 startOffset = ePos;
717 endOffset = sPos;
713 } 718 }
719 // FIXME: Truncate right-to-left text correctly.
720 paintTextWithShadows(context, rendererToUse, combinedText ? combined Text->originalFont() : font, emphasisMarkTextRun, emphasisMark, emphasisMarkOffs et, startOffset, endOffset, paintRunLength, emphasisMarkTextOrigin, boxRect, tex tShadow, textStrokeWidth > 0, isHorizontal());
714 721
715 if (combinedText) 722 if (combinedText)
716 context->concatCTM(rotation(boxRect, Counterclockwise)); 723 context->concatCTM(rotation(boxRect, Counterclockwise));
717 } 724 }
718 } 725 }
719 726
720 if ((paintSelectedTextOnly || paintSelectedTextSeparately) && sPos < ePos) { 727 if ((paintSelectedTextOnly || paintSelectedTextSeparately) && sPos < ePos) {
721 // paint only the text that is selected 728 // paint only the text that is selected
722 GraphicsContextStateSaver stateSaver(*context, selectionStrokeWidth > 0) ; 729 GraphicsContextStateSaver stateSaver(*context, selectionStrokeWidth > 0) ;
723 730
724 updateGraphicsContext(context, selectionFillColor, selectionStrokeColor, selectionStrokeWidth); 731 updateGraphicsContext(context, selectionFillColor, selectionStrokeColor, selectionStrokeWidth);
725 paintTextWithShadows(context, rendererToUse, font, textRun, nullAtom, 0, sPos, ePos, length, textOrigin, boxRect, selectionShadow, selectionStrokeWidth > 0, isHorizontal()); 732 paintTextWithShadows(context, rendererToUse, font, textRun, nullAtom, 0, sPos, ePos, length, textOrigin, boxRect, selectionShadow, selectionStrokeWidth > 0, isHorizontal());
726 if (!emphasisMark.isEmpty()) { 733 if (!emphasisMark.isEmpty()) {
727 updateGraphicsContext(context, selectionEmphasisMarkColor, textStrok eColor, textStrokeWidth); 734 updateGraphicsContext(context, selectionEmphasisMarkColor, textStrok eColor, textStrokeWidth);
728 735
729 DEFINE_STATIC_LOCAL(TextRun, objectReplacementCharacterTextRun, (&ob jectReplacementCharacter, 1)); 736 DEFINE_STATIC_LOCAL(TextRun, objectReplacementCharacterTextRun, (&ob jectReplacementCharacter, 1));
730 TextRun& emphasisMarkTextRun = combinedText ? objectReplacementChara cterTextRun : textRun; 737 TextRun& emphasisMarkTextRun = combinedText ? objectReplacementChara cterTextRun : textRun;
731 FloatPoint emphasisMarkTextOrigin = combinedText ? FloatPoint(boxOri gin.x() + boxRect.width() / 2, boxOrigin.y() + font.fontMetrics().ascent()) : te xtOrigin; 738 FloatPoint emphasisMarkTextOrigin = combinedText ? FloatPoint(boxOri gin.x() + boxRect.width() / 2, boxOrigin.y() + font.fontMetrics().ascent()) : te xtOrigin;
732 if (combinedText) 739 if (combinedText)
733 context->concatCTM(rotation(boxRect, Clockwise)); 740 context->concatCTM(rotation(boxRect, Clockwise));
734 741
735 paintTextWithShadows(context, rendererToUse, combinedText ? combined Text->originalFont() : font, emphasisMarkTextRun, emphasisMark, emphasisMarkOffs et, sPos, ePos, length, emphasisMarkTextOrigin, boxRect, selectionShadow, select ionStrokeWidth > 0, isHorizontal()); 742 int startOffset = combinedText ? 0 : sPos;
743 int endOffset = combinedText ? objectReplacementCharacterTextRun.len gth() : ePos;
744 int paintRunLength = combinedText ? endOffset : length;
745 paintTextWithShadows(context, rendererToUse, combinedText ? combined Text->originalFont() : font, emphasisMarkTextRun, emphasisMark, emphasisMarkOffs et, startOffset, endOffset, paintRunLength, emphasisMarkTextOrigin, boxRect, sel ectionShadow, selectionStrokeWidth > 0, isHorizontal());
736 746
737 if (combinedText) 747 if (combinedText)
738 context->concatCTM(rotation(boxRect, Counterclockwise)); 748 context->concatCTM(rotation(boxRect, Counterclockwise));
739 } 749 }
740 } 750 }
741 751
742 // Paint decorations 752 // Paint decorations
743 TextDecoration textDecorations = styleToUse->textDecorationsInEffect(); 753 TextDecoration textDecorations = styleToUse->textDecorationsInEffect();
744 if (textDecorations != TextDecorationNone && paintInfo.phase != PaintPhaseSe lection) { 754 if (textDecorations != TextDecorationNone && paintInfo.phase != PaintPhaseSe lection) {
745 updateGraphicsContext(context, textFillColor, textStrokeColor, textStrok eWidth); 755 updateGraphicsContext(context, textFillColor, textStrokeColor, textStrok eWidth);
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after
1554 printedCharacters = fprintf(stderr, "\t%s %p", obj.renderName(), &obj); 1564 printedCharacters = fprintf(stderr, "\t%s %p", obj.renderName(), &obj);
1555 const int rendererCharacterOffset = 24; 1565 const int rendererCharacterOffset = 24;
1556 for (; printedCharacters < rendererCharacterOffset; printedCharacters++) 1566 for (; printedCharacters < rendererCharacterOffset; printedCharacters++)
1557 fputc(' ', stderr); 1567 fputc(' ', stderr);
1558 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d ata()); 1568 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d ata());
1559 } 1569 }
1560 1570
1561 #endif 1571 #endif
1562 1572
1563 } // namespace WebCore 1573 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/fast/text/emphasis-combined-text.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698