Bug 527685 - Simplify widget transparency handling. r=josh, r=roc

Store the window's transparency state on the NSWindow and use it for all of its subviews, instead of only making the top-level NSView transparent.

--HG--
extra : rebase_source : 88cbbc9104a156f236464722cadd8194d47a1584
This commit is contained in:
Markus Stange 2009-11-13 23:58:15 +01:00
Родитель a219f3c5ab
Коммит 86e667ba3d
4 изменённых файлов: 10 добавлений и 48 удалений

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

@ -155,9 +155,6 @@ enum {
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;
PRIntervalTime mLastShadowInvalidation;
BOOL mNeedsShadowInvalidation;
@ -207,8 +204,6 @@ enum {
// Stop NSView hierarchy being changed during [ChildView drawRect:]
- (void)delayedTearDown;
- (void)setTransparent:(BOOL)transparent;
- (void)sendFocusEvent:(PRUint32)eventType;
- (void)handleMouseMoved:(NSEvent*)aEvent;

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

@ -807,12 +807,12 @@ void* nsChildView::GetNativeData(PRUint32 aDataType)
nsTransparencyMode nsChildView::GetTransparencyMode()
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
return [mView isOpaque] ? eTransparencyOpaque : eTransparencyTransparent;
nsCocoaWindow* windowWidget = GetXULWindowWidget();
return windowWidget ? windowWidget->GetTransparencyMode() : eTransparencyOpaque;
NS_OBJC_END_TRY_ABORT_BLOCK;
return eTransparencyOpaque;
NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(eTransparencyOpaque);
}
// This is called by nsContainerFrame on the root widget for all window types
@ -821,14 +821,9 @@ void nsChildView::SetTransparencyMode(nsTransparencyMode aMode)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
BOOL isTransparent = aMode == eTransparencyTransparent;
BOOL currentTransparency = ![[mView window] isOpaque];
if (isTransparent != currentTransparency) {
nsCocoaWindow *widget = GetXULWindowWidget();
if (widget) {
widget->MakeBackgroundTransparent(aMode);
[(ChildView*)mView setTransparent:isTransparent];
}
nsCocoaWindow* windowWidget = GetXULWindowWidget();
if (windowWidget) {
windowWidget->SetTransparencyMode(aMode);
}
NS_OBJC_END_TRY_ABORT_BLOCK;
@ -2397,14 +2392,9 @@ NSEvent* gLastDragMouseDownEvent = nil;
return YES;
}
- (void)setTransparent:(BOOL)transparent
{
mIsTransparent = transparent;
}
- (BOOL)isOpaque
{
return !mIsTransparent;
return [[self window] isOpaque];
}
-(void)setIsPluginView:(BOOL)aIsPlugin

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

@ -272,8 +272,6 @@ public:
// nsIKBStateControl interface
NS_IMETHOD ResetInputState();
void MakeBackgroundTransparent(PRBool aTransparent);
NS_IMETHOD BeginSecureKeyboardInput();
NS_IMETHOD EndSecureKeyboardInput();

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

@ -804,19 +804,6 @@ nsCocoaWindow::Scroll(const nsIntPoint& aDelta,
}
}
void nsCocoaWindow::MakeBackgroundTransparent(PRBool aTransparent)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
BOOL currentTransparency = ![mWindow isOpaque];
if (aTransparent != currentTransparency) {
[mWindow setOpaque:!aTransparent];
[mWindow setBackgroundColor:(aTransparent ? [NSColor clearColor] : [NSColor whiteColor])];
}
NS_OBJC_END_TRY_ABORT_BLOCK;
}
nsTransparencyMode nsCocoaWindow::GetTransparencyMode()
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
@ -833,18 +820,10 @@ void nsCocoaWindow::SetTransparencyMode(nsTransparencyMode aMode)
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
BOOL isTransparent = aMode == eTransparencyTransparent;
BOOL currentTransparency = ![mWindow isOpaque];
if (isTransparent != currentTransparency) {
// Take care of window transparency
MakeBackgroundTransparent(isTransparent);
// Make sure our content view is also transparent
if (mPopupContentView) {
ChildView *childView = (ChildView*)mPopupContentView->GetNativeData(NS_NATIVE_WIDGET);
if (childView) {
[childView setTransparent:isTransparent];
}
}
[mWindow setOpaque:!isTransparent];
[mWindow setBackgroundColor:(isTransparent ? [NSColor clearColor] : [NSColor whiteColor])];
}
NS_OBJC_END_TRY_ABORT_BLOCK;