| 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 19 matching lines...) Expand all Loading... |
| 30 #include "core/rendering/RenderBlock.h" | 30 #include "core/rendering/RenderBlock.h" |
| 31 #include "core/rendering/RootInlineBox.h" | 31 #include "core/rendering/RootInlineBox.h" |
| 32 #include "core/rendering/style/ShadowData.h" | 32 #include "core/rendering/style/ShadowData.h" |
| 33 | 33 |
| 34 namespace WebCore { | 34 namespace WebCore { |
| 35 | 35 |
| 36 void EllipsisBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, La
youtUnit lineTop, LayoutUnit lineBottom) | 36 void EllipsisBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, La
youtUnit lineTop, LayoutUnit lineBottom) |
| 37 { | 37 { |
| 38 GraphicsContext* context = paintInfo.context; | 38 GraphicsContext* context = paintInfo.context; |
| 39 RenderStyle* style = m_renderer->style(isFirstLineStyle()); | 39 RenderStyle* style = m_renderer->style(isFirstLineStyle()); |
| 40 Color styleTextColor = style->visitedDependentColor(CSSPropertyWebkitTextFil
lColor); | 40 Color styleTextColor = m_renderer->resolveColor(style, CSSPropertyWebkitText
FillColor); |
| 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.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(), shadow->color(), | 64 drawLooper.addShadow(offset, shadow->blur(), m_renderer->resolveColo
r(shadow->color()), |
| 65 DrawLooper::ShadowRespectsTransforms, DrawLooper::ShadowIgnoresA
lpha); | 65 DrawLooper::ShadowRespectsTransforms, DrawLooper::ShadowIgnoresA
lpha); |
| 66 } while ((shadow = shadow->next())); | 66 } while ((shadow = shadow->next())); |
| 67 drawLooper.addUnmodifiedContent(); | 67 drawLooper.addUnmodifiedContent(); |
| 68 context->setDrawLooper(drawLooper); | 68 context->setDrawLooper(drawLooper); |
| 69 } | 69 } |
| 70 | 70 |
| 71 // 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. |
| 72 FloatPoint boxOrigin(paintOffset); | 72 FloatPoint boxOrigin(paintOffset); |
| 73 boxOrigin.move(x(), y()); | 73 boxOrigin.move(x(), y()); |
| 74 FloatRect boxRect(boxOrigin, LayoutSize(logicalWidth(), logicalHeight())); | 74 FloatRect boxRect(boxOrigin, LayoutSize(logicalWidth(), logicalHeight())); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 IntRect EllipsisBox::selectionRect() | 122 IntRect EllipsisBox::selectionRect() |
| 123 { | 123 { |
| 124 RenderStyle* style = m_renderer->style(isFirstLineStyle()); | 124 RenderStyle* style = m_renderer->style(isFirstLineStyle()); |
| 125 const Font& font = style->font(); | 125 const Font& font = style->font(); |
| 126 // 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. |
| 127 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())); |
| 128 } | 128 } |
| 129 | 129 |
| 130 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) |
| 131 { | 131 { |
| 132 Color textColor = style->visitedDependentColor(CSSPropertyColor); | 132 Color textColor = m_renderer->resolveColor(style, CSSPropertyColor); |
| 133 Color c = m_renderer->selectionBackgroundColor(); | 133 Color c = m_renderer->selectionBackgroundColor(); |
| 134 if (!c.isValid() || !c.alpha()) | 134 if (!c.isValid() || !c.alpha()) |
| 135 return; | 135 return; |
| 136 | 136 |
| 137 // 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 |
| 138 // background. | 138 // background. |
| 139 if (textColor == c) | 139 if (textColor == c) |
| 140 c = Color(0xff - c.red(), 0xff - c.green(), 0xff - c.blue()); | 140 c = Color(0xff - c.red(), 0xff - c.green(), 0xff - c.blue()); |
| 141 | 141 |
| 142 GraphicsContextStateSaver stateSaver(*context); | 142 GraphicsContextStateSaver stateSaver(*context); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 168 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))) { |
| 169 renderer()->updateHitTestResult(result, locationInContainer.point() - to
LayoutSize(adjustedLocation)); | 169 renderer()->updateHitTestResult(result, locationInContainer.point() - to
LayoutSize(adjustedLocation)); |
| 170 if (!result.addNodeToRectBasedTestResult(renderer()->node(), request, lo
cationInContainer, boundsRect)) | 170 if (!result.addNodeToRectBasedTestResult(renderer()->node(), request, lo
cationInContainer, boundsRect)) |
| 171 return true; | 171 return true; |
| 172 } | 172 } |
| 173 | 173 |
| 174 return false; | 174 return false; |
| 175 } | 175 } |
| 176 | 176 |
| 177 } // namespace WebCore | 177 } // namespace WebCore |
| OLD | NEW |