1 /*
2 * This file is part of the WebKit project.
3 *
4 * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz>
5 * Copyright (C) 2006 Apple Inc. All rights reserved.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
16 *
17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
21 *
22 */
23
24 #include "config.h"
25
26 #if ENABLE(SVG)
27 #include "RenderSVGInline.h"
28
29 #include "FloatQuad.h"
30 #include "RenderBlock.h"
31 #include "SVGInlineFlowBox.h"
32 #include "SVGInlineTextBox.h"
33 #include "SVGRootInlineBox.h"
34
35 namespace WebCore {
36
RenderSVGInline(Node * n)37 RenderSVGInline::RenderSVGInline(Node* n)
38 : RenderInline(n)
39 {
40 }
41
createInlineFlowBox()42 InlineFlowBox* RenderSVGInline::createInlineFlowBox()
43 {
44 InlineFlowBox* box = new (renderArena()) SVGInlineFlowBox(this);
45 box->setHasVirtualHeight();
46 return box;
47 }
48
absoluteRects(Vector<IntRect> & rects,int,int)49 void RenderSVGInline::absoluteRects(Vector<IntRect>& rects, int, int)
50 {
51 InlineRunBox* firstBox = firstLineBox();
52
53 SVGRootInlineBox* rootBox = firstBox ? static_cast<SVGInlineTextBox*>(firstBox)->svgRootInlineBox() : 0;
54 RenderBox* object = rootBox ? rootBox->block() : 0;
55
56 if (!object)
57 return;
58
59 int xRef = object->x();
60 int yRef = object->y();
61
62 for (InlineRunBox* curr = firstBox; curr; curr = curr->nextLineBox()) {
63 FloatRect rect(xRef + curr->x(), yRef + curr->y(), curr->width(), curr->height());
64 rects.append(enclosingIntRect(localToAbsoluteQuad(rect).boundingBox()));
65 }
66 }
67
absoluteQuads(Vector<FloatQuad> & quads)68 void RenderSVGInline::absoluteQuads(Vector<FloatQuad>& quads)
69 {
70 InlineRunBox* firstBox = firstLineBox();
71
72 SVGRootInlineBox* rootBox = firstBox ? static_cast<SVGInlineTextBox*>(firstBox)->svgRootInlineBox() : 0;
73 RenderBox* object = rootBox ? rootBox->block() : 0;
74
75 if (!object)
76 return;
77
78 int xRef = object->x();
79 int yRef = object->y();
80
81 for (InlineRunBox* curr = firstBox; curr; curr = curr->nextLineBox()) {
82 FloatRect rect(xRef + curr->x(), yRef + curr->y(), curr->width(), curr->height());
83 quads.append(localToAbsoluteQuad(rect));
84 }
85 }
86
87 }
88
89 #endif // ENABLE(SVG)
90