Title: [166329] trunk/Source/WebCore
Revision
166329
Author
timo...@apple.com
Date
2014-03-26 16:58:15 -0700 (Wed, 26 Mar 2014)

Log Message

Modernize the loops in InspectorPageAgent.cpp.

Also moves the check for hiddenFromInspector to a lower level.
This hides hidden resources from more places.

https://bugs.webkit.org/show_bug.cgi?id=130803

Reviewed by Joseph Pecoraro.

* inspector/InspectorPageAgent.cpp:
(WebCore::buildArrayForCookies):
(WebCore::cachedResourcesForFrame):
(WebCore::allResourcesURLsForFrame):
(WebCore::InspectorPageAgent::getCookies):
(WebCore::InspectorPageAgent::searchInResources):
(WebCore::InspectorPageAgent::didClearWindowObjectInWorld):
(WebCore::InspectorPageAgent::loaderDetachedFromFrame):
(WebCore::InspectorPageAgent::buildObjectForFrameTree):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (166328 => 166329)


--- trunk/Source/WebCore/ChangeLog	2014-03-26 23:51:12 UTC (rev 166328)
+++ trunk/Source/WebCore/ChangeLog	2014-03-26 23:58:15 UTC (rev 166329)
@@ -1,3 +1,24 @@
+2014-03-26  Timothy Hatcher  <timo...@apple.com>
+
+        Modernize the loops in InspectorPageAgent.cpp.
+
+        Also moves the check for hiddenFromInspector to a lower level.
+        This hides hidden resources from more places.
+
+        https://bugs.webkit.org/show_bug.cgi?id=130803
+
+        Reviewed by Joseph Pecoraro.
+
+        * inspector/InspectorPageAgent.cpp:
+        (WebCore::buildArrayForCookies):
+        (WebCore::cachedResourcesForFrame):
+        (WebCore::allResourcesURLsForFrame):
+        (WebCore::InspectorPageAgent::getCookies):
+        (WebCore::InspectorPageAgent::searchInResources):
+        (WebCore::InspectorPageAgent::didClearWindowObjectInWorld):
+        (WebCore::InspectorPageAgent::loaderDetachedFromFrame):
+        (WebCore::InspectorPageAgent::buildObjectForFrameTree):
+
 2014-03-26  Thiago de Barros Lacerda  <thiago.lace...@openbossa.org>
 
         Add platform implementation for RTCOfferAnswerOptions and RTCOfferOptions

Modified: trunk/Source/WebCore/inspector/InspectorPageAgent.cpp (166328 => 166329)


--- trunk/Source/WebCore/inspector/InspectorPageAgent.cpp	2014-03-26 23:51:12 UTC (rev 166328)
+++ trunk/Source/WebCore/inspector/InspectorPageAgent.cpp	2014-03-26 23:58:15 UTC (rev 166329)
@@ -451,10 +451,8 @@
 {
     RefPtr<Inspector::TypeBuilder::Array<Inspector::TypeBuilder::Page::Cookie>> cookies = Inspector::TypeBuilder::Array<Inspector::TypeBuilder::Page::Cookie>::create();
 
-    ListHashSet<Cookie>::iterator end = cookiesList.end();
-    ListHashSet<Cookie>::iterator it = cookiesList.begin();
-    for (int i = 0; it != end; ++it, i++)
-        cookies->addItem(buildObjectForCookie(*it));
+    for (auto& cookie : cookiesList)
+        cookies->addItem(buildObjectForCookie(cookie));
 
     return cookies;
 }
