Loading dom/base/PlacesBookmarkTitle.h 0 → 100644 +56 −0 Original line number Diff line number Diff line /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ #ifndef mozilla_dom_PlacesBookmarkTitle_h #define mozilla_dom_PlacesBookmarkTitle_h #include "mozilla/dom/PlacesBookmark.h" namespace mozilla { namespace dom { class PlacesBookmarkTitle final : public PlacesBookmark { public: explicit PlacesBookmarkTitle() : PlacesBookmark(PlacesEventType::Bookmark_title_changed) {} static already_AddRefed<PlacesBookmarkTitle> Constructor( const GlobalObject& aGlobal, const PlacesBookmarkTitleInit& aInitDict) { RefPtr<PlacesBookmarkTitle> event = new PlacesBookmarkTitle(); event->mId = aInitDict.mId; event->mItemType = aInitDict.mItemType; event->mUrl = aInitDict.mUrl; event->mGuid = aInitDict.mGuid; event->mParentGuid = aInitDict.mParentGuid; event->mTitle = aInitDict.mTitle; event->mLastModified = aInitDict.mLastModified; event->mSource = aInitDict.mSource; event->mIsTagging = aInitDict.mIsTagging; return event.forget(); } JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override { return PlacesBookmarkTitle_Binding::Wrap(aCx, this, aGivenProto); } const PlacesBookmarkTitle* AsPlacesBookmarkTitle() const override { return this; } void GetTitle(nsString& aTitle) const { aTitle = mTitle; } uint64_t LastModified() { return mLastModified; } nsString mTitle; uint64_t mLastModified; private: ~PlacesBookmarkTitle() = default; }; } // namespace dom } // namespace mozilla #endif dom/base/PlacesEvent.h +3 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,9 @@ class PlacesEvent : public nsWrapperCache { virtual const PlacesBookmarkMoved* AsPlacesBookmarkMoved() const { return nullptr; } virtual const PlacesBookmarkTitle* AsPlacesBookmarkTitle() const { return nullptr; } virtual const PlacesFavicon* AsPlacesFavicon() const { return nullptr; } virtual const PlacesVisitTitle* AsPlacesVisitTitle() const { return nullptr; } virtual const PlacesHistoryCleared* AsPlacesHistoryCleared() const { Loading dom/base/moz.build +1 −0 Original line number Diff line number Diff line Loading @@ -224,6 +224,7 @@ EXPORTS.mozilla.dom += [ "PlacesBookmarkAddition.h", "PlacesBookmarkMoved.h", "PlacesBookmarkRemoved.h", "PlacesBookmarkTitle.h", "PlacesEvent.h", "PlacesFavicon.h", "PlacesHistoryCleared.h", Loading dom/chrome-webidl/PlacesEvent.webidl +31 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,10 @@ enum PlacesEventType { * (or a bookmark folder/separator) is moved. */ "bookmark-moved", /** * data: PlacesBookmarkTitle. Fired whenever a bookmark title changes. */ "bookmark-title-changed", /** * data: PlacesFavicon. Fired whenever a favicon changes. */ Loading Loading @@ -258,6 +262,33 @@ interface PlacesBookmarkMoved : PlacesBookmark { readonly attribute long oldIndex; }; dictionary PlacesBookmarkTitleInit { required long long id; required unsigned short itemType; DOMString? url = null; required ByteString guid; required ByteString parentGuid; required DOMString title; required long long lastModified; required unsigned short source; required boolean isTagging; }; [ChromeOnly, Exposed=Window] interface PlacesBookmarkTitle : PlacesBookmark { constructor(PlacesBookmarkTitleInit initDict); /** * The title of the changed bookmark. */ readonly attribute DOMString title; /** * The updated last modified value in milliseconds. */ readonly attribute long long lastModified; }; dictionary PlacesFaviconInit { required DOMString url; required ByteString pageGuid; Loading toolkit/components/places/Bookmarks.jsm +22 −0 Original line number Diff line number Diff line Loading @@ -896,6 +896,13 @@ var Bookmarks = Object.freeze({ } if (updateInfo.hasOwnProperty("title")) { let isTagging = updatedItem.parentGuid == Bookmarks.tagsGuid; if (!isTagging) { if (!parent) { parent = await fetchBookmark({ guid: updatedItem.parentGuid }); } isTagging = parent.parentGuid === Bookmarks.tagsGuid; } notify( observers, "onItemChanged", Loading @@ -914,6 +921,21 @@ var Bookmarks = Object.freeze({ ], { isTagging } ); notifications.push( new PlacesBookmarkTitle({ id: updatedItem._id, itemType: updatedItem.type, url: updatedItem.url?.href, guid: updatedItem.guid, parentGuid: updatedItem.parentGuid, title: updatedItem.title, lastModified: updatedItem.lastModified, source: updatedItem.source, isTagging, }) ); // If we're updating a tag, we must notify all the tagged bookmarks // about the change. if (isTagging) { Loading Loading
dom/base/PlacesBookmarkTitle.h 0 → 100644 +56 −0 Original line number Diff line number Diff line /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file, * You can obtain one at http://mozilla.org/MPL/2.0/. */ #ifndef mozilla_dom_PlacesBookmarkTitle_h #define mozilla_dom_PlacesBookmarkTitle_h #include "mozilla/dom/PlacesBookmark.h" namespace mozilla { namespace dom { class PlacesBookmarkTitle final : public PlacesBookmark { public: explicit PlacesBookmarkTitle() : PlacesBookmark(PlacesEventType::Bookmark_title_changed) {} static already_AddRefed<PlacesBookmarkTitle> Constructor( const GlobalObject& aGlobal, const PlacesBookmarkTitleInit& aInitDict) { RefPtr<PlacesBookmarkTitle> event = new PlacesBookmarkTitle(); event->mId = aInitDict.mId; event->mItemType = aInitDict.mItemType; event->mUrl = aInitDict.mUrl; event->mGuid = aInitDict.mGuid; event->mParentGuid = aInitDict.mParentGuid; event->mTitle = aInitDict.mTitle; event->mLastModified = aInitDict.mLastModified; event->mSource = aInitDict.mSource; event->mIsTagging = aInitDict.mIsTagging; return event.forget(); } JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override { return PlacesBookmarkTitle_Binding::Wrap(aCx, this, aGivenProto); } const PlacesBookmarkTitle* AsPlacesBookmarkTitle() const override { return this; } void GetTitle(nsString& aTitle) const { aTitle = mTitle; } uint64_t LastModified() { return mLastModified; } nsString mTitle; uint64_t mLastModified; private: ~PlacesBookmarkTitle() = default; }; } // namespace dom } // namespace mozilla #endif
dom/base/PlacesEvent.h +3 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,9 @@ class PlacesEvent : public nsWrapperCache { virtual const PlacesBookmarkMoved* AsPlacesBookmarkMoved() const { return nullptr; } virtual const PlacesBookmarkTitle* AsPlacesBookmarkTitle() const { return nullptr; } virtual const PlacesFavicon* AsPlacesFavicon() const { return nullptr; } virtual const PlacesVisitTitle* AsPlacesVisitTitle() const { return nullptr; } virtual const PlacesHistoryCleared* AsPlacesHistoryCleared() const { Loading
dom/base/moz.build +1 −0 Original line number Diff line number Diff line Loading @@ -224,6 +224,7 @@ EXPORTS.mozilla.dom += [ "PlacesBookmarkAddition.h", "PlacesBookmarkMoved.h", "PlacesBookmarkRemoved.h", "PlacesBookmarkTitle.h", "PlacesEvent.h", "PlacesFavicon.h", "PlacesHistoryCleared.h", Loading
dom/chrome-webidl/PlacesEvent.webidl +31 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,10 @@ enum PlacesEventType { * (or a bookmark folder/separator) is moved. */ "bookmark-moved", /** * data: PlacesBookmarkTitle. Fired whenever a bookmark title changes. */ "bookmark-title-changed", /** * data: PlacesFavicon. Fired whenever a favicon changes. */ Loading Loading @@ -258,6 +262,33 @@ interface PlacesBookmarkMoved : PlacesBookmark { readonly attribute long oldIndex; }; dictionary PlacesBookmarkTitleInit { required long long id; required unsigned short itemType; DOMString? url = null; required ByteString guid; required ByteString parentGuid; required DOMString title; required long long lastModified; required unsigned short source; required boolean isTagging; }; [ChromeOnly, Exposed=Window] interface PlacesBookmarkTitle : PlacesBookmark { constructor(PlacesBookmarkTitleInit initDict); /** * The title of the changed bookmark. */ readonly attribute DOMString title; /** * The updated last modified value in milliseconds. */ readonly attribute long long lastModified; }; dictionary PlacesFaviconInit { required DOMString url; required ByteString pageGuid; Loading
toolkit/components/places/Bookmarks.jsm +22 −0 Original line number Diff line number Diff line Loading @@ -896,6 +896,13 @@ var Bookmarks = Object.freeze({ } if (updateInfo.hasOwnProperty("title")) { let isTagging = updatedItem.parentGuid == Bookmarks.tagsGuid; if (!isTagging) { if (!parent) { parent = await fetchBookmark({ guid: updatedItem.parentGuid }); } isTagging = parent.parentGuid === Bookmarks.tagsGuid; } notify( observers, "onItemChanged", Loading @@ -914,6 +921,21 @@ var Bookmarks = Object.freeze({ ], { isTagging } ); notifications.push( new PlacesBookmarkTitle({ id: updatedItem._id, itemType: updatedItem.type, url: updatedItem.url?.href, guid: updatedItem.guid, parentGuid: updatedItem.parentGuid, title: updatedItem.title, lastModified: updatedItem.lastModified, source: updatedItem.source, isTagging, }) ); // If we're updating a tag, we must notify all the tagged bookmarks // about the change. if (isTagging) { Loading