Skip to content

Commit a64e4f1

Browse files
committed
Bug 1322414 - part 1 - remove GetContentShellById and id passing, r=bz
MozReview-Commit-ID: FggtlNAP6ax --HG-- extra : rebase_source : 3e20f36001d5b19e334941c2638573ba838d2df7 extra : histedit_source : 3f47eea51d257f23b0a5ba655911aab4d43ba8d1
1 parent 359efd2 commit a64e4f1

File tree

10 files changed

+12
-193
lines changed

10 files changed

+12
-193
lines changed

docshell/base/nsIDocShellTreeOwner.idl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,9 @@ interface nsIDocShellTreeOwner : nsISupports
2323
*
2424
* @param aContentShell the shell being added.
2525
* @param aPrimary whether the shell is primary.
26-
* @param aID the "id" of the shell. What this actually means is
27-
* undefined. Don't rely on this for anything.
2826
*/
2927
void contentShellAdded(in nsIDocShellTreeItem aContentShell,
30-
in boolean aPrimary, in AString aID);
28+
in boolean aPrimary);
3129

3230
/**
3331
* Called when a content shell is removed from the docshell tree. This is

dom/base/nsFrameLoader.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,7 @@ nsFrameLoader::AddTreeItemToTreeOwner(nsIDocShellTreeItem* aItem,
10141014
if (aOwner) {
10151015
mOwnerContent->AddMutationObserver(this);
10161016
mObservingOwnerContent = true;
1017-
aOwner->ContentShellAdded(aItem, is_primary, value);
1017+
aOwner->ContentShellAdded(aItem, is_primary);
10181018
}
10191019
}
10201020

@@ -3337,7 +3337,7 @@ nsFrameLoader::AttributeChanged(nsIDocument* aDocument,
33373337
StringBeginsWith(value, NS_LITERAL_STRING("content-"),
33383338
nsCaseInsensitiveStringComparator())) {
33393339

3340-
parentTreeOwner->ContentShellAdded(mDocShell, is_primary, value);
3340+
parentTreeOwner->ContentShellAdded(mDocShell, is_primary);
33413341
}
33423342
}
33433343

embedding/browser/nsDocShellTreeOwner.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,10 +274,10 @@ nsDocShellTreeOwner::EnsureContentTreeOwner()
274274

275275
NS_IMETHODIMP
276276
nsDocShellTreeOwner::ContentShellAdded(nsIDocShellTreeItem* aContentShell,
277-
bool aPrimary, const nsAString& aID)
277+
bool aPrimary)
278278
{
279279
if (mTreeOwner)
280-
return mTreeOwner->ContentShellAdded(aContentShell, aPrimary, aID);
280+
return mTreeOwner->ContentShellAdded(aContentShell, aPrimary);
281281

282282
EnsureContentTreeOwner();
283283
aContentShell->SetTreeOwner(mContentTreeOwner);

xpfe/appshell/nsChromeTreeOwner.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,10 @@ NS_IMETHODIMP nsChromeTreeOwner::GetInterface(const nsIID& aIID, void** aSink)
139139

140140
NS_IMETHODIMP
141141
nsChromeTreeOwner::ContentShellAdded(nsIDocShellTreeItem* aContentShell,
142-
bool aPrimary, const nsAString& aID)
142+
bool aPrimary)
143143
{
144144
NS_ENSURE_STATE(mXULWindow);
145-
return mXULWindow->ContentShellAdded(aContentShell, aPrimary, aID);
145+
return mXULWindow->ContentShellAdded(aContentShell, aPrimary);
146146
}
147147

148148
NS_IMETHODIMP

xpfe/appshell/nsContentTreeOwner.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,10 @@ NS_IMETHODIMP nsContentTreeOwner::GetInterface(const nsIID& aIID, void** aSink)
172172

173173
NS_IMETHODIMP
174174
nsContentTreeOwner::ContentShellAdded(nsIDocShellTreeItem* aContentShell,
175-
bool aPrimary, const nsAString& aID)
175+
bool aPrimary)
176176
{
177177
NS_ENSURE_STATE(mXULWindow);
178-
return mXULWindow->ContentShellAdded(aContentShell, aPrimary, aID);
178+
return mXULWindow->ContentShellAdded(aContentShell, aPrimary);
179179
}
180180

181181
NS_IMETHODIMP

xpfe/appshell/nsIXULWindow.idl

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,6 @@ interface nsIXULWindow : nsISupports
5151
void tabParentAdded(in nsITabParent aTab, in boolean aPrimary);
5252
void tabParentRemoved(in nsITabParent aTab);
5353

54-
/**
55-
* The content shell specified by the supplied id.
56-
*
57-
* Note that this is a docshell tree item and therefore can not be assured of
58-
* what object it is. It could be an editor, a docshell, or a browser object.
59-
* Or down the road any other object that supports being a DocShellTreeItem
60-
* Query accordingly to determine the capabilities.
61-
*/
62-
nsIDocShellTreeItem getContentShellById(in wstring ID);
63-
6454
/**
6555
* Tell this window that it has picked up a child XUL window
6656
* @param aChild the child window being added

xpfe/appshell/nsWebShellWindow.cpp

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,6 @@ nsWebShellWindow::OnStateChange(nsIWebProgress *aProgress,
622622
#endif // USE_NATIVE_MENUS
623623

624624
OnChromeLoaded();
625-
LoadContentAreas();
626625

627626
return NS_OK;
628627
}
@@ -657,81 +656,6 @@ nsWebShellWindow::OnSecurityChange(nsIWebProgress *aWebProgress,
657656
}
658657

659658

660-
//----------------------------------------
661-
662-
// if the main document URL specified URLs for any content areas, start them loading
663-
void nsWebShellWindow::LoadContentAreas() {
664-
665-
nsAutoString searchSpec;
666-
667-
// fetch the chrome document URL
668-
nsCOMPtr<nsIContentViewer> contentViewer;
669-
// yes, it's possible for the docshell to be null even this early
670-
// see bug 57514.
671-
if (mDocShell)
672-
mDocShell->GetContentViewer(getter_AddRefs(contentViewer));
673-
if (contentViewer) {
674-
nsIDocument* doc = contentViewer->GetDocument();
675-
if (doc) {
676-
nsIURI* mainURL = doc->GetDocumentURI();
677-
678-
nsCOMPtr<nsIURL> url = do_QueryInterface(mainURL);
679-
if (url) {
680-
nsAutoCString search;
681-
url->GetQuery(search);
682-
683-
AppendUTF8toUTF16(search, searchSpec);
684-
}
685-
}
686-
}
687-
688-
// content URLs are specified in the search part of the URL
689-
// as <contentareaID>=<escapedURL>[;(repeat)]
690-
if (!searchSpec.IsEmpty()) {
691-
int32_t begPos,
692-
eqPos,
693-
endPos;
694-
nsString contentAreaID,
695-
contentURL;
696-
char *urlChar;
697-
nsresult rv;
698-
for (endPos = 0; endPos < (int32_t)searchSpec.Length(); ) {
699-
// extract contentAreaID and URL substrings
700-
begPos = endPos;
701-
eqPos = searchSpec.FindChar('=', begPos);
702-
if (eqPos < 0)
703-
break;
704-
705-
endPos = searchSpec.FindChar(';', eqPos);
706-
if (endPos < 0)
707-
endPos = searchSpec.Length();
708-
searchSpec.Mid(contentAreaID, begPos, eqPos-begPos);
709-
searchSpec.Mid(contentURL, eqPos+1, endPos-eqPos-1);
710-
endPos++;
711-
712-
// see if we have a docshell with a matching contentAreaID
713-
nsCOMPtr<nsIDocShellTreeItem> content;
714-
rv = GetContentShellById(contentAreaID.get(), getter_AddRefs(content));
715-
if (NS_SUCCEEDED(rv) && content) {
716-
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(content));
717-
if (webNav) {
718-
urlChar = ToNewCString(contentURL);
719-
if (urlChar) {
720-
nsUnescape(urlChar);
721-
contentURL.AssignWithConversion(urlChar);
722-
webNav->LoadURI(contentURL.get(),
723-
nsIWebNavigation::LOAD_FLAGS_NONE,
724-
nullptr,
725-
nullptr,
726-
nullptr);
727-
free(urlChar);
728-
}
729-
}
730-
}
731-
}
732-
}
733-
}
734-
735659
/**
736660
* ExecuteCloseHandler - Run the close handler, if any.
737661
* @return true iff we found a close handler to run.

xpfe/appshell/nsWebShellWindow.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ class nsWebShellWindow final : public nsXULWindow,
7070

7171
virtual ~nsWebShellWindow();
7272

73-
void LoadContentAreas();
7473
bool ExecuteCloseHandler();
7574
void ConstrainToOpenerScreen(int32_t* aX, int32_t* aY);
7675

xpfe/appshell/nsXULWindow.cpp

Lines changed: 2 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -344,25 +344,6 @@ nsXULWindow::GetPrimaryTabParent(nsITabParent** aTab)
344344
return NS_OK;
345345
}
346346

347-
NS_IMETHODIMP nsXULWindow::GetContentShellById(const char16_t* aID,
348-
nsIDocShellTreeItem** aDocShellTreeItem)
349-
{
350-
NS_ENSURE_ARG_POINTER(aDocShellTreeItem);
351-
*aDocShellTreeItem = nullptr;
352-
353-
uint32_t count = mContentShells.Length();
354-
for (uint32_t i = 0; i < count; i++) {
355-
nsContentShellInfo* shellInfo = mContentShells.ElementAt(i);
356-
if (shellInfo->id.Equals(aID)) {
357-
*aDocShellTreeItem = nullptr;
358-
if (shellInfo->child)
359-
CallQueryReferent(shellInfo->child.get(), aDocShellTreeItem);
360-
return NS_OK;
361-
}
362-
}
363-
return NS_ERROR_FAILURE;
364-
}
365-
366347
NS_IMETHODIMP nsXULWindow::AddChildWindow(nsIXULWindow *aChild)
367348
{
368349
// we're not really keeping track of this right now
@@ -510,13 +491,6 @@ NS_IMETHODIMP nsXULWindow::Destroy()
510491
mDocShell = nullptr; // this can cause reentrancy of this function
511492
}
512493

513-
// Remove our ref on the content shells
514-
uint32_t count = mContentShells.Length();
515-
for (uint32_t i = 0; i < count; i++) {
516-
nsContentShellInfo* shellInfo = mContentShells.ElementAt(i);
517-
delete shellInfo;
518-
}
519-
mContentShells.Clear();
520494
mPrimaryContentShell = nullptr;
521495

522496
if (mContentTreeOwner) {
@@ -1685,28 +1659,8 @@ nsXULWindow::GetWindowDOMElement() const
16851659
}
16861660

16871661
nsresult nsXULWindow::ContentShellAdded(nsIDocShellTreeItem* aContentShell,
1688-
bool aPrimary, const nsAString& aID)
1689-
{
1690-
nsContentShellInfo* shellInfo = nullptr;
1691-
1692-
uint32_t i, count = mContentShells.Length();
1693-
nsWeakPtr contentShellWeak = do_GetWeakReference(aContentShell);
1694-
for (i = 0; i < count; i++) {
1695-
nsContentShellInfo* info = mContentShells.ElementAt(i);
1696-
if (info->id.Equals(aID)) {
1697-
// We already exist. Do a replace.
1698-
info->child = contentShellWeak;
1699-
shellInfo = info;
1700-
}
1701-
else if (info->child == contentShellWeak)
1702-
info->child = nullptr;
1703-
}
1704-
1705-
if (!shellInfo) {
1706-
shellInfo = new nsContentShellInfo(aID, contentShellWeak);
1707-
mContentShells.AppendElement(shellInfo);
1708-
}
1709-
1662+
bool aPrimary)
1663+
{
17101664
// Set the default content tree owner
17111665
if (aPrimary) {
17121666
NS_ENSURE_SUCCESS(EnsurePrimaryContentTreeOwner(), NS_ERROR_FAILURE);
@@ -1729,17 +1683,6 @@ nsresult nsXULWindow::ContentShellRemoved(nsIDocShellTreeItem* aContentShell)
17291683
if (mPrimaryContentShell == aContentShell) {
17301684
mPrimaryContentShell = nullptr;
17311685
}
1732-
1733-
int32_t i, count = mContentShells.Length();
1734-
for (i = count - 1; i >= 0; --i) {
1735-
nsContentShellInfo* info = mContentShells.ElementAt(i);
1736-
nsCOMPtr<nsIDocShellTreeItem> curItem = do_QueryReferent(info->child);
1737-
if (!curItem || SameCOMIdentity(curItem, aContentShell)) {
1738-
mContentShells.RemoveElementAt(i);
1739-
delete info;
1740-
}
1741-
}
1742-
17431686
return NS_OK;
17441687
}
17451688

@@ -2271,20 +2214,3 @@ nsXULWindow::GetTabCount(uint32_t* aResult)
22712214
return NS_OK;
22722215
}
22732216

2274-
//*****************************************************************************
2275-
//*** nsContentShellInfo: Object Management
2276-
//*****************************************************************************
2277-
2278-
nsContentShellInfo::nsContentShellInfo(const nsAString& aID,
2279-
nsIWeakReference* aContentShell)
2280-
: id(aID),
2281-
child(aContentShell)
2282-
{
2283-
MOZ_COUNT_CTOR(nsContentShellInfo);
2284-
}
2285-
2286-
nsContentShellInfo::~nsContentShellInfo()
2287-
{
2288-
MOZ_COUNT_DTOR(nsContentShellInfo);
2289-
//XXX Set Tree Owner to null if the tree owner is nsXULWindow->mContentTreeOwner
2290-
}

xpfe/appshell/nsXULWindow.h

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,7 @@ friend class nsContentTreeOwner;
106106

107107
// See nsIDocShellTreeOwner for docs on next two methods
108108
nsresult ContentShellAdded(nsIDocShellTreeItem* aContentShell,
109-
bool aPrimary,
110-
const nsAString& aID);
109+
bool aPrimary);
111110
nsresult ContentShellRemoved(nsIDocShellTreeItem* aContentShell);
112111
NS_IMETHOD GetPrimaryContentSize(int32_t* aWidth,
113112
int32_t* aHeight);
@@ -146,7 +145,6 @@ friend class nsContentTreeOwner;
146145
nsCOMPtr<nsIAuthPrompt> mAuthPrompter;
147146
nsCOMPtr<nsIXULBrowserWindow> mXULBrowserWindow;
148147
nsCOMPtr<nsIDocShellTreeItem> mPrimaryContentShell;
149-
nsTArray<nsContentShellInfo*> mContentShells; // array of doc shells by id
150148
nsresult mModalStatus;
151149
bool mContinueModalLoop;
152150
bool mDebuting; // being made visible right now
@@ -178,20 +176,4 @@ friend class nsContentTreeOwner;
178176
};
179177

180178
NS_DEFINE_STATIC_IID_ACCESSOR(nsXULWindow, NS_XULWINDOW_IMPL_CID)
181-
182-
// nsContentShellInfo
183-
// Used to map shell IDs to nsIDocShellTreeItems.
184-
185-
class nsContentShellInfo
186-
{
187-
public:
188-
nsContentShellInfo(const nsAString& aID,
189-
nsIWeakReference* aContentShell);
190-
~nsContentShellInfo();
191-
192-
public:
193-
nsString id; // The identifier of the content shell
194-
nsWeakPtr child; // content shell (weak reference to nsIDocShellTreeItem)
195-
};
196-
197179
#endif /* nsXULWindow_h__ */

0 commit comments

Comments
 (0)