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

Side by Side Diff: Source/core/rendering/EllipsisBox.cpp

Issue 20061003: Move isValid/isCurrentColor from Color to StyleColor (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 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
OLDNEW
1 /** 1 /**
2 * Copyright (C) 2003, 2006 Apple Computer, Inc. 2 * Copyright (C) 2003, 2006 Apple Computer, Inc.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 30 matching lines...) Expand all
41 if (styleTextColor != context->fillColor()) 41 if (styleTextColor != context->fillColor())
42 context->setFillColor(styleTextColor); 42 context->setFillColor(styleTextColor);
43 43
44 Color textColor = styleTextColor; 44 Color textColor = styleTextColor;
45 const Font& font = style->font(); 45 const Font& font = style->font();
46 if (selectionState() != RenderObject::SelectionNone) { 46 if (selectionState() != RenderObject::SelectionNone) {
47 paintSelection(context, paintOffset, style, font); 47 paintSelection(context, paintOffset, style, font);
48 48
49 // Select the correct color for painting the text. 49 // Select the correct color for painting the text.
50 Color foreground = paintInfo.forceBlackText() ? Color::black : renderer( )->selectionForegroundColor(); 50 Color foreground = paintInfo.forceBlackText() ? Color::black : renderer( )->selectionForegroundColor();
51 if (foreground.isValid() && foreground != styleTextColor) 51 if (foreground != Color::transparent && foreground != styleTextColor)
52 context->setFillColor(foreground); 52 context->setFillColor(foreground);
53 } 53 }
54 54
55 // Text shadows are disabled when printing. http://crbug.com/258321 55 // Text shadows are disabled when printing. http://crbug.com/258321
56 const ShadowData* shadow = context->printing() ? 0 : style->textShadow(); 56 const ShadowData* shadow = context->printing() ? 0 : style->textShadow();
57 bool hasShadow = shadow; 57 bool hasShadow = shadow;
58 if (hasShadow) { 58 if (hasShadow) {
59 DrawLooper drawLooper; 59 DrawLooper drawLooper;
60 do { 60 do {
61 int shadowX = isHorizontal() ? shadow->x() : shadow->y(); 61 int shadowX = isHorizontal() ? shadow->x() : shadow->y();
62 int shadowY = isHorizontal() ? shadow->y() : -shadow->x(); 62 int shadowY = isHorizontal() ? shadow->y() : -shadow->x();
63 FloatSize offset(shadowX, shadowY); 63 FloatSize offset(shadowX, shadowY);
64 drawLooper.addShadow(offset, shadow->blur(), m_renderer->resolveColo r(shadow->color()), 64 drawLooper.addShadow(offset, shadow->blur(),
65 m_renderer->resolveColor(shadow->color(), Color::stdShadowColor) ,
65 DrawLooper::ShadowRespectsTransforms, DrawLooper::ShadowIgnoresA lpha); 66 DrawLooper::ShadowRespectsTransforms, DrawLooper::ShadowIgnoresA lpha);
66 } while ((shadow = shadow->next())); 67 } while ((shadow = shadow->next()));
67 drawLooper.addUnmodifiedContent(); 68 drawLooper.addUnmodifiedContent();
68 context->setDrawLooper(drawLooper); 69 context->setDrawLooper(drawLooper);
69 } 70 }
70 71
71 // FIXME: Why is this always LTR? Fix by passing correct text run flags belo w. 72 // FIXME: Why is this always LTR? Fix by passing correct text run flags belo w.
72 FloatPoint boxOrigin(paintOffset); 73 FloatPoint boxOrigin(paintOffset);
73 boxOrigin.move(x(), y()); 74 boxOrigin.move(x(), y());
74 FloatRect boxRect(boxOrigin, LayoutSize(logicalWidth(), logicalHeight())); 75 FloatRect boxRect(boxOrigin, LayoutSize(logicalWidth(), logicalHeight()));
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 RenderStyle* style = m_renderer->style(isFirstLineStyle()); 125 RenderStyle* style = m_renderer->style(isFirstLineStyle());
125 const Font& font = style->font(); 126 const Font& font = style->font();
126 // FIXME: Why is this always LTR? Fix by passing correct text run flags belo w. 127 // FIXME: Why is this always LTR? Fix by passing correct text run flags belo w.
127 return enclosingIntRect(font.selectionRectForText(RenderBlock::constructText Run(renderer(), font, m_str, style, TextRun::AllowTrailingExpansion), IntPoint(x (), y() + root()->selectionTopAdjustedForPrecedingBlock()), root()->selectionHei ghtAdjustedForPrecedingBlock())); 128 return enclosingIntRect(font.selectionRectForText(RenderBlock::constructText Run(renderer(), font, m_str, style, TextRun::AllowTrailingExpansion), IntPoint(x (), y() + root()->selectionTopAdjustedForPrecedingBlock()), root()->selectionHei ghtAdjustedForPrecedingBlock()));
128 } 129 }
129 130
130 void EllipsisBox::paintSelection(GraphicsContext* context, const LayoutPoint& pa intOffset, RenderStyle* style, const Font& font) 131 void EllipsisBox::paintSelection(GraphicsContext* context, const LayoutPoint& pa intOffset, RenderStyle* style, const Font& font)
131 { 132 {
132 Color textColor = m_renderer->resolveColor(style, CSSPropertyColor); 133 Color textColor = m_renderer->resolveColor(style, CSSPropertyColor);
133 Color c = m_renderer->selectionBackgroundColor(); 134 Color c = m_renderer->selectionBackgroundColor();
134 if (!c.isValid() || !c.alpha()) 135 if (!c.alpha())
135 return; 136 return;
136 137
137 // If the text color ends up being the same as the selection background, inv ert the selection 138 // If the text color ends up being the same as the selection background, inv ert the selection
138 // background. 139 // background.
139 if (textColor == c) 140 if (textColor == c)
140 c = Color(0xff - c.red(), 0xff - c.green(), 0xff - c.blue()); 141 c = Color(0xff - c.red(), 0xff - c.green(), 0xff - c.blue());
141 142
142 GraphicsContextStateSaver stateSaver(*context); 143 GraphicsContextStateSaver stateSaver(*context);
143 LayoutUnit top = root()->selectionTop(); 144 LayoutUnit top = root()->selectionTop();
144 LayoutUnit h = root()->selectionHeight(); 145 LayoutUnit h = root()->selectionHeight();
(...skipping 23 matching lines...) Expand all
168 if (visibleToHitTestRequest(request) && boundsRect.intersects(HitTestLocatio n::rectForPoint(locationInContainer.point(), 0, 0, 0, 0))) { 169 if (visibleToHitTestRequest(request) && boundsRect.intersects(HitTestLocatio n::rectForPoint(locationInContainer.point(), 0, 0, 0, 0))) {
169 renderer()->updateHitTestResult(result, locationInContainer.point() - to LayoutSize(adjustedLocation)); 170 renderer()->updateHitTestResult(result, locationInContainer.point() - to LayoutSize(adjustedLocation));
170 if (!result.addNodeToRectBasedTestResult(renderer()->node(), request, lo cationInContainer, boundsRect)) 171 if (!result.addNodeToRectBasedTestResult(renderer()->node(), request, lo cationInContainer, boundsRect))
171 return true; 172 return true;
172 } 173 }
173 174
174 return false; 175 return false;
175 } 176 }
176 177
177 } // namespace WebCore 178 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698