Bug 130078. Integrate all view managers in a given top-level window into a single view manager tree. r+sr=dbaron

This commit is contained in:
roc+%cs.cmu.edu 2005-08-18 17:14:29 +00:00
Родитель 971dd68989
Коммит 1da9d9ae96
3 изменённых файлов: 30 добавлений и 34 удалений

Просмотреть файл

@ -2124,37 +2124,6 @@ DocumentViewerImpl::MakeWindow(nsIWidget* aParentWidget,
// if aParentWidget has a view, we'll hook our view manager up to its view tree
nsIView* containerView = nsView::GetViewFor(aParentWidget);
if (containerView) {
// see if the containerView has already been hooked into a foreign view manager hierarchy
// if it has, then we have to hook into the hierarchy too otherwise bad things will happen.
nsIViewManager* containerVM = containerView->GetViewManager();
nsIView* pView = containerView;
do {
pView = pView->GetParent();
} while (pView && pView->GetViewManager() == containerVM);
if (!pView) {
// OK, so the container is not already hooked up into a foreign view manager hierarchy.
// That means we can choose not to hook ourselves up.
//
// If the parent container is a chrome shell then we won't hook into its view
// tree. This will improve performance a little bit (especially given scrolling/painting perf bugs)
// but is really just for peace of mind. This check can be removed if we want to support fancy
// chrome effects like transparent controls floating over content, transparent Web browsers, and
// things like that, and the perf bugs are fixed.
nsCOMPtr<nsIDocShellTreeItem> container(do_QueryReferent(mContainer));
nsCOMPtr<nsIDocShellTreeItem> parentContainer;
PRInt32 itemType;
if (nsnull == container
|| NS_FAILED(container->GetParent(getter_AddRefs(parentContainer)))
|| nsnull == parentContainer
|| NS_FAILED(parentContainer->GetItemType(&itemType))
|| itemType != nsIDocShellTreeItem::typeContent) {
containerView = nsnull;
}
}
}
// Create a view
nsIView* view = mViewManager->CreateView(tbounds, containerView);
if (!view)

Просмотреть файл

@ -312,7 +312,7 @@
<field name="mPrefs" readonly="true">
Components.classes['@mozilla.org/preferences-service;1']
.getService(Components.interfaces.nsIPrefService)
.getBranch(null);
.getBranch(null).QueryInterface(Components.interfaces.nsIPrefBranch2);
</field>
<field name="mAtomService" readonly="true">
@ -570,6 +570,9 @@
this.addEventListener("pageshow", this.onPageShow, true);
this.addEventListener("pagehide", this.onPageHide, true);
this.addEventListener("DOMPopupBlocked", this.onPopupBlocked, false);
mPrefs.addObserver("browser.display.background_color", this, false);
this.observe(null, "nsPref:changed", "browser.display.background_color");
]]>
</constructor>
@ -610,6 +613,7 @@
this.removeEventListener("pageshow", this.onPageShow, true);
this.removeEventListener("pagehide", this.onPageHide, true);
this.removeEventListener("DOMPopupBlocked", this.onPopupBlocked, true);
this.mPrefs.removeObserver("browser.display.background_color", this);
]]>
</body>
</method>
@ -620,6 +624,11 @@
<parameter name="aState"/>
<body>
<![CDATA[
if (aTopic == "nsPref:changed" && aState == "browser.display.background_color") {
this.style.backgroundColor = this.mPrefs.getCharPref("browser.display.background_color");
return;
}
if (aTopic != "browser:purge-session-history")
return;

Просмотреть файл

@ -42,7 +42,7 @@
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="browser" extends="xul:browser">
<implementation type="application/x-javascript" implements="nsIAccessibleProvider">
<implementation type="application/x-javascript" implements="nsIAccessibleProvider, nsIObserver">
<property name="accessible">
<getter>
<![CDATA[
@ -256,7 +256,7 @@
<field name="mPrefs" readonly="true">
Components.classes['@mozilla.org/preferences-service;1']
.getService(Components.interfaces.nsIPrefService)
.getBranch(null);
.getBranch(null).QueryInterface(Components.interfaces.nsIPrefBranch2);
</field>
<field name="mAtomService" readonly="true">
@ -362,6 +362,9 @@
}
catch (e) {
}
mPrefs.addObserver("browser.display.background_color", this, false);
this.observe(null, "nsPref:changed", "browser.display.background_color");
]]>
</constructor>
@ -389,9 +392,24 @@
this.focusedWindow = null;
this.focusedElement = null;
this._webBrowserFind = null;
this.mPrefs.removeObserver("browser.display.background_color", this);
]]>
</body>
</method>
<method name="observe">
<parameter name="aSubject"/>
<parameter name="aTopic"/>
<parameter name="aState"/>
<body>
<![CDATA[
if (aTopic == "nsPref:changed" && aState == "browser.display.background_color") {
this.style.backgroundColor = this.mPrefs.getCharPref("browser.display.background_color");
return;
}
]]>
</body>
</method>
</implementation>
<handlers>