1 /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
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/. */
7 #include
"domstubs.idl"
8 #include
"nsIDocShellTreeItem.idl"
9 #include
"nsIRequest.idl"
12 #include
"js/TypeDecls.h"
13 #include
"mozilla/Maybe.h"
14 #include
"mozilla/NotNull.h"
15 #include
"mozilla/UniquePtr.h"
18 class nsCommandManager
;
20 class nsDocShellLoadState
;
26 class BrowsingContext
;
33 * The nsIDocShell interface.
36 [ptr] native nsPresContext
(nsPresContext
);
37 [ptr] native nsCommandManager
(nsCommandManager
);
38 [ptr] native PresShell
(mozilla
::PresShell
);
39 [ref] native MaybeURI
(mozilla
::Maybe<nsCOMPtr
<nsIURI
>>);
40 [ref] native Encoding
(const mozilla
::Encoding
*);
41 native UniqueClientSource
(mozilla
::UniquePtr
<mozilla
::dom
::ClientSource
>);
45 interface nsIContentViewer
;
46 interface nsIContentSecurityPolicy
;
48 interface nsIEditingSession
;
49 interface nsIInputStream
;
52 interface nsILayoutHistoryState
;
53 interface nsISecureBrowserUI
;
54 interface nsIScriptGlobalObject
;
55 interface nsIStructuredCloneContainer
;
56 interface nsIDOMStorage
;
57 interface nsIPrincipal
;
58 interface nsIPrivacyTransitionObserver
;
59 interface nsIReflowObserver
;
60 interface nsIScrollObserver
;
61 interface nsIRemoteTab
;
62 interface nsIBrowserChild
;
63 interface nsICommandParams
;
64 interface nsILoadURIDelegate
;
65 native BrowserChildRef
(already_AddRefed
<nsIBrowserChild
>);
66 native nsDocShellLoadStatePtr
(nsDocShellLoadState
*);
68 webidl BrowsingContext
;
69 webidl ContentFrameMessageManager
;
73 [scriptable
, builtinclass
, uuid(049234fe
-da10
-478b
-bc5d
-bc6f9a1ba63d
)]
74 interface nsIDocShell
: nsIDocShellTreeItem
76 void setCancelContentJSEpoch
(in long aEpoch
);
79 * Loads a given URI. This will give priority to loading the requested URI
80 * in the object implementing this interface. If it can't be loaded here
81 * however, the URL dispatcher will go through its normal process of content
84 * @param aLoadState This is the extended load info for this load.
85 * @param aSetNavigating If we should set isNavigating to true while initiating
88 [noscript
]void loadURI
(in nsDocShellLoadStatePtr aLoadState
, in boolean aSetNavigating
);
91 * Do either a history.pushState() or history.replaceState() operation,
92 * depending on the value of aReplace.
95 void addState
(in jsval aData
, in AString aTitle
,
96 in AString aURL
, in boolean aReplace
);
99 * Reset state to a new content model within the current document and the document
100 * viewer. Called by the document before initiating an out of band document.write().
102 void prepareForNewContentModel
();
105 * Helper for the session store to change the URI associated with the
108 void setCurrentURIForSessionStore
(in nsIURI aURI
);
111 * Notify the associated content viewer and all child docshells that they are
112 * about to be hidden. If |isUnload| is true, then the document is being
113 * unloaded and all dynamic subframe history entries are removed as well.
116 * True to fire the unload event in addition to the pagehide event,
117 * and remove all dynamic subframe history entries.
119 [noscript
] void firePageHideNotification
(in boolean isUnload
);
122 * Presentation context for the currently loaded document. This may be null.
124 [notxpcom
,nostdcall
] readonly attribute nsPresContext presContext
;
127 * Presentation shell for the currently loaded document. This may be null.
129 [notxpcom
,nostdcall
] readonly attribute PresShell presShell
;
132 * Presentation shell for the oldest document, if this docshell is
133 * currently transitioning between documents.
135 [notxpcom
,nostdcall
] readonly attribute PresShell eldestPresShell
;
138 * Content Viewer that is currently loaded for this DocShell. This may
139 * change as the underlying content changes.
141 [infallible
] readonly attribute nsIContentViewer contentViewer
;
144 * Get the id of the outer window that is or will be in this docshell.
146 [infallible
] readonly attribute
unsigned long long outerWindowID
;
149 * This attribute allows chrome to tie in to handle DOM events that may
150 * be of interest to chrome.
152 attribute EventTarget chromeEventHandler
;
155 * This allows chrome to set a custom User agent on a specific docshell
157 attribute AString customUserAgent
;
160 * Whether CSS error reporting is enabled.
162 attribute
boolean cssErrorReportingEnabled
;
165 * Whether to allow plugin execution
167 attribute
boolean allowPlugins
;
170 * Attribute stating if refresh based redirects can be allowed
172 attribute
boolean allowMetaRedirects
;
175 * Attribute stating if it should allow subframes (framesets/iframes) or not
177 attribute
boolean allowSubframes
;
180 * Attribute stating whether or not images should be loaded.
182 attribute
boolean allowImages
;
185 * Attribute stating whether or not media (audio/video) should be loaded.
187 [infallible
] attribute
boolean allowMedia
;
190 * Attribute that determines whether DNS prefetch is allowed for this subtree
191 * of the docshell tree. Defaults to true. Setting this will make it take
192 * effect starting with the next document loaded in the docshell.
194 attribute
boolean allowDNSPrefetch
;
197 * Attribute that determines whether window control (move/resize) is allowed.
199 attribute
boolean allowWindowControl
;
202 * True if the docshell allows its content to be handled by a content listener
203 * other than the docshell itself, including the external helper app service,
204 * and false otherwise. Defaults to true.
206 [infallible
] attribute
boolean allowContentRetargeting
;
209 * True if new child docshells should allow content retargeting.
210 * Setting allowContentRetargeting also overwrites this value.
212 [infallible
] attribute
boolean allowContentRetargetingOnChildren
;
215 * Get an array of this docShell and its children.
217 * @param aItemType - Only include docShells of this type, or if typeAll,
218 * include all child shells.
219 * Uses types from nsIDocShellTreeItem.
220 * @param aDirection - Whether to enumerate forwards or backwards.
223 cenum DocShellEnumeratorDirection
: 8 {
224 ENUMERATE_FORWARDS
= 0,
225 ENUMERATE_BACKWARDS
= 1
228 Array
<nsIDocShell
> getAllDocShellsInSubtree
(in long aItemType
,
229 in nsIDocShell_DocShellEnumeratorDirection aDirection
);
232 * The type of application that created this window.
234 * DO NOT DELETE, see bug 176166. For firefox, this value will always be
235 * UNKNOWN. However, it is used heavily in Thunderbird/comm-central and we
236 * don't really have a great replacement at the moment, so we'll just leave it
240 APP_TYPE_UNKNOWN
= 0,
245 [infallible
] attribute nsIDocShell_AppType appType
;
248 * certain docshells (like the message pane)
249 * should not throw up auth dialogs
250 * because it can act as a password trojan
252 attribute
boolean allowAuth
;
255 * Set/Get the document scale factor. When setting this attribute, a
256 * NS_ERROR_NOT_IMPLEMENTED error may be returned by implementations
257 * not supporting zoom. Implementations not supporting zoom should return
258 * 1.0 all the time for the Get operation. 1.0 by the way is the default
259 * of zoom. This means 100% of normal scaling or in other words normal size
262 attribute
float zoom
;
265 * Tells the docshell to offer focus to its tree owner.
266 * This is currently only necessary for embedding chrome.
267 * If forDocumentNavigation is true, then document navigation should be
268 * performed, where only the root of documents are selected. Otherwise, the
269 * next element in the parent should be returned. Returns true if focus was
270 * successfully taken by the tree owner.
272 bool tabToTreeOwner
(in boolean forward
, in boolean forDocumentNavigation
);
275 * Current busy state for DocShell
277 cenum BusyFlags
: 8 {
280 BUSY_FLAGS_BEFORE_PAGE_LOAD
= 2,
281 BUSY_FLAGS_PAGE_LOADING
= 4,
284 [infallible
] readonly attribute nsIDocShell_BusyFlags busyFlags
;
287 * Load commands for the document
289 cenum LoadCommand
: 8 {
290 LOAD_CMD_NORMAL
= 0x1, // Normal load
291 LOAD_CMD_RELOAD
= 0x2, // Reload
292 LOAD_CMD_HISTORY
= 0x4, // Load from history
293 LOAD_CMD_PUSHSTATE
= 0x8, // History.pushState()
297 * Attribute to access the loadtype for the document. LoadType Enum is
298 * defined in nsDocShellLoadTypes.h
300 [infallible
] attribute
unsigned long loadType
;
303 * Default load flags (as defined in nsIRequest) that will be set on all
304 * requests made by this docShell and propagated to all child docShells and
305 * to nsILoadGroup::defaultLoadFlags for the docShell's loadGroup.
306 * Default is no flags. Once set, only future requests initiated by the
307 * docShell are affected, so in general, these flags should be set before
308 * the docShell loads any content.
310 attribute nsLoadFlags defaultLoadFlags
;
313 * returns true if the docshell is being destroyed, false otherwise
315 boolean isBeingDestroyed
();
318 * Returns true if the docshell is currently executing the onLoad Handler
320 readonly attribute
boolean isExecutingOnLoadHandler
;
322 attribute nsILayoutHistoryState layoutHistoryState
;
325 * Object used to delegate URI loading to an upper context.
326 * Currently only set for GeckoView to allow handling of load requests
327 * at the application level.
329 readonly attribute nsILoadURIDelegate loadURIDelegate
;
332 * Cancel the XPCOM timers for each meta-refresh URI in this docshell,
333 * and this docshell's children, recursively. The meta-refresh timers can be
334 * restarted using resumeRefreshURIs(). If the timers are already suspended,
335 * this has no effect.
337 void suspendRefreshURIs
();
340 * Restart the XPCOM timers for each meta-refresh URI in this docshell,
341 * and this docshell's children, recursively. If the timers are already
342 * running, this has no effect.
344 void resumeRefreshURIs
();
347 * Begin firing WebProgressListener notifications for restoring a page
348 * presentation. |viewer| is the content viewer whose document we are
349 * starting to load. If null, it defaults to the docshell's current content
350 * viewer, creating one if necessary. |top| should be true for the toplevel
351 * docshell that is being restored; it will be set to false when this method
352 * is called for child docshells. This method will post an event to
353 * complete the simulated load after returning to the event loop.
355 void beginRestore
(in nsIContentViewer viewer
, in boolean top
);
358 * Finish firing WebProgressListener notifications and DOM events for
359 * restoring a page presentation. This should only be called via
362 void finishRestore
();
364 void clearCachedUserAgent
();
366 void clearCachedPlatform
();
368 /* Track whether we're currently restoring a document presentation. */
369 readonly attribute
boolean restoringDocument
;
371 /* attribute to access whether error pages are enabled */
372 attribute
boolean useErrorPages
;
375 * Display a load error in a frame while keeping that frame's currentURI
376 * pointing correctly to the page where the error ocurred, rather than to
377 * the error document page. You must provide either the aURI or aURL parameter.
379 * @param aError The error code to be displayed
380 * @param aURI nsIURI of the page where the error happened
381 * @param aURL wstring of the page where the error happened
382 * @param aFailedChannel The channel related to this error
384 * Returns whether or not we displayed an error page (note: will always
385 * return false if in-content error pages are disabled!)
387 boolean displayLoadError
(in nsresult aError
,
390 [optional] in nsIChannel aFailedChannel
);
393 * The channel that failed to load and resulted in an error page.
394 * May be null. Relevant only to error pages.
396 readonly attribute nsIChannel failedChannel
;
399 * Keeps track of the previous nsISHEntry index and the current
400 * nsISHEntry index at the time that the doc shell begins to load.
401 * Used for ContentViewer eviction.
403 readonly attribute
long previousEntryIndex
;
404 readonly attribute
long loadedEntryIndex
;
407 * Notification that entries have been removed from the beginning of a
408 * nsSHistory which has this as its rootDocShell.
410 * @param numEntries - The number of entries removed
412 void historyPurged
(in long numEntries
);
415 * Gets the channel for the currently loaded document, if any.
416 * For a new document load, this will be the channel of the previous document
417 * until after OnLocationChange fires.
419 readonly attribute nsIChannel currentDocumentChannel
;
422 * Find out whether the docshell is currently in the middle of a page
423 * transition. This is set just before the pagehide/unload events fire.
425 [infallible
] readonly attribute
boolean isInUnload
;
428 * Disconnects this docshell's editor from its window, and stores the
429 * editor data in the open document's session history entry. This
430 * should be called only during page transitions.
432 [noscript
, notxpcom
] void DetachEditorFromWindow
();
435 * Propagated to the print preview document viewer. Must only be called on
436 * a document viewer that has been initialized for print preview.
438 void exitPrintPreview
();
441 * The ID of the docshell in the session history.
443 readonly attribute nsIDRef historyID
;
446 * Helper method for accessing this value from C++
448 [noscript
, notxpcom
] nsIDRef HistoryID
();
451 * Create a new about:blank document and content viewer.
452 * @param aPrincipal the principal to use for the new document.
453 * @param aPartitionedPrincipal the partitioned principal to use for the new
455 * @param aCsp the CSP to use for the new document.
457 void createAboutBlankContentViewer
(in nsIPrincipal aPrincipal
,
458 in nsIPrincipal aPartitionedPrincipal
,
459 [optional] in nsIContentSecurityPolicy aCSP
);
462 * Upon getting, returns the canonical encoding label of the document
463 * currently loaded into this docshell.
465 readonly attribute ACString charset
;
467 void forceEncodingDetection
();
470 * In a child docshell, this is the charset of the parent docshell
472 [noscript
, notxpcom
, nostdcall
] void setParentCharset
(
473 in Encoding parentCharset
,
474 in int32_t parentCharsetSource
,
475 in nsIPrincipal parentCharsetPrincipal
);
476 [noscript
, notxpcom
, nostdcall
] void getParentCharset
(
477 out Encoding parentCharset
,
478 out int32_t parentCharsetSource
,
479 out nsIPrincipal parentCharsetPrincipal
);
482 * Whether the docShell records profile timeline markers at the moment
484 [infallible
] attribute
boolean recordProfileTimelineMarkers
;
487 * Return a DOMHighResTimeStamp representing the number of
488 * milliseconds from an arbitrary point in time. The reference
489 * point is shared by all DocShells and is also used by timestamps
492 DOMHighResTimeStamp now
();
495 * Returns and flushes the profile timeline markers gathered by the docShell
498 jsval popProfileTimelineMarkers
();
501 * Add an observer to the list of parties to be notified when this docshell's
502 * private browsing status is changed. |obs| must support weak references.
504 void addWeakPrivacyTransitionObserver
(in nsIPrivacyTransitionObserver obs
);
507 * Add an observer to the list of parties to be notified when reflows are
508 * occurring. |obs| must support weak references.
510 void addWeakReflowObserver
(in nsIReflowObserver obs
);
513 * Remove an observer from the list of parties to be notified about reflows.
515 void removeWeakReflowObserver
(in nsIReflowObserver obs
);
518 * Notify all attached observers that a reflow has just occurred.
520 * @param interruptible if true, the reflow was interruptible.
521 * @param start timestamp when reflow started, in milliseconds since
522 * navigationStart (accurate to 1/1000 of a ms)
523 * @param end timestamp when reflow ended, in milliseconds since
524 * navigationStart (accurate to 1/1000 of a ms)
526 [noscript
] void notifyReflowObservers
(in bool interruptible
,
527 in DOMHighResTimeStamp start
,
528 in DOMHighResTimeStamp end
);
531 * Add an observer to the list of parties to be notified when scroll position
532 * of some elements is changed.
534 [noscript
] void addWeakScrollObserver
(in nsIScrollObserver obs
);
537 * Add an observer to the list of parties to be notified when scroll position
538 * of some elements is changed.
540 [noscript
] void removeWeakScrollObserver
(in nsIScrollObserver obs
);
543 * Notify all attached observers that the scroll position of some element
546 [noscript
] void notifyScrollObservers
();
549 * Returns true if this docshell is the top level content docshell.
551 [infallible
] readonly attribute
boolean isTopLevelContentDocShell
;
554 * Like nsIDocShellTreeItem::GetSameTypeParent, except this ignores <iframe
555 * mozbrowser> boundaries. Which no longer exist.
557 * @deprecated: Use `BrowsingContext::GetParent()` in the future.
559 nsIDocShell getSameTypeInProcessParentIgnoreBrowserBoundaries
();
562 * True iff asynchronous panning and zooming is enabled for this
565 readonly attribute bool asyncPanZoomEnabled
;
568 * Are plugins allowed in the current document loaded in this docshell ?
569 * (if there is one). This depends on whether plugins are allowed by this
570 * docshell itself or if the document is sandboxed and hence plugins should
573 [noscript
, notxpcom
] bool pluginsAllowedInCurrentDoc
();
576 * Indicates whether the UI may enable the character encoding menu. The UI
577 * must disable the menu when this property is false.
579 [infallible
] readonly attribute
boolean mayEnableCharacterEncodingMenu
;
581 attribute nsIEditor editor
;
582 readonly attribute
boolean editable
; /* this docShell is editable */
583 readonly attribute
boolean hasEditingSession
; /* this docShell has an editing session */
586 * Make this docShell editable, setting a flag that causes
587 * an editor to get created, either immediately, or after
588 * a url has been loaded.
589 * @param inWaitForUriLoad true to wait for a URI before
590 * creating the editor.
592 void makeEditable
(in boolean inWaitForUriLoad
);
595 * Returns false for mLSHE, true for mOSHE
597 boolean getCurrentSHEntry
(out nsISHEntry aEntry
);
600 * Cherry picked parts of nsIController.
601 * They are here, because we want to call these functions
604 boolean isCommandEnabled
(in string command
);
606 void doCommand
(in string command
);
608 void doCommandWithParams
(in string command
, in nsICommandParams aParams
);
611 * Invisible DocShell are dummy construct to simulate DOM windows
612 * without any actual visual representation. They have to be marked
613 * at construction time, to avoid any painting activity.
615 [noscript
, notxpcom
] bool IsInvisible
();
616 [noscript
, notxpcom
] void SetInvisible
(in bool aIsInvisibleDocshell
);
619 * Get the script global for the document in this docshell.
621 [noscript
,notxpcom
,nostdcall
] nsIScriptGlobalObject GetScriptGlobalObject
();
623 [noscript
,notxpcom
,nostdcall
] Document getExtantDocument
();
626 * Notify DocShell when the browser is about to start executing JS, and after
627 * that execution has stopped. This only occurs when the Timeline devtool
628 * is collecting information.
630 [noscript
,notxpcom
,nostdcall
] void notifyJSRunToCompletionStart
(in string aReason
,
631 in AString functionName
,
633 in unsigned long lineNumber
,
635 in string asyncCause
);
636 [noscript
,notxpcom
,nostdcall
] void notifyJSRunToCompletionStop
();
639 * This attribute determines whether a document which is not about:blank has
640 * already be loaded by this docShell.
642 [infallible
] readonly attribute
boolean hasLoadedNonBlankURI
;
645 * Allow usage of -moz-window-dragging:drag for content docshells.
646 * True for top level chrome docshells. Throws if set to false with
647 * top level chrome docshell.
649 attribute
boolean windowDraggingAllowed
;
652 * Sets/gets the current scroll restoration mode.
653 * @see https://html.spec.whatwg.org/#dom-history-scroll-restoration
655 attribute
boolean currentScrollRestorationIsManual
;
658 * Setter and getter for the origin attributes living on this docshell.
661 jsval getOriginAttributes
();
664 void setOriginAttributes
(in jsval aAttrs
);
667 * The editing session for this docshell.
669 readonly attribute nsIEditingSession editingSession
;
672 * The browser child for this docshell.
674 [binaryname
(ScriptableBrowserChild
)] readonly attribute nsIBrowserChild browserChild
;
675 [noscript
,notxpcom
,nostdcall
] BrowserChildRef GetBrowserChild
();
677 [noscript
,nostdcall
,notxpcom
] nsCommandManager GetCommandManager
();
679 cenum MetaViewportOverride
: 8 {
681 * Override platform/pref default behaviour and force-disable support for
682 * <meta name="viewport">.
684 META_VIEWPORT_OVERRIDE_DISABLED
= 0,
686 * Override platform/pref default behaviour and force-enable support for
687 * <meta name="viewport">.
689 META_VIEWPORT_OVERRIDE_ENABLED
= 1,
691 * Don't override the platform/pref default behaviour for support for
692 * <meta name="viewport">.
694 META_VIEWPORT_OVERRIDE_NONE
= 2,
698 * This allows chrome to override the default choice of whether the
699 * <meta name="viewport"> tag is respected in a specific docshell.
700 * Possible values are listed above.
702 [infallible
, setter_can_run_script
] attribute nsIDocShell_MetaViewportOverride metaViewportOverride
;
705 * Attribute that determines whether tracking protection is enabled.
707 attribute
boolean useTrackingProtection
;
710 * Fire a dummy location change event asynchronously.
712 [noscript
] void dispatchLocationChangeEvent
();
716 * Start delayed autoplay media which are in the current document.
718 [noscript
] void startDelayedAutoplayMediaComponents
();
721 * Take ownership of the ClientSource representing an initial about:blank
722 * document that was never needed. As an optimization we avoid creating
723 * this document if no code calls GetDocument(), but we still need a
724 * ClientSource object to represent the about:blank window. This may return
725 * nullptr; for example if the docshell has created a real window and document
728 [noscript
, nostdcall
, notxpcom
]
729 UniqueClientSource TakeInitialClientSource
();
731 void setColorMatrix
(in Array
<float> aMatrix
);
734 * Returns true if the current load is a forced reload,
735 * e.g. started by holding shift whilst triggering reload.
737 readonly attribute bool isForceReloading
;
739 Array
<float> getColorMatrix
();
743 * These methods call nsDocShell::GetHTMLEditorInternal() and
744 * nsDocShell::SetHTMLEditorInternal() with static_cast.
746 mozilla
::HTMLEditor
* GetHTMLEditor
();
747 nsresult SetHTMLEditor
(mozilla
::HTMLEditor
* aHTMLEditor
);
751 * The message manager for this docshell. This does not throw, but
752 * can return null if the docshell has no message manager.
754 [infallible
] readonly attribute ContentFrameMessageManager messageManager
;
757 * This returns a Promise which resolves to a boolean. True when the
758 * document has Tracking Content that has been blocked from loading, false
761 Promise getHasTrackingContentBlocked
();
764 * Return whether this docshell is "attempting to navigate" in the
765 * sense that's relevant to document.open.
767 [notxpcom
, nostdcall
] readonly attribute
boolean isAttemptingToNavigate
;
770 * Whether or not this docshell is executing a nsIWebNavigation navigation
773 * This will be true when the following methods are executing:
774 * nsIWebNavigation.binaryLoadURI
775 * nsIWebNavigation.goBack
776 * nsIWebNavigation.goForward
777 * nsIWebNavigation.gotoIndex
778 * nsIWebNavigation.loadURI
780 [infallible
] readonly attribute
boolean isNavigating
;
783 * @see nsISHEntry synchronizeLayoutHistoryState().
785 void synchronizeLayoutHistoryState
();
788 * This attempts to save any applicable layout history state (like
789 * scroll position) in the nsISHEntry. This is normally done
790 * automatically when transitioning from page to page in the
791 * same process. We expose this function to support transitioning
792 * from page to page across processes as a workaround for bug 1630234
793 * until session history state is moved into the parent process.
795 void persistLayoutHistoryState
();