Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde .org> | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde .org> |
| 3 * Copyright (C) 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org> |
| 4 * Copyright (C) 2008 Apple Inc. All rights reserved. | 4 * Copyright (C) 2008 Apple Inc. All rights reserved. |
| 5 * Copyright (C) 2008 Alp Toker <alp@atoker.com> | 5 * Copyright (C) 2008 Alp Toker <alp@atoker.com> |
| 6 * Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> | 6 * Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 525 { | 525 { |
| 526 // This function is provided for use by SVGAnimatedProperty to avoid | 526 // This function is provided for use by SVGAnimatedProperty to avoid |
| 527 // global inclusion of core/dom/Document.h in SVG code. | 527 // global inclusion of core/dom/Document.h in SVG code. |
| 528 return document().accessSVGExtensions(); | 528 return document().accessSVGExtensions(); |
| 529 } | 529 } |
| 530 | 530 |
| 531 void SVGElement::mapInstanceToElement(SVGElementInstance* instance) | 531 void SVGElement::mapInstanceToElement(SVGElementInstance* instance) |
| 532 { | 532 { |
| 533 ASSERT(instance); | 533 ASSERT(instance); |
| 534 | 534 |
| 535 HashSet<SVGElementInstance*>& instances = ensureSVGRareData()->elementInstan ces(); | 535 HashSet<SVGElement*>& instances = ensureSVGRareData()->elementInstances(); |
| 536 ASSERT(!instances.contains(instance)); | 536 ASSERT(!instances.contains(instance->shadowTreeElement())); |
| 537 | 537 |
| 538 instances.add(instance); | 538 instances.add(instance->shadowTreeElement()); |
| 539 } | 539 } |
| 540 | 540 |
| 541 void SVGElement::removeInstanceMapping(SVGElementInstance* instance) | 541 void SVGElement::removeInstanceMapping(SVGElementInstance* instance) |
| 542 { | 542 { |
| 543 ASSERT(instance); | 543 ASSERT(instance); |
| 544 ASSERT(hasSVGRareData()); | 544 ASSERT(hasSVGRareData()); |
| 545 | 545 |
| 546 HashSet<SVGElementInstance*>& instances = svgRareData()->elementInstances(); | 546 if (!instance->shadowTreeElement()) |
| 547 ASSERT(instances.contains(instance)); | 547 return; |
| 548 | 548 |
| 549 instances.remove(instance); | 549 HashSet<SVGElement*>& instances = svgRareData()->elementInstances(); |
| 550 ASSERT(instances.contains(instance->shadowTreeElement())); | |
| 551 | |
| 552 instances.remove(instance->shadowTreeElement()); | |
| 550 } | 553 } |
| 551 | 554 |
| 552 const HashSet<SVGElementInstance*>& SVGElement::instancesForElement() const | 555 const HashSet<SVGElement*>& SVGElement::instancesForElement() const |
| 553 { | 556 { |
| 554 if (!hasSVGRareData()) { | 557 if (!hasSVGRareData()) { |
| 555 DEFINE_STATIC_LOCAL(HashSet<SVGElementInstance*>, emptyInstances, ()); | 558 DEFINE_STATIC_LOCAL(HashSet<SVGElement*>, emptyInstances, ()); |
| 556 return emptyInstances; | 559 return emptyInstances; |
| 557 } | 560 } |
| 558 return svgRareData()->elementInstances(); | 561 return svgRareData()->elementInstances(); |
| 559 } | 562 } |
| 560 | 563 |
| 561 bool SVGElement::getBoundingBox(FloatRect& rect) | 564 bool SVGElement::getBoundingBox(FloatRect& rect) |
| 562 { | 565 { |
| 563 if (!isSVGGraphicsElement()) | 566 if (!isSVGGraphicsElement()) |
| 564 return false; | 567 return false; |
| 565 | 568 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 606 svgRareData()->setCursorImageValue(0); | 609 svgRareData()->setCursorImageValue(0); |
| 607 } | 610 } |
| 608 #endif | 611 #endif |
| 609 | 612 |
| 610 SVGElement* SVGElement::correspondingElement() | 613 SVGElement* SVGElement::correspondingElement() |
| 611 { | 614 { |
| 612 ASSERT(!hasSVGRareData() || !svgRareData()->correspondingElement() || contai ningShadowRoot()); | 615 ASSERT(!hasSVGRareData() || !svgRareData()->correspondingElement() || contai ningShadowRoot()); |
| 613 return hasSVGRareData() ? svgRareData()->correspondingElement() : 0; | 616 return hasSVGRareData() ? svgRareData()->correspondingElement() : 0; |
| 614 } | 617 } |
| 615 | 618 |
| 619 SVGUseElement* SVGElement::correspondingUseElement() | |
|
pdr.
2014/05/04 00:03:03
Can we now use this in inUseShadowTree?
bool SVGE
| |
| 620 { | |
| 621 if (ShadowRoot* root = containingShadowRoot()) { | |
| 622 if (isSVGUseElement(root->host()) && (root->type() == ShadowRoot::UserAg entShadowRoot)) | |
| 623 return toSVGUseElement(root->host()); | |
| 624 } | |
| 625 return 0; | |
| 626 } | |
| 627 | |
| 616 void SVGElement::setCorrespondingElement(SVGElement* correspondingElement) | 628 void SVGElement::setCorrespondingElement(SVGElement* correspondingElement) |
| 617 { | 629 { |
| 618 ensureSVGRareData()->setCorrespondingElement(correspondingElement); | 630 ensureSVGRareData()->setCorrespondingElement(correspondingElement); |
| 619 } | 631 } |
| 620 | 632 |
| 621 bool SVGElement::inUseShadowTree() const | 633 bool SVGElement::inUseShadowTree() const |
| 622 { | 634 { |
| 623 if (ShadowRoot* root = containingShadowRoot()) | 635 if (ShadowRoot* root = containingShadowRoot()) |
| 624 return isSVGUseElement(root->host()) && (root->type() == ShadowRoot::Use rAgentShadowRoot); | 636 return isSVGUseElement(root->host()) && (root->type() == ShadowRoot::Use rAgentShadowRoot); |
| 625 return false; | 637 return false; |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 768 | 780 |
| 769 bool SVGElement::haveLoadedRequiredResources() | 781 bool SVGElement::haveLoadedRequiredResources() |
| 770 { | 782 { |
| 771 for (SVGElement* child = Traversal<SVGElement>::firstChild(*this); child; ch ild = Traversal<SVGElement>::nextSibling(*child)) { | 783 for (SVGElement* child = Traversal<SVGElement>::firstChild(*this); child; ch ild = Traversal<SVGElement>::nextSibling(*child)) { |
| 772 if (!child->haveLoadedRequiredResources()) | 784 if (!child->haveLoadedRequiredResources()) |
| 773 return false; | 785 return false; |
| 774 } | 786 } |
| 775 return true; | 787 return true; |
| 776 } | 788 } |
| 777 | 789 |
| 778 static inline void collectInstancesForSVGElement(SVGElement* element, HashSet<SV GElementInstance*>& instances) | 790 static inline void collectInstancesForSVGElement(SVGElement* element, HashSet<SV GElement*>& instances) |
| 779 { | 791 { |
| 780 ASSERT(element); | 792 ASSERT(element); |
| 781 if (element->containingShadowRoot()) | 793 if (element->containingShadowRoot()) |
| 782 return; | 794 return; |
| 783 | 795 |
| 784 ASSERT(!element->instanceUpdatesBlocked()); | 796 ASSERT(!element->instanceUpdatesBlocked()); |
| 785 | 797 |
| 786 instances = element->instancesForElement(); | 798 instances = element->instancesForElement(); |
| 787 } | 799 } |
| 788 | 800 |
| 789 bool SVGElement::addEventListener(const AtomicString& eventType, PassRefPtr<Even tListener> prpListener, bool useCapture) | 801 bool SVGElement::addEventListener(const AtomicString& eventType, PassRefPtr<Even tListener> prpListener, bool useCapture) |
| 790 { | 802 { |
| 791 RefPtr<EventListener> listener = prpListener; | 803 RefPtr<EventListener> listener = prpListener; |
| 792 | 804 |
| 793 // Add event listener to regular DOM element | 805 // Add event listener to regular DOM element |
| 794 if (!Node::addEventListener(eventType, listener, useCapture)) | 806 if (!Node::addEventListener(eventType, listener, useCapture)) |
| 795 return false; | 807 return false; |
| 796 | 808 |
| 797 // Add event listener to all shadow tree DOM element instances | 809 // Add event listener to all shadow tree DOM element instances |
| 798 HashSet<SVGElementInstance*> instances; | 810 HashSet<SVGElement*> instances; |
| 799 collectInstancesForSVGElement(this, instances); | 811 collectInstancesForSVGElement(this, instances); |
| 800 const HashSet<SVGElementInstance*>::const_iterator end = instances.end(); | 812 const HashSet<SVGElement*>::const_iterator end = instances.end(); |
| 801 for (HashSet<SVGElementInstance*>::const_iterator it = instances.begin(); it != end; ++it) { | 813 for (HashSet<SVGElement*>::const_iterator it = instances.begin(); it != end; ++it) { |
| 802 ASSERT((*it)->shadowTreeElement()); | 814 bool result = (*it)->Node::addEventListener(eventType, listener, useCapt ure); |
| 803 ASSERT((*it)->correspondingElement() == this); | |
| 804 | |
| 805 bool result = (*it)->shadowTreeElement()->Node::addEventListener(eventTy pe, listener, useCapture); | |
| 806 ASSERT_UNUSED(result, result); | 815 ASSERT_UNUSED(result, result); |
| 807 } | 816 } |
| 808 | 817 |
| 809 return true; | 818 return true; |
| 810 } | 819 } |
| 811 | 820 |
| 812 bool SVGElement::removeEventListener(const AtomicString& eventType, EventListene r* listener, bool useCapture) | 821 bool SVGElement::removeEventListener(const AtomicString& eventType, EventListene r* listener, bool useCapture) |
| 813 { | 822 { |
| 814 HashSet<SVGElementInstance*> instances; | 823 HashSet<SVGElement*> instances; |
| 815 collectInstancesForSVGElement(this, instances); | 824 collectInstancesForSVGElement(this, instances); |
| 816 if (instances.isEmpty()) | 825 if (instances.isEmpty()) |
| 817 return Node::removeEventListener(eventType, listener, useCapture); | 826 return Node::removeEventListener(eventType, listener, useCapture); |
| 818 | 827 |
| 819 // EventTarget::removeEventListener creates a PassRefPtr around the given Ev entListener | 828 // EventTarget::removeEventListener creates a PassRefPtr around the given Ev entListener |
| 820 // object when creating a temporary RegisteredEventListener object used to l ook up the | 829 // object when creating a temporary RegisteredEventListener object used to l ook up the |
| 821 // event listener in a cache. If we want to be able to call removeEventListe ner() multiple | 830 // event listener in a cache. If we want to be able to call removeEventListe ner() multiple |
| 822 // times on different nodes, we have to delay its immediate destruction, whi ch would happen | 831 // times on different nodes, we have to delay its immediate destruction, whi ch would happen |
| 823 // after the first call below. | 832 // after the first call below. |
| 824 RefPtr<EventListener> protector(listener); | 833 RefPtr<EventListener> protector(listener); |
| 825 | 834 |
| 826 // Remove event listener from regular DOM element | 835 // Remove event listener from regular DOM element |
| 827 if (!Node::removeEventListener(eventType, listener, useCapture)) | 836 if (!Node::removeEventListener(eventType, listener, useCapture)) |
| 828 return false; | 837 return false; |
| 829 | 838 |
| 830 // Remove event listener from all shadow tree DOM element instances | 839 // Remove event listener from all shadow tree DOM element instances |
| 831 const HashSet<SVGElementInstance*>::const_iterator end = instances.end(); | 840 const HashSet<SVGElement*>::const_iterator end = instances.end(); |
| 832 for (HashSet<SVGElementInstance*>::const_iterator it = instances.begin(); it != end; ++it) { | 841 for (HashSet<SVGElement*>::const_iterator it = instances.begin(); it != end; ++it) { |
| 833 ASSERT((*it)->correspondingElement() == this); | 842 SVGElement* shadowTreeElement = *it; |
| 834 | |
| 835 SVGElement* shadowTreeElement = (*it)->shadowTreeElement(); | |
| 836 ASSERT(shadowTreeElement); | 843 ASSERT(shadowTreeElement); |
| 837 | 844 |
| 838 if (shadowTreeElement->Node::removeEventListener(eventType, listener, us eCapture)) | 845 if (shadowTreeElement->Node::removeEventListener(eventType, listener, us eCapture)) |
| 839 continue; | 846 continue; |
| 840 | 847 |
| 841 // This case can only be hit for event listeners created from markup | 848 // This case can only be hit for event listeners created from markup |
| 842 ASSERT(listener->wasCreatedFromMarkup()); | 849 ASSERT(listener->wasCreatedFromMarkup()); |
| 843 | 850 |
| 844 // If the event listener 'listener' has been created from markup and has been fired before | 851 // If the event listener 'listener' has been created from markup and has been fired before |
| 845 // then JSLazyEventListener::parseCode() has been called and m_jsFunctio n of that listener | 852 // then JSLazyEventListener::parseCode() has been called and m_jsFunctio n of that listener |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1142 animatableAttributes.add(SVGNames::zAttr); | 1149 animatableAttributes.add(SVGNames::zAttr); |
| 1143 } | 1150 } |
| 1144 | 1151 |
| 1145 if (name == classAttr) | 1152 if (name == classAttr) |
| 1146 return true; | 1153 return true; |
| 1147 | 1154 |
| 1148 return animatableAttributes.contains(name); | 1155 return animatableAttributes.contains(name); |
| 1149 } | 1156 } |
| 1150 #endif | 1157 #endif |
| 1151 } | 1158 } |
| OLD | NEW |