Bug 743975 - move theme and window size done events to direct calls, r=smaug

This commit is contained in:
Neil Deakin 2012-08-15 14:52:35 -04:00
parent 0fabd086e1
commit 2ed511feda
12 changed files with 75 additions and 87 deletions

View File

@ -114,10 +114,10 @@ typedef struct CapturingContentInfo {
nsIContent* mContent;
} CapturingContentInfo;
// fcada634-fdea-45f5-b841-0a361d5f6a68
// 7E29E8A8-9C77-4445-A523-41B363E0C98A
#define NS_IPRESSHELL_IID \
{ 0xfcada634, 0xfdea, 0x45f5, \
{ 0xb8, 0x41, 0x0a, 0x36, 0x1d, 0x5f, 0x6a, 0x68 } }
{ 0x7e29e8a8, 0x9c77, 0x4445, \
{ 0xa5, 0x23, 0x41, 0xb3, 0x63, 0xe0, 0xc9, 0x8a } }
// debug VerifyReflow flags
#define VERIFY_REFLOW_ON 0x01
@ -1316,6 +1316,10 @@ public:
return mScrollPositionClampingScrollPortSize;
}
virtual void WindowSizeMoveDone() = 0;
virtual void SysColorChanged() = 0;
virtual void ThemeChanged() = 0;
protected:
friend class nsRefreshDriver;

View File

