Bug 773983 - Switch to new drag and drop api for urlbar proxyIcon r=neil

This commit is contained in:
Ian Neal 2012-07-16 16:00:03 +01:00
Родитель 639881ec83
Коммит d314abc13b
3 изменённых файлов: 29 добавлений и 29 удалений

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

@ -2269,15 +2269,6 @@ function SetPageProxyState(aState, aURI)
}
}
function PageProxyDragGesture(aEvent)
{
if (gProxyButton.getAttribute("pageproxystate") == "valid") {
nsDragAndDrop.startDrag(aEvent, proxyIconDNDObserver);
return true;
}
return false;
}
function handlePageProxyClick(aEvent)
{
switch (aEvent.button) {

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

@ -280,12 +280,11 @@
</box>
<deck id="page-proxy-deck"
class="urlbar-icons"
ondragstart="proxyIconDNDObserver.onDragStart(event);"
onclick="handlePageProxyClick(event);">
<image id="page-proxy-button"
ondraggesture="PageProxyDragGesture(event);"
tooltiptext="&proxyIcon.tooltip;"/>
<image id="page-proxy-favicon" validate="never"
ondraggesture="PageProxyDragGesture(event);"
onload="this.parentNode.selectedIndex = 1;
event.stopPropagation();"
onerror="gBrowser.addToMissedIconCache(this.src);"

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

@ -40,26 +40,36 @@ var RDFUtils = {
}
}
var proxyIconDNDObserver = {
onDragStart: function (aEvent, aXferData, aDragAction)
{
var urlBar = document.getElementById("urlbar");
// XXX - do we want to allow the user to set a blank page to their homepage?
// if so then we want to modify this a little to set about:blank as
// the homepage in the event of an empty urlbar.
if (!urlBar.value) return;
var urlString = urlBar.value + "\n" + window.content.document.title;
var htmlString = "<a href=\"" + urlBar.value + "\">" + urlBar.value + "</a>";
aXferData.data = new TransferData();
aXferData.data.addDataForFlavour("text/x-moz-url", urlString);
aXferData.data.addDataForFlavour("text/unicode", urlBar.value);
aXferData.data.addDataForFlavour("text/html", htmlString);
}
function htmlEscape(aString)
{
return aString.replace(/&/g, "&amp;")
.replace(/>/g, "&gt;")
.replace(/</g, "&lt;")
.replace(/"/g, "&quot;")
.replace(/'/g, "&apos;");
}
function BeginDragLink(aEvent, aHref, aTitle)
{
var dt = aEvent.dataTransfer;
dt.setData("text/x-moz-url", aHref + "\n" + aTitle);
dt.setData("text/uri-list", aHref);
dt.setData("text/html", "<a href=\"" + htmlEscape(aHref) +
"\">" + htmlEscape(aTitle) + "</a>");
dt.setData("text/plain", aHref);
}
var proxyIconDNDObserver = {
onDragStart: function (aEvent)
{
if (gProxyButton.getAttribute("pageproxystate") != "valid")
return;
BeginDragLink(aEvent, window.content.location.href,
window.content.document.title);
}
};
var homeButtonObserver = {
onDragStart: function (aEvent, aXferData, aDragAction)
{