Commit c9b46971 authored by kinuko@chromium.org's avatar kinuko@chromium.org

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):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@120081 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 4cd12716
2012-06-12 Kinuko Yasuda <kinuko@chromium.org>
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 <thiago.santos@intel.com>
Generate -webkit-box-decoration-break property only when the feature is enabled
......
......@@ -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 @@ void FileInputType::updateRendering(PassRefPtr<Icon> icon)
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 @@ void FileInputType::receiveDroppedFiles(const Vector<String>& paths)
firstFileOnly.append(files[0]);
filesChosen(firstFileOnly);
}
return true;
}
Icon* FileInputType::icon() const
......
......@@ -39,6 +39,7 @@
namespace WebCore {
class DragData;
class FileList;
class FileInputType : public BaseClickableWithKeyInputType, private FileChooserClient, private FileIconLoaderClient {
......@@ -62,7 +63,7 @@ private:
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;
......
......@@ -1226,9 +1226,9 @@ void HTMLInputElement::setFiles(PassRefPtr<FileList> files)
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
......
......@@ -31,6 +31,7 @@
namespace WebCore {
class CheckedRadioButtons;
class DragData;
class FileList;
class HTMLDataListElement;
class HTMLOptionElement;
......@@ -213,7 +214,10 @@ public:
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.
......
......@@ -667,9 +667,10 @@ bool InputType::hasUnacceptableValue()
return false;
}
void InputType::receiveDroppedFiles(const Vector<String>&)
bool InputType::receiveDroppedFiles(const DragData*)
{
ASSERT_NOT_REACHED();
return false;
}
Icon* InputType::icon() const
......
......@@ -47,6 +47,7 @@ class BeforeTextInsertedEvent;
class Chrome;
class Color;
class DateComponents;
class DragData;
class Event;
class FileList;
class FormDataList;
......@@ -231,7 +232,8 @@ public:
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();
......
......@@ -469,13 +469,7 @@ bool DragController::concludeEditDrag(DragData* dragData)
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)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment