nsILayoutHistoryState.idl (3604B)
1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6 /* 7 * interface for container for information saved in session history when 8 * the document is not 9 */ 10 11 #include "nsISupports.idl" 12 13 14 [ptr] native PresStatePtr(mozilla::PresState); 15 native PresStateUnique(mozilla::UniquePtr<mozilla::PresState>); 16 native PresState(mozilla::PresState); 17 [ref] native nsCString(const nsCString); 18 native constBool(const bool); 19 20 %{C++ 21 #include "nsStringFwd.h" 22 #include "mozilla/UniquePtr.h" 23 24 namespace mozilla { 25 class PresState; 26 } // namespace mozilla 27 28 template<typename> struct already_AddRefed; 29 %} 30 31 [scriptable, builtinclass, uuid(aef27cb3-4df9-4eeb-b0b0-ac56cf861d04)] 32 interface nsILayoutHistoryState : nsISupports 33 { 34 /** 35 * Whether this LayoutHistoryState contains any PresStates. 36 */ 37 readonly attribute boolean hasStates; 38 39 /** 40 * Get the keys of all PresStates held by this LayoutHistoryState. 41 * Note: Check hasStates first. 42 */ 43 Array<ACString> getKeys(); 44 45 /* 46 * Attempts to get the data of the PresState corresponding to 47 * the passed key. Throws if no data could be found. 48 */ 49 void getPresState(in ACString aKey, 50 out float aScrollX, out float aScrollY, 51 out boolean aAllowScrollOriginDowngrade, 52 out float aRes); 53 54 /** 55 * Constructs a new PresState object based on the supplied data 56 * and adds it to the LayoutHistoryState. 57 */ 58 void addNewPresState(in ACString aKey, 59 in float aScrollX, in float aScrollY, 60 in boolean aAllowScrollOriginDowngrade, 61 in float aRes); 62 63 // Native only interface, converted from the original nsILayoutHistoryState.h 64 65 /** 66 * Set |aState| as the state object for |aKey|. 67 * This _transfers_ownership_ of |aState| to the LayoutHistoryState. 68 * It will be freed when RemoveState() is called or when the 69 * LayoutHistoryState is destroyed. 70 */ 71 [noscript, notxpcom, nostdcall] void AddState(in nsCString aKey, in PresStateUnique aState); 72 73 /** 74 * Look up the state object for |aKey|. 75 */ 76 [noscript, notxpcom, nostdcall] PresStatePtr GetState(in nsCString aKey); 77 78 /** 79 * Remove the state object for |aKey|. 80 */ 81 [noscript, notxpcom, nostdcall] void RemoveState(in nsCString aKey); 82 83 /** 84 * Check whether this history has any states in it 85 */ 86 [noscript, notxpcom, nostdcall] boolean HasStates(); 87 88 /** 89 * Sets whether this history can contain only scroll position history 90 * or all possible history 91 */ 92 [noscript, notxpcom, nostdcall] void SetScrollPositionOnly(in constBool aFlag); 93 94 /** 95 * Resets PresState::GetScrollState of all PresState objects to 0,0. 96 */ 97 [noscript, notxpcom, nostdcall] void ResetScrollState(); 98 99 /** 100 * Get the contents of the layout history. 101 */ 102 [noscript, notxpcom, nostdcall] void GetContents(out boolean aScrollPositionOnly, 103 out Array<ACString> aKeys, 104 out Array<PresState> aStates); 105 106 /** 107 * Remove all the states and clear the scroll position only flag. 108 */ 109 [noscript, notxpcom, nostdcall] void Reset(); 110 }; 111 112 %{C++ 113 /* Defined in nsLayoutHistoryState.cpp */ 114 already_AddRefed<nsILayoutHistoryState> 115 NS_NewLayoutHistoryState(); 116 117 namespace mozilla { 118 mozilla::UniquePtr<mozilla::PresState> NewPresState(); 119 } // namespace mozilla 120 %}