| 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 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1032 // Calculate start & width | 1032 // Calculate start & width |
| 1033 int deltaY = logicalTop() - selectionTop(); | 1033 int deltaY = logicalTop() - selectionTop(); |
| 1034 int selHeight = selectionHeight(); | 1034 int selHeight = selectionHeight(); |
| 1035 FloatPoint startPoint(boxOrigin.x(), boxOrigin.y() - deltaY); | 1035 FloatPoint startPoint(boxOrigin.x(), boxOrigin.y() - deltaY); |
| 1036 TextRun run = constructTextRun(style, font); | 1036 TextRun run = constructTextRun(style, font); |
| 1037 | 1037 |
| 1038 // FIXME: Convert the document markers to float rects. | 1038 // FIXME: Convert the document markers to float rects. |
| 1039 IntRect markerRect = enclosingIntRect(font.selectionRectForText(run, sta
rtPoint, selHeight, startPosition, endPosition)); | 1039 IntRect markerRect = enclosingIntRect(font.selectionRectForText(run, sta
rtPoint, selHeight, startPosition, endPosition)); |
| 1040 start = markerRect.x() - startPoint.x(); | 1040 start = markerRect.x() - startPoint.x(); |
| 1041 width = markerRect.width(); | 1041 width = markerRect.width(); |
| 1042 | |
| 1043 // Store rendered rects for bad grammar markers, so we can hit-test agai
nst it elsewhere in order to | |
| 1044 // display a toolTip. We don't do this for misspelling markers. | |
| 1045 if (grammar) { | |
| 1046 markerRect.move(-boxOrigin.x(), -boxOrigin.y()); | |
| 1047 markerRect = renderer().localToAbsoluteQuad(FloatRect(markerRect)).e
nclosingBoundingBox(); | |
| 1048 toRenderedDocumentMarker(marker)->setRenderedRect(markerRect); | |
| 1049 } | |
| 1050 } | 1042 } |
| 1051 | 1043 |
| 1052 // IMPORTANT: The misspelling underline is not considered when calculating t
he text bounds, so we have to | 1044 // IMPORTANT: The misspelling underline is not considered when calculating t
he text bounds, so we have to |
| 1053 // make sure to fit within those bounds. This means the top pixel(s) of the
underline will overlap the | 1045 // make sure to fit within those bounds. This means the top pixel(s) of the
underline will overlap the |
| 1054 // bottom pixel(s) of the glyphs in smaller font sizes. The alternatives ar
e to increase the line spacing (bad!!) | 1046 // bottom pixel(s) of the glyphs in smaller font sizes. The alternatives ar
e to increase the line spacing (bad!!) |
| 1055 // or decrease the underline thickness. The overlap is actually the most us
eful, and matches what AppKit does. | 1047 // or decrease the underline thickness. The overlap is actually the most us
eful, and matches what AppKit does. |
| 1056 // So, we generally place the underline at the bottom of the text, but in la
rger fonts that's not so good so | 1048 // So, we generally place the underline at the bottom of the text, but in la
rger fonts that's not so good so |
| 1057 // we pin to two pixels under the baseline. | 1049 // we pin to two pixels under the baseline. |
| 1058 int lineThickness = misspellingLineThickness; | 1050 int lineThickness = misspellingLineThickness; |
| 1059 int baseline = renderer().style(isFirstLineStyle())->fontMetrics().ascent(); | 1051 int baseline = renderer().style(isFirstLineStyle())->fontMetrics().ascent(); |
| 1060 int descent = logicalHeight() - baseline; | 1052 int descent = logicalHeight() - baseline; |
| 1061 int underlineOffset; | 1053 int underlineOffset; |
| 1062 if (descent <= (2 + lineThickness)) { | 1054 if (descent <= (2 + lineThickness)) { |
| 1063 // Place the underline at the very bottom of the text in small/medium fo
nts. | 1055 // Place the underline at the very bottom of the text in small/medium fo
nts. |
| 1064 underlineOffset = logicalHeight() - lineThickness; | 1056 underlineOffset = logicalHeight() - lineThickness; |
| 1065 } else { | 1057 } else { |
| 1066 // In larger fonts, though, place the underline up near the baseline to
prevent a big gap. | 1058 // In larger fonts, though, place the underline up near the baseline to
prevent a big gap. |
| 1067 underlineOffset = baseline + 2; | 1059 underlineOffset = baseline + 2; |
| 1068 } | 1060 } |
| 1069 pt->drawLineForDocumentMarker(FloatPoint(boxOrigin.x() + start, boxOrigin.y(
) + underlineOffset), width, lineStyleForMarkerType(marker->type())); | 1061 pt->drawLineForDocumentMarker(FloatPoint(boxOrigin.x() + start, boxOrigin.y(
) + underlineOffset), width, lineStyleForMarkerType(marker->type())); |
| 1070 } | 1062 } |
| 1071 | 1063 |
| 1072 void InlineTextBox::paintTextMatchMarker(GraphicsContext* pt, const FloatPoint&
boxOrigin, DocumentMarker* marker, RenderStyle* style, const Font& font) | 1064 void InlineTextBox::paintTextMatchMarker(GraphicsContext* pt, const FloatPoint&
boxOrigin, DocumentMarker* marker, RenderStyle* style, const Font& font) |
| 1073 { | 1065 { |
| 1074 // Use same y positioning and height as for selection, so that when the sele
ction and this highlight are on | 1066 // FIXME(sky): This function didn't seem to actually paint. |
| 1075 // the same word there are no pieces sticking out. | 1067 // Do we even have TextMatch markers in sky? What are they for? |
| 1076 int selHeight = selectionHeight(); | |
| 1077 | |
| 1078 int sPos = std::max(marker->startOffset() - m_start, (unsigned)0); | |
| 1079 int ePos = std::min(marker->endOffset() - m_start, (unsigned)m_len); | |
| 1080 TextRun run = constructTextRun(style, font); | |
| 1081 | |
| 1082 // Always compute and store the rect associated with this marker. The comput
ed rect is in absolute coordinates. | |
| 1083 IntRect markerRect = enclosingIntRect(font.selectionRectForText(run, IntPoin
t(x(), selectionTop()), selHeight, sPos, ePos)); | |
| 1084 markerRect = renderer().localToAbsoluteQuad(FloatRect(markerRect)).enclosing
BoundingBox(); | |
| 1085 toRenderedDocumentMarker(marker)->setRenderedRect(markerRect); | |
| 1086 } | 1068 } |
| 1087 | 1069 |
| 1088 void InlineTextBox::paintCompositionBackgrounds(GraphicsContext* pt, const Float
Point& boxOrigin, RenderStyle* style, const Font& font, bool useCustomUnderlines
) | 1070 void InlineTextBox::paintCompositionBackgrounds(GraphicsContext* pt, const Float
Point& boxOrigin, RenderStyle* style, const Font& font, bool useCustomUnderlines
) |
| 1089 { | 1071 { |
| 1090 if (useCustomUnderlines) { | 1072 if (useCustomUnderlines) { |
| 1091 // Paint custom background highlights for compositions. | 1073 // Paint custom background highlights for compositions. |
| 1092 const Vector<CompositionUnderline>& underlines = renderer().frame()->inp
utMethodController().customCompositionUnderlines(); | 1074 const Vector<CompositionUnderline>& underlines = renderer().frame()->inp
utMethodController().customCompositionUnderlines(); |
| 1093 CompositionUnderlineRangeFilter filter(underlines, start(), end()); | 1075 CompositionUnderlineRangeFilter filter(underlines, start(), end()); |
| 1094 for (CompositionUnderlineRangeFilter::ConstIterator it = filter.begin();
it != filter.end(); ++it) { | 1076 for (CompositionUnderlineRangeFilter::ConstIterator it = filter.begin();
it != filter.end(); ++it) { |
| 1095 if (it->backgroundColor == Color::transparent) | 1077 if (it->backgroundColor == Color::transparent) |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1357 printedCharacters = fprintf(stderr, "\t%s %p", obj.renderName(), &obj); | 1339 printedCharacters = fprintf(stderr, "\t%s %p", obj.renderName(), &obj); |
| 1358 const int rendererCharacterOffset = 24; | 1340 const int rendererCharacterOffset = 24; |
| 1359 for (; printedCharacters < rendererCharacterOffset; printedCharacters++) | 1341 for (; printedCharacters < rendererCharacterOffset; printedCharacters++) |
| 1360 fputc(' ', stderr); | 1342 fputc(' ', stderr); |
| 1361 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d
ata()); | 1343 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d
ata()); |
| 1362 } | 1344 } |
| 1363 | 1345 |
| 1364 #endif | 1346 #endif |
| 1365 | 1347 |
| 1366 } // namespace blink | 1348 } // namespace blink |
| OLD | NEW |