OLD | NEW |
(Empty) | |
| 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 #include "core/svg/SVGAnimatedHref.h" |
| 6 |
| 7 #include "core/SVGNames.h" |
| 8 #include "core/XLinkNames.h" |
| 9 #include "core/frame/UseCounter.h" |
| 10 #include "core/svg/SVGElement.h" |
| 11 |
| 12 namespace blink { |
| 13 |
| 14 PassRefPtrWillBeRawPtr<SVGAnimatedHref> SVGAnimatedHref::create(SVGElement* cont
extElement) |
| 15 { |
| 16 return adoptRefWillBeNoop(new SVGAnimatedHref(contextElement)); |
| 17 } |
| 18 |
| 19 DEFINE_TRACE(SVGAnimatedHref) |
| 20 { |
| 21 visitor->trace(m_href); |
| 22 visitor->trace(m_xlinkHref); |
| 23 SVGAnimatedString::trace(visitor); |
| 24 } |
| 25 |
| 26 SVGAnimatedHref::SVGAnimatedHref(SVGElement* contextElement) |
| 27 : SVGAnimatedString(contextElement, SVGNames::hrefAttr, nullptr) |
| 28 , m_href(SVGAnimatedString::create(contextElement, SVGNames::hrefAttr, SVGSt
ring::create())) |
| 29 , m_xlinkHref(SVGAnimatedString::create(contextElement, XLinkNames::hrefAttr
, SVGString::create())) |
| 30 { |
| 31 } |
| 32 |
| 33 void SVGAnimatedHref::addToPropertyMap(SVGElement* element) |
| 34 { |
| 35 element->addToPropertyMap(m_href); |
| 36 element->addToPropertyMap(m_xlinkHref); |
| 37 } |
| 38 |
| 39 bool SVGAnimatedHref::isKnownAttribute(const QualifiedName& attrName) |
| 40 { |
| 41 return attrName.matches(SVGNames::hrefAttr) || attrName.matches(XLinkNames::
hrefAttr); |
| 42 } |
| 43 |
| 44 SVGPropertyBase* SVGAnimatedHref::currentValueBase() |
| 45 { |
| 46 ASSERT_NOT_REACHED(); |
| 47 return nullptr; |
| 48 } |
| 49 |
| 50 const SVGPropertyBase& SVGAnimatedHref::baseValueBase() const |
| 51 { |
| 52 ASSERT_NOT_REACHED(); |
| 53 return SVGAnimatedString::baseValueBase(); |
| 54 } |
| 55 |
| 56 bool SVGAnimatedHref::isAnimating() const |
| 57 { |
| 58 ASSERT_NOT_REACHED(); |
| 59 return false; |
| 60 } |
| 61 |
| 62 PassRefPtrWillBeRawPtr<SVGPropertyBase> SVGAnimatedHref::createAnimatedValue() |
| 63 { |
| 64 ASSERT_NOT_REACHED(); |
| 65 return nullptr; |
| 66 } |
| 67 |
| 68 void SVGAnimatedHref::setAnimatedValue(PassRefPtrWillBeRawPtr<SVGPropertyBase>) |
| 69 { |
| 70 ASSERT_NOT_REACHED(); |
| 71 } |
| 72 |
| 73 void SVGAnimatedHref::animationEnded() |
| 74 { |
| 75 ASSERT_NOT_REACHED(); |
| 76 } |
| 77 |
| 78 SVGParsingError SVGAnimatedHref::setBaseValueAsString(const String&) |
| 79 { |
| 80 ASSERT_NOT_REACHED(); |
| 81 return SVGParseStatus::NoError; |
| 82 } |
| 83 |
| 84 bool SVGAnimatedHref::needsSynchronizeAttribute() |
| 85 { |
| 86 ASSERT_NOT_REACHED(); |
| 87 return false; |
| 88 } |
| 89 |
| 90 void SVGAnimatedHref::synchronizeAttribute() |
| 91 { |
| 92 ASSERT_NOT_REACHED(); |
| 93 } |
| 94 |
| 95 String SVGAnimatedHref::baseVal() |
| 96 { |
| 97 UseCounter::count(contextElement()->document(), UseCounter::SVGHrefBaseVal); |
| 98 return backingHref()->baseVal(); |
| 99 } |
| 100 |
| 101 void SVGAnimatedHref::setBaseVal(const String& value, ExceptionState& exceptionS
tate) |
| 102 { |
| 103 UseCounter::count(contextElement()->document(), UseCounter::SVGHrefBaseVal); |
| 104 backingHref()->setBaseVal(value, exceptionState); |
| 105 } |
| 106 |
| 107 String SVGAnimatedHref::animVal() |
| 108 { |
| 109 UseCounter::count(contextElement()->document(), UseCounter::SVGHrefAnimVal); |
| 110 // We should only animate (non-XLink) 'href'. |
| 111 return m_href->animVal(); |
| 112 } |
| 113 |
| 114 SVGAnimatedString* SVGAnimatedHref::backingHref() const |
| 115 { |
| 116 if (m_href->isSpecified()) |
| 117 return m_href.get(); |
| 118 if (m_xlinkHref->isSpecified()) |
| 119 return m_xlinkHref.get(); |
| 120 return m_href.get(); |
| 121 } |
| 122 |
| 123 } // namespace blink |
OLD | NEW |