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

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

Issue 147703002: Calculate Underline thickness from Font (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Adding Test cases in TestExpectations Created 6 years, 10 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
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 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 bool isPrinting = textRenderer()->document().printing(); 1077 bool isPrinting = textRenderer()->document().printing();
1078 1078
1079 bool linesAreOpaque = !isPrinting && (!(deco & TextDecorationUnderline) || u nderline.alpha() == 255) && (!(deco & TextDecorationOverline) || overline.alpha( ) == 255) && (!(deco & TextDecorationLineThrough) || linethrough.alpha() == 255) ; 1079 bool linesAreOpaque = !isPrinting && (!(deco & TextDecorationUnderline) || u nderline.alpha() == 255) && (!(deco & TextDecorationOverline) || overline.alpha( ) == 255) && (!(deco & TextDecorationLineThrough) || linethrough.alpha() == 255) ;
1080 1080
1081 RenderStyle* styleToUse = renderer()->style(isFirstLineStyle()); 1081 RenderStyle* styleToUse = renderer()->style(isFirstLineStyle());
1082 int baseline = styleToUse->fontMetrics().ascent(); 1082 int baseline = styleToUse->fontMetrics().ascent();
1083 1083
1084 size_t shadowCount = shadowList ? shadowList->shadows().size() : 0; 1084 size_t shadowCount = shadowList ? shadowList->shadows().size() : 0;
1085 // Set the thick of the line to be 10% (or something else ?)of the computed font size and not less than 1px. 1085 // Set the thick of the line to be 10% (or something else ?)of the computed font size and not less than 1px.
1086 // Using computedFontSize should take care of zoom as well. 1086 // Using computedFontSize should take care of zoom as well.
1087 const float textDecorationThickness = std::max(1.f, styleToUse->computedFont Size() / 10.f); 1087
1088 // Update Underline thickness, in case we have Faulty Font Metrics calculati ng underline thickness by old method.
1089 float textDecorationThickness = styleToUse->fontMetrics().underlineThickness ();
1090 int fontHeightInt = (int)(styleToUse->fontMetrics().floatHeight() + 0.5);
1091 if ((textDecorationThickness == 0.f) || (textDecorationThickness >= (fontHei ghtInt >> 1)))
1092 textDecorationThickness = std::max(1.f, styleToUse->computedFontSize() / 10.f);
1093
1088 context->setStrokeThickness(textDecorationThickness); 1094 context->setStrokeThickness(textDecorationThickness);
1089 1095
1090 float extraOffset = 0; 1096 float extraOffset = 0;
1091 if (!linesAreOpaque && shadowCount > 1) { 1097 if (!linesAreOpaque && shadowCount > 1) {
1092 FloatRect clipRect(localOrigin, FloatSize(width, baseline + 2)); 1098 FloatRect clipRect(localOrigin, FloatSize(width, baseline + 2));
1093 for (size_t i = shadowCount; i--; ) { 1099 for (size_t i = shadowCount; i--; ) {
1094 const ShadowData& s = shadowList->shadows()[i]; 1100 const ShadowData& s = shadowList->shadows()[i];
1095 FloatRect shadowRect(localOrigin, FloatSize(width, baseline + 2)); 1101 FloatRect shadowRect(localOrigin, FloatSize(width, baseline + 2));
1096 shadowRect.inflate(s.blur()); 1102 shadowRect.inflate(s.blur());
1097 float shadowX = isHorizontal() ? s.x() : s.y(); 1103 float shadowX = isHorizontal() ? s.x() : s.y();
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
1556 printedCharacters = fprintf(stderr, "\t%s %p", obj->renderName(), obj); 1562 printedCharacters = fprintf(stderr, "\t%s %p", obj->renderName(), obj);
1557 const int rendererCharacterOffset = 24; 1563 const int rendererCharacterOffset = 24;
1558 for (; printedCharacters < rendererCharacterOffset; printedCharacters++) 1564 for (; printedCharacters < rendererCharacterOffset; printedCharacters++)
1559 fputc(' ', stderr); 1565 fputc(' ', stderr);
1560 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d ata()); 1566 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d ata());
1561 } 1567 }
1562 1568
1563 #endif 1569 #endif
1564 1570
1565 } // namespace WebCore 1571 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698