| OLD | NEW |
| 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 Loading... |
| 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 != Color::transparent && foreground != styleTextColor) | 51 if (foreground.isValid() && 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(), | 64 drawLooper.addShadow(offset, shadow->blur(), m_renderer->resolveColo
r(shadow->color()), |
| 65 m_renderer->resolveColor(shadow->color(), Color::stdShadowColor)
, | |
| 66 DrawLooper::ShadowRespectsTransforms, DrawLooper::ShadowIgnoresA
lpha); | 65 DrawLooper::ShadowRespectsTransforms, DrawLooper::ShadowIgnoresA
lpha); |
| 67 } while ((shadow = shadow->next())); | 66 } while ((shadow = shadow->next())); |
| 68 drawLooper.addUnmodifiedContent(); | 67 drawLooper.addUnmodifiedContent(); |
| 69 context->setDrawLooper(drawLooper); | 68 context->setDrawLooper(drawLooper); |
| 70 } | 69 } |
| 71 | 70 |
| 72 // FIXME: Why is this always LTR? Fix by passing correct text run flags belo
w. | 71 // FIXME: Why is this always LTR? Fix by passing correct text run flags belo
w. |
| 73 FloatPoint boxOrigin(paintOffset); | 72 FloatPoint boxOrigin(paintOffset); |
| 74 boxOrigin.move(x(), y()); | 73 boxOrigin.move(x(), y()); |
| 75 FloatRect boxRect(boxOrigin, LayoutSize(logicalWidth(), logicalHeight())); | 74 FloatRect boxRect(boxOrigin, LayoutSize(logicalWidth(), logicalHeight())); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 RenderStyle* style = m_renderer->style(isFirstLineStyle()); | 124 RenderStyle* style = m_renderer->style(isFirstLineStyle()); |
| 126 const Font& font = style->font(); | 125 const Font& font = style->font(); |
| 127 // FIXME: Why is this always LTR? Fix by passing correct text run flags belo
w. | 126 // FIXME: Why is this always LTR? Fix by passing correct text run flags belo
w. |
| 128 return enclosingIntRect(font.selectionRectForText(RenderBlock::constructText
Run(renderer(), font, m_str, style, TextRun::AllowTrailingExpansion), IntPoint(x
(), y() + root()->selectionTopAdjustedForPrecedingBlock()), root()->selectionHei
ghtAdjustedForPrecedingBlock())); | 127 return enclosingIntRect(font.selectionRectForText(RenderBlock::constructText
Run(renderer(), font, m_str, style, TextRun::AllowTrailingExpansion), IntPoint(x
(), y() + root()->selectionTopAdjustedForPrecedingBlock()), root()->selectionHei
ghtAdjustedForPrecedingBlock())); |
| 129 } | 128 } |
| 130 | 129 |
| 131 void EllipsisBox::paintSelection(GraphicsContext* context, const LayoutPoint& pa
intOffset, RenderStyle* style, const Font& font) | 130 void EllipsisBox::paintSelection(GraphicsContext* context, const LayoutPoint& pa
intOffset, RenderStyle* style, const Font& font) |
| 132 { | 131 { |
| 133 Color textColor = m_renderer->resolveColor(style, CSSPropertyColor); | 132 Color textColor = m_renderer->resolveColor(style, CSSPropertyColor); |
| 134 Color c = m_renderer->selectionBackgroundColor(); | 133 Color c = m_renderer->selectionBackgroundColor(); |
| 135 if (!c.alpha()) | 134 if (!c.isValid() || !c.alpha()) |
| 136 return; | 135 return; |
| 137 | 136 |
| 138 // If the text color ends up being the same as the selection background, inv
ert the selection | 137 // If the text color ends up being the same as the selection background, inv
ert the selection |
| 139 // background. | 138 // background. |
| 140 if (textColor == c) | 139 if (textColor == c) |
| 141 c = Color(0xff - c.red(), 0xff - c.green(), 0xff - c.blue()); | 140 c = Color(0xff - c.red(), 0xff - c.green(), 0xff - c.blue()); |
| 142 | 141 |
| 143 GraphicsContextStateSaver stateSaver(*context); | 142 GraphicsContextStateSaver stateSaver(*context); |
| 144 LayoutUnit top = root()->selectionTop(); | 143 LayoutUnit top = root()->selectionTop(); |
| 145 LayoutUnit h = root()->selectionHeight(); | 144 LayoutUnit h = root()->selectionHeight(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 169 if (visibleToHitTestRequest(request) && boundsRect.intersects(HitTestLocatio
n::rectForPoint(locationInContainer.point(), 0, 0, 0, 0))) { | 168 if (visibleToHitTestRequest(request) && boundsRect.intersects(HitTestLocatio
n::rectForPoint(locationInContainer.point(), 0, 0, 0, 0))) { |
| 170 renderer()->updateHitTestResult(result, locationInContainer.point() - to
LayoutSize(adjustedLocation)); | 169 renderer()->updateHitTestResult(result, locationInContainer.point() - to
LayoutSize(adjustedLocation)); |
| 171 if (!result.addNodeToRectBasedTestResult(renderer()->node(), request, lo
cationInContainer, boundsRect)) | 170 if (!result.addNodeToRectBasedTestResult(renderer()->node(), request, lo
cationInContainer, boundsRect)) |
| 172 return true; | 171 return true; |
| 173 } | 172 } |
| 174 | 173 |
| 175 return false; | 174 return false; |
| 176 } | 175 } |
| 177 | 176 |
| 178 } // namespace WebCore | 177 } // namespace WebCore |
| OLD | NEW |