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 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 | 476 |
477 static inline AffineTransform rotation(const FloatRect& boxRect, RotationDirecti
on clockwise) | 477 static inline AffineTransform rotation(const FloatRect& boxRect, RotationDirecti
on clockwise) |
478 { | 478 { |
479 return clockwise ? AffineTransform(0, 1, -1, 0, boxRect.x() + boxRect.maxY()
, boxRect.maxY() - boxRect.x()) | 479 return clockwise ? AffineTransform(0, 1, -1, 0, boxRect.x() + boxRect.maxY()
, boxRect.maxY() - boxRect.x()) |
480 : AffineTransform(0, -1, 1, 0, boxRect.x() - boxRect.maxY(), boxRect.x()
+ boxRect.maxY()); | 480 : AffineTransform(0, -1, 1, 0, boxRect.x() - boxRect.maxY(), boxRect.x()
+ boxRect.maxY()); |
481 } | 481 } |
482 | 482 |
483 void InlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset,
LayoutUnit /*lineTop*/, LayoutUnit /*lineBottom*/) | 483 void InlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset,
LayoutUnit /*lineTop*/, LayoutUnit /*lineBottom*/) |
484 { | 484 { |
485 if (isLineBreak() || !paintInfo.shouldPaintWithinRoot(renderer()) || rendere
r()->style()->visibility() != VISIBLE || | 485 if (isLineBreak() || !paintInfo.shouldPaintWithinRoot(renderer()) || rendere
r()->style()->visibility() != VISIBLE || |
486 m_truncation == cFullTruncation || paintInfo.phase == PaintPhaseOutline
|| !m_len) | 486 m_truncation == cFullTruncation || paintInfo.getPhase() == PaintPhaseOut
line || !m_len) |
487 return; | 487 return; |
488 | 488 |
489 ASSERT(paintInfo.phase != PaintPhaseSelfOutline && paintInfo.phase != PaintP
haseChildOutlines); | 489 ASSERT(paintInfo.getPhase() != PaintPhaseSelfOutline && paintInfo.getPhase()
!= PaintPhaseChildOutlines); |
490 | 490 |
491 LayoutUnit logicalLeftSide = logicalLeftVisualOverflow(); | 491 LayoutUnit logicalLeftSide = logicalLeftVisualOverflow(); |
492 LayoutUnit logicalRightSide = logicalRightVisualOverflow(); | 492 LayoutUnit logicalRightSide = logicalRightVisualOverflow(); |
493 LayoutUnit logicalStart = logicalLeftSide + (isHorizontal() ? paintOffset.x(
) : paintOffset.y()); | 493 LayoutUnit logicalStart = logicalLeftSide + (isHorizontal() ? paintOffset.x(
) : paintOffset.y()); |
494 LayoutUnit logicalExtent = logicalRightSide - logicalLeftSide; | 494 LayoutUnit logicalExtent = logicalRightSide - logicalLeftSide; |
495 | 495 |
496 LayoutUnit paintEnd = isHorizontal() ? paintInfo.rect.maxX() : paintInfo.rec
t.maxY(); | 496 LayoutUnit paintEnd = isHorizontal() ? paintInfo.getRect().maxX() : paintInf
o.getRect().maxY(); |
497 LayoutUnit paintStart = isHorizontal() ? paintInfo.rect.x() : paintInfo.rect
.y(); | 497 LayoutUnit paintStart = isHorizontal() ? paintInfo.getRect().x() : paintInfo
.getRect().y(); |
498 | 498 |
499 LayoutPoint adjustedPaintOffset = roundedIntPoint(paintOffset); | 499 LayoutPoint adjustedPaintOffset = roundedIntPoint(paintOffset); |
500 | 500 |
501 if (logicalStart >= paintEnd || logicalStart + logicalExtent <= paintStart) | 501 if (logicalStart >= paintEnd || logicalStart + logicalExtent <= paintStart) |
502 return; | 502 return; |
503 | 503 |
504 bool isPrinting = textRenderer()->document()->printing(); | 504 bool isPrinting = textRenderer()->document()->printing(); |
505 | 505 |
506 // Determine whether or not we're selected. | 506 // Determine whether or not we're selected. |
507 bool haveSelection = !isPrinting && paintInfo.phase != PaintPhaseTextClip &&
selectionState() != RenderObject::SelectionNone; | 507 bool haveSelection = !isPrinting && paintInfo.getPhase() != PaintPhaseTextCl
ip && selectionState() != RenderObject::SelectionNone; |
508 if (!haveSelection && paintInfo.phase == PaintPhaseSelection) | 508 if (!haveSelection && paintInfo.getPhase() == PaintPhaseSelection) |
509 // When only painting the selection, don't bother to paint if there is n
one. | 509 // When only painting the selection, don't bother to paint if there is n
one. |
510 return; | 510 return; |
511 | 511 |
512 if (m_truncation != cNoTruncation) { | 512 if (m_truncation != cNoTruncation) { |
513 if (renderer()->containingBlock()->style()->isLeftToRightDirection() !=
isLeftToRightDirection()) { | 513 if (renderer()->containingBlock()->style()->isLeftToRightDirection() !=
isLeftToRightDirection()) { |
514 // Make the visible fragment of text hug the edge closest to the res
t of the run by moving the origin | 514 // Make the visible fragment of text hug the edge closest to the res
t of the run by moving the origin |
515 // at which we start drawing text. | 515 // at which we start drawing text. |
516 // e.g. In the case of LTR text truncated in an RTL Context, the cor
rect behavior is: | 516 // e.g. In the case of LTR text truncated in an RTL Context, the cor
rect behavior is: |
517 // |Hello|CBA| -> |...He|CBA| | 517 // |Hello|CBA| -> |...He|CBA| |
518 // In order to draw the fragment "He" aligned to the right edge of i
t's box, we need to start drawing | 518 // In order to draw the fragment "He" aligned to the right edge of i
t's box, we need to start drawing |
519 // farther to the right. | 519 // farther to the right. |
520 // NOTE: WebKit's behavior differs from that of IE which appears to
just overlay the ellipsis on top of the | 520 // NOTE: WebKit's behavior differs from that of IE which appears to
just overlay the ellipsis on top of the |
521 // truncated string i.e. |Hello|CBA| -> |...lo|CBA| | 521 // truncated string i.e. |Hello|CBA| -> |...lo|CBA| |
522 LayoutUnit widthOfVisibleText = toRenderText(renderer())->width(m_st
art, m_truncation, textPos(), isFirstLineStyle()); | 522 LayoutUnit widthOfVisibleText = toRenderText(renderer())->width(m_st
art, m_truncation, textPos(), isFirstLineStyle()); |
523 LayoutUnit widthOfHiddenText = m_logicalWidth - widthOfVisibleText; | 523 LayoutUnit widthOfHiddenText = m_logicalWidth - widthOfVisibleText; |
524 // FIXME: The hit testing logic also needs to take this translation
into account. | 524 // FIXME: The hit testing logic also needs to take this translation
into account. |
525 LayoutSize truncationOffset(isLeftToRightDirection() ? widthOfHidden
Text : -widthOfHiddenText, 0); | 525 LayoutSize truncationOffset(isLeftToRightDirection() ? widthOfHidden
Text : -widthOfHiddenText, 0); |
526 adjustedPaintOffset.move(isHorizontal() ? truncationOffset : truncat
ionOffset.transposedSize()); | 526 adjustedPaintOffset.move(isHorizontal() ? truncationOffset : truncat
ionOffset.transposedSize()); |
527 } | 527 } |
528 } | 528 } |
529 | 529 |
530 GraphicsContext* context = paintInfo.context; | 530 GraphicsContext* context = paintInfo.getContext(); |
531 | 531 |
532 RenderObject* rendererToUse = renderer(); | 532 RenderObject* rendererToUse = renderer(); |
533 RenderStyle* styleToUse = rendererToUse->style(isFirstLineStyle()); | 533 RenderStyle* styleToUse = rendererToUse->style(isFirstLineStyle()); |
534 | 534 |
535 adjustedPaintOffset.move(0, styleToUse->isHorizontalWritingMode() ? 0 : -log
icalHeight()); | 535 adjustedPaintOffset.move(0, styleToUse->isHorizontalWritingMode() ? 0 : -log
icalHeight()); |
536 | 536 |
537 FloatPoint boxOrigin = locationIncludingFlipping(); | 537 FloatPoint boxOrigin = locationIncludingFlipping(); |
538 boxOrigin.move(adjustedPaintOffset.x(), adjustedPaintOffset.y()); | 538 boxOrigin.move(adjustedPaintOffset.x(), adjustedPaintOffset.y()); |
539 FloatRect boxRect(boxOrigin, LayoutSize(logicalWidth(), logicalHeight())); | 539 FloatRect boxRect(boxOrigin, LayoutSize(logicalWidth(), logicalHeight())); |
540 | 540 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 if (forceBackgroundToWhite) | 582 if (forceBackgroundToWhite) |
583 textStrokeColor = correctedTextColor(textStrokeColor, Color::white); | 583 textStrokeColor = correctedTextColor(textStrokeColor, Color::white); |
584 | 584 |
585 emphasisMarkColor = rendererToUse->resolveColor(styleToUse, CSSPropertyW
ebkitTextEmphasisColor); | 585 emphasisMarkColor = rendererToUse->resolveColor(styleToUse, CSSPropertyW
ebkitTextEmphasisColor); |
586 | 586 |
587 // Make the text stroke color legible against a white background | 587 // Make the text stroke color legible against a white background |
588 if (forceBackgroundToWhite) | 588 if (forceBackgroundToWhite) |
589 emphasisMarkColor = correctedTextColor(emphasisMarkColor, Color::whi
te); | 589 emphasisMarkColor = correctedTextColor(emphasisMarkColor, Color::whi
te); |
590 } | 590 } |
591 | 591 |
592 bool paintSelectedTextOnly = (paintInfo.phase == PaintPhaseSelection); | 592 bool paintSelectedTextOnly = (paintInfo.getPhase() == PaintPhaseSelection); |
593 bool paintSelectedTextSeparately = false; | 593 bool paintSelectedTextSeparately = false; |
594 | 594 |
595 Color selectionFillColor = textFillColor; | 595 Color selectionFillColor = textFillColor; |
596 Color selectionStrokeColor = textStrokeColor; | 596 Color selectionStrokeColor = textStrokeColor; |
597 Color selectionEmphasisMarkColor = emphasisMarkColor; | 597 Color selectionEmphasisMarkColor = emphasisMarkColor; |
598 float selectionStrokeWidth = textStrokeWidth; | 598 float selectionStrokeWidth = textStrokeWidth; |
599 const ShadowData* selectionShadow = textShadow; | 599 const ShadowData* selectionShadow = textShadow; |
600 if (haveSelection) { | 600 if (haveSelection) { |
601 // Check foreground color first. | 601 // Check foreground color first. |
602 Color foreground = paintInfo.forceBlackText() ? Color::black : renderer(
)->selectionForegroundColor(); | 602 Color foreground = paintInfo.forceBlackText() ? Color::black : renderer(
)->selectionForegroundColor(); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 // Set our font. | 641 // Set our font. |
642 const Font& font = styleToUse->font(); | 642 const Font& font = styleToUse->font(); |
643 | 643 |
644 FloatPoint textOrigin = FloatPoint(boxOrigin.x(), boxOrigin.y() + font.fontM
etrics().ascent()); | 644 FloatPoint textOrigin = FloatPoint(boxOrigin.x(), boxOrigin.y() + font.fontM
etrics().ascent()); |
645 | 645 |
646 if (combinedText) | 646 if (combinedText) |
647 combinedText->adjustTextOrigin(textOrigin, boxRect); | 647 combinedText->adjustTextOrigin(textOrigin, boxRect); |
648 | 648 |
649 // 1. Paint backgrounds behind text if needed. Examples of such backgrounds
include selection | 649 // 1. Paint backgrounds behind text if needed. Examples of such backgrounds
include selection |
650 // and composition underlines. | 650 // and composition underlines. |
651 if (paintInfo.phase != PaintPhaseSelection && paintInfo.phase != PaintPhaseT
extClip && !isPrinting) { | 651 if (paintInfo.getPhase() != PaintPhaseSelection && paintInfo.getPhase() != P
aintPhaseTextClip && !isPrinting) { |
652 | 652 |
653 if (containsComposition && !useCustomUnderlines) | 653 if (containsComposition && !useCustomUnderlines) |
654 paintCompositionBackground(context, boxOrigin, styleToUse, font, | 654 paintCompositionBackground(context, boxOrigin, styleToUse, font, |
655 renderer()->frame()->editor()->compositionStart(), | 655 renderer()->frame()->editor()->compositionStart(), |
656 renderer()->frame()->editor()->compositionEnd()); | 656 renderer()->frame()->editor()->compositionEnd()); |
657 | 657 |
658 paintDocumentMarkers(context, boxOrigin, styleToUse, font, true); | 658 paintDocumentMarkers(context, boxOrigin, styleToUse, font, true); |
659 | 659 |
660 if (haveSelection && !useCustomUnderlines) | 660 if (haveSelection && !useCustomUnderlines) |
661 paintSelection(context, boxOrigin, styleToUse, font, selectionFillCo
lor); | 661 paintSelection(context, boxOrigin, styleToUse, font, selectionFillCo
lor); |
662 } | 662 } |
663 | 663 |
664 if (Frame* frame = renderer()->frame()) { | 664 if (Frame* frame = renderer()->frame()) { |
665 if (Page* page = frame->page()) { | 665 if (Page* page = frame->page()) { |
666 // FIXME: Right now, InlineTextBoxes never call addRelevantUnpainted
Object() even though they might | 666 // FIXME: Right now, InlineTextBoxes never call addRelevantUnpainted
Object() even though they might |
667 // legitimately be unpainted if they are waiting on a slow-loading w
eb font. We should fix that, and | 667 // legitimately be unpainted if they are waiting on a slow-loading w
eb font. We should fix that, and |
668 // when we do, we will have to account for the fact the InlineTextBo
xes do not always have unique | 668 // when we do, we will have to account for the fact the InlineTextBo
xes do not always have unique |
669 // renderers and Page currently relies on each unpainted object havi
ng a unique renderer. | 669 // renderers and Page currently relies on each unpainted object havi
ng a unique renderer. |
670 if (paintInfo.phase == PaintPhaseForeground) | 670 if (paintInfo.getPhase() == PaintPhaseForeground) |
671 page->addRelevantRepaintedObject(renderer(), IntRect(boxOrigin.x
(), boxOrigin.y(), logicalWidth(), logicalHeight())); | 671 page->addRelevantRepaintedObject(renderer(), IntRect(boxOrigin.x
(), boxOrigin.y(), logicalWidth(), logicalHeight())); |
672 } | 672 } |
673 } | 673 } |
674 | 674 |
675 // 2. Now paint the foreground, including text and decorations like underlin
e/overline (in quirks mode only). | 675 // 2. Now paint the foreground, including text and decorations like underlin
e/overline (in quirks mode only). |
676 int length = m_len; | 676 int length = m_len; |
677 int maximumLength; | 677 int maximumLength; |
678 StringView string; | 678 StringView string; |
679 if (!combinedText) { | 679 if (!combinedText) { |
680 string = textRenderer()->text().createView(); | 680 string = textRenderer()->text().createView(); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 | 760 |
761 paintTextWithShadows(context, rendererToUse, combinedText ? combined
Text->originalFont() : font, emphasisMarkTextRun, emphasisMark, emphasisMarkOffs
et, sPos, ePos, length, emphasisMarkTextOrigin, boxRect, selectionShadow, select
ionStrokeWidth > 0, isHorizontal()); | 761 paintTextWithShadows(context, rendererToUse, combinedText ? combined
Text->originalFont() : font, emphasisMarkTextRun, emphasisMark, emphasisMarkOffs
et, sPos, ePos, length, emphasisMarkTextOrigin, boxRect, selectionShadow, select
ionStrokeWidth > 0, isHorizontal()); |
762 | 762 |
763 if (combinedText) | 763 if (combinedText) |
764 context->concatCTM(rotation(boxRect, Counterclockwise)); | 764 context->concatCTM(rotation(boxRect, Counterclockwise)); |
765 } | 765 } |
766 } | 766 } |
767 | 767 |
768 // Paint decorations | 768 // Paint decorations |
769 TextDecoration textDecorations = styleToUse->textDecorationsInEffect(); | 769 TextDecoration textDecorations = styleToUse->textDecorationsInEffect(); |
770 if (textDecorations != TextDecorationNone && paintInfo.phase != PaintPhaseSe
lection) { | 770 if (textDecorations != TextDecorationNone && paintInfo.getPhase() != PaintPh
aseSelection) { |
771 updateGraphicsContext(context, textFillColor, textStrokeColor, textStrok
eWidth); | 771 updateGraphicsContext(context, textFillColor, textStrokeColor, textStrok
eWidth); |
772 if (combinedText) | 772 if (combinedText) |
773 context->concatCTM(rotation(boxRect, Clockwise)); | 773 context->concatCTM(rotation(boxRect, Clockwise)); |
774 paintDecoration(context, boxOrigin, textDecorations, styleToUse->textDec
orationStyle(), textShadow); | 774 paintDecoration(context, boxOrigin, textDecorations, styleToUse->textDec
orationStyle(), textShadow); |
775 if (combinedText) | 775 if (combinedText) |
776 context->concatCTM(rotation(boxRect, Counterclockwise)); | 776 context->concatCTM(rotation(boxRect, Counterclockwise)); |
777 } | 777 } |
778 | 778 |
779 if (paintInfo.phase == PaintPhaseForeground) { | 779 if (paintInfo.getPhase() == PaintPhaseForeground) { |
780 paintDocumentMarkers(context, boxOrigin, styleToUse, font, false); | 780 paintDocumentMarkers(context, boxOrigin, styleToUse, font, false); |
781 | 781 |
782 if (useCustomUnderlines) { | 782 if (useCustomUnderlines) { |
783 const Vector<CompositionUnderline>& underlines = renderer()->frame()
->editor()->customCompositionUnderlines(); | 783 const Vector<CompositionUnderline>& underlines = renderer()->frame()
->editor()->customCompositionUnderlines(); |
784 size_t numUnderlines = underlines.size(); | 784 size_t numUnderlines = underlines.size(); |
785 | 785 |
786 for (size_t index = 0; index < numUnderlines; ++index) { | 786 for (size_t index = 0; index < numUnderlines; ++index) { |
787 const CompositionUnderline& underline = underlines[index]; | 787 const CompositionUnderline& underline = underlines[index]; |
788 | 788 |
789 if (underline.endOffset <= start()) | 789 if (underline.endOffset <= start()) |
(...skipping 769 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 |