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 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
917 context->drawHighlightForText(font, constructTextRun(style, font), localOrig
in, selHeight, c, style->colorSpace(), sPos, ePos); | 917 context->drawHighlightForText(font, constructTextRun(style, font), localOrig
in, selHeight, c, style->colorSpace(), sPos, ePos); |
918 } | 918 } |
919 | 919 |
920 static StrokeStyle textDecorationStyleToStrokeStyle(TextDecorationStyle decorati
onStyle) | 920 static StrokeStyle textDecorationStyleToStrokeStyle(TextDecorationStyle decorati
onStyle) |
921 { | 921 { |
922 StrokeStyle strokeStyle = SolidStroke; | 922 StrokeStyle strokeStyle = SolidStroke; |
923 switch (decorationStyle) { | 923 switch (decorationStyle) { |
924 case TextDecorationStyleSolid: | 924 case TextDecorationStyleSolid: |
925 strokeStyle = SolidStroke; | 925 strokeStyle = SolidStroke; |
926 break; | 926 break; |
927 #if ENABLE(CSS3_TEXT) | |
928 case TextDecorationStyleDouble: | 927 case TextDecorationStyleDouble: |
929 strokeStyle = DoubleStroke; | 928 strokeStyle = DoubleStroke; |
930 break; | 929 break; |
931 case TextDecorationStyleDotted: | 930 case TextDecorationStyleDotted: |
932 strokeStyle = DottedStroke; | 931 strokeStyle = DottedStroke; |
933 break; | 932 break; |
934 case TextDecorationStyleDashed: | 933 case TextDecorationStyleDashed: |
935 strokeStyle = DashedStroke; | 934 strokeStyle = DashedStroke; |
936 break; | 935 break; |
937 case TextDecorationStyleWavy: | 936 case TextDecorationStyleWavy: |
938 strokeStyle = WavyStroke; | 937 strokeStyle = WavyStroke; |
939 break; | 938 break; |
940 #endif // CSS3_TEXT | |
941 } | 939 } |
942 | 940 |
943 return strokeStyle; | 941 return strokeStyle; |
944 } | 942 } |
945 | 943 |
946 #if ENABLE(CSS3_TEXT) | 944 #if ENABLE(CSS3_TEXT) |
947 static int computeUnderlineOffset(const TextUnderlinePosition underlinePosition,
const FontMetrics& fontMetrics, const InlineTextBox* inlineTextBox, const int t
extDecorationThickness) | 945 static int computeUnderlineOffset(const TextUnderlinePosition underlinePosition,
const FontMetrics& fontMetrics, const InlineTextBox* inlineTextBox, const int t
extDecorationThickness) |
948 { | 946 { |
949 // Compute the gap between the font and the underline. Use at least one | 947 // Compute the gap between the font and the underline. Use at least one |
950 // pixel gap, if underline is thick then use a bigger gap. | 948 // pixel gap, if underline is thick then use a bigger gap. |
(...skipping 12 matching lines...) Expand all Loading... |
963 return inlineTextBox->logicalHeight() + gap + offset; | 961 return inlineTextBox->logicalHeight() + gap + offset; |
964 return inlineTextBox->logicalHeight() + gap; | 962 return inlineTextBox->logicalHeight() + gap; |
965 } | 963 } |
966 } | 964 } |
967 | 965 |
968 ASSERT_NOT_REACHED(); | 966 ASSERT_NOT_REACHED(); |
969 return fontMetrics.ascent() + gap; | 967 return fontMetrics.ascent() + gap; |
970 } | 968 } |
971 #endif // CSS3_TEXT | 969 #endif // CSS3_TEXT |
972 | 970 |
973 #if ENABLE(CSS3_TEXT) | |
974 static void adjustStepToDecorationLength(float& step, float& controlPointDistanc
e, float length) | 971 static void adjustStepToDecorationLength(float& step, float& controlPointDistanc
e, float length) |
975 { | 972 { |
976 ASSERT(step > 0); | 973 ASSERT(step > 0); |
977 | 974 |
978 if (length <= 0) | 975 if (length <= 0) |
979 return; | 976 return; |
980 | 977 |
981 unsigned stepCount = static_cast<unsigned>(length / step); | 978 unsigned stepCount = static_cast<unsigned>(length / step); |
982 | 979 |
983 // Each Bezier curve starts at the same pixel that the previous one | 980 // Each Bezier curve starts at the same pixel that the previous one |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1085 controlPoint1.setX(x + step); | 1082 controlPoint1.setX(x + step); |
1086 controlPoint2.setX(x + step); | 1083 controlPoint2.setX(x + step); |
1087 x += 2 * step; | 1084 x += 2 * step; |
1088 path.addBezierCurveTo(controlPoint1, controlPoint2, FloatPoint(x, yA
xis)); | 1085 path.addBezierCurveTo(controlPoint1, controlPoint2, FloatPoint(x, yA
xis)); |
1089 } | 1086 } |
1090 } | 1087 } |
1091 | 1088 |
1092 context->setShouldAntialias(true); | 1089 context->setShouldAntialias(true); |
1093 context->strokePath(path); | 1090 context->strokePath(path); |
1094 } | 1091 } |
1095 #endif // CSS3_TEXT | |
1096 | 1092 |
1097 void InlineTextBox::paintDecoration(GraphicsContext* context, const FloatPoint&
boxOrigin, ETextDecoration deco, TextDecorationStyle decorationStyle, const Shad
owData* shadow) | 1093 void InlineTextBox::paintDecoration(GraphicsContext* context, const FloatPoint&
boxOrigin, ETextDecoration deco, TextDecorationStyle decorationStyle, const Shad
owData* shadow) |
1098 { | 1094 { |
1099 // FIXME: We should improve this rule and not always just assume 1. | 1095 // FIXME: We should improve this rule and not always just assume 1. |
1100 const float textDecorationThickness = 1.f; | 1096 const float textDecorationThickness = 1.f; |
1101 | 1097 |
1102 if (m_truncation == cFullTruncation) | 1098 if (m_truncation == cFullTruncation) |
1103 return; | 1099 return; |
1104 | 1100 |
1105 FloatPoint localOrigin = boxOrigin; | 1101 FloatPoint localOrigin = boxOrigin; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1156 localOrigin.move(0, -extraOffset); | 1152 localOrigin.move(0, -extraOffset); |
1157 extraOffset = 0; | 1153 extraOffset = 0; |
1158 } | 1154 } |
1159 int shadowX = isHorizontal() ? shadow->x() : shadow->y(); | 1155 int shadowX = isHorizontal() ? shadow->x() : shadow->y(); |
1160 int shadowY = isHorizontal() ? shadow->y() : -shadow->x(); | 1156 int shadowY = isHorizontal() ? shadow->y() : -shadow->x(); |
1161 context->setShadow(FloatSize(shadowX, shadowY - extraOffset), shadow
->blur(), shadow->color(), colorSpace); | 1157 context->setShadow(FloatSize(shadowX, shadowY - extraOffset), shadow
->blur(), shadow->color(), colorSpace); |
1162 setShadow = true; | 1158 setShadow = true; |
1163 shadow = shadow->next(); | 1159 shadow = shadow->next(); |
1164 } | 1160 } |
1165 | 1161 |
1166 #if ENABLE(CSS3_TEXT) | |
1167 // Offset between lines - always non-zero, so lines never cross each oth
er. | 1162 // Offset between lines - always non-zero, so lines never cross each oth
er. |
1168 float doubleOffset = textDecorationThickness + 1.f; | 1163 float doubleOffset = textDecorationThickness + 1.f; |
1169 #endif // CSS3_TEXT | |
1170 context->setStrokeStyle(textDecorationStyleToStrokeStyle(decorationStyle
)); | 1164 context->setStrokeStyle(textDecorationStyleToStrokeStyle(decorationStyle
)); |
1171 if (deco & UNDERLINE) { | 1165 if (deco & UNDERLINE) { |
1172 context->setStrokeColor(underline, colorSpace); | 1166 context->setStrokeColor(underline, colorSpace); |
1173 #if ENABLE(CSS3_TEXT) | 1167 #if ENABLE(CSS3_TEXT) |
1174 TextUnderlinePosition underlinePosition = styleToUse->textUnderlineP
osition(); | 1168 TextUnderlinePosition underlinePosition = styleToUse->textUnderlineP
osition(); |
1175 const int underlineOffset = computeUnderlineOffset(underlinePosition
, styleToUse->fontMetrics(), this, textDecorationThickness); | 1169 const int underlineOffset = computeUnderlineOffset(underlinePosition
, styleToUse->fontMetrics(), this, textDecorationThickness); |
| 1170 #else |
| 1171 const int underlineOffset = styleToUse->fontMetrics().ascent() + max
<int>(1, ceilf(textDecorationThickness / 2.0)); |
| 1172 #endif // CSS3_TEXT |
1176 | 1173 |
1177 switch (decorationStyle) { | 1174 switch (decorationStyle) { |
1178 case TextDecorationStyleWavy: { | 1175 case TextDecorationStyleWavy: { |
1179 FloatPoint start(localOrigin.x(), localOrigin.y() + underlineOff
set + doubleOffset); | 1176 FloatPoint start(localOrigin.x(), localOrigin.y() + underlineOff
set + doubleOffset); |
1180 FloatPoint end(localOrigin.x() + width, localOrigin.y() + underl
ineOffset + doubleOffset); | 1177 FloatPoint end(localOrigin.x() + width, localOrigin.y() + underl
ineOffset + doubleOffset); |
1181 strokeWavyTextDecoration(context, start, end, textDecorationThic
kness); | 1178 strokeWavyTextDecoration(context, start, end, textDecorationThic
kness); |
1182 break; | 1179 break; |
1183 } | 1180 } |
1184 default: | 1181 default: |
1185 context->drawLineForText(FloatPoint(localOrigin.x(), localOrigin
.y() + underlineOffset), width, isPrinting); | 1182 context->drawLineForText(FloatPoint(localOrigin.x(), localOrigin
.y() + underlineOffset), width, isPrinting); |
1186 | 1183 |
1187 if (decorationStyle == TextDecorationStyleDouble) | 1184 if (decorationStyle == TextDecorationStyleDouble) |
1188 context->drawLineForText(FloatPoint(localOrigin.x(), localOr
igin.y() + underlineOffset + doubleOffset), width, isPrinting); | 1185 context->drawLineForText(FloatPoint(localOrigin.x(), localOr
igin.y() + underlineOffset + doubleOffset), width, isPrinting); |
1189 } | 1186 } |
1190 #else | |
1191 // Leave one pixel of white between the baseline and the underline. | |
1192 context->drawLineForText(FloatPoint(localOrigin.x(), localOrigin.y()
+ baseline + 1), width, isPrinting); | |
1193 #endif // CSS3_TEXT | |
1194 } | 1187 } |
1195 if (deco & OVERLINE) { | 1188 if (deco & OVERLINE) { |
1196 context->setStrokeColor(overline, colorSpace); | 1189 context->setStrokeColor(overline, colorSpace); |
1197 #if ENABLE(CSS3_TEXT) | |
1198 switch (decorationStyle) { | 1190 switch (decorationStyle) { |
1199 case TextDecorationStyleWavy: { | 1191 case TextDecorationStyleWavy: { |
1200 FloatPoint start(localOrigin.x(), localOrigin.y() - doubleOffset
); | 1192 FloatPoint start(localOrigin.x(), localOrigin.y() - doubleOffset
); |
1201 FloatPoint end(localOrigin.x() + width, localOrigin.y() - double
Offset); | 1193 FloatPoint end(localOrigin.x() + width, localOrigin.y() - double
Offset); |
1202 strokeWavyTextDecoration(context, start, end, textDecorationThic
kness); | 1194 strokeWavyTextDecoration(context, start, end, textDecorationThic
kness); |
1203 break; | 1195 break; |
1204 } | 1196 } |
1205 default: | 1197 default: |
1206 #endif // CSS3_TEXT | |
1207 context->drawLineForText(localOrigin, width, isPrinting); | 1198 context->drawLineForText(localOrigin, width, isPrinting); |
1208 #if ENABLE(CSS3_TEXT) | |
1209 if (decorationStyle == TextDecorationStyleDouble) | 1199 if (decorationStyle == TextDecorationStyleDouble) |
1210 context->drawLineForText(FloatPoint(localOrigin.x(), localOr
igin.y() - doubleOffset), width, isPrinting); | 1200 context->drawLineForText(FloatPoint(localOrigin.x(), localOr
igin.y() - doubleOffset), width, isPrinting); |
1211 } | 1201 } |
1212 #endif // CSS3_TEXT | |
1213 } | 1202 } |
1214 if (deco & LINE_THROUGH) { | 1203 if (deco & LINE_THROUGH) { |
1215 context->setStrokeColor(linethrough, colorSpace); | 1204 context->setStrokeColor(linethrough, colorSpace); |
1216 #if ENABLE(CSS3_TEXT) | |
1217 switch (decorationStyle) { | 1205 switch (decorationStyle) { |
1218 case TextDecorationStyleWavy: { | 1206 case TextDecorationStyleWavy: { |
1219 FloatPoint start(localOrigin.x(), localOrigin.y() + 2 * baseline
/ 3); | 1207 FloatPoint start(localOrigin.x(), localOrigin.y() + 2 * baseline
/ 3); |
1220 FloatPoint end(localOrigin.x() + width, localOrigin.y() + 2 * ba
seline / 3); | 1208 FloatPoint end(localOrigin.x() + width, localOrigin.y() + 2 * ba
seline / 3); |
1221 strokeWavyTextDecoration(context, start, end, textDecorationThic
kness); | 1209 strokeWavyTextDecoration(context, start, end, textDecorationThic
kness); |
1222 break; | 1210 break; |
1223 } | 1211 } |
1224 default: | 1212 default: |
1225 #endif // CSS3_TEXT | |
1226 context->drawLineForText(FloatPoint(localOrigin.x(), localOrigin
.y() + 2 * baseline / 3), width, isPrinting); | 1213 context->drawLineForText(FloatPoint(localOrigin.x(), localOrigin
.y() + 2 * baseline / 3), width, isPrinting); |
1227 #if ENABLE(CSS3_TEXT) | |
1228 if (decorationStyle == TextDecorationStyleDouble) | 1214 if (decorationStyle == TextDecorationStyleDouble) |
1229 context->drawLineForText(FloatPoint(localOrigin.x(), localOr
igin.y() + doubleOffset + 2 * baseline / 3), width, isPrinting); | 1215 context->drawLineForText(FloatPoint(localOrigin.x(), localOr
igin.y() + doubleOffset + 2 * baseline / 3), width, isPrinting); |
1230 } | 1216 } |
1231 #endif // CSS3_TEXT | |
1232 } | 1217 } |
1233 } while (shadow); | 1218 } while (shadow); |
1234 | 1219 |
1235 if (setClip) | 1220 if (setClip) |
1236 context->restore(); | 1221 context->restore(); |
1237 else if (setShadow) | 1222 else if (setShadow) |
1238 context->clearShadow(); | 1223 context->clearShadow(); |
1239 } | 1224 } |
1240 | 1225 |
1241 static GraphicsContext::DocumentMarkerLineStyle lineStyleForMarkerType(DocumentM
arker::MarkerType markerType) | 1226 static GraphicsContext::DocumentMarkerLineStyle lineStyleForMarkerType(DocumentM
arker::MarkerType markerType) |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1601 | 1586 |
1602 void InlineTextBox::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const | 1587 void InlineTextBox::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const |
1603 { | 1588 { |
1604 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Rendering); | 1589 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Rendering); |
1605 InlineBox::reportMemoryUsage(memoryObjectInfo); | 1590 InlineBox::reportMemoryUsage(memoryObjectInfo); |
1606 info.addMember(m_prevTextBox, "prevTextBox"); | 1591 info.addMember(m_prevTextBox, "prevTextBox"); |
1607 info.addMember(m_nextTextBox, "nextTextBox"); | 1592 info.addMember(m_nextTextBox, "nextTextBox"); |
1608 } | 1593 } |
1609 | 1594 |
1610 } // namespace WebCore | 1595 } // namespace WebCore |
OLD | NEW |