зеркало из https://github.com/mozilla/gecko-dev.git
Bug 799078. Part 1: Expose nsContentUtils::FindPresShellForDocument. r=matspal
--HG-- extra : rebase_source : f7e6410637ea70fe2d68fdcc24bcb409816d5bd7
This commit is contained in:
Родитель
c09d833bfb
Коммит
360d84134c
|
@ -1822,12 +1822,23 @@ public:
|
|||
const nsAString& aClasses,
|
||||
nsIDOMNodeList** aReturn);
|
||||
|
||||
/**
|
||||
* Returns a presshell for this document, if there is one. This will be
|
||||
* aDoc's direct presshell if there is one, otherwise we'll look at all
|
||||
* ancestor documents to try to find a presshell, so for example this can
|
||||
* still find a presshell for documents in display:none frames that have
|
||||
* no presentation. So you have to be careful how you use this presshell ---
|
||||
* getting generic data like a device context or widget from it is OK, but it
|
||||
* might not be this document's actual presentation.
|
||||
*/
|
||||
static nsIPresShell* FindPresShellForDocument(nsIDocument* aDoc);
|
||||
|
||||
/**
|
||||
* Returns the widget for this document if there is one. Looks at all ancestor
|
||||
* documents to try to find a widget, so for example this can still find a
|
||||
* widget for documents in display:none frames that have no presentation.
|
||||
*/
|
||||
static nsIWidget *WidgetForDocument(nsIDocument *aDoc);
|
||||
static nsIWidget* WidgetForDocument(nsIDocument* aDoc);
|
||||
|
||||
/**
|
||||
* Returns a layer manager to use for the given document. Basically we
|
||||
|
|
|
@ -6524,8 +6524,8 @@ nsContentUtils::PlatformToDOMLineBreaks(nsString &aString)
|
|||
}
|
||||
}
|
||||
|
||||
nsIWidget *
|
||||
nsContentUtils::WidgetForDocument(nsIDocument *aDoc)
|
||||
nsIPresShell*
|
||||
nsContentUtils::FindPresShellForDocument(nsIDocument* aDoc)
|
||||
{
|
||||
nsIDocument* doc = aDoc;
|
||||
nsIDocument* displayDoc = doc->GetDisplayDocument();
|
||||
|
@ -6534,25 +6534,35 @@ nsContentUtils::WidgetForDocument(nsIDocument *aDoc)
|
|||
}
|
||||
|
||||
nsIPresShell* shell = doc->GetShell();
|
||||
if (shell) {
|
||||
return shell;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISupports> container = doc->GetContainer();
|
||||
nsCOMPtr<nsIDocShellTreeItem> docShellTreeItem = do_QueryInterface(container);
|
||||
while (!shell && docShellTreeItem) {
|
||||
while (docShellTreeItem) {
|
||||
// We may be in a display:none subdocument, or we may not have a presshell
|
||||
// created yet.
|
||||
// Walk the docshell tree to find the nearest container that has a presshell,
|
||||
// and find the root widget from that.
|
||||
// and return that.
|
||||
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;
|
||||
return presShell;
|
||||
}
|
||||
nsCOMPtr<nsIDocShellTreeItem> parent;
|
||||
docShellTreeItem->GetParent(getter_AddRefs(parent));
|
||||
docShellTreeItem = parent;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsIWidget*
|
||||
nsContentUtils::WidgetForDocument(nsIDocument* aDoc)
|
||||
{
|
||||
nsIPresShell* shell = FindPresShellForDocument(aDoc);
|
||||
if (shell) {
|
||||
nsIViewManager* VM = shell->GetViewManager();
|
||||
if (VM) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче