Chromium Code Reviews| 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 24 matching lines...) Expand all Loading... | |
| 35 #include "core/rendering/AbstractInlineTextBox.h" | 35 #include "core/rendering/AbstractInlineTextBox.h" |
| 36 #include "core/rendering/EllipsisBox.h" | 36 #include "core/rendering/EllipsisBox.h" |
| 37 #include "core/rendering/HitTestResult.h" | 37 #include "core/rendering/HitTestResult.h" |
| 38 #include "core/rendering/PaintInfo.h" | 38 #include "core/rendering/PaintInfo.h" |
| 39 #include "core/rendering/RenderBR.h" | 39 #include "core/rendering/RenderBR.h" |
| 40 #include "core/rendering/RenderBlock.h" | 40 #include "core/rendering/RenderBlock.h" |
| 41 #include "core/rendering/RenderCombineText.h" | 41 #include "core/rendering/RenderCombineText.h" |
| 42 #include "core/rendering/RenderRubyRun.h" | 42 #include "core/rendering/RenderRubyRun.h" |
| 43 #include "core/rendering/RenderRubyText.h" | 43 #include "core/rendering/RenderRubyText.h" |
| 44 #include "core/rendering/RenderTheme.h" | 44 #include "core/rendering/RenderTheme.h" |
| 45 #include "core/rendering/style/AppliedTextDecorationList.h" | |
| 45 #include "core/rendering/style/ShadowList.h" | 46 #include "core/rendering/style/ShadowList.h" |
| 46 #include "core/rendering/svg/SVGTextRunRenderingContext.h" | 47 #include "core/rendering/svg/SVGTextRunRenderingContext.h" |
| 47 #include "platform/fonts/FontCache.h" | 48 #include "platform/fonts/FontCache.h" |
| 48 #include "platform/fonts/WidthIterator.h" | 49 #include "platform/fonts/WidthIterator.h" |
| 49 #include "platform/graphics/DrawLooperBuilder.h" | 50 #include "platform/graphics/DrawLooperBuilder.h" |
| 50 #include "platform/graphics/GraphicsContextStateSaver.h" | 51 #include "platform/graphics/GraphicsContextStateSaver.h" |
| 51 #include "wtf/Vector.h" | 52 #include "wtf/Vector.h" |
| 52 #include "wtf/text/CString.h" | 53 #include "wtf/text/CString.h" |
| 53 #include "wtf/text/StringBuilder.h" | 54 #include "wtf/text/StringBuilder.h" |
| 54 | 55 |
| (...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 744 int endOffset = combinedText ? objectReplacementCharacterTextRun.len gth() : ePos; | 745 int endOffset = combinedText ? objectReplacementCharacterTextRun.len gth() : ePos; |
| 745 int paintRunLength = combinedText ? endOffset : length; | 746 int paintRunLength = combinedText ? endOffset : length; |
| 746 paintTextWithShadows(context, rendererToUse, combinedText ? combined Text->originalFont() : font, emphasisMarkTextRun, emphasisMark, emphasisMarkOffs et, startOffset, endOffset, paintRunLength, emphasisMarkTextOrigin, boxRect, sel ectionShadow, selectionStrokeWidth > 0, isHorizontal()); | 747 paintTextWithShadows(context, rendererToUse, combinedText ? combined Text->originalFont() : font, emphasisMarkTextRun, emphasisMark, emphasisMarkOffs et, startOffset, endOffset, paintRunLength, emphasisMarkTextOrigin, boxRect, sel ectionShadow, selectionStrokeWidth > 0, isHorizontal()); |
| 747 | 748 |
| 748 if (combinedText) | 749 if (combinedText) |
| 749 context->concatCTM(rotation(boxRect, Counterclockwise)); | 750 context->concatCTM(rotation(boxRect, Counterclockwise)); |
| 750 } | 751 } |
| 751 } | 752 } |
| 752 | 753 |
| 753 // Paint decorations | 754 // Paint decorations |
| 754 TextDecoration textDecorations = styleToUse->textDecorationsInEffect(); | 755 if (styleToUse->hasAppliedTextDecorations() && paintInfo.phase != PaintPhase Selection) { |
| 755 if (textDecorations != TextDecorationNone && paintInfo.phase != PaintPhaseSe lection) { | |
| 756 updateGraphicsContext(context, textFillColor, textStrokeColor, textStrok eWidth); | 756 updateGraphicsContext(context, textFillColor, textStrokeColor, textStrok eWidth); |
| 757 if (combinedText) | 757 if (combinedText) |
| 758 context->concatCTM(rotation(boxRect, Clockwise)); | 758 context->concatCTM(rotation(boxRect, Clockwise)); |
| 759 paintDecoration(context, boxOrigin, textDecorations, textShadow); | 759 paintDecoration(context, boxOrigin, styleToUse, textShadow); |
| 760 if (combinedText) | 760 if (combinedText) |
| 761 context->concatCTM(rotation(boxRect, Counterclockwise)); | 761 context->concatCTM(rotation(boxRect, Counterclockwise)); |
| 762 } | 762 } |
| 763 | 763 |
| 764 if (paintInfo.phase == PaintPhaseForeground) { | 764 if (paintInfo.phase == PaintPhaseForeground) { |
| 765 paintDocumentMarkers(context, boxOrigin, styleToUse, font, false); | 765 paintDocumentMarkers(context, boxOrigin, styleToUse, font, false); |
| 766 | 766 |
| 767 if (useCustomUnderlines) { | 767 if (useCustomUnderlines) { |
| 768 const Vector<CompositionUnderline>& underlines = renderer().frame()- >inputMethodController().customCompositionUnderlines(); | 768 const Vector<CompositionUnderline>& underlines = renderer().frame()- >inputMethodController().customCompositionUnderlines(); |
| 769 size_t numUnderlines = underlines.size(); | 769 size_t numUnderlines = underlines.size(); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 909 strokeStyle = DashedStroke; | 909 strokeStyle = DashedStroke; |
| 910 break; | 910 break; |
| 911 case TextDecorationStyleWavy: | 911 case TextDecorationStyleWavy: |
| 912 strokeStyle = WavyStroke; | 912 strokeStyle = WavyStroke; |
| 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 int InlineTextBox::computeUnderlineOffset(RenderStyle* style, const float textDe corationThickness) |
| 920 { | 920 { |
| 921 const TextUnderlinePosition underlinePosition = style->textUnderlinePosition (); | |
| 922 const FontMetrics& fontMetrics = style->fontMetrics(); | |
| 923 | |
| 921 // Compute the gap between the font and the underline. Use at least one | 924 // 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. | 925 // pixel gap, if underline is thick then use a bigger gap. |
| 923 const int gap = std::max<int>(1, ceilf(textDecorationThickness / 2.f)); | 926 const int gap = std::max<int>(1, ceilf(textDecorationThickness / 2.f)); |
| 924 | 927 |
| 925 // FIXME: We support only horizontal text for now. | 928 // FIXME: We support only horizontal text for now. |
| 926 switch (underlinePosition) { | 929 switch (underlinePosition) { |
| 927 case TextUnderlinePositionAuto: | 930 case TextUnderlinePositionAuto: |
| 928 return fontMetrics.ascent() + gap; // Position underline near the alphab etic baseline. | 931 return fontMetrics.ascent() + gap; // Position underline near the alphab etic baseline. |
| 929 case TextUnderlinePositionUnder: { | 932 case TextUnderlinePositionUnder: { |
| 930 // Position underline relative to the under edge of the lowest element's content box. | 933 // Position underline relative to the under edge of the lowest element's content box. |
| 931 const float offset = inlineTextBox->root().maxLogicalTop() - inlineTextB ox->logicalTop(); | 934 const float offset = root().maxLogicalTop() - logicalTop(); |
| 932 if (offset > 0) | 935 if (offset > 0) |
| 933 return inlineTextBox->logicalHeight() + gap + offset; | 936 return logicalHeight() + gap + offset; |
| 934 return inlineTextBox->logicalHeight() + gap; | 937 return logicalHeight() + gap; |
| 935 } | 938 } |
| 936 } | 939 } |
| 937 | 940 |
| 938 ASSERT_NOT_REACHED(); | 941 ASSERT_NOT_REACHED(); |
| 939 return fontMetrics.ascent() + gap; | 942 return fontMetrics.ascent() + gap; |
| 940 } | 943 } |
| 941 | 944 |
| 942 static void adjustStepToDecorationLength(float& step, float& controlPointDistanc e, float length) | 945 static void adjustStepToDecorationLength(float& step, float& controlPointDistanc e, float length) |
| 943 { | 946 { |
| 944 ASSERT(step > 0); | 947 ASSERT(step > 0); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1059 | 1062 |
| 1060 context->setShouldAntialias(true); | 1063 context->setShouldAntialias(true); |
| 1061 context->strokePath(path); | 1064 context->strokePath(path); |
| 1062 } | 1065 } |
| 1063 | 1066 |
| 1064 static bool shouldSetDecorationAntialias(TextDecorationStyle decorationStyle) | 1067 static bool shouldSetDecorationAntialias(TextDecorationStyle decorationStyle) |
| 1065 { | 1068 { |
| 1066 return decorationStyle == TextDecorationStyleDotted || decorationStyle == Te xtDecorationStyleDashed; | 1069 return decorationStyle == TextDecorationStyleDotted || decorationStyle == Te xtDecorationStyleDashed; |
| 1067 } | 1070 } |
| 1068 | 1071 |
| 1069 static bool shouldSetDecorationAntialias(TextDecorationStyle underline, TextDeco rationStyle overline, TextDecorationStyle linethrough) | 1072 static void getDecorationMetaData(const AppliedTextDecorationList* decorations, bool& linesAreOpaque, bool& setDecorationAntialias) |
|
esprehn
2014/03/31 17:41:24
I might use a struct instead of all these out para
| |
| 1070 { | 1073 { |
| 1071 return shouldSetDecorationAntialias(underline) || shouldSetDecorationAntiali as(overline) || shouldSetDecorationAntialias(linethrough); | 1074 for (size_t i = 0; i < decorations->size(); ++i) { |
|
esprehn
2014/03/31 17:41:24
Pass decorations by reference.
| |
| 1075 const AppliedTextDecoration& d = decorations->at(i); | |
| 1076 linesAreOpaque &= (d.color().alpha() == 255); | |
| 1077 setDecorationAntialias |= shouldSetDecorationAntialias(d.style()); | |
| 1078 } | |
| 1072 } | 1079 } |
| 1073 | 1080 |
| 1074 static void paintAppliedDecoration(GraphicsContext* context, FloatPoint start, f loat width, float doubleOffset, int wavyOffsetFactor, | 1081 struct PaintAppliedDecorationData { |
| 1075 RenderObject::AppliedTextDecoration decoration, float thickness, bool antial iasDecoration, bool isPrinting) | 1082 RenderStyle* style; |
| 1083 FloatPoint start; | |
| 1084 float width; | |
| 1085 float doubleOffset; | |
| 1086 float thickness; | |
| 1087 bool antialias; | |
| 1088 bool isPrinting; | |
| 1089 int baseline; | |
|
esprehn
2014/03/31 17:41:24
Do we need a constructor that zero inits this thin
| |
| 1090 }; | |
| 1091 | |
| 1092 static void paintAppliedDecorationStyle(GraphicsContext* context, const AppliedT extDecoration& decoration, const PaintAppliedDecorationData& d, int wavyOffsetFa ctor) | |
|
esprehn
2014/03/31 17:41:24
Don't use single letter variable names.
| |
| 1076 { | 1093 { |
| 1077 context->setStrokeStyle(textDecorationStyleToStrokeStyle(decoration.style)); | 1094 context->setStrokeStyle(textDecorationStyleToStrokeStyle(decoration.style()) ); |
| 1078 context->setStrokeColor(decoration.color); | 1095 context->setStrokeColor(decoration.color()); |
| 1079 | 1096 |
| 1080 switch (decoration.style) { | 1097 switch (decoration.style()) { |
| 1081 case TextDecorationStyleWavy: | 1098 case TextDecorationStyleWavy: |
| 1082 strokeWavyTextDecoration(context, start + FloatPoint(0, doubleOffset * w avyOffsetFactor), start + FloatPoint(width, doubleOffset * wavyOffsetFactor), th ickness); | 1099 strokeWavyTextDecoration(context, d.start + FloatPoint(0, d.doubleOffset * wavyOffsetFactor), d.start + FloatPoint(d.width, d.doubleOffset * wavyOffsetF actor), d.thickness); |
| 1083 break; | 1100 break; |
| 1084 case TextDecorationStyleDotted: | 1101 case TextDecorationStyleDotted: |
| 1085 case TextDecorationStyleDashed: | 1102 case TextDecorationStyleDashed: |
| 1086 context->setShouldAntialias(antialiasDecoration); | 1103 context->setShouldAntialias(d.antialias); |
| 1087 // Fall through | 1104 // Fall through |
| 1088 default: | 1105 default: |
| 1089 context->drawLineForText(start, width, isPrinting); | 1106 context->drawLineForText(d.start, d.width, d.isPrinting); |
| 1090 | 1107 |
| 1091 if (decoration.style == TextDecorationStyleDouble) | 1108 if (decoration.style() == TextDecorationStyleDouble) |
| 1092 context->drawLineForText(start + FloatPoint(0, doubleOffset), width, isPrinting); | 1109 context->drawLineForText(d.start + FloatPoint(0, d.doubleOffset), d. width, d.isPrinting); |
| 1093 } | 1110 } |
| 1094 } | 1111 } |
| 1095 | 1112 |
| 1096 void InlineTextBox::paintDecoration(GraphicsContext* context, const FloatPoint& boxOrigin, TextDecoration deco, const ShadowList* shadowList) | 1113 void InlineTextBox::paintAppliedDecoration(GraphicsContext* context, const Appli edTextDecoration& decoration, const PaintAppliedDecorationData& d) |
| 1114 { | |
| 1115 PaintAppliedDecorationData data = d; | |
| 1116 int wavyOffsetFactor = 1; | |
| 1117 | |
| 1118 switch (decoration.line()) { | |
| 1119 case TextDecorationUnderline: | |
| 1120 data.start += FloatPoint(0, computeUnderlineOffset(d.style, d.thickness) ); | |
| 1121 break; | |
| 1122 case TextDecorationOverline: | |
| 1123 data.doubleOffset *= -1; | |
| 1124 break; | |
| 1125 case TextDecorationLineThrough: | |
| 1126 data.start += FloatPoint(0, (2 * d.baseline / 3)); | |
| 1127 wavyOffsetFactor = 0; | |
| 1128 break; | |
| 1129 default: | |
| 1130 return; | |
| 1131 } | |
| 1132 | |
| 1133 paintAppliedDecorationStyle(context, decoration, data, wavyOffsetFactor); | |
| 1134 } | |
| 1135 | |
| 1136 void InlineTextBox::paintDecoration(GraphicsContext* context, const FloatPoint& boxOrigin, RenderStyle* styleToUse, const ShadowList* shadowList) | |
| 1097 { | 1137 { |
| 1098 GraphicsContextStateSaver stateSaver(*context); | 1138 GraphicsContextStateSaver stateSaver(*context); |
| 1099 | 1139 |
| 1100 if (m_truncation == cFullTruncation) | 1140 if (m_truncation == cFullTruncation) |
| 1101 return; | 1141 return; |
| 1102 | 1142 |
| 1103 FloatPoint localOrigin = boxOrigin; | 1143 FloatPoint localOrigin = boxOrigin; |
| 1104 | 1144 |
| 1105 float width = m_logicalWidth; | 1145 float width = m_logicalWidth; |
| 1106 if (m_truncation != cNoTruncation) { | 1146 if (m_truncation != cNoTruncation) { |
| 1107 width = toRenderText(renderer()).width(m_start, m_truncation, textPos(), isLeftToRightDirection() ? LTR : RTL, isFirstLineStyle()); | 1147 width = toRenderText(renderer()).width(m_start, m_truncation, textPos(), isLeftToRightDirection() ? LTR : RTL, isFirstLineStyle()); |
| 1108 if (!isLeftToRightDirection()) | 1148 if (!isLeftToRightDirection()) |
| 1109 localOrigin.move(m_logicalWidth - width, 0); | 1149 localOrigin.move(m_logicalWidth - width, 0); |
| 1110 } | 1150 } |
| 1111 | 1151 |
| 1112 // Get the text decoration colors. | 1152 const AppliedTextDecorationList* decorations = styleToUse->appliedTextDecora tions(); |
| 1113 RenderObject::AppliedTextDecoration underline, overline, linethrough; | |
| 1114 | 1153 |
| 1115 renderer().getTextDecorations(deco, underline, overline, linethrough, true); | 1154 // If appliedTextUnderline() is true, we must paint an extra underline |
| 1116 if (isFirstLineStyle()) | 1155 // before painting the other decorations. |
| 1117 renderer().getTextDecorations(deco, underline, overline, linethrough, tr ue, true); | 1156 AppliedTextDecoration underline; |
| 1157 if (styleToUse->appliedTextUnderline()) { | |
| 1158 Color color = renderer().getUnderlineColor(true, isFirstLineStyle()); | |
|
esprehn
2014/03/31 17:41:24
this boolean argument is confusing, can we use an
| |
| 1159 underline = AppliedTextDecoration(TextDecorationUnderline, TextDecoratio nStyleSolid, color); | |
| 1160 } | |
| 1118 | 1161 |
| 1119 // Use a special function for underlines to get the positioning exactly righ t. | 1162 // Use a special function for underlines to get the positioning exactly righ t. |
| 1120 bool isPrinting = textRenderer().document().printing(); | 1163 bool isPrinting = textRenderer().document().printing(); |
| 1121 | 1164 |
| 1122 bool linesAreOpaque = !isPrinting && (!(deco & TextDecorationUnderline) || u nderline.color.alpha() == 255) && (!(deco & TextDecorationOverline) || overline. color.alpha() == 255) && (!(deco & TextDecorationLineThrough) || linethrough.col or.alpha() == 255); | 1165 bool linesAreOpaque = !isPrinting; |
| 1166 bool setDecorationAntialias = false; | |
| 1123 | 1167 |
| 1124 RenderStyle* styleToUse = renderer().style(isFirstLineStyle()); | 1168 if (decorations) |
| 1169 getDecorationMetaData(decorations, linesAreOpaque, setDecorationAntialia s); | |
| 1170 | |
| 1125 int baseline = styleToUse->fontMetrics().ascent(); | 1171 int baseline = styleToUse->fontMetrics().ascent(); |
| 1126 | 1172 |
| 1127 size_t shadowCount = shadowList ? shadowList->shadows().size() : 0; | 1173 size_t shadowCount = shadowList ? shadowList->shadows().size() : 0; |
| 1128 // Set the thick of the line to be 10% (or something else ?)of the computed font size and not less than 1px. | 1174 // Set the thick of the line to be 10% (or something else ?)of the computed font size and not less than 1px. |
| 1129 // Using computedFontSize should take care of zoom as well. | 1175 // Using computedFontSize should take care of zoom as well. |
| 1130 | 1176 |
| 1131 // Update Underline thickness, in case we have Faulty Font Metrics calculati ng underline thickness by old method. | 1177 // Update Underline thickness, in case we have Faulty Font Metrics calculati ng underline thickness by old method. |
| 1132 float textDecorationThickness = styleToUse->fontMetrics().underlineThickness (); | 1178 float textDecorationThickness = styleToUse->fontMetrics().underlineThickness (); |
| 1133 int fontHeightInt = (int)(styleToUse->fontMetrics().floatHeight() + 0.5); | 1179 int fontHeightInt = (int)(styleToUse->fontMetrics().floatHeight() + 0.5); |
| 1134 if ((textDecorationThickness == 0.f) || (textDecorationThickness >= (fontHei ghtInt >> 1))) | 1180 if ((textDecorationThickness == 0.f) || (textDecorationThickness >= (fontHei ghtInt >> 1))) |
| 1135 textDecorationThickness = std::max(1.f, styleToUse->computedFontSize() / 10.f); | 1181 textDecorationThickness = std::max(1.f, styleToUse->computedFontSize() / 10.f); |
| 1136 | 1182 |
| 1137 context->setStrokeThickness(textDecorationThickness); | 1183 context->setStrokeThickness(textDecorationThickness); |
| 1138 | 1184 |
| 1139 bool antialiasDecoration = shouldSetDecorationAntialias(overline.style, unde rline.style, linethrough.style) | 1185 bool antialiasDecoration = setDecorationAntialias && RenderBoxModelObject::s houldAntialiasLines(context); |
| 1140 && RenderBoxModelObject::shouldAntialiasLines(context); | |
| 1141 | 1186 |
| 1142 float extraOffset = 0; | 1187 float extraOffset = 0; |
| 1143 if (!linesAreOpaque && shadowCount > 1) { | 1188 if (!linesAreOpaque && shadowCount > 1) { |
| 1144 FloatRect clipRect(localOrigin, FloatSize(width, baseline + 2)); | 1189 FloatRect clipRect(localOrigin, FloatSize(width, baseline + 2)); |
| 1145 for (size_t i = shadowCount; i--; ) { | 1190 for (size_t i = shadowCount; i--; ) { |
| 1146 const ShadowData& s = shadowList->shadows()[i]; | 1191 const ShadowData& s = shadowList->shadows()[i]; |
| 1147 FloatRect shadowRect(localOrigin, FloatSize(width, baseline + 2)); | 1192 FloatRect shadowRect(localOrigin, FloatSize(width, baseline + 2)); |
| 1148 shadowRect.inflate(s.blur()); | 1193 shadowRect.inflate(s.blur()); |
| 1149 float shadowX = isHorizontal() ? s.x() : s.y(); | 1194 float shadowX = isHorizontal() ? s.x() : s.y(); |
| 1150 float shadowY = isHorizontal() ? s.y() : -s.x(); | 1195 float shadowY = isHorizontal() ? s.y() : -s.x(); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 1164 // The last set of lines paints normally inside the clip. | 1209 // The last set of lines paints normally inside the clip. |
| 1165 localOrigin.move(0, -extraOffset); | 1210 localOrigin.move(0, -extraOffset); |
| 1166 extraOffset = 0; | 1211 extraOffset = 0; |
| 1167 } | 1212 } |
| 1168 const ShadowData& shadow = shadowList->shadows()[i]; | 1213 const ShadowData& shadow = shadowList->shadows()[i]; |
| 1169 float shadowX = isHorizontal() ? shadow.x() : shadow.y(); | 1214 float shadowX = isHorizontal() ? shadow.x() : shadow.y(); |
| 1170 float shadowY = isHorizontal() ? shadow.y() : -shadow.x(); | 1215 float shadowY = isHorizontal() ? shadow.y() : -shadow.x(); |
| 1171 context->setShadow(FloatSize(shadowX, shadowY - extraOffset), shadow .blur(), shadow.color()); | 1216 context->setShadow(FloatSize(shadowX, shadowY - extraOffset), shadow .blur(), shadow.color()); |
| 1172 } | 1217 } |
| 1173 | 1218 |
| 1219 PaintAppliedDecorationData data; | |
| 1220 data.style = styleToUse; | |
| 1221 data.start = localOrigin; | |
| 1222 data.width = width; | |
| 1174 // Offset between lines - always non-zero, so lines never cross each oth er. | 1223 // Offset between lines - always non-zero, so lines never cross each oth er. |
| 1175 float doubleOffset = textDecorationThickness + 1.f; | 1224 data.doubleOffset = textDecorationThickness + 1.f; |
| 1225 data.thickness = textDecorationThickness; | |
| 1226 data.antialias = antialiasDecoration; | |
| 1227 data.isPrinting = isPrinting; | |
| 1228 data.baseline = baseline; | |
| 1176 | 1229 |
| 1177 if (deco & TextDecorationUnderline) { | 1230 if (styleToUse->appliedTextUnderline()) |
| 1178 const int underlineOffset = computeUnderlineOffset(styleToUse->textU nderlinePosition(), styleToUse->fontMetrics(), this, textDecorationThickness); | 1231 paintAppliedDecoration(context, underline, data); |
| 1179 paintAppliedDecoration(context, localOrigin + FloatPoint(0, underlin eOffset), width, doubleOffset, 1, underline, textDecorationThickness, antialiasD ecoration, isPrinting); | 1232 |
| 1180 } | 1233 if (decorations) |
| 1181 if (deco & TextDecorationOverline) { | 1234 for (size_t i = 0; i < decorations->size(); ++i) |
| 1182 paintAppliedDecoration(context, localOrigin, width, -doubleOffset, 1 , overline, textDecorationThickness, antialiasDecoration, isPrinting); | 1235 paintAppliedDecoration(context, decorations->at(i), data); |
| 1183 } | |
| 1184 if (deco & TextDecorationLineThrough) { | |
| 1185 const float lineThroughOffset = 2 * baseline / 3; | |
| 1186 paintAppliedDecoration(context, localOrigin + FloatPoint(0, lineThro ughOffset), width, doubleOffset, 0, linethrough, textDecorationThickness, antial iasDecoration, isPrinting); | |
| 1187 } | |
| 1188 } | 1236 } |
| 1189 } | 1237 } |
| 1190 | 1238 |
| 1191 static GraphicsContext::DocumentMarkerLineStyle lineStyleForMarkerType(DocumentM arker::MarkerType markerType) | 1239 static GraphicsContext::DocumentMarkerLineStyle lineStyleForMarkerType(DocumentM arker::MarkerType markerType) |
| 1192 { | 1240 { |
| 1193 switch (markerType) { | 1241 switch (markerType) { |
| 1194 case DocumentMarker::Spelling: | 1242 case DocumentMarker::Spelling: |
| 1195 return GraphicsContext::DocumentMarkerSpellingLineStyle; | 1243 return GraphicsContext::DocumentMarkerSpellingLineStyle; |
| 1196 case DocumentMarker::Grammar: | 1244 case DocumentMarker::Grammar: |
| 1197 return GraphicsContext::DocumentMarkerGrammarLineStyle; | 1245 return GraphicsContext::DocumentMarkerGrammarLineStyle; |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1565 printedCharacters = fprintf(stderr, "\t%s %p", obj.renderName(), &obj); | 1613 printedCharacters = fprintf(stderr, "\t%s %p", obj.renderName(), &obj); |
| 1566 const int rendererCharacterOffset = 24; | 1614 const int rendererCharacterOffset = 24; |
| 1567 for (; printedCharacters < rendererCharacterOffset; printedCharacters++) | 1615 for (; printedCharacters < rendererCharacterOffset; printedCharacters++) |
| 1568 fputc(' ', stderr); | 1616 fputc(' ', stderr); |
| 1569 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d ata()); | 1617 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d ata()); |
| 1570 } | 1618 } |
| 1571 | 1619 |
| 1572 #endif | 1620 #endif |
| 1573 | 1621 |
| 1574 } // namespace WebCore | 1622 } // namespace WebCore |
| OLD | NEW |