Diff
Modified: trunk/Source/WebCore/ChangeLog (184989 => 184990)
--- trunk/Source/WebCore/ChangeLog 2015-05-29 16:58:51 UTC (rev 184989)
+++ trunk/Source/WebCore/ChangeLog 2015-05-29 17:01:12 UTC (rev 184990)
@@ -1,3 +1,38 @@
+2015-05-29 Hunseop Jeong <[email protected]>
+
+ Use modern for-loops in WebCore/plugins, storage, style, testing and workers.
+ https://bugs.webkit.org/show_bug.cgi?id=145425
+
+ Reviewed by Darin Adler.
+
+ No new tests, no behavior changes.
+
+ * plugins/DOMMimeTypeArray.cpp:
+ (WebCore::DOMMimeTypeArray::canGetItemsForName):
+ * plugins/DOMPlugin.cpp:
+ (WebCore::DOMPlugin::canGetItemsForName):
+ * plugins/DOMPluginArray.cpp:
+ (WebCore::DOMPluginArray::canGetItemsForName):
+ * plugins/PluginData.cpp:
+ (WebCore::PluginData::getWebVisibleMimesAndPluginIndices):
+ * plugins/PluginMainThreadScheduler.cpp:
+ (WebCore::PluginMainThreadScheduler::dispatchCallsForPlugin):
+ (WebCore::PluginMainThreadScheduler::dispatchCalls):
+ * storage/StorageEventDispatcher.cpp:
+ (WebCore::StorageEventDispatcher::dispatchLocalStorageEvents):
+ (WebCore::StorageEventDispatcher::dispatchSessionStorageEventsToFrames):
+ (WebCore::StorageEventDispatcher::dispatchLocalStorageEventsToFrames):
+ * storage/StorageMap.cpp:
+ (WebCore::StorageMap::importItems):
+ * style/StyleResolveTree.cpp:
+ (WebCore::Style::pseudoStyleCacheIsInvalid):
+ * testing/Internals.cpp:
+ (WebCore::Internals::nodesFromRect):
+ * workers/Worker.cpp:
+ (WebCore::networkStateChanged):
+ * workers/WorkerGlobalScope.cpp:
+ (WebCore::WorkerGlobalScope::importScripts):
+
2015-05-29 Alex Christensen <[email protected]>
Unreviewed build fix when using content extensions debugging.
Modified: trunk/Source/WebCore/plugins/DOMMimeTypeArray.cpp (184989 => 184990)
--- trunk/Source/WebCore/plugins/DOMMimeTypeArray.cpp 2015-05-29 16:58:51 UTC (rev 184989)
+++ trunk/Source/WebCore/plugins/DOMMimeTypeArray.cpp 2015-05-29 17:01:12 UTC (rev 184990)
@@ -79,8 +79,8 @@
Vector<MimeClassInfo> mimes;
Vector<size_t> mimePluginIndices;
data->getWebVisibleMimesAndPluginIndices(mimes, mimePluginIndices);
- for (unsigned i = 0; i < mimes.size(); ++i) {
- if (mimes[i].type == propertyName)
+ for (auto& mime : mimes) {
+ if (mime.type == propertyName)
return true;
}
return false;
Modified: trunk/Source/WebCore/plugins/DOMPlugin.cpp (184989 => 184990)
--- trunk/Source/WebCore/plugins/DOMPlugin.cpp 2015-05-29 16:58:51 UTC (rev 184989)
+++ trunk/Source/WebCore/plugins/DOMPlugin.cpp 2015-05-29 17:01:12 UTC (rev 184990)
@@ -83,9 +83,10 @@
Vector<MimeClassInfo> mimes;
Vector<size_t> mimePluginIndices;
m_pluginData->getWebVisibleMimesAndPluginIndices(mimes, mimePluginIndices);
- for (unsigned i = 0; i < mimes.size(); ++i)
- if (mimes[i].type == propertyName)
+ for (auto& mime : mimes) {
+ if (mime.type == propertyName)
return true;
+ }
return false;
}
Modified: trunk/Source/WebCore/plugins/DOMPluginArray.cpp (184989 => 184990)
--- trunk/Source/WebCore/plugins/DOMPluginArray.cpp 2015-05-29 16:58:51 UTC (rev 184989)
+++ trunk/Source/WebCore/plugins/DOMPluginArray.cpp 2015-05-29 17:01:12 UTC (rev 184990)
@@ -70,9 +70,8 @@
if (!data)
return 0;
- const Vector<PluginInfo>& plugins = data->webVisiblePlugins();
- for (unsigned i = 0; i < plugins.size(); ++i) {
- if (plugins[i].name == propertyName)
+ for (auto& plugin : data->webVisiblePlugins()) {
+ if (plugin.name == propertyName)
return true;
}
return false;
Modified: trunk/Source/WebCore/plugins/PluginData.cpp (184989 => 184990)
--- trunk/Source/WebCore/plugins/PluginData.cpp 2015-05-29 16:58:51 UTC (rev 184989)
+++ trunk/Source/WebCore/plugins/PluginData.cpp 2015-05-29 17:01:12 UTC (rev 184990)
@@ -52,8 +52,8 @@
const Vector<PluginInfo>& plugins = webVisiblePlugins();
for (unsigned i = 0; i < plugins.size(); ++i) {
const PluginInfo& plugin = plugins[i];
- for (unsigned j = 0; j < plugin.mimes.size(); ++j) {
- mimes.append(plugin.mimes[j]);
+ for (auto& mime : plugin.mimes) {
+ mimes.append(mime);
mimePluginIndices.append(i);
}
}
Modified: trunk/Source/WebCore/plugins/PluginMainThreadScheduler.cpp (184989 => 184990)
--- trunk/Source/WebCore/plugins/PluginMainThreadScheduler.cpp 2015-05-29 16:58:51 UTC (rev 184989)
+++ trunk/Source/WebCore/plugins/PluginMainThreadScheduler.cpp 2015-05-29 17:01:12 UTC (rev 184990)
@@ -74,8 +74,7 @@
void PluginMainThreadScheduler::dispatchCallsForPlugin(NPP npp, const Deque<Call>& calls)
{
- Deque<Call>::const_iterator end = calls.end();
- for (Deque<Call>::const_iterator it = calls.begin(); it != end; ++it) {
+ for (auto& call : calls) {
// Check if the plug-in has been destroyed.
{
MutexLocker lock(m_queueMutex);
@@ -83,7 +82,7 @@
return;
}
- (*it).performCall();
+ call.performCall();
}
}
@@ -92,19 +91,15 @@
m_queueMutex.lock();
CallQueueMap copy(m_callQueueMap);
- {
- // Empty all the queues in the original map
- CallQueueMap::iterator end = m_callQueueMap.end();
- for (CallQueueMap::iterator it = m_callQueueMap.begin(); it != end; ++it)
- it->value.clear();
- }
+ // Empty all the queues in the original map
+ for (auto& call : m_callQueueMap.values())
+ call.clear();
m_callPending = false;
m_queueMutex.unlock();
- CallQueueMap::iterator end = copy.end();
- for (CallQueueMap::iterator it = copy.begin(); it != end; ++it)
- dispatchCallsForPlugin(it->key, it->value);
+ for (auto& entry : copy)
+ dispatchCallsForPlugin(entry.key, entry.value);
}
void PluginMainThreadScheduler::mainThreadCallback(void* context)
Modified: trunk/Source/WebCore/storage/StorageEventDispatcher.cpp (184989 => 184990)
--- trunk/Source/WebCore/storage/StorageEventDispatcher.cpp 2015-05-29 16:58:51 UTC (rev 184989)
+++ trunk/Source/WebCore/storage/StorageEventDispatcher.cpp 2015-05-29 17:01:12 UTC (rev 184990)
@@ -64,9 +64,8 @@
Vector<RefPtr<Frame>> frames;
// Send events to every page.
- const HashSet<Page*>& pages = page->group().pages();
- for (HashSet<Page*>::const_iterator it = pages.begin(), end = pages.end(); it != end; ++it) {
- for (Frame* frame = &(*it)->mainFrame(); frame; frame = frame->tree().traverseNext()) {
+ for (auto& pageInGroup : page->group().pages()) {
+ for (Frame* frame = &pageInGroup->mainFrame(); frame; frame = frame->tree().traverseNext()) {
if (sourceFrame != frame && frame->document()->securityOrigin()->equal(securityOrigin))
frames.append(frame);
}
@@ -79,25 +78,24 @@
{
InspectorInstrumentation::didDispatchDOMStorageEvent(key, oldValue, newValue, SessionStorage, securityOrigin, &page);
- for (unsigned i = 0; i < frames.size(); ++i) {
+ for (auto& frame : frames) {
ExceptionCode ec = 0;
- Storage* storage = frames[i]->document()->domWindow()->sessionStorage(ec);
+ Storage* storage = frame->document()->domWindow()->sessionStorage(ec);
if (!ec)
- frames[i]->document()->enqueueWindowEvent(StorageEvent::create(eventNames().storageEvent, key, oldValue, newValue, url, storage));
+ frame->document()->enqueueWindowEvent(StorageEvent::create(eventNames().storageEvent, key, oldValue, newValue, url, storage));
}
}
void StorageEventDispatcher::dispatchLocalStorageEventsToFrames(PageGroup& pageGroup, const Vector<RefPtr<Frame>>& frames, const String& key, const String& oldValue, const String& newValue, const String& url, SecurityOrigin* securityOrigin)
{
- const HashSet<Page*>& pages = pageGroup.pages();
- for (HashSet<Page*>::const_iterator it = pages.begin(), end = pages.end(); it != end; ++it)
- InspectorInstrumentation::didDispatchDOMStorageEvent(key, oldValue, newValue, LocalStorage, securityOrigin, *it);
+ for (auto& page : pageGroup.pages())
+ InspectorInstrumentation::didDispatchDOMStorageEvent(key, oldValue, newValue, LocalStorage, securityOrigin, page);
- for (unsigned i = 0; i < frames.size(); ++i) {
+ for (auto& frame : frames) {
ExceptionCode ec = 0;
- Storage* storage = frames[i]->document()->domWindow()->localStorage(ec);
+ Storage* storage = frame->document()->domWindow()->localStorage(ec);
if (!ec)
- frames[i]->document()->enqueueWindowEvent(StorageEvent::create(eventNames().storageEvent, key, oldValue, newValue, url, storage));
+ frame->document()->enqueueWindowEvent(StorageEvent::create(eventNames().storageEvent, key, oldValue, newValue, url, storage));
}
}
Modified: trunk/Source/WebCore/storage/StorageMap.cpp (184989 => 184990)
--- trunk/Source/WebCore/storage/StorageMap.cpp 2015-05-29 16:58:51 UTC (rev 184989)
+++ trunk/Source/WebCore/storage/StorageMap.cpp 2015-05-29 17:01:12 UTC (rev 184990)
@@ -184,9 +184,9 @@
void StorageMap::importItems(const HashMap<String, String>& items)
{
- for (HashMap<String, String>::const_iterator it = items.begin(), end = items.end(); it != end; ++it) {
- const String& key = it->key;
- const String& value = it->value;
+ for (auto& item : items) {
+ const String& key = item.key;
+ const String& value = item.value;
HashMap<String, String>::AddResult result = m_map.add(key, value);
ASSERT_UNUSED(result, result.isNewEntry); // True if the key didn't exist previously.
Modified: trunk/Source/WebCore/style/StyleResolveTree.cpp (184989 => 184990)
--- trunk/Source/WebCore/style/StyleResolveTree.cpp 2015-05-29 16:58:51 UTC (rev 184989)
+++ trunk/Source/WebCore/style/StyleResolveTree.cpp 2015-05-29 17:01:12 UTC (rev 184990)
@@ -583,17 +583,16 @@
if (!pseudoStyleCache)
return false;
- size_t cacheSize = pseudoStyleCache->size();
- for (size_t i = 0; i < cacheSize; ++i) {
+ for (auto& cache : *pseudoStyleCache) {
RefPtr<RenderStyle> newPseudoStyle;
- PseudoId pseudoId = pseudoStyleCache->at(i)->styleType();
+ PseudoId pseudoId = cache->styleType();
if (pseudoId == FIRST_LINE || pseudoId == FIRST_LINE_INHERITED)
newPseudoStyle = renderer->uncachedFirstLineStyle(newStyle);
else
newPseudoStyle = renderer->getUncachedPseudoStyle(PseudoStyleRequest(pseudoId), newStyle, newStyle);
if (!newPseudoStyle)
return true;
- if (*newPseudoStyle != *pseudoStyleCache->at(i)) {
+ if (*newPseudoStyle != *cache) {
if (pseudoId < FIRST_INTERNAL_PSEUDOID)
newStyle->setHasPseudoStyle(pseudoId);
newStyle->addCachedPseudoStyle(newPseudoStyle);
Modified: trunk/Source/WebCore/testing/Internals.cpp (184989 => 184990)
--- trunk/Source/WebCore/testing/Internals.cpp 2015-05-29 16:58:51 UTC (rev 184989)
+++ trunk/Source/WebCore/testing/Internals.cpp 2015-05-29 17:01:12 UTC (rev 184990)
@@ -1383,8 +1383,8 @@
const HitTestResult::NodeSet& nodeSet = result.rectBasedTestResult();
matches.reserveInitialCapacity(nodeSet.size());
- for (auto it = nodeSet.begin(), end = nodeSet.end(); it != end; ++it)
- matches.uncheckedAppend(*it->get());
+ for (auto& node : nodeSet)
+ matches.uncheckedAppend(*node);
}
return StaticNodeList::adopt(matches);
Modified: trunk/Source/WebCore/workers/Worker.cpp (184989 => 184990)
--- trunk/Source/WebCore/workers/Worker.cpp 2015-05-29 16:58:51 UTC (rev 184989)
+++ trunk/Source/WebCore/workers/Worker.cpp 2015-05-29 17:01:12 UTC (rev 184990)
@@ -54,9 +54,8 @@
void networkStateChanged(bool isOnLine)
{
- HashSet<Worker*>::iterator end = allWorkers->end();
- for (HashSet<Worker*>::iterator it = allWorkers->begin(); it != end; ++it)
- (*it)->notifyNetworkStateChange(isOnLine);
+ for (auto& worker : *allWorkers)
+ worker->notifyNetworkStateChange(isOnLine);
}
inline Worker::Worker(ScriptExecutionContext& context)
Modified: trunk/Source/WebCore/workers/WorkerGlobalScope.cpp (184989 => 184990)
--- trunk/Source/WebCore/workers/WorkerGlobalScope.cpp 2015-05-29 16:58:51 UTC (rev 184989)
+++ trunk/Source/WebCore/workers/WorkerGlobalScope.cpp 2015-05-29 17:01:12 UTC (rev 184990)
@@ -175,21 +175,19 @@
{
ASSERT(contentSecurityPolicy());
ec = 0;
- Vector<String>::const_iterator urlsEnd = urls.end();
Vector<URL> completedURLs;
- for (Vector<String>::const_iterator it = urls.begin(); it != urlsEnd; ++it) {
- const URL& url = ""
+ for (auto& entry : urls) {
+ URL url = ""
if (!url.isValid()) {
ec = SYNTAX_ERR;
return;
}
- completedURLs.append(url);
+ completedURLs.append(WTF::move(url));
}
- Vector<URL>::const_iterator end = completedURLs.end();
- for (Vector<URL>::const_iterator it = completedURLs.begin(); it != end; ++it) {
+ for (auto& url : completedURLs) {
Ref<WorkerScriptLoader> scriptLoader = WorkerScriptLoader::create();
- scriptLoader->loadSynchronously(scriptExecutionContext(), *it, AllowCrossOriginRequests);
+ scriptLoader->loadSynchronously(scriptExecutionContext(), url, AllowCrossOriginRequests);
// If the fetching attempt failed, throw a NETWORK_ERR exception and abort all these steps.
if (scriptLoader->failed()) {