Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Unified Diff: third_party/WebKit/Source/core/html/forms/FileInputType.cpp

Issue 2556043002: Avoid WTF::Vector::at() and operator[] in core/html. (Closed)
Patch Set: _ Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/html/forms/FileInputType.cpp
diff --git a/third_party/WebKit/Source/core/html/forms/FileInputType.cpp b/third_party/WebKit/Source/core/html/forms/FileInputType.cpp
index 70eb51205910cc1ba3927cc6cc278df25f619a59..f278b86819aeb240d67ac8e25940f2e2ba135238 100644
--- a/third_party/WebKit/Source/core/html/forms/FileInputType.cpp
+++ b/third_party/WebKit/Source/core/html/forms/FileInputType.cpp
@@ -225,24 +225,22 @@ FileList* FileInputType::createFileList(
int rootLength = rootPath.length();
if (rootPath[rootLength - 1] != '\\' && rootPath[rootLength - 1] != '/')
rootLength += 1;
- for (size_t i = 0; i < size; ++i) {
+ for (const auto& file : files) {
// Normalize backslashes to slashes before exposing the relative path to
// script.
- String relativePath =
- files[i].path.substring(rootLength).replace('\\', '/');
- fileList->append(
- File::createWithRelativePath(files[i].path, relativePath));
+ String relativePath = file.path.substring(rootLength).replace('\\', '/');
+ fileList->append(File::createWithRelativePath(file.path, relativePath));
}
return fileList;
}
- for (size_t i = 0; i < size; ++i) {
- if (files[i].fileSystemURL.isEmpty()) {
+ for (const auto& file : files) {
+ if (file.fileSystemURL.isEmpty()) {
fileList->append(
- File::createForUserProvidedFile(files[i].path, files[i].displayName));
+ File::createForUserProvidedFile(file.path, file.displayName));
} else {
fileList->append(File::createForFileSystemFile(
- files[i].fileSystemURL, files[i].metadata, File::IsUserVisible));
+ file.fileSystemURL, file.metadata, File::IsUserVisible));
}
}
return fileList;
@@ -352,8 +350,8 @@ void FileInputType::setFilesFromPaths(const Vector<String>& paths) {
}
Vector<FileChooserFileInfo> files;
- for (unsigned i = 0; i < paths.size(); ++i)
- files.append(FileChooserFileInfo(paths[i]));
+ for (const auto& path : paths)
+ files.append(FileChooserFileInfo(path));
if (input.fastHasAttribute(multipleAttr)) {
filesChosen(files);

Powered by Google App Engine
This is Rietveld 408576698