@@ -463,10 +461,10 @@
 {
     Vector<CachedResource*> result;
 
-    const CachedResourceLoader::DocumentResourceMap& allResources = frame->document()->cachedResourceLoader()->allCachedResources();
-    CachedResourceLoader::DocumentResourceMap::const_iterator end = allResources.end();
-    for (CachedResourceLoader::DocumentResourceMap::const_iterator it = allResources.begin(); it != end; ++it) {
-        CachedResource* cachedResource = it->value.get();
+    for (auto& cachedResourceHandle : frame->document()->cachedResourceLoader()->allCachedResources().values()) {
+        auto* cachedResource = cachedResourceHandle.get();
+        if (cachedResource->resourceRequest().hiddenFromInspector())
+            continue;
 
         switch (cachedResource->type()) {
         case CachedResource::ImageResource:
@@ -493,9 +491,8 @@
 
     result.append(frame->loader().documentLoader()->url());
 
-    Vector<CachedResource*> allResources = cachedResourcesForFrame(frame);
-    for (Vector<CachedResource*>::const_iterator it = allResources.begin(); it != allResources.end(); ++it)
-        result.append((*it)->url());
+    for (auto* cachedResource : cachedResourcesForFrame(frame))
+        result.append(cachedResource->url());
 
     return result;
 }
@@ -515,13 +512,13 @@
 
     for (Frame* frame = mainFrame(); frame; frame = frame->tree().traverseNext(mainFrame())) {
         Document* document = frame->document();
-        Vector<URL> allURLs = allResourcesURLsForFrame(frame);
-        for (Vector<URL>::const_iterator it = allURLs.begin(); it != allURLs.end(); ++it) {
+
+        for (auto& url : allResourcesURLsForFrame(frame)) {
             Vector<Cookie> docCookiesList;
-            rawCookiesImplemented = getRawCookies(document, URL(ParsedURLString, *it), docCookiesList);
+            rawCookiesImplemented = getRawCookies(document, URL(ParsedURLString, url), docCookiesList);
+
             if (!rawCookiesImplemented) {
                 // FIXME: We need duplication checking for the String representation of cookies.
-                //
                 // Exceptions are thrown by cookie() in sandboxed frames. That won't happen here
                 // because "document" is the document of the main frame of the page.
                 stringCookiesList.append(document->cookie(ASSERT_NO_EXCEPTION));
@@ -629,15 +626,15 @@
 
     for (Frame* frame = &m_page->mainFrame(); frame; frame = frame->tree().traverseNext(&m_page->mainFrame())) {
         String content;
-        Vector<CachedResource*> allResources = cachedResourcesForFrame(frame);
-        for (Vector<CachedResource*>::const_iterator it = allResources.begin(); it != allResources.end(); ++it) {
-            CachedResource* cachedResource = *it;
+
+        for (auto* cachedResource : cachedResourcesForFrame(frame)) {
             if (textContentForCachedResource(cachedResource, &content)) {
                 int matchesCount = ContentSearchUtilities::countRegularExpressionMatches(regex, content);
                 if (matchesCount)
                     searchResults->addItem(buildObjectForSearchResult(frameId(frame), cachedResource->url(), matchesCount));
             }
         }
+
         if (mainResourceContent(frame, false, &content)) {
             int matchesCount = ContentSearchUtilities::countRegularExpressionMatches(regex, content);
             if (matchesCount)
@@ -749,10 +746,9 @@
         return;
 
     if (m_scriptsToEvaluateOnLoad) {
-        InspectorObject::const_iterator end = m_scriptsToEvaluateOnLoad->end();
-        for (InspectorObject::const_iterator it = m_scriptsToEvaluateOnLoad->begin(); it != end; ++it) {
+        for (auto& keyValuePair : *m_scriptsToEvaluateOnLoad) {
             String scriptText;
-            if (it->value->asString(&scriptText))
+            if (keyValuePair.value->asString(&scriptText))
                 frame->script().executeScript(scriptText);
         }
     }
@@ -862,9 +858,7 @@
 
 void InspectorPageAgent::loaderDetachedFromFrame(DocumentLoader* loader)
 {
-    HashMap<DocumentLoader*, String>::iterator iterator = m_loaderToIdentifier.find(loader);
-    if (iterator != m_loaderToIdentifier.end())
-        m_loaderToIdentifier.remove(iterator);
+    m_loaderToIdentifier.remove(loader);
 }
 
 void InspectorPageAgent::frameStartedLoading(Frame& frame)
@@ -974,13 +968,7 @@
          .setFrame(frameObject)
          .setResources(subresources);
 
-    Vector<CachedResource*> allResources = cachedResourcesForFrame(frame);
-    for (Vector<CachedResource*>::const_iterator it = allResources.begin(); it != allResources.end(); ++it) {
-        CachedResource* cachedResource = *it;
-
-        if (cachedResource->resourceRequest().hiddenFromInspector())
-            continue;
-
+    for (auto* cachedResource : cachedResourcesForFrame(frame)) {
         RefPtr<Inspector::TypeBuilder::Page::FrameResourceTree::Resources> resourceObject = Inspector::TypeBuilder::Page::FrameResourceTree::Resources::create()
             .setUrl(cachedResource->url())
             .setType(cachedResourceTypeJson(*cachedResource))
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to