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 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 // This function is provided for use by SVGAnimatedProperty to avoid | 465 // This function is provided for use by SVGAnimatedProperty to avoid |
466 // global inclusion of core/dom/Document.h in SVG code. | 466 // global inclusion of core/dom/Document.h in SVG code. |
467 return document().accessSVGExtensions(); | 467 return document().accessSVGExtensions(); |
468 } | 468 } |
469 | 469 |
470 void SVGElement::mapInstanceToElement(SVGElement* instance) | 470 void SVGElement::mapInstanceToElement(SVGElement* instance) |
471 { | 471 { |
472 ASSERT(instance); | 472 ASSERT(instance); |
473 ASSERT(instance->inUseShadowTree()); | 473 ASSERT(instance->inUseShadowTree()); |
474 | 474 |
475 WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement> >& instances = ensureSV
GRareData()->elementInstances(); | 475 WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement>>& instances = ensureSVG
RareData()->elementInstances(); |
476 ASSERT(!instances.contains(instance)); | 476 ASSERT(!instances.contains(instance)); |
477 | 477 |
478 instances.add(instance); | 478 instances.add(instance); |
479 } | 479 } |
480 | 480 |
481 void SVGElement::removeInstanceMapping(SVGElement* instance) | 481 void SVGElement::removeInstanceMapping(SVGElement* instance) |
482 { | 482 { |
483 ASSERT(instance); | 483 ASSERT(instance); |
484 ASSERT(instance->inUseShadowTree()); | 484 ASSERT(instance->inUseShadowTree()); |
485 | 485 |
486 if (!hasSVGRareData()) | 486 if (!hasSVGRareData()) |
487 return; | 487 return; |
488 | 488 |
489 WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement> >& instances = svgRareD
ata()->elementInstances(); | 489 WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement>>& instances = svgRareDa
ta()->elementInstances(); |
490 | 490 |
491 instances.remove(instance); | 491 instances.remove(instance); |
492 } | 492 } |
493 | 493 |
494 static WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement> >& emptyInstances() | 494 static WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement>>& emptyInstances() |
495 { | 495 { |
496 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<WillBeHeapHashSet<RawPtrWillBeWea
kMember<SVGElement> > >, emptyInstances, (adoptPtrWillBeNoop(new WillBeHeapHashS
et<RawPtrWillBeWeakMember<SVGElement> >()))); | 496 DEFINE_STATIC_LOCAL(OwnPtrWillBePersistent<WillBeHeapHashSet<RawPtrWillBeWea
kMember<SVGElement>>>, emptyInstances, (adoptPtrWillBeNoop(new WillBeHeapHashSet
<RawPtrWillBeWeakMember<SVGElement>>()))); |
497 return *emptyInstances; | 497 return *emptyInstances; |
498 } | 498 } |
499 | 499 |
500 const WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement> >& SVGElement::instan
cesForElement() const | 500 const WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement>>& SVGElement::instanc
esForElement() const |
501 { | 501 { |
502 if (!hasSVGRareData()) | 502 if (!hasSVGRareData()) |
503 return emptyInstances(); | 503 return emptyInstances(); |
504 return svgRareData()->elementInstances(); | 504 return svgRareData()->elementInstances(); |
505 } | 505 } |
506 | 506 |
507 bool SVGElement::getBoundingBox(FloatRect& rect) | 507 bool SVGElement::getBoundingBox(FloatRect& rect) |
508 { | 508 { |
509 if (!isSVGGraphicsElement()) | 509 if (!isSVGGraphicsElement()) |
510 return false; | 510 return false; |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 | 731 |
732 bool SVGElement::haveLoadedRequiredResources() | 732 bool SVGElement::haveLoadedRequiredResources() |
733 { | 733 { |
734 for (SVGElement* child = Traversal<SVGElement>::firstChild(*this); child; ch
ild = Traversal<SVGElement>::nextSibling(*child)) { | 734 for (SVGElement* child = Traversal<SVGElement>::firstChild(*this); child; ch
ild = Traversal<SVGElement>::nextSibling(*child)) { |
735 if (!child->haveLoadedRequiredResources()) | 735 if (!child->haveLoadedRequiredResources()) |
736 return false; | 736 return false; |
737 } | 737 } |
738 return true; | 738 return true; |
739 } | 739 } |
740 | 740 |
741 static inline void collectInstancesForSVGElement(SVGElement* element, WillBeHeap
HashSet<RawPtrWillBeWeakMember<SVGElement> >& instances) | 741 static inline void collectInstancesForSVGElement(SVGElement* element, WillBeHeap
HashSet<RawPtrWillBeWeakMember<SVGElement>>& instances) |
742 { | 742 { |
743 ASSERT(element); | 743 ASSERT(element); |
744 if (element->containingShadowRoot()) | 744 if (element->containingShadowRoot()) |
745 return; | 745 return; |
746 | 746 |
747 ASSERT(!element->instanceUpdatesBlocked()); | 747 ASSERT(!element->instanceUpdatesBlocked()); |
748 | 748 |
749 instances = element->instancesForElement(); | 749 instances = element->instancesForElement(); |
750 } | 750 } |
751 | 751 |
752 bool SVGElement::addEventListener(const AtomicString& eventType, PassRefPtr<Even
tListener> prpListener, bool useCapture) | 752 bool SVGElement::addEventListener(const AtomicString& eventType, PassRefPtr<Even
tListener> prpListener, bool useCapture) |
753 { | 753 { |
754 RefPtr<EventListener> listener = prpListener; | 754 RefPtr<EventListener> listener = prpListener; |
755 | 755 |
756 // Add event listener to regular DOM element | 756 // Add event listener to regular DOM element |
757 if (!Node::addEventListener(eventType, listener, useCapture)) | 757 if (!Node::addEventListener(eventType, listener, useCapture)) |
758 return false; | 758 return false; |
759 | 759 |
760 // Add event listener to all shadow tree DOM element instances | 760 // Add event listener to all shadow tree DOM element instances |
761 WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement> > instances; | 761 WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement>> instances; |
762 collectInstancesForSVGElement(this, instances); | 762 collectInstancesForSVGElement(this, instances); |
763 for (SVGElement* element : instances) { | 763 for (SVGElement* element : instances) { |
764 bool result = element->Node::addEventListener(eventType, listener, useCa
pture); | 764 bool result = element->Node::addEventListener(eventType, listener, useCa
pture); |
765 ASSERT_UNUSED(result, result); | 765 ASSERT_UNUSED(result, result); |
766 } | 766 } |
767 | 767 |
768 return true; | 768 return true; |
769 } | 769 } |
770 | 770 |
771 bool SVGElement::removeEventListener(const AtomicString& eventType, PassRefPtr<E
ventListener> prpListener, bool useCapture) | 771 bool SVGElement::removeEventListener(const AtomicString& eventType, PassRefPtr<E
ventListener> prpListener, bool useCapture) |
772 { | 772 { |
773 RefPtr<EventListener> listener = prpListener; | 773 RefPtr<EventListener> listener = prpListener; |
774 | 774 |
775 // Remove event listener from regular DOM element | 775 // Remove event listener from regular DOM element |
776 if (!Node::removeEventListener(eventType, listener, useCapture)) | 776 if (!Node::removeEventListener(eventType, listener, useCapture)) |
777 return false; | 777 return false; |
778 | 778 |
779 // Remove event listener from all shadow tree DOM element instances | 779 // Remove event listener from all shadow tree DOM element instances |
780 WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement> > instances; | 780 WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement>> instances; |
781 collectInstancesForSVGElement(this, instances); | 781 collectInstancesForSVGElement(this, instances); |
782 for (SVGElement* shadowTreeElement : instances) { | 782 for (SVGElement* shadowTreeElement : instances) { |
783 ASSERT(shadowTreeElement); | 783 ASSERT(shadowTreeElement); |
784 | 784 |
785 shadowTreeElement->Node::removeEventListener(eventType, listener, useCap
ture); | 785 shadowTreeElement->Node::removeEventListener(eventType, listener, useCap
ture); |
786 } | 786 } |
787 | 787 |
788 return true; | 788 return true; |
789 } | 789 } |
790 | 790 |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
970 } | 970 } |
971 | 971 |
972 void SVGElement::invalidateInstances() | 972 void SVGElement::invalidateInstances() |
973 { | 973 { |
974 if (!inDocument()) | 974 if (!inDocument()) |
975 return; | 975 return; |
976 | 976 |
977 if (instanceUpdatesBlocked()) | 977 if (instanceUpdatesBlocked()) |
978 return; | 978 return; |
979 | 979 |
980 const WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement> >& set = instance
sForElement(); | 980 const WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement>>& set = instances
ForElement(); |
981 if (set.isEmpty()) | 981 if (set.isEmpty()) |
982 return; | 982 return; |
983 | 983 |
984 // Mark all use elements referencing 'element' for rebuilding | 984 // Mark all use elements referencing 'element' for rebuilding |
985 for (SVGElement* instance : set) { | 985 for (SVGElement* instance : set) { |
986 instance->setCorrespondingElement(0); | 986 instance->setCorrespondingElement(0); |
987 | 987 |
988 if (SVGUseElement* element = instance->correspondingUseElement()) { | 988 if (SVGUseElement* element = instance->correspondingUseElement()) { |
989 ASSERT(element->inDocument()); | 989 ASSERT(element->inDocument()); |
990 element->invalidateShadowTree(); | 990 element->invalidateShadowTree(); |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1136 } | 1136 } |
1137 | 1137 |
1138 void SVGElement::rebuildAllIncomingReferences() | 1138 void SVGElement::rebuildAllIncomingReferences() |
1139 { | 1139 { |
1140 if (!hasSVGRareData()) | 1140 if (!hasSVGRareData()) |
1141 return; | 1141 return; |
1142 | 1142 |
1143 const SVGElementSet& incomingReferences = svgRareData()->incomingReferences(
); | 1143 const SVGElementSet& incomingReferences = svgRareData()->incomingReferences(
); |
1144 | 1144 |
1145 // Iterate on a snapshot as |incomingReferences| may be altered inside loop. | 1145 // Iterate on a snapshot as |incomingReferences| may be altered inside loop. |
1146 WillBeHeapVector<RawPtrWillBeMember<SVGElement> > incomingReferencesSnapshot
; | 1146 WillBeHeapVector<RawPtrWillBeMember<SVGElement>> incomingReferencesSnapshot; |
1147 copyToVector(incomingReferences, incomingReferencesSnapshot); | 1147 copyToVector(incomingReferences, incomingReferencesSnapshot); |
1148 | 1148 |
1149 // Force rebuilding the |sourceElement| so it knows about this change. | 1149 // Force rebuilding the |sourceElement| so it knows about this change. |
1150 for (SVGElement* sourceElement : incomingReferencesSnapshot) { | 1150 for (SVGElement* sourceElement : incomingReferencesSnapshot) { |
1151 // Before rebuilding |sourceElement| ensure it was not removed from unde
r us. | 1151 // Before rebuilding |sourceElement| ensure it was not removed from unde
r us. |
1152 if (incomingReferences.contains(sourceElement)) | 1152 if (incomingReferences.contains(sourceElement)) |
1153 sourceElement->svgAttributeChanged(XLinkNames::hrefAttr); | 1153 sourceElement->svgAttributeChanged(XLinkNames::hrefAttr); |
1154 } | 1154 } |
1155 } | 1155 } |
1156 | 1156 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1191 Element::trace(visitor); | 1191 Element::trace(visitor); |
1192 } | 1192 } |
1193 | 1193 |
1194 const AtomicString& SVGElement::eventParameterName() | 1194 const AtomicString& SVGElement::eventParameterName() |
1195 { | 1195 { |
1196 DEFINE_STATIC_LOCAL(const AtomicString, evtString, ("evt", AtomicString::Con
structFromLiteral)); | 1196 DEFINE_STATIC_LOCAL(const AtomicString, evtString, ("evt", AtomicString::Con
structFromLiteral)); |
1197 return evtString; | 1197 return evtString; |
1198 } | 1198 } |
1199 | 1199 |
1200 } // namespace blink | 1200 } // namespace blink |
OLD | NEW |