Use modern for-loops in WebCore/dom.
authorhs85.jeong@samsung.com <hs85.jeong@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Oct 2015 17:04:07 +0000 (17:04 +0000)
committerhs85.jeong@samsung.com <hs85.jeong@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Oct 2015 17:04:07 +0000 (17:04 +0000)
https://bugs.webkit.org/show_bug.cgi?id=150664

Reviewed by Darin Adler.

No new tests because there is no behavior change.

* dom/AuthorStyleSheets.cpp:
(WebCore::AuthorStyleSheets::analyzeStyleSheetChange):
(WebCore::filterEnabledNonemptyCSSStyleSheets):
(WebCore::AuthorStyleSheets::activeStyleSheetsContains):
* dom/CheckedRadioButtons.cpp:
(WebCore::RadioButtonGroup::updateValidityForAllButtons):
* dom/ClientRectList.cpp:
(WebCore::ClientRectList::ClientRectList):
(WebCore::ClientRectList::~ClientRectList):
* dom/ContainerNode.cpp:
(WebCore::ContainerNode::insertBefore):
* dom/DOMNamedFlowCollection.cpp:
(WebCore::DOMNamedFlowCollection::DOMNamedFlowCollection):
(WebCore::DOMNamedFlowCollection::length):
(WebCore::DOMNamedFlowCollection::item):
(WebCore::DOMNamedFlowCollection::namedItem):
* dom/DOMStringList.cpp:
(WebCore::DOMStringList::contains):
* dom/Document.cpp:
(WebCore::Document::Document):
(WebCore::Document::~Document):
(WebCore::Document::removedLastRef):
(WebCore::Document::adjustFloatQuadsForScrollAndAbsoluteZoomAndFrameScale):
(WebCore::Document::updateHoverActiveState):
* dom/DocumentMarkerController.cpp:
(WebCore::DocumentMarkerController::copyMarkers):
(WebCore::DocumentMarkerController::removeMarkers):
(WebCore::DocumentMarkerController::repaintMarkers):
(DocumentMarkerController::showMarkers):
* dom/ElementData.cpp:
(WebCore::UniqueElementData::findAttributeByName):
* dom/EventDispatcher.cpp:
(WebCore::EventPath::updateTouchLists):
(WebCore::EventPath::hasEventListeners):
* dom/EventListenerMap.cpp:
(WebCore::EventListenerMap::contains):
(WebCore::EventListenerMap::containsCapturing):
(WebCore::EventListenerMap::eventTypes):
(WebCore::EventListenerMap::add):
(WebCore::EventListenerMap::find):
(WebCore::copyListenersNotCreatedFromMarkupToTarget):
(WebCore::EventListenerMap::copyEventListenersNotCreatedFromMarkupToTarget):
(WebCore::EventListenerIterator::EventListenerIterator):
* dom/EventTarget.cpp:
(WebCore::EventTarget::removeEventListener):
(WebCore::EventTarget::getAttributeEventListener):
(WebCore::EventTarget::removeAllEventListeners):
* dom/IdTargetObserverRegistry.cpp:
(WebCore::IdTargetObserverRegistry::notifyObserversInternal):
* dom/MessagePort.cpp:
(WebCore::MessagePort::postMessage):
(WebCore::MessagePort::disentanglePorts):
* dom/MutationObserver.cpp:
(WebCore::MutationObserver::observe):
(WebCore::MutationObserver::deliver):
(WebCore::MutationObserver::deliverAllMutations):
* dom/NamedFlowCollection.cpp:
(WebCore::NamedFlowCollection::namedFlows):
(WebCore::NamedFlowCollection::createCSSOMSnapshot):
* dom/Node.cpp:
(WebCore::Node::notifyMutationObserversNodeWillDetach):
* dom/Range.cpp:
(WebCore::Range::processNodes):
(WebCore::Range::processAncestorsAndTheirSiblings):
(WebCore::Range::absoluteBoundingBox):
(WebCore::Range::collectSelectionRects):
* dom/ScriptRunner.cpp:
(WebCore::ScriptRunner::timerFired):
* dom/ScriptedAnimationController.cpp:
(WebCore::ScriptedAnimationController::serviceScriptedAnimations):
* dom/SelectorQuery.cpp:
(WebCore::SelectorDataList::matches):
(WebCore::SelectorDataList::executeFastPathForIdSelector):
(WebCore::SelectorDataList::executeSingleMultiSelectorData):
(WebCore::SelectorDataList::executeCompiledSingleMultiSelectorData):
(WebCore::SelectorDataList::execute):
* dom/TreeScopeAdopter.cpp:
(WebCore::TreeScopeAdopter::moveTreeToNewScope):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@191792 268f45cc-cd09-0410-ab3c-d52691b4dbfc

23 files changed:
Source/WebCore/ChangeLog
Source/WebCore/dom/AuthorStyleSheets.cpp
Source/WebCore/dom/CheckedRadioButtons.cpp
Source/WebCore/dom/ClientRectList.cpp
Source/WebCore/dom/ContainerNode.cpp
Source/WebCore/dom/DOMNamedFlowCollection.cpp
Source/WebCore/dom/DOMStringList.cpp
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/DocumentMarkerController.cpp
Source/WebCore/dom/ElementData.cpp
Source/WebCore/dom/EventDispatcher.cpp
Source/WebCore/dom/EventListenerMap.cpp
Source/WebCore/dom/EventTarget.cpp
Source/WebCore/dom/IdTargetObserverRegistry.cpp
Source/WebCore/dom/MessagePort.cpp
Source/WebCore/dom/MutationObserver.cpp
Source/WebCore/dom/NamedFlowCollection.cpp
Source/WebCore/dom/Node.cpp
Source/WebCore/dom/Range.cpp
Source/WebCore/dom/ScriptRunner.cpp
Source/WebCore/dom/ScriptedAnimationController.cpp
Source/WebCore/dom/SelectorQuery.cpp
Source/WebCore/dom/TreeScopeAdopter.cpp

