Changeset 166586 in webkit
- Timestamp:
- Apr 1, 2014 8:22:36 AM (10 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r166585 r166586 1 2014-04-01 Zan Dobersek <zdobersek@igalia.com> 2 3 Avoid unnecessary HashSet copies when calling collectInstancesForSVGElement 4 https://bugs.webkit.org/show_bug.cgi?id=131020 5 6 Reviewed by Andreas Kling. 7 8 Remove collectInstancesForSVGElement() to avoid HashSet copies when assigning a const 9 HashSet reference to a non-const HashSet reference. Instead, range-based for-loops are 10 deployed to iterate directly over the const reference to HashSet that's returned by 11 SVGElement::instancesForElement(). SVGElement::containingShadowRoot() return value 12 is checked to see if the iteration should be performed in the first place, preserving 13 the behavior of collectInstancesForSVGElement(). 14 15 * svg/SVGElement.cpp: 16 (WebCore::SVGElement::addEventListener): 17 (WebCore::SVGElement::removeEventListener): 18 (WebCore::collectInstancesForSVGElement): Deleted. 19 1 20 2014-04-01 Zan Dobersek <zdobersek@igalia.com> 2 21 -
trunk/Source/WebCore/svg/SVGElement.cpp
r165607 r166586 536 536 } 537 537 538 static inline void collectInstancesForSVGElement(SVGElement* element, HashSet<SVGElementInstance*>& instances)539 {540 ASSERT(element);541 if (element->containingShadowRoot())542 return;543 544 ASSERT(!element->instanceUpdatesBlocked());545 546 instances = element->instancesForElement();547 }548 549 538 bool SVGElement::addEventListener(const AtomicString& eventType, PassRefPtr<EventListener> prpListener, bool useCapture) 550 539 { … … 555 544 return false; 556 545 546 if (containingShadowRoot()) 547 return true; 548 557 549 // Add event listener to all shadow tree DOM element instances 558 HashSet<SVGElementInstance*> instances; 559 collectInstancesForSVGElement(this, instances); 560 const HashSet<SVGElementInstance*>::const_iterator end = instances.end(); 561 for (HashSet<SVGElementInstance*>::const_iterator it = instances.begin(); it != end; ++it) { 562 ASSERT((*it)->shadowTreeElement()); 563 ASSERT((*it)->correspondingElement() == this); 564 565 bool result = (*it)->shadowTreeElement()->Node::addEventListener(eventType, listener, useCapture); 550 ASSERT(!element->instanceUpdatesBlocked()); 551 for (auto& instance : instancesForElement()) { 552 ASSERT(instance->shadowTreeElement()); 553 ASSERT(instance->correspondingElement() == this); 554 555 bool result = instance->shadowTreeElement()->Node::addEventListener(eventType, listener, useCapture); 566 556 ASSERT_UNUSED(result, result); 567 557 } … … 572 562 bool SVGElement::removeEventListener(const AtomicString& eventType, EventListener* listener, bool useCapture) 573 563 { 574 HashSet<SVGElementInstance*> instances; 575 collectInstancesForSVGElement(this, instances); 576 if (instances.isEmpty()) 564 if (containingShadowRoot()) 577 565 return Node::removeEventListener(eventType, listener, useCapture); 578 566 … … 589 577 590 578 // Remove event listener from all shadow tree DOM element instances 591 const HashSet<SVGElementInstance*>::const_iterator end = instances.end();592 for ( HashSet<SVGElementInstance*>::const_iterator it = instances.begin(); it != end; ++it) {593 ASSERT( (*it)->correspondingElement() == this);594 595 SVGElement* shadowTreeElement = (*it)->shadowTreeElement();579 ASSERT(!element->instanceUpdatesBlocked()); 580 for (auto& instance : instancesForElement()) { 581 ASSERT(instance->correspondingElement() == this); 582 583 SVGElement* shadowTreeElement = instance->shadowTreeElement(); 596 584 ASSERT(shadowTreeElement); 597 585
Note: See TracChangeset
for help on using the changeset viewer.