| 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 = 0; |
| 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. |
| 917 // Positive underline Position means underline should be drawn above baselin
e |
| 918 // and negative value means drawing below baseline, negating the value as in
Blink |
| 919 // downward Y-increases. |
| 920 if (fontMetrics.underlinePosition()) |
| 921 gap = -fontMetrics.underlinePosition(); |
| 922 else |
| 923 gap = std::max<int>(1, ceilf(textDecorationThickness / 2.f)); |
| 914 | 924 |
| 915 // FIXME: We support only horizontal text for now. | 925 // FIXME: We support only horizontal text for now. |
| 916 switch (underlinePosition) { | 926 switch (underlinePosition) { |
| 917 case TextUnderlinePositionAuto: | 927 case TextUnderlinePositionAuto: |
| 918 return fontMetrics.ascent() + gap; // Position underline near the alphab
etic baseline. | 928 return fontMetrics.ascent() + gap; // Position underline near the alphab
etic baseline. |
| 919 case TextUnderlinePositionUnder: { | 929 case TextUnderlinePositionUnder: { |
| 920 // Position underline relative to the under edge of the lowest element's
content box. | 930 // Position underline relative to the under edge of the lowest element's
content box. |
| 921 const float offset = inlineTextBox->root()->maxLogicalTop() - inlineText
Box->logicalTop(); | 931 const float offset = inlineTextBox->root()->maxLogicalTop() - inlineText
Box->logicalTop(); |
| 922 if (offset > 0) | 932 if (offset > 0) |
| 923 return inlineTextBox->logicalHeight() + gap + offset; | 933 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); | 1572 printedCharacters = fprintf(stderr, "\t%s %p", obj->renderName(), obj); |
| 1563 const int rendererCharacterOffset = 24; | 1573 const int rendererCharacterOffset = 24; |
| 1564 for (; printedCharacters < rendererCharacterOffset; printedCharacters++) | 1574 for (; printedCharacters < rendererCharacterOffset; printedCharacters++) |
| 1565 fputc(' ', stderr); | 1575 fputc(' ', stderr); |
| 1566 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d
ata()); | 1576 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d
ata()); |
| 1567 } | 1577 } |
| 1568 | 1578 |
| 1569 #endif | 1579 #endif |
| 1570 | 1580 |
| 1571 } // namespace WebCore | 1581 } // namespace WebCore |
| OLD | NEW |