index b194293ba1f2c966a73d228dc432c88433b810ea..a77ac88cc9c8dda85484c63761336707016aa354 100644 (file)
@@ -1,3 +1,91 @@
+2015-10-30  Hunseop Jeong  <hs85.jeong@samsung.com>
+
+        Use modern for-loops in WebCore/dom.
+        https://bugs.webkit.org/show_bug.cgi?id=150664
+
+        Reviewed by Darin Adler.
+
+        No new tests because there is no behavior change.
+
+        * dom/AuthorStyleSheets.cpp:
+        (WebCore::AuthorStyleSheets::analyzeStyleSheetChange):
+        (WebCore::filterEnabledNonemptyCSSStyleSheets):
+        (WebCore::AuthorStyleSheets::activeStyleSheetsContains):
+        * dom/CheckedRadioButtons.cpp:
+        (WebCore::RadioButtonGroup::updateValidityForAllButtons):
+        * dom/ClientRectList.cpp:
+        (WebCore::ClientRectList::ClientRectList):
+        (WebCore::ClientRectList::~ClientRectList):
+        * dom/ContainerNode.cpp:
+        (WebCore::ContainerNode::insertBefore):
+        * dom/DOMNamedFlowCollection.cpp:
+        (WebCore::DOMNamedFlowCollection::DOMNamedFlowCollection):
+        (WebCore::DOMNamedFlowCollection::length):
+        (WebCore::DOMNamedFlowCollection::item):
+        (WebCore::DOMNamedFlowCollection::namedItem):
+        * dom/DOMStringList.cpp:
+        (WebCore::DOMStringList::contains):
+        * dom/Document.cpp:
+        (WebCore::Document::Document):
+        (WebCore::Document::~Document):
+        (WebCore::Document::removedLastRef):
+        (WebCore::Document::adjustFloatQuadsForScrollAndAbsoluteZoomAndFrameScale):
+        (WebCore::Document::updateHoverActiveState):
+        * dom/DocumentMarkerController.cpp:
+        (WebCore::DocumentMarkerController::copyMarkers):
+        (WebCore::DocumentMarkerController::removeMarkers):
+        (WebCore::DocumentMarkerController::repaintMarkers):
+        (DocumentMarkerController::showMarkers):
+        * dom/ElementData.cpp:
+        (WebCore::UniqueElementData::findAttributeByName):
+        * dom/EventDispatcher.cpp:
+        (WebCore::EventPath::updateTouchLists):
+        (WebCore::EventPath::hasEventListeners):
+        * dom/EventListenerMap.cpp:
+        (WebCore::EventListenerMap::contains):
+        (WebCore::EventListenerMap::containsCapturing):
+        (WebCore::EventListenerMap::eventTypes):
+        (WebCore::EventListenerMap::add):
+        (WebCore::EventListenerMap::find):
+        (WebCore::copyListenersNotCreatedFromMarkupToTarget):
+        (WebCore::EventListenerMap::copyEventListenersNotCreatedFromMarkupToTarget):
+        (WebCore::EventListenerIterator::EventListenerIterator):
+        * dom/EventTarget.cpp:
+        (WebCore::EventTarget::removeEventListener):
+        (WebCore::EventTarget::getAttributeEventListener):
+        (WebCore::EventTarget::removeAllEventListeners):
+        * dom/IdTargetObserverRegistry.cpp:
+        (WebCore::IdTargetObserverRegistry::notifyObserversInternal):
+        * dom/MessagePort.cpp:
+        (WebCore::MessagePort::postMessage):
+        (WebCore::MessagePort::disentanglePorts):
+        * dom/MutationObserver.cpp:
+        (WebCore::MutationObserver::observe):
+        (WebCore::MutationObserver::deliver):
+        (WebCore::MutationObserver::deliverAllMutations):
+        * dom/NamedFlowCollection.cpp:
+        (WebCore::NamedFlowCollection::namedFlows):
+        (WebCore::NamedFlowCollection::createCSSOMSnapshot):
+        * dom/Node.cpp:
+        (WebCore::Node::notifyMutationObserversNodeWillDetach):
+        * dom/Range.cpp:
+        (WebCore::Range::processNodes):
+        (WebCore::Range::processAncestorsAndTheirSiblings):
+        (WebCore::Range::absoluteBoundingBox):
+        (WebCore::Range::collectSelectionRects):
+        * dom/ScriptRunner.cpp:
+        (WebCore::ScriptRunner::timerFired):
+        * dom/ScriptedAnimationController.cpp:
+        (WebCore::ScriptedAnimationController::serviceScriptedAnimations):
+        * dom/SelectorQuery.cpp:
+        (WebCore::SelectorDataList::matches):
+        (WebCore::SelectorDataList::executeFastPathForIdSelector):
+        (WebCore::SelectorDataList::executeSingleMultiSelectorData):
+        (WebCore::SelectorDataList::executeCompiledSingleMultiSelectorData):
+        (WebCore::SelectorDataList::execute):
+        * dom/TreeScopeAdopter.cpp:
+        (WebCore::TreeScopeAdopter::moveTreeToNewScope):
+
 2015-10-30  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         Make every port implement MainThreadSharedTimer instead of using global functions
index 7ecaeb3071b09c466774dfdae4bf8a014684a4d3..12d6a120b506ad0f846e29a60e1e350ecc338ea4 100644 (file)
@@ -218,8 +218,8 @@ AuthorStyleSheets::StyleResolverUpdateType AuthorStyleSheets::analyzeStyleSheetC
     // Stylesheets of <style> elements that @import stylesheets are active but loading. We need to trigger a full recalc when such loads are done.
     bool hasActiveLoadingStylesheet = false;
     unsigned newStylesheetCount = newStylesheets.size();
