| 1 | /* |
| 2 | * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> |
| 3 | * Copyright (C) 2004, 2005 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 "QualifiedName.h" |
| 25 | #include "SVGPropertyOwnerRegistry.h" |
| 26 | #include <wtf/HashSet.h> |
| 27 | |
| 28 | namespace WebCore { |
| 29 | |
| 30 | class SVGElement; |
| 31 | |
| 32 | // Notes on a SVG 1.1 spec discrepancy: |
| 33 | // The SVG DOM defines the attribute externalResourcesRequired as being of type SVGAnimatedBoolean, whereas the |
| 34 | // SVG language definition says that externalResourcesRequired is not animated. Because the SVG language definition |
| 35 | // states that externalResourcesRequired cannot be animated, the animVal will always be the same as the baseVal. |
| 36 | // FIXME: When implementing animVal support, make sure that animVal==baseVal for externalResourcesRequired |
| 37 | class SVGExternalResourcesRequired { |
| 38 | WTF_MAKE_NONCOPYABLE(SVGExternalResourcesRequired); |
| 39 | public: |
| 40 | virtual ~SVGExternalResourcesRequired() = default; |
| 41 | |
| 42 | void parseAttribute(const QualifiedName&, const AtomicString&); |
| 43 | void svgAttributeChanged(const QualifiedName&); |
| 44 | |
| 45 | static void addSupportedAttributes(HashSet<QualifiedName>&); |
| 46 | |
| 47 | using PropertyRegistry = SVGPropertyOwnerRegistry<SVGExternalResourcesRequired>; |
| 48 | |
| 49 | bool externalResourcesRequired() const { return m_externalResourcesRequired->currentValue(); } |
| 50 | SVGAnimatedBoolean& externalResourcesRequiredAnimated() { return m_externalResourcesRequired; } |
| 51 | |
| 52 | protected: |
| 53 | SVGExternalResourcesRequired(SVGElement* contextElement); |
| 54 | |
| 55 | static bool isKnownAttribute(const QualifiedName& attributeName) { return PropertyRegistry::isKnownAttribute(attributeName); } |
| 56 | |
| 57 | virtual void setHaveFiredLoadEvent(bool) { } |
| 58 | virtual bool isParserInserted() const { return false; } |
| 59 | virtual bool haveFiredLoadEvent() const { return false; } |
| 60 | |
| 61 | void dispatchLoadEvent(); |
| 62 | void insertedIntoDocument(); |
| 63 | void finishParsingChildren(); |
| 64 | bool haveLoadedRequiredResources() const; |
| 65 | |
| 66 | private: |
| 67 | SVGElement& m_contextElement; |
| 68 | Ref<SVGAnimatedBoolean> m_externalResourcesRequired; |
| 69 | }; |
| 70 | |
| 71 | } // namespace WebCore |
| 72 | |