nsISHEntry 编辑

docshell/shistory/public/nsISHEntry.idlScriptable Each document or subframe in Session History will have a nsISHEntry associated with it which will hold all information required to recreate the document from history. Inherits from: nsIHistoryEntry Last changed in Gecko 6.0 (Firefox 6.0 / Thunderbird 6.0 / SeaMonkey 2.3)

Implemented by: @mozilla.org/browser/session-history-entry;1. To create an instance, use:

var shentry = Components.classes["@mozilla.org/browser/session-history-entry;1"]
                        .createInstance(Components.interfaces.nsISHEntry);

Method overview

void addChildShell(in nsIDocShellTreeItem shell);
nsIDocShellTreeItem childShellAt(in long index);
void clearChildShells();
nsISHEntry clone();
void create(in nsIURI URI, in AString title, in nsIInputStream inputStream, in nsILayoutHistoryState layoutHistoryState, in nsISupports cacheKey, in ACString contentType, in nsISupports owner, in unsigned long long docshellID, in boolean dynamicCreation); Native code only!
nsDocShellEditorDataPtr forgetEditorData(); Violates the XPCOM interface guidelines
nsIContentViewer getAnyContentViewer(out nsISHEntry ownerEntry);
void getScrollPosition(out long x, out long y);
void getViewerBounds(in nsIntRect bounds); Native code only!
boolean hasDetachedEditor(); Violates the XPCOM interface guidelines
boolean hasDynamicallyAddedChild();
boolean isDynamicallyAdded();
void setEditorData(in nsDocShellEditorDataPtr aData); Violates the XPCOM interface guidelines
void setIsSubFrame(in boolean aFlag);
void setScrollPosition(in long x, in long y);
void setTitle(in AString aTitle);
void setUniqueDocIdentifier();
void setURI(in nsIURI aURI);
void setViewerBounds(in nsIntRect bounds); Native code only!
void syncPresentationState();

Attributes

AttributeTypeDescription
cacheKeynsISupportsSet and get the cache key for the entry.
contentTypeACStringIndicates the content-type of the document that this is a session history entry for.
contentViewernsIContentViewerContent viewer, for fast restoration of presentation.
docIdentifierunsigned long longAn integer that should be the same for two entries attached to the same docshell if and only if the two entries are entries for the same document. In practice, two entries A and B will have the same docIdentifier if we arrived at B by clicking an anchor link in A or if B was created by A's calling history.pushState().
docshellIDunsigned long longThe history ID of the docshell.
documentnsIDOMDocumentDOM Document. Obsolete since Gecko 1.8
expirationStatusbooleanIndicates whether the page is already expired in cache.
IDunsigned longAn ID to help identify this entry from others during subframe navigation.
layoutHistoryStatensILayoutHistoryStateLayoutHistoryState for scroll position and form values.
loadTypeunsigned longThe loadType for this entry. This is typically loadHistory except when reload is pressed, it has the appropriate reload flag.
ownernsISupportsGet the owner, if any, that was associated with the channel that the document that was loaded to create this history entry came from.
pageIdentifierunsigned longAn integer that should be the same for two entries attached to the same docshell only if the two entries are entries for the same page in the sense that one could go from the state represented by one to the state represented by the other simply by scrolling (so the entries are separated by an anchor traversal or a subframe navigation in some other frame). Obsolete since Gecko 6.0
parentnsISHEntryParent of this entry.
postDatansIInputStreamPost Data for the document.
referrerURInsIURIReferrer URI.
refreshURIListnsISupportsArraySaved refresh URI list for the content viewer.
saveLayoutStateFlagbooleanIndicate whether layoutHistoryState should be saved.
stateDatansIStructuredCloneContainerGet/set data associated with this history state via a pushState() call, serialized using structured clone. (Prior to Gecko 6.0 returned a JSON encoded string.)
stickybooleanWhether the content viewer is marked "sticky"
windowStatensISupportsSaved state of the global window object.

Methods

addChildShell()

