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

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

Issue 1681553002: Add support for 'href' (w/o XLink NS) for various SVG elements (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase; update comment 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/UnsafeSVGAttributeSanitizationTest.cpp ('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 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 { 232 {
233 clearResourceAndEventBaseReferences(); 233 clearResourceAndEventBaseReferences();
234 234
235 if (!inDocument()) { 235 if (!inDocument()) {
236 // Reset the target element if we are no longer in the document. 236 // Reset the target element if we are no longer in the document.
237 setTargetElement(nullptr); 237 setTargetElement(nullptr);
238 return; 238 return;
239 } 239 }
240 240
241 AtomicString id; 241 AtomicString id;
242 AtomicString href = getAttribute(XLinkNames::hrefAttr); 242 const AtomicString& href = SVGURIReference::legacyHrefString(*this);
243 Element* target; 243 Element* target;
244 if (href.isEmpty()) 244 if (href.isEmpty())
245 target = parentNode() && parentNode()->isElementNode() ? toElement(paren tNode()) : nullptr; 245 target = parentNode() && parentNode()->isElementNode() ? toElement(paren tNode()) : nullptr;
246 else 246 else
247 target = SVGURIReference::targetElementFromIRIString(href, treeScope(), &id); 247 target = SVGURIReference::targetElementFromIRIString(href, treeScope(), &id);
248 SVGElement* svgTarget = target && target->isSVGElement() ? toSVGElement(targ et) : nullptr; 248 SVGElement* svgTarget = target && target->isSVGElement() ? toSVGElement(targ et) : nullptr;
249 249
250 if (svgTarget && !svgTarget->inDocument()) 250 if (svgTarget && !svgTarget->inDocument())
251 svgTarget = nullptr; 251 svgTarget = nullptr;
252 252
(...skipping 27 matching lines...) Expand all
280 280
281 AtomicString prefix; 281 AtomicString prefix;
282 AtomicString localName; 282 AtomicString localName;
283 if (!Document::parseQualifiedName(attributeName, prefix, localName, IGNORE_E XCEPTION)) 283 if (!Document::parseQualifiedName(attributeName, prefix, localName, IGNORE_E XCEPTION))
284 return anyQName(); 284 return anyQName();
285 285
286 const AtomicString& namespaceURI = svgElement->lookupNamespaceURI(prefix); 286 const AtomicString& namespaceURI = svgElement->lookupNamespaceURI(prefix);
287 if (namespaceURI.isEmpty()) 287 if (namespaceURI.isEmpty())
288 return anyQName(); 288 return anyQName();
289 289
290 return QualifiedName(nullAtom, localName, namespaceURI); 290 QualifiedName resolvedAttrName(nullAtom, localName, namespaceURI);
291 // "Animation elements treat attributeName='xlink:href' as being an alias
292 // for targetting the 'href' attribute."
293 // https://svgwg.org/svg2-draft/types.html#__svg__SVGURIReference__href
294 if (resolvedAttrName == XLinkNames::hrefAttr)
295 return SVGNames::hrefAttr;
296 return resolvedAttrName;
291 } 297 }
292 298
293 static inline void clearTimesWithDynamicOrigins(Vector<SMILTimeWithOrigin>& time List) 299 static inline void clearTimesWithDynamicOrigins(Vector<SMILTimeWithOrigin>& time List)
294 { 300 {
295 for (int i = timeList.size() - 1; i >= 0; --i) { 301 for (int i = timeList.size() - 1; i >= 0; --i) {
296 if (timeList[i].originIsScript()) 302 if (timeList[i].originIsScript())
297 timeList.remove(i); 303 timeList.remove(i);
298 } 304 }
299 } 305 }
300 306
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 setAttributeEventListener(EventTypeNames::endEvent, createAttributeEvent Listener(this, name, value, eventParameterName())); 543 setAttributeEventListener(EventTypeNames::endEvent, createAttributeEvent Listener(this, name, value, eventParameterName()));
538 } else if (name == SVGNames::onrepeatAttr) { 544 } else if (name == SVGNames::onrepeatAttr) {
539 setAttributeEventListener(EventTypeNames::repeatEvent, createAttributeEv entListener(this, name, value, eventParameterName())); 545 setAttributeEventListener(EventTypeNames::repeatEvent, createAttributeEv entListener(this, name, value, eventParameterName()));
540 } else { 546 } else {
541 SVGElement::parseAttribute(name, oldValue, value); 547 SVGElement::parseAttribute(name, oldValue, value);
542 } 548 }
543 } 549 }
544 550
545 void SVGSMILElement::svgAttributeChanged(const QualifiedName& attrName) 551 void SVGSMILElement::svgAttributeChanged(const QualifiedName& attrName)
546 { 552 {
547 if (attrName == SVGNames::durAttr) 553 if (attrName == SVGNames::durAttr) {
548 m_cachedDur = invalidCachedTime; 554 m_cachedDur = invalidCachedTime;
549 else if (attrName == SVGNames::repeatDurAttr) 555 } else if (attrName == SVGNames::repeatDurAttr) {
550 m_cachedRepeatDur = invalidCachedTime; 556 m_cachedRepeatDur = invalidCachedTime;
551 else if (attrName == SVGNames::repeatCountAttr) 557 } else if (attrName == SVGNames::repeatCountAttr) {
552 m_cachedRepeatCount = invalidCachedTime; 558 m_cachedRepeatCount = invalidCachedTime;
553 else if (attrName == SVGNames::minAttr) 559 } else if (attrName == SVGNames::minAttr) {
554 m_cachedMin = invalidCachedTime; 560 m_cachedMin = invalidCachedTime;
555 else if (attrName == SVGNames::maxAttr) 561 } else if (attrName == SVGNames::maxAttr) {
556 m_cachedMax = invalidCachedTime; 562 m_cachedMax = invalidCachedTime;
557 else if (attrName == SVGNames::attributeNameAttr) 563 } else if (attrName == SVGNames::attributeNameAttr) {
558 setAttributeName(constructQualifiedName(this, fastGetAttribute(SVGNames: :attributeNameAttr))); 564 setAttributeName(constructQualifiedName(this, fastGetAttribute(SVGNames: :attributeNameAttr)));
559 else if (attrName.matches(XLinkNames::hrefAttr)) { 565 } else if (attrName.matches(SVGNames::hrefAttr) || attrName.matches(XLinkNam es::hrefAttr)) {
566 // TODO(fs): Could be smarter here when 'href' is specified and 'xlink:h ref' is changed.
560 SVGElement::InvalidationGuard invalidationGuard(this); 567 SVGElement::InvalidationGuard invalidationGuard(this);
561 buildPendingResource(); 568 buildPendingResource();
562 if (m_targetElement) 569 if (m_targetElement)
563 clearAnimatedType(); 570 clearAnimatedType();
564 } else if (attrName == SVGNames::beginAttr || attrName == SVGNames::endAttr) { 571 } else if (attrName == SVGNames::beginAttr || attrName == SVGNames::endAttr) {
565 if (inDocument()) { 572 if (inDocument()) {
566 connectEventBaseConditions(); 573 connectEventBaseConditions();
567 if (attrName == SVGNames::beginAttr) 574 if (attrName == SVGNames::beginAttr)
568 beginListChanged(elapsed()); 575 beginListChanged(elapsed());
569 else if (attrName == SVGNames::endAttr) 576 else if (attrName == SVGNames::endAttr)
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after
1361 visitor->trace(m_targetElement); 1368 visitor->trace(m_targetElement);
1362 visitor->trace(m_timeContainer); 1369 visitor->trace(m_timeContainer);
1363 visitor->trace(m_conditions); 1370 visitor->trace(m_conditions);
1364 visitor->trace(m_syncBaseDependents); 1371 visitor->trace(m_syncBaseDependents);
1365 #endif 1372 #endif
1366 SVGElement::trace(visitor); 1373 SVGElement::trace(visitor);
1367 SVGTests::trace(visitor); 1374 SVGTests::trace(visitor);
1368 } 1375 }
1369 1376
1370 } // namespace blink 1377 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/svg/UnsafeSVGAttributeSanitizationTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698