Bug 868727 - Pass an nsAString to nsGlobalWindow::GetChildWindow; r=bz

This commit is contained in:
Ms2ger 2013-05-05 09:03:19 +02:00
parent afaa2a6431
commit 65037ba176
4 changed files with 12 additions and 9 deletions

View File

@ -3121,6 +3121,7 @@ static JSBool
ChildWindowGetter(JSContext *cx, JSHandleObject obj, JSHandleId id,
JSMutableHandleValue vp)
{
MOZ_ASSERT(JSID_IS_STRING(id));
// Grab the native DOM window.
vp.setUndefined();
nsCOMPtr<nsISupports> winSupports =
@ -3130,7 +3131,8 @@ ChildWindowGetter(JSContext *cx, JSHandleObject obj, JSHandleId id,
nsGlobalWindow *win = nsGlobalWindow::FromSupports(winSupports);
// Find the child, if it exists.
nsCOMPtr<nsIDOMWindow> child = win->GetChildWindow(id);
nsDependentJSString name(id);
nsCOMPtr<nsIDOMWindow> child = win->GetChildWindow(name);
if (!child)
return true;
@ -3174,7 +3176,8 @@ nsWindowSH::GlobalScopePolluterNewResolve(JSContext *cx, JSHandleObject obj,
nsGlobalWindow* win = static_cast<nsGlobalWindow*>(piWin.get());
if (win->GetLength() > 0) {
nsCOMPtr<nsIDOMWindow> child_win = win->GetChildWindow(id);
nsDependentJSString name(id);
nsCOMPtr<nsIDOMWindow> child_win = win->GetChildWindow(name);
if (child_win) {
// We found a subframe of the right name, so define the property
// on the GSP. This property is a read-only accessor. Shadowing via

View File

@ -3518,7 +3518,8 @@ nsGlobalWindow::GetContent(nsIDOMWindow** aContent)
*aContent = nullptr;
// First check for a named frame named "content"
nsCOMPtr<nsIDOMWindow> domWindow = GetChildWindow(nsDOMClassInfo::sContent_id);
nsCOMPtr<nsIDOMWindow> domWindow =
GetChildWindow(NS_LITERAL_STRING("content"));
if (domWindow) {
domWindow.forget(aContent);
return NS_OK;
@ -4800,15 +4801,13 @@ nsGlobalWindow::GetLength(uint32_t* aLength)
}
already_AddRefed<nsIDOMWindow>
nsGlobalWindow::GetChildWindow(jsid aName)
nsGlobalWindow::GetChildWindow(const nsAString& 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),
dsn->FindChildWithName(PromiseFlatString(aName).get(),
false, true, nullptr, nullptr,
getter_AddRefs(child));

View File

@ -459,7 +459,7 @@ public:
return nullptr;
}
already_AddRefed<nsIDOMWindow> GetChildWindow(jsid aName);
already_AddRefed<nsIDOMWindow> GetChildWindow(const nsAString& aName);
// Returns true if dialogs need to be prevented from appearings for this
// window. beingAbused returns whether dialogs are being abused.

View File

@ -1593,7 +1593,8 @@ XrayWrapper<Base, Traits>::getPropertyDescriptor(JSContext *cx, HandleObject wra
if (!desc->obj && Traits::Type == XrayForWrappedNative && JSID_IS_STRING(id) &&
(win = static_cast<nsGlobalWindow*>(As<nsPIDOMWindow>(wrapper))))
{
nsCOMPtr<nsIDOMWindow> childDOMWin = win->GetChildWindow(id);
nsDependentJSString name(id);
nsCOMPtr<nsIDOMWindow> childDOMWin = win->GetChildWindow(name);
if (childDOMWin) {
nsGlobalWindow *cwin = static_cast<nsGlobalWindow*>(childDOMWin.get());
JSObject *childObj = cwin->FastGetGlobalJSObject();