• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
29 namespace WebCore {
30 
paint(RenderObject::PaintInfo & paintInfo,int tx,int ty)31 void EllipsisBox::paint(RenderObject::PaintInfo& paintInfo, int tx, int ty)
32 {
33     GraphicsContext* context = paintInfo.context;
34     RenderStyle* style = m_renderer->style(m_firstLine);
35     Color textColor = style->color();
36     if (textColor != context->fillColor())
37         context->setFillColor(textColor);
38     bool setShadow = false;
39     if (style->textShadow()) {
40         context->setShadow(IntSize(style->textShadow()->x, style->textShadow()->y),
41                            style->textShadow()->blur, style->textShadow()->color);
42         setShadow = true;
43     }
44 
45     const String& str = m_str;
46     context->drawText(style->font(), TextRun(str.characters(), str.length(), false, 0, 0, false, style->visuallyOrdered()), IntPoint(m_x + tx, m_y + ty + style->font().ascent()));
47 
48     if (setShadow)
49         context->clearShadow();
50 
51     if (m_markupBox) {
52         // Paint the markup box
53         tx += m_x + m_width - m_markupBox->x();
54         ty += m_y + style->font().ascent() - (m_markupBox->y() + m_markupBox->renderer()->style(m_firstLine)->font().ascent());
55         m_markupBox->paint(paintInfo, tx, ty);
56     }
57 }
58 
nodeAtPoint(const HitTestRequest & request,HitTestResult & result,int x,int y,int tx,int ty)59 bool EllipsisBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, int x, int y, int tx, int ty)
60 {
61     tx += m_x;
62     ty += m_y;
63 
64     // Hit test the markup box.
65     if (m_markupBox) {
66         RenderStyle* style = m_renderer->style(m_firstLine);
67         int mtx = tx + m_width - m_markupBox->x();
68         int mty = ty + style->font().ascent() - (m_markupBox->y() + m_markupBox->renderer()->style(m_firstLine)->font().ascent());
69         if (m_markupBox->nodeAtPoint(request, result, x, y, mtx, mty)) {
70             renderer()->updateHitTestResult(result, IntPoint(x - mtx, y - mty));
71             return true;
72         }
73     }
74 
75     if (visibleToHitTesting() && IntRect(tx, ty, m_width, m_height).contains(x, y)) {
76         renderer()->updateHitTestResult(result, IntPoint(x - tx, y - ty));
77         return true;
78     }
79 
80     return false;
81 }
82 
83 } // namespace WebCore
84