bug 276707, JS Error when dragging address card with no email address to compose window address widget, patch by Mark Banner, r=bienvenu, sr=mscott, a=chofmann

This commit is contained in:
axel%pike.org 2005-05-02 16:08:32 +00:00
Родитель 2607d79d3e
Коммит 61750e8ffe
7 изменённых файлов: 88 добавлений и 84 удалений

Просмотреть файл

@ -3084,6 +3084,10 @@ var envelopeDragObserver = {
document.getElementById("attachmentbucket-sizer").hidden=false;
}
}
else
{
DragAddressOverTargetControl(aEvent);
}
},
onDragExit: function (aEvent, aDragSession)

Просмотреть файл

@ -78,6 +78,7 @@
<script type="application/x-javascript" src="chrome://messenger/content/messengercompose/MsgComposeCommands.js"/>
<!-- drag and drop -->
<script type="application/x-javascript" src="chrome://messenger/content/addressbook/abDragDrop.js"/>
<script type="application/x-javascript" src="chrome://global/content/nsDragAndDrop.js"/>
<script type="application/x-javascript" src="chrome://global/content/nsTransferable.js"/>

Просмотреть файл

@ -197,3 +197,77 @@ var abDirTreeObserver = {
{
}
}
function DragAddressOverTargetControl(event)
{
var dragSession = gDragService.getCurrentSession();
if (!dragSession.isDataFlavorSupported("text/x-moz-address"))
return;
try {
trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable);
trans.addDataFlavor("text/x-moz-address");
}
catch (ex) {
return;
}
var canDrop = true;
for ( var i = 0; i < dragSession.numDropItems; ++i )
{
dragSession.getData ( trans, i );
var dataObj = new Object();
var bestFlavor = new Object();
var len = new Object();
try
{
trans.getAnyTransferData ( bestFlavor, dataObj, len );
}
catch (ex)
{
canDrop = false;
break;
}
}
dragSession.canDrop = canDrop;
}
function DropAddressOverTargetControl(event)
{
var dragSession = gDragService.getCurrentSession();
var trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable);
trans.addDataFlavor("text/x-moz-address");
for ( var i = 0; i < dragSession.numDropItems; ++i )
{
dragSession.getData ( trans, i );
var dataObj = new Object();
var bestFlavor = new Object();
var len = new Object();
// Ensure we catch any empty data that may have slipped through
try
{
trans.getAnyTransferData ( bestFlavor, dataObj, len);
}
catch (ex)
{
continue;
}
if ( dataObj )
dataObj = dataObj.value.QueryInterface(Components.interfaces.nsISupportsString);
if ( !dataObj )
continue;
// pull the address out of the data object
var address = dataObj.data.substring(0, len.value);
if (!address)
continue;
DropRecipient(address);
}
}

Просмотреть файл

@ -370,46 +370,9 @@ function UpdateCardView()
// in the select address dialog, do nothing
}
function DragOverBucketPane(event)
function DropRecipient(address)
{
var dragSession = gDragService.getCurrentSession();
if (dragSession.isDataFlavorSupported("text/x-moz-address"))
dragSession.canDrop = true;
}
function DropOnBucketPane(event)
{
var dragSession = gDragService.getCurrentSession();
var trans;
try {
trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable);
trans.addDataFlavor("text/x-moz-address");
}
catch (ex) {
return;
}
for ( var i = 0; i < dragSession.numDropItems; ++i )
{
dragSession.getData ( trans, i );
var dataObj = new Object();
var bestFlavor = new Object();
var len = new Object();
trans.getAnyTransferData ( bestFlavor, dataObj, len );
if ( dataObj )
dataObj = dataObj.value.QueryInterface(Components.interfaces.nsISupportsString);
if ( !dataObj )
continue;
// pull the address out of the data object
var address = dataObj.data.substring(0, len.value);
if (!address)
continue;
AddAddressIntoBucket(prefixTo, address, address);
}
AddAddressIntoBucket(prefixTo, address, address);
}
function OnReturnHit(event)

Просмотреть файл

@ -67,6 +67,7 @@
<stringbundle id="bundle_composeMsgs" src="chrome://messenger/locale/messengercompose/composeMsgs.properties"/>
<script type="application/x-javascript" src="chrome://messenger/content/addressbook/abCommon.js"/>
<script type="application/x-javascript" src="chrome://messenger/content/addressbook/abSelectAddressesDialog.js"/>
<script type="application/x-javascript" src="chrome://messenger/content/addressbook/abDragDrop.js"/>
<script type="application/x-javascript" src="chrome://messenger/content/messengercompose/MsgComposeCommands.js"/>
<script type="application/x-javascript" src="chrome://global/content/globalOverlay.js"/>
@ -127,8 +128,8 @@
<vbox id="bucketBox" flex="1">
<label value="&addressMessageTo.label;"/>
<tree id="addressBucket" flex="1" hidecolumnpicker="true"
ondragover="DragOverBucketPane(event);"
ondragdrop="DropOnBucketPane(event);"
ondragover="DragAddressOverTargetControl(event);"
ondragdrop="DropAddressOverTargetControl(event);"
onselect="DialogBucketPaneSelectionChanged();">
<treecols>
<treecol id="addressCol" flex="1" hideheader="true"/>

Просмотреть файл

@ -752,47 +752,7 @@ function awGetNumberOfRecipients()
return top.MAX_RECIPIENTS;
}
function DragOverAddressingWidget(event)
{
var validFlavor = false;
var dragSession = dragSession = gDragService.getCurrentSession();
if (dragSession.isDataFlavorSupported("text/x-moz-address"))
validFlavor = true;
if (validFlavor)
dragSession.canDrop = true;
}
function DropOnAddressingWidget(event)
{
var dragSession = gDragService.getCurrentSession();
var trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance(Components.interfaces.nsITransferable);
trans.addDataFlavor("text/x-moz-address");
for ( var i = 0; i < dragSession.numDropItems; ++i )
{
dragSession.getData ( trans, i );
var dataObj = new Object();
var bestFlavor = new Object();
var len = new Object();
trans.getAnyTransferData ( bestFlavor, dataObj, len );
if ( dataObj )
dataObj = dataObj.value.QueryInterface(Components.interfaces.nsISupportsString);
if ( !dataObj )
continue;
// pull the address out of the data object
var address = dataObj.data.substring(0, len.value);
if (!address)
continue;
DropRecipient(event.target, address);
}
}
function DropRecipient(target, recipient)
function DropRecipient(recipient)
{
// break down and add each address
return parseAndAddAddresses(recipient, awGetPopupElement(top.MAX_RECIPIENTS).selectedItem.getAttribute("value"));

Просмотреть файл

@ -43,13 +43,14 @@
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/x-javascript" src="chrome://messenger/content/messengercompose/addressingWidgetOverlay.js"/>
<script type="application/x-javascript" src="chrome://messenger/content/addressbook/abDragDrop.js"/>
<!-- Addressing Widget -->
<listbox id="addressingWidget" seltype="multiple" rows="4"
onkeydown="awKeyDown(event, this)"
onclick="awClickEmptySpace(event.originalTarget, true)"
ondragover="DragOverAddressingWidget(event);"
ondragdrop="return DropOnAddressingWidget(event);">
ondragover="DragAddressOverTargetControl(event);"
ondragdrop="DropAddressOverTargetControl(event);">
<listcols>
<listcol id="typecol-addressingWidget"/>