зеркало из https://github.com/mozilla/gecko-dev.git
Fix 233473: History doesn't sort properly.
This commit is contained in:
Родитель
b5015a424d
Коммит
0061b8bf8d
|
@ -27,7 +27,6 @@
|
||||||
<page id="history-panel" orient="vertical"
|
<page id="history-panel" orient="vertical"
|
||||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||||
onload="HistoryCommonInit();"
|
onload="HistoryCommonInit();"
|
||||||
onunload="onUnload();"
|
|
||||||
elementtofocus="historyTree">
|
elementtofocus="historyTree">
|
||||||
|
|
||||||
<script type="application/x-javascript" src="chrome://global/content/nsDragAndDrop.js"/>
|
<script type="application/x-javascript" src="chrome://global/content/nsDragAndDrop.js"/>
|
||||||
|
@ -91,7 +90,7 @@
|
||||||
</toolbarbutton>
|
</toolbarbutton>
|
||||||
</hbox>
|
</hbox>
|
||||||
<tree id="historyTree" flex="1" class="plain"
|
<tree id="historyTree" flex="1" class="plain"
|
||||||
context="historyContextMenu" persist="ref"
|
context="historyContextMenu"
|
||||||
datasources="rdf:history" ref="NC:HistoryByDate" flags="dont-build-content"
|
datasources="rdf:history" ref="NC:HistoryByDate" flags="dont-build-content"
|
||||||
onkeypress="if (event.keyCode == 13) OpenURL(event.shiftKey || event.metaKey);"
|
onkeypress="if (event.keyCode == 13) OpenURL(event.shiftKey || event.metaKey);"
|
||||||
onselect="this.treeBoxObject.view.selectionChanged();
|
onselect="this.treeBoxObject.view.selectionChanged();
|
||||||
|
@ -106,7 +105,7 @@
|
||||||
<treeitem uri="rdf:*" rdf:type="rdf:http://www.w3.org/1999/02/22-rdf-syntax-ns#type">
|
<treeitem uri="rdf:*" rdf:type="rdf:http://www.w3.org/1999/02/22-rdf-syntax-ns#type">
|
||||||
<treerow>
|
<treerow>
|
||||||
<treecell label="rdf:http://home.netscape.com/NC-rdf#Name"
|
<treecell label="rdf:http://home.netscape.com/NC-rdf#Name"
|
||||||
dayindex="rdf:http://home.netscape.com/NC-rdf#DayFolderIndex"
|
sortName="rdf:http://home.netscape.com/NC-rdf#Name?sort=true"
|
||||||
visitcount="rdf:http://home.netscape.com/NC-rdf#VisitCount"
|
visitcount="rdf:http://home.netscape.com/NC-rdf#VisitCount"
|
||||||
date="rdf:http://home.netscape.com/NC-rdf#Date"/>
|
date="rdf:http://home.netscape.com/NC-rdf#Date"/>
|
||||||
</treerow>
|
</treerow>
|
||||||
|
@ -117,7 +116,7 @@
|
||||||
<treecols id="historyTreeCols">
|
<treecols id="historyTreeCols">
|
||||||
<treecol flex="1" id="Name" persist="sortActive sortDirection"
|
<treecol flex="1" id="Name" persist="sortActive sortDirection"
|
||||||
hideheader="true" primary="true"
|
hideheader="true" primary="true"
|
||||||
sort="rdf:http://home.netscape.com/NC-rdf#DayFolderIndex"
|
sort="rdf:http://home.netscape.com/NC-rdf#Name?sort=true"
|
||||||
sortActive="true"/>
|
sortActive="true"/>
|
||||||
</treecols>
|
</treecols>
|
||||||
</tree>
|
</tree>
|
||||||
|
|
|
@ -59,8 +59,12 @@ function HistoryCommonInit()
|
||||||
document.getElementById("bydayandsite").setAttribute("checked", "true");
|
document.getElementById("bydayandsite").setAttribute("checked", "true");
|
||||||
else
|
else
|
||||||
document.getElementById("byday").setAttribute("checked", "true");
|
document.getElementById("byday").setAttribute("checked", "true");
|
||||||
|
|
||||||
|
// XXXBlake we should persist the last search value
|
||||||
|
// If it's empty, this will do the right thing and just group by the old grouping.
|
||||||
|
searchHistory(gSearchBox.value);
|
||||||
|
|
||||||
gHistoryTree.focus();
|
gHistoryTree.focus();
|
||||||
SortInNewDirection(find_sort_direction(find_sort_column()));
|
|
||||||
gHistoryTree.treeBoxObject.view.selection.select(0);
|
gHistoryTree.treeBoxObject.view.selection.select(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,10 +154,8 @@ function OpenURL(aWhere, event)
|
||||||
|
|
||||||
function SortBy(sortKey)
|
function SortBy(sortKey)
|
||||||
{
|
{
|
||||||
// XXXBlake Welcome to the end of the world of Lame.
|
// We set the sortDirection to the one before we actually want it to be in the
|
||||||
// You can go no further. You are standing on the edge -- teetering, even.
|
// cycle list, since cycleHeader cycles it forward before doing the sort.
|
||||||
// Look on the bright side: you can rest assured that no code you see in the future
|
|
||||||
// will even come close to the lameness of the code below.
|
|
||||||
|
|
||||||
var sortDirection;
|
var sortDirection;
|
||||||
switch(sortKey) {
|
switch(sortKey) {
|
||||||
|
@ -162,17 +164,13 @@ function SortBy(sortKey)
|
||||||
sortDirection = "ascending";
|
sortDirection = "ascending";
|
||||||
break;
|
break;
|
||||||
case "name":
|
case "name":
|
||||||
sortKey = "rdf:http://home.netscape.com/NC-rdf#Name";
|
sortKey = "rdf:http://home.netscape.com/NC-rdf#Name?sort=true";
|
||||||
sortDirection = "natural";
|
sortDirection = "natural";
|
||||||
break;
|
break;
|
||||||
case "lastvisited":
|
case "lastvisited":
|
||||||
sortKey = "rdf:http://home.netscape.com/NC-rdf#Date";
|
sortKey = "rdf:http://home.netscape.com/NC-rdf#Date";
|
||||||
sortDirection = "ascending";
|
sortDirection = "ascending";
|
||||||
break;
|
break;
|
||||||
case "day":
|
|
||||||
sortKey = "rdf:http://home.netscape.com/NC-rdf#DayFolderIndex";
|
|
||||||
sortDirection = "natural";
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -182,37 +180,55 @@ function SortBy(sortKey)
|
||||||
gHistoryTree.treeBoxObject.view.cycleHeader(sortKey, col);
|
gHistoryTree.treeBoxObject.view.cycleHeader(sortKey, col);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function IsFindResource(uri)
|
||||||
|
{
|
||||||
|
return (uri.substr(0, 5) == "find:");
|
||||||
|
}
|
||||||
|
|
||||||
function GroupBy(groupingType)
|
function GroupBy(groupingType)
|
||||||
{
|
{
|
||||||
|
var isFind = IsFindResource(groupingType);
|
||||||
|
if (!isFind) {
|
||||||
gHistoryGrouping = groupingType;
|
gHistoryGrouping = groupingType;
|
||||||
switch(groupingType) {
|
|
||||||
case "none":
|
|
||||||
gHistoryTree.setAttribute("ref", "NC:HistoryRoot");
|
|
||||||
break;
|
|
||||||
case "site":
|
|
||||||
// xxx for now
|
|
||||||
gHistoryTree.setAttribute("ref", "NC:HistoryRoot");
|
|
||||||
SortBy("name");
|
|
||||||
break;
|
|
||||||
case "dayandsite":
|
|
||||||
gHistoryTree.setAttribute("ref", "NC:HistoryByDateAndSite");
|
|
||||||
SortBy("dayandsite");
|
|
||||||
break;
|
|
||||||
case "visited":
|
|
||||||
gHistoryTree.setAttribute("ref", "NC:HistoryRoot");
|
|
||||||
SortBy("visited");
|
|
||||||
break;
|
|
||||||
case "lastvisited":
|
|
||||||
gHistoryTree.setAttribute("ref", "NC:HistoryRoot");
|
|
||||||
SortBy("lastvisited");
|
|
||||||
break;
|
|
||||||
case "day":
|
|
||||||
default:
|
|
||||||
gHistoryTree.setAttribute("ref", "NC:HistoryByDate");
|
|
||||||
SortBy("day");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
gSearchBox.value = "";
|
gSearchBox.value = "";
|
||||||
|
}
|
||||||
|
switch(groupingType) {
|
||||||
|
case "site":
|
||||||
|
gHistoryTree.setAttribute("ref", "NC:HistoryRoot");
|
||||||
|
break;
|
||||||
|
case "dayandsite":
|
||||||
|
gHistoryTree.setAttribute("ref", "NC:HistoryByDateAndSite");
|
||||||
|
break;
|
||||||
|
case "visited":
|
||||||
|
gHistoryTree.setAttribute("ref", "NC:HistoryRoot");
|
||||||
|
break;
|
||||||
|
case "lastvisited":
|
||||||
|
gHistoryTree.setAttribute("ref", "NC:HistoryRoot");
|
||||||
|
break;
|
||||||
|
case "day":
|
||||||
|
gHistoryTree.setAttribute("ref", "NC:HistoryByDate");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
gHistoryTree.setAttribute("ref", groupingType);
|
||||||
|
}
|
||||||
|
Sort(isFind? gHistoryGrouping : groupingType);
|
||||||
|
}
|
||||||
|
|
||||||
|
function Sort(groupingType)
|
||||||
|
{
|
||||||
|
switch(groupingType) {
|
||||||
|
case "site":
|
||||||
|
case "dayandsite":
|
||||||
|
case "day":
|
||||||
|
SortBy("name");
|
||||||
|
break;
|
||||||
|
case "lastvisited":
|
||||||
|
SortBy("lastvisited");
|
||||||
|
break;
|
||||||
|
case "visited":
|
||||||
|
SortBy("visited");
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function historyAddBookmarks()
|
function historyAddBookmarks()
|
||||||
|
@ -293,14 +309,11 @@ function buildContextMenu()
|
||||||
|
|
||||||
function searchHistory(aInput)
|
function searchHistory(aInput)
|
||||||
{
|
{
|
||||||
if (!aInput)
|
if (aInput == "") {
|
||||||
GroupBy(gHistoryGrouping);
|
GroupBy(gHistoryGrouping);
|
||||||
else
|
return;
|
||||||
gHistoryTree.setAttribute("ref",
|
}
|
||||||
"find:datasource=history&match=Name&method=contains&text=" + encodeURIComponent(aInput));
|
|
||||||
|
GroupBy("find:datasource=history&match=Name&method=contains&text=" + encodeURIComponent(aInput));
|
||||||
}
|
}
|
||||||
|
|
||||||
function onUnload()
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1555,51 +1555,39 @@ nsGlobalHistory::GetTarget(nsIRDFResource* aSource,
|
||||||
|
|
||||||
// find URIs are special
|
// find URIs are special
|
||||||
if (IsFindResource(aSource)) {
|
if (IsFindResource(aSource)) {
|
||||||
if (aProperty == kNC_Name || aProperty == kNC_NameSort) {
|
if (aProperty == kNC_Name)
|
||||||
|
return GetFindUriName(uri, aTarget);
|
||||||
// for sorting, we sort by uri, so just return the URI as a literal
|
|
||||||
if (aProperty == kNC_NameSort) {
|
if (aProperty == kNC_NameSort) {
|
||||||
nsCOMPtr<nsIRDFLiteral> uriLiteral;
|
|
||||||
rv = gRDFService->GetLiteral(NS_ConvertUTF8toUCS2(uri).get(),
|
|
||||||
getter_AddRefs(uriLiteral));
|
|
||||||
if (NS_FAILED(rv)) return(rv);
|
|
||||||
|
|
||||||
*aTarget = uriLiteral;
|
|
||||||
NS_ADDREF(*aTarget);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return GetFindUriName(uri, aTarget);
|
|
||||||
} else if (aProperty == kNC_DayFolderIndex) {
|
|
||||||
// parse out the 'text' token
|
// parse out the 'text' token
|
||||||
nsVoidArray tokenList;
|
nsVoidArray tokenList;
|
||||||
FindUrlToTokenList(uri, tokenList);
|
FindUrlToTokenList(uri, tokenList);
|
||||||
|
|
||||||
nsCOMPtr<nsIRDFInt> intLiteral;
|
nsCOMPtr<nsIRDFLiteral> literal;
|
||||||
|
|
||||||
for (PRInt32 i = 0; i < tokenList.Count(); ++i) {
|
for (PRInt32 i = 0; i < tokenList.Count(); ++i) {
|
||||||
tokenPair* token = NS_STATIC_CAST(tokenPair*, tokenList[i]);
|
tokenPair* token = NS_STATIC_CAST(tokenPair*, tokenList[i]);
|
||||||
if (!strcmp(token->tokenName, "text")) {
|
|
||||||
rv = gRDFService->GetIntLiteral(atoi(token->tokenValue),
|
if (!strncmp(token->tokenName, "text", token->tokenNameLength)) {
|
||||||
getter_AddRefs(intLiteral));
|
rv = gRDFService->GetLiteral(NS_ConvertUTF8toUCS2(Substring(token->tokenValue, token->tokenValue + token->tokenValueLength)).get(),
|
||||||
break;
|
getter_AddRefs(literal));
|
||||||
|
// We don't break out of the loop here because there could be other text tokens in the string.
|
||||||
|
// The last one is the most specific so wait and see if we've got one...
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FreeTokenList(tokenList);
|
FreeTokenList(tokenList);
|
||||||
|
|
||||||
if (intLiteral && NS_SUCCEEDED(rv)) {
|
if (literal && NS_SUCCEEDED(rv)) {
|
||||||
*aTarget = intLiteral;
|
*aTarget = literal;
|
||||||
NS_ADDREF(*aTarget);
|
NS_ADDREF(*aTarget);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
} else {
|
|
||||||
*aTarget = nsnull;
|
|
||||||
return rv;
|
|
||||||
}
|
}
|
||||||
|
*aTarget = nsnull;
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
} else if (aProperty == kNC_DayFolderIndex)
|
}
|
||||||
return NS_RDF_NO_VALUE;
|
|
||||||
|
|
||||||
// ok, we got this far, so we have to retrieve something from
|
// ok, we got this far, so we have to retrieve something from
|
||||||
// the row in the database
|
// the row in the database
|
||||||
nsCOMPtr<nsIMdbRow> row;
|
nsCOMPtr<nsIMdbRow> row;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче