Bug 550330. Try harder to find a document with a layer manager that we can use to create our ImageContainer. r=mats

This commit is contained in:
Robert O'Callahan 2010-04-23 12:26:38 +12:00
Родитель c2ef8303da
Коммит 614a854ff4
1 изменённых файлов: 34 добавлений и 17 удалений

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

@ -85,6 +85,7 @@
#include "nsVideoFrame.h" #include "nsVideoFrame.h"
#include "BasicLayers.h" #include "BasicLayers.h"
#include <limits> #include <limits>
#include "nsIDocShellTreeItem.h"
#ifdef MOZ_OGG #ifdef MOZ_OGG
#include "nsOggDecoder.h" #include "nsOggDecoder.h"
@ -1752,26 +1753,42 @@ void nsHTMLMediaElement::NotifyAutoplayDataReady()
*/ */
static already_AddRefed<LayerManager> GetLayerManagerForDoc(nsIDocument* aDoc) static already_AddRefed<LayerManager> GetLayerManagerForDoc(nsIDocument* aDoc)
{ {
while (aDoc) { nsIDocument* doc = aDoc;
nsIDocument* displayDoc = aDoc->GetDisplayDocument(); nsIDocument* displayDoc = doc->GetDisplayDocument();
if (displayDoc) { if (displayDoc) {
aDoc = displayDoc; doc = displayDoc;
continue; }
}
nsIPresShell* shell = aDoc->GetPrimaryShell(); nsIPresShell* shell = doc->GetPrimaryShell();
if (shell) { nsCOMPtr<nsISupports> container = doc->GetContainer();
nsIFrame* rootFrame = shell->FrameManager()->GetRootFrame(); nsCOMPtr<nsIDocShellTreeItem> docShellTreeItem = do_QueryInterface(container);
if (rootFrame) { while (!shell && docShellTreeItem) {
nsIWidget* widget = // We may be in a display:none subdocument, or we may not have a presshell
nsLayoutUtils::GetDisplayRootFrame(rootFrame)->GetWindow(); // created yet.
if (widget) { // Walk the docshell tree to find the nearest container that has a presshell,
nsRefPtr<LayerManager> manager = widget->GetLayerManager(); // and find the root widget from that.
return manager.forget(); nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(docShellTreeItem);
} nsCOMPtr<nsIPresShell> presShell;
docShell->GetPresShell(getter_AddRefs(presShell));
if (presShell) {
shell = presShell;
} else {
nsCOMPtr<nsIDocShellTreeItem> parent;
docShellTreeItem->GetParent(getter_AddRefs(parent));
docShellTreeItem = parent;
}
}
if (shell) {
nsIFrame* rootFrame = shell->FrameManager()->GetRootFrame();
if (rootFrame) {
nsIWidget* widget =
nsLayoutUtils::GetDisplayRootFrame(rootFrame)->GetWindow();
if (widget) {
nsRefPtr<LayerManager> manager = widget->GetLayerManager();
return manager.forget();
} }
} }
aDoc = aDoc->GetParentDocument();
} }
nsRefPtr<LayerManager> manager = new BasicLayerManager(nsnull); nsRefPtr<LayerManager> manager = new BasicLayerManager(nsnull);