| 1 | /* |
| 2 | * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> |
| 3 | * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> |
| 4 | * Copyright (C) 2018-2019 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 | #pragma once |
| 23 | |
| 24 | #include "SVGElement.h" |
| 25 | #include "SVGTests.h" |
| 26 | #include "SVGTransformable.h" |
| 27 | |
| 28 | namespace WebCore { |
| 29 | |
| 30 | class AffineTransform; |
| 31 | class Path; |
| 32 | class SVGRect; |
| 33 | class SVGMatrix; |
| 34 | |
| 35 | class SVGGraphicsElement : public SVGElement, public SVGTransformable, public SVGTests { |
| 36 | WTF_MAKE_ISO_ALLOCATED(SVGGraphicsElement); |
| 37 | public: |
| 38 | virtual ~SVGGraphicsElement(); |
| 39 | |
| 40 | Ref<SVGMatrix> getCTMForBindings(); |
| 41 | AffineTransform getCTM(StyleUpdateStrategy = AllowStyleUpdate) override; |
| 42 | |
| 43 | Ref<SVGMatrix> getScreenCTMForBindings(); |
| 44 | AffineTransform getScreenCTM(StyleUpdateStrategy = AllowStyleUpdate) override; |
| 45 | |
| 46 | SVGElement* nearestViewportElement() const override; |
| 47 | SVGElement* farthestViewportElement() const override; |
| 48 | |
| 49 | AffineTransform localCoordinateSpaceTransform(SVGLocatable::CTMScope mode) const override { return SVGTransformable::localCoordinateSpaceTransform(mode); } |
| 50 | AffineTransform animatedLocalTransform() const override; |
| 51 | AffineTransform* supplementalTransform() override; |
| 52 | |
| 53 | Ref<SVGRect> getBBoxForBindings(); |
| 54 | FloatRect getBBox(StyleUpdateStrategy = AllowStyleUpdate) override; |
| 55 | |
| 56 | bool shouldIsolateBlending() const { return m_shouldIsolateBlending; } |
| 57 | void setShouldIsolateBlending(bool isolate) { m_shouldIsolateBlending = isolate; } |
| 58 | |
| 59 | // "base class" methods for all the elements which render as paths |
| 60 | virtual Path toClipPath(); |
| 61 | RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) override; |
| 62 | |
| 63 | size_t approximateMemoryCost() const override { return sizeof(*this); } |
| 64 | |
| 65 | using PropertyRegistry = SVGPropertyOwnerRegistry<SVGGraphicsElement, SVGElement, SVGTests>; |
| 66 | |
| 67 | const SVGTransformList& transform() const { return m_transform->currentValue(); } |
| 68 | SVGAnimatedTransformList& transformAnimated() { return m_transform; } |
| 69 | |
| 70 | protected: |
| 71 | SVGGraphicsElement(const QualifiedName&, Document&); |
| 72 | |
| 73 | bool supportsFocus() const override { return Element::supportsFocus() || hasFocusEventListeners(); } |
| 74 | |
| 75 | void parseAttribute(const QualifiedName&, const AtomicString&) override; |
| 76 | void svgAttributeChanged(const QualifiedName&) override; |
| 77 | |
| 78 | private: |
| 79 | bool isSVGGraphicsElement() const override { return true; } |
| 80 | |
| 81 | // Used by <animateMotion> |
| 82 | std::unique_ptr<AffineTransform> m_supplementalTransform; |
| 83 | |
| 84 | // Used to isolate blend operations caused by masking. |
| 85 | bool m_shouldIsolateBlending; |
| 86 | |
| 87 | Ref<SVGAnimatedTransformList> m_transform { SVGAnimatedTransformList::create(this) }; |
| 88 | }; |
| 89 | |
| 90 | } // namespace WebCore |
| 91 | |
| 92 | SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::SVGGraphicsElement) |
| 93 | static bool isType(const WebCore::SVGElement& element) { return element.isSVGGraphicsElement(); } |
| 94 | static bool isType(const WebCore::Node& node) { return is<WebCore::SVGElement>(node) && isType(downcast<WebCore::SVGElement>(node)); } |
| 95 | SPECIALIZE_TYPE_TRAITS_END() |
| 96 | |