Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(350)

Side by Side Diff: Source/core/paint/InlineTextBoxPainter.cpp

Issue 1236183003: Add 'printing' flag to PaintInfo (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: PrintAdaption -> Printing; printing -> isPrinting; Comment fixups. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/paint/InlineTextBoxPainter.h ('k') | Source/core/paint/LineBoxListPainter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "core/paint/InlineTextBoxPainter.h" 6 #include "core/paint/InlineTextBoxPainter.h"
7 7
8 #include "core/dom/DocumentMarkerController.h" 8 #include "core/dom/DocumentMarkerController.h"
9 #include "core/dom/RenderedDocumentMarker.h" 9 #include "core/dom/RenderedDocumentMarker.h"
10 #include "core/editing/CompositionUnderline.h" 10 #include "core/editing/CompositionUnderline.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 62
63 LayoutUnit paintEnd = m_inlineTextBox.isHorizontal() ? paintInfo.rect.maxX() : paintInfo.rect.maxY(); 63 LayoutUnit paintEnd = m_inlineTextBox.isHorizontal() ? paintInfo.rect.maxX() : paintInfo.rect.maxY();
64 LayoutUnit paintStart = m_inlineTextBox.isHorizontal() ? paintInfo.rect.x() : paintInfo.rect.y(); 64 LayoutUnit paintStart = m_inlineTextBox.isHorizontal() ? paintInfo.rect.x() : paintInfo.rect.y();
65 65
66 // We round the y-axis to ensure consistent line heights. 66 // We round the y-axis to ensure consistent line heights.
67 LayoutPoint adjustedPaintOffset = LayoutPoint(paintOffset.x(), paintOffset.y ().round()); 67 LayoutPoint adjustedPaintOffset = LayoutPoint(paintOffset.x(), paintOffset.y ().round());
68 68
69 if (logicalStart >= paintEnd || logicalStart + logicalExtent <= paintStart) 69 if (logicalStart >= paintEnd || logicalStart + logicalExtent <= paintStart)
70 return; 70 return;
71 71
72 bool isPrinting = m_inlineTextBox.layoutObject().document().printing(); 72 bool isPrinting = paintInfo.isPrinting();
73 73
74 // Determine whether or not we're selected. 74 // Determine whether or not we're selected.
75 bool haveSelection = !isPrinting && paintInfo.phase != PaintPhaseTextClip && m_inlineTextBox.selectionState() != LayoutObject::SelectionNone; 75 bool haveSelection = !isPrinting && paintInfo.phase != PaintPhaseTextClip && m_inlineTextBox.selectionState() != LayoutObject::SelectionNone;
76 if (!haveSelection && paintInfo.phase == PaintPhaseSelection) { 76 if (!haveSelection && paintInfo.phase == PaintPhaseSelection) {
77 // When only painting the selection, don't bother to paint if there is n one. 77 // When only painting the selection, don't bother to paint if there is n one.
78 return; 78 return;
79 } 79 }
80 80
81 // Determine whether or not we have composition underlines to draw. 81 // Determine whether or not we have composition underlines to draw.
82 bool containsComposition = m_inlineTextBox.layoutObject().node() && m_inline TextBox.layoutObject().frame()->inputMethodController().compositionNode() == m_i nlineTextBox.layoutObject().node(); 82 bool containsComposition = m_inlineTextBox.layoutObject().node() && m_inline TextBox.layoutObject().frame()->inputMethodController().compositionNode() == m_i nlineTextBox.layoutObject().node();
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 textPainter.paint(selectionStart, selectionEnd, length, selectionStyle, cachedTextBlob); 231 textPainter.paint(selectionStart, selectionEnd, length, selectionStyle, cachedTextBlob);
232 } 232 }
233 233
234 // Paint decorations 234 // Paint decorations
235 TextDecoration textDecorations = styleToUse.textDecorationsInEffect(); 235 TextDecoration textDecorations = styleToUse.textDecorationsInEffect();
236 if (textDecorations != TextDecorationNone && !paintSelectedTextOnly) { 236 if (textDecorations != TextDecorationNone && !paintSelectedTextOnly) {
237 GraphicsContextStateSaver stateSaver(*context, false); 237 GraphicsContextStateSaver stateSaver(*context, false);
238 TextPainter::updateGraphicsContext(context, textStyle, m_inlineTextBox.i sHorizontal(), stateSaver); 238 TextPainter::updateGraphicsContext(context, textStyle, m_inlineTextBox.i sHorizontal(), stateSaver);
239 if (combinedText) 239 if (combinedText)
240 context->concatCTM(TextPainter::rotation(boxRect, TextPainter::Clock wise)); 240 context->concatCTM(TextPainter::rotation(boxRect, TextPainter::Clock wise));
241 paintDecoration(context, boxOrigin, textDecorations); 241 paintDecoration(paintInfo, boxOrigin, textDecorations);
242 if (combinedText) 242 if (combinedText)
243 context->concatCTM(TextPainter::rotation(boxRect, TextPainter::Count erclockwise)); 243 context->concatCTM(TextPainter::rotation(boxRect, TextPainter::Count erclockwise));
244 } 244 }
245 245
246 if (paintInfo.phase == PaintPhaseForeground) { 246 if (paintInfo.phase == PaintPhaseForeground) {
247 paintDocumentMarkers(context, boxOrigin, styleToUse, font, false); 247 paintDocumentMarkers(context, boxOrigin, styleToUse, font, false);
248 248
249 // Paint custom underlines for compositions. 249 // Paint custom underlines for compositions.
250 if (useCustomUnderlines) { 250 if (useCustomUnderlines) {
251 const Vector<CompositionUnderline>& underlines = m_inlineTextBox.lay outObject().frame()->inputMethodController().customCompositionUnderlines(); 251 const Vector<CompositionUnderline>& underlines = m_inlineTextBox.lay outObject().frame()->inputMethodController().customCompositionUnderlines();
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 context->setShouldAntialias(antialiasDecoration); 698 context->setShouldAntialias(antialiasDecoration);
699 // Fall through 699 // Fall through
700 default: 700 default:
701 context->drawLineForText(FloatPoint(start), width, isPrinting); 701 context->drawLineForText(FloatPoint(start), width, isPrinting);
702 702
703 if (decoration.style == TextDecorationStyleDouble) 703 if (decoration.style == TextDecorationStyleDouble)
704 context->drawLineForText(start + FloatPoint(0, doubleOffset), width, isPrinting); 704 context->drawLineForText(start + FloatPoint(0, doubleOffset), width, isPrinting);
705 } 705 }
706 } 706 }
707 707
708 void InlineTextBoxPainter::paintDecoration(GraphicsContext* context, const Layou tPoint& boxOrigin, TextDecoration deco) 708 void InlineTextBoxPainter::paintDecoration(const PaintInfo& paintInfo, const Lay outPoint& boxOrigin, TextDecoration deco)
709 { 709 {
710 GraphicsContextStateSaver stateSaver(*context);
711
712 if (m_inlineTextBox.truncation() == cFullTruncation) 710 if (m_inlineTextBox.truncation() == cFullTruncation)
713 return; 711 return;
714 712
713 GraphicsContext* context = paintInfo.context;
714 GraphicsContextStateSaver stateSaver(*context);
715
715 LayoutPoint localOrigin(boxOrigin); 716 LayoutPoint localOrigin(boxOrigin);
716 717
717 LayoutUnit width = m_inlineTextBox.logicalWidth(); 718 LayoutUnit width = m_inlineTextBox.logicalWidth();
718 if (m_inlineTextBox.truncation() != cNoTruncation) { 719 if (m_inlineTextBox.truncation() != cNoTruncation) {
719 width = m_inlineTextBox.layoutObject().width(m_inlineTextBox.start(), m_ inlineTextBox.truncation(), m_inlineTextBox.textPos(), m_inlineTextBox.isLeftToR ightDirection() ? LTR : RTL, m_inlineTextBox.isFirstLineStyle()); 720 width = m_inlineTextBox.layoutObject().width(m_inlineTextBox.start(), m_ inlineTextBox.truncation(), m_inlineTextBox.textPos(), m_inlineTextBox.isLeftToR ightDirection() ? LTR : RTL, m_inlineTextBox.isFirstLineStyle());
720 if (!m_inlineTextBox.isLeftToRightDirection()) 721 if (!m_inlineTextBox.isLeftToRightDirection())
721 localOrigin.move(m_inlineTextBox.logicalWidth() - width, 0); 722 localOrigin.move(m_inlineTextBox.logicalWidth() - width, 0);
722 } 723 }
723 724
724 // Get the text decoration colors. 725 // Get the text decoration colors.
725 LayoutObject::AppliedTextDecoration underline, overline, linethrough; 726 LayoutObject::AppliedTextDecoration underline, overline, linethrough;
726 m_inlineTextBox.layoutObject().getTextDecorations(deco, underline, overline, linethrough, true); 727 m_inlineTextBox.layoutObject().getTextDecorations(deco, underline, overline, linethrough, true);
727 if (m_inlineTextBox.isFirstLineStyle()) 728 if (m_inlineTextBox.isFirstLineStyle())
728 m_inlineTextBox.layoutObject().getTextDecorations(deco, underline, overl ine, linethrough, true, true); 729 m_inlineTextBox.layoutObject().getTextDecorations(deco, underline, overl ine, linethrough, true, true);
729 730
730 // Use a special function for underlines to get the positioning exactly righ t. 731 // Use a special function for underlines to get the positioning exactly righ t.
731 bool isPrinting = m_inlineTextBox.layoutObject().document().printing(); 732 bool isPrinting = paintInfo.isPrinting();
732 733
733 const ComputedStyle& styleToUse = m_inlineTextBox.layoutObject().styleRef(m_ inlineTextBox.isFirstLineStyle()); 734 const ComputedStyle& styleToUse = m_inlineTextBox.layoutObject().styleRef(m_ inlineTextBox.isFirstLineStyle());
734 float baseline = styleToUse.fontMetrics().ascent(); 735 float baseline = styleToUse.fontMetrics().ascent();
735 736
736 // Set the thick of the line to be 10% (or something else ?)of the computed font size and not less than 1px. 737 // Set the thick of the line to be 10% (or something else ?)of the computed font size and not less than 1px.
737 // Using computedFontSize should take care of zoom as well. 738 // Using computedFontSize should take care of zoom as well.
738 739
739 // Update Underline thickness, in case we have Faulty Font Metrics calculati ng underline thickness by old method. 740 // Update Underline thickness, in case we have Faulty Font Metrics calculati ng underline thickness by old method.
740 float textDecorationThickness = styleToUse.fontMetrics().underlineThickness( ); 741 float textDecorationThickness = styleToUse.fontMetrics().underlineThickness( );
741 int fontHeightInt = (int)(styleToUse.fontMetrics().floatHeight() + 0.5); 742 int fontHeightInt = (int)(styleToUse.fontMetrics().floatHeight() + 0.5);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 LayoutTheme::theme().platformActiveTextSearchHighlightColor() : 814 LayoutTheme::theme().platformActiveTextSearchHighlightColor() :
814 LayoutTheme::theme().platformInactiveTextSearchHighlightColor(); 815 LayoutTheme::theme().platformInactiveTextSearchHighlightColor();
815 GraphicsContextStateSaver stateSaver(*pt); 816 GraphicsContextStateSaver stateSaver(*pt);
816 pt->clip(FloatRect(boxOrigin.x().toFloat(), (boxOrigin.y() - deltaY).toF loat(), m_inlineTextBox.logicalWidth().toFloat(), selHeight)); 817 pt->clip(FloatRect(boxOrigin.x().toFloat(), (boxOrigin.y() - deltaY).toF loat(), m_inlineTextBox.logicalWidth().toFloat(), selHeight));
817 pt->drawHighlightForText(font, run, FloatPoint(boxOrigin.x().toFloat(), (boxOrigin.y() - deltaY).toFloat()), selHeight, color, sPos, ePos); 818 pt->drawHighlightForText(font, run, FloatPoint(boxOrigin.x().toFloat(), (boxOrigin.y() - deltaY).toFloat()), selHeight, color, sPos, ePos);
818 } 819 }
819 } 820 }
820 821
821 822
822 } // namespace blink 823 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/paint/InlineTextBoxPainter.h ('k') | Source/core/paint/LineBoxListPainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698