Closed
Bug 578757
Opened 15 years ago
Closed 14 years ago
Gears drag and drop fails under windows 7 with FF 3.6.6 because setDropEffect broken
Categories
(Core :: Widget: Win32, defect)
Tracking
()
RESOLVED
WONTFIX
People
(Reporter: tlhackque, Unassigned)
Details
Attachments
(2 files)
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; HPDTDF; .NET4.0C; .NET4.0E)
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6
Google Gears provides drag-and-drop for Firefox and other browsers. It works under windows XP, but fails under windows 7. It's not clear whether this is a Firefox problem or a Gears problem. So I've reported it in both places - especially since Gears is, er, not on the fast track at the moment.
Specifically, if one sets up a drop zone on an element, the cursor doesn't change to 'copy' when dragging a file over it; it changes to 'prohibited'.
I've created a reproducer, which I'll paste in the additional info box below.
YOu can also see this live on the plupload.com site -- Drag any .jpg over the Gears box on http://www.plupload.com/example_all_runtimes.php (with Gears installed, of course!). Note that the cursor doesn't change to 'copy' (it shows prohibited) and if you drop anyway, nothing happens.
Same browser, same file, same URL under XP works.
Reproducible: Always
Steps to Reproduce:
1. Save HTML/script below as a file on local disk
2. open with browser
3. drag any file onto the 'drop here' box
Actual Results:
Result for FF are here. Results for other browers are in the Gears bug report (referenced below).
Note that FF works under XP, and other browsers work under W7...
o Box turns from white to green when the file hovers over the box
W7:
FF:OK
XP:
FF: No, but turns red on drop (cursor moving to alert)
o Cursor changes to 'copy' when the file hovers over the box
W7:
FF: Shows 'prohibited; ('none') instead of 'copy'
XP:
FF: No, does not change
o Box turns red if cursor leaves box (or if bad drag data)
W7:
FF:OK
XP:
FF: No, seems not to deliver events while mouse button depressed
o Drop produces an alert
W7:
FF:Box turns red, firebug shows a dragleave event There is no drop.
XP:
FF: OK
o Box turns yellow after alert
W7:
FF:No drop event
XP:
FF: OK
Expected Results:
What's expected:
o Box turns from white to green when the file hovers over the box
o Cursor changes to 'copy' when the file hovers over the box
o Box turns red if cursor leaves box (or if bad drag data)
o Drop produces an alert
o Box turns yellow after alert
Gears bug report is http://code.google.com/p/gears/issues/detail?id=1021
As best I can tell, FF is rejecting whatever setDropEffect call is being made by Gears...
---Cut here
<html>
<head>
<script type="text/javascript" charset="utf-8" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" charset="utf-8" src="http://code.google.com/apis/gears/gears_init.js"></script>
</head>
<body>
<script type="text/javascript">
$(function() {
/* Check for Google Gears. */
if (!window.google || !google.gears || typeof(google.gears.factory.create) == 'undefined') {
alert( "No google");
return;
}
var desktop;
try {
desktop = google.gears.factory.create('beta.desktop');
} catch( ex ) {
alert( "Unable to create gears desktop: " + ex.message );
}
var FILES = 'application/x-gears-files';
function preventDefault(evt) {
if (evt.preventDefault) {
evt.preventDefault();
}
evt.returnValue = false;
}
function validFiles(data) {
var accept = (data && data.count);
return accept;
}
function setZone(evt, accept) {
if( accept ) {
$('#dropzone').css('background-color','green');
try {
desktop.setDropEffect(evt, 'copy' );
} catch( ex ) {
alert( ex.message );
}
} else {
desktop.setDropEffect(evt, 'none' );
$('#dropzone').css('background-color','red');
}
}
var dragEnter =
function(event) {
var evt = event || window.event;
var data = desktop.getDragData(evt, FILES);
// Drag enters dropzone element
// Change color if a drop would be accepted
var accept = validFiles(data);
setZone(evt, accept );
// Prevent browser from opening files if dropped
if (!navigator.userAgent.match( /Firefox\/[2,3]\.0/) ) {
preventDefault(evt);
} else if (!accept) {
preventDefault(evt);
}
// Try to change cursor - will not work in IE until over the element
setZone(evt, accept, false);
};
var dragOver =
function(event) {
var evt = event || window.event;
var data = desktop.getDragData(evt, FILES);
var accept = validFiles(data);
// Cursor is over the dropzone element, try to change it
setZone(evt, accept, true);
// Ensure that browser will not act on this
if (!navigator.userAgent.match( /Firefox\/[2,3]\.0/) ) {
preventDefault(evt);
}
// Change the cursor to 'copy' or prohibited depending on
// Whether we will accept the drag contents
setZone(evt, accept, false);
}
var dragLeave =
function(event) {
// var evt = event || window.event;
// Drag leaving dropzone element. Restore background color
//
// Do NOT change cursor as leave may come before drop (or drop may never come)
$('#dropzone').css('background-color','red');
};
function addEvent(element, type, handler) {
if (element.addEventListener) {
element.addEventListener(type, handler, false);
} else if (element.attachEvent) {
element.attachEvent('on' + type, handler);
} else {
alert( "Unable to add drag and drop event " + type );
}
}
var html5 = true;
if (navigator.userAgent.match( /Firefox\/[2,3]\.0/ )) {
html5 = false;
}
var dzele = $('#dropzone').get(0);
if( !dzele ) {
alert( 'dropzone element not found on page' );
return false;
}
function dragDrop(event) {
var evt = event || window.event;
data = desktop.getDragData(event, FILES);
if( ! (data != null && data.files) ) {
alert( "Drop with null dat or no files array" );
return;
}
// Timing of dragDrop and dragLeave seems variable
if( validFiles(data) ) {
alert( "Successful Drop" );
}
if( navigator.userAgent.match( /Firefox\/.*/ ) ) {
evt.stopPropagation();
} else{
if( navigator.userAgent.match( /MSIE [5,6]/) ) {
evt.dataTransfer.dropEffect = 'none';
evt.returnValue = false;
}
}
/* Fix Safari forgetting the background change after drop. */
$('#dropzone').css('background-color','yellow');
}
addEvent(dzele, 'dragenter', dragEnter);
addEvent(dzele, 'dragover', dragOver);
addEvent(dzele, html5 ? 'dragleave' : 'dragexit', dragLeave);
addEvent(dzele, html5 ? 'drop' : 'dragdrop', dragDrop);
});
</script>
<div id='dropzone' style='border:solid;width:200px;height:200px' >
Drop here.
</div>
Updated•15 years ago
|
Component: General → Widget: Win32
Product: Firefox → Core
QA Contact: general → win32
Version: unspecified → 1.9.2 Branch
Curiouser and curiouser.
It seems that simply reading <event>.dataTransfer.dropEffect after calling setDropEffect will make this work!
The **only** difference between the previous test case and this one is the line:
window['fred'] = evt.dataTransfer.dropEffect;
window.fred is not used anywhere else - it's coded that way so that any optimizer can't remove the apparently useless read.
So it seems that accessing dataTransfer.dropEffect has the side effect of making setDropEffect's change visible. There must be native code magic behind this...
Comment 3•14 years ago
|
||
"Gears is deprecated and will no longer be available as of December 2012."
Reference: http://gears.google.com/
Since that is only a few months away I am going to mark this as RESOLVED|WONTFIX.
Status: UNCONFIRMED → RESOLVED
Closed: 14 years ago
Resolution: --- → WONTFIX
You need to log in
before you can comment on or make changes to this bug.
Description
•