Bug 1855386: Remove nsNavBookmarks::ResultNodeForContainer() r=mak

Differential Revision: https://phabricator.services.mozilla.com/D190650
This commit is contained in:
Daisuke Akatsuka 2023-11-06 21:28:19 +00:00
parent 19d70df0a2
commit a899e73b55
16 changed files with 429 additions and 173 deletions

View File

@ -43,6 +43,10 @@ class PlacesBookmarkAddition final : public PlacesBookmark {
event->mLastVisitDate.SetNull();
}
event->mTargetFolderItemId = aInitDict.mTargetFolderItemId;
event->mTargetFolderGuid = aInitDict.mTargetFolderGuid;
event->mTargetFolderTitle = aInitDict.mTargetFolderTitle;
return event.forget();
}
@ -63,6 +67,9 @@ class PlacesBookmarkAddition final : public PlacesBookmark {
bool Hidden() { return mHidden; }
uint32_t VisitCount() { return mVisitCount; }
Nullable<uint64_t> GetLastVisitDate() { return mLastVisitDate; }
uint64_t TargetFolderItemId() { return mTargetFolderItemId; }
void GetTargetFolderGuid(nsCString& aGuid) { aGuid = mTargetFolderGuid; }
void GetTargetFolderTitle(nsString& aTitle) { aTitle = mTargetFolderTitle; }
int32_t mIndex;
nsString mTitle;
@ -72,6 +79,9 @@ class PlacesBookmarkAddition final : public PlacesBookmark {
bool mHidden;
uint32_t mVisitCount;
Nullable<uint64_t> mLastVisitDate;
int64_t mTargetFolderItemId;
nsCString mTargetFolderGuid;
nsString mTargetFolderTitle;
private:
~PlacesBookmarkAddition() = default;

View File

@ -215,6 +215,9 @@ dictionary PlacesBookmarkAdditionInit {
required boolean hidden;
required unsigned long visitCount;
required unsigned long long? lastVisitDate;
required long long targetFolderItemId;
required ByteString? targetFolderGuid;
required DOMString? targetFolderTitle;
};
[ChromeOnly, Exposed=Window]
@ -260,6 +263,22 @@ interface PlacesBookmarkAddition : PlacesBookmark {
* Date of the last visit, in milliseconds since epoch.
*/
readonly attribute unsigned long long? lastVisitDate;
/**
* If this is a folder shortcut, the id of the target folder.
*/
readonly attribute long long targetFolderItemId;
/**
* If this is a folder shortcut, the unique ID associated with the target folder.
*/
readonly attribute ByteString targetFolderGuid;
/**
* If this is a folder shortcut, the title of the target folder.
*/
readonly attribute DOMString targetFolderTitle;
};
dictionary PlacesBookmarkRemovedInit {

View File

@ -305,6 +305,9 @@ export var Bookmarks = Object.freeze({
hidden: itemDetail.hidden,
visitCount: itemDetail.visitCount,
lastVisitDate: itemDetail.lastVisitDate,
targetFolderGuid: itemDetail.targetFolderGuid,
targetFolderItemId: itemDetail.targetFolderItemId,
targetFolderTitle: itemDetail.targetFolderTitle,
}),
];
@ -624,6 +627,9 @@ export var Bookmarks = Object.freeze({
hidden: itemDetail.hidden,
visitCount: itemDetail.visitCount,
lastVisitDate: itemDetail.lastVisitDate,
targetFolderGuid: itemDetail.targetFolderGuid,
targetFolderItemId: itemDetail.targetFolderItemId,
targetFolderTitle: itemDetail.targetFolderTitle,
})
);
@ -3340,9 +3346,11 @@ async function getBookmarkDetailMap(aGuids) {
SELECT id FROM moz_bookmarks
WHERE guid = '${Bookmarks.tagsGuid}'
)
)
),
t.guid, t.id, t.title
FROM moz_bookmarks b
LEFT JOIN moz_places h ON h.id = b.fk
LEFT JOIN moz_bookmarks t ON t.guid = target_folder_guid(h.url)
WHERE b.guid IN (${lazy.PlacesUtils.sqlBindPlaceholders(aGuids)})
`,
aGuids
@ -3364,6 +3372,9 @@ async function getBookmarkDetailMap(aGuids) {
? lazy.PlacesUtils.toDate(lastVisitDate).getTime()
: null,
tags: row.getResultByIndex(7) ?? "",
targetFolderGuid: row.getResultByIndex(8),
targetFolderItemId: row.getResultByIndex(9),
targetFolderTitle: row.getResultByIndex(10),
},
];
})

View File

@ -1619,6 +1619,8 @@ nsresult Database::InitFunctions() {
NS_ENSURE_SUCCESS(rv, rv);
rv = SetShouldStartFrecencyRecalculationFunction::create(mMainConn);
NS_ENSURE_SUCCESS(rv, rv);
rv = TargetFolderGuidFunction::create(mMainConn);
NS_ENSURE_SUCCESS(rv, rv);
if (StaticPrefs::places_frecency_pages_alternative_featureGate_AtStartup()) {
rv = CalculateAltFrecencyFunction::create(mMainConn);

View File

@ -1478,4 +1478,43 @@ InvalidateDaysOfHistoryFunction::OnFunctionCall(mozIStorageValueArray* aArgs,
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
//// Target folder guid from places query Function
/* static */
nsresult TargetFolderGuidFunction::create(mozIStorageConnection* aDBConn) {
RefPtr<TargetFolderGuidFunction> function = new TargetFolderGuidFunction();
nsresult rv = aDBConn->CreateFunction("target_folder_guid"_ns, 1, function);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
NS_IMPL_ISUPPORTS(TargetFolderGuidFunction, mozIStorageFunction)
NS_IMETHODIMP
TargetFolderGuidFunction::OnFunctionCall(mozIStorageValueArray* aArguments,
nsIVariant** _result) {
// Must have non-null function arguments.
MOZ_ASSERT(aArguments);
// Must have one argument.
DebugOnly<uint32_t> numArgs = 0;
MOZ_ASSERT(NS_SUCCEEDED(aArguments->GetNumEntries(&numArgs)) && numArgs == 1,
"unexpected number of arguments");
nsDependentCString queryURI = getSharedUTF8String(aArguments, 0);
Maybe<nsCString> targetFolderGuid =
nsNavHistory::GetTargetFolderGuid(queryURI);
if (targetFolderGuid.isSome()) {
RefPtr<nsVariant> result = new nsVariant();
result->SetAsACString(*targetFolderGuid);
result.forget(_result);
} else {
*_result = MakeAndAddRef<NullVariant>().take();
}
return NS_OK;
}
} // namespace mozilla::places

View File

@ -657,6 +657,29 @@ class InvalidateDaysOfHistoryFunction final : public mozIStorageFunction {
~InvalidateDaysOfHistoryFunction() = default;
};
////////////////////////////////////////////////////////////////////////////////
//// Target folder guid from places query Function
/**
* Target folder guid from places query.
*/
class TargetFolderGuidFunction final : public mozIStorageFunction {
public:
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_MOZISTORAGEFUNCTION
/**
* Registers the function with the specified database connection.
*
* @param aDBConn
* The database connection to register with.
*/
static nsresult create(mozIStorageConnection* aDBConn);
private:
~TargetFolderGuidFunction() = default;
};
} // namespace places
} // namespace mozilla

View File

@ -2246,11 +2246,13 @@ class BookmarkObserverRecorder {
SELECT id FROM moz_bookmarks
WHERE guid = '${lazy.PlacesUtils.bookmarks.tagsGuid}'
)
) AS tags
) AS tags,
t.guid AS tGuid, t.id AS tId, t.title AS tTitle
FROM itemsAdded n
JOIN moz_bookmarks b ON b.guid = n.guid
JOIN moz_bookmarks p ON p.id = b.parent
LEFT JOIN moz_places h ON h.id = b.fk
LEFT JOIN moz_bookmarks t ON t.guid = target_folder_guid(url)
${this.orderBy("n.level", "b.parent", "b.position")}`,
null,
(row, cancel) => {
@ -2279,6 +2281,9 @@ class BookmarkObserverRecorder {
? lazy.PlacesUtils.toDate(lastVisitDate).getTime()
: null,
tags: row.getResultByName("tags"),
targetFolderGuid: row.getResultByName("tGuid"),
targetFolderItemId: row.getResultByName("tId"),
targetFolderTitle: row.getResultByName("tTitle"),
};
this.noteItemAdded(info);
@ -2425,6 +2430,9 @@ class BookmarkObserverRecorder {
hidden: info.hidden,
visitCount: info.visitCount,
lastVisitDate: info.lastVisitDate,
targetFolderGuid: info.targetFolderGuid,
targetFolderItemId: info.targetFolderItemId,
targetFolderTitle: info.targetFolderTitle,
})
);
}