-    for (unsigned i = 0; i < newStylesheetCount; ++i) {
-        if (newStylesheets[i]->isLoading())
+    for (auto& sheet : newStylesheets) {
+        if (sheet->isLoading())
             hasActiveLoadingStylesheet = true;
     }
     if (m_hadActiveLoadingStylesheet && !hasActiveLoadingStylesheet) {
@@ -277,15 +277,15 @@ AuthorStyleSheets::StyleResolverUpdateType AuthorStyleSheets::analyzeStyleSheetC
 
 static void filterEnabledNonemptyCSSStyleSheets(Vector<RefPtr<CSSStyleSheet>>& result, const Vector<RefPtr<StyleSheet>>& sheets)
 {
-    for (unsigned i = 0; i < sheets.size(); ++i) {
-        if (!is<CSSStyleSheet>(*sheets[i]))
+    for (auto& sheet : sheets) {
+        if (!is<CSSStyleSheet>(*sheet))
             continue;
-        CSSStyleSheet& sheet = downcast<CSSStyleSheet>(*sheets[i]);
-        if (sheet.disabled())
+        CSSStyleSheet& styleSheet = downcast<CSSStyleSheet>(*sheet);
+        if (styleSheet.disabled())
             continue;
-        if (!sheet.length())
+        if (!styleSheet.length())
             continue;
-        result.append(&sheet);
+        result.append(&styleSheet);
     }
 }
 
@@ -387,8 +387,8 @@ bool AuthorStyleSheets::activeStyleSheetsContains(const CSSStyleSheet* sheet) co
 {
     if (!m_weakCopyOfActiveStyleSheetListForFastLookup) {
         m_weakCopyOfActiveStyleSheetListForFastLookup = std::make_unique<HashSet<const CSSStyleSheet*>>();
-        for (unsigned i = 0; i < m_activeStyleSheets.size(); ++i)
-            m_weakCopyOfActiveStyleSheetListForFastLookup->add(m_activeStyleSheets[i].get());
+        for (auto& activeStyleSheet : m_activeStyleSheets)
+            m_weakCopyOfActiveStyleSheetListForFastLookup->add(activeStyleSheet.get());
     }
     return m_weakCopyOfActiveStyleSheetListForFastLookup->contains(sheet);
 }
index df63f20650eccdefdda2ee601213471706e57466..8305a9e01b57d6f545d118f6577a73d4eb5fc754 100644 (file)
@@ -150,10 +150,7 @@ void RadioButtonGroup::remove(HTMLInputElement* button)
 
 void RadioButtonGroup::updateValidityForAllButtons()
 {
-    typedef HashSet<HTMLInputElement*>::const_iterator Iterator;
-    Iterator end = m_members.end();
-    for (Iterator it = m_members.begin(); it != end; ++it) {
-        HTMLInputElement* button = *it;
+    for (auto& button : m_members) {
         ASSERT(button->isRadioButton());
         button->updateValidity();
     }
index a057ddf3c6764158f3377ca1c8e5844f4137a0a0..a0ca625288567be754809fd4c7749455e00ecda9 100644 (file)
@@ -39,8 +39,8 @@ ClientRectList::ClientRectList()
 ClientRectList::ClientRectList(const Vector<FloatQuad>& quads)
 {
     m_list.reserveInitialCapacity(quads.size());
-    for (size_t i = 0; i < quads.size(); ++i)
-        m_list.append(ClientRect::create(quads[i].enclosingBoundingBox()));
+    for (auto& quad : quads)
+        m_list.uncheckedAppend(ClientRect::create(quad.enclosingBoundingBox()));
 }
 
 ClientRectList::~ClientRectList()
index 7c71c0b88a04a34e35619f1bf3c13b49eaef4af7..a1abb2eeb131a5643034d59337b9f7ba1a892e94 100644 (file)
@@ -272,19 +272,17 @@ bool ContainerNode::insertBefore(Ref<Node>&& newChild, Node* refChild, Exception
     InspectorInstrumentation::willInsertDOMNode(document(), *this);
 
     ChildListMutationScope mutation(*this);
-    for (auto it = targets.begin(), end = targets.end(); it != end; ++it) {
-        Node& child = it->get();
-
+    for (auto& child : targets) {
         // Due to arbitrary code running in response to a DOM mutation event it's
         // possible that "next" is no longer a child of "this".
         // It's also possible that "child" has been inserted elsewhere.
         // In either of those cases, we'll just stop.
         if (next->parentNode() != this)
             break;
-        if (child.parentNode())
+        if (child->parentNode())
             break;
 
-        treeScope().adoptIfNeeded(&child);
+        treeScope().adoptIfNeeded(child.ptr());
 
         insertBeforeCommon(next, child);
 
index e0b42cdfc717b793af771475771dca77461cb24e..9a3c3938083dd943035253f110add9b11167e572 100644 (file)
@@ -34,8 +34,8 @@ namespace WebCore {
 
 DOMNamedFlowCollection::DOMNamedFlowCollection(const Vector<WebKitNamedFlow*>& namedFlows)
 {
-    for (Vector<WebKitNamedFlow*>::const_iterator it = namedFlows.begin(); it != namedFlows.end(); ++it)
-        m_namedFlows.add(*it);
+    for (auto& flow : namedFlows)
+        m_namedFlows.add(flow);
 }
 
 unsigned long DOMNamedFlowCollection::length() const
@@ -47,7 +47,7 @@ PassRefPtr<WebKitNamedFlow> DOMNamedFlowCollection::item(unsigned long index) co
 {
     if (index >= static_cast<unsigned long>(m_namedFlows.size()))
         return nullptr;
-    DOMNamedFlowSet::const_iterator it = m_namedFlows.begin();
+    auto it = m_namedFlows.begin();
     for (unsigned long i = 0; i < index; ++i)
         ++it;
     return *it;
@@ -55,7 +55,7 @@ PassRefPtr<WebKitNamedFlow> DOMNamedFlowCollection::item(unsigned long index) co
 
 RefPtr<WebKitNamedFlow> DOMNamedFlowCollection::namedItem(const AtomicString& name) const
 {
-    DOMNamedFlowSet::const_iterator it = m_namedFlows.find<String, DOMNamedFlowHashTranslator>(name);
+    auto it = m_namedFlows.find<String, DOMNamedFlowHashTranslator>(name);
     if (it != m_namedFlows.end())
         return *it;
     return nullptr;
index bcc0d23ba307ba3caf59e08783bad41e0ed8f2c5..8826b9344da4d68e418c176fe101d0fd48552b8e 100644 (file)
@@ -40,9 +40,8 @@ bool DOMStringList::contains(const String& string) const
     // FIXME: Currently, all consumers of DOMStringList store fairly small lists and thus an O(n)
     //        algorithm is OK.  But this may need to be optimized if larger amounts of data are
     //        stored in m_strings.
-    size_t count = m_strings.size();
-    for (size_t i = 0; i < count; ++i) {
-        if (m_strings[i] == string)
+    for (auto& value : m_strings) {
+        if (value == string)
             return true;
     }
     return false;
index 2cf223bfe46817a1b8168f4b5fcc9bcf27ad963a..8c10d0e94c01b7078bd1120b67445f64668b5a9c 100644 (file)
@@ -557,8 +557,8 @@ Document::Document(Frame* frame, const URL& url, unsigned documentClasses, unsig
     initSecurityContext();
     initDNSPrefetch();
 
-    for (unsigned i = 0; i < WTF_ARRAY_LENGTH(m_nodeListAndCollectionCounts); ++i)
-        m_nodeListAndCollectionCounts[i] = 0;
+    for (auto& nodeListAndCollectionCount : m_nodeListAndCollectionCounts)
+        nodeListAndCollectionCount = 0;
 }
 
 #if ENABLE(FULLSCREEN_API)
@@ -6317,12 +6317,12 @@ void Document::adjustFloatQuadsForScrollAndAbsoluteZoomAndFrameScale(Vector<Floa
         inverseFrameScale = 1 / frame()->frameScaleFactor();
 
     LayoutRect visibleContentRect = view()->visibleContentRect();
-    for (size_t i = 0; i < quads.size(); ++i) {
-        quads[i].move(-visibleContentRect.x(), -visibleContentRect.y());
+    for (auto& quad : quads) {
+        quad.move(-visibleContentRect.x(), -visibleContentRect.y());
         if (zoom != 1)
-            quads[i].scale(1 / zoom, 1 / zoom);
+            quad.scale(1 / zoom, 1 / zoom);
         if (inverseFrameScale != 1)
-            quads[i].scale(inverseFrameScale, inverseFrameScale);
+            quad.scale(inverseFrameScale, inverseFrameScale);
     }
 }
 
@@ -6478,19 +6478,18 @@ void Document::updateHoverActiveState(const HitTestRequest& request, Element* in
             elementsToAddToChain.append(element);
     }
 
-    size_t removeCount = elementsToRemoveFromChain.size();
-    for (size_t i = 0; i < removeCount; ++i)
-        elementsToRemoveFromChain[i]->setHovered(false);
+    for (auto& element : elementsToRemoveFromChain)
+        element->setHovered(false);
 
     bool sawCommonAncestor = false;
-    for (size_t i = 0, size = elementsToAddToChain.size(); i < size; ++i) {
+    for (auto& element : elementsToAddToChain) {
         if (allowActiveChanges)
-            elementsToAddToChain[i]->setActive(true);
-        if (ancestor && elementsToAddToChain[i] == ancestor->element())
+            element->setActive(true);
+        if (ancestor && element == ancestor->element())
             sawCommonAncestor = true;
         if (!sawCommonAncestor) {
             // Elements after the common hover ancestor does not change hover state, but are iterated over because they may change active state.
-            elementsToAddToChain[i]->setHovered(true);
+            element->setHovered(true);
         }
     }
 
index 9695e6303374622cc34eaf9afd7e298b14e98511..9d4b652b5da886c3eb2edf9f5aca4d9be4b204e1 100644 (file)
@@ -390,9 +390,7 @@ void DocumentMarkerController::copyMarkers(Node* srcNode, unsigned startOffset,
 
     bool docDirty = false;
     unsigned endOffset = startOffset + length - 1;
-    for (size_t i = 0; i != list->size(); ++i) {
-        DocumentMarker marker = list->at(i);
-
+    for (auto& marker : *list) {
         // stop if we are now past the specified range
         if (marker.startOffset() > endOffset)
             break;
@@ -561,9 +559,8 @@ void DocumentMarkerController::removeMarkers(DocumentMarker::MarkerTypes markerT
 
     Vector<RefPtr<Node>> nodesWithMarkers;
     copyKeysToVector(m_markers, nodesWithMarkers);
-    unsigned size = nodesWithMarkers.size();
-    for (unsigned i = 0; i < size; ++i) {
-        MarkerMap::iterator iterator = m_markers.find(nodesWithMarkers[i]);
+    for (auto& node : nodesWithMarkers) {
+        auto iterator = m_markers.find(node);
         if (iterator != m_markers.end())
             removeMarkersFromList(iterator, markerTypes);
     }
@@ -619,15 +616,13 @@ void DocumentMarkerController::repaintMarkers(DocumentMarker::MarkerTypes marker
     ASSERT(!m_markers.isEmpty());
 
     // outer loop: process each markered node in the document
-    MarkerMap::iterator end = m_markers.end();
-    for (MarkerMap::iterator i = m_markers.begin(); i != end; ++i) {
-        Node* node = i->key.get();
+    for (auto& marker : m_markers) {
+        Node* node = marker.key.get();
 
         // inner loop: process each marker in the current node
-        MarkerList* list = i->value.get();
         bool nodeNeedsRepaint = false;
-        for (auto& marker : *list) {
-            if (markerTypes.contains(marker.type())) {
+        for (auto& documentMarker : *marker.value) {
+            if (markerTypes.contains(documentMarker.type())) {
                 nodeNeedsRepaint = true;
                 break;
             }
@@ -798,15 +793,11 @@ void DocumentMarkerController::clearDescriptionOnMarkersIntersectingRange(Range*
 void DocumentMarkerController::showMarkers() const
 {
     fprintf(stderr, "%d nodes have markers:\n", m_markers.size());
-    MarkerMap::const_iterator end = m_markers.end();
-    for (MarkerMap::const_iterator nodeIterator = m_markers.begin(); nodeIterator != end; ++nodeIterator) {
-        Node* node = nodeIterator->key.get();
+    for (auto& marker : m_markers) {
+        Node* node = marker.key.get();
         fprintf(stderr, "%p", node);
-        MarkerList* list = nodeIterator->value.get();
-        for (unsigned markerIndex = 0; markerIndex < list->size(); ++markerIndex) {
-            const DocumentMarker& marker = list->at(markerIndex);
-            fprintf(stderr, " %d:[%d:%d](%d)", marker.type(), marker.startOffset(), marker.endOffset(), marker.activeMatch());
-        }
+        for (auto& documentMarker : *marker.value)
+            fprintf(stderr, " %d:[%d:%d](%d)", documentMarker.type(), documentMarker.startOffset(), documentMarker.endOffset(), documentMarker.activeMatch());
 
         fprintf(stderr, "\n");
     }
index d6357c183bbb7116c3c0fa44032ca96b0985eec8..4b9ebf8894819d4e3d2aba6cfc4b1665d187f26f 100644 (file)
@@ -180,9 +180,9 @@ bool ElementData::isEquivalent(const ElementData* other) const
 
 Attribute* UniqueElementData::findAttributeByName(const QualifiedName& name)
 {
-    for (unsigned i = 0, count = m_attributeVector.size(); i < count; ++i) {
-        if (m_attributeVector.at(i).name().matches(name))
-            return &m_attributeVector.at(i);
+    for (auto& attribute : m_attributeVector) {
+        if (attribute.name().matches(name))
+            return &attribute;
     }
     return nullptr;
 }
index b54f82bea2322fae99b02a140c912961dd118d81..28e3a491dd0fc60429f1575aaa7ec71b30a367ed 100644 (file)
@@ -484,9 +484,8 @@ bool EventPath::updateTouchLists(const TouchEvent& touchEvent)
     addRelatedNodeResolversForTouchList(touchTargetResolvers, touchEvent.changedTouches(), TouchEventContext::ChangedTouches);
 
     ASSERT(touchTargetResolvers.size() == touchNodeCount);
-    size_t eventPathSize = m_path.size();
-    for (size_t i = 0; i < eventPathSize; ++i) {
-        TouchEventContext& context = toTouchEventContext(*m_path[i]);
+    for (auto& eventPath : m_path) {
+        TouchEventContext& context = toTouchEventContext(*eventPath);
         Node& nodeToMoveTo = *context.node();
         for (size_t resolverIndex = 0; resolverIndex < touchNodeCount; ++resolverIndex) {
             EventRelatedNodeResolver& currentResolver = touchTargetResolvers[resolverIndex];
@@ -667,8 +666,8 @@ void EventPath::setRelatedTarget(Node& origin, EventTarget& relatedTarget)
 
 bool EventPath::hasEventListeners(const AtomicString& eventType) const
 {
-    for (size_t i = 0; i < m_path.size(); i++) {
-        if (m_path[i]->node()->hasEventListeners(eventType))
+    for (auto& eventPath : m_path) {
+        if (eventPath->node()->hasEventListeners(eventType))
             return true;
     }
 
index dbb19e4933c5eff40f94711d7f6e6dc64ba20bb7..36b7724afe1c80283d59c6a02e03cee16e807b68 100644 (file)
@@ -57,8 +57,8 @@ EventListenerMap::EventListenerMap()
 
 bool EventListenerMap::contains(const AtomicString& eventType) const
 {
-    for (unsigned i = 0; i < m_entries.size(); ++i) {
-        if (m_entries[i].first == eventType)
+    for (auto& entry : m_entries) {
+        if (entry.first == eventType)
             return true;
     }
     return false;
@@ -66,11 +66,10 @@ bool EventListenerMap::contains(const AtomicString& eventType) const
 
 bool EventListenerMap::containsCapturing(const AtomicString& eventType) const
 {
-    for (unsigned i = 0; i < m_entries.size(); ++i) {
-        if (m_entries[i].first == eventType) {
-            const EventListenerVector* vector = m_entries[i].second.get();
-            for (unsigned j = 0; j < vector->size(); ++j) {
-                if (vector->at(j).useCapture)
+    for (auto& entry : m_entries) {
+        if (entry.first == eventType) {
+            for (auto& eventListener : *entry.second) {
+                if (eventListener.useCapture)
                     return true;
             }
         }
@@ -90,8 +89,8 @@ Vector<AtomicString> EventListenerMap::eventTypes() const
     Vector<AtomicString> types;
     types.reserveInitialCapacity(m_entries.size());
 
-    for (unsigned i = 0; i < m_entries.size(); ++i)
-        types.uncheckedAppend(m_entries[i].first);
+    for (auto& entry : m_entries)
+        types.uncheckedAppend(entry.first);
 
     return types;
 }
@@ -111,9 +110,9 @@ bool EventListenerMap::add(const AtomicString& eventType, PassRefPtr<EventListen
 {
     assertNoActiveIterators();
 
-    for (unsigned i = 0; i < m_entries.size(); ++i) {
-        if (m_entries[i].first == eventType)
-            return addListenerToVector(m_entries[i].second.get(), listener, useCapture);
+    for (auto& entry : m_entries) {
+        if (entry.first == eventType)
+            return addListenerToVector(entry.second.get(), listener, useCapture);
     }
 
     m_entries.append(std::make_pair(eventType, std::make_unique<EventListenerVector>()));
@@ -150,9 +149,9 @@ EventListenerVector* EventListenerMap::find(const AtomicString& eventType)
 {
     assertNoActiveIterators();
 
-    for (unsigned i = 0; i < m_entries.size(); ++i) {
-        if (m_entries[i].first == eventType)
-            return m_entries[i].second.get();
+    for (auto& entry : m_entries) {
+        if (entry.first == eventType)
+            return entry.second.get();
     }
 
     return nullptr;
@@ -182,11 +181,11 @@ void EventListenerMap::removeFirstEventListenerCreatedFromMarkup(const AtomicStr
 
 static void copyListenersNotCreatedFromMarkupToTarget(const AtomicString& eventType, EventListenerVector* listenerVector, EventTarget* target)
 {
-    for (size_t i = 0; i < listenerVector->size(); ++i) {
+    for (auto& listener : *listenerVector) {
         // Event listeners created from markup have already been transfered to the shadow tree during cloning.
-        if ((*listenerVector)[i].listener->wasCreatedFromMarkup())
+        if (listener.listener->wasCreatedFromMarkup())
             continue;
-        target->addEventListener(eventType, (*listenerVector)[i].listener.copyRef(), (*listenerVector)[i].useCapture);
+        target->addEventListener(eventType, listener.listener.copyRef(), listener.useCapture);
     }
 }
 
@@ -194,8 +193,8 @@ void EventListenerMap::copyEventListenersNotCreatedFromMarkupToTarget(EventTarge
 {
     assertNoActiveIterators();
 
-    for (unsigned i = 0; i < m_entries.size(); ++i)
-        copyListenersNotCreatedFromMarkupToTarget(m_entries[i].first, m_entries[i].second.get(), target);
+    for (auto& entry : m_entries)
+        copyListenersNotCreatedFromMarkupToTarget(entry.first, entry.second.get(), target);
 }
 
 EventListenerIterator::EventListenerIterator()
index 4ef19f2b61326d43a9264cae54e624dbd7d3375e..cfc4a3afed6580a698821c8461147a002666b0de 100644 (file)
@@ -94,8 +94,7 @@ bool EventTarget::removeEventListener(const AtomicString& eventType, EventListen
     // they have one less listener to invoke.
     if (!d->firingEventIterators)
         return true;
-    for (size_t i = 0; i < d->firingEventIterators->size(); ++i) {
-        FiringEventIterator& firingIterator = d->firingEventIterators->at(i);
+    for (auto& firingIterator : *d->firingEventIterators) {
         if (eventType != firingIterator.eventType)
             continue;
 
@@ -120,10 +119,9 @@ bool EventTarget::setAttributeEventListener(const AtomicString& eventType, PassR
 
 EventListener* EventTarget::getAttributeEventListener(const AtomicString& eventType)
 {
-    const EventListenerVector& entry = getEventListeners(eventType);
-    for (size_t i = 0; i < entry.size(); ++i) {
-        if (entry[i].listener->isAttribute())
-            return entry[i].listener.get();
+    for (auto& eventListener : getEventListeners(eventType)) {
+        if (eventListener.listener->isAttribute())
+            return eventListener.listener.get();
     }
     return 0;
 }
@@ -280,9 +278,9 @@ void EventTarget::removeAllEventListeners()
     // Notify firing events planning to invoke the listener at 'index' that
     // they have one less listener to invoke.
     if (d->firingEventIterators) {
-        for (size_t i = 0; i < d->firingEventIterators->size(); ++i) {
-            d->firingEventIterators->at(i).iterator = 0;
-            d->firingEventIterators->at(i).size = 0;
+        for (auto& firingEventIterator : *d->firingEventIterators) {
+            firingEventIterator.iterator = 0;
+            firingEventIterator.size = 0;
         }
     }
 }
index b3d6fd43b8c5b8b1f7fbcfdeac35de00b5e47e41..bf7e54a8ceb0645d1176fcf32480be944970b336 100644 (file)
@@ -65,15 +65,15 @@ void IdTargetObserverRegistry::notifyObserversInternal(const AtomicStringImpl& i
 
     Vector<IdTargetObserver*> copy;
     copyToVector(*m_notifyingObserversInSet, copy);
-    for (Vector<IdTargetObserver*>::const_iterator it = copy.begin(); it != copy.end(); ++it) {
-        if (m_notifyingObserversInSet->contains(*it))
-            (*it)->idTargetChanged();
+    for (auto& observer : copy) {
+        if (m_notifyingObserversInSet->contains(observer))
+            observer->idTargetChanged();
     }
 
     if (m_notifyingObserversInSet->isEmpty())
         m_registry.remove(&id);
 
-    m_notifyingObserversInSet = 0;
+    m_notifyingObserversInSet = nullptr;
 }
 
 } // namespace WebCore
index 25245451e596b3aa98c79bf7fc62d2b46df8e253..8af307fdc1ac8d0501a90359e8f2f39afab5df80 100644 (file)
@@ -69,9 +69,8 @@ void MessagePort::postMessage(PassRefPtr<SerializedScriptValue> message, const M
     std::unique_ptr<MessagePortChannelArray> channels;
     // Make sure we aren't connected to any of the passed-in ports.
     if (ports) {
-        for (unsigned int i = 0; i < ports->size(); ++i) {
-            MessagePort* dataPort = (*ports)[i].get();
-            if (dataPort == this || m_entangledChannel->isConnectedTo(dataPort)) {
+        for (auto& dataPort : *ports) {
+            if (dataPort == this || m_entangledChannel->isConnectedTo(dataPort.get())) {
                 ec = DATA_CLONE_ERR;
                 return;
             }
@@ -192,13 +191,12 @@ std::unique_ptr<MessagePortChannelArray> MessagePort::disentanglePorts(const Mes
     HashSet<MessagePort*> portSet;
 
     // Walk the incoming array - if there are any duplicate ports, or null ports or cloned ports, throw an error (per section 8.3.3 of the HTML5 spec).
-    for (unsigned int i = 0; i < ports->size(); ++i) {
-        MessagePort* port = (*ports)[i].get();
-        if (!port || port->isNeutered() || portSet.contains(port)) {
+    for (auto& port : *ports) {
+        if (!port || port->isNeutered() || portSet.contains(port.get())) {
             ec = DATA_CLONE_ERR;
             return nullptr;
         }
-        portSet.add(port);
+        portSet.add(port.get());
     }
 
     // Passed-in ports passed validity checks, so we can disentangle them.
index d2023a8ef068b9cdd74cd9d3766555f30bb5bc74..a0c04deb535f15f01626beed67a8193e6d50c740 100644 (file)
@@ -88,9 +88,9 @@ void MutationObserver::observe(Node* node, const Dictionary& optionsDictionary,
     };
     MutationObserverOptions options = 0;
     bool value = false;
-    for (unsigned i = 0; i < sizeof(booleanOptions) / sizeof(booleanOptions[0]); ++i) {
-        if (optionsDictionary.get(booleanOptions[i].name, value) && value)
-            options |= booleanOptions[i].value;
+    for (auto& booleanOption : booleanOptions) {
+        if (optionsDictionary.get(booleanOption.name, value) && value)
+            options |= booleanOption.value;
     }
 
     HashSet<AtomicString> attributeFilter;
@@ -191,8 +191,8 @@ void MutationObserver::deliver()
         if (registration->hasTransientRegistrations())
             transientRegistrations.append(registration);
     }
-    for (size_t i = 0; i < transientRegistrations.size(); ++i)
-        transientRegistrations[i]->clearTransientRegistrations();
+    for (auto& registration : transientRegistrations)
+        registration->clearTransientRegistrations();
 
     if (m_records.isEmpty())
         return;
@@ -214,12 +214,12 @@ void MutationObserver::deliverAllMutations()
     if (!suspendedMutationObservers().isEmpty()) {
         Vector<RefPtr<MutationObserver>> suspended;
         copyToVector(suspendedMutationObservers(), suspended);
-        for (size_t i = 0; i < suspended.size(); ++i) {
-            if (!suspended[i]->canDeliver())
+        for (auto& observer : suspended) {
+            if (!observer->canDeliver())
                 continue;
 
-            suspendedMutationObservers().remove(suspended[i]);
-            activeMutationObservers().add(suspended[i]);
+            suspendedMutationObservers().remove(observer);
+            activeMutationObservers().add(observer);
         }
     }
 
@@ -231,11 +231,11 @@ void MutationObserver::deliverAllMutations()
             return lhs->m_priority < rhs->m_priority;
         });
 
-        for (size_t i = 0; i < observers.size(); ++i) {
-            if (observers[i]->canDeliver())
-                observers[i]->deliver();
+        for (auto& observer : observers) {
+            if (observer->canDeliver())
+                observer->deliver();
             else
-                suspendedMutationObservers().add(observers[i]);
+                suspendedMutationObservers().add(observer);
         }
     }
 
index 622797ceb17e2d4b325602ab30d723ea2ec96445..1a14db4284a1c6bbd2ee390c5142b9e6a2da46b8 100644 (file)
@@ -47,11 +47,11 @@ Vector<RefPtr<WebKitNamedFlow>> NamedFlowCollection::namedFlows()
 {
     Vector<RefPtr<WebKitNamedFlow>> namedFlows;
 
-    for (NamedFlowSet::iterator it = m_namedFlows.begin(); it != m_namedFlows.end(); ++it) {
-        if ((*it)->flowState() == WebKitNamedFlow::FlowStateNull)
+    for (auto& namedFlow : m_namedFlows) {
+        if (namedFlow->flowState() == WebKitNamedFlow::FlowStateNull)
             continue;
 
-        namedFlows.append(RefPtr<WebKitNamedFlow>(*it));
+        namedFlows.append(RefPtr<WebKitNamedFlow>(namedFlow));
     }
 
     return namedFlows;
@@ -107,9 +107,10 @@ Document* NamedFlowCollection::document() const
 PassRefPtr<DOMNamedFlowCollection> NamedFlowCollection::createCSSOMSnapshot()
 {
     Vector<WebKitNamedFlow*> createdFlows;
-    for (NamedFlowSet::iterator it = m_namedFlows.begin(); it != m_namedFlows.end(); ++it)
-        if ((*it)->flowState() == WebKitNamedFlow::FlowStateCreated)
-            createdFlows.append(*it);
+    for (auto& namedFlow : m_namedFlows) {
+        if (namedFlow->flowState() == WebKitNamedFlow::FlowStateCreated)
+            createdFlows.append(namedFlow);
+    }
     return DOMNamedFlowCollection::create(createdFlows);
 }
 
index 6a5c2c0f7c211b66dc15d3ba470f8e5981ab05ae..1ff1217b8cfde8a89281522fd639a2883e435ecc 100644 (file)
@@ -2074,9 +2074,8 @@ void Node::notifyMutationObserversNodeWillDetach()
 
     for (Node* node = parentNode(); node; node = node->parentNode()) {
         if (auto* registry = node->mutationObserverRegistry()) {
-            const size_t size = registry->size();
-            for (size_t i = 0; i < size; ++i)
-                registry->at(i)->observedSubtreeNodeWillDetach(this);
+            for (auto& registration : *registry)
+                registration->observedSubtreeNodeWillDetach(this);
         }
 
         if (auto* transientRegistry = node->transientMutationObserverRegistry()) {
index d90cb38c811afef38a01049aefda723622d1cf7b..60ef8521b01a305b56333ba5aa6bb1ad690a8a0e 100644 (file)
@@ -755,16 +755,16 @@ RefPtr<Node> Range::processContentsBetweenOffsets(ActionType action, PassRefPtr<
 
 void Range::processNodes(ActionType action, Vector<RefPtr<Node>>& nodes, PassRefPtr<Node> oldContainer, PassRefPtr<Node> newContainer, ExceptionCode& ec)
 {
-    for (unsigned i = 0; i < nodes.size(); i++) {
+    for (auto& node : nodes) {
         switch (action) {
         case Delete:
-            oldContainer->removeChild(nodes[i].get(), ec);
+            oldContainer->removeChild(node.get(), ec);
             break;
         case Extract:
-            newContainer->appendChild(nodes[i].release(), ec); // will remove n from its parent
+            newContainer->appendChild(node.release(), ec); // will remove n from its parent
             break;
         case Clone:
-            newContainer->appendChild(nodes[i]->cloneNode(true), ec);
+            newContainer->appendChild(node->cloneNode(true), ec);
             break;
         }
     }
@@ -780,8 +780,7 @@ RefPtr<Node> Range::processAncestorsAndTheirSiblings(ActionType action, Node* co
         ancestors.append(n);
 
     RefPtr<Node> firstChildInAncestorToProcess = direction == ProcessContentsForward ? container->nextSibling() : container->previousSibling();
-    for (Vector<RefPtr<Node>>::const_iterator it = ancestors.begin(); it != ancestors.end(); ++it) {
-        RefPtr<Node> ancestor = *it;
+    for (auto& ancestor : ancestors) {
         if (action == Extract || action == Clone) {
             if (RefPtr<Node> clonedAncestor = ancestor->cloneNode(false)) { // Might have been removed already during mutation event.
                 clonedAncestor->appendChild(clonedContainer, ec);
@@ -799,17 +798,16 @@ RefPtr<Node> Range::processAncestorsAndTheirSiblings(ActionType action, Node* co
             child = (direction == ProcessContentsForward) ? child->nextSibling() : child->previousSibling())
             nodes.append(child);
 
-        for (NodeVector::const_iterator it = nodes.begin(); it != nodes.end(); ++it) {
-            Node* child = it->get();
+        for (auto& child : nodes) {
             switch (action) {
             case Delete:
-                ancestor->removeChild(child, ec);
+                ancestor->removeChild(child.get(), ec);
                 break;
             case Extract: // will remove child from ancestor
                 if (direction == ProcessContentsForward)
-                    clonedContainer->appendChild(child, ec);
+                    clonedContainer->appendChild(child.get(), ec);
                 else
-                    clonedContainer->insertBefore(child, clonedContainer->firstChild(), ec);
+                    clonedContainer->insertBefore(child.get(), clonedContainer->firstChild(), ec);
                 break;
             case Clone:
                 if (direction == ProcessContentsForward)
@@ -1182,9 +1180,8 @@ IntRect Range::absoluteBoundingBox() const
     IntRect result;
     Vector<IntRect> rects;
     absoluteTextRects(rects);
-    const size_t n = rects.size();
-    for (size_t i = 0; i < n; ++i)
-        result.unite(rects[i]);
+    for (auto& rect : rects)
+        result.unite(rect);
     return result;
 }
 
@@ -1316,15 +1313,13 @@ void Range::collectSelectionRects(Vector<SelectionRect>& rects)
             int beginSelectionOffset = isStartNode ? startOffset : 0;
             int endSelectionOffset = isEndNode ? endOffset : std::numeric_limits<int>::max();
             renderer->collectSelectionRects(newRects, beginSelectionOffset, endSelectionOffset);
-            size_t numberOfNewRects = newRects.size();
-            for (size_t i = 0; i < numberOfNewRects; ++i) {
-                SelectionRect& selectionRect = newRects[i];
+            for (auto& selectionRect : newRects) {
                 if (selectionRect.containsStart() && !isStartNode)
                     selectionRect.setContainsStart(false);
                 if (selectionRect.containsEnd() && !isEndNode)
                     selectionRect.setContainsEnd(false);
                 if (selectionRect.logicalWidth() || selectionRect.logicalHeight())
-                    rects.append(newRects[i]);
+                    rects.append(selectionRect);
             }
             newRects.shrink(0);
         }
index 96369804ad8f074bd736afbfb502a45fc9157601..01bdf85240f0540bebb7a6ef7078ee1180d19b40 100644 (file)
@@ -110,10 +110,9 @@ void ScriptRunner::timerFired()
     if (numInOrderScriptsToExecute)
         m_scriptsToExecuteInOrder.remove(0, numInOrderScriptsToExecute);
 
-    size_t size = scripts.size();
-    for (size_t i = 0; i < size; ++i) {
-        CachedScript* cachedScript = scripts[i].cachedScript();
-        RefPtr<Element> element = scripts[i].releaseElementAndClear();
+    for (auto& script : scripts) {
+        CachedScript* cachedScript = script.cachedScript();
+        RefPtr<Element> element = script.releaseElementAndClear();
         ASSERT(element);
         // Paper over https://bugs.webkit.org/show_bug.cgi?id=144050
         if (!element)
index 1b39bf16e03503ac3c237f44b3f5fefa5686ee62..fb294514d16652de5ff0358bf1922d53b26ca188 100644 (file)
@@ -149,8 +149,7 @@ void ScriptedAnimationController::serviceScriptedAnimations(double monotonicTime
     // reference to us, so take a defensive reference.
     Ref<ScriptedAnimationController> protect(*this);
 
-    for (size_t i = 0; i < callbacks.size(); ++i) {
-        RequestAnimationFrameCallback* callback = callbacks[i].get();
+    for (auto& callback : callbacks) {
         if (!callback->m_firedOrCancelled) {
             callback->m_firedOrCancelled = true;
             InspectorInstrumentationCookie cookie = InspectorInstrumentation::willFireAnimationFrame(m_document, callback->m_id);
index 1d17c30541dde81257ec15a222de785af7803c66..d7ca84f0a0ddd1dbfe125ba2e52154f07482d431 100644 (file)
@@ -135,9 +135,8 @@ inline Element* SelectorDataList::selectorClosest(const SelectorData& selectorDa
 
 bool SelectorDataList::matches(Element& targetElement) const
 {
-    unsigned selectorCount = m_selectors.size();
-    for (unsigned i = 0; i < selectorCount; ++i) {
-        if (selectorMatches(m_selectors[i], targetElement, targetElement))
+    for (auto& selctor : m_selectors) {
+        if (selectorMatches(selctor, targetElement, targetElement))
             return true;
     }
     return false;
@@ -220,12 +219,10 @@ ALWAYS_INLINE void SelectorDataList::executeFastPathForIdSelector(const Containe
     if (UNLIKELY(rootNode.treeScope().containsMultipleElementsWithId(idToMatch))) {
         const Vector<Element*>* elements = rootNode.treeScope().getAllElementsById(idToMatch);
         ASSERT(elements);
-        size_t count = elements->size();
         bool rootNodeIsTreeScopeRoot = isTreeScopeRoot(rootNode);
-        for (size_t i = 0; i < count; ++i) {
-            Element& element = *elements->at(i);
-            if ((rootNodeIsTreeScopeRoot || element.isDescendantOf(&rootNode)) && selectorMatches(selectorData, element, rootNode)) {
-                SelectorQueryTrait::appendOutputForElement(output, &element);
+        for (auto& element : *elements) {
+            if ((rootNodeIsTreeScopeRoot || element->isDescendantOf(&rootNode)) && selectorMatches(selectorData, *element, rootNode)) {
+                SelectorQueryTrait::appendOutputForElement(output, element);
                 if (SelectorQueryTrait::shouldOnlyMatchFirstElement)
                     return;
             }
@@ -385,10 +382,9 @@ ALWAYS_INLINE void SelectorDataList::executeSingleSelectorData(const ContainerNo
 template <typename SelectorQueryTrait>
 ALWAYS_INLINE void SelectorDataList::executeSingleMultiSelectorData(const ContainerNode& rootNode, typename SelectorQueryTrait::OutputType& output) const
 {
-    unsigned selectorCount = m_selectors.size();
     for (auto& element : elementDescendants(const_cast<ContainerNode&>(rootNode))) {
-        for (unsigned i = 0; i < selectorCount; ++i) {
-            if (selectorMatches(m_selectors[i], element, rootNode)) {
+        for (auto& selector : m_selectors) {
+            if (selectorMatches(selector, element, rootNode)) {
                 SelectorQueryTrait::appendOutputForElement(output, &element);
                 if (SelectorQueryTrait::shouldOnlyMatchFirstElement)
                     return;
@@ -441,20 +437,19 @@ ALWAYS_INLINE void SelectorDataList::executeCompiledSingleMultiSelectorData(cons
 {
     SelectorChecker::CheckingContext checkingContext(SelectorChecker::Mode::QueryingRules);
     checkingContext.scope = rootNode.isDocumentNode() ? nullptr : &rootNode;
-    unsigned selectorCount = m_selectors.size();
     for (auto& element : elementDescendants(const_cast<ContainerNode&>(rootNode))) {
-        for (unsigned i = 0; i < selectorCount; ++i) {
+        for (auto& selector : m_selectors) {
 #if CSS_SELECTOR_JIT_PROFILING
-            m_selectors[i].compiledSelectorUsed();
+            selector.compiledSelectorUsed();
 #endif
             bool matched = false;
-            void* compiledSelectorChecker = m_selectors[i].compiledSelectorCodeRef.code().executableAddress();
-            if (m_selectors[i].compilationStatus == SelectorCompilationStatus::SimpleSelectorChecker) {
-                SelectorCompiler::QuerySelectorSimpleSelectorChecker selectorChecker = SelectorCompiler::querySelectorSimpleSelectorCheckerFunction(compiledSelectorChecker, m_selectors[i].compilationStatus);
+            void* compiledSelectorChecker = selector.compiledSelectorCodeRef.code().executableAddress();
+            if (selector.compilationStatus == SelectorCompilationStatus::SimpleSelectorChecker) {
+                auto selectorChecker = SelectorCompiler::querySelectorSimpleSelectorCheckerFunction(compiledSelectorChecker, selector.compilationStatus);
                 matched = selectorChecker(&element);
             } else {
-                ASSERT(m_selectors[i].compilationStatus == SelectorCompilationStatus::SelectorCheckerWithCheckingContext);
-                SelectorCompiler::QuerySelectorSelectorCheckerWithCheckingContext selectorChecker = SelectorCompiler::querySelectorSelectorCheckerFunctionWithCheckingContext(compiledSelectorChecker, m_selectors[i].compilationStatus);
+                ASSERT(selector.compilationStatus == SelectorCompilationStatus::SelectorCheckerWithCheckingContext);
+                auto selectorChecker = SelectorCompiler::querySelectorSelectorCheckerFunctionWithCheckingContext(compiledSelectorChecker, selector.compilationStatus);
                 matched = selectorChecker(&element, &checkingContext);
             }
             if (matched) {
@@ -579,9 +574,8 @@ ALWAYS_INLINE void SelectorDataList::execute(ContainerNode& rootNode, typename S
     case CompilableMultipleSelectorMatch:
 #if ENABLE(CSS_SELECTOR_JIT)
         {
-        unsigned selectorCount = m_selectors.size();
-        for (unsigned i = 0; i < selectorCount; ++i) {
-            if (!compileSelector(m_selectors[i], *searchRootNode)) {
+        for (auto& selector : m_selectors) {
+            if (!compileSelector(selector, *searchRootNode)) {
                 m_matchType = MultipleSelectorMatch;
                 goto MultipleSelectorMatch;
             }
index 4ff0c6f7c754994c155537fbea2f39bd6822fd60..f9f93cf2921587371256c4ea7a7f99aa5a40ee2a 100644 (file)
@@ -64,9 +64,8 @@ void TreeScopeAdopter::moveTreeToNewScope(Node* root) const
             continue;
 
         if (node->hasSyntheticAttrChildNodes()) {
-            const Vector<RefPtr<Attr>>& attrs = downcast<Element>(*node).attrNodeList();
-            for (unsigned i = 0; i < attrs.size(); ++i)
-                moveTreeToNewScope(attrs[i].get());
+            for (auto& attr : downcast<Element>(*node).attrNodeList())
+                moveTreeToNewScope(attr.get());
         }
 
         if (ShadowRoot* shadow = node->shadowRoot()) {