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 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 LayoutUnit logicalExtent = logicalRightSide - logicalLeftSide; | 486 LayoutUnit logicalExtent = logicalRightSide - logicalLeftSide; |
487 | 487 |
488 LayoutUnit paintEnd = isHorizontal() ? paintInfo.rect.maxX() : paintInfo.rec
t.maxY(); | 488 LayoutUnit paintEnd = isHorizontal() ? paintInfo.rect.maxX() : paintInfo.rec
t.maxY(); |
489 LayoutUnit paintStart = isHorizontal() ? paintInfo.rect.x() : paintInfo.rect
.y(); | 489 LayoutUnit paintStart = isHorizontal() ? paintInfo.rect.x() : paintInfo.rect
.y(); |
490 | 490 |
491 LayoutPoint adjustedPaintOffset = roundedIntPoint(paintOffset); | 491 LayoutPoint adjustedPaintOffset = roundedIntPoint(paintOffset); |
492 | 492 |
493 if (logicalStart >= paintEnd || logicalStart + logicalExtent <= paintStart) | 493 if (logicalStart >= paintEnd || logicalStart + logicalExtent <= paintStart) |
494 return; | 494 return; |
495 | 495 |
496 bool isPrinting = textRenderer()->document()->printing(); | 496 bool isPrinting = textRenderer()->document().printing(); |
497 | 497 |
498 // Determine whether or not we're selected. | 498 // Determine whether or not we're selected. |
499 bool haveSelection = !isPrinting && paintInfo.phase != PaintPhaseTextClip &&
selectionState() != RenderObject::SelectionNone; | 499 bool haveSelection = !isPrinting && paintInfo.phase != PaintPhaseTextClip &&
selectionState() != RenderObject::SelectionNone; |
500 if (!haveSelection && paintInfo.phase == PaintPhaseSelection) | 500 if (!haveSelection && paintInfo.phase == PaintPhaseSelection) |
501 // When only painting the selection, don't bother to paint if there is n
one. | 501 // When only painting the selection, don't bother to paint if there is n
one. |
502 return; | 502 return; |
503 | 503 |
504 if (m_truncation != cNoTruncation) { | 504 if (m_truncation != cNoTruncation) { |
505 if (renderer()->containingBlock()->style()->isLeftToRightDirection() !=
isLeftToRightDirection()) { | 505 if (renderer()->containingBlock()->style()->isLeftToRightDirection() !=
isLeftToRightDirection()) { |
506 // Make the visible fragment of text hug the edge closest to the res
t of the run by moving the origin | 506 // Make the visible fragment of text hug the edge closest to the res
t of the run by moving the origin |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 textFillColor = Color::black; | 553 textFillColor = Color::black; |
554 textStrokeColor = Color::black; | 554 textStrokeColor = Color::black; |
555 emphasisMarkColor = Color::black; | 555 emphasisMarkColor = Color::black; |
556 } else { | 556 } else { |
557 textFillColor = rendererToUse->resolveColor(styleToUse, CSSPropertyWebki
tTextFillColor); | 557 textFillColor = rendererToUse->resolveColor(styleToUse, CSSPropertyWebki
tTextFillColor); |
558 | 558 |
559 bool forceBackgroundToWhite = false; | 559 bool forceBackgroundToWhite = false; |
560 if (isPrinting) { | 560 if (isPrinting) { |
561 if (styleToUse->printColorAdjust() == PrintColorAdjustEconomy) | 561 if (styleToUse->printColorAdjust() == PrintColorAdjustEconomy) |
562 forceBackgroundToWhite = true; | 562 forceBackgroundToWhite = true; |
563 if (textRenderer()->document()->settings() && textRenderer()->docume
nt()->settings()->shouldPrintBackgrounds()) | 563 if (textRenderer()->document().settings() && textRenderer()->documen
t().settings()->shouldPrintBackgrounds()) |
564 forceBackgroundToWhite = false; | 564 forceBackgroundToWhite = false; |
565 } | 565 } |
566 | 566 |
567 // Make the text fill color legible against a white background | 567 // Make the text fill color legible against a white background |
568 if (forceBackgroundToWhite) | 568 if (forceBackgroundToWhite) |
569 textFillColor = correctedTextColor(textFillColor, Color::white); | 569 textFillColor = correctedTextColor(textFillColor, Color::white); |
570 | 570 |
571 textStrokeColor = rendererToUse->resolveColor(styleToUse, CSSPropertyWeb
kitTextStrokeColor); | 571 textStrokeColor = rendererToUse->resolveColor(styleToUse, CSSPropertyWeb
kitTextStrokeColor); |
572 | 572 |
573 // Make the text stroke color legible against a white background | 573 // Make the text stroke color legible against a white background |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1092 localOrigin.move(m_logicalWidth - width, 0); | 1092 localOrigin.move(m_logicalWidth - width, 0); |
1093 } | 1093 } |
1094 | 1094 |
1095 // Get the text decoration colors. | 1095 // Get the text decoration colors. |
1096 Color underline, overline, linethrough; | 1096 Color underline, overline, linethrough; |
1097 renderer()->getTextDecorationColors(deco, underline, overline, linethrough,
true); | 1097 renderer()->getTextDecorationColors(deco, underline, overline, linethrough,
true); |
1098 if (isFirstLineStyle()) | 1098 if (isFirstLineStyle()) |
1099 renderer()->getTextDecorationColors(deco, underline, overline, linethrou
gh, true, true); | 1099 renderer()->getTextDecorationColors(deco, underline, overline, linethrou
gh, true, true); |
1100 | 1100 |
1101 // Use a special function for underlines to get the positioning exactly righ
t. | 1101 // Use a special function for underlines to get the positioning exactly righ
t. |
1102 bool isPrinting = textRenderer()->document()->printing(); | 1102 bool isPrinting = textRenderer()->document().printing(); |
1103 context->setStrokeThickness(textDecorationThickness); | 1103 context->setStrokeThickness(textDecorationThickness); |
1104 | 1104 |
1105 bool linesAreOpaque = !isPrinting && (!(deco & TextDecorationUnderline) || u
nderline.alpha() == 255) && (!(deco & TextDecorationOverline) || overline.alpha(
) == 255) && (!(deco & TextDecorationLineThrough) || linethrough.alpha() == 255)
; | 1105 bool linesAreOpaque = !isPrinting && (!(deco & TextDecorationUnderline) || u
nderline.alpha() == 255) && (!(deco & TextDecorationOverline) || overline.alpha(
) == 255) && (!(deco & TextDecorationLineThrough) || linethrough.alpha() == 255)
; |
1106 | 1106 |
1107 RenderStyle* styleToUse = renderer()->style(isFirstLineStyle()); | 1107 RenderStyle* styleToUse = renderer()->style(isFirstLineStyle()); |
1108 int baseline = styleToUse->fontMetrics().ascent(); | 1108 int baseline = styleToUse->fontMetrics().ascent(); |
1109 | 1109 |
1110 int extraOffset = 0; | 1110 int extraOffset = 0; |
1111 if (!linesAreOpaque && shadow && shadow->next()) { | 1111 if (!linesAreOpaque && shadow && shadow->next()) { |
1112 FloatRect clipRect(localOrigin, FloatSize(width, baseline + 2)); | 1112 FloatRect clipRect(localOrigin, FloatSize(width, baseline + 2)); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1206 return GraphicsContext::DocumentMarkerGrammarLineStyle; | 1206 return GraphicsContext::DocumentMarkerGrammarLineStyle; |
1207 default: | 1207 default: |
1208 ASSERT_NOT_REACHED(); | 1208 ASSERT_NOT_REACHED(); |
1209 return GraphicsContext::DocumentMarkerSpellingLineStyle; | 1209 return GraphicsContext::DocumentMarkerSpellingLineStyle; |
1210 } | 1210 } |
1211 } | 1211 } |
1212 | 1212 |
1213 void InlineTextBox::paintDocumentMarker(GraphicsContext* pt, const FloatPoint& b
oxOrigin, DocumentMarker* marker, RenderStyle* style, const Font& font, bool gra
mmar) | 1213 void InlineTextBox::paintDocumentMarker(GraphicsContext* pt, const FloatPoint& b
oxOrigin, DocumentMarker* marker, RenderStyle* style, const Font& font, bool gra
mmar) |
1214 { | 1214 { |
1215 // Never print spelling/grammar markers (5327887) | 1215 // Never print spelling/grammar markers (5327887) |
1216 if (textRenderer()->document()->printing()) | 1216 if (textRenderer()->document().printing()) |
1217 return; | 1217 return; |
1218 | 1218 |
1219 if (m_truncation == cFullTruncation) | 1219 if (m_truncation == cFullTruncation) |
1220 return; | 1220 return; |
1221 | 1221 |
1222 float start = 0; // start of line to draw, relative to tx | 1222 float start = 0; // start of line to draw, relative to tx |
1223 float width = m_logicalWidth; // how much line to draw | 1223 float width = m_logicalWidth; // how much line to draw |
1224 | 1224 |
1225 // Determine whether we need to measure text | 1225 // Determine whether we need to measure text |
1226 bool markerSpansWholeBox = true; | 1226 bool markerSpansWholeBox = true; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1304 pt->clip(FloatRect(boxOrigin.x(), boxOrigin.y() - deltaY, m_logicalWidth
, selHeight)); | 1304 pt->clip(FloatRect(boxOrigin.x(), boxOrigin.y() - deltaY, m_logicalWidth
, selHeight)); |
1305 pt->drawHighlightForText(font, run, FloatPoint(boxOrigin.x(), boxOrigin.
y() - deltaY), selHeight, color, sPos, ePos); | 1305 pt->drawHighlightForText(font, run, FloatPoint(boxOrigin.x(), boxOrigin.
y() - deltaY), selHeight, color, sPos, ePos); |
1306 } | 1306 } |
1307 } | 1307 } |
1308 | 1308 |
1309 void InlineTextBox::paintDocumentMarkers(GraphicsContext* pt, const FloatPoint&
boxOrigin, RenderStyle* style, const Font& font, bool background) | 1309 void InlineTextBox::paintDocumentMarkers(GraphicsContext* pt, const FloatPoint&
boxOrigin, RenderStyle* style, const Font& font, bool background) |
1310 { | 1310 { |
1311 if (!renderer()->node()) | 1311 if (!renderer()->node()) |
1312 return; | 1312 return; |
1313 | 1313 |
1314 Vector<DocumentMarker*> markers = renderer()->document()->markers()->markers
For(renderer()->node()); | 1314 Vector<DocumentMarker*> markers = renderer()->document().markers()->markersF
or(renderer()->node()); |
1315 Vector<DocumentMarker*>::const_iterator markerIt = markers.begin(); | 1315 Vector<DocumentMarker*>::const_iterator markerIt = markers.begin(); |
1316 | 1316 |
1317 // Give any document markers that touch this run a chance to draw before the
text has been drawn. | 1317 // Give any document markers that touch this run a chance to draw before the
text has been drawn. |
1318 // Note end() points at the last char, not one past it like endOffset and ra
nges do. | 1318 // Note end() points at the last char, not one past it like endOffset and ra
nges do. |
1319 for ( ; markerIt != markers.end(); markerIt++) { | 1319 for ( ; markerIt != markers.end(); markerIt++) { |
1320 DocumentMarker* marker = *markerIt; | 1320 DocumentMarker* marker = *markerIt; |
1321 | 1321 |
1322 // Paint either the background markers or the foreground markers, but no
t both | 1322 // Paint either the background markers or the foreground markers, but no
t both |
1323 switch (marker->type()) { | 1323 switch (marker->type()) { |
1324 case DocumentMarker::Grammar: | 1324 case DocumentMarker::Grammar: |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1396 if (underline.thick && logicalHeight() - baseline >= 2) | 1396 if (underline.thick && logicalHeight() - baseline >= 2) |
1397 lineThickness = 2; | 1397 lineThickness = 2; |
1398 | 1398 |
1399 // We need to have some space between underlines of subsequent clauses, beca
use some input methods do not use different underline styles for those. | 1399 // We need to have some space between underlines of subsequent clauses, beca
use some input methods do not use different underline styles for those. |
1400 // We make each line shorter, which has a harmless side effect of shortening
the first and last clauses, too. | 1400 // We make each line shorter, which has a harmless side effect of shortening
the first and last clauses, too. |
1401 start += 1; | 1401 start += 1; |
1402 width -= 2; | 1402 width -= 2; |
1403 | 1403 |
1404 ctx->setStrokeColor(underline.color); | 1404 ctx->setStrokeColor(underline.color); |
1405 ctx->setStrokeThickness(lineThickness); | 1405 ctx->setStrokeThickness(lineThickness); |
1406 ctx->drawLineForText(FloatPoint(boxOrigin.x() + start, boxOrigin.y() + logic
alHeight() - lineThickness), width, textRenderer()->document()->printing()); | 1406 ctx->drawLineForText(FloatPoint(boxOrigin.x() + start, boxOrigin.y() + logic
alHeight() - lineThickness), width, textRenderer()->document().printing()); |
1407 } | 1407 } |
1408 | 1408 |
1409 int InlineTextBox::caretMinOffset() const | 1409 int InlineTextBox::caretMinOffset() const |
1410 { | 1410 { |
1411 return m_start; | 1411 return m_start; |
1412 } | 1412 } |
1413 | 1413 |
1414 int InlineTextBox::caretMaxOffset() const | 1414 int InlineTextBox::caretMaxOffset() const |
1415 { | 1415 { |
1416 return m_start + m_len; | 1416 return m_start + m_len; |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1559 printedCharacters = fprintf(stderr, "\t%s %p", obj->renderName(), obj); | 1559 printedCharacters = fprintf(stderr, "\t%s %p", obj->renderName(), obj); |
1560 const int rendererCharacterOffset = 24; | 1560 const int rendererCharacterOffset = 24; |
1561 for (; printedCharacters < rendererCharacterOffset; printedCharacters++) | 1561 for (; printedCharacters < rendererCharacterOffset; printedCharacters++) |
1562 fputc(' ', stderr); | 1562 fputc(' ', stderr); |
1563 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d
ata()); | 1563 fprintf(stderr, "(%d,%d) \"%s\"\n", start(), start() + len(), value.utf8().d
ata()); |
1564 } | 1564 } |
1565 | 1565 |
1566 #endif | 1566 #endif |
1567 | 1567 |
1568 } // namespace WebCore | 1568 } // namespace WebCore |
OLD | NEW |