The Android Open Source Project | 8e35f3c | 2009-03-03 19:30:52 -0800 | [diff] [blame^] | 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 | |
| 31 | void EllipsisBox::paint(RenderObject::PaintInfo& paintInfo, int tx, int ty) |
| 32 | { |
| 33 | GraphicsContext* context = paintInfo.context; |
| 34 | RenderStyle* style = m_object->style(m_firstLine); |
| 35 | if (style->font() != context->font()) |
| 36 | context->setFont(style->font()); |
| 37 | |
| 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; |
| 46 | } |
| 47 | |
| 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)); |
| 50 | |
| 51 | if (setShadow) |
| 52 | context->clearShadow(); |
| 53 | |
| 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); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | bool EllipsisBox::nodeAtPoint(const HitTestRequest& request, HitTestResult& result, int x, int y, int tx, int ty) |
| 63 | { |
| 64 | tx += m_x; |
| 65 | ty += m_y; |
| 66 | |
| 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; |
| 74 | } |
| 75 | } |
| 76 | |
| 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; |
| 80 | } |
| 81 | |
| 82 | return false; |
| 83 | } |
| 84 | |
| 85 | } // namespace WebCore |