2008-11-04 Anders Carlsson <andersca@apple.com>
[webkit/qt.git] / WebCore / rendering / EllipsisBox.cpp
blob7f563d5ac344733d2bfc0f8546a9eb654b2c5ddd
1 /**
2 * This file is part of the html renderer for KDE.
4 * Copyright (C) 2003, 2006 Apple Computer, Inc.
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.
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.
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.
22 #include "config.h"
23 #include "EllipsisBox.h"
25 #include "Document.h"
26 #include "GraphicsContext.h"
27 #include "HitTestResult.h"
29 namespace WebCore {
31 void EllipsisBox::paint(RenderObject::PaintInfo& paintInfo, int tx, int ty)
33 GraphicsContext* context = paintInfo.context;
34 RenderStyle* style = m_object->style(m_firstLine);
35 if (style->font() != context->font())
36 context->setFont(style->font());
38 Color textColor = style->color();
39 if (textColor != context->fillColor())
40 context->setFillColor(textColor);
41 bool setShadow = false;
42 if (style->textShadow()) {
43 context->setShadow(IntSize(style->textShadow()->x, style->textShadow()->y),
44 style->textShadow()->blur, style->textShadow()->color);
45 setShadow = true;
48 const String& str = m_str;
49 context->drawText(TextRun(str.characters(), str.length(), false, 0, 0, false, style->visuallyOrdered()), IntPoint(m_x + tx, m_y + ty + m_baseline));
51 if (setShadow)
52 context->clearShadow();
54 if (m_markupBox) {
55 // Paint the markup box
56 tx += m_x + m_width - m_markupBox->xPos();
57 ty += m_y + m_baseline - (m_markupBox->yPos() + m_markupBox->baseline());
58 m_markupBox->paint(paintInfo, tx, ty);
62 bool EllipsisBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, int x, int y, int tx, int ty)
64 tx += m_x;
65 ty += m_y;
67 // Hit test the markup box.
68 if (m_markupBox) {
69 int mtx = tx + m_width - m_markupBox->xPos();
70 int mty = ty + m_baseline - (m_markupBox->yPos() + m_markupBox->baseline());
71 if (m_markupBox->nodeAtPoint(request, result, x, y, mtx, mty)) {
72 object()->updateHitTestResult(result, IntPoint(x - mtx, y - mty));
73 return true;
77 if (object()->style()->visibility() == VISIBLE && IntRect(tx, ty, m_width, m_height).contains(x, y)) {
78 object()->updateHitTestResult(result, IntPoint(x - tx, y - ty));
79 return true;
82 return false;
85 } // namespace WebCore