Bug 850517 - Factor out child window lookup into a helper. r=mrbkap

This commit is contained in:
Bobby Holley 2013-03-14 22:38:26 -07:00
parent 595f5e3955
commit 4a97aa3720
3 changed files with 20 additions and 12 deletions

View File

@ -5486,18 +5486,7 @@ nsWindowSH::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
if (!ObjectIsNativeWrapper(cx, obj) ||
xpc::WrapperFactory::XrayWrapperNotShadowing(obj, id)) {
if (win->GetLength() > 0) {
const jschar *chars = ::JS_GetInternedStringChars(JSID_TO_STRING(id));
nsCOMPtr<nsIDocShellTreeNode> dsn(do_QueryInterface(win->GetDocShell()));
MOZ_ASSERT(dsn);
nsCOMPtr<nsIDocShellTreeItem> child;
dsn->FindChildWithName(reinterpret_cast<const PRUnichar*>(chars),
false, true, nullptr, nullptr,
getter_AddRefs(child));
nsCOMPtr<nsIDOMWindow> child_win(do_GetInterface(child));
nsCOMPtr<nsIDOMWindow> child_win = win->GetChildWindow(id);
if (child_win) {
// We found a subframe of the right name, define the property
// on the wrapper so that ::NewResolve() doesn't get called

View File

@ -4627,6 +4627,23 @@ nsGlobalWindow::GetLength(uint32_t* aLength)
return NS_OK;
}
already_AddRefed<nsIDOMWindow>
nsGlobalWindow::GetChildWindow(jsid aName)
{
const jschar *chars = JS_GetInternedStringChars(JSID_TO_STRING(aName));
nsCOMPtr<nsIDocShellTreeNode> dsn(do_QueryInterface(GetDocShell()));
NS_ENSURE_TRUE(dsn, nullptr);
nsCOMPtr<nsIDocShellTreeItem> child;
dsn->FindChildWithName(reinterpret_cast<const PRUnichar*>(chars),
false, true, nullptr, nullptr,
getter_AddRefs(child));
nsCOMPtr<nsIDOMWindow> child_win(do_GetInterface(child));
return child_win.forget();
}
bool
nsGlobalWindow::DispatchCustomEvent(const char *aEventName)
{

View File

@ -436,6 +436,8 @@ public:
return nullptr;
}
already_AddRefed<nsIDOMWindow> GetChildWindow(jsid aName);
// Returns true if dialogs need to be prevented from appearings for this
// window. beingAbused returns whether dialogs are being abused.
bool DialogsAreBlocked(bool *aBeingAbused);