bug 307204, implement support for transparent windows in XUL for Mac OS X. r=josh, sr=roc, approval1.9=damons

This commit is contained in:
hwaara%gmail.com 2007-12-19 19:40:20 +00:00
Родитель 689db72371
Коммит fa19e7bfb0
16 изменённых файлов: 173 добавлений и 136 удалений

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

@ -3299,13 +3299,13 @@ nsCSSRendering::PaintBackground(nsPresContext* aPresContext,
nsIView* rootView;
vm->GetRootView(rootView);
if (!rootView->GetParent()) {
PRBool widgetIsTranslucent = PR_FALSE;
PRBool widgetIsTransparent = PR_FALSE;
if (rootView->HasWidget()) {
rootView->GetWidget()->GetWindowTranslucency(widgetIsTranslucent);
rootView->GetWidget()->GetHasTransparentBackground(widgetIsTransparent);
}
if (!widgetIsTranslucent) {
if (!widgetIsTransparent) {
// Ensure that we always paint a color for the root (in case there's
// no background at all or a partly transparent image).
canvasColor.mBackgroundFlags &= ~NS_STYLE_BG_COLOR_TRANSPARENT;

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

@ -5286,9 +5286,9 @@ PresShell::Paint(nsIView* aView,
mViewManager->GetDefaultBackgroundColor(&backgroundColor);
for (nsIView *view = aView; view; view = view->GetParent()) {
if (view->HasWidget()) {
PRBool widgetIsTranslucent;
view->GetWidget()->GetWindowTranslucency(widgetIsTranslucent);
if (widgetIsTranslucent) {
PRBool widgetIsTransparent;
view->GetWidget()->GetHasTransparentBackground(widgetIsTransparent);
if (widgetIsTransparent) {
backgroundColor = NS_RGBA(0,0,0,0);
break;
}

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

@ -458,7 +458,7 @@ SyncFrameViewGeometryDependentProperties(nsPresContext* aPresContext,
// don't proceed unless this is the root view
// (sometimes the non-root-view is a canvas)
if (aView->HasWidget() && aView == rootView) {
aView->GetWidget()->SetWindowTranslucency(nsLayoutUtils::FrameHasTransparency(aFrame));
aView->GetWidget()->SetHasTransparentBackground(nsLayoutUtils::FrameHasTransparency(aFrame));
}
}
}

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

@ -244,7 +244,7 @@ nsMenuPopupFrame::CreateWidgetForView(nsIView* aView)
aView->CreateWidget(kCChildCID, &widgetData, nsnull, PR_TRUE, PR_TRUE,
eContentTypeInherit, parentWidget);
#endif
aView->GetWidget()->SetWindowTranslucency(viewHasTransparentContent);
aView->GetWidget()->SetHasTransparentBackground(viewHasTransparentContent);
return NS_OK;
}

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

@ -1028,11 +1028,11 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsEventStatus *aS
nsRefPtr<nsViewManager> rootVM = RootViewManager();
nsIWidget *widget = mRootView->GetWidget();
PRBool translucentWindow = PR_FALSE;
PRBool transparentWindow = PR_FALSE;
if (widget)
widget->GetWindowTranslucency(translucentWindow);
widget->GetHasTransparentBackground(transparentWindow);
if (rootVM->mScrollCnt == 0 && !translucentWindow) {
if (rootVM->mScrollCnt == 0 && !transparentWindow) {
nsIViewObserver* observer = GetViewObserver();
if (observer) {
// Do an update view batch. Make sure not to do it DEFERRED,

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

@ -95,13 +95,13 @@ typedef nsEventStatus (*PR_CALLBACK EVENT_CALLBACK)(nsGUIEvent *event);
#define NS_NATIVE_PLUGIN_PORT_CG 101
#endif
// d7d1aae8-fcb9-4fe7-be62-b20ffc53f1f9
// a6593177-ba36-400e-8812-a0d36b3af17b
#define NS_IWIDGET_IID \
{ 0xd7d1aae8, 0xfcb9, 0x4fe7, \
{ 0xbe, 0x62, 0xb2, 0x0f, 0xfc, 0x53, 0xf1, 0xf9 } }
{ 0xa6593177, 0xba36, 0x400e, \
{ 0x88, 0x12, 0xa0, 0xd3, 0x6b, 0x3a, 0xf1, 0x7b } }
// Hide the native window systems real window type so as to avoid
// including native window system types and api's. This is necessary
// including native window system types and APIs. This is necessary
// to ensure cross-platform code.
typedef void* nsNativeWidget;
@ -669,29 +669,18 @@ class nsIWidget : public nsISupports {
* If the window is resized then the alpha channel values for
* all pixels are reset to 1.
* Pixel RGB color values are already premultiplied with alpha channel values.
* @param aTranslucent true if the window may have translucent
* @param aTransparent true if the window may have translucent
* or transparent pixels
*/
NS_IMETHOD SetWindowTranslucency(PRBool aTranslucent) = 0;
NS_IMETHOD SetHasTransparentBackground(PRBool aTransparent) = 0;
/**
* Get the translucency of the top-level window that contains this
* widget.
* @param aTranslucent true if the window may have translucent or
* @param aTransparent true if the window may have translucent or
* transparent pixels
*/
NS_IMETHOD GetWindowTranslucency(PRBool& aTranslucent) = 0;
/**
* Update the alpha channel for some pixels of the top-level window
* that contains this widget.
* The window must have been made translucent using SetWindowTranslucency.
* Pixel RGB color values are already premultiplied with alpha channel values.
* @param aRect the rect to update
* @param aAlphas the alpha values, in w x h array, row-major order,
* in units of 1/255. nsBlender::GetAlphas is a good way to compute this array.
*/
NS_IMETHOD UpdateTranslucentWindowAlpha(const nsRect& aRect, PRUint8* aAlphas) = 0;
NS_IMETHOD GetHasTransparentBackground(PRBool& aTransparent) = 0;
/**
* Hide window chrome (borders, buttons) for this widget.

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

@ -111,6 +111,10 @@ union nsPluginPort;
NSMutableArray* mPendingDirtyRects;
BOOL mPendingFullDisplay;
// All views are always opaque (non-transparent). The only exception is when we're
// the content view in a transparent XUL window.
BOOL mIsTransparent;
// Holds our drag service across multiple drag calls. The reference to the
// service is obtained when the mouse enters the view and is released when
// the mouse exits or there is a drop. This prevents us from having to
@ -127,6 +131,7 @@ union nsPluginPort;
// Stop NSView hierarchy being changed during [ChildView drawRect:]
- (void)delayedTearDown;
- (void)setTransparent:(BOOL)transparent;
@end
@ -292,12 +297,13 @@ public:
NS_IMETHOD StartDrawPlugin();
NS_IMETHOD EndDrawPlugin();
NS_IMETHOD GetHasTransparentBackground(PRBool& aTransparent);
NS_IMETHOD SetHasTransparentBackground(PRBool aTransparent);
// Mac specific methods
virtual PRBool PointInWidget(Point aThePoint);
virtual PRBool DispatchWindowEvent(nsGUIEvent& event);
virtual void AcceptFocusOnClick(PRBool aBool) { mAcceptFocusOnClick = aBool;};
PRBool AcceptFocusOnClick() { return mAcceptFocusOnClick;};
void LiveResizeStarted();
void LiveResizeEnded();
@ -346,7 +352,6 @@ protected:
PRPackedBool mDrawing;
PRPackedBool mAcceptFocusOnClick;
PRPackedBool mLiveResizeInProgress;
PRPackedBool mIsPluginView; // true if this is a plugin view
PRPackedBool mPluginDrawing;

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

@ -46,7 +46,6 @@
#include "nsCOMPtr.h"
#include "nsToolkit.h"
#include "prmem.h"
#include "nsCRT.h"
#include "nsplugindefs.h"
#include "nsThreadUtils.h"
@ -343,7 +342,6 @@ nsChildView::nsChildView() : nsBaseWidget()
, mDestructorCalled(PR_FALSE)
, mVisible(PR_FALSE)
, mDrawing(PR_FALSE)
, mAcceptFocusOnClick(PR_TRUE)
, mLiveResizeInProgress(PR_FALSE)
, mIsPluginView(PR_FALSE)
, mPluginDrawing(PR_FALSE)
@ -655,8 +653,34 @@ void* nsChildView::GetNativeData(PRUint32 aDataType)
#pragma mark -
NS_IMETHODIMP nsChildView::GetHasTransparentBackground(PRBool& aTransparent)
{
aTransparent = ![mView isOpaque];
return NS_OK;
}
// This is called by nsContainerFrame on the root widget for all window types
// except popup windows (when nsCocoaWindow::SetHasTransparentBackground is used instead).
NS_IMETHODIMP nsChildView::SetHasTransparentBackground(PRBool aTransparent)
{
BOOL currentTransparency = ![[mView nativeWindow] isOpaque];
if (aTransparent != currentTransparency) {
// Find out if this is a window we created by seeing if the delegate is WindowDelegate. If it is,
// tell the nsCocoaWindow to set its background to transparent.
id windowDelegate = [[mView nativeWindow] delegate];
if (windowDelegate && [windowDelegate isKindOfClass:[WindowDelegate class]]) {
nsCocoaWindow *widget = [(WindowDelegate *)windowDelegate geckoWidget];
if (widget) {
widget->MakeBackgroundTransparent(aTransparent);
[mView setTransparent:aTransparent];
}
}
}
return NS_OK;
}
// Return PR_TRUE if the whether the component is visible, PR_FALSE otherwise
NS_IMETHODIMP nsChildView::IsVisible(PRBool& outState)
{
if (!mVisible) {
@ -2042,10 +2066,15 @@ NSEvent* gLastDragEvent = nil;
}
- (void)setTransparent:(BOOL)transparent
{
mIsTransparent = transparent;
}
- (BOOL)isOpaque
{
// this will be NO when we can do transparent windows/views
return YES;
return !mIsTransparent;
}
@ -2172,11 +2201,6 @@ NSEvent* gLastDragEvent = nil;
if (!mGeckoChild || NS_FAILED(mGeckoChild->IsVisible(isVisible)) || !isVisible)
return;
// Workaround for the fact that NSQuickDrawViews can't be opaque; see if the rect
// being drawn is covered by a subview, and, if so, just bail.
if ([self isRectObscuredBySubview:aRect])
return;
CGContextRef cgContext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
nsRect geckoBounds;
@ -2262,22 +2286,6 @@ NSEvent* gLastDragEvent = nil;
}
- (BOOL)isRectObscuredBySubview:(NSRect)inRect
{
unsigned int numSubviews = [[self subviews] count];
for (unsigned int i = 0; i < numSubviews; i++) {
NSView* view = (NSView*)[[self subviews] objectAtIndex:i];
if (![view isHidden]) {
NSRect subviewFrame = [view frame];
if (NSContainsRect(subviewFrame, inRect))
return YES;
}
}
return NO;
}
// Allows us to turn off setting up the clip region
// before each drawRect. We already clip within gecko.
- (BOOL)wantsDefaultClipping

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

@ -237,6 +237,8 @@ public:
NS_IMETHOD DispatchEvent(nsGUIEvent* event, nsEventStatus & aStatus) ;
NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener, PRBool aDoCapture, PRBool aConsumeRollupEvent);
NS_IMETHOD GetAttention(PRInt32 aCycleCount);
NS_IMETHOD GetHasTransparentBackground(PRBool& aTransparent);
NS_IMETHOD SetHasTransparentBackground(PRBool aTransparent);
NS_IMETHOD SetWindowTitlebarColor(nscolor aColor);
virtual gfxASurface* GetThebesSurface();
@ -252,6 +254,8 @@ public:
// nsIKBStateControl interface
NS_IMETHOD ResetInputState();
void MakeBackgroundTransparent(PRBool aTransparent);
NS_IMETHOD BeginSecureKeyboardInput();
NS_IMETHOD EndSecureKeyboardInput();

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

@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* -*- Mode: Objective-C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -67,6 +67,8 @@ extern BOOL gSomeMenuBarPainted;
#define NS_APPSHELLSERVICE_CONTRACTID "@mozilla.org/appshell/appShellService;1"
#define POPUP_DEFAULT_TRANSPARENCY 0.95
NS_IMPL_ISUPPORTS_INHERITED1(nsCocoaWindow, Inherited, nsPIWidgetCocoa)
@ -372,10 +374,10 @@ nsresult nsCocoaWindow::StandardCreate(nsIWidget *aParent,
// Create the window
mWindow = [[windowClass alloc] initWithContentRect:rect styleMask:features
backing:NSBackingStoreBuffered defer:NO];
backing:NSBackingStoreBuffered defer:YES];
if (mWindowType == eWindowType_popup) {
[mWindow setAlphaValue:0.95];
[mWindow setAlphaValue:POPUP_DEFAULT_TRANSPARENCY];
[mWindow setLevel:NSPopUpMenuWindowLevel];
[mWindow setHasShadow:YES];
@ -698,6 +700,48 @@ NS_IMETHODIMP nsCocoaWindow::Show(PRBool bState)
}
void nsCocoaWindow::MakeBackgroundTransparent(PRBool aTransparent)
{
BOOL currentTransparency = ![mWindow isOpaque];
if (aTransparent != currentTransparency) {
// Popups have an alpha value we need to toggle.
if (mWindowType == eWindowType_popup) {
[mWindow setAlphaValue:(aTransparent ? 1.0 : POPUP_DEFAULT_TRANSPARENCY)];
}
[mWindow setOpaque:!aTransparent];
[mWindow setBackgroundColor:(aTransparent ? [NSColor clearColor] : [NSColor whiteColor])];
[mWindow setHasShadow:!aTransparent];
}
}
NS_IMETHODIMP nsCocoaWindow::GetHasTransparentBackground(PRBool& aTransparent)
{
aTransparent = ![mWindow isOpaque];
return NS_OK;
}
// This is called from nsMenuPopupFrame when making a popup transparent.
// For other window types, nsChildView::SetHasTransparentBackground is used.
NS_IMETHODIMP nsCocoaWindow::SetHasTransparentBackground(PRBool aTransparent)
{
BOOL currentTransparency = ![mWindow isOpaque];
if (aTransparent != currentTransparency) {
// Take care of window transparency
MakeBackgroundTransparent(aTransparent);
// Make sure our content view is also transparent
if (mPopupContentView) {
ChildView *childView = (ChildView*)mPopupContentView->GetNativeData(NS_NATIVE_WIDGET);
if (childView) {
[childView setTransparent:aTransparent];
}
}
}
return NS_OK;
}
NS_METHOD nsCocoaWindow::AddMouseListener(nsIMouseListener * aListener)
{
nsBaseWidget::AddMouseListener(aListener);

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

@ -347,7 +347,7 @@ nsWindow::nsWindow()
mRootAccessible = nsnull;
#endif
mIsTranslucent = PR_FALSE;
mIsTransparent = PR_FALSE;
mTransparencyBitmap = nsnull;
mTransparencyBitmapWidth = 0;
@ -1663,7 +1663,7 @@ nsWindow::OnExposeEvent(GtkWidget *aWidget, GdkEventExpose *aEvent)
}
PRBool translucent;
GetWindowTranslucency(translucent);
GetHasTransparentBackground(translucent);
nsIntRect boundsRect;
GdkPixmap* bufferPixmap = nsnull;
nsRefPtr<gfxXlibSurface> bufferPixmapSurface;
@ -3465,7 +3465,7 @@ nsWindow::EnsureGrabs(void)
}
NS_IMETHODIMP
nsWindow::SetWindowTranslucency(PRBool aTranslucent)
nsWindow::SetHasTransparentBackground(PRBool aTransparent)
{
if (!mShell) {
// Pass the request to the toplevel window
@ -3478,13 +3478,13 @@ nsWindow::SetWindowTranslucency(PRBool aTranslucent)
if (!topWindow)
return NS_ERROR_FAILURE;
return topWindow->SetWindowTranslucency(aTranslucent);
return topWindow->SetHasTransparentBackground(aTransparent);
}
if (mIsTranslucent == aTranslucent)
if (mIsTransparent == aTransparent)
return NS_OK;
if (!aTranslucent) {
if (!aTransparent) {
if (mTransparencyBitmap) {
delete[] mTransparencyBitmap;
mTransparencyBitmap = nsnull;
@ -3495,32 +3495,32 @@ nsWindow::SetWindowTranslucency(PRBool aTranslucent)
} // else the new default alpha values are "all 1", so we don't
// need to change anything yet
mIsTranslucent = aTranslucent;
mIsTransparent = aTransparent;
return NS_OK;
}
NS_IMETHODIMP
nsWindow::GetWindowTranslucency(PRBool& aTranslucent)
nsWindow::GetHasTransparentBackground(PRBool& aTransparent)
{
if (!mShell) {
// Pass the request to the toplevel window
GtkWidget *topWidget = nsnull;
GetToplevelWidget(&topWidget);
if (!topWidget) {
aTranslucent = PR_FALSE;
aTransparent = PR_FALSE;
return NS_ERROR_FAILURE;
}
nsWindow *topWindow = get_window_for_gtk_widget(topWidget);
if (!topWindow) {
aTranslucent = PR_FALSE;
aTransparent = PR_FALSE;
return NS_ERROR_FAILURE;
}
return topWindow->GetWindowTranslucency(aTranslucent);
return topWindow->GetHasTransparentBackground(aTransparent);
}
aTranslucent = mIsTranslucent;
aTransparent = mIsTransparent;
return NS_OK;
}
@ -3648,7 +3648,7 @@ nsWindow::UpdateTranslucentWindowAlphaInternal(const nsRect& aRect,
return topWindow->UpdateTranslucentWindowAlphaInternal(aRect, aAlphas, aStride);
}
NS_ASSERTION(mIsTranslucent, "Window is not transparent");
NS_ASSERTION(mIsTransparent, "Window is not transparent");
if (mTransparencyBitmap == nsnull) {
PRInt32 size = ((mBounds.width+7)/8)*mBounds.height;
@ -3679,12 +3679,6 @@ nsWindow::UpdateTranslucentWindowAlphaInternal(const nsRect& aRect,
return NS_OK;
}
NS_IMETHODIMP
nsWindow::UpdateTranslucentWindowAlpha(const nsRect& aRect, PRUint8* aAlphas)
{
return UpdateTranslucentWindowAlphaInternal(aRect, aAlphas, aRect.width);
}
void
nsWindow::GrabPointer(void)
{

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

@ -343,11 +343,10 @@ public:
void ResizeTransparencyBitmap(PRInt32 aNewWidth, PRInt32 aNewHeight);
void ApplyTransparencyBitmap();
NS_IMETHOD SetWindowTranslucency(PRBool aTransparent);
NS_IMETHOD GetWindowTranslucency(PRBool& aTransparent);
NS_IMETHOD SetHasTransparentBackground(PRBool aTransparent);
NS_IMETHOD GetHasTransparentBackground(PRBool& aTransparent);
nsresult UpdateTranslucentWindowAlphaInternal(const nsRect& aRect,
PRUint8* aAlphas, PRInt32 aStride);
NS_IMETHOD UpdateTranslucentWindowAlpha(const nsRect& aRect, PRUint8* aAlphas);
gfxASurface *GetThebesSurface();
@ -399,7 +398,7 @@ private:
static GdkCursor *gsGtkCursorCache[eCursorCount];
// Transparency
PRBool mIsTranslucent;
PRBool mIsTransparent;
// This bitmap tracks which pixels are transparent. We don't support
// full translucency at this time; each pixel is either fully opaque
// or fully transparent.

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

@ -737,9 +737,9 @@ nsWindow::nsWindow() : nsBaseWidget()
mIsVisible = PR_FALSE;
mHas3DBorder = PR_FALSE;
#ifdef MOZ_XUL
mIsTranslucent = PR_FALSE;
mIsTopTranslucent = PR_FALSE;
mTranslucentSurface = nsnull;
mIsTransparent = PR_FALSE;
mIsTopTransparent = PR_FALSE;
mTransparentSurface = nsnull;
mMemoryDC = NULL;
mMemoryBitmap = NULL;
mMemoryBits = NULL;
@ -1559,7 +1559,7 @@ NS_METHOD nsWindow::Destroy()
::DestroyIcon(icon);
#ifdef MOZ_XUL
if (mIsTranslucent)
if (mIsTransparent)
{
SetupTranslucentWindowMemoryBitmap(PR_FALSE);
@ -1775,7 +1775,7 @@ NS_METHOD nsWindow::Show(PRBool bState)
}
#ifdef MOZ_XUL
if (!mIsVisible && bState && mIsTopTranslucent)
if (!mIsVisible && bState && mIsTopTransparent)
Invalidate(PR_FALSE);
#endif
@ -2093,7 +2093,7 @@ NS_METHOD nsWindow::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint)
NS_ASSERTION((aHeight >=0 ), "Negative height passed to nsWindow::Resize");
#ifdef MOZ_XUL
if (mIsTranslucent)
if (mIsTransparent)
ResizeTranslucentWindow(aWidth, aHeight);
#endif
@ -2143,7 +2143,7 @@ NS_METHOD nsWindow::Resize(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeig
NS_ASSERTION((aHeight >=0 ), "Negative height passed to nsWindow::Resize");
#ifdef MOZ_XUL
if (mIsTranslucent)
if (mIsTransparent)
ResizeTranslucentWindow(aWidth, aHeight);
#endif
@ -2874,7 +2874,7 @@ void* nsWindow::GetNativeData(PRUint32 aDataType)
case NS_NATIVE_GRAPHIC:
// XXX: This is sleezy!! Remember to Release the DC after using it!
#ifdef MOZ_XUL
return (void*)(mIsTranslucent) ?
return (void*)(mIsTransparent) ?
mMemoryDC : ::GetDC(mWnd);
#else
return (void*)::GetDC(mWnd);
@ -2894,7 +2894,7 @@ void nsWindow::FreeNativeData(void * data, PRUint32 aDataType)
{
case NS_NATIVE_GRAPHIC:
#ifdef MOZ_XUL
if (!mIsTranslucent)
if (!mIsTransparent)
::ReleaseDC(mWnd, (HDC)data);
#else
::ReleaseDC(mWnd, (HDC)data);
@ -4704,7 +4704,7 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT
#ifdef MOZ_XUL
if (mIsTranslucent)
if (mIsTransparent)
ResizeTranslucentWindow(newWidth, newHeight);
#endif
@ -5569,7 +5569,7 @@ PRBool nsWindow::OnPaint(HDC aDC)
nsEventStatus eventStatus = nsEventStatus_eIgnore;
#ifdef MOZ_XUL
if (!aDC && mIsTranslucent)
if (!aDC && mIsTransparent)
{
// For layered translucent windows all drawing should go to memory DC and no
// WM_PAINT messages are normally generated. To support asynchronous painting
@ -5603,7 +5603,7 @@ PRBool nsWindow::OnPaint(HDC aDC)
RECT paintRect;
#ifdef MOZ_XUL
if (aDC || mIsTranslucent) {
if (aDC || mIsTransparent) {
#else
if (aDC) {
#endif
@ -5641,8 +5641,8 @@ PRBool nsWindow::OnPaint(HDC aDC)
#ifdef MOZ_XUL
nsRefPtr<gfxASurface> targetSurface;
if (mIsTranslucent) {
targetSurface = mTranslucentSurface;
if (mIsTransparent) {
targetSurface = mTransparentSurface;
} else {
targetSurface = new gfxWindowsSurface(hDC);
}
@ -5653,7 +5653,7 @@ PRBool nsWindow::OnPaint(HDC aDC)
nsRefPtr<gfxContext> thebesContext = new gfxContext(targetSurface);
#ifdef MOZ_XUL
if (mIsTranslucent) {
if (mIsTransparent) {
// If we're rendering with translucency, we're going to be
// rendering the whole window; make sure we clear it first
thebesContext->SetOperator(gfxContext::OPERATOR_CLEAR);
@ -5683,7 +5683,7 @@ PRBool nsWindow::OnPaint(HDC aDC)
event.renderingContext = nsnull;
#ifdef MOZ_XUL
if (mIsTranslucent) {
if (mIsTransparent) {
// Data from offscreen drawing surface was copied to memory bitmap of transparent
// bitmap. Now it can be read from memory bitmap to apply alpha channel and after
// that displayed on the screen.
@ -7889,28 +7889,28 @@ void nsWindow::ResizeTranslucentWindow(PRInt32 aNewWidth, PRInt32 aNewHeight, PR
if (!force && aNewWidth == mBounds.width && aNewHeight == mBounds.height)
return;
mTranslucentSurface = new gfxWindowsSurface(gfxIntSize(aNewWidth, aNewHeight), gfxASurface::ImageFormatARGB32);
mMemoryDC = mTranslucentSurface->GetDC();
mTransparentSurface = new gfxWindowsSurface(gfxIntSize(aNewWidth, aNewHeight), gfxASurface::ImageFormatARGB32);
mMemoryDC = mTransparentSurface->GetDC();
mMemoryBitmap = NULL;
}
NS_IMETHODIMP nsWindow::GetWindowTranslucency(PRBool& aTranslucent)
NS_IMETHODIMP nsWindow::GetHasTransparentBackground(PRBool& aTransparent)
{
aTranslucent = GetTopLevelWindow()->GetWindowTranslucencyInner();
aTransparent = GetTopLevelWindow()->GetWindowTranslucencyInner();
return NS_OK;
}
NS_IMETHODIMP nsWindow::SetWindowTranslucency(PRBool aTranslucent)
NS_IMETHODIMP nsWindow::SetHasTransparentBackground(PRBool aTransparent)
{
nsresult rv = GetTopLevelWindow()->SetWindowTranslucencyInner(aTranslucent);
nsresult rv = GetTopLevelWindow()->SetWindowTranslucencyInner(aTransparent);
return rv;
}
nsresult nsWindow::SetWindowTranslucencyInner(PRBool aTranslucent)
nsresult nsWindow::SetWindowTranslucencyInner(PRBool aTransparent)
{
if (aTranslucent == mIsTranslucent)
if (aTransparent == mIsTransparent)
return NS_OK;
HWND hWnd = GetTopLevelHWND(mWnd, PR_TRUE);
@ -7924,7 +7924,7 @@ nsresult nsWindow::SetWindowTranslucencyInner(PRBool aTranslucent)
LONG style, exStyle;
if (aTranslucent)
if (aTransparent)
{
style = ::GetWindowLongW(hWnd, GWL_STYLE) &
~(WS_CAPTION | WS_THICKFRAME | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX);
@ -7940,14 +7940,14 @@ nsresult nsWindow::SetWindowTranslucencyInner(PRBool aTranslucent)
::SetWindowLongW(hWnd, GWL_STYLE, style);
::SetWindowLongW(hWnd, GWL_EXSTYLE, exStyle);
mIsTranslucent = aTranslucent;
topWindow->mIsTopTranslucent = aTranslucent;
mIsTransparent = aTransparent;
topWindow->mIsTopTransparent = aTransparent;
nsresult rv = NS_OK;
rv = SetupTranslucentWindowMemoryBitmap(aTranslucent);
rv = SetupTranslucentWindowMemoryBitmap(aTransparent);
if (aTranslucent)
if (aTransparent)
{
if (!mBounds.IsEmpty())
{
@ -7969,12 +7969,12 @@ nsresult nsWindow::SetWindowTranslucencyInner(PRBool aTranslucent)
return rv;
}
nsresult nsWindow::SetupTranslucentWindowMemoryBitmap(PRBool aTranslucent)
nsresult nsWindow::SetupTranslucentWindowMemoryBitmap(PRBool aTransparent)
{
if (aTranslucent) {
if (aTransparent) {
ResizeTranslucentWindow(mBounds.width, mBounds.height, PR_TRUE);
} else {
mTranslucentSurface = nsnull;
mTransparentSurface = nsnull;
mMemoryDC = NULL;
mMemoryBitmap = NULL;
}

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

@ -209,14 +209,14 @@ public:
gfxASurface *GetThebesSurface();
#ifdef MOZ_XUL
NS_IMETHOD SetWindowTranslucency(PRBool aTransparent);
NS_IMETHOD GetWindowTranslucency(PRBool& aTransparent);
NS_IMETHOD SetHasTransparentBackground(PRBool aTransparent);
NS_IMETHOD GetHasTransparentBackground(PRBool& aTransparent);
private:
nsresult SetWindowTranslucencyInner(PRBool aTransparent);
PRBool GetWindowTranslucencyInner() { return mIsTranslucent; }
PRBool GetWindowTranslucencyInner() { return mIsTransparent; }
void ResizeTranslucentWindow(PRInt32 aNewWidth, PRInt32 aNewHeight, PRBool force = PR_FALSE);
nsresult UpdateTranslucentWindow();
nsresult SetupTranslucentWindowMemoryBitmap(PRBool aTranslucent);
nsresult SetupTranslucentWindowMemoryBitmap(PRBool aTransparent);
public:
#endif
@ -408,14 +408,14 @@ protected:
#ifdef MOZ_XUL
// use layered windows to support full 256 level alpha translucency
nsRefPtr<gfxWindowsSurface> mTranslucentSurface;
nsRefPtr<gfxWindowsSurface> mTransparentSurface;
HDC mMemoryDC;
HBITMAP mMemoryBitmap;
PRUint8* mMemoryBits;
PRUint8* mAlphaMask;
PRPackedBool mIsTranslucent;
PRPackedBool mIsTopTranslucent; // Topmost window itself or any of it's child windows has tranlucency enabled
PRPackedBool mIsTransparent;
PRPackedBool mIsTopTransparent; // Topmost window itself or any of it's child windows has tranlucency enabled
#endif
PRPackedBool mHasAeroGlass;
PRPackedBool mIsTopWidgetWindow;

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

@ -534,20 +534,15 @@ NS_IMETHODIMP nsBaseWidget::SetWindowType(nsWindowType aWindowType)
//
//-------------------------------------------------------------------------
NS_IMETHODIMP nsBaseWidget::SetWindowTranslucency(PRBool aTranslucent) {
NS_IMETHODIMP nsBaseWidget::SetHasTransparentBackground(PRBool aTransparent) {
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsBaseWidget::GetWindowTranslucency(PRBool& aTranslucent) {
aTranslucent = PR_FALSE;
NS_IMETHODIMP nsBaseWidget::GetHasTransparentBackground(PRBool& aTransparent) {
aTransparent = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP nsBaseWidget::UpdateTranslucentWindowAlpha(const nsRect& aRect, PRUint8* aAlphas) {
NS_ASSERTION(PR_FALSE, "Window is not translucent");
return NS_ERROR_NOT_IMPLEMENTED;
}
//-------------------------------------------------------------------------
//
// Hide window borders/decorations for this widget

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

@ -103,9 +103,8 @@ public:
PRUint32 aHotspotX, PRUint32 aHotspotY);
NS_IMETHOD GetWindowType(nsWindowType& aWindowType);
NS_IMETHOD SetWindowType(nsWindowType aWindowType);
NS_IMETHOD SetWindowTranslucency(PRBool aTranslucent);
NS_IMETHOD GetWindowTranslucency(PRBool& aTranslucent);
NS_IMETHOD UpdateTranslucentWindowAlpha(const nsRect& aRect, PRUint8* aAlphas);
NS_IMETHOD SetHasTransparentBackground(PRBool aTransparent);
NS_IMETHOD GetHasTransparentBackground(PRBool& aTransparent);
NS_IMETHOD HideWindowChrome(PRBool aShouldHide);
NS_IMETHOD MakeFullScreen(PRBool aFullScreen);
nsresult MakeFullScreenInternal(PRBool aFullScreen);