/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* 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/. */
// generic "retrieve the value of a XUL attribute" function void GetAttribute(nsIAppWindow* inWindow, const nsAString& inAttribute,
nsAString& outValue) {
nsCOMPtr<nsIDocShell> shell; if (inWindow && NS_SUCCEEDED(inWindow->GetDocShell(getter_AddRefs(shell)))) {
RefPtr<Element> webshellElement = GetElementFromDocShell(shell); if (webshellElement) {
webshellElement->GetAttribute(inAttribute, outValue);
}
}
}
// retrieve the window type, stored as the value of a particular // attribute in its XUL window tag void GetWindowType(nsIAppWindow* aWindow, nsString& outType) {
GetAttribute(aWindow, u"windowtype"_ns, outType);
}
// return true if the window described by this WindowInfo has a type // equal to the given type bool nsWindowInfo::TypeEquals(const nsAString& aType) {
nsAutoString rtnString;
GetWindowType(mWindow, rtnString); return rtnString == aType;
}
// insert the struct into their two linked lists, in position after the // given (independent) method arguments void nsWindowInfo::InsertAfter(nsWindowInfo* inOlder, nsWindowInfo* inHigher) { 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 void nsWindowInfo::Unlink(bool inAge, bool inZ) { if (inAge) {
mOlder->mYounger = mYounger;
mYounger->mOlder = mOlder;
} if (inZ) {
mLower->mHigher = mHigher;
mHigher->mLower = mLower;
}
ReferenceSelf(inAge, inZ);
}
// initialize the struct to be a valid linked list of one element void nsWindowInfo::ReferenceSelf(bool inAge, bool inZ) { if (inAge) {
mYounger = this;
mOlder = this;
} if (inZ) {
mLower = this;
mHigher = this;
}
}
// after mCurrentPosition has been initialized to point to the beginning // of the appropriate list, adjust it if necessary void nsAppShellWindowEnumerator::AdjustInitialPosition() { if (!mType.IsEmpty() && mCurrentPosition &&
!mCurrentPosition->TypeEquals(mType))
mCurrentPosition = FindNext();
}
NS_IMETHODIMP nsAppShellWindowEnumerator::HasMoreElements(bool* retval) { if (!retval) return NS_ERROR_INVALID_ARG;
// if a window is being removed adjust the iterator's current position void nsAppShellWindowEnumerator::WindowRemoved(nsWindowInfo* inInfo) { if (mCurrentPosition == inInfo) mCurrentPosition = FindNext();
}
/* 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) return nullptr;
info = mCurrentPosition->mYounger;
listEnd = mWindowMediator->mOldestWindow;
while (info != listEnd) { if (allWindows || info->TypeEquals(mType)) return info;
info = info->mYounger;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.