Browse Source

history: update git copy with KM76RC2

master
roytam1 5 years ago
parent
commit
de513dfeb2
  1. 10
      k-meleon/components/history/controller.js
  2. 5
      k-meleon/components/history/history.xul
  3. 154
      k-meleon/components/history/history2.xul
  4. 36
      k-meleon/components/history/tree.xml
  5. 3389
      k-meleon/components/history/treeView.js
  6. 152
      k-meleon/components/history/utilityOverlay.js

10
k-meleon/components/history/controller.js

@ -51,16 +51,16 @@ HistoryController.prototype = {
doCommand : function PC_doCommand(aCommand) {
switch (aCommand) {
case "historyCmd_open":
PlacesUIUtils.openNodeIn(this._view.selectedNode, "current", this._view);
KMeleon.Open(this._view.selectedNode.uri, KMeleon.OPEN_NORMAL);
break;
case "historyCmd_opentab":
PlacesUIUtils.openNodeIn(this._view.selectedNode, "tab", this._view);
KMeleon.Open(this._view.selectedNode.uri, KMeleon.OPEN_NEWTAB);
break;
case "historyCmd_opentabback":
KMeleon.Open(this._view.selectedNode.uri, KMeleon.OPEN_BACKGROUNDTAB);
break;
case "historyCmd_openwindow":
PlacesUIUtils.openNodeIn(this._view.selectedNode, "window", this._view);
KMeleon.Open(this._view.selectedNode.uri, KMeleon.OPEN_NEW);
break;
case "historyCmd_openbackwindow":
KMeleon.Open(this._view.selectedNode.uri, KMeleon.OPEN_BACKGROUND);
@ -114,8 +114,8 @@ HistoryController.prototype = {
// to delete a child of a live bookmark folder, since when the folder
// refreshes, the child will return.
var parent = nodes[i].parent || root;
if (PlacesUtils.isReadonlyFolder(parent))
return false;
//if (PlacesUtils.isReadonlyFolder(parent))
// return false;
}
}
return true;

5
k-meleon/components/history/history.xul

@ -9,12 +9,9 @@
%viewSourceDTD;
]>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
orient="vertical"
title="&window.title;"
windowtype="kmeleon:history"
height="550px"
width="440px"
onload="window.sizeToContent();HistorySidebarInit();"
onload="HistorySidebarInit();"
onclose="SidebarUtils.setMouseoverURL('');">
<script type="application/javascript" src="chrome://history/content/sidebarUtils.js"/>
<script type="application/javascript" src="chrome://history/content/history.js"/>

154
k-meleon/components/history/history2.xul

@ -0,0 +1,154 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://history/content/history.css"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://history/skin/history.css"?>
<!DOCTYPE page [
<!ENTITY % historyDTD SYSTEM "chrome://history/locale/history.dtd">
%historyDTD;
<!ENTITY % viewSourceDTD SYSTEM "chrome://global/locale/viewSource.dtd">
%viewSourceDTD;
]>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="&window.title;"
windowtype="kmeleon:history"
onload="HistorySidebarInit();"
onclose="SidebarUtils.setMouseoverURL('');">
<script type="application/javascript" src="chrome://history/content/sidebarUtils.js"/>
<script type="application/javascript" src="chrome://history/content/history.js"/>
<script type="application/javascript" src="chrome://global/content/globalOverlay.js"/>
<script type="application/javascript" src="chrome://history/content/utilityOverlay.js"/>
<script type="application/x-javascript">
<![CDATA[
var Cc = Components.classes;
var Ci = Components.interfaces;
var Cr = Components.results;
Components.utils.import("resource://gre/modules/PlacesUtils.jsm");
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
]]>
</script>
<script type="application/javascript" src="chrome://history/content/controller.js"/>
<script type="application/javascript" src="chrome://history/content/treeView.js"/>
<commandset id="historyCommands" commandupdater="true" events="focus,sort,places" oncommandupdate="goUpdateHistoryCommands();">
<command id="historyCmd_open" oncommand="goDoHistoryCommand('historyCmd_open');"/>
<command id="historyCmd_opentab" oncommand="goDoHistoryCommand('historyCmd_opentab');"/>
<command id="historyCmd_opentabback" oncommand="goDoHistoryCommand('historyCmd_opentabback');"/>
<command id="historyCmd_delete" oncommand="goDoHistoryCommand('historyCmd_delete');"/>
<command id="historyCmd_deleteall" oncommand="goDoHistoryCommand('historyCmd_deleteall');"/>
<command id="historyCmd_copylink" oncommand="goDoHistoryCommand('historyCmd_copylink');"/>
<command id="historyCmd_opennewwindow" oncommand="goDoHistoryCommand('historyCmd_openwindow');"/>
<command id="historyCmd_openbackwindow" oncommand="goDoHistoryCommand('historyCmd_openbackwindow');"/> <!-- My new code ends here JohnHell -->
</commandset>
<keyset>
<key id="close-key" keycode="VK_ESCAPE"
oncommand="window.close();"/>
</keyset>
<menupopup id="historyContext">
<menuitem id="historyContext_open"
command="historyCmd_open"
label="&cmd.open.label;"
accesskey="&cmd.open.accesskey;"
selectiontype="single"
selection="link"/>
<menuitem id="historyContext_opentab"
command="historyCmd_opentab"
label="&cmd.opentab.label;"
accesskey="&cmd.opentab.accesskey;"
selectiontype="single"
selection="link"/>
<menuitem id="historyContext_opentabback"
command="historyCmd_opentabback"
label="&cmd.opentabback.label;"
accesskey="&cmd.opentabback.accesskey;"
selectiontype="single"
selection="link"/>
<menuitem id="historyContext_opennewwindow"
command="historyCmd_opennewwindow"
label="&cmd.opennewwindow.label;"
accesskey="&cmd.opennewwindow.accesskey;"
selectiontype="single"
selection="link"/>
<!-- <menuitem id="historyContext_opennewbackwindow"
command="historyCmd_openbackwindow"
label="&cmd.opennewbackwindow.label;"
accesskey="&cmd.opennewbackwindow.accesskey;"
selectiontype="single"
selection="link"/>-->
<menuitem id="historyContext_copylink"
command="historyCmd_copylink"
label="&copyLinkCmd.label;"
accesskey="&copyLinkCmd.accesskey;"
selectiontype="single"
selection="link"/>
<menuitem id="historyContext_delete_history"
command="historyCmd_delete"
label="&cmd.delete.label;"
accesskey="&cmd.delete.accesskey;"
closemenu="single"
selection="link"/>
<menuitem id="historyContext_deleteall_history"
command="historyCmd_deleteall"
label="&cmd.deleteall.label;"
accesskey="&cmd.deleteall.accesskey;"
closemenu="single"
selection="link"/>
</menupopup>
<tooltip id="bhTooltip" noautohide="true"
onpopupshowing="fillInBHTooltip(document, event)">
<vbox id="bhTooltipTextBox" flex="1">
<label id="bhtTitleText" class="tooltip-label" />
<label id="bhtUrlText" crop="center" class="tooltip-label" />
</vbox>
</tooltip>
<hbox id="sidebar-search-container" align="center">
<label id="sidebar-search-label"
value="&find.label;" accesskey="&find.accesskey;"
control="search-box"/>
<textbox id="search-box" flex="1" type="search" class="compact"
aria-controls="historyTree"
oncommand="searchHistory(this.value);"/>
<button id="viewButton" style="min-width:0px !important;" type="menu"
label="&view.label;" accesskey="&view.accesskey;" selectedsort="day"
persist="selectedsort">
<menupopup>
<menuitem id="bydayandsite" label="&byDayAndSite.label;"
accesskey="&byDayAndSite.accesskey;" type="radio"
oncommand="this.parentNode.parentNode.setAttribute('selectedsort', 'dayandsite'); GroupBy('dayandsite');"/>
<menuitem id="bysite" label="&bySite.label;"
accesskey="&bySite.accesskey;" type="radio"
oncommand="this.parentNode.parentNode.setAttribute('selectedsort', 'site'); GroupBy('site');"/>
<menuitem id="byday" label="&byDate.label;"
accesskey="&byDate.accesskey;"
type="radio"
oncommand="this.parentNode.parentNode.setAttribute('selectedsort', 'day'); GroupBy('day');"/>
<menuitem id="byvisited" label="&byMostVisited.label;"
accesskey="&byMostVisited.accesskey;"
type="radio"
oncommand="this.parentNode.parentNode.setAttribute('selectedsort', 'visited'); GroupBy('visited');"/>
<menuitem id="bylastvisited" label="&byLastVisited.label;"
accesskey="&byLastVisited.accesskey;"
type="radio"
oncommand="this.parentNode.parentNode.setAttribute('selectedsort', 'lastvisited'); GroupBy('lastvisited');"/>
</menupopup>
</button>
</hbox>
<tree id="historyTree"
class="sidebar-placesTree"
flex="1"
type="places"
context="historyContext"
hidecolumnpicker="true"
onkeypress="SidebarUtils.handleTreeKeyPress(event);"
onclick="SidebarUtils.handleTreeClick(this, event, true);"
onmousemove="SidebarUtils.handleTreeMouseMove(event);"
onmouseout="SidebarUtils.setMouseoverURL('');">
<treecols>
<treecol id="title" flex="1" primary="true" hideheader="true"/>
</treecols>
<treechildren class="sidebar-placesTreechildren" flex="1" tooltip="bhTooltip"/>
</tree>
</window>

36
k-meleon/components/history/tree.xml

@ -45,7 +45,7 @@
<property name="view">
<getter><![CDATA[
try {
return this.treeBoxObject.view.wrappedJSObject;
return this.treeBoxObject.view.wrappedJSObject || null;
}
catch(e) {
return null;
@ -312,9 +312,9 @@
for (let i = 0; i < rc; ++i) {
let min = { }, max = { };
selection.getRangeAt(i, min, max);
for (let j = min.value; j <= max.value; ++j)
for (let j = min.value; j <= max.value; ++j) {
nodes.push(resultview.nodeForTreeIndex(j));
}
}
return nodes;
]]></getter>
@ -453,8 +453,6 @@
//
// If the sole selection is the bookmarks toolbar folder, we insert
// into it even if it is not opened
var itemId =
PlacesUtils.getConcreteItemId(resultView.nodeForTreeIndex(max.value));
if (selection.count == 1 && resultView.isContainer(max.value) &&
!this.flatList)
orientation = Ci.nsITreeView.DROP_ON;
@ -531,9 +529,11 @@
if (PlacesControllerDragHelper.disallowInsertion(container))
return null;
let tagName = PlacesUtils.nodeIsTagQuery(container) ?
container.title : null;
return new InsertionPoint(PlacesUtils.getConcreteItemId(container),
index, orientation,
PlacesUtils.nodeIsTagQuery(container),
tagName,
dropNearItemId);
]]></body>
</method>
@ -553,6 +553,9 @@
<parameter name="aIDs"/>
<parameter name="aOpenContainers"/>
<body><![CDATA[
// Never open containers in flat lists.
if (this.flatList)
aOpenContainers = false;
// By default, we do search and select within containers which were
// closed (note that containers in which nodes were not found are
// closed).
@ -601,8 +604,13 @@
nodesURIChecked.indexOf(node.uri) != -1)
return foundOne;
// Don't try to open a query or a shurtcut, since it may return
// any duplicate data and be infinitely nested. Though, if it has
// been explicitly opened by the caller, search into it.
let shouldOpen = aOpenContainers &&
node.type == Ci.nsINavHistoryResultNode.RESULT_TYPE_FOLDER;
PlacesUtils.asContainer(node);
if (!aOpenContainers && !node.containerOpen)
if (!node.containerOpen && !shouldOpen)
return foundOne;
nodesURIChecked.push(node.uri);
@ -739,11 +747,9 @@
if (event.target.localName != "treechildren")
return;
let row = { }, col = { }, child = { };
this.treeBoxObject.getCellAt(event.clientX, event.clientY,
row, col, child);
let node = row.value != -1 ?
this.view.nodeForTreeIndex(row.value) :
let cell = this.treeBoxObject.getCellAt(event.clientX, event.clientY);
let node = cell.row != -1 ?
this.view.nodeForTreeIndex(cell.row) :
this.result.root;
// cache the dropTarget for the view
PlacesControllerDragHelper.currentDropTarget = node;
@ -753,11 +759,11 @@
let tbo = this.treeBoxObject;
let rowHeight = tbo.rowHeight;
let eventY = event.clientY - tbo.treeBody.boxObject.y -
rowHeight * (row.value - tbo.getFirstVisibleRow());
rowHeight * (cell.row - tbo.getFirstVisibleRow());
let orientation = Ci.nsITreeView.DROP_BEFORE;
if (row.value == -1) {
if (cell.row == -1) {
// If the row is not valid we try to insert inside the resultNode.
orientation = Ci.nsITreeView.DROP_ON;
}
@ -774,7 +780,7 @@
orientation = Ci.nsITreeView.DROP_ON;
}
if (!this.view.canDrop(row.value, orientation, event.dataTransfer))
if (!this.view.canDrop(cell.row, orientation, event.dataTransfer))
return;
event.preventDefault();

3389
k-meleon/components/history/treeView.js

File diff suppressed because it is too large Load Diff

152
k-meleon/components/history/utilityOverlay.js

@ -100,7 +100,8 @@ function openUILink(url, event, aIgnoreButton, aIgnoreAlt, aAllowThirdPartyFixup
allowThirdPartyFixup: aAllowThirdPartyFixup,
postData: aPostData,
referrerURI: aReferrerURI,
initiatingDoc: event ? event.target.ownerDocument : null
referrerPolicy: Components.interfaces.nsIHttpChannel.REFERRER_POLICY_DEFAULT,
initiatingDoc: event ? event.target.ownerDocument : null,
};
}
@ -229,6 +230,7 @@ function openLinkIn(url, where, params) {
const Ci = Components.interfaces;
/** K-Meleon **********************/
var w;
if (where == "tab")
w = KMeleon.Open(url, aInBackground ? KMeleon.OPEN_BACKGROUNDTAB : KMeleon.OPEN_NEWTAB);
else if (where == "window")
@ -240,103 +242,8 @@ function openLinkIn(url, where, params) {
return;
/*************************************/
var w = getTopWin();
if ((where == "tab" || where == "tabshifted") &&
w && !w.toolbar.visible) {
w = getTopWin(true);
aRelatedToCurrent = false;
}
if (!w || where == "window") {
var sa = Cc["@mozilla.org/supports-array;1"].
createInstance(Ci.nsISupportsArray);
var wuri = Cc["@mozilla.org/supports-string;1"].
createInstance(Ci.nsISupportsString);
wuri.data = url;
let charset = null;
if (aCharset) {
charset = Cc["@mozilla.org/supports-string;1"]
.createInstance(Ci.nsISupportsString);
charset.data = "charset=" + aCharset;
}
var allowThirdPartyFixupSupports = Cc["@mozilla.org/supports-PRBool;1"].
createInstance(Ci.nsISupportsPRBool);
allowThirdPartyFixupSupports.data = aAllowThirdPartyFixup;
sa.AppendElement(wuri);
sa.AppendElement(charset);
sa.AppendElement(aReferrerURI);
sa.AppendElement(aPostData);
sa.AppendElement(allowThirdPartyFixupSupports);
let features = "chrome,dialog=no,all";
if (aIsPrivate) {
features += ",private";
}
Services.ww.openWindow(w || window, getBrowserURL(), null, features, sa);
return;
}
let loadInBackground = where == "current" ? false : aInBackground;
if (loadInBackground == null) {
loadInBackground = aFromChrome ?
false :
getBoolPref("browser.tabs.loadInBackground");
}
if (where == "current" && w.gBrowser.selectedTab.pinned) {
try {
let uriObj = Services.io.newURI(url, null, null);
if (!uriObj.schemeIs("javascript") &&
w.gBrowser.currentURI.host != uriObj.host) {
where = "tab";
loadInBackground = false;
}
} catch (err) {
where = "tab";
loadInBackground = false;
}
}
// Raise the target window before loading the URI, since loading it may
// result in a new frontmost window (e.g. "javascript:window.open('');").
w.focus();
switch (where) {
case "current":
let flags = Ci.nsIWebNavigation.LOAD_FLAGS_NONE;
if (aAllowThirdPartyFixup)
flags |= Ci.nsIWebNavigation.LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP;
if (aDisallowInheritPrincipal)
flags |= Ci.nsIWebNavigation.LOAD_FLAGS_DISALLOW_INHERIT_OWNER;
if (aIsUTF8)
flags |= Ci.nsIWebNavigation.LOAD_FLAGS_URI_IS_UTF8;
w.gBrowser.loadURIWithFlags(url, flags, aReferrerURI, null, aPostData);
break;
case "tabshifted":
loadInBackground = !loadInBackground;
// fall through
case "tab":
let browser = w.gBrowser;
browser.loadOneTab(url, {
referrerURI: aReferrerURI,
charset: aCharset,
postData: aPostData,
inBackground: loadInBackground,
allowThirdPartyFixup: aAllowThirdPartyFixup,
relatedToCurrent: aRelatedToCurrent,
isUTF8: aIsUTF8});
break;
}
w.gBrowser.selectedBrowser.focus();
if (!loadInBackground && w.isBlankPageURL(url))
w.focusAndSelectUrlBar();
}
// Used as an onclick handler for UI elements with link-like behavior.
@ -388,11 +295,10 @@ function gatherTextUnder ( root )
// Add this text to our collection.
text += " " + node.data;
} else if ( node instanceof HTMLImageElement) {
// If it has an alt= attribute, use that.
// If it has an "alt" attribute, add that.
var altText = node.getAttribute( "alt" );
if ( altText && altText != "" ) {
text = altText;
break;
text += " " + altText;
}
}
// Find next node to test.
@ -412,10 +318,8 @@ function gatherTextUnder ( root )
}
}
}
// Strip leading whitespace.
text = text.replace( /^\s+/, "" );
// Strip trailing whitespace.
text = text.replace( /\s+$/, "" );
// Strip leading and tailing whitespace.
text = text.trim();
// Compress remaining whitespace.
text = text.replace( /\s+/g, " " );
return text;
@ -437,8 +341,13 @@ function isBidiEnabled() {
if (getBoolPref("bidi.browser.ui", false))
return true;
// if the pref isn't set, check for an RTL locale and force the pref to true
// if we find one.
// then check intl.uidirection.<locale>
var chromeReg = Components.classes["@mozilla.org/chrome/chrome-registry;1"].
getService(Components.interfaces.nsIXULChromeRegistry);
if (chromeReg.isLocaleRTL("global"))
return true;
// now see if the system locale is an RTL one.
var rv = false;
try {
@ -450,6 +359,7 @@ function isBidiEnabled() {
case "ar-":
case "he-":
case "fa-":
case "ug-":
case "ur-":
case "syr":
rv = true;
@ -465,6 +375,9 @@ function openAboutDialog() {
while (enumerator.hasMoreElements()) {
// Only open one about window (Bug 599573)
let win = enumerator.getNext();
if (win.closed) {
continue;
}
win.focus();
return;
}
@ -682,10 +595,29 @@ function openPrefsHelp() {
function trimURL(aURL) {
// This function must not modify the given URL such that calling
// nsIURIFixup::createFixupURI with the result will produce a different URI.
return aURL /* remove single trailing slash for http/https/ftp URLs */
.replace(/^((?:http|https|ftp):\/\/[^/]+)\/$/, "$1")
/* remove http:// unless the host starts with "ftp\d*\." or contains "@" */
.replace(/^http:\/\/((?!ftp\d*\.)[^\/@]+(?:\/|$))/, "$1");
// remove single trailing slash for http/https/ftp URLs
let url = aURL.replace(/^((?:http|https|ftp):\/\/[^/]+)\/$/, "$1");
// remove http://
if (!url.startsWith("http://")) {
return url;
}
let urlWithoutProtocol = url.substring(7);
let flags = Services.uriFixup.FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP |
Services.uriFixup.FIXUP_FLAG_FIX_SCHEME_TYPOS;
let fixedUpURL = Services.uriFixup.createFixupURI(urlWithoutProtocol, flags);
let expectedURLSpec;
try {
expectedURLSpec = makeURI(aURL).spec;
} catch (ex) {
return url;
}
if (fixedUpURL.spec == expectedURLSpec) {
return urlWithoutProtocol;
}
return url;
}
function getShellService()

Loading…
Cancel
Save