@ -5745,12 +5745,6 @@ PresShell::HandleEvent(nsIFrame *aFrame,
}
}
// Check for a theme change up front, since the frame type is irrelevant
if (aEvent->message == NS_THEMECHANGED && mPresContext) {
mPresContext->ThemeChanged();
return NS_OK;
}
if (aEvent->message == NS_UISTATECHANGED && mDocument) {
nsPIDOMWindow* win = mDocument->GetWindow();
if (win) {
@ -5760,15 +5754,6 @@ PresShell::HandleEvent(nsIFrame *aFrame,
return NS_OK;
}
// Check for a system color change up front, since the frame type is
// irrelevant
if ((aEvent->message == NS_SYSCOLORCHANGED) && mPresContext &&
aFrame == mFrameConstructor->GetRootFrame()) {
*aEventStatus = nsEventStatus_eConsumeDoDefault;
mPresContext->SysColorChanged();
return NS_OK;
}
if (aEvent->eventStructType == NS_KEY_EVENT &&
mDocument && mDocument->EventHandlingSuppressed()) {
if (aEvent->message == NS_KEY_DOWN) {
@ -7710,6 +7695,15 @@ PresShell::ProcessReflowCommands(bool aInterruptible)
return !interrupted;
}
void
PresShell::WindowSizeMoveDone()
{
if (mPresContext) {
nsEventStateManager::ClearGlobalActiveContent(nullptr);
ClearMouseCapture(nullptr);
}
}
#ifdef MOZ_XUL
/*
* It's better to add stuff to the |DidSetStyleContext| method of the

View File

@ -689,7 +689,12 @@ protected:
// The callback for the mReflowContinueTimer timer.
static void sReflowContinueCallback(nsITimer* aTimer, void* aPresShell);
bool ScheduleReflowOffTimer();
// Widget notificiations
virtual void WindowSizeMoveDone();
virtual void SysColorChanged() { mPresContext->SysColorChanged(); }
virtual void ThemeChanged() { mPresContext->ThemeChanged(); }
#ifdef DEBUG
// The reflow root under which we're currently reflowing. Null when
// not in reflow.

View File

@ -719,20 +719,6 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent,
break;
}
case NS_DONESIZEMOVE:
{
if (mPresShell) {
nsPresContext* presContext = mPresShell->GetPresContext();
if (presContext) {
nsEventStateManager::ClearGlobalActiveContent(nullptr);
}
}
nsIPresShell::ClearMouseCapture(nullptr);
}
break;
case NS_XUL_CLOSE:
{
// if this is a popup, make a request to hide it. Note that a popuphidden
@ -844,26 +830,6 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent,
*aStatus = nsEventStatus_eConsumeNoDefault;
break;
case NS_DISPLAYCHANGED:
//Destroy the cached backbuffer to force a new backbuffer
//be constructed with the appropriate display depth.
//@see bugzilla bug 6061
*aStatus = nsEventStatus_eConsumeDoDefault;
break;
case NS_SYSCOLORCHANGED:
{
if (mPresShell) {
// Hold a refcount to the presshell. The continued existence of the observer will
// delay deletion of this view hierarchy should the event want to cause its
// destruction in, say, some JavaScript event handler.
nsCOMPtr<nsIPresShell> presShell = mPresShell;
presShell->HandleEvent(aView->GetFrame(), aEvent, false, aStatus);
}
}
break;
default:
{
if ((NS_IS_MOUSE_EVENT(aEvent) &&

View File

@ -2185,11 +2185,8 @@ NSEvent* gLastDragMouseDownEvent = nil;
- (void)systemMetricsChanged
{
if (!mGeckoChild)
return;
nsGUIEvent guiEvent(true, NS_THEMECHANGED, mGeckoChild);
mGeckoChild->DispatchWindowEvent(guiEvent);
if (mGeckoChild)
mGeckoChild->NotifyThemeChanged();
}
- (void)setNeedsPendingDisplay

View File

@ -3264,14 +3264,12 @@ nsWindow::OnWindowStateEvent(GtkWidget *aWidget, GdkEventWindowState *aEvent)
void
nsWindow::ThemeChanged()
{
nsGUIEvent event(true, NS_THEMECHANGED, this);
nsEventStatus status = nsEventStatus_eIgnore;
DispatchEvent(&event, status);
NotifyThemeChanged();
if (!mGdkWindow || NS_UNLIKELY(mIsDestroyed))
return;
// Dispatch NS_THEMECHANGED to all child windows
// Dispatch theme change notification to all child windows
GList *children =
gdk_window_peek_children(mGdkWindow);
while (children) {

View File

@ -188,17 +188,6 @@ class nsHashKey;
#define NS_OS_TOOLBAR (NS_WINDOW_START + 36)
// Indicates the display has changed depth
#define NS_DISPLAYCHANGED (NS_WINDOW_START + 40)
// Indicates a theme change has occurred
#define NS_THEMECHANGED (NS_WINDOW_START + 41)
// Indicates a System color has changed. It is the platform
// toolkits responsibility to invalidate the window to
// ensure that it is drawn using the current system colors.
#define NS_SYSCOLORCHANGED (NS_WINDOW_START + 42)
// Indicates that the ui state such as whether to show focus or
// keyboard accelerator indicators has changed.
#define NS_UISTATECHANGED (NS_WINDOW_START + 43)

View File

@ -2135,12 +2135,7 @@ nsWindow::DistanceBetweenPoints(const QPointF &aFirstPoint, const QPointF &aSeco
void
nsWindow::ThemeChanged()
{
nsGUIEvent event(true, NS_THEMECHANGED, this);
DispatchEvent(&event);
// do nothing
return;
NotifyThemeChanged();
}
nsEventStatus

View File

@ -4519,10 +4519,6 @@ bool nsWindow::ProcessMessage(UINT msg, WPARAM &wParam, LPARAM &lParam,
result = true;
break;
case WM_DISPLAYCHANGE:
DispatchStandardEvent(NS_DISPLAYCHANGED);
break;
case WM_SYSCOLORCHANGE:
OnSysColorChanged();
break;
@ -4550,7 +4546,7 @@ bool nsWindow::ProcessMessage(UINT msg, WPARAM &wParam, LPARAM &lParam,
nsUXThemeData::InitTitlebarInfo();
nsUXThemeData::UpdateNativeThemeInfo();
DispatchStandardEvent(NS_THEMECHANGED);
NotifyThemeChanged();
// Invalidate the window so that the repaint will
// pick up the new theme.
@ -4980,7 +4976,7 @@ bool nsWindow::ProcessMessage(UINT msg, WPARAM &wParam, LPARAM &lParam,
case WM_EXITSIZEMOVE:
if (!sIsInMouseCapture) {
DispatchStandardEvent(NS_DONESIZEMOVE);
NotifySizeMoveDone();
}
break;
@ -5188,7 +5184,7 @@ bool nsWindow::ProcessMessage(UINT msg, WPARAM &wParam, LPARAM &lParam,
UpdateNonClientMargins();
RemovePropW(mWnd, kManageWindowInfoProperty);
BroadcastMsg(mWnd, WM_DWMCOMPOSITIONCHANGED);
DispatchStandardEvent(NS_THEMECHANGED);
NotifyThemeChanged();
UpdateGlass();
Invalidate(true, true, true);
break;
@ -7264,7 +7260,7 @@ nsWindow::OnSysColorChanged()
// But we cycle through all of the childwindows and send it to them as well
// so all presentations get notified properly.
// See nsWindow::GlobalMsgWindowProc.
DispatchStandardEvent(NS_SYSCOLORCHANGED);
NotifySysColorChanged();
}
}

View File

@ -78,6 +78,7 @@ LOCAL_INCLUDES += \
-I$(topsrcdir)/layout/forms \
-I$(topsrcdir)/layout/generic \
-I$(topsrcdir)/layout/xul/base/src \
-I$(topsrcdir)/view/src \
-I$(srcdir) \
$(NULL)

View File

@ -22,6 +22,9 @@
#include "BasicLayers.h"
#include "LayerManagerOGL.h"
#include "nsIXULRuntime.h"
#include "nsView.h"
#include "nsIViewManager.h"
#include "nsEventStateManager.h"
#include "nsIGfxInfo.h"
#include "npapi.h"
#include "base/thread.h"
@ -1336,6 +1339,39 @@ const widget::SizeConstraints& nsBaseWidget::GetSizeConstraints() const
return mSizeConstraints;
}
static nsIPresShell* GetPresShell(nsIWidget* aWidget)
{
nsIView* view = nsView::GetViewFor(aWidget);
return view ? view->GetViewManager()->GetPresShell() : nullptr;
}
void
nsBaseWidget::NotifySizeMoveDone()
{
nsIPresShell* presShell = GetPresShell(this);
if (presShell) {
presShell->WindowSizeMoveDone();
}
}
void
nsBaseWidget::NotifySysColorChanged()
{
nsIPresShell* presShell = GetPresShell(this);
if (presShell) {
presShell->SysColorChanged();
}
}
void
nsBaseWidget::NotifyThemeChanged()
{
nsIPresShell* presShell = GetPresShell(this);
if (presShell) {
presShell->ThemeChanged();
}
}
#ifdef DEBUG
//////////////////////////////////////////////////////////////
//

View File

@ -160,6 +160,13 @@ public:
NS_IMETHOD RegisterTouchWindow();
NS_IMETHOD UnregisterTouchWindow();
void NotifySizeMoveDone();
// Should be called by derived implementations to notify on system color and
// theme changes.
void NotifySysColorChanged();
void NotifyThemeChanged();
nsPopupLevel PopupLevel() { return mPopupLevel; }
virtual nsIntSize ClientToWindowSize(const nsIntSize& aClientSize)