1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_SVG_SVG_ANIMATED_HREF_H_
6 #define THIRD_PARTY_BLINK_RENDERER_CORE_SVG_SVG_ANIMATED_HREF_H_
7 
8 #include "third_party/blink/renderer/core/svg/svg_animated_string.h"
9 
10 namespace blink {
11 
12 class StringOrTrustedScriptURL;
13 
14 // This is an "access wrapper" for the 'href' attribute. The object
15 // itself holds the value for 'href' in the null/default NS and wraps
16 // one for 'href' in the XLink NS. Both objects are added to an
17 // SVGElement's property map and hence any updates/synchronization/etc
18 // via the "attribute DOM" (setAttribute and friends) will operate on
19 // the independent objects, while users of an 'href' value will be
20 // using this interface (which essentially just selects either itself
21 // or the wrapped object and forwards the operation to it.)
22 class SVGAnimatedHref final : public SVGAnimatedString {
23  public:
24   explicit SVGAnimatedHref(SVGElement* context_element);
25 
26   SVGString* CurrentValue();
27   const SVGString* CurrentValue() const;
28 
29   void baseVal(StringOrTrustedScriptURL&) override;
30   void setBaseVal(const StringOrTrustedScriptURL&, ExceptionState&) override;
31   String animVal() override;
32 
IsSpecified()33   bool IsSpecified() const {
34     return SVGAnimatedString::IsSpecified() || xlink_href_->IsSpecified();
35   }
36 
37   static bool IsKnownAttribute(const QualifiedName&);
38   void AddToPropertyMap(SVGElement*);
39 
40   void Trace(Visitor*) const override;
41 
42  private:
43   SVGAnimatedString* BackingString();
44   const SVGAnimatedString* BackingString() const;
45   bool UseXLink() const;
46 
47   Member<SVGAnimatedString> xlink_href_;
48 };
49 
50 }  // namespace blink
51 
52 #endif  // THIRD_PARTY_BLINK_RENDERER_CORE_SVG_SVG_ANIMATED_HREF_H_
53