|
1 /** |
|
2 * This file is part of the html renderer for KDE. |
|
3 * |
|
4 * Copyright (C) 2003, 2006 Apple Computer, Inc. |
|
5 * |
|
6 * This library is free software; you can redistribute it and/or |
|
7 * modify it under the terms of the GNU Library General Public |
|
8 * License as published by the Free Software Foundation; either |
|
9 * version 2 of the License, or (at your option) any later version. |
|
10 * |
|
11 * This library is distributed in the hope that it will be useful, |
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 * Library General Public License for more details. |
|
15 * |
|
16 * You should have received a copy of the GNU Library General Public License |
|
17 * along with this library; see the file COPYING.LIB. If not, write to |
|
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
|
19 * Boston, MA 02110-1301, USA. |
|
20 */ |
|
21 |
|
22 #include "config.h" |
|
23 #include "EllipsisBox.h" |
|
24 |
|
25 #include "Document.h" |
|
26 #include "GraphicsContext.h" |
|
27 #include "HitTestResult.h" |
|
28 #include "TextStyle.h" |
|
29 |
|
30 namespace WebCore { |
|
31 |
|
32 void EllipsisBox::paint(RenderObject::PaintInfo& paintInfo, int tx, int ty) |
|
33 { |
|
34 GraphicsContext* context = paintInfo.context; |
|
35 RenderStyle* style = m_object->style(m_firstLine); |
|
36 if (style->font() != context->font()) |
|
37 context->setFont(style->font()); |
|
38 |
|
39 Color textColor = style->color(); |
|
40 if (textColor != context->fillColor()) |
|
41 context->setFillColor(textColor); |
|
42 bool setShadow = false; |
|
43 if (style->textShadow()) { |
|
44 context->setShadow(IntSize(style->textShadow()->x, style->textShadow()->y), |
|
45 style->textShadow()->blur, style->textShadow()->color); |
|
46 setShadow = true; |
|
47 } |
|
48 |
|
49 const String& str = m_str; |
|
50 TextStyle textStyle(0, 0, 0, false, style->visuallyOrdered()); |
|
51 context->drawText(TextRun(str.characters(), str.length()), IntPoint(m_x + tx, m_y + ty + m_baseline), textStyle); |
|
52 |
|
53 if (setShadow) |
|
54 context->clearShadow(); |
|
55 |
|
56 if (m_markupBox) { |
|
57 // Paint the markup box |
|
58 tx += m_x + m_width - m_markupBox->xPos(); |
|
59 ty += m_y + m_baseline - (m_markupBox->yPos() + m_markupBox->baseline()); |
|
60 m_markupBox->paint(paintInfo, tx, ty); |
|
61 } |
|
62 } |
|
63 |
|
64 bool EllipsisBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, int x, int y, int tx, int ty) |
|
65 { |
|
66 tx += m_x; |
|
67 ty += m_y; |
|
68 |
|
69 // Hit test the markup box. |
|
70 if (m_markupBox) { |
|
71 int mtx = tx + m_width - m_markupBox->xPos(); |
|
72 int mty = ty + m_baseline - (m_markupBox->yPos() + m_markupBox->baseline()); |
|
73 if (m_markupBox->nodeAtPoint(request, result, x, y, mtx, mty)) { |
|
74 object()->updateHitTestResult(result, IntPoint(x - mtx, y - mty)); |
|
75 return true; |
|
76 } |
|
77 } |
|
78 |
|
79 if (object()->style()->visibility() == VISIBLE && IntRect(tx, ty, m_width, m_height).contains(x, y)) { |
|
80 object()->updateHitTestResult(result, IntPoint(x - tx, y - ty)); |
|
81 return true; |
|
82 } |
|
83 |
|
84 return false; |
|
85 } |
|
86 |
|
87 } // namespace WebCore |