Title: [89523] trunk/Source/WebCore
- Revision
- 89523
- Author
- [email protected]
- Date
- 2011-06-22 20:07:58 -0700 (Wed, 22 Jun 2011)
Log Message
2011-06-22 Dimitri Glazkov <[email protected]>
Reviewed by Kent Tamura.
Add a helper function to FileList to retrieve a list of filenames.
https://bugs.webkit.org/show_bug.cgi?id=63222
Refactoring, covered by existing tests.
* fileapi/FileList.cpp:
(WebCore::FileList::filenames): Added.
* fileapi/FileList.h:
* rendering/RenderFileUploadControl.cpp:
(WebCore::RenderFileUploadControl::RenderFileUploadControl): Changed to use newly added helper.
(WebCore::RenderFileUploadControl::click): Ditto.
(WebCore::RenderFileUploadControl::fileTextValue): Ditto.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (89522 => 89523)
--- trunk/Source/WebCore/ChangeLog 2011-06-23 02:31:11 UTC (rev 89522)
+++ trunk/Source/WebCore/ChangeLog 2011-06-23 03:07:58 UTC (rev 89523)
@@ -1,3 +1,20 @@
+2011-06-22 Dimitri Glazkov <[email protected]>
+
+ Reviewed by Kent Tamura.
+
+ Add a helper function to FileList to retrieve a list of filenames.
+ https://bugs.webkit.org/show_bug.cgi?id=63222
+
+ Refactoring, covered by existing tests.
+
+ * fileapi/FileList.cpp:
+ (WebCore::FileList::filenames): Added.
+ * fileapi/FileList.h:
+ * rendering/RenderFileUploadControl.cpp:
+ (WebCore::RenderFileUploadControl::RenderFileUploadControl): Changed to use newly added helper.
+ (WebCore::RenderFileUploadControl::click): Ditto.
+ (WebCore::RenderFileUploadControl::fileTextValue): Ditto.
+
2011-06-22 Sam Weinig <[email protected]>
Reviewed by Adam Barth.
Modified: trunk/Source/WebCore/fileapi/FileList.cpp (89522 => 89523)
--- trunk/Source/WebCore/fileapi/FileList.cpp 2011-06-23 02:31:11 UTC (rev 89522)
+++ trunk/Source/WebCore/fileapi/FileList.cpp 2011-06-23 03:07:58 UTC (rev 89523)
@@ -41,4 +41,13 @@
return m_files[index].get();
}
+Vector<String> FileList::filenames() const
+{
+ Vector<String> filenames;
+ for (unsigned i = 0; i < m_files.size(); ++i)
+ filenames.append(m_files[i]->path());
+
+ return filenames;
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/fileapi/FileList.h (89522 => 89523)
--- trunk/Source/WebCore/fileapi/FileList.h 2011-06-23 02:31:11 UTC (rev 89522)
+++ trunk/Source/WebCore/fileapi/FileList.h 2011-06-23 03:07:58 UTC (rev 89523)
@@ -47,6 +47,7 @@
bool isEmpty() const { return m_files.isEmpty(); }
void clear() { m_files.clear(); }
void append(PassRefPtr<File> file) { m_files.append(file); }
+ Vector<String> filenames() const;
private:
FileList();
Modified: trunk/Source/WebCore/rendering/RenderFileUploadControl.cpp (89522 => 89523)
--- trunk/Source/WebCore/rendering/RenderFileUploadControl.cpp 2011-06-23 02:31:11 UTC (rev 89522)
+++ trunk/Source/WebCore/rendering/RenderFileUploadControl.cpp 2011-06-23 03:07:58 UTC (rev 89523)
@@ -54,20 +54,12 @@
const int defaultWidthNumChars = 34;
const int buttonShadowHeight = 2;
-static void filenamesFromFileList(const FileList* list, Vector<String>& filenames)
-{
- unsigned length = list ? list->length() : 0;
- for (unsigned i = 0; i < length; ++i)
- filenames.append(list->item(i)->path());
-}
-
RenderFileUploadControl::RenderFileUploadControl(HTMLInputElement* input)
: RenderBlock(input)
, m_iconLoader(FileIconLoader::create(this))
{
- Vector<String> filenames;
- filenamesFromFileList(input->files(), filenames);
- requestIcon(filenames);
+ ASSERT(input->files());
+ requestIcon(input->files()->filenames());
}
RenderFileUploadControl::~RenderFileUploadControl()
@@ -133,7 +125,8 @@
settings.allowsMultipleFiles = input->fastHasAttribute(multipleAttr);
#endif
settings.acceptTypes = input->accept();
- filenamesFromFileList(input->files(), settings.selectedFiles);
+ ASSERT(input->files());
+ settings.selectedFiles = input->files()->filenames();
chrome->runOpenPanel(frame(), newFileChooser(settings));
}
}
@@ -328,9 +321,9 @@
String RenderFileUploadControl::fileTextValue() const
{
- Vector<String> filenames;
- filenamesFromFileList(static_cast<HTMLInputElement*>(node())->files(), filenames);
- return theme()->fileListNameForWidth(filenames, style()->font(), maxFilenameWidth());
+ HTMLInputElement* input = static_cast<HTMLInputElement*>(node());
+ ASSERT(input->files());
+ return theme()->fileListNameForWidth(input->files()->filenames(), style()->font(), maxFilenameWidth());
}
} // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes