darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 1 | /* |
zimmermann@webkit.org | 711245f | 2010-08-03 19:39:01 +0000 | [diff] [blame] | 2 | * Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> |
| 3 | * Copyright (C) 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org> |
| 4 | * |
| 5 | * This library is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU Library General Public |
| 7 | * License as published by the Free Software Foundation; either |
| 8 | * version 2 of the License, or (at your option) any later version. |
| 9 | * |
| 10 | * This library is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | * Library General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU Library General Public License |
| 16 | * along with this library; see the file COPYING.LIB. If not, write to |
| 17 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 | * Boston, MA 02110-1301, USA. |
| 19 | */ |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 20 | |
| 21 | #include "config.h" |
oliver | 98d5238 | 2007-10-12 10:47:18 +0000 | [diff] [blame] | 22 | |
mjs | d2948ef | 2007-02-26 19:29:04 +0000 | [diff] [blame] | 23 | #if ENABLE(SVG) |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 24 | #include "SVGTextElement.h" |
darin | cfcabdb | 2006-04-02 02:41:24 +0000 | [diff] [blame] | 25 | |
weinig@apple.com | c360893 | 2010-05-19 17:48:06 +0000 | [diff] [blame] | 26 | #include "Attribute.h" |
zimmermann@webkit.org | 5bed57f | 2010-07-16 08:26:24 +0000 | [diff] [blame] | 27 | #include "RenderSVGResource.h" |
rwlbuis | 40a8556 | 2006-10-12 15:07:55 +0000 | [diff] [blame] | 28 | #include "RenderSVGText.h" |
zimmermann@webkit.org | efff725 | 2011-05-21 06:15:40 +0000 | [diff] [blame] | 29 | #include "SVGElementInstance.h" |
zimmermann@webkit.org | 42ab4a7 | 2010-12-03 11:14:32 +0000 | [diff] [blame] | 30 | #include "SVGNames.h" |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 31 | #include "SVGRenderStyle.h" |
darin | cfcabdb | 2006-04-02 02:41:24 +0000 | [diff] [blame] | 32 | #include "SVGTSpanElement.h" |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 33 | |
| 34 | namespace WebCore { |
| 35 | |
weinig@apple.com | 52e786e | 2013-09-15 18:06:06 +0000 | [diff] [blame] | 36 | inline SVGTextElement::SVGTextElement(const QualifiedName& tagName, Document& document) |
| 37 | : SVGTextPositioningElement(tagName, document) |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 38 | { |
rwlbuis@webkit.org | 2551812 | 2011-05-09 13:41:55 +0000 | [diff] [blame] | 39 | ASSERT(hasTagName(SVGNames::textTag)); |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 40 | } |
| 41 | |
weinig@apple.com | 52e786e | 2013-09-15 18:06:06 +0000 | [diff] [blame] | 42 | PassRefPtr<SVGTextElement> SVGTextElement::create(const QualifiedName& tagName, Document& document) |
darin@apple.com | 3cbd5cb | 2010-08-30 06:51:56 +0000 | [diff] [blame] | 43 | { |
darin@apple.com | 69b3ef4 | 2010-08-31 17:08:40 +0000 | [diff] [blame] | 44 | return adoptRef(new SVGTextElement(tagName, document)); |
darin@apple.com | 3cbd5cb | 2010-08-30 06:51:56 +0000 | [diff] [blame] | 45 | } |
| 46 | |
ch.dumez@sisa.samsung.com | 50e120f | 2013-07-04 18:48:51 +0000 | [diff] [blame] | 47 | // We override SVGGraphics::animatedLocalTransform() so that the transform-origin |
| 48 | // is not taken into account. |
krit@webkit.org | 2b95a9a | 2010-02-08 20:30:42 +0000 | [diff] [blame] | 49 | AffineTransform SVGTextElement::animatedLocalTransform() const |
oliver | 09e98ea | 2007-10-12 15:38:34 +0000 | [diff] [blame] | 50 | { |
zimmermann@webkit.org | bbd697c | 2010-11-11 11:20:11 +0000 | [diff] [blame] | 51 | AffineTransform matrix; |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame^] | 52 | RenderStyle* style = renderer() ? &renderer()->style() : nullptr; |
commit-queue@webkit.org | 0db5755 | 2011-11-23 11:34:37 +0000 | [diff] [blame] | 53 | |
| 54 | // if CSS property was set, use that, otherwise fallback to attribute (if set) |
schenney@chromium.org | fa6cd71 | 2012-03-28 14:28:02 +0000 | [diff] [blame] | 55 | if (style && style->hasTransform()) { |
commit-queue@webkit.org | 0db5755 | 2011-11-23 11:34:37 +0000 | [diff] [blame] | 56 | TransformationMatrix t; |
| 57 | // For now, the transform-origin is not taken into account |
| 58 | // Also, any percentage values will not be taken into account |
| 59 | style->applyTransform(t, IntSize(0, 0), RenderStyle::ExcludeTransformOrigin); |
| 60 | // Flatten any 3D transform |
| 61 | matrix = t.toAffineTransform(); |
| 62 | } else |
| 63 | transform().concatenate(matrix); |
| 64 | |
ch.dumez@sisa.samsung.com | 50e120f | 2013-07-04 18:48:51 +0000 | [diff] [blame] | 65 | const AffineTransform* transform = const_cast<SVGTextElement*>(this)->supplementalTransform(); |
| 66 | if (transform) |
| 67 | return *transform * matrix; |
commit-queue@webkit.org | 17b1786 | 2011-01-19 20:10:07 +0000 | [diff] [blame] | 68 | return matrix; |
antti@apple.com | af57927 | 2008-04-18 07:40:17 +0000 | [diff] [blame] | 69 | } |
| 70 | |
akling@apple.com | 8f40c5b | 2013-10-27 22:54:07 +0000 | [diff] [blame] | 71 | RenderElement* SVGTextElement::createRenderer(PassRef<RenderStyle> style) |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 72 | { |
akling@apple.com | 8f40c5b | 2013-10-27 22:54:07 +0000 | [diff] [blame] | 73 | return new RenderSVGText(*this, std::move(style)); |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 74 | } |
| 75 | |
antti@apple.com | dacd6de | 2013-08-20 22:52:55 +0000 | [diff] [blame] | 76 | bool SVGTextElement::childShouldCreateRenderer(const Node* child) const |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 77 | { |
antti@apple.com | dacd6de | 2013-08-20 22:52:55 +0000 | [diff] [blame] | 78 | if (child->isTextNode() |
| 79 | || child->hasTagName(SVGNames::aTag) |
hausmann@webkit.org | af1cc00 | 2008-03-27 21:37:33 +0000 | [diff] [blame] | 80 | #if ENABLE(SVG_FONTS) |
antti@apple.com | dacd6de | 2013-08-20 22:52:55 +0000 | [diff] [blame] | 81 | || child->hasTagName(SVGNames::altGlyphTag) |
hausmann@webkit.org | af1cc00 | 2008-03-27 21:37:33 +0000 | [diff] [blame] | 82 | #endif |
antti@apple.com | dacd6de | 2013-08-20 22:52:55 +0000 | [diff] [blame] | 83 | || child->hasTagName(SVGNames::textPathTag) |
| 84 | || child->hasTagName(SVGNames::trefTag) |
| 85 | || child->hasTagName(SVGNames::tspanTag)) |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 86 | return true; |
commit-queue@webkit.org | ea6bdc7 | 2010-12-11 01:23:26 +0000 | [diff] [blame] | 87 | |
darin | b9481ed | 2006-03-20 02:57:59 +0000 | [diff] [blame] | 88 | return false; |
| 89 | } |
| 90 | |
| 91 | } |
| 92 | |
mjs | d2948ef | 2007-02-26 19:29:04 +0000 | [diff] [blame] | 93 | #endif // ENABLE(SVG) |