Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=2 sw=2 et 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/. */
8 #ifndef nsPIDOMWindow_h__
9 #define nsPIDOMWindow_h__
11 #include "nsIDOMWindow.h"
13 #include "nsCOMPtr.h"
14 #include "nsAutoPtr.h"
15 #include "nsTArray.h"
16 #include "mozilla/dom/EventTarget.h"
17 #include "js/TypeDecls.h"
19 #define DOM_WINDOW_DESTROYED_TOPIC "dom-window-destroyed"
20 #define DOM_WINDOW_FROZEN_TOPIC "dom-window-frozen"
21 #define DOM_WINDOW_THAWED_TOPIC "dom-window-thawed"
23 class nsIArray;
24 class nsIContent;
25 class nsIDocShell;
26 class nsIDocument;
27 class nsIIdleObserver;
28 class nsIPrincipal;
29 class nsIScriptTimeoutHandler;
30 class nsIURI;
31 class nsPerformance;
32 class nsPIWindowRoot;
33 class nsXBLPrototypeHandler;
34 struct nsTimeout;
36 namespace mozilla {
37 namespace dom {
38 class AudioContext;
39 class Element;
40 }
41 }
43 // Popup control state enum. The values in this enum must go from most
44 // permissive to least permissive so that it's safe to push state in
45 // all situations. Pushing popup state onto the stack never makes the
46 // current popup state less permissive (see
47 // nsGlobalWindow::PushPopupControlState()).
48 enum PopupControlState {
49 openAllowed = 0, // open that window without worries
50 openControlled, // it's a popup, but allow it
51 openAbused, // it's a popup. disallow it, but allow domain override.
52 openOverridden // disallow window open
53 };
55 enum UIStateChangeType
56 {
57 UIStateChangeType_NoChange,
58 UIStateChangeType_Set,
59 UIStateChangeType_Clear
60 };
62 #define NS_PIDOMWINDOW_IID \
63 { 0xf26953de, 0xa799, 0x4a92, \
64 { 0x87, 0x49, 0x7c, 0x37, 0xe5, 0x90, 0x3f, 0x37 } }
66 class nsPIDOMWindow : public nsIDOMWindowInternal
67 {
68 public:
69 NS_DECLARE_STATIC_IID_ACCESSOR(NS_PIDOMWINDOW_IID)
71 virtual nsPIDOMWindow* GetPrivateRoot() = 0;
73 // Outer windows only.
74 virtual void ActivateOrDeactivate(bool aActivate) = 0;
76 // this is called GetTopWindowRoot to avoid conflicts with nsIDOMWindow::GetWindowRoot
77 virtual already_AddRefed<nsPIWindowRoot> GetTopWindowRoot() = 0;
79 // Inner windows only.
80 virtual nsresult RegisterIdleObserver(nsIIdleObserver* aIdleObserver) = 0;
81 virtual nsresult UnregisterIdleObserver(nsIIdleObserver* aIdleObserver) = 0;
83 // Outer windows only.
84 virtual void SetActive(bool aActive)
85 {
86 MOZ_ASSERT(IsOuterWindow());
87 mIsActive = aActive;
88 }
89 bool IsActive()
90 {
91 MOZ_ASSERT(IsOuterWindow());
92 return mIsActive;
93 }
95 // Outer windows only.
96 virtual void SetIsBackground(bool aIsBackground)
97 {
98 MOZ_ASSERT(IsOuterWindow());
99 mIsBackground = aIsBackground;
100 }
101 bool IsBackground()
102 {
103 MOZ_ASSERT(IsOuterWindow());
104 return mIsBackground;
105 }
107 mozilla::dom::EventTarget* GetChromeEventHandler() const
108 {
109 return mChromeEventHandler;
110 }
112 // Outer windows only.
113 virtual void SetChromeEventHandler(mozilla::dom::EventTarget* aChromeEventHandler) = 0;
115 mozilla::dom::EventTarget* GetParentTarget()
116 {
117 if (!mParentTarget) {
118 UpdateParentTarget();
119 }
120 return mParentTarget;
121 }
123 bool HasMutationListeners(uint32_t aMutationEventType) const
124 {
125 const nsPIDOMWindow *win;
127 if (IsOuterWindow()) {
128 win = GetCurrentInnerWindow();
130 if (!win) {
131 NS_ERROR("No current inner window available!");
133 return false;
134 }
135 } else {
136 if (!mOuterWindow) {
137 NS_ERROR("HasMutationListeners() called on orphan inner window!");
139 return false;
140 }
142 win = this;
143 }
145 return (win->mMutationBits & aMutationEventType) != 0;
146 }
148 void SetMutationListeners(uint32_t aType)
149 {
150 nsPIDOMWindow *win;
152 if (IsOuterWindow()) {
153 win = GetCurrentInnerWindow();
155 if (!win) {
156 NS_ERROR("No inner window available to set mutation bits on!");
158 return;
159 }
160 } else {
161 if (!mOuterWindow) {
162 NS_ERROR("HasMutationListeners() called on orphan inner window!");
164 return;
165 }
167 win = this;
168 }
170 win->mMutationBits |= aType;
171 }
173 virtual void MaybeUpdateTouchState() {}
174 virtual void UpdateTouchState() {}
176 nsIDocument* GetExtantDoc() const
177 {
178 return mDoc;
179 }
180 nsIURI* GetDocumentURI() const;
181 nsIURI* GetDocBaseURI() const;
183 nsIDocument* GetDoc()
184 {
185 if (!mDoc) {
186 MaybeCreateDoc();
187 }
188 return mDoc;
189 }
191 virtual NS_HIDDEN_(bool) IsRunningTimeout() = 0;
193 // Audio API
194 bool GetAudioMuted() const;
195 void SetAudioMuted(bool aMuted);
197 float GetAudioVolume() const;
198 nsresult SetAudioVolume(float aVolume);
200 float GetAudioGlobalVolume();
202 protected:
203 // Lazily instantiate an about:blank document if necessary, and if
204 // we have what it takes to do so.
205 void MaybeCreateDoc();
207 float GetAudioGlobalVolumeInternal(float aVolume);
208 void RefreshMediaElements();
210 public:
211 // Internal getter/setter for the frame element, this version of the
212 // getter crosses chrome boundaries whereas the public scriptable
213 // one doesn't for security reasons.
214 mozilla::dom::Element* GetFrameElementInternal() const;
215 void SetFrameElementInternal(mozilla::dom::Element* aFrameElement);
217 bool IsLoadingOrRunningTimeout() const
218 {
219 const nsPIDOMWindow *win = GetCurrentInnerWindow();
221 if (!win) {
222 win = this;
223 }
225 return !win->mIsDocumentLoaded || win->mRunningTimeout;
226 }
228 // Check whether a document is currently loading
229 bool IsLoading() const
230 {
231 const nsPIDOMWindow *win;
233 if (IsOuterWindow()) {
234 win = GetCurrentInnerWindow();
236 if (!win) {
237 NS_ERROR("No current inner window available!");
239 return false;
240 }
241 } else {
242 if (!mOuterWindow) {
243 NS_ERROR("IsLoading() called on orphan inner window!");
245 return false;
246 }
248 win = this;
249 }
251 return !win->mIsDocumentLoaded;
252 }
254 bool IsHandlingResizeEvent() const
255 {
256 const nsPIDOMWindow *win;
258 if (IsOuterWindow()) {
259 win = GetCurrentInnerWindow();
261 if (!win) {
262 NS_ERROR("No current inner window available!");
264 return false;
265 }
266 } else {
267 if (!mOuterWindow) {
268 NS_ERROR("IsHandlingResizeEvent() called on orphan inner window!");
270 return false;
271 }
273 win = this;
274 }
276 return win->mIsHandlingResizeEvent;
277 }
279 // Set the window up with an about:blank document with the current subject
280 // principal.
281 virtual void SetInitialPrincipalToSubject() = 0;
283 virtual PopupControlState PushPopupControlState(PopupControlState aState,
284 bool aForce) const = 0;
285 virtual void PopPopupControlState(PopupControlState state) const = 0;
286 virtual PopupControlState GetPopupControlState() const = 0;
288 // Returns an object containing the window's state. This also suspends
289 // all running timeouts in the window.
290 virtual already_AddRefed<nsISupports> SaveWindowState() = 0;
292 // Restore the window state from aState.
293 virtual nsresult RestoreWindowState(nsISupports *aState) = 0;
295 // Suspend timeouts in this window and in child windows.
296 virtual void SuspendTimeouts(uint32_t aIncrease = 1,
297 bool aFreezeChildren = true) = 0;
299 // Resume suspended timeouts in this window and in child windows.
300 virtual nsresult ResumeTimeouts(bool aThawChildren = true) = 0;
302 virtual uint32_t TimeoutSuspendCount() = 0;
304 // Fire any DOM notification events related to things that happened while
305 // the window was frozen.
306 virtual nsresult FireDelayedDOMEvents() = 0;
308 virtual bool IsFrozen() const = 0;
310 // Add a timeout to this window.
311 virtual nsresult SetTimeoutOrInterval(nsIScriptTimeoutHandler *aHandler,
312 int32_t interval,
313 bool aIsInterval, int32_t *aReturn) = 0;
315 // Clear a timeout from this window.
316 virtual nsresult ClearTimeoutOrInterval(int32_t aTimerID) = 0;
318 nsPIDOMWindow *GetOuterWindow()
319 {
320 return mIsInnerWindow ? mOuterWindow.get() : this;
321 }
323 nsPIDOMWindow *GetCurrentInnerWindow() const
324 {
325 return mInnerWindow;
326 }
328 nsPIDOMWindow *EnsureInnerWindow()
329 {
330 NS_ASSERTION(IsOuterWindow(), "EnsureInnerWindow called on inner window");
331 // GetDoc forces inner window creation if there isn't one already
332 GetDoc();
333 return GetCurrentInnerWindow();
334 }
336 bool IsInnerWindow() const
337 {
338 return mIsInnerWindow;
339 }
341 // Returns true if this object has an outer window and it is the current inner
342 // window of that outer. Only call this on inner windows.
343 bool IsCurrentInnerWindow() const
344 {
345 MOZ_ASSERT(IsInnerWindow(),
346 "It doesn't make sense to call this on outer windows.");
347 return mOuterWindow && mOuterWindow->GetCurrentInnerWindow() == this;
348 }
350 // Returns true if the document of this window is the active document. This
351 // is not identical to IsCurrentInnerWindow() because document.open() will
352 // keep the same document active but create a new window.
353 bool HasActiveDocument()
354 {
355 MOZ_ASSERT(IsInnerWindow());
356 return IsCurrentInnerWindow() ||
357 (mOuterWindow &&
358 mOuterWindow->GetCurrentInnerWindow() &&
359 mOuterWindow->GetCurrentInnerWindow()->GetDoc() == mDoc);
360 }
362 bool IsOuterWindow() const
363 {
364 return !IsInnerWindow();
365 }
367 virtual bool WouldReuseInnerWindow(nsIDocument *aNewDocument) = 0;
369 /**
370 * Get the docshell in this window.
371 */
372 nsIDocShell *GetDocShell()
373 {
374 if (mOuterWindow) {
375 return mOuterWindow->mDocShell;
376 }
378 return mDocShell;
379 }
381 /**
382 * Set the docshell in the window. Must not be called with a null docshell
383 * (use DetachFromDocShell for that).
384 */
385 virtual void SetDocShell(nsIDocShell *aDocShell) = 0;
387 /**
388 * Detach an outer window from its docshell.
389 */
390 virtual void DetachFromDocShell() = 0;
392 /**
393 * Set a new document in the window. Calling this method will in
394 * most cases create a new inner window. If this method is called on
395 * an inner window the call will be forewarded to the outer window,
396 * if the inner window is not the current inner window an
397 * NS_ERROR_NOT_AVAILABLE error code will be returned. This may be
398 * called with a pointer to the current document, in that case the
399 * document remains unchanged, but a new inner window will be
400 * created.
401 *
402 * aDocument must not be null.
403 */
404 virtual nsresult SetNewDocument(nsIDocument *aDocument,
405 nsISupports *aState,
406 bool aForceReuseInnerWindow) = 0;
408 /**
409 * Set the opener window. aOriginalOpener is true if and only if this is the
410 * original opener for the window. That is, it can only be true at most once
411 * during the life cycle of a window, and then only the first time
412 * SetOpenerWindow is called. It might never be true, of course, if the
413 * window does not have an opener when it's created.
414 */
415 virtual void SetOpenerWindow(nsIDOMWindow* aOpener,
416 bool aOriginalOpener) = 0;
418 virtual void EnsureSizeUpToDate() = 0;
420 /**
421 * Callback for notifying a window about a modal dialog being
422 * opened/closed with the window as a parent.
423 */
424 virtual void EnterModalState() = 0;
425 virtual void LeaveModalState() = 0;
427 virtual bool CanClose() = 0;
428 virtual nsresult ForceClose() = 0;
430 bool IsModalContentWindow() const
431 {
432 return mIsModalContentWindow;
433 }
435 /**
436 * Call this to indicate that some node (this window, its document,
437 * or content in that document) has a paint event listener.
438 */
439 void SetHasPaintEventListeners()
440 {
441 mMayHavePaintEventListener = true;
442 }
444 /**
445 * Call this to check whether some node (this window, its document,
446 * or content in that document) has a paint event listener.
447 */
448 bool HasPaintEventListeners()
449 {
450 return mMayHavePaintEventListener;
451 }
453 /**
454 * Call this to indicate that some node (this window, its document,
455 * or content in that document) has a touch event listener.
456 */
457 void SetHasTouchEventListeners()
458 {
459 mMayHaveTouchEventListener = true;
460 MaybeUpdateTouchState();
461 }
463 bool HasTouchEventListeners()
464 {
465 return mMayHaveTouchEventListener;
466 }
468 /**
469 * Moves the top-level window into fullscreen mode if aIsFullScreen is true,
470 * otherwise exits fullscreen. If aRequireTrust is true, this method only
471 * changes window state in a context trusted for write.
472 */
473 virtual nsresult SetFullScreenInternal(bool aIsFullScreen, bool aRequireTrust) = 0;
475 /**
476 * Call this to check whether some node (this window, its document,
477 * or content in that document) has a mouseenter/leave event listener.
478 */
479 bool HasMouseEnterLeaveEventListeners()
480 {
481 return mMayHaveMouseEnterLeaveEventListener;
482 }
484 /**
485 * Call this to indicate that some node (this window, its document,
486 * or content in that document) has a mouseenter/leave event listener.
487 */
488 void SetHasMouseEnterLeaveEventListeners()
489 {
490 mMayHaveMouseEnterLeaveEventListener = true;
491 }
493 /**
494 * Call this to check whether some node (this window, its document,
495 * or content in that document) has a Pointerenter/leave event listener.
496 */
497 bool HasPointerEnterLeaveEventListeners()
498 {
499 return mMayHavePointerEnterLeaveEventListener;
500 }
502 /**
503 * Call this to indicate that some node (this window, its document,
504 * or content in that document) has a Pointerenter/leave event listener.
505 */
506 void SetHasPointerEnterLeaveEventListeners()
507 {
508 mMayHavePointerEnterLeaveEventListener = true;
509 }
512 virtual JSObject* GetCachedXBLPrototypeHandler(nsXBLPrototypeHandler* aKey) = 0;
513 virtual void CacheXBLPrototypeHandler(nsXBLPrototypeHandler* aKey,
514 JS::Handle<JSObject*> aHandler) = 0;
516 /*
517 * Get and set the currently focused element within the document. If
518 * aNeedsFocus is true, then set mNeedsFocus to true to indicate that a
519 * document focus event is needed.
520 *
521 * DO NOT CALL EITHER OF THESE METHODS DIRECTLY. USE THE FOCUS MANAGER
522 * INSTEAD.
523 */
524 nsIContent* GetFocusedNode()
525 {
526 if (IsOuterWindow()) {
527 return mInnerWindow ? mInnerWindow->mFocusedNode.get() : nullptr;
528 }
529 return mFocusedNode;
530 }
531 virtual void SetFocusedNode(nsIContent* aNode,
532 uint32_t aFocusMethod = 0,
533 bool aNeedsFocus = false) = 0;
535 /**
536 * Retrieves the method that was used to focus the current node.
537 */
538 virtual uint32_t GetFocusMethod() = 0;
540 /*
541 * Tells the window that it now has focus or has lost focus, based on the
542 * state of aFocus. If this method returns true, then the document loaded
543 * in the window has never received a focus event and expects to receive
544 * one. If false is returned, the document has received a focus event before
545 * and should only receive one if the window is being focused.
546 *
547 * aFocusMethod may be set to one of the focus method constants in
548 * nsIFocusManager to indicate how focus was set.
549 */
550 virtual bool TakeFocus(bool aFocus, uint32_t aFocusMethod) = 0;
552 /**
553 * Indicates that the window may now accept a document focus event. This
554 * should be called once a document has been loaded into the window.
555 */
556 virtual void SetReadyForFocus() = 0;
558 /**
559 * Whether the focused content within the window should show a focus ring.
560 */
561 virtual bool ShouldShowFocusRing() = 0;
563 /**
564 * Set the keyboard indicator state for accelerators and focus rings.
565 */
566 virtual void SetKeyboardIndicators(UIStateChangeType aShowAccelerators,
567 UIStateChangeType aShowFocusRings) = 0;
569 /**
570 * Get the keyboard indicator state for accelerators and focus rings.
571 */
572 virtual void GetKeyboardIndicators(bool* aShowAccelerators,
573 bool* aShowFocusRings) = 0;
575 /**
576 * Indicates that the page in the window has been hidden. This is used to
577 * reset the focus state.
578 */
579 virtual void PageHidden() = 0;
581 /**
582 * Instructs this window to asynchronously dispatch a hashchange event. This
583 * method must be called on an inner window.
584 */
585 virtual nsresult DispatchAsyncHashchange(nsIURI *aOldURI,
586 nsIURI *aNewURI) = 0;
588 /**
589 * Instructs this window to synchronously dispatch a popState event.
590 */
591 virtual nsresult DispatchSyncPopState() = 0;
593 /**
594 * Tell this window that it should listen for sensor changes of the given
595 * type.
596 *
597 * Inner windows only.
598 */
599 virtual void EnableDeviceSensor(uint32_t aType) = 0;
601 /**
602 * Tell this window that it should remove itself from sensor change
603 * notifications.
604 *
605 * Inner windows only.
606 */
607 virtual void DisableDeviceSensor(uint32_t aType) = 0;
609 virtual void EnableTimeChangeNotifications() = 0;
610 virtual void DisableTimeChangeNotifications() = 0;
612 #ifdef MOZ_B2G
613 /**
614 * Tell the window that it should start to listen to the network event of the
615 * given aType.
616 *
617 * Inner windows only.
618 */
619 virtual void EnableNetworkEvent(uint32_t aType) = 0;
621 /**
622 * Tell the window that it should stop to listen to the network event of the
623 * given aType.
624 *
625 * Inner windows only.
626 */
627 virtual void DisableNetworkEvent(uint32_t aType) = 0;
628 #endif // MOZ_B2G
630 /**
631 * Tell this window that there is an observer for gamepad input
632 */
633 virtual void SetHasGamepadEventListener(bool aHasGamepad = true) = 0;
635 /**
636 * Set a arguments for this window. This will be set on the window
637 * right away (if there's an existing document) and it will also be
638 * installed on the window when the next document is loaded.
639 *
640 * This function serves double-duty for passing both |arguments| and
641 * |dialogArguments| back from nsWindowWatcher to nsGlobalWindow. For the
642 * latter, the array is an array of length 0 whose only element is a
643 * DialogArgumentsHolder representing the JS value passed to showModalDialog.
644 */
645 virtual nsresult SetArguments(nsIArray *aArguments) = 0;
647 /**
648 * NOTE! This function *will* be called on multiple threads so the
649 * implementation must not do any AddRef/Release or other actions that will
650 * mutate internal state.
651 */
652 virtual uint32_t GetSerial() = 0;
654 /**
655 * Return the window id of this window
656 */
657 uint64_t WindowID() const { return mWindowID; }
659 /**
660 * Dispatch a custom event with name aEventName targeted at this window.
661 * Returns whether the default action should be performed.
662 */
663 virtual bool DispatchCustomEvent(const char *aEventName) = 0;
665 /**
666 * Notify the active inner window that the document principal may have changed
667 * and that the compartment principal needs to be updated.
668 */
669 virtual void RefreshCompartmentPrincipal() = 0;
671 /**
672 * Like nsIDOMWindow::Open, except that we don't navigate to the given URL.
673 */
674 virtual nsresult
675 OpenNoNavigate(const nsAString& aUrl, const nsAString& aName,
676 const nsAString& aOptions, nsIDOMWindow **_retval) = 0;
678 void AddAudioContext(mozilla::dom::AudioContext* aAudioContext);
679 void RemoveAudioContext(mozilla::dom::AudioContext* aAudioContext);
680 void MuteAudioContexts();
681 void UnmuteAudioContexts();
683 // Given an inner window, return its outer if the inner is the current inner.
684 // Otherwise (argument null or not an inner or not current) return null.
685 static nsPIDOMWindow* GetOuterFromCurrentInner(nsPIDOMWindow* aInner)
686 {
687 if (!aInner) {
688 return nullptr;
689 }
691 nsPIDOMWindow* outer = aInner->GetOuterWindow();
692 if (!outer || outer->GetCurrentInnerWindow() != aInner) {
693 return nullptr;
694 }
696 return outer;
697 }
699 // WebIDL-ish APIs
700 nsPerformance* GetPerformance();
702 void MarkUncollectableForCCGeneration(uint32_t aGeneration)
703 {
704 mMarkedCCGeneration = aGeneration;
705 }
707 uint32_t GetMarkedCCGeneration()
708 {
709 return mMarkedCCGeneration;
710 }
711 protected:
712 // The nsPIDOMWindow constructor. The aOuterWindow argument should
713 // be null if and only if the created window itself is an outer
714 // window. In all other cases aOuterWindow should be the outer
715 // window for the inner window that is being created.
716 nsPIDOMWindow(nsPIDOMWindow *aOuterWindow);
718 ~nsPIDOMWindow();
720 void SetChromeEventHandlerInternal(mozilla::dom::EventTarget* aChromeEventHandler) {
721 mChromeEventHandler = aChromeEventHandler;
722 // mParentTarget will be set when the next event is dispatched.
723 mParentTarget = nullptr;
724 }
726 virtual void UpdateParentTarget() = 0;
728 // Helper for creating performance objects.
729 void CreatePerformanceObjectIfNeeded();
731 // These two variables are special in that they're set to the same
732 // value on both the outer window and the current inner window. Make
733 // sure you keep them in sync!
734 nsCOMPtr<mozilla::dom::EventTarget> mChromeEventHandler; // strong
735 nsCOMPtr<nsIDocument> mDoc; // strong
736 // Cache the URI when mDoc is cleared.
737 nsCOMPtr<nsIURI> mDocumentURI; // strong
738 nsCOMPtr<nsIURI> mDocBaseURI; // strong
740 nsCOMPtr<mozilla::dom::EventTarget> mParentTarget; // strong
742 // These members are only used on outer windows.
743 nsCOMPtr<mozilla::dom::Element> mFrameElement;
744 nsIDocShell *mDocShell; // Weak Reference
746 // mPerformance is only used on inner windows.
747 nsRefPtr<nsPerformance> mPerformance;
749 uint32_t mModalStateDepth;
751 // These variables are only used on inner windows.
752 nsTimeout *mRunningTimeout;
754 uint32_t mMutationBits;
756 bool mIsDocumentLoaded;
757 bool mIsHandlingResizeEvent;
758 bool mIsInnerWindow;
759 bool mMayHavePaintEventListener;
760 bool mMayHaveTouchEventListener;
761 bool mMayHaveMouseEnterLeaveEventListener;
762 bool mMayHavePointerEnterLeaveEventListener;
764 // This variable is used on both inner and outer windows (and they
765 // should match).
766 bool mIsModalContentWindow;
768 // Tracks activation state that's used for :-moz-window-inactive.
769 // Only used on outer windows.
770 bool mIsActive;
772 // Tracks whether our docshell is active. If it is, mIsBackground
773 // is false. Too bad we have so many different concepts of
774 // "active". Only used on outer windows.
775 bool mIsBackground;
777 bool mAudioMuted;
778 float mAudioVolume;
780 // And these are the references between inner and outer windows.
781 nsPIDOMWindow *mInnerWindow;
782 nsCOMPtr<nsPIDOMWindow> mOuterWindow;
784 // the element within the document that is currently focused when this
785 // window is active
786 nsCOMPtr<nsIContent> mFocusedNode;
788 // The AudioContexts created for the current document, if any.
789 nsTArray<mozilla::dom::AudioContext*> mAudioContexts; // Weak
791 // A unique (as long as our 64-bit counter doesn't roll over) id for
792 // this window.
793 uint64_t mWindowID;
795 // This is only used by the inner window. Set to true once we've sent
796 // the (chrome|content)-document-global-created notification.
797 bool mHasNotifiedGlobalCreated;
799 uint32_t mMarkedCCGeneration;
800 };
803 NS_DEFINE_STATIC_IID_ACCESSOR(nsPIDOMWindow, NS_PIDOMWINDOW_IID)
805 #ifdef MOZILLA_INTERNAL_API
806 PopupControlState
807 PushPopupControlState(PopupControlState aState, bool aForce);
809 void
810 PopPopupControlState(PopupControlState aState);
812 #define NS_AUTO_POPUP_STATE_PUSHER nsAutoPopupStatePusherInternal
813 #else
814 #define NS_AUTO_POPUP_STATE_PUSHER nsAutoPopupStatePusherExternal
815 #endif
817 // Helper class that helps with pushing and popping popup control
818 // state. Note that this class looks different from within code that's
819 // part of the layout library than it does in code outside the layout
820 // library. We give the two object layouts different names so the symbols
821 // don't conflict, but code should always use the name
822 // |nsAutoPopupStatePusher|.
823 class NS_AUTO_POPUP_STATE_PUSHER
824 {
825 public:
826 #ifdef MOZILLA_INTERNAL_API
827 NS_AUTO_POPUP_STATE_PUSHER(PopupControlState aState, bool aForce = false)
828 : mOldState(::PushPopupControlState(aState, aForce))
829 {
830 }
832 ~NS_AUTO_POPUP_STATE_PUSHER()
833 {
834 PopPopupControlState(mOldState);
835 }
836 #else
837 NS_AUTO_POPUP_STATE_PUSHER(nsPIDOMWindow *aWindow, PopupControlState aState)
838 : mWindow(aWindow), mOldState(openAbused)
839 {
840 if (aWindow) {
841 mOldState = aWindow->PushPopupControlState(aState, false);
842 }
843 }
845 ~NS_AUTO_POPUP_STATE_PUSHER()
846 {
847 if (mWindow) {
848 mWindow->PopPopupControlState(mOldState);
849 }
850 }
851 #endif
853 protected:
854 #ifndef MOZILLA_INTERNAL_API
855 nsCOMPtr<nsPIDOMWindow> mWindow;
856 #endif
857 PopupControlState mOldState;
859 private:
860 // Hide so that this class can only be stack-allocated
861 static void* operator new(size_t /*size*/) CPP_THROW_NEW { return nullptr; }
862 static void operator delete(void* /*memory*/) {}
863 };
865 #define nsAutoPopupStatePusher NS_AUTO_POPUP_STATE_PUSHER
867 #endif // nsPIDOMWindow_h__