| 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 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 const FloatPoint& textOrigin, const FloatRect& boxRect, | 395 const FloatPoint& textOrigin, const FloatRect& boxRect, |
| 396 const ShadowList* shadowList, bool stroked, bool horizontal) | 396 const ShadowList* shadowList, bool stroked, bool horizontal) |
| 397 { | 397 { |
| 398 // Text shadows are disabled when printing. http://crbug.com/258321 | 398 // Text shadows are disabled when printing. http://crbug.com/258321 |
| 399 bool hasShadow = shadowList && !context->printing(); | 399 bool hasShadow = shadowList && !context->printing(); |
| 400 | 400 |
| 401 if (hasShadow) { | 401 if (hasShadow) { |
| 402 DrawLooper drawLooper; | 402 DrawLooper drawLooper; |
| 403 for (size_t i = shadowList->shadows().size(); i--; ) { | 403 for (size_t i = shadowList->shadows().size(); i--; ) { |
| 404 const ShadowData& shadow = shadowList->shadows()[i]; | 404 const ShadowData& shadow = shadowList->shadows()[i]; |
| 405 int shadowX = horizontal ? shadow.x() : shadow.y(); | 405 float shadowX = horizontal ? shadow.x() : shadow.y(); |
| 406 int shadowY = horizontal ? shadow.y() : -shadow.x(); | 406 float shadowY = horizontal ? shadow.y() : -shadow.x(); |
| 407 FloatSize offset(shadowX, shadowY); | 407 FloatSize offset(shadowX, shadowY); |
| 408 drawLooper.addShadow(offset, shadow.blur(), renderer->resolveColor(s
hadow.color()), | 408 drawLooper.addShadow(offset, shadow.blur(), renderer->resolveColor(s
hadow.color()), |
| 409 DrawLooper::ShadowRespectsTransforms, DrawLooper::ShadowIgnoresA
lpha); | 409 DrawLooper::ShadowRespectsTransforms, DrawLooper::ShadowIgnoresA
lpha); |
| 410 } | 410 } |
| 411 drawLooper.addUnmodifiedContent(); | 411 drawLooper.addUnmodifiedContent(); |
| 412 context->setDrawLooper(drawLooper); | 412 context->setDrawLooper(drawLooper); |
| 413 } | 413 } |
| 414 | 414 |
| 415 TextRunPaintInfo textRunPaintInfo(textRun); | 415 TextRunPaintInfo textRunPaintInfo(textRun); |
| 416 textRunPaintInfo.bounds = boxRect; | 416 textRunPaintInfo.bounds = boxRect; |
| (...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1082 | 1082 |
| 1083 RenderStyle* styleToUse = renderer()->style(isFirstLineStyle()); | 1083 RenderStyle* styleToUse = renderer()->style(isFirstLineStyle()); |
| 1084 int baseline = styleToUse->fontMetrics().ascent(); | 1084 int baseline = styleToUse->fontMetrics().ascent(); |
| 1085 | 1085 |
| 1086 size_t shadowCount = shadowList ? shadowList->shadows().size() : 0; | 1086 size_t shadowCount = shadowList ? shadowList->shadows().size() : 0; |
| 1087 // Set the thick of the line to be 10% (or something else ?)of the computed
font size and not less than 1px. | 1087 // Set the thick of the line to be 10% (or something else ?)of the computed
font size and not less than 1px. |
| 1088 // Using computedFontSize should take care of zoom as well. | 1088 // Using computedFontSize should take care of zoom as well. |
| 1089 const float textDecorationThickness = std::max(1.f, styleToUse->computedFont
Size() / 10.f); | 1089 const float textDecorationThickness = std::max(1.f, styleToUse->computedFont
Size() / 10.f); |
| 1090 context->setStrokeThickness(textDecorationThickness); | 1090 context->setStrokeThickness(textDecorationThickness); |
| 1091 | 1091 |
| 1092 int extraOffset = 0; | 1092 float extraOffset = 0; |
| 1093 if (!linesAreOpaque && shadowCount > 1) { | 1093 if (!linesAreOpaque && shadowCount > 1) { |
| 1094 FloatRect clipRect(localOrigin, FloatSize(width, baseline + 2)); | 1094 FloatRect clipRect(localOrigin, FloatSize(width, baseline + 2)); |
| 1095 for (size_t i = shadowCount; i--; ) { | 1095 for (size_t i = shadowCount; i--; ) { |
| 1096 const ShadowData& s = shadowList->shadows()[i]; | 1096 const ShadowData& s = shadowList->shadows()[i]; |
| 1097 FloatRect shadowRect(localOrigin, FloatSize(width, baseline + 2)); | 1097 FloatRect shadowRect(localOrigin, FloatSize(width, baseline + 2)); |
| 1098 shadowRect.inflate(s.blur()); | 1098 shadowRect.inflate(s.blur()); |
| 1099 int shadowX = isHorizontal() ? s.x() : s.y(); | 1099 float shadowX = isHorizontal() ? s.x() : s.y(); |
| 1100 int shadowY = isHorizontal() ? s.y() : -s.x(); | 1100 float shadowY = isHorizontal() ? s.y() : -s.x(); |
| 1101 shadowRect.move(shadowX, shadowY); | 1101 shadowRect.move(shadowX, shadowY); |
| 1102 clipRect.unite(shadowRect); | 1102 clipRect.unite(shadowRect); |
| 1103 extraOffset = max(extraOffset, max(0, shadowY) + s.blur()); | 1103 extraOffset = max(extraOffset, max(0.0f, shadowY) + s.blur()); |
| 1104 } | 1104 } |
| 1105 context->clip(clipRect); | 1105 context->clip(clipRect); |
| 1106 extraOffset += baseline + 2; | 1106 extraOffset += baseline + 2; |
| 1107 localOrigin.move(0, extraOffset); | 1107 localOrigin.move(0, extraOffset); |
| 1108 } | 1108 } |
| 1109 | 1109 |
| 1110 for (size_t i = max(static_cast<size_t>(1), shadowCount); i--; ) { | 1110 for (size_t i = max(static_cast<size_t>(1), shadowCount); i--; ) { |
| 1111 // Even if we have no shadows, we still want to run the code below this
once. | 1111 // Even if we have no shadows, we still want to run the code below this
once. |
| 1112 if (i < shadowCount) { | 1112 if (i < shadowCount) { |
| 1113 if (!i) { | 1113 if (!i) { |
| 1114 // The last set of lines paints normally inside the clip. | 1114 // The last set of lines paints normally inside the clip. |
| 1115 localOrigin.move(0, -extraOffset); | 1115 localOrigin.move(0, -extraOffset); |
| 1116 extraOffset = 0; | 1116 extraOffset = 0; |
| 1117 } | 1117 } |
| 1118 const ShadowData& shadow = shadowList->shadows()[i]; | 1118 const ShadowData& shadow = shadowList->shadows()[i]; |
| 1119 int shadowX = isHorizontal() ? shadow.x() : shadow.y(); | 1119 float shadowX = isHorizontal() ? shadow.x() : shadow.y(); |
| 1120 int shadowY = isHorizontal() ? shadow.y() : -shadow.x(); | 1120 float shadowY = isHorizontal() ? shadow.y() : -shadow.x(); |
| 1121 context->setShadow(FloatSize(shadowX, shadowY - extraOffset), shadow
.blur(), shadow.color()); | 1121 context->setShadow(FloatSize(shadowX, shadowY - extraOffset), shadow
.blur(), shadow.color()); |
| 1122 } | 1122 } |
| 1123 | 1123 |
| 1124 // Offset between lines - always non-zero, so lines never cross each oth
er. | 1124 // Offset between lines - always non-zero, so lines never cross each oth
er. |
| 1125 float doubleOffset = textDecorationThickness + 1.f; | 1125 float doubleOffset = textDecorationThickness + 1.f; |
| 1126 context->setStrokeStyle(textDecorationStyleToStrokeStyle(decorationStyle
)); | 1126 context->setStrokeStyle(textDecorationStyleToStrokeStyle(decorationStyle
)); |
| 1127 if (deco & TextDecorationUnderline) { | 1127 if (deco & TextDecorationUnderline) { |
| 1128 context->setStrokeColor(underline); | 1128 context->setStrokeColor(underline); |
| 1129 const int underlineOffset = computeUnderlineOffset(styleToUse->textU
nderlinePosition(), styleToUse->fontMetrics(), this, textDecorationThickness); | 1129 const int underlineOffset = computeUnderlineOffset(styleToUse->textU
nderlinePosition(), styleToUse->fontMetrics(), this, textDecorationThickness); |
| 1130 switch (decorationStyle) { | 1130 switch (decorationStyle) { |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1557 printedCharacters = fprintf(stderr, "\t%s %p", obj->renderName(), obj); | 1557 printedCharacters = fprintf(stderr, "\t%s %p", obj->renderName(), obj); |
| 1558 const int rendererCharacterOffset = 24; | 1558 const int rendererCharacterOffset = 24; |
| 1559 for (; printedCharacters < rendererCharacterOffset; printedCharacters++) | 1559 for (; printedCharacters < rendererCharacterOffset; printedCharacters++) |
| 1560 fputc(' ', stderr); | 1560 fputc(' ', stderr); |
| 1561 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d
ata()); | 1561 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d
ata()); |
| 1562 } | 1562 } |
| 1563 | 1563 |
| 1564 #endif | 1564 #endif |
| 1565 | 1565 |
| 1566 } // namespace WebCore | 1566 } // namespace WebCore |
| OLD | NEW |