Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(822)

Side by Side Diff: third_party/WebKit/Source/core/svg/SVGAnimatedHref.cpp

Issue 1697593002: Simplify SVGAnimatedHref (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Now with less infinite recursion! Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGAnimatedHref.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/svg/SVGAnimatedHref.h" 5 #include "core/svg/SVGAnimatedHref.h"
6 6
7 #include "core/SVGNames.h" 7 #include "core/SVGNames.h"
8 #include "core/XLinkNames.h" 8 #include "core/XLinkNames.h"
9 #include "core/frame/UseCounter.h" 9 #include "core/frame/UseCounter.h"
10 #include "core/svg/SVGElement.h" 10 #include "core/svg/SVGElement.h"
11 11
12 namespace blink { 12 namespace blink {
13 13
14 PassRefPtrWillBeRawPtr<SVGAnimatedHref> SVGAnimatedHref::create(SVGElement* cont extElement) 14 PassRefPtrWillBeRawPtr<SVGAnimatedHref> SVGAnimatedHref::create(SVGElement* cont extElement)
15 { 15 {
16 return adoptRefWillBeNoop(new SVGAnimatedHref(contextElement)); 16 return adoptRefWillBeNoop(new SVGAnimatedHref(contextElement));
17 } 17 }
18 18
19 DEFINE_TRACE(SVGAnimatedHref) 19 DEFINE_TRACE(SVGAnimatedHref)
20 { 20 {
21 visitor->trace(m_href);
22 visitor->trace(m_xlinkHref); 21 visitor->trace(m_xlinkHref);
23 SVGAnimatedString::trace(visitor); 22 SVGAnimatedString::trace(visitor);
24 } 23 }
25 24
26 SVGAnimatedHref::SVGAnimatedHref(SVGElement* contextElement) 25 SVGAnimatedHref::SVGAnimatedHref(SVGElement* contextElement)
27 : SVGAnimatedString(contextElement, SVGNames::hrefAttr, nullptr) 26 : SVGAnimatedString(contextElement, SVGNames::hrefAttr, SVGString::create())
28 , m_href(SVGAnimatedString::create(contextElement, SVGNames::hrefAttr, SVGSt ring::create()))
29 , m_xlinkHref(SVGAnimatedString::create(contextElement, XLinkNames::hrefAttr , SVGString::create())) 27 , m_xlinkHref(SVGAnimatedString::create(contextElement, XLinkNames::hrefAttr , SVGString::create()))
30 { 28 {
31 } 29 }
32 30
33 void SVGAnimatedHref::addToPropertyMap(SVGElement* element) 31 void SVGAnimatedHref::addToPropertyMap(SVGElement* element)
34 { 32 {
35 element->addToPropertyMap(m_href); 33 element->addToPropertyMap(this);
36 element->addToPropertyMap(m_xlinkHref); 34 element->addToPropertyMap(m_xlinkHref);
37 } 35 }
38 36
39 bool SVGAnimatedHref::isKnownAttribute(const QualifiedName& attrName) 37 bool SVGAnimatedHref::isKnownAttribute(const QualifiedName& attrName)
40 { 38 {
41 return attrName.matches(SVGNames::hrefAttr) || attrName.matches(XLinkNames:: hrefAttr); 39 return attrName.matches(SVGNames::hrefAttr) || attrName.matches(XLinkNames:: hrefAttr);
42 } 40 }
43 41
44 SVGPropertyBase* SVGAnimatedHref::currentValueBase() 42 SVGString* SVGAnimatedHref::currentValue()
45 { 43 {
46 ASSERT_NOT_REACHED(); 44 return backingString()->SVGAnimatedString::currentValue();
47 return nullptr;
48 } 45 }
49 46
50 const SVGPropertyBase& SVGAnimatedHref::baseValueBase() const 47 const SVGString* SVGAnimatedHref::currentValue() const
51 { 48 {
52 ASSERT_NOT_REACHED(); 49 return backingString()->SVGAnimatedString::currentValue();
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 } 50 }
94 51
95 String SVGAnimatedHref::baseVal() 52 String SVGAnimatedHref::baseVal()
96 { 53 {
97 UseCounter::count(contextElement()->document(), UseCounter::SVGHrefBaseVal); 54 UseCounter::count(contextElement()->document(), UseCounter::SVGHrefBaseVal);
98 return backingHref()->baseVal(); 55 return backingString()->SVGAnimatedString::baseVal();
99 } 56 }
100 57
101 void SVGAnimatedHref::setBaseVal(const String& value, ExceptionState& exceptionS tate) 58 void SVGAnimatedHref::setBaseVal(const String& value, ExceptionState& exceptionS tate)
102 { 59 {
103 UseCounter::count(contextElement()->document(), UseCounter::SVGHrefBaseVal); 60 UseCounter::count(contextElement()->document(), UseCounter::SVGHrefBaseVal);
104 backingHref()->setBaseVal(value, exceptionState); 61 return backingString()->SVGAnimatedString::setBaseVal(value, exceptionState) ;
105 } 62 }
106 63
107 String SVGAnimatedHref::animVal() 64 String SVGAnimatedHref::animVal()
108 { 65 {
109 UseCounter::count(contextElement()->document(), UseCounter::SVGHrefAnimVal); 66 UseCounter::count(contextElement()->document(), UseCounter::SVGHrefAnimVal);
110 // We should only animate (non-XLink) 'href'. 67 // We should only animate (non-XLink) 'href'.
111 return m_href->animVal(); 68 return SVGAnimatedString::animVal();
112 } 69 }
113 70
114 SVGAnimatedString* SVGAnimatedHref::backingHref() const 71 SVGAnimatedString* SVGAnimatedHref::backingString()
115 { 72 {
116 if (m_href->isSpecified()) 73 return useXLink() ? m_xlinkHref.get() : this;
117 return m_href.get(); 74 }
118 if (m_xlinkHref->isSpecified()) 75
119 return m_xlinkHref.get(); 76 const SVGAnimatedString* SVGAnimatedHref::backingString() const
120 return m_href.get(); 77 {
78 return useXLink() ? m_xlinkHref.get() : this;
79 }
80
81 bool SVGAnimatedHref::useXLink() const
82 {
83 return !SVGAnimatedString::isSpecified() && m_xlinkHref->isSpecified();
121 } 84 }
122 85
123 } // namespace blink 86 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGAnimatedHref.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698