Diff
Modified: trunk/Source/WebCore/ChangeLog (120080 => 120081)
--- trunk/Source/WebCore/ChangeLog 2012-06-12 15:29:33 UTC (rev 120080)
+++ trunk/Source/WebCore/ChangeLog 2012-06-12 15:34:15 UTC (rev 120081)
@@ -1,3 +1,28 @@
+2012-06-12 Kinuko Yasuda <[email protected]>
+
+ Refactor InputType::receiveDroppedFiles to take DragData
+ https://bugs.webkit.org/show_bug.cgi?id=88860
+
+ Reviewed by Kent Tamura.
+
+ So that we can centralize the file paths related code into FileInputType
+ and makes it easier to extract more data from DragData for
+ <input type=file> (like bug 88293 for directory drag-and-drop).
+
+ No new tests as this has no behavioral changes.
+
+ * html/FileInputType.cpp:
+ (WebCore::FileInputType::receiveDroppedFiles):
+ * html/FileInputType.h:
+ * html/HTMLInputElement.cpp:
+ (WebCore::HTMLInputElement::receiveDroppedFiles):
+ * html/HTMLInputElement.h:
+ * html/InputType.cpp:
+ (WebCore::InputType::receiveDroppedFiles):
+ * html/InputType.h:
+ * page/DragController.cpp:
+ (WebCore::DragController::concludeEditDrag):
+
2012-06-12 Thiago Marcos P. Santos <[email protected]>
Generate -webkit-box-decoration-break property only when the feature is enabled
Modified: trunk/Source/WebCore/html/FileInputType.cpp (120080 => 120081)
--- trunk/Source/WebCore/html/FileInputType.cpp 2012-06-12 15:29:33 UTC (rev 120080)
+++ trunk/Source/WebCore/html/FileInputType.cpp 2012-06-12 15:34:15 UTC (rev 120081)
@@ -23,6 +23,7 @@
#include "FileInputType.h"
#include "Chrome.h"
+#include "DragData.h"
#include "ElementShadow.h"
#include "Event.h"
#include "File.h"
@@ -389,13 +390,18 @@
element()->renderer()->repaint();
}
-void FileInputType::receiveDroppedFiles(const Vector<String>& paths)
+bool FileInputType::receiveDroppedFiles(const DragData* dragData)
{
+ Vector<String> paths;
+ dragData->asFilenames(paths);
+ if (paths.isEmpty())
+ return false;
+
HTMLInputElement* input = element();
#if ENABLE(DIRECTORY_UPLOAD)
if (input->fastHasAttribute(webkitdirectoryAttr)) {
receiveDropForDirectoryUpload(paths);
- return;
+ return true;
}
#endif
@@ -410,6 +416,7 @@
firstFileOnly.append(files[0]);
filesChosen(firstFileOnly);
}
+ return true;
}
Icon* FileInputType::icon() const
Modified: trunk/Source/WebCore/html/FileInputType.h (120080 => 120081)
--- trunk/Source/WebCore/html/FileInputType.h 2012-06-12 15:29:33 UTC (rev 120080)
+++ trunk/Source/WebCore/html/FileInputType.h 2012-06-12 15:34:15 UTC (rev 120081)
@@ -39,6 +39,7 @@
namespace WebCore {
+class DragData;
class FileList;
class FileInputType : public BaseClickableWithKeyInputType, private FileChooserClient, private FileIconLoaderClient {
@@ -62,7 +63,7 @@
virtual bool canSetValue(const String&) OVERRIDE;
virtual bool getTypeSpecificValue(String&) OVERRIDE; // Checked first, before internal storage or the value attribute.
virtual void setValue(const String&, bool valueChanged, TextFieldEventBehavior) OVERRIDE;
- virtual void receiveDroppedFiles(const Vector<String>&) OVERRIDE;
+ virtual bool receiveDroppedFiles(const DragData*) OVERRIDE;
virtual Icon* icon() const OVERRIDE;
virtual bool isFileUpload() const OVERRIDE;
virtual void createShadowSubtree() OVERRIDE;
Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (120080 => 120081)
--- trunk/Source/WebCore/html/HTMLInputElement.cpp 2012-06-12 15:29:33 UTC (rev 120080)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp 2012-06-12 15:34:15 UTC (rev 120081)
@@ -1226,9 +1226,9 @@
m_inputType->setFiles(files);
}
-void HTMLInputElement::receiveDroppedFiles(const Vector<String>& filenames)
+bool HTMLInputElement::receiveDroppedFiles(const DragData* dragData)
{
- m_inputType->receiveDroppedFiles(filenames);
+ return m_inputType->receiveDroppedFiles(dragData);
}
Icon* HTMLInputElement::icon() const
Modified: trunk/Source/WebCore/html/HTMLInputElement.h (120080 => 120081)
--- trunk/Source/WebCore/html/HTMLInputElement.h 2012-06-12 15:29:33 UTC (rev 120080)
+++ trunk/Source/WebCore/html/HTMLInputElement.h 2012-06-12 15:34:15 UTC (rev 120081)
@@ -31,6 +31,7 @@
namespace WebCore {
class CheckedRadioButtons;
+class DragData;
class FileList;
class HTMLDataListElement;
class HTMLOptionElement;
@@ -213,7 +214,10 @@
FileList* files();
void setFiles(PassRefPtr<FileList>);
- void receiveDroppedFiles(const Vector<String>&);
+
+ // Returns true if the given DragData has more than one dropped files.
+ bool receiveDroppedFiles(const DragData*);
+
Icon* icon() const;
// These functions are used for rendering the input active during a
// drag-and-drop operation.
Modified: trunk/Source/WebCore/html/InputType.cpp (120080 => 120081)
--- trunk/Source/WebCore/html/InputType.cpp 2012-06-12 15:29:33 UTC (rev 120080)
+++ trunk/Source/WebCore/html/InputType.cpp 2012-06-12 15:34:15 UTC (rev 120081)
@@ -667,9 +667,10 @@
return false;
}
-void InputType::receiveDroppedFiles(const Vector<String>&)
+bool InputType::receiveDroppedFiles(const DragData*)
{
ASSERT_NOT_REACHED();
+ return false;
}
Icon* InputType::icon() const
Modified: trunk/Source/WebCore/html/InputType.h (120080 => 120081)
--- trunk/Source/WebCore/html/InputType.h 2012-06-12 15:29:33 UTC (rev 120080)
+++ trunk/Source/WebCore/html/InputType.h 2012-06-12 15:34:15 UTC (rev 120081)
@@ -47,6 +47,7 @@
class Chrome;
class Color;
class DateComponents;
+class DragData;
class Event;
class FileList;
class FormDataList;
@@ -231,7 +232,8 @@
virtual bool shouldRespectAlignAttribute();
virtual FileList* files();
virtual void setFiles(PassRefPtr<FileList>);
- virtual void receiveDroppedFiles(const Vector<String>&);
+ // Should return true if the given DragData has more than one dropped files.
+ virtual bool receiveDroppedFiles(const DragData*);
virtual Icon* icon() const;
// Should return true if the corresponding renderer for a type can display a suggested value.
virtual bool canSetSuggestedValue();
Modified: trunk/Source/WebCore/page/DragController.cpp (120080 => 120081)
--- trunk/Source/WebCore/page/DragController.cpp 2012-06-12 15:29:33 UTC (rev 120080)
+++ trunk/Source/WebCore/page/DragController.cpp 2012-06-12 15:34:15 UTC (rev 120081)
@@ -469,13 +469,7 @@
if (fileInput->disabled())
return false;
- Vector<String> filenames;
- dragData->asFilenames(filenames);
- if (filenames.isEmpty())
- return false;
-
- fileInput->receiveDroppedFiles(filenames);
- return true;
+ return fileInput->receiveDroppedFiles(dragData);
}
if (!m_page->dragController()->canProcessDrag(dragData)) {