2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2001-09-05 03:30:24 +04:00
|
|
|
|
2011-10-15 11:33:26 +04:00
|
|
|
#include "nsAppShellWindowEnumerator.h"
|
|
|
|
|
2001-09-05 03:30:24 +04:00
|
|
|
#include "nsIContentViewer.h"
|
|
|
|
#include "nsIDocShell.h"
|
|
|
|
#include "nsIDocument.h"
|
|
|
|
#include "nsIDOMWindow.h"
|
|
|
|
#include "nsIFactory.h"
|
|
|
|
#include "nsIInterfaceRequestor.h"
|
2001-09-06 01:28:38 +04:00
|
|
|
#include "nsIInterfaceRequestorUtils.h"
|
2001-09-05 03:30:24 +04:00
|
|
|
#include "nsIXULWindow.h"
|
2018-01-30 07:28:00 +03:00
|
|
|
#include "mozilla/dom/Element.h"
|
2001-09-05 03:30:24 +04:00
|
|
|
|
|
|
|
#include "nsWindowMediator.h"
|
|
|
|
|
2018-01-30 07:28:00 +03:00
|
|
|
using mozilla::dom::Element;
|
|
|
|
|
2009-01-03 07:06:52 +03:00
|
|
|
//
|
|
|
|
// static helper functions
|
|
|
|
//
|
2001-09-05 03:30:24 +04:00
|
|
|
|
2004-01-22 16:13:09 +03:00
|
|
|
static void GetAttribute(nsIXULWindow *inWindow, const nsAString &inAttribute,
|
|
|
|
nsAString &outValue);
|
2001-09-05 03:30:24 +04:00
|
|
|
static void GetWindowType(nsIXULWindow* inWindow, nsString &outType);
|
|
|
|
|
2018-05-30 05:58:49 +03:00
|
|
|
static Element* GetElementFromDocShell(nsIDocShell *aShell)
|
2001-09-05 03:30:24 +04:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIContentViewer> cv;
|
|
|
|
aShell->GetContentViewer(getter_AddRefs(cv));
|
|
|
|
if (cv) {
|
2018-01-31 23:18:10 +03:00
|
|
|
nsCOMPtr<nsIDocument> doc = cv->GetDocument();
|
|
|
|
if (doc) {
|
2018-05-30 05:58:49 +03:00
|
|
|
return doc->GetDocumentElement();
|
2001-09-05 03:30:24 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-30 05:58:49 +03:00
|
|
|
return nullptr;
|
2001-09-05 03:30:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// generic "retrieve the value of a XUL attribute" function
|
2004-01-22 16:13:09 +03:00
|
|
|
void GetAttribute(nsIXULWindow *inWindow, const nsAString &inAttribute,
|
2002-03-24 00:23:50 +03:00
|
|
|
nsAString &outValue)
|
2001-09-05 03:30:24 +04:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDocShell> shell;
|
2004-01-22 16:13:09 +03:00
|
|
|
if (inWindow && NS_SUCCEEDED(inWindow->GetDocShell(getter_AddRefs(shell)))) {
|
2018-05-30 05:58:49 +03:00
|
|
|
RefPtr<Element> webshellElement = GetElementFromDocShell(shell);
|
|
|
|
if (webshellElement) {
|
|
|
|
webshellElement->GetAttribute(inAttribute, outValue);
|
2001-09-05 03:30:24 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// retrieve the window type, stored as the value of a particular
|
|
|
|
// attribute in its XUL window tag
|
|
|
|
void GetWindowType(nsIXULWindow* aWindow, nsString &outType)
|
|
|
|
{
|
|
|
|
GetAttribute(aWindow, NS_LITERAL_STRING("windowtype"), outType);
|
|
|
|
}
|
|
|
|
|
2009-01-03 07:06:52 +03:00
|
|
|
//
|
|
|
|
// nsWindowInfo
|
|
|
|
//
|
2001-09-05 03:30:24 +04:00
|
|
|
|
2018-04-13 16:01:28 +03:00
|
|
|
nsWindowInfo::nsWindowInfo(nsIXULWindow* inWindow, int32_t inTimeStamp) :
|
|
|
|
mWindow(inWindow),mTimeStamp(inTimeStamp),mZLevel(nsIXULWindow::normalZ)
|
2001-09-05 03:30:24 +04:00
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
ReferenceSelf(true, true);
|
2001-09-05 03:30:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsWindowInfo::~nsWindowInfo()
|
|
|
|
{
|
|
|
|
}
|
2009-01-03 07:06:52 +03:00
|
|
|
|
2001-09-05 03:30:24 +04:00
|
|
|
// return true if the window described by this WindowInfo has a type
|
|
|
|
// equal to the given type
|
2011-09-29 10:19:26 +04:00
|
|
|
bool nsWindowInfo::TypeEquals(const nsAString &aType)
|
2017-07-06 15:00:35 +03:00
|
|
|
{
|
2001-09-05 03:30:24 +04:00
|
|
|
nsAutoString rtnString;
|
|
|
|
GetWindowType(mWindow, rtnString);
|
|
|
|
return rtnString == aType;
|
|
|
|
}
|
|
|
|
|
|
|
|
// insert the struct into their two linked lists, in position after the
|
|
|
|
// given (independent) method arguments
|
2009-01-03 07:06:52 +03:00
|
|
|
void nsWindowInfo::InsertAfter(nsWindowInfo *inOlder , nsWindowInfo *inHigher)
|
|
|
|
{
|
2001-09-05 03:30:24 +04:00
|
|
|
if (inOlder) {
|
|
|
|
mOlder = inOlder;
|
|
|
|
mYounger = inOlder->mYounger;
|
|
|
|
mOlder->mYounger = this;
|
|
|
|
if (mOlder->mOlder == mOlder)
|
|
|
|
mOlder->mOlder = this;
|
|
|
|
mYounger->mOlder = this;
|
|
|
|
if (mYounger->mYounger == mYounger)
|
|
|
|
mYounger->mYounger = this;
|
|
|
|
}
|
|
|
|
if (inHigher) {
|
|
|
|
mHigher = inHigher;
|
|
|
|
mLower = inHigher->mLower;
|
|
|
|
mHigher->mLower = this;
|
|
|
|
if (mHigher->mHigher == mHigher)
|
|
|
|
mHigher->mHigher = this;
|
|
|
|
mLower->mHigher = this;
|
|
|
|
if (mLower->mLower == mLower)
|
|
|
|
mLower->mLower = this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// remove the struct from its linked lists
|
2011-09-29 10:19:26 +04:00
|
|
|
void nsWindowInfo::Unlink(bool inAge, bool inZ)
|
2009-01-03 07:06:52 +03:00
|
|
|
{
|
2001-09-05 03:30:24 +04:00
|
|
|
if (inAge) {
|
|
|
|
mOlder->mYounger = mYounger;
|
|
|
|
mYounger->mOlder = mOlder;
|
|
|
|
}
|
|
|
|
if (inZ) {
|
|
|
|
mLower->mHigher = mHigher;
|
|
|
|
mHigher->mLower = mLower;
|
|
|
|
}
|
2009-01-03 07:06:52 +03:00
|
|
|
ReferenceSelf(inAge, inZ);
|
2001-09-05 03:30:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// initialize the struct to be a valid linked list of one element
|
2011-09-29 10:19:26 +04:00
|
|
|
void nsWindowInfo::ReferenceSelf(bool inAge, bool inZ)
|
2009-01-03 07:06:52 +03:00
|
|
|
{
|
2001-09-05 03:30:24 +04:00
|
|
|
if (inAge) {
|
|
|
|
mYounger = this;
|
|
|
|
mOlder = this;
|
|
|
|
}
|
|
|
|
if (inZ) {
|
|
|
|
mLower = this;
|
|
|
|
mHigher = this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-03 07:06:52 +03:00
|
|
|
//
|
|
|
|
// nsAppShellWindowEnumerator
|
|
|
|
//
|
2001-09-05 03:30:24 +04:00
|
|
|
|
2009-01-03 07:06:52 +03:00
|
|
|
nsAppShellWindowEnumerator::nsAppShellWindowEnumerator(
|
2014-01-04 19:02:17 +04:00
|
|
|
const char16_t* aTypeString,
|
2001-09-05 03:30:24 +04:00
|
|
|
nsWindowMediator& aMediator) :
|
2012-07-30 18:20:58 +04:00
|
|
|
mWindowMediator(&aMediator), mType(aTypeString), mCurrentPosition(nullptr)
|
2001-09-05 03:30:24 +04:00
|
|
|
{
|
|
|
|
mWindowMediator->AddEnumerator(this);
|
2002-06-27 02:34:09 +04:00
|
|
|
NS_ADDREF(mWindowMediator);
|
2001-09-05 03:30:24 +04:00
|
|
|
}
|
|
|
|
|
2009-01-03 07:06:52 +03:00
|
|
|
nsAppShellWindowEnumerator::~nsAppShellWindowEnumerator()
|
|
|
|
{
|
2001-09-05 03:30:24 +04:00
|
|
|
mWindowMediator->RemoveEnumerator(this);
|
2002-06-27 02:34:09 +04:00
|
|
|
NS_RELEASE(mWindowMediator);
|
2001-09-05 03:30:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// after mCurrentPosition has been initialized to point to the beginning
|
|
|
|
// of the appropriate list, adjust it if necessary
|
2009-01-03 07:06:52 +03:00
|
|
|
void nsAppShellWindowEnumerator::AdjustInitialPosition()
|
|
|
|
{
|
2001-09-05 03:30:24 +04:00
|
|
|
if (!mType.IsEmpty() && mCurrentPosition && !mCurrentPosition->TypeEquals(mType))
|
|
|
|
mCurrentPosition = FindNext();
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
NS_IMETHODIMP nsAppShellWindowEnumerator::HasMoreElements(bool *retval)
|
2001-09-05 03:30:24 +04:00
|
|
|
{
|
|
|
|
if (!retval)
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
*retval = mCurrentPosition ? true : false;
|
2001-09-05 03:30:24 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2009-01-03 07:06:52 +03:00
|
|
|
// if a window is being removed adjust the iterator's current position
|
|
|
|
void nsAppShellWindowEnumerator::WindowRemoved(nsWindowInfo *inInfo)
|
|
|
|
{
|
2001-09-05 03:30:24 +04:00
|
|
|
if (mCurrentPosition == inInfo)
|
|
|
|
mCurrentPosition = FindNext();
|
|
|
|
}
|
|
|
|
|
2009-01-03 07:06:52 +03:00
|
|
|
//
|
|
|
|
// nsASDOMWindowEnumerator
|
|
|
|
//
|
2001-09-05 03:30:24 +04:00
|
|
|
|
|
|
|
nsASDOMWindowEnumerator::nsASDOMWindowEnumerator(
|
2014-01-04 19:02:17 +04:00
|
|
|
const char16_t* aTypeString,
|
2001-09-05 03:30:24 +04:00
|
|
|
nsWindowMediator& aMediator) :
|
2009-01-03 07:06:52 +03:00
|
|
|
nsAppShellWindowEnumerator(aTypeString, aMediator)
|
|
|
|
{
|
2001-09-05 03:30:24 +04:00
|
|
|
}
|
|
|
|
|
2009-01-03 07:06:52 +03:00
|
|
|
nsASDOMWindowEnumerator::~nsASDOMWindowEnumerator()
|
|
|
|
{
|
2001-09-05 03:30:24 +04:00
|
|
|
}
|
|
|
|
|
2009-01-03 07:06:52 +03:00
|
|
|
NS_IMETHODIMP nsASDOMWindowEnumerator::GetNext(nsISupports **retval)
|
|
|
|
{
|
2001-09-05 03:30:24 +04:00
|
|
|
if (!retval)
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
*retval = nullptr;
|
2012-10-02 12:06:53 +04:00
|
|
|
while (mCurrentPosition) {
|
2016-01-30 20:05:36 +03:00
|
|
|
nsCOMPtr<nsPIDOMWindowOuter> domWindow;
|
2013-12-04 02:03:45 +04:00
|
|
|
nsWindowMediator::GetDOMWindow(mCurrentPosition->mWindow, domWindow);
|
2001-09-05 03:30:24 +04:00
|
|
|
mCurrentPosition = FindNext();
|
2012-10-02 12:06:53 +04:00
|
|
|
if (domWindow)
|
|
|
|
return CallQueryInterface(domWindow, retval);
|
2001-09-05 03:30:24 +04:00
|
|
|
}
|
2018-08-19 04:28:10 +03:00
|
|
|
return NS_ERROR_FAILURE;
|
2003-09-08 04:31:50 +04:00
|
|
|
}
|
2001-09-05 03:30:24 +04:00
|
|
|
|
2009-01-03 07:06:52 +03:00
|
|
|
//
|
|
|
|
// nsASXULWindowEnumerator
|
|
|
|
//
|
2001-09-05 03:30:24 +04:00
|
|
|
|
|
|
|
nsASXULWindowEnumerator::nsASXULWindowEnumerator(
|
2014-01-04 19:02:17 +04:00
|
|
|
const char16_t* aTypeString,
|
2001-09-05 03:30:24 +04:00
|
|
|
nsWindowMediator& aMediator) :
|
2009-01-03 07:06:52 +03:00
|
|
|
nsAppShellWindowEnumerator(aTypeString, aMediator)
|
|
|
|
{
|
2001-09-05 03:30:24 +04:00
|
|
|
}
|
|
|
|
|
2009-01-03 07:06:52 +03:00
|
|
|
nsASXULWindowEnumerator::~nsASXULWindowEnumerator()
|
|
|
|
{
|
2001-09-05 03:30:24 +04:00
|
|
|
}
|
|
|
|
|
2009-01-03 07:06:52 +03:00
|
|
|
NS_IMETHODIMP nsASXULWindowEnumerator::GetNext(nsISupports **retval)
|
|
|
|
{
|
2001-09-05 03:30:24 +04:00
|
|
|
if (!retval)
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
*retval = nullptr;
|
2001-09-05 03:30:24 +04:00
|
|
|
if (mCurrentPosition) {
|
|
|
|
CallQueryInterface(mCurrentPosition->mWindow, retval);
|
|
|
|
mCurrentPosition = FindNext();
|
2018-08-19 04:28:10 +03:00
|
|
|
return NS_OK;
|
2001-09-05 03:30:24 +04:00
|
|
|
}
|
2018-08-19 04:28:10 +03:00
|
|
|
return NS_ERROR_FAILURE;
|
2003-09-08 04:31:50 +04:00
|
|
|
}
|
2001-09-05 03:30:24 +04:00
|
|
|
|
2009-01-03 07:06:52 +03:00
|
|
|
//
|
|
|
|
// nsASDOMWindowEarlyToLateEnumerator
|
|
|
|
//
|
2001-09-05 03:30:24 +04:00
|
|
|
|
|
|
|
nsASDOMWindowEarlyToLateEnumerator::nsASDOMWindowEarlyToLateEnumerator(
|
2014-01-04 19:02:17 +04:00
|
|
|
const char16_t *aTypeString,
|
2001-09-05 03:30:24 +04:00
|
|
|
nsWindowMediator &aMediator) :
|
2009-01-03 07:06:52 +03:00
|
|
|
nsASDOMWindowEnumerator(aTypeString, aMediator)
|
|
|
|
{
|
2001-09-05 03:30:24 +04:00
|
|
|
mCurrentPosition = aMediator.mOldestWindow;
|
|
|
|
AdjustInitialPosition();
|
|
|
|
}
|
|
|
|
|
2009-01-03 07:06:52 +03:00
|
|
|
nsASDOMWindowEarlyToLateEnumerator::~nsASDOMWindowEarlyToLateEnumerator()
|
|
|
|
{
|
2001-09-05 03:30:24 +04:00
|
|
|
}
|
|
|
|
|
2009-01-03 07:06:52 +03:00
|
|
|
nsWindowInfo *nsASDOMWindowEarlyToLateEnumerator::FindNext()
|
|
|
|
{
|
2001-09-05 03:30:24 +04:00
|
|
|
nsWindowInfo *info,
|
|
|
|
*listEnd;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool allWindows = mType.IsEmpty();
|
2001-09-05 03:30:24 +04:00
|
|
|
|
|
|
|
// see nsXULWindowEarlyToLateEnumerator::FindNext
|
|
|
|
if (!mCurrentPosition)
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2001-09-05 03:30:24 +04:00
|
|
|
|
|
|
|
info = mCurrentPosition->mYounger;
|
|
|
|
listEnd = mWindowMediator->mOldestWindow;
|
|
|
|
|
|
|
|
while (info != listEnd) {
|
|
|
|
if (allWindows || info->TypeEquals(mType))
|
|
|
|
return info;
|
|
|
|
info = info->mYounger;
|
|
|
|
}
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2001-09-05 03:30:24 +04:00
|
|
|
}
|
|
|
|
|
2009-01-03 07:06:52 +03:00
|
|
|
//
|
|
|
|
// nsASXULWindowEarlyToLateEnumerator
|
|
|
|
//
|
2001-09-05 03:30:24 +04:00
|
|
|
|
|
|
|
nsASXULWindowEarlyToLateEnumerator::nsASXULWindowEarlyToLateEnumerator(
|
2014-01-04 19:02:17 +04:00
|
|
|
const char16_t *aTypeString,
|
2001-09-05 03:30:24 +04:00
|
|
|
nsWindowMediator &aMediator) :
|
2009-01-03 07:06:52 +03:00
|
|
|
nsASXULWindowEnumerator(aTypeString, aMediator)
|
|
|
|
{
|
2001-09-05 03:30:24 +04:00
|
|
|
mCurrentPosition = aMediator.mOldestWindow;
|
|
|
|
AdjustInitialPosition();
|
|
|
|
}
|
|
|
|
|
2009-01-03 07:06:52 +03:00
|
|
|
nsASXULWindowEarlyToLateEnumerator::~nsASXULWindowEarlyToLateEnumerator()
|
|
|
|
{
|
2001-09-05 03:30:24 +04:00
|
|
|
}
|
|
|
|
|
2009-01-03 07:06:52 +03:00
|
|
|
nsWindowInfo *nsASXULWindowEarlyToLateEnumerator::FindNext()
|
|
|
|
{
|
2001-09-05 03:30:24 +04:00
|
|
|
nsWindowInfo *info,
|
|
|
|
*listEnd;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool allWindows = mType.IsEmpty();
|
2001-09-05 03:30:24 +04:00
|
|
|
|
|
|
|
/* mCurrentPosition null is assumed to mean that the enumerator has run
|
|
|
|
its course and is now basically useless. It could also be interpreted
|
|
|
|
to mean that it was created at a time when there were no windows. In
|
|
|
|
that case it would probably be more appropriate to check to see whether
|
|
|
|
windows have subsequently been added. But it's not guaranteed that we'll
|
|
|
|
pick up newly added windows anyway (if they occurred previous to our
|
|
|
|
current position) so we just don't worry about that. */
|
|
|
|
if (!mCurrentPosition)
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2001-09-05 03:30:24 +04:00
|
|
|
|
|
|
|
info = mCurrentPosition->mYounger;
|
|
|
|
listEnd = mWindowMediator->mOldestWindow;
|
|
|
|
|
|
|
|
while (info != listEnd) {
|
|
|
|
if (allWindows || info->TypeEquals(mType))
|
|
|
|
return info;
|
|
|
|
info = info->mYounger;
|
|
|
|
}
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2001-09-05 03:30:24 +04:00
|
|
|
}
|
|
|
|
|
2009-01-03 07:06:52 +03:00
|
|
|
//
|
|
|
|
// nsASDOMWindowFrontToBackEnumerator
|
|
|
|
//
|
2001-09-05 03:30:24 +04:00
|
|
|
|
|
|
|
nsASDOMWindowFrontToBackEnumerator::nsASDOMWindowFrontToBackEnumerator(
|
2014-01-04 19:02:17 +04:00
|
|
|
const char16_t *aTypeString,
|
2001-09-05 03:30:24 +04:00
|
|
|
nsWindowMediator &aMediator) :
|
2009-01-03 07:06:52 +03:00
|
|
|
nsASDOMWindowEnumerator(aTypeString, aMediator)
|
|
|
|
{
|
2001-09-05 03:30:24 +04:00
|
|
|
mCurrentPosition = aMediator.mTopmostWindow;
|
|
|
|
AdjustInitialPosition();
|
|
|
|
}
|
|
|
|
|
2009-01-03 07:06:52 +03:00
|
|
|
nsASDOMWindowFrontToBackEnumerator::~nsASDOMWindowFrontToBackEnumerator()
|
|
|
|
{
|
2001-09-05 03:30:24 +04:00
|
|
|
}
|
|
|
|
|
2009-01-03 07:06:52 +03:00
|
|
|
nsWindowInfo *nsASDOMWindowFrontToBackEnumerator::FindNext()
|
|
|
|
{
|
2001-09-05 03:30:24 +04:00
|
|
|
nsWindowInfo *info,
|
|
|
|
*listEnd;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool allWindows = mType.IsEmpty();
|
2001-09-05 03:30:24 +04:00
|
|
|
|
|
|
|
// see nsXULWindowEarlyToLateEnumerator::FindNext
|
|
|
|
if (!mCurrentPosition)
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2001-09-05 03:30:24 +04:00
|
|
|
|
|
|
|
info = mCurrentPosition->mLower;
|
|
|
|
listEnd = mWindowMediator->mTopmostWindow;
|
|
|
|
|
|
|
|
while (info != listEnd) {
|
|
|
|
if (allWindows || info->TypeEquals(mType))
|
|
|
|
return info;
|
|
|
|
info = info->mLower;
|
|
|
|
}
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2001-09-05 03:30:24 +04:00
|
|
|
}
|
|
|
|
|
2009-01-03 07:06:52 +03:00
|
|
|
//
|
|
|
|
// nsASXULWindowFrontToBackEnumerator
|
|
|
|
//
|
2001-09-05 03:30:24 +04:00
|
|
|
|
|
|
|
nsASXULWindowFrontToBackEnumerator::nsASXULWindowFrontToBackEnumerator(
|
2014-01-04 19:02:17 +04:00
|
|
|
const char16_t *aTypeString,
|
2001-09-05 03:30:24 +04:00
|
|
|
nsWindowMediator &aMediator) :
|
2009-01-03 07:06:52 +03:00
|
|
|
nsASXULWindowEnumerator(aTypeString, aMediator)
|
|
|
|
{
|
2001-09-05 03:30:24 +04:00
|
|
|
mCurrentPosition = aMediator.mTopmostWindow;
|
|
|
|
AdjustInitialPosition();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsASXULWindowFrontToBackEnumerator::~nsASXULWindowFrontToBackEnumerator()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-01-03 07:06:52 +03:00
|
|
|
nsWindowInfo *nsASXULWindowFrontToBackEnumerator::FindNext()
|
|
|
|
{
|
2001-09-05 03:30:24 +04:00
|
|
|
nsWindowInfo *info,
|
|
|
|
*listEnd;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool allWindows = mType.IsEmpty();
|
2001-09-05 03:30:24 +04:00
|
|
|
|
|
|
|
// see nsXULWindowEarlyToLateEnumerator::FindNext
|
|
|
|
if (!mCurrentPosition)
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2001-09-05 03:30:24 +04:00
|
|
|
|
|
|
|
info = mCurrentPosition->mLower;
|
|
|
|
listEnd = mWindowMediator->mTopmostWindow;
|
|
|
|
|
|
|
|
while (info != listEnd) {
|
|
|
|
if (allWindows || info->TypeEquals(mType))
|
|
|
|
return info;
|
|
|
|
info = info->mLower;
|
|
|
|
}
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2001-09-05 03:30:24 +04:00
|
|
|
}
|
|
|
|
|
2009-01-03 07:06:52 +03:00
|
|
|
//
|
|
|
|
// nsASDOMWindowBackToFrontEnumerator
|
|
|
|
//
|
2001-09-05 03:30:24 +04:00
|
|
|
|
|
|
|
nsASDOMWindowBackToFrontEnumerator::nsASDOMWindowBackToFrontEnumerator(
|
2014-01-04 19:02:17 +04:00
|
|
|
const char16_t *aTypeString,
|
2001-09-05 03:30:24 +04:00
|
|
|
nsWindowMediator &aMediator) :
|
2009-01-03 07:06:52 +03:00
|
|
|
nsASDOMWindowEnumerator(aTypeString, aMediator)
|
|
|
|
{
|
2001-09-05 03:30:24 +04:00
|
|
|
mCurrentPosition = aMediator.mTopmostWindow ?
|
2012-07-30 18:20:58 +04:00
|
|
|
aMediator.mTopmostWindow->mHigher : nullptr;
|
2001-09-05 03:30:24 +04:00
|
|
|
AdjustInitialPosition();
|
|
|
|
}
|
|
|
|
|
2009-01-03 07:06:52 +03:00
|
|
|
nsASDOMWindowBackToFrontEnumerator::~nsASDOMWindowBackToFrontEnumerator()
|
|
|
|
{
|
2001-09-05 03:30:24 +04:00
|
|
|
}
|
|
|
|
|
2009-01-03 07:06:52 +03:00
|
|
|
nsWindowInfo *nsASDOMWindowBackToFrontEnumerator::FindNext()
|
|
|
|
{
|
2001-09-05 03:30:24 +04:00
|
|
|
nsWindowInfo *info,
|
|
|
|
*listEnd;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool allWindows = mType.IsEmpty();
|
2001-09-05 03:30:24 +04:00
|
|
|
|
|
|
|
// see nsXULWindowEarlyToLateEnumerator::FindNext
|
|
|
|
if (!mCurrentPosition)
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2001-09-05 03:30:24 +04:00
|
|
|
|
|
|
|
info = mCurrentPosition->mHigher;
|
|
|
|
listEnd = mWindowMediator->mTopmostWindow;
|
|
|
|
if (listEnd)
|
|
|
|
listEnd = listEnd->mHigher;
|
|
|
|
|
|
|
|
while (info != listEnd) {
|
|
|
|
if (allWindows || info->TypeEquals(mType))
|
|
|
|
return info;
|
|
|
|
info = info->mHigher;
|
|
|
|
}
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2001-09-05 03:30:24 +04:00
|
|
|
}
|
|
|
|
|
2009-01-03 07:06:52 +03:00
|
|
|
//
|
|
|
|
// nsASXULWindowBackToFrontEnumerator
|
|
|
|
//
|
2001-09-05 03:30:24 +04:00
|
|
|
|
|
|
|
nsASXULWindowBackToFrontEnumerator::nsASXULWindowBackToFrontEnumerator(
|
2014-01-04 19:02:17 +04:00
|
|
|
const char16_t *aTypeString,
|
2001-09-05 03:30:24 +04:00
|
|
|
nsWindowMediator &aMediator) :
|
2009-01-03 07:06:52 +03:00
|
|
|
nsASXULWindowEnumerator(aTypeString, aMediator)
|
|
|
|
{
|
2001-09-05 03:30:24 +04:00
|
|
|
mCurrentPosition = aMediator.mTopmostWindow ?
|
2012-07-30 18:20:58 +04:00
|
|
|
aMediator.mTopmostWindow->mHigher : nullptr;
|
2001-09-05 03:30:24 +04:00
|
|
|
AdjustInitialPosition();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsASXULWindowBackToFrontEnumerator::~nsASXULWindowBackToFrontEnumerator()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-01-03 07:06:52 +03:00
|
|
|
nsWindowInfo *nsASXULWindowBackToFrontEnumerator::FindNext()
|
|
|
|
{
|
2001-09-05 03:30:24 +04:00
|
|
|
nsWindowInfo *info,
|
|
|
|
*listEnd;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool allWindows = mType.IsEmpty();
|
2001-09-05 03:30:24 +04:00
|
|
|
|
|
|
|
// see nsXULWindowEarlyToLateEnumerator::FindNext
|
|
|
|
if (!mCurrentPosition)
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2001-09-05 03:30:24 +04:00
|
|
|
|
|
|
|
info = mCurrentPosition->mHigher;
|
|
|
|
listEnd = mWindowMediator->mTopmostWindow;
|
|
|
|
if (listEnd)
|
|
|
|
listEnd = listEnd->mHigher;
|
|
|
|
|
|
|
|
while (info != listEnd) {
|
|
|
|
if (allWindows || info->TypeEquals(mType))
|
|
|
|
return info;
|
|
|
|
info = info->mHigher;
|
|
|
|
}
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2001-09-05 03:30:24 +04:00
|
|
|
}
|