Saved child docshells corresponding to contentViewer. The child shells are restored as children of the parent docshell, in this order, when the parent docshell restores a saved presentation.

Append a child shell to the end of our list.

void addChildShell(
  in nsIDocShellTreeItem shell
);
Parameters
shell

childShellAt()

nsIDocShellTreeItem childShellAt(
  in long index
);
Parameters
index
The child shell at index; null if index is out of bounds.
Return value

 

clearChildShells()

Clear the child shell list.

void clearChildShells();
Parameters

None.

clone()

nsISHEntry clone();
Parameters

None.

Return value

 

Native code only!

create

Additional ways to create an entry.

void create(
  in nsIURI URI,
  in AString title,
  in nsIInputStream inputStream,
  in nsILayoutHistoryState layoutHistoryState,
  in nsISupports cacheKey,
  in ACString contentType,
  in nsISupports owner,
  in unsigned long long docshellID,
  in boolean dynamicCreation
);
Parameters
URI
title
inputStream
layoutHistoryState
cacheKey
contentType
owner
docshellID
dynamicCreation
Violates the XPCOM interface guidelines

forgetEditorData()

Gets the owning pointer to the editor data assosicated with this shistory entry. This forgets its pointer, so free it when you're done.

nsDocShellEditorDataPtr forgetEditorData();
Parameters

None.

Return value

 

getAnyContentViewer()

Return any content viewer present in or below this node in the nsSHEntry tree. This will differ from contentViewer in the case where a child nsSHEntry has the content viewer for this tree.

nsIContentViewer getAnyContentViewer(
  out nsISHEntry ownerEntry
);
Parameters
ownerEntry
Return value

 

getScrollPosition()

void getScrollPosition(
  out long x,
  out long y
);
Parameters
x
y
Native code only!

getViewerBounds

Saved position and dimensions of the content viewer; we must adjust the root view's widget accordingly if this has changed when the presentation is restored.

void getViewerBounds(
  in nsIntRect bounds
);
Parameters
bounds
Violates the XPCOM interface guidelines

hasDetachedEditor()

boolean hasDetachedEditor();
Parameters

None.

Return value

true if this shistory entry is storing a detached editor.

hasDynamicallyAddedChild()

boolean hasDynamicallyAddedChild();
Parameters

None.

Return value

true if any of the child entries returns true when isDynamicallyAdded() is called on it.

isDynamicallyAdded()

Returns true if the related docshell was added because of dynamic addition of an iframe/frame.

boolean isDynamicallyAdded();
Parameters

None.

Return value

 

Violates the XPCOM interface guidelines

setEditorData()

Sets the owning pointer to the editor data assosicated with this shistory entry. Unless forgetEditorData() is called, this shentry will destroy the editor data when it is destroyed.

void setEditorData(
  in nsDocShellEditorDataPtr aData
);
Parameters
aData

setIsSubFrame()

Attribute that indicates if this entry is for a subframe navigation.

void setIsSubFrame(
  in boolean aFlag
);
Parameters
aFlag

setScrollPosition()

Set/Get scrollers' positon in anchored pages.

void setScrollPosition(
  in long x,
  in long y
);
Parameters
x
y

setTitle()

Title for the document.

void setTitle(
  in AString aTitle
);
Parameters
aTitle

setUniqueDocIdentifier()

Changes this entry's doc identifier to a new value which is unique among those of all other entries.

void setUniqueDocIdentifier();
Parameters

None.

setURI()

URI for the document.

void setURI(
  in nsIURI aURI
);
Parameters
aURI
Native code only!

setViewerBounds

void setViewerBounds(
  in nsIntRect bounds
);
Parameters
bounds

syncPresentationState()

Ensure that the cached presentation members are self-consistent. If either contentViewer or windowState are null, then all of the following members are cleared/reset: contentViewer, sticky, windowState, viewerBounds, childShells, refreshURIList.

void syncPresentationState();
Parameters

None.

Example

see nsSessionStore.js for a real example.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:40 次

字数:18194

最后编辑:6 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文