mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-03 12:35:58 +00:00
Bug 743975 - add a getpresshell method to the widget listener, r=tn
This commit is contained in:
parent
2e9eced59a
commit
f313800475
@ -49,6 +49,11 @@ class ViewWrapper MOZ_FINAL : public nsIInterfaceRequestor,
|
||||
|
||||
public:
|
||||
|
||||
virtual nsIPresShell* GetPresShell()
|
||||
{
|
||||
return mView->GetViewManager()->GetPresShell();
|
||||
}
|
||||
|
||||
bool WindowMoved(nsIWidget* aWidget, PRInt32 x, PRInt32 y)
|
||||
{
|
||||
nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "nsIXULWindow.h"
|
||||
|
||||
class nsIView;
|
||||
class nsIPresShell;
|
||||
|
||||
class nsIWidgetListener
|
||||
{
|
||||
@ -58,6 +59,11 @@ public:
|
||||
*/
|
||||
virtual nsIView* GetView() { return nullptr; }
|
||||
|
||||
/**
|
||||
* Return the presshell for this widget listener.
|
||||
*/
|
||||
virtual nsIPresShell* GetPresShell() { return nullptr; }
|
||||
|
||||
/**
|
||||
* Called when a window is moved to location (x, y). Returns true if the
|
||||
* notification was handled. Coordinates are outer window screen coordinates.
|
||||
|
@ -24,9 +24,6 @@
|
||||
#include "nsIXULRuntime.h"
|
||||
#include "nsIXULWindow.h"
|
||||
#include "nsIBaseWindow.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsView.h"
|
||||
#include "nsIViewManager.h"
|
||||
#include "nsEventStateManager.h"
|
||||
#include "nsIWidgetListener.h"
|
||||
#include "nsIGfxInfo.h"
|
||||
@ -1345,31 +1342,6 @@ const widget::SizeConstraints& nsBaseWidget::GetSizeConstraints() const
|
||||
return mSizeConstraints;
|
||||
}
|
||||
|
||||
// If widgetListener is non-null, then get the presShell from either the window
|
||||
// or the view. Otherwise, assume that this is a widget attached to a view.
|
||||
static nsIPresShell* GetPresShell(nsIWidget* aWidget, void* clientData)
|
||||
{
|
||||
nsCOMPtr<nsIXULWindow> window =
|
||||
aWidgetListener ? aWidgetListener->GetXULWindow() : nullptr;
|
||||
if (window) {
|
||||
nsCOMPtr<nsIDocShell> docShell;
|
||||
window->GetDocShell(getter_AddRefs(docShell));
|
||||
if (docShell) {
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
docShell->GetPresShell(getter_AddRefs(presShell));
|
||||
return presShell.get();
|
||||
}
|
||||
}
|
||||
else {
|
||||
nsIView* view = nsView::GetViewFor(aWidget);
|
||||
if (view) {
|
||||
return view->GetViewManager()->GetPresShell();
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void
|
||||
nsBaseWidget::NotifyWindowDestroyed()
|
||||
{
|
||||
@ -1386,7 +1358,10 @@ nsBaseWidget::NotifyWindowDestroyed()
|
||||
void
|
||||
nsBaseWidget::NotifySizeMoveDone()
|
||||
{
|
||||
nsIPresShell* presShell = GetPresShell(this, nullptr);
|
||||
if (!mWidgetListener || mWidgetListener->GetXULWindow())
|
||||
return;
|
||||
|
||||
nsIPresShell* presShell = mWidgetListener->GetPresShell();
|
||||
if (presShell) {
|
||||
presShell->WindowSizeMoveDone();
|
||||
}
|
||||
@ -1395,7 +1370,10 @@ nsBaseWidget::NotifySizeMoveDone()
|
||||
void
|
||||
nsBaseWidget::NotifySysColorChanged()
|
||||
{
|
||||
nsIPresShell* presShell = GetPresShell(this, nullptr);
|
||||
if (!mWidgetListener || mWidgetListener->GetXULWindow())
|
||||
return;
|
||||
|
||||
nsIPresShell* presShell = mWidgetListener->GetPresShell();
|
||||
if (presShell) {
|
||||
presShell->SysColorChanged();
|
||||
}
|
||||
@ -1404,7 +1382,10 @@ nsBaseWidget::NotifySysColorChanged()
|
||||
void
|
||||
nsBaseWidget::NotifyThemeChanged()
|
||||
{
|
||||
nsIPresShell* presShell = GetPresShell(this, nullptr);
|
||||
if (!mWidgetListener || mWidgetListener->GetXULWindow())
|
||||
return;
|
||||
|
||||
nsIPresShell* presShell = mWidgetListener->GetPresShell();
|
||||
if (presShell) {
|
||||
presShell->ThemeChanged();
|
||||
}
|
||||
@ -1414,7 +1395,7 @@ void
|
||||
nsBaseWidget::NotifyUIStateChanged(UIStateChangeType aShowAccelerators,
|
||||
UIStateChangeType aShowFocusRings)
|
||||
{
|
||||
nsIPresShell* presShell = GetPresShell(this, mWidgetListener);
|
||||
nsIPresShell* presShell = mWidgetListener->GetPresShell();
|
||||
nsIDocument* doc = presShell->GetDocument();
|
||||
if (doc) {
|
||||
nsPIDOMWindow* win = doc->GetWindow();
|
||||
@ -1429,7 +1410,7 @@ nsBaseWidget::NotifyUIStateChanged(UIStateChangeType aShowAccelerators,
|
||||
Accessible*
|
||||
nsBaseWidget::GetAccessible()
|
||||
{
|
||||
nsIPresShell* presShell = GetPresShell(this, mWidgetListener);
|
||||
nsIPresShell* presShell = mWidgetListener->GetPresShell();
|
||||
NS_ENSURE_TRUE(presShell, nullptr);
|
||||
|
||||
// If container is null then the presshell is not active. This often happens
|
||||
|
@ -217,6 +217,17 @@ nsresult nsWebShellWindow::Initialize(nsIXULWindow* aParent,
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsIPresShell*
|
||||
nsWebShellWindow::GetPresShell()
|
||||
{
|
||||
if (!mDocShell)
|
||||
return nullptr;
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
mDocShell->GetPresShell(getter_AddRefs(presShell));
|
||||
return presShell.get();
|
||||
}
|
||||
|
||||
bool
|
||||
nsWebShellWindow::WindowMoved(nsIWidget* aWidget, PRInt32 x, PRInt32 y)
|
||||
{
|
||||
|
@ -48,7 +48,7 @@ public:
|
||||
|
||||
// nsIWidgetListener
|
||||
virtual nsIXULWindow* GetXULWindow() { return this; }
|
||||
|
||||
virtual nsIPresShell* GetPresShell();
|
||||
virtual bool WindowMoved(nsIWidget* aWidget, PRInt32 x, PRInt32 y);
|
||||
virtual bool WindowResized(nsIWidget* aWidget, PRInt32 aWidth, PRInt32 aHeight);
|
||||
virtual bool RequestWindowClose(nsIWidget* aWidget);
|
||||
|
Loading…
x
Reference in New Issue
Block a user