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

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

Issue 182923003: Chrome not considering Underline Position from Font (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixing TestExpectation Created 6 years, 8 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/TestExpectations ('k') | Source/platform/fonts/FontMetrics.h » ('j') | 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 902 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 break; 913 break;
914 } 914 }
915 915
916 return strokeStyle; 916 return strokeStyle;
917 } 917 }
918 918
919 static int computeUnderlineOffset(const TextUnderlinePosition underlinePosition, const FontMetrics& fontMetrics, const InlineTextBox* inlineTextBox, const float textDecorationThickness) 919 static int computeUnderlineOffset(const TextUnderlinePosition underlinePosition, const FontMetrics& fontMetrics, const InlineTextBox* inlineTextBox, const float textDecorationThickness)
920 { 920 {
921 // Compute the gap between the font and the underline. Use at least one 921 // Compute the gap between the font and the underline. Use at least one
922 // pixel gap, if underline is thick then use a bigger gap. 922 // pixel gap, if underline is thick then use a bigger gap.
923 const int gap = std::max<int>(1, ceilf(textDecorationThickness / 2.f)); 923 int gap = 0;
924
925 // Underline position of zero means draw underline on Baseline Position,
926 // in Blink we need at least 1-pixel gap to adding following check.
927 // Positive underline Position means underline should be drawn above baselin e
928 // and negative value means drawing below baseline, negating the value as in Blink
929 // downward Y-increases.
930
931 if (fontMetrics.underlinePosition())
932 gap = -fontMetrics.underlinePosition();
933 else
934 gap = std::max<int>(1, ceilf(textDecorationThickness / 2.f));
924 935
925 // FIXME: We support only horizontal text for now. 936 // FIXME: We support only horizontal text for now.
926 switch (underlinePosition) { 937 switch (underlinePosition) {
927 case TextUnderlinePositionAuto: 938 case TextUnderlinePositionAuto:
928 return fontMetrics.ascent() + gap; // Position underline near the alphab etic baseline. 939 return fontMetrics.ascent() + gap; // Position underline near the alphab etic baseline.
929 case TextUnderlinePositionUnder: { 940 case TextUnderlinePositionUnder: {
930 // Position underline relative to the under edge of the lowest element's content box. 941 // Position underline relative to the under edge of the lowest element's content box.
931 const float offset = inlineTextBox->root().maxLogicalTop() - inlineTextB ox->logicalTop(); 942 const float offset = inlineTextBox->root().maxLogicalTop() - inlineTextB ox->logicalTop();
932 if (offset > 0) 943 if (offset > 0)
933 return inlineTextBox->logicalHeight() + gap + offset; 944 return inlineTextBox->logicalHeight() + gap + offset;
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
1565 printedCharacters = fprintf(stderr, "\t%s %p", obj.renderName(), &obj); 1576 printedCharacters = fprintf(stderr, "\t%s %p", obj.renderName(), &obj);
1566 const int rendererCharacterOffset = 24; 1577 const int rendererCharacterOffset = 24;
1567 for (; printedCharacters < rendererCharacterOffset; printedCharacters++) 1578 for (; printedCharacters < rendererCharacterOffset; printedCharacters++)
1568 fputc(' ', stderr); 1579 fputc(' ', stderr);
1569 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d ata()); 1580 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d ata());
1570 } 1581 }
1571 1582
1572 #endif 1583 #endif
1573 1584
1574 } // namespace WebCore 1585 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/TestExpectations ('k') | Source/platform/fonts/FontMetrics.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698