tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

NavigationHistoryEntry.h (2142B)


      1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=2 sts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef mozilla_dom_NavigationHistoryEntry_h___
      8 #define mozilla_dom_NavigationHistoryEntry_h___
      9 
     10 #include "mozilla/DOMEventTargetHelper.h"
     11 
     12 class nsIGlobalObject;
     13 class nsIStructuredCloneContainer;
     14 
     15 namespace mozilla::dom {
     16 
     17 class SessionHistoryInfo;
     18 
     19 // https://html.spec.whatwg.org/#navigationhistoryentry
     20 class NavigationHistoryEntry final : public DOMEventTargetHelper {
     21 public:
     22  NS_DECL_ISUPPORTS_INHERITED
     23  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(NavigationHistoryEntry,
     24                                           DOMEventTargetHelper)
     25 
     26  NavigationHistoryEntry(nsIGlobalObject* aGlobal,
     27                         const SessionHistoryInfo* aSHInfo, int64_t aIndex);
     28 
     29  void GetUrl(nsAString& aResult) const;
     30  void GetKey(nsAString& aResult) const;
     31  void GetId(nsAString& aResult) const;
     32  int64_t Index() const;
     33  bool SameDocument() const;
     34 
     35  void GetState(JSContext* aCx, JS::MutableHandle<JS::Value> aResult,
     36                ErrorResult& aRv) const;
     37 
     38  IMPL_EVENT_HANDLER(dispose);
     39 
     40  JSObject* WrapObject(JSContext* aCx,
     41                       JS::Handle<JSObject*> aGivenProto) override;
     42 
     43  bool IsSameEntry(const SessionHistoryInfo* aSHInfo) const;
     44 
     45  bool SharesDocumentWith(const SessionHistoryInfo& aSHInfo) const;
     46 
     47  const nsID& Key() const;
     48 
     49  nsIStructuredCloneContainer* GetNavigationAPIState() const;
     50  void SetNavigationAPIState(nsIStructuredCloneContainer* aState);
     51 
     52  class SessionHistoryInfo* SessionHistoryInfo() { return mSHInfo.get(); }
     53 
     54  void ResetIndexForDisposal();
     55 
     56 private:
     57  ~NavigationHistoryEntry();
     58 
     59  Document* GetAssociatedDocument() const;
     60 
     61  bool HasActiveDocument() const;
     62 
     63  // https://html.spec.whatwg.org/#nhe-she
     64  UniquePtr<class SessionHistoryInfo> mSHInfo;
     65  int64_t mIndex;
     66 };
     67 
     68 }  // namespace mozilla::dom
     69 
     70 #endif  // mozilla_dom_NavigationHistoryEntry_h___