View File

@ -445,9 +445,11 @@ nsNavBookmarks::InsertBookmark(int64_t aFolder, nsIURI* aURI, int32_t aIndex,
" SELECT id FROM moz_bookmarks "
" WHERE guid = '" TAGS_ROOT_GUID
"'"
" ) "
") "
" ) "
" ), "
" t.guid, t.id, t.title "
"FROM moz_places h "
"LEFT JOIN moz_bookmarks t ON t.guid = target_folder_guid(h.url) "
"WHERE h.id = :id");
NS_ENSURE_STATE(stmt);
mozStorageStatementScoper scoper(stmt);
@ -485,6 +487,30 @@ nsNavBookmarks::InsertBookmark(int64_t aFolder, nsIURI* aURI, int32_t aIndex,
rv = stmt->GetString(4, tags);
NS_ENSURE_SUCCESS(rv, rv);
bookmark->mTags.Assign(tags);
bool isTargetFolderNull;
rv = stmt->GetIsNull(5, &isTargetFolderNull);
NS_ENSURE_SUCCESS(rv, rv);
if (!isTargetFolderNull) {
nsCString targetFolderGuid;
rv = stmt->GetUTF8String(5, targetFolderGuid);
NS_ENSURE_SUCCESS(rv, rv);
bookmark->mTargetFolderGuid.Assign(targetFolderGuid);
int64_t targetFolderItemId = -1;
rv = stmt->GetInt64(6, &targetFolderItemId);
NS_ENSURE_SUCCESS(rv, rv);
bookmark->mTargetFolderItemId = targetFolderItemId;
nsString targetFolderTitle;
rv = stmt->GetString(7, targetFolderTitle);
NS_ENSURE_SUCCESS(rv, rv);
bookmark->mTargetFolderTitle.Assign(targetFolderTitle);
} else {
bookmark->mTargetFolderGuid.SetIsVoid(true);
bookmark->mTargetFolderItemId = -1;
bookmark->mTargetFolderTitle.SetIsVoid(true);
}
} else {
MOZ_ASSERT(false);
bookmark->mTags.SetIsVoid(true);
@ -492,6 +518,9 @@ nsNavBookmarks::InsertBookmark(int64_t aFolder, nsIURI* aURI, int32_t aIndex,
bookmark->mHidden = false;
bookmark->mVisitCount = 0;
bookmark->mLastVisitDate.SetNull();
bookmark->mTargetFolderGuid.SetIsVoid(true);
bookmark->mTargetFolderItemId = -1;
bookmark->mTargetFolderTitle.SetIsVoid(true);
}
bool success = !!notifications.AppendElement(bookmark.forget(), fallible);
@ -731,6 +760,9 @@ nsNavBookmarks::CreateFolder(int64_t aParent, const nsACString& aTitle,
folder->mHidden = false;
folder->mVisitCount = 0;
folder->mLastVisitDate.SetNull();
folder->mTargetFolderGuid.SetIsVoid(true);
folder->mTargetFolderItemId = -1;
folder->mTargetFolderTitle.SetIsVoid(true);
bool success = !!events.AppendElement(folder.forget(), fallible);
MOZ_RELEASE_ASSERT(success);
@ -1476,29 +1508,6 @@ nsNavBookmarks::GetItemTitle(int64_t aItemId, nsACString& _title) {
return NS_OK;
}
nsresult nsNavBookmarks::ResultNodeForContainer(
const nsCString& aGUID, nsNavHistoryQueryOptions* aOptions,
nsNavHistoryResultNode** aNode) {
BookmarkData bookmark;
nsresult rv = FetchItemInfo(aGUID, bookmark);
NS_ENSURE_SUCCESS(rv, rv);
if (bookmark.type == TYPE_FOLDER) { // TYPE_FOLDER
*aNode =
new nsNavHistoryFolderResultNode(bookmark.title, aOptions, bookmark.id);
} else {
return NS_ERROR_INVALID_ARG;
}
(*aNode)->mDateAdded = bookmark.dateAdded;
(*aNode)->mLastModified = bookmark.lastModified;
(*aNode)->mBookmarkGuid = bookmark.guid;
(*aNode)->GetAsFolder()->mTargetFolderGuid = bookmark.guid;
NS_ADDREF(*aNode);
return NS_OK;
}
nsresult nsNavBookmarks::QueryFolderChildren(
int64_t aFolderId, nsNavHistoryQueryOptions* aOptions,
nsCOMArray<nsNavHistoryResultNode>* aChildren) {
@ -1522,9 +1531,10 @@ nsresult nsNavBookmarks::QueryFolderChildren(
"'"
" WHERE bb.fk = h.id), "
"h.frecency, h.hidden, h.guid, null, null, null, "
"b.guid, b.position, b.type, b.fk "
"b.guid, b.position, b.type, b.fk, t.guid, t.id, t.title "
"FROM moz_bookmarks b "
"LEFT JOIN moz_places h ON b.fk = h.id "
"LEFT JOIN moz_bookmarks t ON t.guid = target_folder_guid(h.url) "
"WHERE b.parent = :parent "
"AND (NOT :excludeItems OR "
"b.type = :folder OR "
@ -1596,14 +1606,14 @@ nsresult nsNavBookmarks::ProcessFolderNodeRow(
NS_ENSURE_SUCCESS(rv, rv);
}
nsAutoCString guid;
rv = aRow->GetUTF8String(kGetChildrenIndex_Guid, guid);
NS_ENSURE_SUCCESS(rv, rv);
// Don't use options from the parent to build the new folder node, it will
// inherit those later when it's inserted in the result.
node = new nsNavHistoryFolderResultNode(title,
new nsNavHistoryQueryOptions(), id);
rv = aRow->GetUTF8String(kGetChildrenIndex_Guid, node->mBookmarkGuid);
NS_ENSURE_SUCCESS(rv, rv);
node->GetAsFolder()->mTargetFolderGuid = node->mBookmarkGuid;
node = new nsNavHistoryFolderResultNode(id, guid, id, guid, title,
new nsNavHistoryQueryOptions());
rv = aRow->GetInt64(nsNavHistory::kGetInfoIndex_ItemDateAdded,
reinterpret_cast<int64_t*>(&node->mDateAdded));
@ -1649,9 +1659,10 @@ nsresult nsNavBookmarks::QueryFolderChildrenAsync(
"SELECT h.id, h.url, b.title, h.rev_host, h.visit_count, "
"h.last_visit_date, null, b.id, b.dateAdded, b.lastModified, "
"b.parent, null, h.frecency, h.hidden, h.guid, null, null, null, "
"b.guid, b.position, b.type, b.fk "
"b.guid, b.position, b.type, b.fk, t.guid, t.id, t.title "
"FROM moz_bookmarks b "
"LEFT JOIN moz_places h ON b.fk = h.id "
"LEFT JOIN moz_bookmarks t ON t.guid = target_folder_guid(h.url) "
"WHERE b.parent = :parent "
"AND (NOT :excludeItems OR "
"b.type = :folder OR "

View File

@ -101,10 +101,6 @@ class nsNavBookmarks final : public nsINavBookmarksService,
bool aHidden, uint32_t aVisitCount, uint32_t aTyped,
const nsAString& aLastKnownTitle);
nsresult ResultNodeForContainer(const nsCString& aGUID,
nsNavHistoryQueryOptions* aOptions,
nsNavHistoryResultNode** aNode);
// Find all the children of a folder, using the given query and options.
// For each child, a ResultNode is created and added to |children|.
// The results are ordered by folder position.

View File

@ -180,12 +180,11 @@ NS_IMPL_CI_INTERFACE_GETTER(nsNavHistory, nsINavHistoryService)
namespace {
static nsCString GetSimpleBookmarksQueryParent(
static Maybe<nsCString> GetSimpleBookmarksQueryParent(
const RefPtr<nsNavHistoryQuery>& aQuery,
const RefPtr<nsNavHistoryQueryOptions>& aOptions);
static void ParseSearchTermsFromQuery(const RefPtr<nsNavHistoryQuery>& aQuery,
nsTArray<nsString>* aTerms);
void GetTagsSqlFragment(int64_t aTagsFolder, const nsACString& aRelation,
const uint16_t aQueryType, nsACString& _sqlFragment) {
if (aQueryType != nsINavHistoryQueryOptions::QUERY_TYPE_BOOKMARKS) {
@ -208,6 +207,46 @@ void GetTagsSqlFragment(int64_t aTagsFolder, const nsACString& aRelation,
_sqlFragment.AppendLiteral(" AS tags ");
}
nsresult FetchInfo(const RefPtr<mozilla::places::Database>& aDB,
const nsCString& aGUID, int32_t& aType, int64_t& aId,
nsCString& aTitle, PRTime& aDateAdded,
PRTime& aLastModified) {
nsCOMPtr<mozIStorageStatement> statement = aDB->GetStatement(
"SELECT type, id, title, dateAdded, lastModified FROM moz_bookmarks "
"WHERE guid = :guid");
NS_ENSURE_STATE(statement);
mozStorageStatementScoper scoper(statement);
nsresult rv = statement->BindUTF8StringByName("guid"_ns, aGUID);
NS_ENSURE_SUCCESS(rv, rv);
bool hasResult;
rv = statement->ExecuteStep(&hasResult);
NS_ENSURE_SUCCESS(rv, rv);
if (!hasResult) {
return NS_ERROR_INVALID_ARG;
}
aType = statement->AsInt32(0);
aId = statement->AsInt64(1);
bool isNull;
rv = statement->GetIsNull(2, &isNull);
NS_ENSURE_SUCCESS(rv, rv);
if (isNull) {
aTitle.SetIsVoid(true);
} else {
rv = statement->GetUTF8String(2, aTitle);
NS_ENSURE_SUCCESS(rv, rv);
}
aDateAdded = statement->AsInt64(3);
NS_ENSURE_SUCCESS(rv, rv);
aLastModified = statement->AsInt64(4);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
} // namespace
// Queries rows indexes to bind or get values, if adding a new one, be sure to
@ -236,6 +275,9 @@ const int32_t nsNavHistory::kGetInfoIndex_VisitType = 17;
// nsNavBookmarks::kGetChildrenIndex_Position = 19;
// nsNavBookmarks::kGetChildrenIndex_Type = 20;
// nsNavBookmarks::kGetChildrenIndex_PlaceID = 21;
const int32_t nsNavHistory::kGetTargetFolder_Guid = 22;
const int32_t nsNavHistory::kGetTargetFolder_ItemId = 23;
const int32_t nsNavHistory::kGetTargetFolder_Title = 24;
PLACES_FACTORY_SINGLETON_IMPLEMENTATION(nsNavHistory, gHistoryService)
@ -444,6 +486,26 @@ void nsNavHistory::UpdateDaysOfHistory(PRTime visitTime) {
}
}
/* static */
mozilla::Maybe<nsCString> nsNavHistory::GetTargetFolderGuid(
const nsACString& aQueryURI) {
nsCOMPtr<nsINavHistoryQuery> query;
nsCOMPtr<nsINavHistoryQueryOptions> options;
if (!IsQueryURI(aQueryURI) ||
NS_FAILED(nsNavHistoryQuery::QueryStringToQuery(
aQueryURI, getter_AddRefs(query), getter_AddRefs(options)))) {
return Nothing();
}
RefPtr<nsNavHistoryQuery> queryObj = do_QueryObject(query);
RefPtr<nsNavHistoryQueryOptions> optionsObj = do_QueryObject(options);
if (!queryObj || !optionsObj) {
return Nothing();
}
return GetSimpleBookmarksQueryParent(queryObj, optionsObj);
}
Atomic<int64_t> nsNavHistory::sLastInsertedPlaceId(0);
Atomic<int64_t> nsNavHistory::sLastInsertedVisitId(0);
Atomic<bool> nsNavHistory::sIsFrecencyDecaying(false);
@ -687,17 +749,25 @@ nsNavHistory::ExecuteQuery(nsINavHistoryQuery* aQuery,
// Create the root node.
RefPtr<nsNavHistoryContainerResultNode> rootNode;
nsCString folderGuid = GetSimpleBookmarksQueryParent(query, options);
if (!folderGuid.IsEmpty()) {
// In the simple case where we're just querying children of a single
// bookmark folder, we can more efficiently generate results.
nsNavBookmarks* bookmarks = nsNavBookmarks::GetBookmarksService();
NS_ENSURE_TRUE(bookmarks, NS_ERROR_OUT_OF_MEMORY);
RefPtr<nsNavHistoryResultNode> tempRootNode;
nsresult rv = bookmarks->ResultNodeForContainer(
folderGuid, options, getter_AddRefs(tempRootNode));
if (NS_SUCCEEDED(rv)) {
rootNode = tempRootNode->GetAsContainer();
Maybe<nsCString> targetFolderGuid =
GetSimpleBookmarksQueryParent(query, options);
if (targetFolderGuid.isSome()) {
int32_t targetFolderType = 0;
int64_t targetFolderId = -1;
nsCString targetFolderTitle;
PRTime dateAdded;
PRTime lastModified;
nsresult rv =
FetchInfo(mDB, *targetFolderGuid, targetFolderType, targetFolderId,
targetFolderTitle, dateAdded, lastModified);
if (NS_SUCCEEDED(rv) &&
targetFolderType == nsINavBookmarksService::TYPE_FOLDER) {
auto* node = new nsNavHistoryFolderResultNode(
targetFolderId, *targetFolderGuid, targetFolderId, *targetFolderGuid,
targetFolderTitle, options);
node->mDateAdded = dateAdded;
node->mLastModified = lastModified;
rootNode = node->GetAsContainer();
} else {
NS_WARNING("Generating a generic empty node for a broken query!");
// This is a perf hack to generate an empty query that skips filtering.
@ -920,8 +990,8 @@ nsresult PlacesSQLQueryBuilder::SelectAsURI() {
"h.last_visit_date, null, null, null, null, null, ") +
tagsSqlFragment +
nsLiteralCString(
", h.frecency, h.hidden, h.guid, "
"null, null, null "
", h.frecency, h.hidden, h.guid, null, null, null "
", null, null, null, null, null, null, null "
"FROM moz_places h "
// WHERE 1 is a no-op since additonal conditions will
// start with AND.
@ -942,8 +1012,10 @@ nsresult PlacesSQLQueryBuilder::SelectAsURI() {
nsLiteralCString(
", h.frecency, h.hidden, h.guid,"
"null, null, null, b.guid, b.position, b.type, b.fk "
", t.guid, t.id, t.title "
"FROM moz_bookmarks b "
"JOIN moz_places h ON b.fk = h.id "
"LEFT JOIN moz_bookmarks t ON t.guid = target_folder_guid(h.url) "
"WHERE NOT EXISTS "
"(SELECT id FROM moz_bookmarks "
"WHERE id = b.parent AND parent = ") +
@ -977,6 +1049,7 @@ nsresult PlacesSQLQueryBuilder::SelectAsVisit() {
nsLiteralCString(
", h.frecency, h.hidden, h.guid, "
"v.id, v.from_visit, v.visit_type "
", null, null, null, null, null, null, null "
"FROM moz_places h "
"JOIN moz_historyvisits v ON h.id = v.place_id "
// WHERE 1 is a no-op since additonal conditions will start with AND.
@ -1009,6 +1082,7 @@ nsresult PlacesSQLQueryBuilder::SelectAsDay() {
"SELECT null, "
"'place:type=%d&sort=%d&beginTime='||beginTime||'&endTime='||endTime, "
"dayTitle, null, null, beginTime, null, null, null, null, null, null, "
"null, null, null, null, null, null, null, null, null, null, "
"null, null, null "
"FROM (", // TOUTER BEGIN
resultType, sortingMode);
@ -1209,7 +1283,8 @@ nsresult PlacesSQLQueryBuilder::SelectAsSite() {
mQueryString = nsPrintfCString(
"SELECT null, 'place:type=%d&sort=%d&domain=&domainIsHost=true'%s, "
":localhost, :localhost, null, null, null, null, null, null, null, "
"null, null, null "
"null, null, null, null, null, null, null, null, null, null, "
"null, null, null, null "
"WHERE EXISTS ( "
"SELECT h.id FROM moz_places h "
"%s "
@ -1224,7 +1299,8 @@ nsresult PlacesSQLQueryBuilder::SelectAsSite() {
"SELECT null, "
"'place:type=%d&sort=%d&domain='||host||'&domainIsHost=true'%s, "
"host, host, null, null, null, null, null, null, null, "
"null, null, null "
"null, null, null, null, null, null, null, null, null, null, "
"null, null, null, null "
"FROM ( "
"SELECT get_unreversed_host(h.rev_host) AS host "
"FROM moz_places h "
@ -1258,7 +1334,8 @@ nsresult PlacesSQLQueryBuilder::SelectAsTag() {
mQueryString = nsPrintfCString(
"SELECT null, 'place:tag=' || title, "
"title, null, null, null, null, null, dateAdded, "
"lastModified, null, null, null, null, null, null "
"lastModified, null, null, null, null, null, null, "
"null, null, null, null, null, null, null, null, null "
"FROM moz_bookmarks "
"WHERE parent = %" PRId64,
history->GetTagsFolder());
@ -1293,7 +1370,14 @@ nsresult PlacesSQLQueryBuilder::SelectAsRoots() {
"(null, 'place:parent=" MOBILE_ROOT_GUID
"', :MobileBookmarksFolderTitle, null, null, null, "
"null, null, 0, 0, null, null, null, null, "
"'" MOBILE_BOOKMARKS_VIRTUAL_GUID "', null) ");
"'" MOBILE_BOOKMARKS_VIRTUAL_GUID
"', null, "
"null, null, null, null, null, null, "
"'" MOBILE_ROOT_GUID
"', "
"(SELECT id FROM moz_bookmarks WHERE guid='" MOBILE_ROOT_GUID
"'), "
":MobileBookmarksFolderTitle)");
}
mQueryString =
@ -1301,13 +1385,31 @@ nsresult PlacesSQLQueryBuilder::SelectAsRoots() {
"SELECT * FROM ("
"VALUES(null, 'place:parent=" TOOLBAR_ROOT_GUID
"', :BookmarksToolbarFolderTitle, null, null, null, "
"null, null, 0, 0, null, null, null, null, 'toolbar____v', null), "
"null, null, 0, 0, null, null, null, null, 'toolbar____v', null, "
"null, null, null, null, null, null, "
"'" TOOLBAR_ROOT_GUID
"', "
"(SELECT id FROM moz_bookmarks WHERE guid='" TOOLBAR_ROOT_GUID
"'), "
":BookmarksToolbarFolderTitle), "
"(null, 'place:parent=" MENU_ROOT_GUID
"', :BookmarksMenuFolderTitle, null, null, null, "
"null, null, 0, 0, null, null, null, null, 'menu_______v', null), "
"null, null, 0, 0, null, null, null, null, 'menu_______v', null, "
"null, null, null, null, null, null, "
"'" MENU_ROOT_GUID
"', "
"(SELECT id FROM moz_bookmarks WHERE guid='" MENU_ROOT_GUID
"'), "
":BookmarksMenuFolderTitle), "
"(null, 'place:parent=" UNFILED_ROOT_GUID
"', :OtherBookmarksFolderTitle, null, null, null, "
"null, null, 0, 0, null, null, null, null, 'unfiled____v', null) ") +
"null, null, 0, 0, null, null, null, null, 'unfiled____v', null, "
"null, null, null, null, null, null, "
"'" UNFILED_ROOT_GUID
"', "
"(SELECT id FROM moz_bookmarks WHERE guid='" UNFILED_ROOT_GUID
"'), "
":OtherBookmarksFolderTitle)") +
mobileString + ")"_ns;
return NS_OK;
@ -1336,14 +1438,18 @@ nsresult PlacesSQLQueryBuilder::SelectAsLeftPane() {
"VALUES"
"(null, 'place:type=%d&sort=%d', :OrganizerQueryHistory, null, null, "
"null, "
"null, null, 0, 0, null, null, null, null, 'history____v', null), "
"null, null, 0, 0, null, null, null, null, 'history____v', null, "
"null, null, null, null, null, null, null), "
"(null, 'place:transition=%d&sort=%d', :OrganizerQueryDownloads, null, "
"null, null, "
"null, null, 0, 0, null, null, null, null, 'downloads__v', null), "
"null, null, 0, 0, null, null, null, null, 'downloads__v', null, "
"null, null, null, null, null, null, null), "
"(null, 'place:type=%d&sort=%d', :TagsFolderTitle, null, null, null, "
"null, null, 0, 0, null, null, null, null, 'tags_______v', null), "
"null, null, 0, 0, null, null, null, null, 'tags_______v', null, "
"null, null, null, null, null, null, null), "
"(null, 'place:type=%d', :OrganizerQueryAllBookmarks, null, null, null, "
"null, null, 0, 0, null, null, null, null, 'allbms_____v', null) "
"null, null, 0, 0, null, null, null, null, 'allbms_____v', null, "
"null, null, null, null, null, null, null) "
")",
nsINavHistoryQueryOptions::RESULTS_AS_DATE_QUERY,
nsINavHistoryQueryOptions::SORT_BY_DATE_DESCENDING,
@ -1555,8 +1661,8 @@ nsresult nsNavHistory::ConstructQueryString(
"null, null, null, null, null, ") +
tagsSqlFragment +
nsLiteralCString(
", h.frecency, h.hidden, h.guid, "
"null, null, null "
", h.frecency, h.hidden, h.guid, null, null, null"
", null, null, null, null, null, null, null "
"FROM moz_places h "
"WHERE h.hidden = 0 "
"AND EXISTS (SELECT id FROM moz_historyvisits WHERE place_id = "
@ -2450,9 +2556,23 @@ nsresult nsNavHistory::RowToResult(mozIStorageValueArray* aRow,
NS_ENSURE_SUCCESS(rv, rv);
}
int64_t targetFolderItemId = -1;
nsAutoCString targetFolderGuid;
nsAutoCString targetFolderTitle;
rv = aRow->GetIsNull(kGetTargetFolder_Guid, &isNull);
NS_ENSURE_SUCCESS(rv, rv);
if (!isNull) {
targetFolderItemId = aRow->AsInt64(kGetTargetFolder_ItemId);
rv = aRow->GetUTF8String(kGetTargetFolder_Guid, targetFolderGuid);
NS_ENSURE_SUCCESS(rv, rv);
rv = aRow->GetUTF8String(kGetTargetFolder_Title, targetFolderTitle);
NS_ENSURE_SUCCESS(rv, rv);
}
RefPtr<nsNavHistoryResultNode> resultNode;
rv = QueryRowToResult(itemId, guid, url, title, accessCount, time,
getter_AddRefs(resultNode));
rv = QueryUriToResult(url, itemId, guid, title, targetFolderItemId,
targetFolderGuid, targetFolderTitle, accessCount,
time, getter_AddRefs(resultNode));
NS_ENSURE_SUCCESS(rv, rv);
if (itemId != -1 || aOptions->ResultType() ==
@ -2522,27 +2642,23 @@ nsresult nsNavHistory::RowToResult(mozIStorageValueArray* aRow,
return NS_ERROR_FAILURE;
}
// nsNavHistory::QueryRowToResult
//
// Called by RowToResult when the URI is a place: URI to generate the proper
// folder or query node.
nsresult nsNavHistory::QueryRowToResult(int64_t itemId,
const nsACString& aBookmarkGuid,
const nsACString& aURI,
const nsACString& aTitle,
uint32_t aAccessCount, PRTime aTime,
nsNavHistoryResultNode** aNode) {
// Only assert if the itemId is set. In some cases (e.g. virtual queries), we
// have a guid, but not an itemId.
if (itemId != -1) {
// When the URI is a place: URI, generate the proper folder or query node.
nsresult nsNavHistory::QueryUriToResult(
const nsACString& aQueryURI, int64_t aItemId,
const nsACString& aBookmarkGuid, const nsACString& aTitle,
int64_t aTargetFolderItemId, const nsACString& aTargetFolderGuid,
const nsACString& aTargetFolderTitle, uint32_t aAccessCount, PRTime aTime,
nsNavHistoryResultNode** aNode) {
// Only assert if the aItemId is set. In some cases (e.g. virtual queries), we
// have a guid, but not an aItemId.
if (aItemId != -1) {
MOZ_ASSERT(!aBookmarkGuid.IsEmpty());
}
nsCOMPtr<nsINavHistoryQuery> query;
nsCOMPtr<nsINavHistoryQueryOptions> options;
nsresult rv =
QueryStringToQuery(aURI, getter_AddRefs(query), getter_AddRefs(options));
nsresult rv = QueryStringToQuery(aQueryURI, getter_AddRefs(query),
getter_AddRefs(options));
RefPtr<nsNavHistoryResultNode> resultNode;
RefPtr<nsNavHistoryQuery> queryObj = do_QueryObject(query);
NS_ENSURE_STATE(queryObj);
@ -2551,35 +2667,16 @@ nsresult nsNavHistory::QueryRowToResult(int64_t itemId,
// If this failed the query does not parse correctly, let the error pass and
// handle it later.
if (NS_SUCCEEDED(rv)) {
// Check if this is a folder shortcut, so we can take a faster path.
nsCString targetFolderGuid =
GetSimpleBookmarksQueryParent(queryObj, optionsObj);
if (!targetFolderGuid.IsEmpty()) {
nsNavBookmarks* bookmarks = nsNavBookmarks::GetBookmarksService();
NS_ENSURE_TRUE(bookmarks, NS_ERROR_OUT_OF_MEMORY);
rv = bookmarks->ResultNodeForContainer(targetFolderGuid, optionsObj,
getter_AddRefs(resultNode));
// If this failed the shortcut is pointing to nowhere, let the error pass
// and handle it later.
if (NS_SUCCEEDED(rv)) {
// At this point the node is set up like a regular folder node. Here
// we make the necessary change to make it a folder shortcut.
resultNode->mItemId = itemId;
resultNode->mBookmarkGuid = aBookmarkGuid;
resultNode->GetAsFolder()->mTargetFolderGuid = targetFolderGuid;
// Use the query item title, unless it's empty (in that case use the
// concrete folder title).
if (!aTitle.IsEmpty()) {
resultNode->mTitle = aTitle;
}
}
if (!aTargetFolderGuid.IsEmpty()) {
MOZ_ASSERT(aTargetFolderItemId >= 0);
resultNode = new nsNavHistoryFolderResultNode(
aItemId, aBookmarkGuid, aTargetFolderItemId, aTargetFolderGuid,
!aTitle.IsEmpty() ? aTitle : aTargetFolderTitle, optionsObj);
} else {
// This is a regular query.
resultNode = new nsNavHistoryQueryResultNode(aTitle, aTime, aURI,
resultNode = new nsNavHistoryQueryResultNode(aTitle, aTime, aQueryURI,
queryObj, optionsObj);
resultNode->mItemId = itemId;
resultNode->mItemId = aItemId;
resultNode->mBookmarkGuid = aBookmarkGuid;
}
}
@ -2589,9 +2686,9 @@ nsresult nsNavHistory::QueryRowToResult(int64_t itemId,
// This is a broken query, that either did not parse or points to not
// existing data. We don't want to return failure since that will kill the
// whole result. Instead make a generic empty query node.
resultNode =
new nsNavHistoryQueryResultNode(aTitle, 0, aURI, queryObj, optionsObj);
resultNode->mItemId = itemId;
resultNode = new nsNavHistoryQueryResultNode(aTitle, 0, aQueryURI, queryObj,
optionsObj);
resultNode->mItemId = aItemId;
resultNode->mBookmarkGuid = aBookmarkGuid;
// This is a perf hack to generate an empty query that skips filtering.
resultNode->GetAsQuery()->Options()->SetExcludeItems(true);
@ -2673,22 +2770,23 @@ namespace {
// A simple bookmarks query will result in a hierarchical tree of
// bookmark items, folders and separators.
//
// Returns the folder ID if it is a simple folder query, 0 if not.
static nsCString GetSimpleBookmarksQueryParent(
// Returns the folder ID as Maybe<nsCString> if it is a simple folder
// query, Nothing() if not.
static Maybe<nsCString> GetSimpleBookmarksQueryParent(
const RefPtr<nsNavHistoryQuery>& aQuery,
const RefPtr<nsNavHistoryQueryOptions>& aOptions) {
if (aQuery->Parents().Length() != 1) return ""_ns;
if (aQuery->Parents().Length() != 1) return Nothing();
bool hasIt;
if (NS_SUCCEEDED(aQuery->GetHasBeginTime(&hasIt)) && hasIt) return ""_ns;
if (NS_SUCCEEDED(aQuery->GetHasEndTime(&hasIt)) && hasIt) return ""_ns;
if (!aQuery->Domain().IsVoid()) return ""_ns;
if (aQuery->Uri()) return ""_ns;
if (!aQuery->SearchTerms().IsEmpty()) return ""_ns;
if (aQuery->Tags().Length() > 0) return ""_ns;
if (aOptions->MaxResults() > 0) return ""_ns;
if ((NS_SUCCEEDED(aQuery->GetHasBeginTime(&hasIt)) && hasIt) ||
(NS_SUCCEEDED(aQuery->GetHasEndTime(&hasIt)) && hasIt) ||
!aQuery->Domain().IsVoid() || aQuery->Uri() ||
!aQuery->SearchTerms().IsEmpty() || aQuery->Tags().Length() > 0 ||
aOptions->MaxResults() > 0 || !IsValidGUID(aQuery->Parents()[0])) {
return Nothing();
}
return aQuery->Parents()[0];
return Some(aQuery->Parents()[0]);
}
// ParseSearchTermsFromQuery

View File

@ -184,6 +184,9 @@ class nsNavHistory final : public nsSupportsWeakReference,
static const int32_t kGetInfoIndex_VisitId;
static const int32_t kGetInfoIndex_FromVisitId;
static const int32_t kGetInfoIndex_VisitType;
static const int32_t kGetTargetFolder_Guid;
static const int32_t kGetTargetFolder_ItemId;
static const int32_t kGetTargetFolder_Title;
int64_t GetTagsFolder();
@ -199,8 +202,13 @@ class nsNavHistory final : public nsSupportsWeakReference,
nsresult RowToResult(mozIStorageValueArray* aRow,
nsNavHistoryQueryOptions* aOptions,
nsNavHistoryResultNode** aResult);
nsresult QueryRowToResult(int64_t aItemId, const nsACString& aBookmarkGuid,
const nsACString& aURI, const nsACString& aTitle,
nsresult QueryUriToResult(const nsACString& aQueryURI, int64_t aItemId,
const nsACString& aBookmarkGuid,
const nsACString& aTitle,
int64_t aTargetFolderItemId,
const nsACString& aTargetFolderGuid,
const nsACString& aTargetFolderTitle,
uint32_t aAccessCount, PRTime aTime,
nsNavHistoryResultNode** aNode);
@ -299,6 +307,13 @@ class nsNavHistory final : public nsSupportsWeakReference,
*/
void UpdateDaysOfHistory(PRTime visitTime);
/**
* Get target folder guid from given query URI.
* If the folder guid is not found, returns Nonthing().
*/
static mozilla::Maybe<nsCString> GetTargetFolderGuid(
const nsACString& aQueryURI);
/**
* Store last insterted id for a table.
*/
@ -326,6 +341,10 @@ class nsNavHistory final : public nsSupportsWeakReference,
static void InvalidateDaysOfHistory();
static nsresult TokensToQuery(
const nsTArray<mozilla::places::QueryKeyValuePair>& aTokens,
nsNavHistoryQuery* aQuery, nsNavHistoryQueryOptions* aOptions);
private:
~nsNavHistory();
@ -426,13 +445,7 @@ class nsNavHistory final : public nsSupportsWeakReference,
int32_t mUnvisitedTypedBonus;
int32_t mReloadVisitBonus;
// in nsNavHistoryQuery.cpp
nsresult TokensToQuery(
const nsTArray<mozilla::places::QueryKeyValuePair>& aTokens,
nsNavHistoryQuery* aQuery, nsNavHistoryQueryOptions* aOptions);
int64_t mTagsFolder;
int64_t mLastCachedStartOfDay;
int64_t mLastCachedEndOfDay;
};
@ -440,7 +453,7 @@ class nsNavHistory final : public nsSupportsWeakReference,
#define PLACES_URI_PREFIX "place:"
/* Returns true if the given URI represents a history query. */
inline bool IsQueryURI(const nsCString& uri) {
inline static bool IsQueryURI(const nsACString& uri) {
return StringBeginsWith(uri, nsLiteralCString(PLACES_URI_PREFIX));
}

View File

@ -126,25 +126,7 @@ NS_IMETHODIMP
nsNavHistory::QueryStringToQuery(const nsACString& aQueryString,
nsINavHistoryQuery** _query,
nsINavHistoryQueryOptions** _options) {
NS_ENSURE_ARG_POINTER(_query);
NS_ENSURE_ARG_POINTER(_options);
nsTArray<QueryKeyValuePair> tokens;
nsresult rv = TokenizeQueryString(aQueryString, &tokens);
NS_ENSURE_SUCCESS(rv, rv);
RefPtr<nsNavHistoryQueryOptions> options = new nsNavHistoryQueryOptions();
RefPtr<nsNavHistoryQuery> query = new nsNavHistoryQuery();
rv = TokensToQuery(tokens, query, options);
MOZ_ASSERT(NS_SUCCEEDED(rv), "The query string should be valid");
if (NS_FAILED(rv)) {
NS_WARNING("Unable to parse the query string: ");
NS_WARNING(PromiseFlatCString(aQueryString).get());
}
options.forget(_options);
query.forget(_query);
return NS_OK;
return nsNavHistoryQuery::QueryStringToQuery(aQueryString, _query, _options);
}
NS_IMETHODIMP
@ -339,6 +321,7 @@ nsNavHistory::QueryToQueryString(nsINavHistoryQuery* aQuery,
return NS_OK;
}
/* static */
nsresult nsNavHistory::TokensToQuery(const nsTArray<QueryKeyValuePair>& aTokens,
nsNavHistoryQuery* aQuery,
nsNavHistoryQueryOptions* aOptions) {
@ -859,6 +842,31 @@ nsresult nsNavHistoryQuery::Clone(nsNavHistoryQuery** _clone) {
return NS_OK;
}
/* static */
nsresult nsNavHistoryQuery::QueryStringToQuery(
const nsACString& aQueryString, nsINavHistoryQuery** _query,
nsINavHistoryQueryOptions** _options) {
NS_ENSURE_ARG_POINTER(_query);
NS_ENSURE_ARG_POINTER(_options);
nsTArray<QueryKeyValuePair> tokens;
nsresult rv = TokenizeQueryString(aQueryString, &tokens);
NS_ENSURE_SUCCESS(rv, rv);
RefPtr<nsNavHistoryQueryOptions> options = new nsNavHistoryQueryOptions();
RefPtr<nsNavHistoryQuery> query = new nsNavHistoryQuery();
rv = nsNavHistory::TokensToQuery(tokens, query, options);
MOZ_ASSERT(NS_SUCCEEDED(rv), "The query string should be valid");
if (NS_FAILED(rv)) {
NS_WARNING("Unable to parse the query string: ");
NS_WARNING(PromiseFlatCString(aQueryString).get());
}
options.forget(_options);
query.forget(_query);
return NS_OK;
}
// nsNavHistoryQueryOptions
NS_IMPL_ISUPPORTS(nsNavHistoryQueryOptions, nsNavHistoryQueryOptions,
nsINavHistoryQueryOptions)

View File

@ -55,6 +55,10 @@ class nsNavHistoryQuery final : public nsINavHistoryQuery {
nsresult Clone(nsNavHistoryQuery** _clone);
static nsresult QueryStringToQuery(const nsACString& aQueryString,
nsINavHistoryQuery** _query,
nsINavHistoryQueryOptions** _options);
private:
~nsNavHistoryQuery() = default;

View File

@ -2660,16 +2660,19 @@ NS_IMPL_ISUPPORTS_INHERITED(nsNavHistoryFolderResultNode,
mozIStorageStatementCallback)
nsNavHistoryFolderResultNode::nsNavHistoryFolderResultNode(
const nsACString& aTitle, nsNavHistoryQueryOptions* aOptions,
int64_t aFolderId)
int64_t aItemId, const nsACString& aBookmarkGuid,
int64_t aTargetFolderItemId, const nsACString& aTargetFolderGuid,
const nsACString& aTitle, nsNavHistoryQueryOptions* aOptions)
: nsNavHistoryContainerResultNode(
""_ns, aTitle, 0, nsNavHistoryResultNode::RESULT_TYPE_FOLDER,
aOptions),
mContentsValid(false),
mTargetFolderItemId(aFolderId),
mTargetFolderItemId(aTargetFolderItemId),
mTargetFolderGuid(aTargetFolderGuid),
mIsRegisteredFolderObserver(false),
mAsyncBookmarkIndex(-1) {
mItemId = aFolderId;
mItemId = aItemId;
mBookmarkGuid = aBookmarkGuid;
}
nsNavHistoryFolderResultNode::~nsNavHistoryFolderResultNode() {
@ -3084,7 +3087,8 @@ nsresult nsNavHistoryFolderResultNode::OnItemAdded(
nsIURI* aURI, PRTime aDateAdded, const nsACString& aGUID,
const nsACString& aParentGUID, uint16_t aSource, const nsACString& aTitle,
const nsAString& aTags, int64_t aFrecency, bool aHidden,
uint32_t aVisitCount, PRTime aLastVisitDate) {
uint32_t aVisitCount, PRTime aLastVisitDate, int64_t aTargetFolderItemId,
const nsACString& aTargetFolderGuid, const nsACString& aTargetFolderTitle) {
MOZ_ASSERT(aParentFolder == mTargetFolderItemId, "Got wrong bookmark update");
RESTART_AND_RETURN_IF_ASYNC_PENDING();
@ -3150,9 +3154,10 @@ nsresult nsNavHistoryFolderResultNode::OnItemAdded(
if (isQuery) {
nsNavHistory* history = nsNavHistory::GetHistoryService();
NS_ENSURE_TRUE(history, NS_ERROR_OUT_OF_MEMORY);
rv = history->QueryRowToResult(aItemId, aGUID, itemURISpec, aTitle,
aVisitCount, aLastVisitDate,
getter_AddRefs(node));
rv = history->QueryUriToResult(itemURISpec, aItemId, aGUID, aTitle,
aTargetFolderItemId, aTargetFolderGuid,
aTargetFolderTitle, aVisitCount,
aLastVisitDate, getter_AddRefs(node));
NS_ENSURE_SUCCESS(rv, rv);
} else {
node = new nsNavHistoryResultNode(itemURISpec, aTitle, aVisitCount,
@ -3167,12 +3172,10 @@ nsresult nsNavHistoryFolderResultNode::OnItemAdded(
node->mFrecency = aFrecency;
node->mHidden = aHidden;
} else if (aItemType == nsINavBookmarksService::TYPE_FOLDER) {
nsNavBookmarks* bookmarks = nsNavBookmarks::GetBookmarksService();
NS_ENSURE_TRUE(bookmarks, NS_ERROR_OUT_OF_MEMORY);
rv = bookmarks->ResultNodeForContainer(PromiseFlatCString(aGUID),
new nsNavHistoryQueryOptions(),
getter_AddRefs(node));
NS_ENSURE_SUCCESS(rv, rv);
node = new nsNavHistoryFolderResultNode(
aItemId, aGUID, aItemId, aGUID, aTitle, new nsNavHistoryQueryOptions());
node->mDateAdded = aDateAdded;
node->mLastModified = aDateAdded;
} else if (aItemType == nsINavBookmarksService::TYPE_SEPARATOR) {
node = new nsNavHistorySeparatorResultNode();
node->mItemId = aItemId;
@ -3544,7 +3547,8 @@ nsresult nsNavHistoryFolderResultNode::OnItemMoved(
aItemId, mTargetFolderItemId, aNewIndex, aItemType, itemURI,
RoundedPRNow(), // This is a dummy dateAdded, not the real value.
aGUID, aNewParentGUID, aSource, aTitle, aTags, aFrecency, aHidden,
aVisitCount, aLastVisitDate);
aVisitCount, aLastVisitDate, mTargetFolderItemId, mTargetFolderGuid,
aTitle);
}
return NS_OK;
@ -4276,7 +4280,9 @@ void nsNavHistoryResult::HandlePlacesEvent(const PlacesEventSequence& aEvents) {
item->mFrecency, item->mHidden, item->mVisitCount,
item->mLastVisitDate.IsNull()
? 0
: item->mLastVisitDate.Value() * 1000));
: item->mLastVisitDate.Value() * 1000,
item->mTargetFolderItemId, item->mTargetFolderGuid,
NS_ConvertUTF16toUTF8(item->mTargetFolderTitle)));
ENUMERATE_HISTORY_OBSERVERS(
OnItemAdded(item->mId, item->mParentId, item->mIndex,
item->mItemType, uri, item->mDateAdded * 1000,

View File

@ -765,9 +765,11 @@ class nsNavHistoryFolderResultNode final
public nsINavHistoryQueryResultNode,
public mozilla::places::WeakAsyncStatementCallback {
public:
nsNavHistoryFolderResultNode(const nsACString& aTitle,
nsNavHistoryQueryOptions* options,
int64_t aFolderId);
nsNavHistoryFolderResultNode(int64_t aItemId, const nsACString& aBookmarkGuid,
int64_t aTargetFolderItemId,
const nsACString& aTargetFolderGuid,
const nsACString& aTitle,
nsNavHistoryQueryOptions* aOptions);
NS_DECL_ISUPPORTS_INHERITED
NS_FORWARD_COMMON_RESULTNODE_TO_BASE
@ -794,7 +796,10 @@ class nsNavHistoryFolderResultNode final
const nsACString& aGUID, const nsACString& aParentGUID,
uint16_t aSource, const nsACString& aTitle,
const nsAString& aTags, int64_t aFrecency, bool aHidden,
uint32_t aVisitCount, PRTime aLastVisitDate);
uint32_t aVisitCount, PRTime aLastVisitDate,
int64_t aTargetFolderItemId,
const nsACString& aTargetFolderGuid,
const nsACString& aTargetFolderTitle);
nsresult OnItemRemoved(int64_t aItemId, int64_t aParentFolder, int32_t aIndex,
uint16_t aItemType, nsIURI* aURI,
const nsACString& aGUID, const nsACString& aParentGUID,

View File

@ -121,6 +121,9 @@ function notifyPlacesEvent(guid) {
hidden: false,
visitCount: 0,
lastVisitDate: 0,
targetFolderGuid: null,
targetFolderItemId: -1,
targetFolderTitle: null,
}),
]);
}