Bug 1444686 part 1. Get rid of nsIDOMDataTransfer::Get/SetDropEffect. r=mystor

MozReview-Commit-ID: 6Kn9uuaQYI0
This commit is contained in:
Boris Zbarsky 2018-03-13 16:23:59 -04:00
parent 4500b075c6
commit 4968b166a6
6 changed files with 51 additions and 53 deletions

View File

@ -223,16 +223,7 @@ DataTransfer::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
return DataTransferBinding::Wrap(aCx, this, aGivenProto);
}
NS_IMETHODIMP
DataTransfer::GetDropEffect(nsAString& aDropEffect)
{
nsString dropEffect;
GetDropEffect(dropEffect);
aDropEffect = dropEffect;
return NS_OK;
}
NS_IMETHODIMP
void
DataTransfer::SetDropEffect(const nsAString& aDropEffect)
{
// the drop effect can only be 'none', 'copy', 'move' or 'link'.
@ -246,8 +237,6 @@ DataTransfer::SetDropEffect(const nsAString& aDropEffect)
break;
}
}
return NS_OK;
}
NS_IMETHODIMP

View File

@ -128,10 +128,38 @@ public:
Constructor(const GlobalObject& aGlobal, const nsAString& aEventType,
bool aIsExternal, ErrorResult& aRv);
void GetDropEffect(nsString& aDropEffect)
/**
* The actual effect that will be used, and should always be one of the
* possible values of effectAllowed.
*
* For dragstart, drag and dragleave events, the dropEffect is initialized
* to none. Any value assigned to the dropEffect will be set, but the value
* isn't used for anything.
*
* For the dragenter and dragover events, the dropEffect will be initialized
* based on what action the user is requesting. How this is determined is
* platform specific, but typically the user can press modifier keys to
* adjust which action is desired. Within an event handler for the dragenter
* and dragover events, the dropEffect should be modified if the action the
* user is requesting is not the one that is desired.
*
* For the drop and dragend events, the dropEffect will be initialized to
* the action that was desired, which will be the value that the dropEffect
* had after the last dragenter or dragover event.
*
* Possible values:
* copy - a copy of the source item is made at the new location
* move - an item is moved to a new location
* link - a link is established to the source at the new location
* none - the item may not be dropped
*
* Assigning any other value has no effect and retains the old value.
*/
void GetDropEffect(nsAString& aDropEffect)
{
aDropEffect.AssignASCII(sEffects[mDropEffect]);
}
void SetDropEffect(const nsAString& aDropEffect);
void GetEffectAllowed(nsString& aEffectAllowed)
{

View File

@ -36,6 +36,11 @@ public:
return DragEventBinding::Wrap(aCx, this, aGivenProto);
}
DragEvent* AsDragEvent() override
{
return this;
}
DataTransfer* GetDataTransfer();
void InitDragEvent(const nsAString& aType,

View File

@ -30,6 +30,7 @@ namespace mozilla {
namespace dom {
class BeforeUnloadEvent;
class DragEvent;
class EventTarget;
class EventMessageAutoOverride;
// ExtendableEvent is a ServiceWorker event that is not
@ -126,6 +127,12 @@ public:
return nullptr;
}
// DragEvent has a non-autogeneratable initDragEvent.
virtual DragEvent* AsDragEvent()
{
return nullptr;
}
// nsIDOMEvent Interface
NS_DECL_NSIDOMEVENT

View File

@ -11,35 +11,6 @@ interface nsIDOMFileList;
[builtinclass, uuid(655078bf-1675-4aa0-a48d-a133e864ce57)]
interface nsIDOMDataTransfer : nsISupports
{
/**
* The actual effect that will be used, and should always be one of the
* possible values of effectAllowed.
*
* For dragstart, drag and dragleave events, the dropEffect is initialized
* to none. Any value assigned to the dropEffect will be set, but the value
* isn't used for anything.
*
* For the dragenter and dragover events, the dropEffect will be initialized
* based on what action the user is requesting. How this is determined is
* platform specific, but typically the user can press modifier keys to
* adjust which action is desired. Within an event handler for the dragenter
* and dragover events, the dropEffect should be modified if the action the
* user is requesting is not the one that is desired.
*
* For the drop and dragend events, the dropEffect will be initialized to
* the action that was desired, which will be the value that the dropEffect
* had after the last dragenter or dragover event.
*
* Possible values:
* copy - a copy of the source item is made at the new location
* move - an item is moved to a new location
* link - a link is established to the source at the new location
* none - the item may not be dropped
*
* Assigning any other value has no effect and retains the old value.
*/
attribute DOMString dropEffect;
/*
* Specifies the effects that are allowed for this drag. You may set this in
* the dragstart event to set the desired effects for the source, and within

View File

@ -11,8 +11,12 @@
#include "nsIDocument.h"
#include "mozilla/dom/NodeInfo.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/DataTransfer.h"
#include "mozilla/dom/DOMPrefs.h"
#include "mozilla/dom/DOMStringList.h"
#include "mozilla/dom/DataTransfer.h"
#include "mozilla/dom/Directory.h"
#include "mozilla/dom/DragEvent.h"
#include "mozilla/dom/FileList.h"
#include "mozilla/dom/HTMLButtonElement.h"
#include "mozilla/dom/HTMLInputElement.h"
#include "mozilla/dom/MutationEventBinding.h"
@ -21,10 +25,6 @@
#include "nsContentCreatorFunctions.h"
#include "nsContentUtils.h"
#include "mozilla/EventStates.h"
#include "mozilla/dom/DOMStringList.h"
#include "mozilla/dom/Directory.h"
#include "mozilla/dom/FileList.h"
#include "nsIDOMDragEvent.h"
#include "nsIDOMFileList.h"
#include "nsTextNode.h"
@ -238,19 +238,17 @@ nsFileControlFrame::DnDListener::HandleEvent(nsIDOMEvent* aEvent)
{
NS_ASSERTION(mFrame, "We should have been unregistered");
bool defaultPrevented = false;
aEvent->GetDefaultPrevented(&defaultPrevented);
if (defaultPrevented) {
Event* event = aEvent->InternalDOMEvent();
if (event->DefaultPrevented()) {
return NS_OK;
}
nsCOMPtr<nsIDOMDragEvent> dragEvent = do_QueryInterface(aEvent);
DragEvent* dragEvent = event->AsDragEvent();
if (!dragEvent) {
return NS_OK;
}
nsCOMPtr<nsIDOMDataTransfer> dataTransfer;
dragEvent->GetDataTransfer(getter_AddRefs(dataTransfer));
RefPtr<DataTransfer> dataTransfer = dragEvent->GetDataTransfer();
if (!IsValidDropData(dataTransfer)) {
return NS_OK;
}