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

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

Issue 1033943002: Rename LayoutStyle to papayawhip (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: ensureComputedStyle Created 5 years, 8 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/EllipsisBoxPainter.h ('k') | Source/core/paint/ImagePainter.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/EllipsisBoxPainter.h" 6 #include "core/paint/EllipsisBoxPainter.h"
7 7
8 #include "core/layout/PaintInfo.h" 8 #include "core/layout/PaintInfo.h"
9 #include "core/layout/TextRunConstructor.h" 9 #include "core/layout/TextRunConstructor.h"
10 #include "core/layout/line/EllipsisBox.h" 10 #include "core/layout/line/EllipsisBox.h"
11 #include "core/layout/line/RootInlineBox.h" 11 #include "core/layout/line/RootInlineBox.h"
12 #include "core/paint/LayoutObjectDrawingRecorder.h" 12 #include "core/paint/LayoutObjectDrawingRecorder.h"
13 #include "core/paint/TextPainter.h" 13 #include "core/paint/TextPainter.h"
14 #include "platform/graphics/GraphicsContextStateSaver.h" 14 #include "platform/graphics/GraphicsContextStateSaver.h"
15 15
16 namespace blink { 16 namespace blink {
17 17
18 void EllipsisBoxPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset, LayoutUnit lineTop, LayoutUnit lineBottom) 18 void EllipsisBoxPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& pa intOffset, LayoutUnit lineTop, LayoutUnit lineBottom)
19 { 19 {
20 const LayoutStyle& style = m_ellipsisBox.layoutObject().styleRef(m_ellipsisB ox.isFirstLineStyle()); 20 const ComputedStyle& style = m_ellipsisBox.layoutObject().styleRef(m_ellipsi sBox.isFirstLineStyle());
21 paintEllipsis(paintInfo, paintOffset, lineTop, lineBottom, style); 21 paintEllipsis(paintInfo, paintOffset, lineTop, lineBottom, style);
22 paintMarkupBox(paintInfo, paintOffset, lineTop, lineBottom, style); 22 paintMarkupBox(paintInfo, paintOffset, lineTop, lineBottom, style);
23 } 23 }
24 24
25 void EllipsisBoxPainter::paintEllipsis(const PaintInfo& paintInfo, const LayoutP oint& paintOffset, LayoutUnit lineTop, LayoutUnit lineBottom, const LayoutStyle& style) 25 void EllipsisBoxPainter::paintEllipsis(const PaintInfo& paintInfo, const LayoutP oint& paintOffset, LayoutUnit lineTop, LayoutUnit lineBottom, const ComputedStyl e& style)
26 { 26 {
27 GraphicsContext* context = paintInfo.context; 27 GraphicsContext* context = paintInfo.context;
28 FloatPoint boxOrigin = m_ellipsisBox.locationIncludingFlipping().toFloatPoin t(); 28 FloatPoint boxOrigin = m_ellipsisBox.locationIncludingFlipping().toFloatPoin t();
29 boxOrigin.moveBy(FloatPoint(paintOffset)); 29 boxOrigin.moveBy(FloatPoint(paintOffset));
30 FloatRect boxRect(boxOrigin, FloatSize(m_ellipsisBox.logicalWidth(), m_ellip sisBox.virtualLogicalHeight())); 30 FloatRect boxRect(boxOrigin, FloatSize(m_ellipsisBox.logicalWidth(), m_ellip sisBox.virtualLogicalHeight()));
31 31
32 DrawingRecorder recorder(context, m_ellipsisBox, DisplayItem::paintPhaseToDr awingType(paintInfo.phase), boxRect); 32 DrawingRecorder recorder(context, m_ellipsisBox, DisplayItem::paintPhaseToDr awingType(paintInfo.phase), boxRect);
33 if (recorder.canUseCachedDrawing()) 33 if (recorder.canUseCachedDrawing())
34 return; 34 return;
35 35
(...skipping 13 matching lines...) Expand all
49 49
50 TextPainter::Style textStyle = TextPainter::textPaintingStyle(m_ellipsisBox. layoutObject(), style, paintInfo.forceBlackText(), isPrinting); 50 TextPainter::Style textStyle = TextPainter::textPaintingStyle(m_ellipsisBox. layoutObject(), style, paintInfo.forceBlackText(), isPrinting);
51 if (haveSelection) 51 if (haveSelection)
52 textStyle = TextPainter::selectionPaintingStyle(m_ellipsisBox.layoutObje ct(), true, paintInfo.forceBlackText(), isPrinting, textStyle); 52 textStyle = TextPainter::selectionPaintingStyle(m_ellipsisBox.layoutObje ct(), true, paintInfo.forceBlackText(), isPrinting, textStyle);
53 53
54 TextRun textRun = constructTextRun(&m_ellipsisBox.layoutObject(), font, m_el lipsisBox.ellipsisStr(), style, TextRun::AllowTrailingExpansion); 54 TextRun textRun = constructTextRun(&m_ellipsisBox.layoutObject(), font, m_el lipsisBox.ellipsisStr(), style, TextRun::AllowTrailingExpansion);
55 TextPainter textPainter(context, font, textRun, textOrigin, boxRect, m_ellip sisBox.isHorizontal()); 55 TextPainter textPainter(context, font, textRun, textOrigin, boxRect, m_ellip sisBox.isHorizontal());
56 textPainter.paint(0, m_ellipsisBox.ellipsisStr().length(), m_ellipsisBox.ell ipsisStr().length(), textStyle); 56 textPainter.paint(0, m_ellipsisBox.ellipsisStr().length(), m_ellipsisBox.ell ipsisStr().length(), textStyle);
57 } 57 }
58 58
59 void EllipsisBoxPainter::paintMarkupBox(const PaintInfo& paintInfo, const Layout Point& paintOffset, LayoutUnit lineTop, LayoutUnit lineBottom, const LayoutStyle & style) 59 void EllipsisBoxPainter::paintMarkupBox(const PaintInfo& paintInfo, const Layout Point& paintOffset, LayoutUnit lineTop, LayoutUnit lineBottom, const ComputedSty le& style)
60 { 60 {
61 InlineBox* markupBox = m_ellipsisBox.markupBox(); 61 InlineBox* markupBox = m_ellipsisBox.markupBox();
62 if (!markupBox) 62 if (!markupBox)
63 return; 63 return;
64 64
65 LayoutPoint adjustedPaintOffset = paintOffset; 65 LayoutPoint adjustedPaintOffset = paintOffset;
66 adjustedPaintOffset.move(m_ellipsisBox.x() + m_ellipsisBox.logicalWidth() - markupBox->x(), 66 adjustedPaintOffset.move(m_ellipsisBox.x() + m_ellipsisBox.logicalWidth() - markupBox->x(),
67 m_ellipsisBox.y() + style.fontMetrics().ascent() - (markupBox->y() + mar kupBox->layoutObject().styleRef(m_ellipsisBox.isFirstLineStyle()).fontMetrics(). ascent())); 67 m_ellipsisBox.y() + style.fontMetrics().ascent() - (markupBox->y() + mar kupBox->layoutObject().styleRef(m_ellipsisBox.isFirstLineStyle()).fontMetrics(). ascent()));
68 markupBox->paint(paintInfo, adjustedPaintOffset, lineTop, lineBottom); 68 markupBox->paint(paintInfo, adjustedPaintOffset, lineTop, lineBottom);
69 } 69 }
70 70
71 void EllipsisBoxPainter::paintSelection(GraphicsContext* context, const FloatPoi nt& boxOrigin, const LayoutStyle& style, const Font& font) 71 void EllipsisBoxPainter::paintSelection(GraphicsContext* context, const FloatPoi nt& boxOrigin, const ComputedStyle& style, const Font& font)
72 { 72 {
73 Color textColor = m_ellipsisBox.layoutObject().resolveColor(style, CSSProper tyColor); 73 Color textColor = m_ellipsisBox.layoutObject().resolveColor(style, CSSProper tyColor);
74 Color c = m_ellipsisBox.layoutObject().selectionBackgroundColor(); 74 Color c = m_ellipsisBox.layoutObject().selectionBackgroundColor();
75 if (!c.alpha()) 75 if (!c.alpha())
76 return; 76 return;
77 77
78 // If the text color ends up being the same as the selection background, inv ert the selection 78 // If the text color ends up being the same as the selection background, inv ert the selection
79 // background. 79 // background.
80 if (textColor == c) 80 if (textColor == c)
81 c = Color(0xff - c.red(), 0xff - c.green(), 0xff - c.blue()); 81 c = Color(0xff - c.red(), 0xff - c.green(), 0xff - c.blue());
82 82
83 GraphicsContextStateSaver stateSaver(*context); 83 GraphicsContextStateSaver stateSaver(*context);
84 LayoutUnit selectionBottom = m_ellipsisBox.root().selectionBottom(); 84 LayoutUnit selectionBottom = m_ellipsisBox.root().selectionBottom();
85 LayoutUnit top = m_ellipsisBox.root().selectionTop(); 85 LayoutUnit top = m_ellipsisBox.root().selectionTop();
86 LayoutUnit h = m_ellipsisBox.root().selectionHeight(); 86 LayoutUnit h = m_ellipsisBox.root().selectionHeight();
87 const int deltaY = roundToInt(m_ellipsisBox.layoutObject().styleRef().isFlip pedLinesWritingMode() ? selectionBottom - m_ellipsisBox.logicalBottom() : m_elli psisBox.logicalTop() - top); 87 const int deltaY = roundToInt(m_ellipsisBox.layoutObject().styleRef().isFlip pedLinesWritingMode() ? selectionBottom - m_ellipsisBox.logicalBottom() : m_elli psisBox.logicalTop() - top);
88 const FloatPoint localOrigin(boxOrigin.x(), boxOrigin.y() - deltaY); 88 const FloatPoint localOrigin(boxOrigin.x(), boxOrigin.y() - deltaY);
89 FloatRect clipRect(localOrigin, FloatSize(m_ellipsisBox.logicalWidth(), h.to Float())); 89 FloatRect clipRect(localOrigin, FloatSize(m_ellipsisBox.logicalWidth(), h.to Float()));
90 context->clip(clipRect); 90 context->clip(clipRect);
91 context->drawHighlightForText(font, constructTextRun(&m_ellipsisBox.layoutOb ject(), font, m_ellipsisBox.ellipsisStr(), style, TextRun::AllowTrailingExpansio n), localOrigin, h, c); 91 context->drawHighlightForText(font, constructTextRun(&m_ellipsisBox.layoutOb ject(), font, m_ellipsisBox.ellipsisStr(), style, TextRun::AllowTrailingExpansio n), localOrigin, h, c);
92 } 92 }
93 93
94 } // namespace blink 94 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/paint/EllipsisBoxPainter.h ('k') | Source/core/paint/ImagePainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698