зеркало из https://github.com/mozilla/pjs.git
Bug 373838 - Replace nsNavHistoryResultTreeViewer with a JS, browser-specific tree view. r=dietrich.
This commit is contained in:
Родитель
7e1bb51d95
Коммит
9c4d5fb43d
|
@ -54,6 +54,8 @@
|
|||
src="chrome://browser/content/places/utils.js"/>
|
||||
<script type="application/x-javascript"
|
||||
src="chrome://browser/content/places/controller.js"/>
|
||||
<script type="application/x-javascript"
|
||||
src="chrome://browser/content/places/treeView.js"/>
|
||||
<script type="application/x-javascript"
|
||||
src="chrome://browser/content/places/treeHelpers.js"/>
|
||||
<script type="application/x-javascript"
|
||||
|
|
|
@ -132,18 +132,13 @@
|
|||
<parameter name="options"/>
|
||||
<body><![CDATA[
|
||||
var result = PlacesUtils.history.executeQueries(queries, queries.length,
|
||||
options);
|
||||
|
||||
var treeviewer =
|
||||
Cc["@mozilla.org/browser/nav-history/result-tree-viewer;1"].
|
||||
createInstance(Ci.nsINavHistoryResultViewer);
|
||||
result.viewer = treeviewer;
|
||||
|
||||
treeviewer.QueryInterface(Ci.nsITreeView);
|
||||
this.view = treeviewer;
|
||||
options);
|
||||
var treeView = new PlacesTreeView();
|
||||
result.viewer = treeView;
|
||||
this.view = treeView;
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
|
||||
<!--
|
||||
Causes a particular node represented by the specified placeURI to be
|
||||
selected in the tree. All containers above the node in the hierarchy
|
||||
|
@ -288,7 +283,7 @@
|
|||
return this.view.selection.count == 1;
|
||||
]]></getter>
|
||||
</property>
|
||||
|
||||
|
||||
<!-- nsIPlacesView -->
|
||||
<method name="getSelectionNodes">
|
||||
<body><![CDATA[
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -126,6 +126,18 @@ var PlacesUtils = {
|
|||
return this._annotations;
|
||||
},
|
||||
|
||||
/**
|
||||
* The Favicons Service
|
||||
*/
|
||||
_favicons: null,
|
||||
get favicons() {
|
||||
if (!this._favicons) {
|
||||
this._favicons = Cc["@mozilla.org/browser/favicon-service;1"].
|
||||
getService(Ci.nsIFaviconService);
|
||||
}
|
||||
return this._favicons;
|
||||
},
|
||||
|
||||
/**
|
||||
* The Transaction Manager for this window.
|
||||
*/
|
||||
|
@ -221,6 +233,21 @@ var PlacesUtils = {
|
|||
return (aNode.type == Ci.nsINavHistoryResultNode.RESULT_TYPE_SEPARATOR);
|
||||
},
|
||||
|
||||
/**
|
||||
* Determines whether or not a ResultNode is a visit item or not
|
||||
* @param aNode
|
||||
* A NavHistoryResultNode
|
||||
* @returns true if the node is a visit item, false otherwise
|
||||
*/
|
||||
nodeIsVisit: function PU_nodeIsVisit(aNode) {
|
||||
NS_ASSERT(aNode, "null node");
|
||||
|
||||
const NHRN = Ci.nsINavHistoryResultNode;
|
||||
var type = aNode.type;
|
||||
return type == NHRN.RESULT_TYPE_VISIT ||
|
||||
type == NHRN.RESULT_TYPE_FULL_VISIT;
|
||||
},
|
||||
|
||||
/**
|
||||
* Determines whether or not a ResultNode is a URL item or not
|
||||
* @param aNode
|
||||
|
@ -231,9 +258,10 @@ var PlacesUtils = {
|
|||
NS_ASSERT(aNode, "null node");
|
||||
|
||||
const NHRN = Ci.nsINavHistoryResultNode;
|
||||
return aNode.type == NHRN.RESULT_TYPE_URI ||
|
||||
aNode.type == NHRN.RESULT_TYPE_VISIT ||
|
||||
aNode.type == NHRN.RESULT_TYPE_FULL_VISIT;
|
||||
var type = aNode.type;
|
||||
return type == NHRN.RESULT_TYPE_URI ||
|
||||
type == NHRN.RESULT_TYPE_VISIT ||
|
||||
type == NHRN.RESULT_TYPE_FULL_VISIT;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -287,10 +315,12 @@ var PlacesUtils = {
|
|||
NS_ASSERT(aNode, "null node");
|
||||
|
||||
const NHRN = Ci.nsINavHistoryResultNode;
|
||||
return aNode.type == NHRN.RESULT_TYPE_HOST ||
|
||||
aNode.type == NHRN.RESULT_TYPE_QUERY ||
|
||||
aNode.type == NHRN.RESULT_TYPE_FOLDER ||
|
||||
aNode.type == NHRN.RESULT_TYPE_REMOTE_CONTAINER;
|
||||
var type = aNode.type;
|
||||
return type == NHRN.RESULT_TYPE_HOST ||
|
||||
type == NHRN.RESULT_TYPE_QUERY ||
|
||||
type == NHRN.RESULT_TYPE_FOLDER ||
|
||||
type == NHRN.RESULT_TYPE_DAY ||
|
||||
type == NHRN.RESULT_TYPE_REMOTE_CONTAINER;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -12,6 +12,7 @@ browser.jar:
|
|||
* content/browser/places/tree.xml (content/tree.xml)
|
||||
* content/browser/places/utils.js (content/utils.js)
|
||||
* content/browser/places/controller.js (content/controller.js)
|
||||
* content/browser/places/treeView.js (content/treeView.js)
|
||||
* content/browser/places/treeHelpers.js (content/treeHelpers.js)
|
||||
* content/browser/places/demos/time.xul (content/demos/time.xul)
|
||||
* content/browser/places/demos/time.html (content/demos/time.html)
|
||||
|
|
|
@ -88,9 +88,6 @@
|
|||
#define NS_NAVHISTORYSERVICE_CONTRACTID \
|
||||
"@mozilla.org/browser/nav-history-service;1"
|
||||
|
||||
#define NS_NAVHISTORYRESULTTREEVIEWER_CONTRACTID \
|
||||
"@mozilla.org/browser/nav-history/result-tree-viewer;1"
|
||||
|
||||
#define NS_ANNOTATIONSERVICE_CONTRACTID \
|
||||
"@mozilla.org/browser/annotation-service;1"
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
|
||||
interface nsIURI;
|
||||
|
||||
[scriptable, uuid(b7fc8b9b-d85f-4d89-9b2a-0e67bd6e8d78)]
|
||||
[scriptable, uuid(91f635a4-2531-4f3d-89ef-81403a685f44)]
|
||||
interface nsIFaviconService : nsISupports
|
||||
{
|
||||
/**
|
||||
|
@ -258,4 +258,9 @@ interface nsIFaviconService : nsISupports
|
|||
* page on a site that doesn't have a favicon.
|
||||
*/
|
||||
boolean isFailedFavicon(in nsIURI aIcon);
|
||||
|
||||
/**
|
||||
* The default favicon URL
|
||||
*/
|
||||
readonly attribute nsIURI defaultFavicon;
|
||||
};
|
||||
|
|
|
@ -209,6 +209,19 @@ nsFaviconService::SetFaviconUrlForPage(nsIURI* aPage, nsIURI* aFavicon)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsFaviconService::GetDefaultFavicon
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFaviconService::GetDefaultFavicon(nsIURI** _retval)
|
||||
{
|
||||
// not found, use default
|
||||
if (!mDefaultIcon) {
|
||||
nsresult rv = NS_NewURI(getter_AddRefs(mDefaultIcon),
|
||||
NS_LITERAL_CSTRING(FAVICON_DEFAULT_URL));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
return mDefaultIcon->Clone(_retval);
|
||||
}
|
||||
|
||||
// nsFaviconService::SetFaviconUrlForPageInternal
|
||||
//
|
||||
|
@ -653,12 +666,7 @@ nsFaviconService::GetFaviconImageForPage(nsIURI* aPage, nsIURI** _retval)
|
|||
}
|
||||
|
||||
// not found, use default
|
||||
if (! mDefaultIcon) {
|
||||
nsresult rv = NS_NewURI(getter_AddRefs(mDefaultIcon),
|
||||
NS_LITERAL_CSTRING(FAVICON_DEFAULT_URL));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
return mDefaultIcon->Clone(_retval);
|
||||
return GetDefaultFavicon(_retval);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -219,11 +219,6 @@ static const char* gXpcomShutdown = "xpcom-shutdown";
|
|||
// annotation names
|
||||
const char nsNavHistory::kAnnotationPreviousEncoding[] = "history/encoding";
|
||||
|
||||
nsIAtom* nsNavHistory::sMenuRootAtom = nsnull;
|
||||
nsIAtom* nsNavHistory::sToolbarFolderAtom = nsnull;
|
||||
nsIAtom* nsNavHistory::sSessionStartAtom = nsnull;
|
||||
nsIAtom* nsNavHistory::sSessionContinueAtom = nsnull;
|
||||
nsIAtom* nsNavHistory::sContainerAtom = nsnull;
|
||||
|
||||
nsNavHistory* nsNavHistory::gHistoryService;
|
||||
|
||||
|
@ -242,12 +237,6 @@ nsNavHistory::nsNavHistory() : mNowValid(PR_FALSE),
|
|||
#endif
|
||||
NS_ASSERTION(! gHistoryService, "YOU ARE CREATING 2 COPIES OF THE HISTORY SERVICE. Everything will break.");
|
||||
gHistoryService = this;
|
||||
|
||||
sMenuRootAtom = NS_NewAtom("menu-root");
|
||||
sToolbarFolderAtom = NS_NewAtom("toolbar-folder");
|
||||
sSessionStartAtom = NS_NewAtom("session-start");
|
||||
sSessionContinueAtom = NS_NewAtom("session-continue");
|
||||
sContainerAtom = NS_NewAtom("container");
|
||||
}
|
||||
|
||||
|
||||
|
@ -259,12 +248,6 @@ nsNavHistory::~nsNavHistory()
|
|||
// in case somebody creates an extra instance of the service.
|
||||
NS_ASSERTION(gHistoryService == this, "YOU CREATED 2 COPIES OF THE HISTORY SERVICE.");
|
||||
gHistoryService = nsnull;
|
||||
|
||||
NS_IF_RELEASE(sMenuRootAtom);
|
||||
NS_IF_RELEASE(sToolbarFolderAtom);
|
||||
NS_IF_RELEASE(sSessionStartAtom);
|
||||
NS_IF_RELEASE(sSessionContinueAtom);
|
||||
NS_IF_RELEASE(sContainerAtom);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -47,7 +47,6 @@
|
|||
#include "nsCOMArray.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsDataHashtable.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsINavHistoryService.h"
|
||||
#include "nsIAutoCompleteSearch.h"
|
||||
#include "nsIAutoCompleteResult.h"
|
||||
|
@ -242,12 +241,6 @@ public:
|
|||
// used in execute queries to get session ID info (only for visits)
|
||||
static const PRInt32 kGetInfoIndex_SessionId;
|
||||
|
||||
static nsIAtom* sMenuRootAtom;
|
||||
static nsIAtom* sToolbarFolderAtom;
|
||||
static nsIAtom* sSessionStartAtom;
|
||||
static nsIAtom* sSessionContinueAtom;
|
||||
static nsIAtom* sContainerAtom;
|
||||
|
||||
// this actually executes a query and gives you results, it is used by
|
||||
// nsNavHistoryQueryResultNode
|
||||
nsresult GetQueryResults(const nsCOMArray<nsNavHistoryQuery>& aQueries,
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -737,64 +737,4 @@ public:
|
|||
{ *type = nsNavHistoryResultNode::RESULT_TYPE_SEPARATOR; return NS_OK; }
|
||||
};
|
||||
|
||||
|
||||
// nsNavHistoryResultTreeViewer
|
||||
//
|
||||
|
||||
class nsNavHistoryResultTreeViewer : public nsINavHistoryResultTreeViewer,
|
||||
public nsITreeView
|
||||
{
|
||||
public:
|
||||
nsNavHistoryResultTreeViewer();
|
||||
virtual ~nsNavHistoryResultTreeViewer() {}
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSINAVHISTORYRESULTVIEWER
|
||||
NS_DECL_NSINAVHISTORYRESULTTREEVIEWER
|
||||
NS_DECL_NSITREEVIEW
|
||||
|
||||
protected:
|
||||
nsRefPtr<nsNavHistoryResult> mResult;
|
||||
nsCOMPtr<nsITreeBoxObject> mTree; // will be null when no tree attached
|
||||
nsCOMPtr<nsITreeSelection> mSelection; // may be null
|
||||
|
||||
PRBool mCollapseDuplicates;
|
||||
|
||||
// This value indicates whether we should try to compute session boundaries.
|
||||
// It is cached so we don't have to compute it every time we want to get a
|
||||
// row style.
|
||||
PRBool mShowSessions;
|
||||
void ComputeShowSessions();
|
||||
enum SessionStatus { Session_None, Session_Start, Session_Continue };
|
||||
SessionStatus GetRowSessionStatus(PRInt32 row);
|
||||
|
||||
// This list is used to map rows to nodes.
|
||||
typedef nsTArray< nsCOMPtr<nsNavHistoryResultNode> > VisibleList;
|
||||
VisibleList mVisibleElements;
|
||||
nsresult BuildVisibleList();
|
||||
nsresult BuildVisibleSection(nsNavHistoryContainerResultNode* aContainer,
|
||||
VisibleList* aVisible,
|
||||
PRUint32 aVisibleStartIndex);
|
||||
PRUint32 CountVisibleRowsForItem(nsNavHistoryResultNode* aNode);
|
||||
nsresult RefreshVisibleSection(nsNavHistoryContainerResultNode* aContainer);
|
||||
|
||||
PRBool CanCollapseDuplicates(nsNavHistoryResultNode* aTop,
|
||||
nsNavHistoryResultNode* aNext,
|
||||
PRUint32* aShowThisOne);
|
||||
|
||||
// external observers
|
||||
nsMaybeWeakPtrArray<nsINavHistoryResultViewObserver> mObservers;
|
||||
|
||||
nsresult FinishInit();
|
||||
|
||||
// columns
|
||||
enum ColumnType { Column_Unknown = -1, Column_Title, Column_URI, Column_Date,
|
||||
Column_VisitCount };
|
||||
ColumnType GetColumnType(nsITreeColumn* col);
|
||||
ColumnType SortTypeToColumnType(PRUint32 aSortType,
|
||||
PRBool* aDescending = nsnull);
|
||||
|
||||
nsresult FormatFriendlyTime(PRTime aTime, nsAString& aResult);
|
||||
};
|
||||
|
||||
#endif // nsNavHistoryResult_h_
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include "nsMorkHistoryImporter.h"
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsNavHistory, Init)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsNavHistoryResultTreeViewer)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAnnoProtocolHandler)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsAnnotationService, Init)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsNavBookmarks, Init)
|
||||
|
@ -32,11 +31,6 @@ static const nsModuleComponentInfo components[] =
|
|||
"@mozilla.org/autocomplete/search;1?name=history",
|
||||
nsNavHistoryConstructor },
|
||||
|
||||
{ "History tree view",
|
||||
NS_NAVHISTORYRESULTTREEVIEWER_CID,
|
||||
NS_NAVHISTORYRESULTTREEVIEWER_CONTRACTID,
|
||||
nsNavHistoryResultTreeViewerConstructor },
|
||||
|
||||
{ "Page Annotation Service",
|
||||
NS_ANNOTATIONSERVICE_CID,
|
||||
NS_ANNOTATIONSERVICE_CONTRACTID,
|
||||
|
|
Загрузка…
Ссылка в новой задаче