1 | /* |
2 | * Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org> |
3 | * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> |
4 | * Copyright (C) 2018 Apple Inc. All rights reserved. |
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 "SVGSwitchElement.h" |
24 | |
25 | #include "ElementIterator.h" |
26 | #include "RenderSVGTransformableContainer.h" |
27 | #include "SVGNames.h" |
28 | #include <wtf/IsoMallocInlines.h> |
29 | |
30 | namespace WebCore { |
31 | |
32 | WTF_MAKE_ISO_ALLOCATED_IMPL(SVGSwitchElement); |
33 | |
34 | inline SVGSwitchElement::SVGSwitchElement(const QualifiedName& tagName, Document& document) |
35 | : SVGGraphicsElement(tagName, document) |
36 | , SVGExternalResourcesRequired(this) |
37 | { |
38 | ASSERT(hasTagName(SVGNames::switchTag)); |
39 | } |
40 | |
41 | Ref<SVGSwitchElement> SVGSwitchElement::create(const QualifiedName& tagName, Document& document) |
42 | { |
43 | return adoptRef(*new SVGSwitchElement(tagName, document)); |
44 | } |
45 | |
46 | bool SVGSwitchElement::childShouldCreateRenderer(const Node& child) const |
47 | { |
48 | // We create a renderer for the first valid SVG element child. |
49 | // FIXME: The renderer must be updated after dynamic change of the requiredFeatures, requiredExtensions and systemLanguage attributes (https://bugs.webkit.org/show_bug.cgi?id=74749). |
50 | for (auto& element : childrenOfType<SVGElement>(*this)) { |
51 | if (!element.isValid()) |
52 | continue; |
53 | return &element == &child; // Only allow this child if it's the first valid child |
54 | } |
55 | |
56 | return false; |
57 | } |
58 | |
59 | RenderPtr<RenderElement> SVGSwitchElement::createElementRenderer(RenderStyle&& style, const RenderTreePosition&) |
60 | { |
61 | return createRenderer<RenderSVGTransformableContainer>(*this, WTFMove(style)); |
62 | } |
63 | |
64 | } |
65 | |