| 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 21 matching lines...) Expand all Loading... |
| 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 = style->visitedDependentColor(CSSPropertyWebkitTextFil
lColor); |
| 41 if (styleTextColor != context->fillColor()) | 41 if (styleTextColor != context->fillColor()) |
| 42 context->setFillColor(styleTextColor, style->colorSpace()); | 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, style->colorSpace()); | 52 context->setFillColor(foreground); |
| 53 } | 53 } |
| 54 | 54 |
| 55 const ShadowData* shadow = style->textShadow(); | 55 const ShadowData* shadow = style->textShadow(); |
| 56 bool hasShadow = shadow; | 56 bool hasShadow = shadow; |
| 57 if (hasShadow) { | 57 if (hasShadow) { |
| 58 DrawLooper drawLooper; | 58 DrawLooper drawLooper; |
| 59 do { | 59 do { |
| 60 int shadowX = isHorizontal() ? shadow->x() : shadow->y(); | 60 int shadowX = isHorizontal() ? shadow->x() : shadow->y(); |
| 61 int shadowY = isHorizontal() ? shadow->y() : -shadow->x(); | 61 int shadowY = isHorizontal() ? shadow->y() : -shadow->x(); |
| 62 FloatSize offset(shadowX, shadowY); | 62 FloatSize offset(shadowX, shadowY); |
| 63 drawLooper.addShadow(offset, shadow->blur(), shadow->color(), | 63 drawLooper.addShadow(offset, shadow->blur(), shadow->color(), |
| 64 DrawLooper::ShadowRespectsTransforms, DrawLooper::ShadowIgnoresA
lpha); | 64 DrawLooper::ShadowRespectsTransforms, DrawLooper::ShadowIgnoresA
lpha); |
| 65 } while ((shadow = shadow->next())); | 65 } while ((shadow = shadow->next())); |
| 66 drawLooper.addUnmodifiedContent(); | 66 drawLooper.addUnmodifiedContent(); |
| 67 context->setDrawLooper(drawLooper); | 67 context->setDrawLooper(drawLooper); |
| 68 } | 68 } |
| 69 | 69 |
| 70 // FIXME: Why is this always LTR? Fix by passing correct text run flags belo
w. | 70 // FIXME: Why is this always LTR? Fix by passing correct text run flags belo
w. |
| 71 FloatPoint boxOrigin(paintOffset); | 71 FloatPoint boxOrigin(paintOffset); |
| 72 boxOrigin.move(x(), y()); | 72 boxOrigin.move(x(), y()); |
| 73 FloatRect boxRect(boxOrigin, LayoutSize(logicalWidth(), logicalHeight())); | 73 FloatRect boxRect(boxOrigin, LayoutSize(logicalWidth(), logicalHeight())); |
| 74 FloatPoint textOrigin(boxOrigin.x(), boxOrigin.y() + style->fontMetrics().as
cent()); | 74 FloatPoint textOrigin(boxOrigin.x(), boxOrigin.y() + style->fontMetrics().as
cent()); |
| 75 TextRun textRun = RenderBlock::constructTextRun(renderer(), font, m_str, sty
le, TextRun::AllowTrailingExpansion); | 75 TextRun textRun = RenderBlock::constructTextRun(renderer(), font, m_str, sty
le, TextRun::AllowTrailingExpansion); |
| 76 TextRunPaintInfo textRunPaintInfo(textRun); | 76 TextRunPaintInfo textRunPaintInfo(textRun); |
| 77 textRunPaintInfo.bounds = boxRect; | 77 textRunPaintInfo.bounds = boxRect; |
| 78 context->drawText(font, textRunPaintInfo, textOrigin); | 78 context->drawText(font, textRunPaintInfo, textOrigin); |
| 79 | 79 |
| 80 // Restore the regular fill color. | 80 // Restore the regular fill color. |
| 81 if (styleTextColor != context->fillColor()) | 81 if (styleTextColor != context->fillColor()) |
| 82 context->setFillColor(styleTextColor, style->colorSpace()); | 82 context->setFillColor(styleTextColor); |
| 83 | 83 |
| 84 if (hasShadow) | 84 if (hasShadow) |
| 85 context->clearDrawLooper(); | 85 context->clearDrawLooper(); |
| 86 | 86 |
| 87 paintMarkupBox(paintInfo, paintOffset, lineTop, lineBottom, style); | 87 paintMarkupBox(paintInfo, paintOffset, lineTop, lineBottom, style); |
| 88 } | 88 } |
| 89 | 89 |
| 90 InlineBox* EllipsisBox::markupBox() const | 90 InlineBox* EllipsisBox::markupBox() const |
| 91 { | 91 { |
| 92 if (!m_shouldPaintMarkupBox || !m_renderer->isRenderBlock()) | 92 if (!m_shouldPaintMarkupBox || !m_renderer->isRenderBlock()) |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 if (textColor == c) | 138 if (textColor == c) |
| 139 c = Color(0xff - c.red(), 0xff - c.green(), 0xff - c.blue()); | 139 c = Color(0xff - c.red(), 0xff - c.green(), 0xff - c.blue()); |
| 140 | 140 |
| 141 GraphicsContextStateSaver stateSaver(*context); | 141 GraphicsContextStateSaver stateSaver(*context); |
| 142 LayoutUnit top = root()->selectionTop(); | 142 LayoutUnit top = root()->selectionTop(); |
| 143 LayoutUnit h = root()->selectionHeight(); | 143 LayoutUnit h = root()->selectionHeight(); |
| 144 FloatRect clipRect(x() + paintOffset.x(), top + paintOffset.y(), m_logicalWi
dth, h); | 144 FloatRect clipRect(x() + paintOffset.x(), top + paintOffset.y(), m_logicalWi
dth, h); |
| 145 alignSelectionRectToDevicePixels(clipRect); | 145 alignSelectionRectToDevicePixels(clipRect); |
| 146 context->clip(clipRect); | 146 context->clip(clipRect); |
| 147 // FIXME: Why is this always LTR? Fix by passing correct text run flags belo
w. | 147 // FIXME: Why is this always LTR? Fix by passing correct text run flags belo
w. |
| 148 context->drawHighlightForText(font, RenderBlock::constructTextRun(renderer()
, font, m_str, style, TextRun::AllowTrailingExpansion), roundedIntPoint(LayoutPo
int(x() + paintOffset.x(), y() + paintOffset.y() + top)), h, c, style->colorSpac
e()); | 148 context->drawHighlightForText(font, RenderBlock::constructTextRun(renderer()
, font, m_str, style, TextRun::AllowTrailingExpansion), roundedIntPoint(LayoutPo
int(x() + paintOffset.x(), y() + paintOffset.y() + top)), h, c); |
| 149 } | 149 } |
| 150 | 150 |
| 151 bool EllipsisBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& resu
lt, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOf
fset, LayoutUnit lineTop, LayoutUnit lineBottom) | 151 bool EllipsisBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& resu
lt, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOf
fset, LayoutUnit lineTop, LayoutUnit lineBottom) |
| 152 { | 152 { |
| 153 LayoutPoint adjustedLocation = accumulatedOffset + roundedLayoutPoint(topLef
t()); | 153 LayoutPoint adjustedLocation = accumulatedOffset + roundedLayoutPoint(topLef
t()); |
| 154 | 154 |
| 155 // Hit test the markup box. | 155 // Hit test the markup box. |
| 156 if (InlineBox* markupBox = this->markupBox()) { | 156 if (InlineBox* markupBox = this->markupBox()) { |
| 157 RenderStyle* style = m_renderer->style(isFirstLineStyle()); | 157 RenderStyle* style = m_renderer->style(isFirstLineStyle()); |
| 158 LayoutUnit mtx = adjustedLocation.x() + m_logicalWidth - markupBox->x(); | 158 LayoutUnit mtx = adjustedLocation.x() + m_logicalWidth - markupBox->x(); |
| 159 LayoutUnit mty = adjustedLocation.y() + style->fontMetrics().ascent() -
(markupBox->y() + markupBox->renderer()->style(isFirstLineStyle())->fontMetrics(
).ascent()); | 159 LayoutUnit mty = adjustedLocation.y() + style->fontMetrics().ascent() -
(markupBox->y() + markupBox->renderer()->style(isFirstLineStyle())->fontMetrics(
).ascent()); |
| 160 if (markupBox->nodeAtPoint(request, result, locationInContainer, LayoutP
oint(mtx, mty), lineTop, lineBottom)) { | 160 if (markupBox->nodeAtPoint(request, result, locationInContainer, LayoutP
oint(mtx, mty), lineTop, lineBottom)) { |
| 161 renderer()->updateHitTestResult(result, locationInContainer.point()
- LayoutSize(mtx, mty)); | 161 renderer()->updateHitTestResult(result, locationInContainer.point()
- LayoutSize(mtx, mty)); |
| 162 return true; | 162 return true; |
| 163 } | 163 } |
| 164 } | 164 } |
| 165 | 165 |
| 166 LayoutRect boundsRect(adjustedLocation, LayoutSize(m_logicalWidth, m_height)
); | 166 LayoutRect boundsRect(adjustedLocation, LayoutSize(m_logicalWidth, m_height)
); |
| 167 if (visibleToHitTestRequest(request) && boundsRect.intersects(HitTestLocatio
n::rectForPoint(locationInContainer.point(), 0, 0, 0, 0))) { | 167 if (visibleToHitTestRequest(request) && boundsRect.intersects(HitTestLocatio
n::rectForPoint(locationInContainer.point(), 0, 0, 0, 0))) { |
| 168 renderer()->updateHitTestResult(result, locationInContainer.point() - to
LayoutSize(adjustedLocation)); | 168 renderer()->updateHitTestResult(result, locationInContainer.point() - to
LayoutSize(adjustedLocation)); |
| 169 if (!result.addNodeToRectBasedTestResult(renderer()->node(), request, lo
cationInContainer, boundsRect)) | 169 if (!result.addNodeToRectBasedTestResult(renderer()->node(), request, lo
cationInContainer, boundsRect)) |
| 170 return true; | 170 return true; |
| 171 } | 171 } |
| 172 | 172 |
| 173 return false; | 173 return false; |
| 174 } | 174 } |
| 175 | 175 |
| 176 } // namespace WebCore | 176 } // namespace WebCore |
| OLD | NEW |