Changeset 161096 in webkit


Ignore:
Timestamp:
Dec 26, 2013 6:55:57 PM (10 years ago)
Author:
weinig@apple.com
Message:

Convert some of WebCore/dom over to range-for loops
https://bugs.webkit.org/show_bug.cgi?id=126250

Reviewed by Andreas Kling.

  • dom/ContainerNode.cpp:
  • dom/Document.cpp:
  • dom/MutationObserver.cpp:
  • dom/MutationObserverInterestGroup.cpp:
  • dom/MutationObserverRegistration.cpp:
  • dom/Node.cpp:
  • dom/NodeRareData.h:
  • dom/ScriptExecutionContext.cpp:
  • dom/WebKitNamedFlow.cpp:
Location:
trunk/Source/WebCore
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r161094 r161096  
     12013-12-26  Sam Weinig  <sam@webkit.org>
     2
     3        Convert some of WebCore/dom over to range-for loops
     4        https://bugs.webkit.org/show_bug.cgi?id=126250
     5
     6        Reviewed by Andreas Kling.
     7
     8        * dom/ContainerNode.cpp:
     9        * dom/Document.cpp:
     10        * dom/MutationObserver.cpp:
     11        * dom/MutationObserverInterestGroup.cpp:
     12        * dom/MutationObserverRegistration.cpp:
     13        * dom/Node.cpp:
     14        * dom/NodeRareData.h:
     15        * dom/ScriptExecutionContext.cpp:
     16        * dom/WebKitNamedFlow.cpp:
     17
    1182013-12-26  Thiago de Barros Lacerda  <thiago.lacerda@openbossa.org>
    219
  • trunk/Source/WebCore/dom/ContainerNode.cpp

    r161024 r161096  
    302302
    303303    ChildListMutationScope mutation(*this);
    304     for (auto it = targets.begin(), end = targets.end(); it != end; ++it) {
    305         Node& child = it->get();
    306 
     304    for (auto& child : targets) {
    307305        // Due to arbitrary code running in response to a DOM mutation event it's
    308306        // possible that "next" is no longer a child of "this".
     
    311309        if (next->parentNode() != this)
    312310            break;
    313         if (child.parentNode())
     311        if (child->parentNode())
    314312            break;
    315313
    316         treeScope().adoptIfNeeded(&child);
    317 
    318         insertBeforeCommon(next.get(), child);
    319 
    320         updateTreeAfterInsertion(child);
     314        treeScope().adoptIfNeeded(&child.get());
     315
     316        insertBeforeCommon(next.get(), child.get());
     317
     318        updateTreeAfterInsertion(child.get());
    321319    }
    322320
     
    458456
    459457    // Add the new child(ren)
    460     for (auto it = targets.begin(), end = targets.end(); it != end; ++it) {
    461         Node& child = it->get();
    462 
     458    for (auto& child : targets) {
    463459        // Due to arbitrary code running in response to a DOM mutation event it's
    464460        // possible that "next" is no longer a child of "this".
     
    467463        if (next && next->parentNode() != this)
    468464            break;
    469         if (child.parentNode())
     465        if (child->parentNode())
    470466            break;
    471467
    472         treeScope().adoptIfNeeded(&child);
     468        treeScope().adoptIfNeeded(&child.get());
    473469
    474470        // Add child before "next".
     
    476472            NoEventDispatchAssertion assertNoEventDispatch;
    477473            if (next)
    478                 insertBeforeCommon(*next, child);
     474                insertBeforeCommon(*next, child.get());
    479475            else
    480                 appendChildToContainer(&child, *this);
     476                appendChildToContainer(&child.get(), *this);
    481477        }
    482478
    483         updateTreeAfterInsertion(child);
     479        updateTreeAfterInsertion(child.get());
    484480    }
    485481
     
    506502
    507503    ChildListMutationScope mutation(container);
    508     for (auto it = children.begin(); it != children.end(); ++it) {
    509         Node& child = it->get();
    510         mutation.willRemoveChild(child);
    511         child.notifyMutationObserversNodeWillDetach();
     504    for (auto& child : children) {
     505        mutation.willRemoveChild(child.get());
     506        child->notifyMutationObserversNodeWillDetach();
    512507
    513508        // fire removed from document mutation events.
    514         dispatchChildRemovalEvents(child);
     509        dispatchChildRemovalEvents(child.get());
    515510    }
    516511
     
    710705    // Now actually add the child(ren)
    711706    ChildListMutationScope mutation(*this);
    712     for (auto it = targets.begin(), end = targets.end(); it != end; ++it) {
    713         Node& child = it->get();
    714 
     707    for (auto& child : targets) {
    715708        // If the child has a parent again, just stop what we're doing, because
    716709        // that means someone is doing something with DOM mutation -- can't re-parent
    717710        // a child that already has a parent.
    718         if (child.parentNode())
     711        if (child->parentNode())
    719712            break;
    720713
    721         treeScope().adoptIfNeeded(&child);
     714        treeScope().adoptIfNeeded(&child.get());
    722715
    723716        // Append child to the end of the list
    724717        {
    725718            NoEventDispatchAssertion assertNoEventDispatch;
    726             appendChildToContainer(&child, *this);
     719            appendChildToContainer(&child.get(), *this);
    727720        }
    728721
    729         updateTreeAfterInsertion(child);
     722        updateTreeAfterInsertion(child.get());
    730723    }
    731724
  • trunk/Source/WebCore/dom/Document.cpp

    r161024 r161096  
    15541554{
    15551555    dispatchEvent(Event::create(eventNames().visibilitychangeEvent, false, false));
    1556     for (auto it = m_visibilityStateCallbackElements.begin(); it != m_visibilityStateCallbackElements.end(); ++it)
    1557         (*it)->visibilityStateChanged();
     1556    for (auto* element : m_visibilityStateCallbackElements)
     1557        element->visibilityStateChanged();
    15581558}
    15591559
     
    35313531void Document::moveNodeIteratorsToNewDocument(Node* node, Document* newDocument)
    35323532{
    3533     HashSet<NodeIterator*> nodeIteratorsList = m_nodeIterators;
    3534     HashSet<NodeIterator*>::const_iterator nodeIteratorsEnd = nodeIteratorsList.end();
    3535     for (HashSet<NodeIterator*>::const_iterator it = nodeIteratorsList.begin(); it != nodeIteratorsEnd; ++it) {
    3536         if ((*it)->root() == node) {
    3537             detachNodeIterator(*it);
    3538             newDocument->attachNodeIterator(*it);
     3533    HashSet<NodeIterator*> nodeIteratorsCopy = m_nodeIterators;
     3534    for (auto* nodeIterator : nodeIteratorsCopy) {
     3535        if (nodeIterator->root() == node) {
     3536            detachNodeIterator(nodeIterator);
     3537            newDocument->attachNodeIterator(nodeIterator);
    35393538        }
    35403539    }
     
    35443543{
    35453544    if (!m_ranges.isEmpty()) {
    3546         for (auto it = m_ranges.begin(), end = m_ranges.end(); it != end; ++it)
    3547             (*it)->nodeChildrenChanged(container);
     3545        for (auto* range : m_ranges)
     3546            range->nodeChildrenChanged(container);
    35483547    }
    35493548}
     
    35523551{
    35533552    if (!m_ranges.isEmpty()) {
    3554         for (auto it = m_ranges.begin(), end = m_ranges.end(); it != end; ++it)
    3555             (*it)->nodeChildrenWillBeRemoved(container);
    3556     }
    3557 
    3558     for (auto it = m_nodeIterators.begin(), end = m_nodeIterators.end(); it != end; ++it) {
     3553        for (auto* range : m_ranges)
     3554            range->nodeChildrenWillBeRemoved(container);
     3555    }
     3556
     3557    for (auto* nodeIterator : m_nodeIterators) {
    35593558        for (Node* n = container.firstChild(); n; n = n->nextSibling())
    3560             (*it)->nodeWillBeRemoved(n);
     3559            nodeIterator->nodeWillBeRemoved(n);
    35613560    }
    35623561
     
    35723571void Document::nodeWillBeRemoved(Node* n)
    35733572{
    3574     HashSet<NodeIterator*>::const_iterator nodeIteratorsEnd = m_nodeIterators.end();
    3575     for (HashSet<NodeIterator*>::const_iterator it = m_nodeIterators.begin(); it != nodeIteratorsEnd; ++it)
    3576         (*it)->nodeWillBeRemoved(n);
     3573    for (auto* nodeIterator : m_nodeIterators)
     3574        nodeIterator->nodeWillBeRemoved(n);
    35773575
    35783576    if (!m_ranges.isEmpty()) {
    3579         HashSet<Range*>::const_iterator rangesEnd = m_ranges.end();
    3580         for (HashSet<Range*>::const_iterator it = m_ranges.begin(); it != rangesEnd; ++it)
    3581             (*it)->nodeWillBeRemoved(n);
     3577        for (auto* range : m_ranges)
     3578            range->nodeWillBeRemoved(n);
    35823579    }
    35833580
     
    35923589{
    35933590    if (!m_ranges.isEmpty()) {
    3594         HashSet<Range*>::const_iterator end = m_ranges.end();
    3595         for (HashSet<Range*>::const_iterator it = m_ranges.begin(); it != end; ++it)
    3596             (*it)->textInserted(text, offset, length);
     3591        for (auto* range : m_ranges)
     3592            range->textInserted(text, offset, length);
    35973593    }
    35983594
     
    36043600{
    36053601    if (!m_ranges.isEmpty()) {
    3606         HashSet<Range*>::const_iterator end = m_ranges.end();
    3607         for (HashSet<Range*>::const_iterator it = m_ranges.begin(); it != end; ++it)
    3608             (*it)->textRemoved(text, offset, length);
     3602        for (auto* range : m_ranges)
     3603            range->textRemoved(text, offset, length);
    36093604    }
    36103605
     
    36183613    if (!m_ranges.isEmpty()) {
    36193614        NodeWithIndex oldNodeWithIndex(oldNode);
    3620         HashSet<Range*>::const_iterator end = m_ranges.end();
    3621         for (HashSet<Range*>::const_iterator it = m_ranges.begin(); it != end; ++it)
    3622             (*it)->textNodesMerged(oldNodeWithIndex, offset);
     3615        for (auto* range : m_ranges)
     3616            range->textNodesMerged(oldNodeWithIndex, offset);
    36233617    }
    36243618
     
    36293623{
    36303624    if (!m_ranges.isEmpty()) {
    3631         HashSet<Range*>::const_iterator end = m_ranges.end();
    3632         for (HashSet<Range*>::const_iterator it = m_ranges.begin(); it != end; ++it)
    3633             (*it)->textNodeSplit(oldNode);
     3625        for (auto* range : m_ranges)
     3626            range->textNodeSplit(oldNode);
    36343627    }
    36353628
     
    40964089    documentWillBecomeInactive();
    40974090
    4098     HashSet<Element*>::iterator end = m_documentSuspensionCallbackElements.end();
    4099     for (HashSet<Element*>::iterator i = m_documentSuspensionCallbackElements.begin(); i != end; ++i)
    4100         (*i)->documentWillSuspendForPageCache();
     4091    for (auto* element : m_documentSuspensionCallbackElements)
     4092        element->documentWillSuspendForPageCache();
    41014093
    41024094#ifndef NDEBUG
     
    41114103    Vector<Element*> elements;
    41124104    copyToVector(m_documentSuspensionCallbackElements, elements);
    4113     Vector<Element*>::iterator end = elements.end();
    4114     for (Vector<Element*>::iterator i = elements.begin(); i != end; ++i)
    4115         (*i)->documentDidResumeFromPageCache();
     4105    for (auto* element : elements)
     4106        element->documentDidResumeFromPageCache();
    41164107
    41174108#if USE(ACCELERATED_COMPOSITING)
     
    41394130void Document::mediaVolumeDidChange()
    41404131{
    4141     HashSet<Element*>::iterator end = m_mediaVolumeCallbackElements.end();
    4142     for (HashSet<Element*>::iterator i = m_mediaVolumeCallbackElements.begin(); i != end; ++i)
    4143         (*i)->mediaVolumeDidChange();
     4132    for (auto* element : m_mediaVolumeCallbackElements)
     4133        element->mediaVolumeDidChange();
    41444134}
    41454135
     
    41624152void Document::privateBrowsingStateDidChange()
    41634153{
    4164     HashSet<Element*>::iterator end = m_privateBrowsingStateChangedElements.end();
    4165     for (HashSet<Element*>::iterator it = m_privateBrowsingStateChangedElements.begin(); it != end; ++it)
    4166         (*it)->privateBrowsingStateDidChange();
     4154    for (auto* element : m_privateBrowsingStateChangedElements)
     4155        element->privateBrowsingStateDidChange();
    41674156}
    41684157
     
    41934182void Document::captionPreferencesChanged()
    41944183{
    4195     HashSet<Element*>::iterator end = m_captionPreferencesChangedElements.end();
    4196     for (HashSet<Element*>::iterator it = m_captionPreferencesChangedElements.begin(); it != end; ++it)
    4197         (*it)->captionPreferencesChanged();
     4184    for (auto* element : m_captionPreferencesChangedElements)
     4185        element->captionPreferencesChanged();
    41984186}
    41994187#endif
     
    48434831{
    48444832    Vector<TextAutoSizingKey> nodesForRemoval;
    4845     for (auto it = m_textAutoSizedNodes.begin(), end = m_textAutoSizedNodes.end(); it != end; ++it) {
    4846         RefPtr<TextAutoSizingValue> value = it->value;
     4833    for (auto& autoSizingKeyValuePair : m_textAutoSizedNodes) {
     4834        RefPtr<TextAutoSizingValue> value = autoSizingKeyValuePair.value;
    48474835        // Update all the nodes in the collection to reflect the new
    48484836        // candidate size.
     
    48524840        value->adjustNodeSizes();
    48534841        if (!value->numNodes())
    4854             nodesForRemoval.append(it->key);
     4842            nodesForRemoval.append(autoSizingKeyValuePair.key);
    48554843    }
    48564844    unsigned count = nodesForRemoval.size();
     
    48614849void Document::resetAutoSizingNodes()
    48624850{
    4863     for (auto it = m_textAutoSizedNodes.begin(), end = m_textAutoSizedNodes.end(); it != end; ++it) {
    4864         RefPtr<TextAutoSizingValue> value = it->value;
    4865         if (value)
    4866             value->reset();
     4851    for (auto& autoSizingValue : m_textAutoSizedNodes.values()) {
     4852        if (autoSizingValue)
     4853            autoSizingValue->reset();
    48674854    }
    48684855    m_textAutoSizedNodes.clear();
     
    53015288    // 4. For each descendant in descendants, empty descendant's fullscreen element stack, and queue a
    53025289    // task to fire an event named fullscreenchange with its bubbles attribute set to true on descendant.
    5303     for (Deque<RefPtr<Document>>::iterator i = descendants.begin(); i != descendants.end(); ++i) {
    5304         (*i)->clearFullscreenElementStack();
    5305         addDocumentToFullScreenChangeEventQueue(i->get());
     5290    for (auto& descendant : descendants) {
     5291        descendant->clearFullscreenElementStack();
     5292        addDocumentToFullScreenChangeEventQueue(descendant.get());
    53065293    }
    53075294
  • trunk/Source/WebCore/dom/MutationObserver.cpp

    r158569 r161096  
    119119    m_records.clear();
    120120    HashSet<MutationObserverRegistration*> registrations(m_registrations);
    121     for (HashSet<MutationObserverRegistration*>::iterator iter = registrations.begin(); iter != registrations.end(); ++iter)
    122         MutationObserverRegistration::unregisterAndDelete(*iter);
     121    for (auto* registration : registrations)
     122        MutationObserverRegistration::unregisterAndDelete(registration);
    123123}
    124124
     
    165165{
    166166    HashSet<Node*> observedNodes;
    167     for (HashSet<MutationObserverRegistration*>::const_iterator iter = m_registrations.begin(); iter != m_registrations.end(); ++iter)
    168         (*iter)->addRegistrationNodesToSet(observedNodes);
     167    for (auto* registration : m_registrations)
     168        registration->addRegistrationNodesToSet(observedNodes);
    169169    return observedNodes;
    170170}
     
    182182    // to make a copy of the transient registrations before operating on them.
    183183    Vector<MutationObserverRegistration*, 1> transientRegistrations;
    184     for (HashSet<MutationObserverRegistration*>::iterator iter = m_registrations.begin(); iter != m_registrations.end(); ++iter) {
    185         if ((*iter)->hasTransientRegistrations())
    186             transientRegistrations.append(*iter);
     184    for (auto* registration : m_registrations) {
     185        if (registration->hasTransientRegistrations())
     186            transientRegistrations.append(registration);
    187187    }
    188188    for (size_t i = 0; i < transientRegistrations.size(); ++i)
  • trunk/Source/WebCore/dom/MutationObserverInterestGroup.cpp

    r158569 r161096  
    5858bool MutationObserverInterestGroup::isOldValueRequested()
    5959{
    60     for (HashMap<MutationObserver*, MutationRecordDeliveryOptions>::iterator iter = m_observers.begin(); iter != m_observers.end(); ++iter) {
    61         if (hasOldValue(iter->value))
     60    for (auto options : m_observers.values()) {
     61        if (hasOldValue(options))
    6262            return true;
    6363    }
     
    6969    RefPtr<MutationRecord> mutation = prpMutation;
    7070    RefPtr<MutationRecord> mutationWithNullOldValue;
    71     for (HashMap<MutationObserver*, MutationRecordDeliveryOptions>::iterator iter = m_observers.begin(); iter != m_observers.end(); ++iter) {
    72         MutationObserver* observer = iter->key;
    73         if (hasOldValue(iter->value)) {
     71    for (auto& observerOptionsPair : m_observers) {
     72        MutationObserver* observer = observerOptionsPair.key;
     73        if (hasOldValue(observerOptionsPair.value)) {
    7474            observer->enqueueMutationRecord(mutation);
    7575            continue;
  • trunk/Source/WebCore/dom/MutationObserverRegistration.cpp

    r158569 r161096  
    8888    }
    8989
    90     for (NodeHashSet::iterator iter = m_transientRegistrationNodes->begin(); iter != m_transientRegistrationNodes->end(); ++iter)
    91         (*iter)->unregisterTransientMutationObserver(this);
     90    for (auto& node : *m_transientRegistrationNodes)
     91        node->unregisterTransientMutationObserver(this);
    9292
    9393    m_transientRegistrationNodes.clear();
     
    127127    if (!m_transientRegistrationNodes)
    128128        return;
    129     for (NodeHashSet::const_iterator iter = m_transientRegistrationNodes->begin(); iter != m_transientRegistrationNodes->end(); ++iter)
    130         nodes.add(iter->get());
     129    for (auto& node : *m_transientRegistrationNodes)
     130        nodes.add(node.get());
    131131}
    132132
  • trunk/Source/WebCore/dom/Node.cpp

    r160966 r161096  
    132132    size_t elementsWithNamedNodeMap = 0;
    133133
    134     for (HashSet<Node*>::iterator it = liveNodeSet.begin(); it != liveNodeSet.end(); ++it) {
    135         Node* node = *it;
    136 
     134    for (auto* node : liveNodeSet) {
    137135        if (node->hasRareData()) {
    138136            ++nodesWithRareData;
     
    240238
    241239    printf("Element tag name distibution:\n");
    242     for (HashMap<String, size_t>::iterator it = perTagCount.begin(); it != perTagCount.end(); ++it)
    243         printf("  Number of <%s> tags: %zu\n", it->key.utf8().data(), it->value);
     240    for (auto stringSizePair : perTagCount)
     241        printf("  Number of <%s> tags: %zu\n", stringSizePair.key.utf8().data(), stringSizePair.value);
    244242
    245243    printf("Attributes:\n");
     
    728726void Document::invalidateNodeListAndCollectionCaches(const QualifiedName* attrName)
    729727{
    730     for (HashSet<LiveNodeList*>::iterator it = m_listsInvalidatedAtDocument.begin(), end = m_listsInvalidatedAtDocument.end(); it != end; ++it)
    731         (*it)->invalidateCache(attrName);
    732     for (HashSet<HTMLCollection*>::iterator it = m_collectionsInvalidatedAtDocument.begin(), end = m_collectionsInvalidatedAtDocument.end(); it != end; ++it)
    733         (*it)->invalidateCache(attrName);
     728    for (auto* nodeList : m_listsInvalidatedAtDocument)
     729        nodeList->invalidateCache(attrName);
     730    for (auto* collection : m_collectionsInvalidatedAtDocument)
     731        collection->invalidateCache(attrName);
    734732}
    735733
     
    17021700void NodeListsNodeData::invalidateCaches(const QualifiedName* attrName)
    17031701{
    1704     for (auto it = m_atomicNameCaches.begin(), end = m_atomicNameCaches.end(); it != end; ++it)
    1705         it->value->invalidateCache(attrName);
    1706 
    1707     for (auto it = m_nameCaches.begin(), end = m_nameCaches.end(); it != end; ++it)
    1708         it->value->invalidateCache(attrName);
    1709 
    1710     for (auto it = m_cachedCollections.begin(), end = m_cachedCollections.end(); it != end; ++it)
    1711         it->value->invalidateCache(attrName);
     1702    for (auto* nodeList : m_atomicNameCaches.values())
     1703        nodeList->invalidateCache(attrName);
     1704
     1705    for (auto* nodeList : m_nameCaches.values())
     1706        nodeList->invalidateCache(attrName);
     1707
     1708    for (auto* collection : m_cachedCollections.values())
     1709        collection->invalidateCache(attrName);
    17121710
    17131711    if (attrName)
    17141712        return;
    17151713
    1716     for (auto it = m_tagNodeListCacheNS.begin(), end = m_tagNodeListCacheNS.end(); it != end; ++it)
    1717         it->value->invalidateCache();
     1714    for (auto* nodeList : m_tagNodeListCacheNS.values())
     1715        nodeList->invalidateCache();
    17181716}
    17191717
     
    17791777    }
    17801778
    1781     if (Vector<OwnPtr<MutationObserverRegistration>>* registry = mutationObserverRegistry()) {
     1779    if (auto* registry = mutationObserverRegistry()) {
    17821780        for (size_t i = 0; i < registry->size(); ++i) {
    17831781            document().addMutationObserverTypes(registry->at(i)->mutationTypes());
     
    17851783    }
    17861784
    1787     if (HashSet<MutationObserverRegistration*>* transientRegistry = transientMutationObserverRegistry()) {
    1788         for (HashSet<MutationObserverRegistration*>::iterator iter = transientRegistry->begin(); iter != transientRegistry->end(); ++iter) {
    1789             document().addMutationObserverTypes((*iter)->mutationTypes());
    1790         }
     1785    if (auto* transientRegistry = transientMutationObserverRegistry()) {
     1786        for (auto* registration : *transientRegistry)
     1787            document().addMutationObserverTypes(registration->mutationTypes());
    17911788    }
    17921789}
     
    19291926    if (!registry)
    19301927        return;
    1931     for (typename Registry::iterator iter = registry->begin(); iter != registry->end(); ++iter) {
    1932         const MutationObserverRegistration& registration = **iter;
    1933         if (registration.shouldReceiveMutationFrom(target, type, attributeName)) {
    1934             MutationRecordDeliveryOptions deliveryOptions = registration.deliveryOptions();
    1935             HashMap<MutationObserver*, MutationRecordDeliveryOptions>::AddResult result = observers.add(registration.observer(), deliveryOptions);
     1928
     1929    for (auto& registration : *registry) {
     1930        if (registration->shouldReceiveMutationFrom(target, type, attributeName)) {
     1931            MutationRecordDeliveryOptions deliveryOptions = registration->deliveryOptions();
     1932            auto result = observers.add(registration->observer(), deliveryOptions);
    19361933            if (!result.isNewEntry)
    19371934                result.iterator->value |= deliveryOptions;
     
    20072004
    20082005    for (Node* node = parentNode(); node; node = node->parentNode()) {
    2009         if (Vector<OwnPtr<MutationObserverRegistration>>* registry = node->mutationObserverRegistry()) {
     2006        if (auto* registry = node->mutationObserverRegistry()) {
    20102007            const size_t size = registry->size();
    20112008            for (size_t i = 0; i < size; ++i)
     
    20132010        }
    20142011
    2015         if (HashSet<MutationObserverRegistration*>* transientRegistry = node->transientMutationObserverRegistry()) {
    2016             for (HashSet<MutationObserverRegistration*>::iterator iter = transientRegistry->begin(); iter != transientRegistry->end(); ++iter)
    2017                 (*iter)->observedSubtreeNodeWillDetach(this);
     2012        if (auto* transientRegistry = node->transientMutationObserverRegistry()) {
     2013            for (auto* registration : *transientRegistry)
     2014                registration->observedSubtreeNodeWillDetach(this);
    20182015        }
    20192016    }
  • trunk/Source/WebCore/dom/NodeRareData.h

    r158665 r161096  
    229229
    230230        if (oldDocument != newDocument) {
    231             for (auto it = m_atomicNameCaches.begin(), end = m_atomicNameCaches.end(); it != end; ++it) {
    232                 LiveNodeList& list = *it->value;
    233                 oldDocument->unregisterNodeList(list);
    234                 newDocument->registerNodeList(list);
     231            for (auto* list : m_atomicNameCaches.values()) {
     232                oldDocument->unregisterNodeList(*list);
     233                newDocument->registerNodeList(*list);
    235234            }
    236235
    237             for (auto it = m_nameCaches.begin(), end = m_nameCaches.end(); it != end; ++it) {
    238                 LiveNodeList& list = *it->value;
    239                 oldDocument->unregisterNodeList(list);
    240                 newDocument->registerNodeList(list);
     236            for (auto* list : m_nameCaches.values()) {
     237                oldDocument->unregisterNodeList(*list);
     238                newDocument->registerNodeList(*list);
    241239            }
    242240
    243             for (auto it = m_tagNodeListCacheNS.begin(), end = m_tagNodeListCacheNS.end(); it != end; ++it) {
    244                 LiveNodeList& list = *it->value;
    245                 ASSERT(!list.isRootedAtDocument());
    246                 oldDocument->unregisterNodeList(list);
    247                 newDocument->registerNodeList(list);
     241            for (auto* list : m_tagNodeListCacheNS.values()) {
     242                ASSERT(!list->isRootedAtDocument());
     243                oldDocument->unregisterNodeList(*list);
     244                newDocument->registerNodeList(*list);
    248245            }
    249246
    250             for (auto it = m_cachedCollections.begin(), end = m_cachedCollections.end(); it != end; ++it) {
    251                 HTMLCollection& collection = *it->value;
    252                 oldDocument->unregisterCollection(collection);
    253                 newDocument->registerCollection(collection);
     247            for (auto collection : m_cachedCollections.values()) {
     248                oldDocument->unregisterCollection(*collection);
     249                newDocument->registerCollection(*collection);
    254250            }
    255251        }
  • trunk/Source/WebCore/dom/ScriptExecutionContext.cpp

    r160679 r161096  
    104104{
    105105    m_inDestructor = true;
    106     for (HashSet<ContextDestructionObserver*>::iterator iter = m_destructionObservers.begin(); iter != m_destructionObservers.end(); iter = m_destructionObservers.begin()) {
    107         ContextDestructionObserver* observer = *iter;
     106    for (auto* observer : m_destructionObservers) {
    108107        m_destructionObservers.remove(observer);
    109108        ASSERT(observer->scriptExecutionContext() == this);
     
    111110    }
    112111
    113     HashSet<MessagePort*>::iterator messagePortsEnd = m_messagePorts.end();
    114     for (HashSet<MessagePort*>::iterator iter = m_messagePorts.begin(); iter != messagePortsEnd; ++iter) {
    115         ASSERT((*iter)->scriptExecutionContext() == this);
    116         (*iter)->contextDestroyed();
     112    for (auto* port : m_messagePorts) {
     113        ASSERT(port->scriptExecutionContext() == this);
     114        port->contextDestroyed();
    117115    }
    118116#if ENABLE(BLOB)
     
    167165    // No protection against m_activeDOMObjects changing during iteration: canSuspend() shouldn't execute arbitrary JS.
    168166    m_iteratingActiveDOMObjects = true;
    169     ActiveDOMObjectsSet::iterator activeObjectsEnd = m_activeDOMObjects.end();
    170     for (ActiveDOMObjectsSet::iterator iter = m_activeDOMObjects.begin(); iter != activeObjectsEnd; ++iter) {
    171         ASSERT((*iter)->scriptExecutionContext() == this);
    172         ASSERT((*iter)->suspendIfNeededCalled());
    173         if (!(*iter)->canSuspend()) {
     167    for (auto* activeDOMObject : m_activeDOMObjects) {
     168        ASSERT(activeDOMObject->scriptExecutionContext() == this);
     169        ASSERT(activeDOMObject->suspendIfNeededCalled());
     170        if (!activeDOMObject->canSuspend()) {
    174171            m_iteratingActiveDOMObjects = false;
    175172            return false;
     
    191188    // No protection against m_activeDOMObjects changing during iteration: suspend() shouldn't execute arbitrary JS.
    192189    m_iteratingActiveDOMObjects = true;
    193     ActiveDOMObjectsSet::iterator activeObjectsEnd = m_activeDOMObjects.end();
    194     for (ActiveDOMObjectsSet::iterator iter = m_activeDOMObjects.begin(); iter != activeObjectsEnd; ++iter) {
    195         ASSERT((*iter)->scriptExecutionContext() == this);
    196         ASSERT((*iter)->suspendIfNeededCalled());
    197         (*iter)->suspend(why);
     190    for (auto* activeDOMObject : m_activeDOMObjects) {
     191        ASSERT(activeDOMObject->scriptExecutionContext() == this);
     192        ASSERT(activeDOMObject->suspendIfNeededCalled());
     193        activeDOMObject->suspend(why);
    198194    }
    199195    m_iteratingActiveDOMObjects = false;
     
    210206    // No protection against m_activeDOMObjects changing during iteration: resume() shouldn't execute arbitrary JS.
    211207    m_iteratingActiveDOMObjects = true;
    212     ActiveDOMObjectsSet::iterator activeObjectsEnd = m_activeDOMObjects.end();
    213     for (ActiveDOMObjectsSet::iterator iter = m_activeDOMObjects.begin(); iter != activeObjectsEnd; ++iter) {
    214         ASSERT((*iter)->scriptExecutionContext() == this);
    215         ASSERT((*iter)->suspendIfNeededCalled());
    216         (*iter)->resume();
     208    for (auto* activeDOMObject : m_activeDOMObjects) {
     209        ASSERT(activeDOMObject->scriptExecutionContext() == this);
     210        ASSERT(activeDOMObject->suspendIfNeededCalled());
     211        activeDOMObject->resume();
    217212    }
    218213    m_iteratingActiveDOMObjects = false;
     
    226221    // No protection against m_activeDOMObjects changing during iteration: stop() shouldn't execute arbitrary JS.
    227222    m_iteratingActiveDOMObjects = true;
    228     ActiveDOMObjectsSet::iterator activeObjectsEnd = m_activeDOMObjects.end();
    229     for (ActiveDOMObjectsSet::iterator iter = m_activeDOMObjects.begin(); iter != activeObjectsEnd; ++iter) {
    230         ASSERT((*iter)->scriptExecutionContext() == this);
    231         ASSERT((*iter)->suspendIfNeededCalled());
    232         (*iter)->stop();
     223    for (auto* activeDOMObject : m_activeDOMObjects) {
     224        ASSERT(activeDOMObject->scriptExecutionContext() == this);
     225        ASSERT(activeDOMObject->suspendIfNeededCalled());
     226        activeDOMObject->stop();
    233227    }
    234228    m_iteratingActiveDOMObjects = false;
     
    278272}
    279273
    280 void ScriptExecutionContext::closeMessagePorts() {
    281     HashSet<MessagePort*>::iterator messagePortsEnd = m_messagePorts.end();
    282     for (HashSet<MessagePort*>::iterator iter = m_messagePorts.begin(); iter != messagePortsEnd; ++iter) {
    283         ASSERT((*iter)->scriptExecutionContext() == this);
    284         (*iter)->close();
     274void ScriptExecutionContext::closeMessagePorts()
     275{
     276    for (auto* port : m_messagePorts) {
     277        ASSERT(port->scriptExecutionContext() == this);
     278        port->close();
    285279    }
    286280}
     
    374368{
    375369    if (minimumTimerInterval() != oldMinimumTimerInterval) {
    376         for (TimeoutMap::iterator iter = m_timeouts.begin(); iter != m_timeouts.end(); ++iter) {
    377             DOMTimer* timer = iter->value;
     370        for (auto* timer : m_timeouts.values())
    378371            timer->adjustMinimumTimerInterval(oldMinimumTimerInterval);
    379         }
    380372    }
    381373}
     
    393385void ScriptExecutionContext::didChangeTimerAlignmentInterval()
    394386{
    395     for (TimeoutMap::iterator iter = m_timeouts.begin(); iter != m_timeouts.end(); ++iter) {
    396         DOMTimer* timer = iter->value;
     387    for (auto* timer : m_timeouts.values())
    397388        timer->didChangeAlignmentInterval();
    398     }
    399389}
    400390
  • trunk/Source/WebCore/dom/WebKitNamedFlow.cpp

    r158569 r161096  
    131131
    132132    if (inFlowThread(contentNode->renderer(), m_parentFlowThread)) {
    133         const RenderRegionList& regionList = m_parentFlowThread->renderRegionList();
    134         for (auto iter = regionList.begin(), end = regionList.end(); iter != end; ++iter) {
     133        for (auto* region : m_parentFlowThread->renderRegionList()) {
    135134            // FIXME: Pseudo-elements are not included in the list.
    136135            // They will be included when we will properly support the Region interface
    137136            // http://dev.w3.org/csswg/css-regions/#the-region-interface
    138             const RenderNamedFlowFragment* renderRegion = toRenderNamedFlowFragment(*iter);
     137            const RenderNamedFlowFragment* renderRegion = toRenderNamedFlowFragment(region);
    139138            if (renderRegion->isPseudoElementRegion())
    140139                continue;
     
    160159
    161160    Vector<Ref<Element>> regionElements;
    162 
    163     const RenderRegionList& regionList = m_parentFlowThread->renderRegionList();
    164     for (auto iter = regionList.begin(), end = regionList.end(); iter != end; ++iter) {
     161    for (auto region : m_parentFlowThread->renderRegionList()) {
    165162        // FIXME: Pseudo-elements are not included in the list.
    166163        // They will be included when we will properly support the Region interface
    167164        // http://dev.w3.org/csswg/css-regions/#the-region-interface
    168         const RenderNamedFlowFragment* renderRegion = toRenderNamedFlowFragment(*iter);
     165        const RenderNamedFlowFragment* renderRegion = toRenderNamedFlowFragment(region);
    169166        if (renderRegion->isPseudoElementRegion())
    170167            continue;
     
    187184
    188185    Vector<Ref<Element>> contentElements;
    189 
    190     const NamedFlowContentElements& contentElementsList = m_parentFlowThread->contentElements();
    191     for (auto it = contentElementsList.begin(), end = contentElementsList.end(); it != end; ++it) {
    192         Element* element = *it;
     186    for (auto* element : m_parentFlowThread->contentElements()) {
    193187        ASSERT(element->computedStyle()->flowThread() == m_parentFlowThread->flowThreadName());
    194188        contentElements.append(*element);
Note: See TracChangeset for help on using the changeset viewer.