https://bugs.webkit.org/show_bug.cgi?id=175751
Reviewed by Wenson Hsieh.
Removed the code to allow setting the drag mage after dragstart had happened.
The feature was apparently used in Mac WebKit1 port but using it today causes the drag image
to disapepar while the user is moving the mouse cursor and being drawn once it's stopped
and results in the contionus flickering of the drag image.
The feaure was never supported in WebKit2 and doesn't match the HTML5 specification:
https://html.spec.whatwg.org/multipage/dnd.html#concept-dnd-rw
https://html.spec.whatwg.org/multipage/dnd.html#dom-datatransfer-setdragimage
or the behaviors of other browsers such as Chrome and Firefox.
No new tests. This patch simply removes code.
* dom/DataTransfer.cpp:
(WebCore::DataTransfer::setDragImage):
(WebCore::DataTransfer::canSetDragImage const): Deleted.
* dom/DataTransfer.h:
(WebCore::DataTransfer::makeDragImageWritable): Deleted.
* page/EventHandler.cpp:
(WebCore::EventHandler::handleDrag):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220951
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2017-08-18 Ryosuke Niwa <rniwa@webkit.org>
+
+ Forbid setDragImage after dragstart
+ https://bugs.webkit.org/show_bug.cgi?id=175751
+
+ Reviewed by Wenson Hsieh.
+
+ Removed the code to allow setting the drag mage after dragstart had happened.
+
+ The feature was apparently used in Mac WebKit1 port but using it today causes the drag image
+ to disapepar while the user is moving the mouse cursor and being drawn once it's stopped
+ and results in the contionus flickering of the drag image.
+
+ The feaure was never supported in WebKit2 and doesn't match the HTML5 specification:
+ https://html.spec.whatwg.org/multipage/dnd.html#concept-dnd-rw
+ https://html.spec.whatwg.org/multipage/dnd.html#dom-datatransfer-setdragimage
+ or the behaviors of other browsers such as Chrome and Firefox.
+
+ No new tests. This patch simply removes code.
+
+ * dom/DataTransfer.cpp:
+ (WebCore::DataTransfer::setDragImage):
+ (WebCore::DataTransfer::canSetDragImage const): Deleted.
+ * dom/DataTransfer.h:
+ (WebCore::DataTransfer::makeDragImageWritable): Deleted.
+ * page/EventHandler.cpp:
+ (WebCore::EventHandler::handleDrag):
+
2017-08-18 Sam Weinig <sam@webkit.org>
[WebCrypto] Get rid of CryptoKeyData class and all its subclasses
return adoptRef(*new DataTransfer(accessMode, Pasteboard::createForDragAndDrop(dragData), type));
}
-bool DataTransfer::canSetDragImage() const
-{
- // Note that the spec doesn't actually allow drag image modification outside the dragstart
- // event. This capability is maintained for backwards compatiblity for ports that have
- // supported this in the past. On many ports, attempting to set a drag image outside the
- // dragstart operation is a no-op anyway.
- return m_forDrag && (m_storeMode == StoreMode::DragImageWritable || m_storeMode == StoreMode::ReadWrite);
-}
-
void DataTransfer::setDragImage(Element* element, int x, int y)
{
- if (!canSetDragImage())
+ if (!m_forDrag || !canWriteData())
return;
CachedImage* image = nullptr;
class DataTransfer : public RefCounted<DataTransfer> {
public:
// https://html.spec.whatwg.org/multipage/dnd.html#drag-data-store-mode
- enum class StoreMode { Invalid, DragImageWritable, ReadWrite, Readonly, Protected };
+ enum class StoreMode { Invalid, ReadWrite, Readonly, Protected };
static Ref<DataTransfer> createForCopyAndPaste(StoreMode);
static Ref<DataTransfer> createForInputEvent(const String& plainText, const String& htmlText);
void setDragImage(Element*, int x, int y);
void makeInvalidForSecurity() { m_storeMode = StoreMode::Invalid; }
- void makeDragImageWritable()
- {
- ASSERT(m_storeMode != StoreMode::Invalid);
- m_storeMode = StoreMode::DragImageWritable;
- }
bool canReadTypes() const;
bool canReadData() const;
enum class Type { CopyAndPaste, DragAndDropData, DragAndDropFiles, InputEvent };
DataTransfer(StoreMode, std::unique_ptr<Pasteboard>, Type = Type::CopyAndPaste);
-#if ENABLE(DRAG_SUPPORT)
- bool canSetDragImage() const;
-#endif
-
StoreMode m_storeMode;
std::unique_ptr<Pasteboard> m_pasteboard;
std::unique_ptr<DataTransferItemList> m_itemList;
m_mouseDownMayStartDrag = dispatchDragSrcEvent(eventNames().dragstartEvent, m_mouseDown)
&& !m_frame.selection().selection().isInPasswordField();
- // Invalidate dataTransfer here against anymore pasteboard writing for security. The drag
- // image can still be changed as we drag, but not the pasteboard data.
- dragState().dataTransfer->makeDragImageWritable();
+ dragState().dataTransfer->makeInvalidForSecurity();
if (m_mouseDownMayStartDrag) {
// Gather values from DHTML element, if it set any.