Bug 587901 - Make the identity box draggable. r+a=dolske

--HG--
extra : rebase_source : cb1b8aa08d86db86199bfb28a35dc758f9f4270f
This commit is contained in:
Dão Gottwald 2010-09-08 17:10:46 +02:00
parent d77d338142
commit e189e449af
3 changed files with 23 additions and 26 deletions

View File

@ -2870,25 +2870,7 @@ var browserDragAndDrop = {
},
drop: function (aEvent, aName) Services.droppedLinkHandler.dropLink(aEvent, aName)
}
var proxyIconDNDObserver = {
onDragStart: function (aEvent, aXferData, aDragAction)
{
if (gProxyFavIcon.getAttribute("pageproxystate") != "valid")
return;
var value = content.location.href;
var urlString = value + "\n" + content.document.title;
var htmlString = "<a href=\"" + value + "\">" + value + "</a>";
var dt = aEvent.dataTransfer;
dt.setData("text/x-moz-url", urlString);
dt.setData("text/uri-list", value);
dt.setData("text/plain", value);
dt.setData("text/html", htmlString);
}
}
};
var homeButtonObserver = {
onDrop: function (aEvent)
@ -7225,6 +7207,22 @@ var gIdentityHandler = {
// Now open the popup, anchored off the primary chrome element
this._identityPopup.openPopup(this._identityBox, position);
},
onDragStart: function (event) {
if (gURLBar.getAttribute("pageproxystate") != "valid")
return;
var value = content.location.href;
var urlString = value + "\n" + content.document.title;
var htmlString = "<a href=\"" + value + "\">" + value + "</a>";
var dt = event.dataTransfer;
dt.setData("text/x-moz-url", urlString);
dt.setData("text/uri-list", value);
dt.setData("text/plain", value);
dt.setData("text/html", htmlString);
dt.setDragImage(event.currentTarget, 0, 0);
}
};

View File

@ -886,14 +886,14 @@
has focus, otherwise pressing F6 focuses it instead of the location bar -->
<box id="identity-box" role="button"
onclick="gIdentityHandler.handleIdentityButtonEvent(event);"
onkeypress="gIdentityHandler.handleIdentityButtonEvent(event);">
onkeypress="gIdentityHandler.handleIdentityButtonEvent(event);"
ondragstart="gIdentityHandler.onDragStart(event);">
<hbox id="identity-box-inner" align="center">
<stack id="page-proxy-stack"
onclick="PageProxyClickHandler(event);">
<image id="urlbar-throbber" busy="false"/>
<image id="page-proxy-favicon" validate="never"
pageproxystate="invalid"
ondragstart="proxyIconDNDObserver.onDragStart(event);"
onerror="this.removeAttribute('src');"/>
</stack>
<hbox id="identity-icon-labels">

View File

@ -17,12 +17,11 @@ function test()
data : htmlString }
] ];
// set the valid attribute so dropping is allowed
var proxyicon = document.getElementById("page-proxy-favicon")
var oldstate = proxyicon.getAttribute("pageproxystate");
proxyicon.setAttribute("pageproxystate", "valid");
var dt = EventUtils.synthesizeDragStart(proxyicon, expected);
var oldstate = gURLBar.getAttribute("pageproxystate");
gURLBar.setAttribute("pageproxystate", "valid");
var dt = EventUtils.synthesizeDragStart(document.getElementById("identity-box"), expected);
is(dt, null, "drag on proxy icon");
proxyicon.setAttribute("pageproxystate", oldstate);
gURLBar.setAttribute("pageproxystate", oldstate);
// Now, the identity information panel is opened by the proxy icon click.
// We need to close it for next tests.
EventUtils.synthesizeKey("VK_ESCAPE", {}, window);