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<SVGElement*>& instances = ensureSVGRareData()->elementInstances(); | 535 WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement> >& instances = ensureSV GRareData()->elementInstances(); |
| 536 ASSERT(!instances.contains(instance->shadowTreeElement())); | 536 ASSERT(!instances.contains(instance->shadowTreeElement())); |
| 537 | 537 |
| 538 instances.add(instance->shadowTreeElement()); | 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 if (!instance->shadowTreeElement()) | 546 if (!instance->shadowTreeElement()) |
| 547 return; | 547 return; |
| 548 | 548 |
| 549 HashSet<SVGElement*>& instances = svgRareData()->elementInstances(); | 549 WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement> >& instances = svgRareD ata()->elementInstances(); |
|
haraken
2014/05/07 12:50:20
Shall we typedef this? We have a lot of WillBeHea
Mads Ager (chromium)
2014/05/08 09:08:59
The issue is that this type is used all over the p
haraken
2014/05/08 09:15:41
Probably you can define it in SVGElement.h, since
| |
| 550 ASSERT(instances.contains(instance->shadowTreeElement())); | 550 ASSERT(instances.contains(instance->shadowTreeElement())); |
| 551 | 551 |
| 552 instances.remove(instance->shadowTreeElement()); | 552 instances.remove(instance->shadowTreeElement()); |
| 553 } | 553 } |
| 554 | 554 |
| 555 const HashSet<SVGElement*>& SVGElement::instancesForElement() const | 555 static WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement> >& emptyInstances() |
| 556 { | 556 { |
| 557 if (!hasSVGRareData()) { | 557 #if ENABLE(OILPAN) |
| 558 DEFINE_STATIC_LOCAL(HashSet<SVGElement*>, emptyInstances, ()); | 558 DEFINE_STATIC_LOCAL(Persistent<HeapHashSet<WeakMember<SVGElement> > >, empty Instances, (new HeapHashSet<WeakMember<SVGElement> >)); |
| 559 return emptyInstances; | 559 return *emptyInstances; |
| 560 } | 560 #else |
| 561 DEFINE_STATIC_LOCAL(HashSet<RawPtr<SVGElement> >, emptyInstances, ()); | |
| 562 return emptyInstances; | |
| 563 #endif | |
| 564 } | |
| 565 | |
| 566 const WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement> >& SVGElement::instan cesForElement() const | |
| 567 { | |
| 568 if (!hasSVGRareData()) | |
| 569 return emptyInstances(); | |
| 561 return svgRareData()->elementInstances(); | 570 return svgRareData()->elementInstances(); |
|
haraken
2014/05/07 12:50:20
Probably not related to your CL, but I'm not quite
Mads Ager (chromium)
2014/05/08 09:08:59
Yeah, unrelated to my change. When you collect ele
| |
| 562 } | 571 } |
| 563 | 572 |
| 564 bool SVGElement::getBoundingBox(FloatRect& rect) | 573 bool SVGElement::getBoundingBox(FloatRect& rect) |
| 565 { | 574 { |
| 566 if (!isSVGGraphicsElement()) | 575 if (!isSVGGraphicsElement()) |
| 567 return false; | 576 return false; |
| 568 | 577 |
| 569 rect = toSVGGraphicsElement(this)->getBBox(); | 578 rect = toSVGGraphicsElement(this)->getBBox(); |
| 570 return true; | 579 return true; |
| 571 } | 580 } |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 778 | 787 |
| 779 bool SVGElement::haveLoadedRequiredResources() | 788 bool SVGElement::haveLoadedRequiredResources() |
| 780 { | 789 { |
| 781 for (SVGElement* child = Traversal<SVGElement>::firstChild(*this); child; ch ild = Traversal<SVGElement>::nextSibling(*child)) { | 790 for (SVGElement* child = Traversal<SVGElement>::firstChild(*this); child; ch ild = Traversal<SVGElement>::nextSibling(*child)) { |
| 782 if (!child->haveLoadedRequiredResources()) | 791 if (!child->haveLoadedRequiredResources()) |
| 783 return false; | 792 return false; |
| 784 } | 793 } |
| 785 return true; | 794 return true; |
| 786 } | 795 } |
| 787 | 796 |
| 788 static inline void collectInstancesForSVGElement(SVGElement* element, HashSet<SV GElement*>& instances) | 797 static inline void collectInstancesForSVGElement(SVGElement* element, WillBeHeap HashSet<RawPtrWillBeWeakMember<SVGElement> >& instances) |
| 789 { | 798 { |
| 790 ASSERT(element); | 799 ASSERT(element); |
| 791 if (element->containingShadowRoot()) | 800 if (element->containingShadowRoot()) |
| 792 return; | 801 return; |
| 793 | 802 |
| 794 ASSERT(!element->instanceUpdatesBlocked()); | 803 ASSERT(!element->instanceUpdatesBlocked()); |
| 795 | 804 |
| 796 instances = element->instancesForElement(); | 805 instances = element->instancesForElement(); |
| 797 } | 806 } |
| 798 | 807 |
| 799 bool SVGElement::addEventListener(const AtomicString& eventType, PassRefPtr<Even tListener> prpListener, bool useCapture) | 808 bool SVGElement::addEventListener(const AtomicString& eventType, PassRefPtr<Even tListener> prpListener, bool useCapture) |
| 800 { | 809 { |
| 801 RefPtr<EventListener> listener = prpListener; | 810 RefPtr<EventListener> listener = prpListener; |
| 802 | 811 |
| 803 // Add event listener to regular DOM element | 812 // Add event listener to regular DOM element |
| 804 if (!Node::addEventListener(eventType, listener, useCapture)) | 813 if (!Node::addEventListener(eventType, listener, useCapture)) |
| 805 return false; | 814 return false; |
| 806 | 815 |
| 807 // Add event listener to all shadow tree DOM element instances | 816 // Add event listener to all shadow tree DOM element instances |
| 808 HashSet<SVGElement*> instances; | 817 WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement> > instances; |
| 809 collectInstancesForSVGElement(this, instances); | 818 collectInstancesForSVGElement(this, instances); |
| 810 const HashSet<SVGElement*>::const_iterator end = instances.end(); | 819 const WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement> >::const_iterator end = instances.end(); |
| 811 for (HashSet<SVGElement*>::const_iterator it = instances.begin(); it != end; ++it) { | 820 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement> >::const_iterator it = instances.begin(); it != end; ++it) { |
| 812 bool result = (*it)->Node::addEventListener(eventType, listener, useCapt ure); | 821 bool result = (*it)->Node::addEventListener(eventType, listener, useCapt ure); |
| 813 ASSERT_UNUSED(result, result); | 822 ASSERT_UNUSED(result, result); |
| 814 } | 823 } |
| 815 | 824 |
| 816 return true; | 825 return true; |
| 817 } | 826 } |
| 818 | 827 |
| 819 bool SVGElement::removeEventListener(const AtomicString& eventType, EventListene r* listener, bool useCapture) | 828 bool SVGElement::removeEventListener(const AtomicString& eventType, EventListene r* listener, bool useCapture) |
| 820 { | 829 { |
| 821 HashSet<SVGElement*> instances; | 830 WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement> > instances; |
| 822 collectInstancesForSVGElement(this, instances); | 831 collectInstancesForSVGElement(this, instances); |
| 823 if (instances.isEmpty()) | 832 if (instances.isEmpty()) |
| 824 return Node::removeEventListener(eventType, listener, useCapture); | 833 return Node::removeEventListener(eventType, listener, useCapture); |
| 825 | 834 |
| 826 // EventTarget::removeEventListener creates a PassRefPtr around the given Ev entListener | 835 // EventTarget::removeEventListener creates a PassRefPtr around the given Ev entListener |
| 827 // object when creating a temporary RegisteredEventListener object used to l ook up the | 836 // object when creating a temporary RegisteredEventListener object used to l ook up the |
| 828 // event listener in a cache. If we want to be able to call removeEventListe ner() multiple | 837 // event listener in a cache. If we want to be able to call removeEventListe ner() multiple |
| 829 // times on different nodes, we have to delay its immediate destruction, whi ch would happen | 838 // times on different nodes, we have to delay its immediate destruction, whi ch would happen |
| 830 // after the first call below. | 839 // after the first call below. |
| 831 RefPtr<EventListener> protector(listener); | 840 RefPtr<EventListener> protector(listener); |
| 832 | 841 |
| 833 // Remove event listener from regular DOM element | 842 // Remove event listener from regular DOM element |
| 834 if (!Node::removeEventListener(eventType, listener, useCapture)) | 843 if (!Node::removeEventListener(eventType, listener, useCapture)) |
| 835 return false; | 844 return false; |
| 836 | 845 |
| 837 // Remove event listener from all shadow tree DOM element instances | 846 // Remove event listener from all shadow tree DOM element instances |
| 838 const HashSet<SVGElement*>::const_iterator end = instances.end(); | 847 const WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement> >::const_iterator end = instances.end(); |
| 839 for (HashSet<SVGElement*>::const_iterator it = instances.begin(); it != end; ++it) { | 848 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement> >::const_iterator it = instances.begin(); it != end; ++it) { |
| 840 SVGElement* shadowTreeElement = *it; | 849 SVGElement* shadowTreeElement = *it; |
| 841 ASSERT(shadowTreeElement); | 850 ASSERT(shadowTreeElement); |
| 842 | 851 |
| 843 if (shadowTreeElement->Node::removeEventListener(eventType, listener, us eCapture)) | 852 if (shadowTreeElement->Node::removeEventListener(eventType, listener, us eCapture)) |
| 844 continue; | 853 continue; |
| 845 | 854 |
| 846 // This case can only be hit for event listeners created from markup | 855 // This case can only be hit for event listeners created from markup |
| 847 ASSERT(listener->wasCreatedFromMarkup()); | 856 ASSERT(listener->wasCreatedFromMarkup()); |
| 848 | 857 |
| 849 // If the event listener 'listener' has been created from markup and has been fired before | 858 // If the event listener 'listener' has been created from markup and has been fired before |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1034 } | 1043 } |
| 1035 | 1044 |
| 1036 void SVGElement::invalidateInstances() | 1045 void SVGElement::invalidateInstances() |
| 1037 { | 1046 { |
| 1038 if (!inDocument()) | 1047 if (!inDocument()) |
| 1039 return; | 1048 return; |
| 1040 | 1049 |
| 1041 if (instanceUpdatesBlocked()) | 1050 if (instanceUpdatesBlocked()) |
| 1042 return; | 1051 return; |
| 1043 | 1052 |
| 1044 const HashSet<SVGElement*>& set = instancesForElement(); | 1053 const WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement> >& set = instance sForElement(); |
| 1045 if (set.isEmpty()) | 1054 if (set.isEmpty()) |
| 1046 return; | 1055 return; |
| 1047 | 1056 |
| 1048 // Mark all use elements referencing 'element' for rebuilding | 1057 // Mark all use elements referencing 'element' for rebuilding |
| 1049 const HashSet<SVGElement*>::const_iterator end = set.end(); | 1058 const WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement> >::const_iterator end = set.end(); |
| 1050 for (HashSet<SVGElement*>::const_iterator it = set.begin(); it != end; ++it) { | 1059 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement> >::const_iterator it = set.begin(); it != end; ++it) { |
| 1051 (*it)->setCorrespondingElement(0); | 1060 (*it)->setCorrespondingElement(0); |
| 1052 | 1061 |
| 1053 if (SVGUseElement* element = (*it)->correspondingUseElement()) { | 1062 if (SVGUseElement* element = (*it)->correspondingUseElement()) { |
| 1054 ASSERT(element->inDocument()); | 1063 ASSERT(element->inDocument()); |
| 1055 element->invalidateShadowTree(); | 1064 element->invalidateShadowTree(); |
| 1056 } | 1065 } |
| 1057 } | 1066 } |
| 1058 | 1067 |
| 1059 document().updateRenderTreeIfNeeded(); | 1068 document().updateRenderTreeIfNeeded(); |
| 1060 } | 1069 } |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1172 animatableAttributes.add(SVGNames::zAttr); | 1181 animatableAttributes.add(SVGNames::zAttr); |
| 1173 } | 1182 } |
| 1174 | 1183 |
| 1175 if (name == classAttr) | 1184 if (name == classAttr) |
| 1176 return true; | 1185 return true; |
| 1177 | 1186 |
| 1178 return animatableAttributes.contains(name); | 1187 return animatableAttributes.contains(name); |
| 1179 } | 1188 } |
| 1180 #endif | 1189 #endif |
| 1181 } | 1190 } |
| OLD | NEW |