OLD | NEW |
---|---|
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 892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
903 break; | 903 break; |
904 } | 904 } |
905 | 905 |
906 return strokeStyle; | 906 return strokeStyle; |
907 } | 907 } |
908 | 908 |
909 static int computeUnderlineOffset(const TextUnderlinePosition underlinePosition, const FontMetrics& fontMetrics, const InlineTextBox* inlineTextBox, const float textDecorationThickness) | 909 static int computeUnderlineOffset(const TextUnderlinePosition underlinePosition, const FontMetrics& fontMetrics, const InlineTextBox* inlineTextBox, const float textDecorationThickness) |
910 { | 910 { |
911 // Compute the gap between the font and the underline. Use at least one | 911 // Compute the gap between the font and the underline. Use at least one |
912 // pixel gap, if underline is thick then use a bigger gap. | 912 // pixel gap, if underline is thick then use a bigger gap. |
913 const int gap = std::max<int>(1, ceilf(textDecorationThickness / 2.f)); | 913 int gap = std::max<int>(1, ceilf(textDecorationThickness / 2.f)); |
914 | |
915 // Underline position of zero means draw underline on Baseline Position, | |
916 // in Blink we need at least 1-pixel gap to adding following check. Default convention | |
917 // is Positive underline Pos means draw above baseline while Negative means draw below | |
918 // baseline, as Blink has Y increasing downwards so negating the value. | |
919 if (fontMetrics.underlinePosition()) | |
920 gap = -fontMetrics.underlinePosition(); | |
eae
2014/02/28 17:37:59
Computing the gap and then immediately overwriting
h.joshi
2014/03/01 03:36:12
Will make changes in next patch.
On 2014/02/28 17
| |
914 | 921 |
915 // FIXME: We support only horizontal text for now. | 922 // FIXME: We support only horizontal text for now. |
916 switch (underlinePosition) { | 923 switch (underlinePosition) { |
917 case TextUnderlinePositionAuto: | 924 case TextUnderlinePositionAuto: |
918 return fontMetrics.ascent() + gap; // Position underline near the alphab etic baseline. | 925 return fontMetrics.ascent() + gap; // Position underline near the alphab etic baseline. |
919 case TextUnderlinePositionUnder: { | 926 case TextUnderlinePositionUnder: { |
920 // Position underline relative to the under edge of the lowest element's content box. | 927 // Position underline relative to the under edge of the lowest element's content box. |
921 const float offset = inlineTextBox->root()->maxLogicalTop() - inlineText Box->logicalTop(); | 928 const float offset = inlineTextBox->root()->maxLogicalTop() - inlineText Box->logicalTop(); |
922 if (offset > 0) | 929 if (offset > 0) |
923 return inlineTextBox->logicalHeight() + gap + offset; | 930 return inlineTextBox->logicalHeight() + gap + offset; |
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1562 printedCharacters = fprintf(stderr, "\t%s %p", obj->renderName(), obj); | 1569 printedCharacters = fprintf(stderr, "\t%s %p", obj->renderName(), obj); |
1563 const int rendererCharacterOffset = 24; | 1570 const int rendererCharacterOffset = 24; |
1564 for (; printedCharacters < rendererCharacterOffset; printedCharacters++) | 1571 for (; printedCharacters < rendererCharacterOffset; printedCharacters++) |
1565 fputc(' ', stderr); | 1572 fputc(' ', stderr); |
1566 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d ata()); | 1573 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d ata()); |
1567 } | 1574 } |
1568 | 1575 |
1569 #endif | 1576 #endif |
1570 | 1577 |
1571 } // namespace WebCore | 1578 } // namespace WebCore |
OLD | NEW |