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

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

Issue 1648573002: Transition to explicit constructors in LayoutUnit (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove int constructors for size/point... they result in incorrect conversions until LayoutUnit is … Created 4 years, 10 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
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 "core/paint/InlineTextBoxPainter.h" 5 #include "core/paint/InlineTextBoxPainter.h"
6 6
7 #include "core/editing/CompositionUnderline.h" 7 #include "core/editing/CompositionUnderline.h"
8 #include "core/editing/Editor.h" 8 #include "core/editing/Editor.h"
9 #include "core/editing/markers/DocumentMarkerController.h" 9 #include "core/editing/markers/DocumentMarkerController.h"
10 #include "core/editing/markers/RenderedDocumentMarker.h" 10 #include "core/editing/markers/RenderedDocumentMarker.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 if (!shouldPaintTextBox(paintInfo)) 58 if (!shouldPaintTextBox(paintInfo))
59 return; 59 return;
60 60
61 ASSERT(!shouldPaintSelfOutline(paintInfo.phase) && !shouldPaintDescendantOut lines(paintInfo.phase)); 61 ASSERT(!shouldPaintSelfOutline(paintInfo.phase) && !shouldPaintDescendantOut lines(paintInfo.phase));
62 62
63 LayoutRect logicalVisualOverflow = m_inlineTextBox.logicalOverflowRect(); 63 LayoutRect logicalVisualOverflow = m_inlineTextBox.logicalOverflowRect();
64 LayoutUnit logicalStart = logicalVisualOverflow.x() + (m_inlineTextBox.isHor izontal() ? paintOffset.x() : paintOffset.y()); 64 LayoutUnit logicalStart = logicalVisualOverflow.x() + (m_inlineTextBox.isHor izontal() ? paintOffset.x() : paintOffset.y());
65 LayoutUnit logicalExtent = logicalVisualOverflow.width(); 65 LayoutUnit logicalExtent = logicalVisualOverflow.width();
66 66
67 // We round the y-axis to ensure consistent line heights. 67 // We round the y-axis to ensure consistent line heights.
68 LayoutPoint adjustedPaintOffset = LayoutPoint(paintOffset.x(), paintOffset.y ().round()); 68 LayoutPoint adjustedPaintOffset = LayoutPoint(paintOffset.x(), LayoutUnit(pa intOffset.y().round()));
69 69
70 if (m_inlineTextBox.isHorizontal()) { 70 if (m_inlineTextBox.isHorizontal()) {
71 if (!paintInfo.cullRect().intersectsHorizontalRange(logicalStart, logica lStart + logicalExtent)) 71 if (!paintInfo.cullRect().intersectsHorizontalRange(logicalStart, logica lStart + logicalExtent))
72 return; 72 return;
73 } else { 73 } else {
74 if (!paintInfo.cullRect().intersectsVerticalRange(logicalStart, logicalS tart + logicalExtent)) 74 if (!paintInfo.cullRect().intersectsVerticalRange(logicalStart, logicalS tart + logicalExtent))
75 return; 75 return;
76 } 76 }
77 77
78 bool isPrinting = paintInfo.isPrinting(); 78 bool isPrinting = paintInfo.isPrinting();
(...skipping 25 matching lines...) Expand all
104 // at which we start drawing text. 104 // at which we start drawing text.
105 // e.g. In the case of LTR text truncated in an RTL Context, the cor rect behavior is: 105 // e.g. In the case of LTR text truncated in an RTL Context, the cor rect behavior is:
106 // |Hello|CBA| -> |...He|CBA| 106 // |Hello|CBA| -> |...He|CBA|
107 // In order to draw the fragment "He" aligned to the right edge of i t's box, we need to start drawing 107 // In order to draw the fragment "He" aligned to the right edge of i t's box, we need to start drawing
108 // farther to the right. 108 // farther to the right.
109 // NOTE: WebKit's behavior differs from that of IE which appears to just overlay the ellipsis on top of the 109 // NOTE: WebKit's behavior differs from that of IE which appears to just overlay the ellipsis on top of the
110 // truncated string i.e. |Hello|CBA| -> |...lo|CBA| 110 // truncated string i.e. |Hello|CBA| -> |...lo|CBA|
111 LayoutUnit widthOfVisibleText = m_inlineTextBox.lineLayoutItem().wid th(m_inlineTextBox.start(), m_inlineTextBox.truncation(), m_inlineTextBox.textPo s(), m_inlineTextBox.isLeftToRightDirection() ? LTR : RTL, m_inlineTextBox.isFir stLineStyle()); 111 LayoutUnit widthOfVisibleText = m_inlineTextBox.lineLayoutItem().wid th(m_inlineTextBox.start(), m_inlineTextBox.truncation(), m_inlineTextBox.textPo s(), m_inlineTextBox.isLeftToRightDirection() ? LTR : RTL, m_inlineTextBox.isFir stLineStyle());
112 LayoutUnit widthOfHiddenText = m_inlineTextBox.logicalWidth() - widt hOfVisibleText; 112 LayoutUnit widthOfHiddenText = m_inlineTextBox.logicalWidth() - widt hOfVisibleText;
113 // FIXME: The hit testing logic also needs to take this translation into account. 113 // FIXME: The hit testing logic also needs to take this translation into account.
114 LayoutSize truncationOffset(m_inlineTextBox.isLeftToRightDirection() ? widthOfHiddenText : -widthOfHiddenText, 0); 114 LayoutSize truncationOffset(m_inlineTextBox.isLeftToRightDirection() ? widthOfHiddenText : -widthOfHiddenText, LayoutUnit());
115 adjustedPaintOffset.move(m_inlineTextBox.isHorizontal() ? truncation Offset : truncationOffset.transposedSize()); 115 adjustedPaintOffset.move(m_inlineTextBox.isHorizontal() ? truncation Offset : truncationOffset.transposedSize());
116 } 116 }
117 } 117 }
118 118
119 GraphicsContext& context = paintInfo.context; 119 GraphicsContext& context = paintInfo.context;
120 const ComputedStyle& styleToUse = m_inlineTextBox.lineLayoutItem().styleRef( m_inlineTextBox.isFirstLineStyle()); 120 const ComputedStyle& styleToUse = m_inlineTextBox.lineLayoutItem().styleRef( m_inlineTextBox.isFirstLineStyle());
121 121
122 LayoutPoint boxOrigin(m_inlineTextBox.locationIncludingFlipping()); 122 LayoutPoint boxOrigin(m_inlineTextBox.locationIncludingFlipping());
123 boxOrigin.move(adjustedPaintOffset.x(), adjustedPaintOffset.y()); 123 boxOrigin.move(adjustedPaintOffset.x(), adjustedPaintOffset.y());
124 LayoutRect boxRect(boxOrigin, LayoutSize(m_inlineTextBox.logicalWidth(), m_i nlineTextBox.logicalHeight())); 124 LayoutRect boxRect(boxOrigin, LayoutSize(m_inlineTextBox.logicalWidth(), m_i nlineTextBox.logicalHeight()));
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 731
732 GraphicsContext& context = paintInfo.context; 732 GraphicsContext& context = paintInfo.context;
733 GraphicsContextStateSaver stateSaver(context); 733 GraphicsContextStateSaver stateSaver(context);
734 734
735 LayoutPoint localOrigin(boxOrigin); 735 LayoutPoint localOrigin(boxOrigin);
736 736
737 LayoutUnit width = m_inlineTextBox.logicalWidth(); 737 LayoutUnit width = m_inlineTextBox.logicalWidth();
738 if (m_inlineTextBox.truncation() != cNoTruncation) { 738 if (m_inlineTextBox.truncation() != cNoTruncation) {
739 width = m_inlineTextBox.lineLayoutItem().width(m_inlineTextBox.start(), m_inlineTextBox.truncation(), m_inlineTextBox.textPos(), m_inlineTextBox.isLeftT oRightDirection() ? LTR : RTL, m_inlineTextBox.isFirstLineStyle()); 739 width = m_inlineTextBox.lineLayoutItem().width(m_inlineTextBox.start(), m_inlineTextBox.truncation(), m_inlineTextBox.textPos(), m_inlineTextBox.isLeftT oRightDirection() ? LTR : RTL, m_inlineTextBox.isFirstLineStyle());
740 if (!m_inlineTextBox.isLeftToRightDirection()) 740 if (!m_inlineTextBox.isLeftToRightDirection())
741 localOrigin.move(m_inlineTextBox.logicalWidth() - width, 0); 741 localOrigin.move(m_inlineTextBox.logicalWidth() - width, LayoutUnit( ));
742 } 742 }
743 743
744 // Get the text decoration colors. 744 // Get the text decoration colors.
745 LayoutObject::AppliedTextDecoration underline, overline, linethrough; 745 LayoutObject::AppliedTextDecoration underline, overline, linethrough;
746 LayoutObject& textBoxLayoutObject = *LineLayoutAPIShim::layoutObjectFrom(m_i nlineTextBox.lineLayoutItem()); 746 LayoutObject& textBoxLayoutObject = *LineLayoutAPIShim::layoutObjectFrom(m_i nlineTextBox.lineLayoutItem());
747 textBoxLayoutObject.getTextDecorations(deco, underline, overline, linethroug h, true); 747 textBoxLayoutObject.getTextDecorations(deco, underline, overline, linethroug h, true);
748 if (m_inlineTextBox.isFirstLineStyle()) 748 if (m_inlineTextBox.isFirstLineStyle())
749 textBoxLayoutObject.getTextDecorations(deco, underline, overline, lineth rough, true, true); 749 textBoxLayoutObject.getTextDecorations(deco, underline, overline, lineth rough, true, true);
750 750
751 // Use a special function for underlines to get the positioning exactly righ t. 751 // Use a special function for underlines to get the positioning exactly righ t.
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 867
868 Color color = LayoutTheme::theme().platformTextSearchHighlightColor(marker-> activeMatch()); 868 Color color = LayoutTheme::theme().platformTextSearchHighlightColor(marker-> activeMatch());
869 GraphicsContext& context = paintInfo.context; 869 GraphicsContext& context = paintInfo.context;
870 GraphicsContextStateSaver stateSaver(context); 870 GraphicsContextStateSaver stateSaver(context);
871 context.clip(FloatRect(boxOrigin.x().toFloat(), (boxOrigin.y() - deltaY).toF loat(), m_inlineTextBox.logicalWidth().toFloat(), selHeight)); 871 context.clip(FloatRect(boxOrigin.x().toFloat(), (boxOrigin.y() - deltaY).toF loat(), m_inlineTextBox.logicalWidth().toFloat(), selHeight));
872 context.drawHighlightForText(font, run, FloatPoint(boxOrigin.x().toFloat(), (boxOrigin.y() - deltaY).toFloat()), selHeight, color, sPos, ePos); 872 context.drawHighlightForText(font, run, FloatPoint(boxOrigin.x().toFloat(), (boxOrigin.y() - deltaY).toFloat()), selHeight, color, sPos, ePos);
873 } 873 }
874 874
875 875
876 } // namespace blink 876 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/line/InlineFlowBox.h ('k') | third_party/WebKit/Source/core/style/ComputedStyle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698