зеркало из https://github.com/mozilla/gecko-dev.git
Fix 48876: make d&d and modifier-/middle-click possible throughout the app and implement selection within link (50673). Also fixes 59520, 48780, 48632, 57588, 59132. r=jag sr=alecf
This commit is contained in:
Родитель
6ca07d1125
Коммит
be05193ddf
|
@ -74,28 +74,6 @@ catch (ex)
|
|||
// focused frame URL
|
||||
var gFocusedURL = null;
|
||||
|
||||
/**
|
||||
* Save the document at a given location to disk
|
||||
**/
|
||||
function savePage( url )
|
||||
{
|
||||
// Default is to save current page.
|
||||
url = url ? url : window._content.location.href;
|
||||
// Use stream xfer component to prompt for destination and save.
|
||||
var xfer = getService("@mozilla.org/appshell/component/xfer;1", "nsIStreamTransfer");
|
||||
try {
|
||||
// Save; use page in cache if possible.
|
||||
var postData = appCore.postData;
|
||||
xfer.SelectFileAndTransferLocationSpec( url, window, "", "", true, postData );
|
||||
return true;
|
||||
}
|
||||
catch( exception ) {
|
||||
// suppress NS_ERROR_ABORT exceptions for cancellation
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* We can avoid adding multiple load event listeners and save some time by adding
|
||||
* one listener that calls all real handlers.
|
||||
|
@ -602,22 +580,12 @@ function Shutdown()
|
|||
|
||||
function gotoHistoryIndex( aEvent )
|
||||
{
|
||||
var index = aEvent.target.getAttribute("index");
|
||||
if (index)
|
||||
{
|
||||
appCore.gotoHistoryIndex(index);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
var id = aEvent.target.getAttribute("id");
|
||||
if (id == "menuitem-back")
|
||||
BrowserBack();
|
||||
else if (id == "menuitem-forward")
|
||||
BrowserForward();
|
||||
}
|
||||
|
||||
return false;
|
||||
var index = aEvent.target.getAttribute("index");
|
||||
if (index) {
|
||||
appCore.gotoHistoryIndex(index);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function BrowserBack()
|
||||
|
@ -671,62 +639,48 @@ function BrowserHome()
|
|||
RefreshUrlbar();
|
||||
}
|
||||
|
||||
function OpenBookmarkURL(node, datasources)
|
||||
{
|
||||
// what is the meaning of the return value from this function?
|
||||
|
||||
if (node.getAttribute('container') == "true") {
|
||||
return false;
|
||||
}
|
||||
function OpenBookmarkURL(event, datasources)
|
||||
{
|
||||
// what is the meaning of the return value from this function?
|
||||
var node = event.target;
|
||||
if (node.getAttribute('container') == "true")
|
||||
return null;
|
||||
|
||||
var url = node.getAttribute('id');
|
||||
try
|
||||
{
|
||||
// add support for IE favorites under Win32, and NetPositive URLs under BeOS
|
||||
var rdf = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService();
|
||||
if (rdf) rdf = rdf.QueryInterface(Components.interfaces.nsIRDFService);
|
||||
if (rdf && datasources)
|
||||
{
|
||||
var src = rdf.GetResource(url, true);
|
||||
var prop = rdf.GetResource("http://home.netscape.com/NC-rdf#URL", true);
|
||||
var target = datasources.GetTarget(src, prop, true);
|
||||
if (target) target = target.QueryInterface(Components.interfaces.nsIRDFLiteral);
|
||||
if (target) target = target.Value;
|
||||
if (target) url = target;
|
||||
}
|
||||
}
|
||||
catch(ex)
|
||||
{
|
||||
}
|
||||
|
||||
// Ignore "NC:" urls.
|
||||
if (url.substring(0, 3) == "NC:") {
|
||||
return false;
|
||||
var url = node.getAttribute('id');
|
||||
try {
|
||||
// add support for IE favorites under Win32, and NetPositive URLs under BeOS
|
||||
var rdf = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService();
|
||||
if (rdf)
|
||||
rdf = rdf.QueryInterface(Components.interfaces.nsIRDFService);
|
||||
if (rdf && datasources) {
|
||||
var src = rdf.GetResource(url, true);
|
||||
var prop = rdf.GetResource("http://home.netscape.com/NC-rdf#URL", true);
|
||||
var target = datasources.GetTarget(src, prop, true);
|
||||
if (target)
|
||||
target = target.QueryInterface(Components.interfaces.nsIRDFLiteral);
|
||||
if (target)
|
||||
target = target.Value;
|
||||
if (target)
|
||||
url = target;
|
||||
}
|
||||
// Check if we have a browser window
|
||||
if ( window._content == null )
|
||||
{
|
||||
window.openDialog( getBrowserURL(), "_blank", "chrome,all,dialog=no", url );
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//window._content.location.href = url;
|
||||
if (appCore)
|
||||
{
|
||||
appCore.loadUrl(url);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
dump("BrowserAppCore is not initialised\n");
|
||||
return false;
|
||||
}
|
||||
RefreshUrlbar();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
catch(ex) {
|
||||
return null;
|
||||
}
|
||||
// Ignore "NC:" urls.
|
||||
if (url.substring(0, 3) == "NC:")
|
||||
return null;
|
||||
|
||||
// Check if we have a browser window
|
||||
if (!window._content) {
|
||||
window.openDialog( getBrowserURL(), "_blank", "chrome,all,dialog=no", url );
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
loadURI(url);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function OpenSearch(tabName, forceDialogFlag, searchStr)
|
||||
{
|
||||
|
@ -928,50 +882,6 @@ function RevealSearchPanel()
|
|||
return Components.classesByID[ cid ].getService( iid );
|
||||
}
|
||||
|
||||
function openNewWindowWith( url ) {
|
||||
|
||||
// URL Loading Security Check
|
||||
const nsIStandardURL = Components.interfaces.nsIStandardURL;
|
||||
const nsIURI = Components.interfaces.nsIURI;
|
||||
const stdURL = Components.classes["@mozilla.org/network/standard-url;1"];
|
||||
|
||||
var sourceURL = stdURL.createInstance(nsIStandardURL);
|
||||
var focusedWindow = document.commandDispatcher.focusedWindow;
|
||||
var sourceWin = isDocumentFrame(focusedWindow) ? focusedWindow.location.href : window._content.location.href;
|
||||
sourceURL.init(nsIStandardURL.URLTYPE_STANDARD, 80, sourceWin, null);
|
||||
|
||||
var targetURL = stdURL.createInstance(nsIStandardURL);
|
||||
targetURL.init(nsIStandardURL.URLTYPE_STANDARD, 80, url, null);
|
||||
|
||||
const nsIScriptSecurityManager = Components.interfaces.nsIScriptSecurityManager;
|
||||
var secMan = Components.classes["@mozilla.org/scriptsecuritymanager;1"].getService().
|
||||
QueryInterface(nsIScriptSecurityManager);
|
||||
secMan.CheckLoadURI(sourceURL, targetURL, nsIScriptSecurityManager.STANDARD);
|
||||
|
||||
var newWin;
|
||||
var wintype = document.firstChild.getAttribute('windowtype');
|
||||
|
||||
// if and only if the current window is a browser window and it has a document with a character
|
||||
// set, then extract the current charset menu setting from the current document and use it to
|
||||
// initialize the new browser window...
|
||||
if (window && (wintype == "navigator:browser") && window._content && window._content.document)
|
||||
{
|
||||
var DocCharset = window._content.document.characterSet;
|
||||
charsetArg = "charset="+DocCharset;
|
||||
dump("*** Current document charset: " + DocCharset + "\n");
|
||||
|
||||
//we should "inherit" the charset menu setting in a new window
|
||||
newWin = window.openDialog( getBrowserURL(), "_blank", "chrome,all,dialog=no", url, charsetArg );
|
||||
}
|
||||
else // forget about the charset information.
|
||||
{
|
||||
newWin = window.openDialog( getBrowserURL(), "_blank", "chrome,all,dialog=no", url );
|
||||
}
|
||||
|
||||
// Fix new window.
|
||||
newWin.saveFileAndPos = true;
|
||||
}
|
||||
|
||||
function BrowserOpenFileWindow()
|
||||
{
|
||||
// Get filepicker component.
|
||||
|
@ -1003,7 +913,6 @@ function RevealSearchPanel()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
function BrowserAddBookmark(url,title)
|
||||
{
|
||||
var bmks = Components.classes["@mozilla.org/browser/bookmarks-service;1"].getService();
|
||||
|
@ -1486,6 +1395,15 @@ function BrowserEditBookmarks()
|
|||
}
|
||||
}
|
||||
|
||||
function loadURI(href)
|
||||
{
|
||||
var content = document.getElementById("content")
|
||||
var boxObject = content.boxObject.QueryInterface(Components.interfaces.nsIBrowserBoxObject)
|
||||
var docShell = boxObject.docShell
|
||||
var webNavigation = docShell.QueryInterface(Components.interfaces.nsIWebNavigation)
|
||||
return webNavigation.loadURI(href, 0);
|
||||
}
|
||||
|
||||
function BrowserLoadURL()
|
||||
{
|
||||
// rjc: added support for URL shortcuts (3/30/1999)
|
||||
|
@ -1570,94 +1488,6 @@ function BrowserEditBookmarks()
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function findParentNode(node, parentNode)
|
||||
{
|
||||
while (node) {
|
||||
var nodeName = node.localName;
|
||||
if (nodeName == "")
|
||||
return null;
|
||||
nodeName = nodeName.toLowerCase();
|
||||
if (nodeName == "" || nodeName == "body" ||
|
||||
nodeName == "html" || nodeName == "#document") {
|
||||
return null;
|
||||
}
|
||||
if (nodeName == parentNode)
|
||||
return node;
|
||||
node = node.parentNode;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Called whenever the user clicks in the content area,
|
||||
// except when left-clicking on links (special case)
|
||||
// should always return true for click to go through
|
||||
function contentAreaClick(event)
|
||||
{
|
||||
var target = event.originalTarget;
|
||||
var linkNode;
|
||||
switch (target.localName.toLowerCase()) {
|
||||
case "a":
|
||||
linkNode = event.target;
|
||||
break;
|
||||
case "area":
|
||||
if (event.target.href)
|
||||
linkNode = event.target;
|
||||
break;
|
||||
default:
|
||||
linkNode = findParentNode(target, "a");
|
||||
break;
|
||||
}
|
||||
if (linkNode)
|
||||
return handleLinkClick(event, linkNode);
|
||||
|
||||
if (event.button == 2 &&
|
||||
!findParentNode(target, "scrollbar") &&
|
||||
pref.GetBoolPref("middlemouse.paste")) {
|
||||
return middleMousePaste(event);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function handleLinkClick(event, node)
|
||||
{
|
||||
switch (event.button) {
|
||||
case 1: // if left button clicked
|
||||
if (event.metaKey || event.ctrlKey) { // and meta or ctrl are down
|
||||
openNewWindowWith(node.href); // open link in new window
|
||||
event.preventBubble();
|
||||
return true;
|
||||
}
|
||||
if (event.shiftKey) // if shift is down
|
||||
return savePage(node.href); // save the link
|
||||
if (event.altKey) // if alt is down
|
||||
; // select text within link (not implemented)
|
||||
break;
|
||||
case 2: // if middle button clicked
|
||||
if (pref.GetBoolPref("middlemouse.openNewWindow")) { // and the pref is on
|
||||
openNewWindowWith(node.href); // open link in new window
|
||||
event.preventBubble();
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function middleMousePaste(event)
|
||||
{
|
||||
var url = readFromClipboard();
|
||||
//dump ("Loading URL on clipboard: '" + url + "'; length = " + url.length + "\n");
|
||||
if (url) {
|
||||
var urlBar = document.getElementById("urlbar");
|
||||
urlBar.value = url;
|
||||
BrowserLoadURL();
|
||||
event.preventBubble();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function OpenMessenger()
|
||||
{
|
||||
|
|
|
@ -55,21 +55,23 @@ Contributor(s): ______________________________________. -->
|
|||
screenX="10" screenY="10"
|
||||
persist="screenX screenY width height sizemode">
|
||||
|
||||
<script language="javascript" src="chrome://global/content/nsJSSupportsUtils.js"></script>
|
||||
<script language="javascript" src="chrome://global/content/nsJSComponentManager.js"></script>
|
||||
<script language="javascript" src="chrome://global/content/nsUserSettings.js"></script>
|
||||
<script language="javascript" src="chrome://global/content/nsTransferable.js"></script>
|
||||
<script language="javascript" src="chrome://global/content/nsClipboard.js"></script>
|
||||
<script language="javascript" src="chrome://global/content/nsDragAndDrop.js"></script>
|
||||
<script language="javascript" src="chrome://global/content/strres.js"></script>
|
||||
<script language="javascript" src="chrome://communicator/content/bookmarks/bookmarks.js"></script>
|
||||
<script language="javascript" src="chrome://navigator/content/navigator.js"></script>
|
||||
<script language="javascript" src="nsContextMenu.js"></script>
|
||||
<script language="javascript" src="tooltip.js"></script>
|
||||
<script language="javascript" src="navigatorDD.js"></script>
|
||||
<script type="text/javascript" src="chrome://global/content/nsJSSupportsUtils.js"/>
|
||||
<script type="text/javascript" src="chrome://global/content/nsJSComponentManager.js"/>
|
||||
<script type="text/javascript" src="chrome://global/content/nsUserSettings.js"/>
|
||||
<script type="text/javascript" src="chrome://global/content/nsTransferable.js"/>
|
||||
<script type="text/javascript" src="chrome://global/content/nsClipboard.js"/>
|
||||
<script type="text/javascript" src="chrome://global/content/nsDragAndDrop.js"/>
|
||||
<script type="text/javascript" src="chrome://global/content/strres.js"/>
|
||||
<script type="text/javascript" src="chrome://communicator/content/contentAreaUtils.js"/>
|
||||
<script type="text/javascript" src="chrome://communicator/content/contentAreaDD.js"/>
|
||||
<script type="text/javascript" src="chrome://communicator/content/bookmarks/bookmarks.js"/>
|
||||
<script type="text/javascript" src="chrome://navigator/content/navigator.js"/>
|
||||
<script type="text/javascript" src="nsContextMenu.js"/>
|
||||
<script type="text/javascript" src="tooltip.js"/>
|
||||
<script type="text/javascript" src="navigatorDD.js"/>
|
||||
|
||||
<!-- UI services -->
|
||||
<script language="javascript" src="chrome://navigator/content/sessionHistoryUI.js"></script>
|
||||
<script type="text/javascript" src="chrome://navigator/content/sessionHistoryUI.js"/>
|
||||
|
||||
<commands id="commands">
|
||||
<commandset id="globalEditMenuItems"/>
|
||||
|
@ -98,6 +100,11 @@ Contributor(s): ______________________________________. -->
|
|||
</popup>
|
||||
</popupset>
|
||||
|
||||
<popupset>
|
||||
<popup id="backMenu" oncreate="BrowserBackMenu(event);" oncommand="gotoHistoryIndex(event);"/>
|
||||
<popup id="forwardMenu" oncreate="BrowserForwardMenu(event);" oncommand="gotoHistoryIndex(event);"/>
|
||||
</popupset>
|
||||
|
||||
<!-- Context menu -->
|
||||
<script language="javascript">
|
||||
// Global variable that holds the nsContextMenu instance.
|
||||
|
@ -269,16 +276,14 @@ Contributor(s): ______________________________________. -->
|
|||
grippytooltip="aTooltip" grippytooltiptext="&navigationBar.tooltip;"
|
||||
tbautostretch="always">
|
||||
<box id="nav-bar-buttons">
|
||||
<menubutton class="menubutton-dual toolbar top" id="back-button" value="&backButton.label;"
|
||||
crop="right" observes="canGoBack" oncommand="gotoHistoryIndex(event);"
|
||||
tooltip="aTooltip"
|
||||
buttonaction="BrowserBack();" buttontooltiptext="&backButton.tooltip;">
|
||||
<menubutton id="back-button" value="&backButton.label;" buttontooltiptext="&backButton.tooltip;"
|
||||
oncommand="gotoHistoryIndex(event);" buttonaction="BrowserBack();" context="backMenu"
|
||||
class="menubutton-dual toolbar top" crop="right" tooltip="aTooltip" observes="canGoBack">
|
||||
<menupopup oncreate="BrowserBackMenu(event);"/>
|
||||
</menubutton>
|
||||
<menubutton class="menubutton-dual toolbar top" id="forward-button"
|
||||
crop="right" observes="canGoForward" tooltip="aTooltip"
|
||||
oncommand="gotoHistoryIndex(event);" buttonaction="BrowserForward();"
|
||||
value="&forwardButton.label;" buttontooltiptext="&forwardButton.tooltip;">
|
||||
<menubutton id="forward-button" value="&forwardButton.label;" buttontooltiptext="&forwardButton.tooltip;"
|
||||
oncommand="gotoHistoryIndex(event);" buttonaction="BrowserForward();" context="forwardMenu"
|
||||
class="menubutton-dual toolbar top" crop="right" tooltip="aTooltip" observes="canGoForward">
|
||||
<menupopup oncreate="BrowserForwardMenu(event);"/>
|
||||
</menubutton>
|
||||
|
||||
|
@ -391,7 +396,7 @@ Contributor(s): ______________________________________. -->
|
|||
<button class="button-toolbar bookmarkitem" uri="rdf:*"
|
||||
tooltip="aTooltip" tooltiptext="rdf:http://home.netscape.com/NC-rdf#URL"
|
||||
value="rdf:http://home.netscape.com/NC-rdf#Name" crop="right"
|
||||
oncommand="OpenBookmarkURL(event.target, document.getElementById('innermostBox').database);"/>
|
||||
oncommand="OpenBookmarkURL(event, document.getElementById('innermostBox').database);"/>
|
||||
</rule>
|
||||
|
||||
<rule iscontainer="true">
|
||||
|
|
|
@ -266,157 +266,6 @@ var personalToolbarObserver = {
|
|||
}
|
||||
};
|
||||
|
||||
var contentAreaDNDObserver = {
|
||||
onDragStart: function (aEvent)
|
||||
{
|
||||
dump("dragstart\n");
|
||||
var htmlstring = null;
|
||||
var textstring = null;
|
||||
var isLink = false;
|
||||
var domselection = window._content.getSelection();
|
||||
if (domselection && !domselection.isCollapsed &&
|
||||
domselection.containsNode(aEvent.target,false))
|
||||
{
|
||||
var privateSelection = domselection.QueryInterface(Components.interfaces.nsISelectionPrivate);
|
||||
if (privateSelection)
|
||||
{
|
||||
// the window has a selection so we should grab that rather than looking for specific elements
|
||||
htmlstring = privateSelection.toStringWithFormat("text/html", 128+256, 0);
|
||||
textstring = privateSelection.toStringWithFormat("text/plain", 0, 0);
|
||||
dump("we cool?\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dump("didnt get here\n");
|
||||
switch (aEvent.target.localName)
|
||||
{
|
||||
case 'AREA':
|
||||
case 'IMG':
|
||||
var imgsrc = aEvent.target.getAttribute("src");
|
||||
var baseurl = window._content.location.href;
|
||||
// need to do some stuff with the window._content.location (path?)
|
||||
// to get base URL for image.
|
||||
|
||||
textstring = imgsrc;
|
||||
htmlstring = "<img src=\"" + textstring + "\">";
|
||||
if ((linkNode = this.findEnclosingLink(aEvent.target))) {
|
||||
htmlstring = '<a href="' + linkNode.href + '">' + htmlstring + '</a>';
|
||||
textstring = linkNode.href;
|
||||
}
|
||||
break;
|
||||
case 'A':
|
||||
isLink = true;
|
||||
if (aEvent.target.href)
|
||||
{
|
||||
textstring = aEvent.target.getAttribute("href");
|
||||
htmlstring = "<a href=\"" + textstring + "\">" + textstring + "</a>";
|
||||
}
|
||||
else if (aEvent.target.name)
|
||||
{
|
||||
textstring = aEvent.target.getAttribute("name");
|
||||
htmlstring = "<a name=\"" + textstring + "\">" + textstring + "</a>"
|
||||
}
|
||||
break;
|
||||
default:
|
||||
case '#text':
|
||||
case 'LI':
|
||||
case 'OL':
|
||||
case 'DD':
|
||||
var node = this.findEnclosingLink(aEvent.target);
|
||||
textstring = "";
|
||||
//select node now!
|
||||
if (node)
|
||||
textstring = node.href;
|
||||
if (textstring != "")
|
||||
{
|
||||
htmlstring = "<a href=\"" + textstring + "\">" + textstring + "</a>";
|
||||
var parent = node.parentNode;
|
||||
if (parent)
|
||||
{
|
||||
var nodelist = parent.childNodes;
|
||||
var index;
|
||||
for (index = 0; index<nodelist.length; index++)
|
||||
{
|
||||
if (nodelist.item(index) == node)
|
||||
break;
|
||||
}
|
||||
if (index >= nodelist.length)
|
||||
throw Components.results.NS_ERROR_FAILURE;
|
||||
if (domselection)
|
||||
{
|
||||
domselection.collapse(parent,index);
|
||||
domselection.extend(parent,index+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
throw Components.results.NS_ERROR_FAILURE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var flavourList = { };
|
||||
flavourList["text/html"] = { width: 2, data: htmlstring };
|
||||
if (isLink)
|
||||
flavourList["text/x-moz-url"] = { width: 2, data: textstring + " " + "( TEMP TITLE )" };
|
||||
flavourList["text/unicode"] = { width: 2, data: textstring };
|
||||
return flavourList;
|
||||
},
|
||||
|
||||
onDragOver: function (aEvent, aFlavour, aDragSession)
|
||||
{
|
||||
// if the drag originated w/in this content area, bail early. This avoids loading
|
||||
// a URL dragged from the content area into the very same content area (which is
|
||||
// almost never the desired action). This code is a bit too simplistic and may
|
||||
// have problems with nested frames, but that's not my problem ;)
|
||||
if ( aDragSession.sourceDocument == window._content.document )
|
||||
aDragSession.canDrop = false;
|
||||
},
|
||||
|
||||
onDrop: function (aEvent, aData, aDragSession)
|
||||
{
|
||||
var data = aData.length ? aData[0] : aData;
|
||||
var url = retrieveURLFromData(data);
|
||||
if (url.length == 0)
|
||||
return;
|
||||
// valid urls don't contain spaces ' '; if we have a space it isn't a valid url so bail out
|
||||
var urlstr = url.toString();
|
||||
if ( urlstr.indexOf(" ", 0) != -1 )
|
||||
return;
|
||||
|
||||
var urlBar = document.getElementById("urlbar");
|
||||
urlBar.value = url;
|
||||
BrowserLoadURL();
|
||||
},
|
||||
|
||||
getSupportedFlavours: function ()
|
||||
{
|
||||
var flavourList = { };
|
||||
//flavourList["moz/toolbaritem"] = { width: 2 };
|
||||
flavourList["text/x-moz-url"] = { width: 2, iid: "nsISupportsWString" };
|
||||
flavourList["text/unicode"] = { width: 2, iid: "nsISupportsWString" };
|
||||
flavourList["application/x-moz-file"] = { width: 2, iid: "nsIFile" };
|
||||
return flavourList;
|
||||
},
|
||||
|
||||
findEnclosingLink: function (aNode)
|
||||
{
|
||||
while (aNode) {
|
||||
var nodeName = aNode.localName;
|
||||
if (!nodeName) return null;
|
||||
nodeName = nodeName.toLowerCase();
|
||||
if (!nodeName || nodeName == "body" ||
|
||||
nodeName == "html" || nodeName == "#document")
|
||||
return null;
|
||||
if (nodeName == "a" && aNode.href)
|
||||
return aNode;
|
||||
aNode = aNode.parentNode;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// DragProxyIcon
|
||||
//
|
||||
|
@ -494,24 +343,3 @@ var homeButtonObserver = {
|
|||
return flavourList;
|
||||
}
|
||||
};
|
||||
|
||||
function retrieveURLFromData (aData)
|
||||
{
|
||||
switch (aData.flavour)
|
||||
{
|
||||
case "text/unicode":
|
||||
case "text/x-moz-url":
|
||||
return aData.data.data; // XXX this is busted.
|
||||
break;
|
||||
case "application/x-moz-file":
|
||||
var dataObj = aData.data.data.QueryInterface(Components.interfaces.nsIFile);
|
||||
if (dataObj)
|
||||
{
|
||||
var fileURL = nsJSComponentManager.createInstance("@mozilla.org/network/standard-url;1",
|
||||
"nsIFileURL");
|
||||
fileURL.file = dataObj;
|
||||
return fileURL.spec;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -7,44 +7,44 @@
|
|||
<!DOCTYPE window SYSTEM "chrome://navigator/locale/viewSource.dtd" >
|
||||
<window id="main-window" xmlns:html="http://www.w3.org/1999/xhtml"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
onload="onLoadViewSource()"
|
||||
onload="onLoadViewSource();"
|
||||
title="&mainWindow.title;"
|
||||
titlemodifier="&mainWindow.titlemodifier;"
|
||||
titlepreface="&mainWindow.preface;"
|
||||
titlemenuseparator ="&mainWindow.titlemodifierseperator;"
|
||||
windowtype="Browser:view-source"
|
||||
windowtype="navigator:view-source"
|
||||
align="vertical" width="640" height="480"
|
||||
screenX="10" screenY="10"
|
||||
persist="screenX screenY width height sizemode">
|
||||
|
||||
|
||||
<script language="javascript" src="chrome://global/content/nsJSSupportsUtils.js"></script>
|
||||
<script language="javascript" src="chrome://global/content/nsJSComponentManager.js"></script>
|
||||
<script language="javascript" src="chrome://global/content/nsTransferable.js"></script>
|
||||
<script language="javascript" src="chrome://global/content/nsDragAndDrop.js"></script>
|
||||
|
||||
<script language="javascript" src="chrome://navigator/content/viewSourceDD.js"></script>
|
||||
<script language="javascript" src="chrome://navigator/content/viewsource.js"></script>
|
||||
<script type="text/javascript" src="chrome://global/content/nsJSSupportsUtils.js"/>
|
||||
<script type="text/javascript" src="chrome://global/content/nsJSComponentManager.js"/>
|
||||
<script type="text/javascript" src="chrome://global/content/nsTransferable.js"/>
|
||||
<script type="text/javascript" src="chrome://global/content/nsDragAndDrop.js"/>
|
||||
<script type="text/javascript" src="chrome://communicator/content/contentAreaDD.js"/>
|
||||
<script type="text/javascript" src="chrome://navigator/content/viewsource.js"/>
|
||||
|
||||
<broadcasterset id="broadcasterset"/>
|
||||
|
||||
<commands id="commands">
|
||||
<commandset id="globalEditMenuItems"/>
|
||||
<commandset id="selectEditMenuItems"/>
|
||||
<commandset id="undoEditMenuItems"/>
|
||||
<commandset id="clipboardEditMenuItems"/>
|
||||
</commands>
|
||||
<commands id="commands">
|
||||
<commandset id="globalEditMenuItems"/>
|
||||
<commandset id="selectEditMenuItems"/>
|
||||
<commandset id="undoEditMenuItems"/>
|
||||
<commandset id="clipboardEditMenuItems"/>
|
||||
</commands>
|
||||
|
||||
<!-- keys are appended from the overlay -->
|
||||
<keyset id="keyset"/>
|
||||
|
||||
<!-- Menu -->
|
||||
|
||||
<box id="appcontent" align="vertical" flex="1"
|
||||
ondragover="nsDragAndDrop.dragOver(event, contentAreaDNDObserver);"
|
||||
ondraggesture="nsDragAndDrop.startDrag(event, contentAreaDNDObserver);">
|
||||
<box id="appcontent" align="vertical" flex="1"
|
||||
ondragover="nsDragAndDrop.dragOver(event, contentAreaDNDObserver);"
|
||||
ondraggesture="nsDragAndDrop.startDrag(event, contentAreaDNDObserver);"
|
||||
ondragdrop="nsDragAndDrop.drop(event, contentAreaDNDObserver);">
|
||||
|
||||
<iframe id="content-frame" type="content-primary" name="content" src="about:blank" flex="1"/>
|
||||
<iframe id="content-frame" type="content-primary" name="content" src="about:blank" flex="1"/>
|
||||
|
||||
</box>
|
||||
|
||||
|
|
|
@ -4,54 +4,59 @@ var appCore = null;
|
|||
|
||||
function onLoadViewSource()
|
||||
{
|
||||
|
||||
try {
|
||||
createBrowserInstance();
|
||||
if (appCore == null) {
|
||||
// Give up.
|
||||
dump("Giving up...\n");
|
||||
window.close();
|
||||
}
|
||||
|
||||
// Initialize browser instance..
|
||||
appCore.setWebShellWindow(window);
|
||||
if ( window._content ) {
|
||||
dump("Setting content window\n");
|
||||
appCore.setContentWindow( window._content );
|
||||
}
|
||||
}
|
||||
|
||||
catch(ex) {
|
||||
dump("Failed to create and initialiaze the AppCore...\n");
|
||||
}
|
||||
|
||||
var docShellElement = document.getElementById("content-frame");
|
||||
var docShell = docShellElement.docShell;
|
||||
docShell.viewMode = Components.interfaces.nsIDocShell.viewSource;
|
||||
var webNav = docShell.QueryInterface(Components.interfaces.nsIWebNavigation);
|
||||
|
||||
try {
|
||||
if ( window.arguments && window.arguments[1] ) {
|
||||
if (window.arguments[1].indexOf('charset=') != -1) {
|
||||
var arrayArgComponents = window.arguments[1].split('=');
|
||||
if (arrayArgComponents) {
|
||||
if (appCore != null) {
|
||||
dump("*** SetDocumentCharset(" + arrayArgComponents[1] + ")\n");
|
||||
appCore.SetDocumentCharset(arrayArgComponents[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
catch(ex) {
|
||||
dump("*** Failed to SetDocumentCharset...\n");
|
||||
}
|
||||
|
||||
var loadFlags = Components.interfaces.nsIWebNavigation.LOAD_FLAGS_NONE;
|
||||
webNav.loadURI(window.arguments[0], loadFlags);
|
||||
viewSource(window.arguments[0]);
|
||||
}
|
||||
|
||||
function viewSource(url)
|
||||
{
|
||||
if (!url)
|
||||
return; // throw Components.results.NS_ERROR_FAILURE;
|
||||
try {
|
||||
createBrowserInstance();
|
||||
if (appCore == null) {
|
||||
// Give up.
|
||||
dump("Giving up...\n");
|
||||
window.close();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Initialize browser instance..
|
||||
appCore.setWebShellWindow(window);
|
||||
if ( window._content ) {
|
||||
dump("Setting content window\n");
|
||||
appCore.setContentWindow( window._content );
|
||||
}
|
||||
}
|
||||
|
||||
catch(ex) {
|
||||
dump("Failed to create and initialiaze the AppCore...\n");
|
||||
}
|
||||
|
||||
var docShellElement = document.getElementById("content-frame");
|
||||
var docShell = docShellElement.docShell;
|
||||
docShell.viewMode = Components.interfaces.nsIDocShell.viewSource;
|
||||
var webNav = docShell.QueryInterface(Components.interfaces.nsIWebNavigation);
|
||||
|
||||
try {
|
||||
if (window.arguments && window.arguments[1]) {
|
||||
if (window.arguments[1].indexOf('charset=') != -1) {
|
||||
var arrayArgComponents = window.arguments[1].split('=');
|
||||
if (arrayArgComponents) {
|
||||
dump("*** SetDocumentCharset(" + arrayArgComponents[1] + ")\n");
|
||||
appCore.SetDocumentCharset(arrayArgComponents[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
catch(ex) {
|
||||
dump("*** Failed to SetDocumentCharset...\n");
|
||||
}
|
||||
|
||||
var loadFlags = Components.interfaces.nsIWebNavigation.LOAD_FLAGS_NONE;
|
||||
webNav.loadURI(url, loadFlags);
|
||||
return true;
|
||||
}
|
||||
|
||||
function createBrowserInstance()
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче