diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp
index a48f7b272023..f6030f8a823f 100644
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -1428,6 +1428,15 @@ nsDocShell::SetName(const PRUnichar * aName)
return NS_OK;
}
+NS_IMETHODIMP
+nsDocShell::NameEquals(const PRUnichar *aName, PRBool *_retval)
+{
+ NS_ENSURE_ARG_POINTER(aName);
+ NS_ENSURE_ARG_POINTER(_retval);
+ *_retval = mName.Equals(aName);
+ return NS_OK;
+}
+
NS_IMETHODIMP
nsDocShell::GetItemType(PRInt32 * aItemType)
{
@@ -1908,7 +1917,6 @@ nsDocShell::FindChildWithName(const PRUnichar * aName,
*_retval = nsnull; // if we don't find one, we return NS_OK and a null result
- nsDependentString name(aName);
nsXPIDLString childName;
PRInt32 i, n = mChildren.Count();
for (i = 0; i < n; i++) {
@@ -1920,8 +1928,9 @@ nsDocShell::FindChildWithName(const PRUnichar * aName,
if (aSameType && (childType != mItemType))
continue;
- child->GetName(getter_Copies(childName));
- if (name.Equals(childName)) {
+ PRBool childNameEquals = PR_FALSE;
+ child->NameEquals(aName, &childNameEquals);
+ if (childNameEquals) {
*_retval = child;
NS_ADDREF(*_retval);
break;
diff --git a/docshell/base/nsIDocShellTreeItem.idl b/docshell/base/nsIDocShellTreeItem.idl
index 09f48a23b83a..0d6adb86718e 100644
--- a/docshell/base/nsIDocShellTreeItem.idl
+++ b/docshell/base/nsIDocShellTreeItem.idl
@@ -39,6 +39,15 @@ interface nsIDocShellTreeItem : nsISupports
*/
attribute wstring name;
+ /**
+ * Compares the provided name against the item's name and
+ * returns the appropriate result.
+ *
+ * @return PR_TRUE
if names match;
+ * PR_FALSE
otherwise.
+ */
+ boolean nameEquals(in wstring name);
+
/*
Definitions for the item types.
*/
diff --git a/embedding/browser/webBrowser/nsWebBrowser.cpp b/embedding/browser/webBrowser/nsWebBrowser.cpp
index 2a480357f11e..b178aa721d9b 100644
--- a/embedding/browser/webBrowser/nsWebBrowser.cpp
+++ b/embedding/browser/webBrowser/nsWebBrowser.cpp
@@ -397,6 +397,22 @@ NS_IMETHODIMP nsWebBrowser::SetName(const PRUnichar* aName)
return NS_OK;
}
+NS_IMETHODIMP nsWebBrowser::NameEquals(const PRUnichar *aName, PRBool *_retval)
+{
+ NS_ENSURE_ARG_POINTER(aName);
+ NS_ENSURE_ARG_POINTER(_retval);
+ if(mDocShell)
+ {
+ nsCOMPtr docShellAsItem(do_QueryInterface(mDocShell));
+ NS_ENSURE_TRUE(docShellAsItem, NS_ERROR_FAILURE);
+ return docShellAsItem->NameEquals(aName, _retval);
+ }
+ else
+ *_retval = mInitInfo->name.Equals(aName);
+
+ return NS_OK;
+}
+
NS_IMETHODIMP nsWebBrowser::GetItemType(PRInt32* aItemType)
{
NS_ENSURE_ARG_POINTER(aItemType);