Title: [154229] trunk/Source/WebCore
- Revision
- 154229
- Author
- [email protected]
- Date
- 2013-08-17 07:56:48 -0700 (Sat, 17 Aug 2013)
Log Message
<https://webkit.org/b/119946> Move some code used only by EventHandler from Clipboard to EventHandler
Reviewed by Andreas Kling.
Later it would be good to move this all to DragController, but there is no reason to have
these functions as member functions of the DOM-exposed Clipboard class.
* dom/Clipboard.cpp: Deleted hasFileOfType, hasStringOfType, convertDropZoneOperationToDragOperation,
convertDragOperationToDropZoneOperation.
* dom/Clipboard.h: Ditto.
* page/EventHandler.cpp:
(WebCore::convertDropZoneOperationToDragOperation): Moved here.
(WebCore::convertDragOperationToDropZoneOperation): Moved here. Also changed to use ASCIILiteral.
(WebCore::hasFileOfType): Moved here and made a free function instead of a member function. Removed
canReadTypes check because Clipboard::files already takes care of that.
(WebCore::hasStringOfType): Moved here and made a free function instead of a member function.
Added a check for the null string because HashSet::contains will not work on a null string.
(WebCore::hasDropZoneType): Moved here and made a free function instead of a member function.
(WebCore::findDropZone): Call the hasDropZoneType function instead of Clipboard::hasDropZoneType.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (154228 => 154229)
--- trunk/Source/WebCore/ChangeLog 2013-08-17 14:48:32 UTC (rev 154228)
+++ trunk/Source/WebCore/ChangeLog 2013-08-17 14:56:48 UTC (rev 154229)
@@ -1,5 +1,28 @@
2013-08-17 Darin Adler <[email protected]>
+ <https://webkit.org/b/119946> Move some code used only by EventHandler from Clipboard to EventHandler
+
+ Reviewed by Andreas Kling.
+
+ Later it would be good to move this all to DragController, but there is no reason to have
+ these functions as member functions of the DOM-exposed Clipboard class.
+
+ * dom/Clipboard.cpp: Deleted hasFileOfType, hasStringOfType, convertDropZoneOperationToDragOperation,
+ convertDragOperationToDropZoneOperation.
+ * dom/Clipboard.h: Ditto.
+
+ * page/EventHandler.cpp:
+ (WebCore::convertDropZoneOperationToDragOperation): Moved here.
+ (WebCore::convertDragOperationToDropZoneOperation): Moved here. Also changed to use ASCIILiteral.
+ (WebCore::hasFileOfType): Moved here and made a free function instead of a member function. Removed
+ canReadTypes check because Clipboard::files already takes care of that.
+ (WebCore::hasStringOfType): Moved here and made a free function instead of a member function.
+ Added a check for the null string because HashSet::contains will not work on a null string.
+ (WebCore::hasDropZoneType): Moved here and made a free function instead of a member function.
+ (WebCore::findDropZone): Call the hasDropZoneType function instead of Clipboard::hasDropZoneType.
+
+2013-08-17 Darin Adler <[email protected]>
+
<https://webkit.org/b/119943> Clean up the Document class a bit
Reviewed by Antti Koivisto.
Modified: trunk/Source/WebCore/dom/Clipboard.cpp (154228 => 154229)
--- trunk/Source/WebCore/dom/Clipboard.cpp 2013-08-17 14:48:32 UTC (rev 154228)
+++ trunk/Source/WebCore/dom/Clipboard.cpp 2013-08-17 14:56:48 UTC (rev 154229)
@@ -183,30 +183,6 @@
m_dropEffect = IEOpFromDragOp(op);
}
-bool Clipboard::hasFileOfType(const String& type) const
-{
- if (!canReadTypes())
- return false;
-
- RefPtr<FileList> fileList = files();
- if (fileList->isEmpty())
- return false;
-
- for (unsigned int f = 0; f < fileList->length(); f++) {
- if (equalIgnoringCase(fileList->item(f)->type(), type))
- return true;
- }
- return false;
-}
-
-bool Clipboard::hasStringOfType(const String& type) const
-{
- if (!canReadTypes())
- return false;
-
- return types().contains(type);
-}
-
void Clipboard::setDropEffect(const String &effect)
{
if (!isForDragAndDrop())
@@ -242,42 +218,6 @@
m_effectAllowed = effect;
}
-DragOperation convertDropZoneOperationToDragOperation(const String& dragOperation)
-{
- if (dragOperation == "copy")
- return DragOperationCopy;
- if (dragOperation == "move")
- return DragOperationMove;
- if (dragOperation == "link")
- return DragOperationLink;
- return DragOperationNone;
-}
-
-String convertDragOperationToDropZoneOperation(DragOperation operation)
-{
- switch (operation) {
- case DragOperationCopy:
- return String("copy");
- case DragOperationMove:
- return String("move");
- case DragOperationLink:
- return String("link");
- default:
- return String("copy");
- }
-}
-
-bool Clipboard::hasDropZoneType(const String& keyword)
-{
- if (keyword.startsWith("file:"))
- return hasFileOfType(keyword.substring(5));
-
- if (keyword.startsWith("string:"))
- return hasStringOfType(keyword.substring(7));
-
- return false;
-}
-
#if USE(LEGACY_STYLE_ABSTRACT_CLIPBOARD_CLASS)
void Clipboard::setDragImage(Element* element, int x, int y)
Modified: trunk/Source/WebCore/dom/Clipboard.h (154228 => 154229)
--- trunk/Source/WebCore/dom/Clipboard.h 2013-08-17 14:48:32 UTC (rev 154228)
+++ trunk/Source/WebCore/dom/Clipboard.h 2013-08-17 14:56:48 UTC (rev 154229)
@@ -121,8 +121,6 @@
void setSourceOperation(DragOperation);
void setDestinationOperation(DragOperation);
- bool hasDropZoneType(const String&);
-
void setDragHasStarted() { m_dragStarted = true; }
#if ENABLE(DATA_TRANSFER_ITEMS)
@@ -151,9 +149,6 @@
bool dragStarted() const { return m_dragStarted; }
private:
- bool hasFileOfType(const String&) const;
- bool hasStringOfType(const String&) const;
-
// Instead of using this member directly, prefer to use the can*() methods above.
ClipboardAccessPolicy m_policy;
String m_dropEffect;
@@ -176,9 +171,6 @@
#endif
};
- DragOperation convertDropZoneOperationToDragOperation(const String& dragOperation);
- String convertDragOperationToDropZoneOperation(DragOperation);
-
#undef LEGACY_VIRTUAL
#undef LEGACY_PURE
Modified: trunk/Source/WebCore/page/EventHandler.cpp (154228 => 154229)
--- trunk/Source/WebCore/page/EventHandler.cpp 2013-08-17 14:48:32 UTC (rev 154228)
+++ trunk/Source/WebCore/page/EventHandler.cpp 2013-08-17 14:56:48 UTC (rev 154229)
@@ -44,6 +44,7 @@
#include "EventNames.h"
#include "EventPathWalker.h"
#include "ExceptionCodePlaceholder.h"
+#include "FileList.h"
#include "FloatPoint.h"
#include "FloatRect.h"
#include "FocusController.h"
@@ -1971,8 +1972,8 @@
return false;
}
+#if ENABLE(DRAG_SUPPORT)
-#if ENABLE(DRAG_SUPPORT)
bool EventHandler::dispatchDragEvent(const AtomicString& eventType, Node* dragTarget, const PlatformMouseEvent& event, Clipboard* clipboard)
{
FrameView* view = m_frame->view();
@@ -2008,6 +2009,57 @@
return true;
}
+static DragOperation convertDropZoneOperationToDragOperation(const String& dragOperation)
+{
+ if (dragOperation == "copy")
+ return DragOperationCopy;
+ if (dragOperation == "move")
+ return DragOperationMove;
+ if (dragOperation == "link")
+ return DragOperationLink;
+ return DragOperationNone;
+}
+
+static String convertDragOperationToDropZoneOperation(DragOperation operation)
+{
+ switch (operation) {
+ case DragOperationCopy:
+ return ASCIILiteral("copy");
+ case DragOperationMove:
+ return ASCIILiteral("move");
+ case DragOperationLink:
+ return ASCIILiteral("link");
+ default:
+ return ASCIILiteral("copy");
+ }
+}
+
+static inline bool hasFileOfType(Clipboard& clipboard, const String& type)
+{
+ RefPtr<FileList> fileList = clipboard.files();
+ for (unsigned i = 0; i < fileList->length(); i++) {
+ if (equalIgnoringCase(fileList->item(i)->type(), type))
+ return true;
+ }
+ return false;
+}
+
+static inline bool hasStringOfType(Clipboard& clipboard, const String& type)
+{
+ return !type.isNull() && clipboard.types().contains(type);
+}
+
+static bool hasDropZoneType(Clipboard& clipboard, const String& keyword)
+{
+ if (keyword.startsWith("file:"))
+ return hasFileOfType(clipboard, keyword.substring(5));
+
+ if (keyword.startsWith("string:"))
+ return hasStringOfType(clipboard, keyword.substring(7));
+
+ return false;
+}
+
static bool findDropZone(Node* target, Clipboard* clipboard)
{
Element* element = target->isElementNode() ? toElement(target) : target->parentElement();
@@ -2031,7 +2083,7 @@
if (dragOperation == DragOperationNone)
dragOperation = op;
} else
- matched = matched || clipboard->hasDropZoneType(keywords[i].string());
+ matched = matched || hasDropZoneType(*clipboard, keywords[i].string());
if (matched && dragOperation != DragOperationNone)
break;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes