Implement Aero Glass effect support - bug 418454 r=vlad r=roc
authorRob Arnold <robarnold@mozilla.com>
Tue, 12 Aug 2008 17:44:14 -0700
changeset 16601 460fce61ebc7
parent 16600 b5c8ab76e729
child 16602 66ab9c4075c4
push id1169
push userrobarnold@cmu.edu
push date2008-08-13 00:44 +0000
treeherdermozilla-central@460fce61ebc7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvlad, roc
bugs418454
milestone1.9.1a2pre
Implement Aero Glass effect support - bug 418454 r=vlad r=roc
gfx/public/nsThemeConstants.h
layout/base/nsCSSRendering.cpp
layout/base/nsLayoutUtils.cpp
layout/base/nsLayoutUtils.h
layout/base/nsPresShell.cpp
layout/generic/nsContainerFrame.cpp
layout/style/nsCSSKeywordList.h
layout/style/nsCSSProps.cpp
layout/style/nsCSSRuleProcessor.cpp
layout/xul/base/src/nsMenuPopupFrame.cpp
view/src/nsViewManager.cpp
widget/public/nsILookAndFeel.h
widget/public/nsIWidget.h
widget/src/beos/nsLookAndFeel.cpp
widget/src/cocoa/nsChildView.h
widget/src/cocoa/nsChildView.mm
widget/src/cocoa/nsCocoaWindow.h
widget/src/cocoa/nsCocoaWindow.mm
widget/src/cocoa/nsLookAndFeel.mm
widget/src/gtk2/nsLookAndFeel.cpp
widget/src/gtk2/nsWindow.cpp
widget/src/gtk2/nsWindow.h
widget/src/os2/nsLookAndFeel.cpp
widget/src/photon/nsLookAndFeel.cpp
widget/src/windows/nsLookAndFeel.cpp
widget/src/windows/nsUXThemeData.cpp
widget/src/windows/nsUXThemeData.h
widget/src/windows/nsWindow.cpp
widget/src/windows/nsWindow.h
widget/src/xpwidgets/nsBaseWidget.cpp
widget/src/xpwidgets/nsBaseWidget.h
--- a/gfx/public/nsThemeConstants.h
+++ b/gfx/public/nsThemeConstants.h
@@ -233,8 +233,11 @@
 #define NS_THEME_MENUIMAGE                                 219
 // For text on non-iconic menuitems only
 #define NS_THEME_MENUITEMTEXT                              220
 
 // Vista Rebars
 #define NS_THEME_WIN_COMMUNICATIONS_TOOLBOX                221
 #define NS_THEME_WIN_MEDIA_TOOLBOX                         222
 #define NS_THEME_WIN_BROWSER_TAB_BAR_TOOLBOX               223
+
+// Vista glass
+#define NS_THEME_WIN_GLASS                                 230
--- a/layout/base/nsCSSRendering.cpp
+++ b/layout/base/nsCSSRendering.cpp
@@ -1307,19 +1307,19 @@ nsCSSRendering::PaintBackground(nsPresCo
   nsIViewManager* vm = aPresContext->GetViewManager();
 
   if (canvasColor.mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT) {
     nsIView* rootView;
     vm->GetRootView(rootView);
     if (!rootView->GetParent()) {
       PRBool widgetIsTransparent = PR_FALSE;
 
-      if (rootView->HasWidget()) {
-        rootView->GetWidget()->GetHasTransparentBackground(widgetIsTransparent);
-      }
+      if (rootView->HasWidget())
+        // We don't want to draw a bg for glass windows either
+        widgetIsTransparent = eTransparencyOpaque != rootView->GetWidget()->GetTransparencyMode();
       
       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;
         canvasColor.mBackgroundColor = aPresContext->DefaultBackgroundColor();
       }
     }
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -65,16 +65,17 @@
 #include "imgIContainer.h"
 #include "gfxRect.h"
 #include "gfxContext.h"
 #include "gfxFont.h"
 #include "nsIImage.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsCSSRendering.h"
 #include "nsContentUtils.h"
+#include "nsThemeConstants.h"
 #include "nsPIDOMWindow.h"
 #include "nsIBaseWindow.h"
 #include "nsIDocShell.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsIWidget.h"
 
 #ifdef MOZ_SVG
 #include "nsSVGUtils.h"
@@ -2631,47 +2632,49 @@ static PRBool NonZeroStyleCoord(const ns
     return aCoord.GetPercentValue() > 0;
   case eStyleUnit_Coord:
     return aCoord.GetCoordValue() > 0;
   default:
     return PR_TRUE;
   }
 }
 
-/* static */ PRBool
+/* static */ PRBool 
 nsLayoutUtils::HasNonZeroSide(const nsStyleSides& aSides)
 {
   return NonZeroStyleCoord(aSides.GetTop()) ||
          NonZeroStyleCoord(aSides.GetRight()) ||
          NonZeroStyleCoord(aSides.GetBottom()) ||
          NonZeroStyleCoord(aSides.GetLeft());
 }
 
-/* static */ PRBool
-nsLayoutUtils::FrameHasTransparency(nsIFrame* aFrame) {
+/* static */ nsTransparencyMode
+nsLayoutUtils::GetFrameTransparency(nsIFrame* aFrame) {
   if (aFrame->GetStyleContext()->GetStyleDisplay()->mOpacity < 1.0f)
-    return PR_TRUE;
+    return eTransparencyTransparent;
 
   if (HasNonZeroSide(aFrame->GetStyleContext()->GetStyleBorder()->mBorderRadius))
-    return PR_TRUE;
+    return eTransparencyTransparent;
 
   if (aFrame->IsThemed())
-    return PR_FALSE;
+    return eTransparencyOpaque;
 
+  if (aFrame->GetStyleDisplay()->mAppearance == NS_THEME_WIN_GLASS)
+    return eTransparencyGlass;
   PRBool isCanvas;
   const nsStyleBackground* bg;
   if (!nsCSSRendering::FindBackground(aFrame->PresContext(), aFrame, &bg, &isCanvas))
-    return PR_TRUE;
+    return eTransparencyTransparent;
   if (bg->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT)
-    return PR_TRUE;
+    return eTransparencyTransparent;
   if (NS_GET_A(bg->mBackgroundColor) < 255)
-    return PR_TRUE;
+    return eTransparencyTransparent;
   if (bg->mBackgroundClip != NS_STYLE_BG_CLIP_BORDER)
-    return PR_TRUE;
-  return PR_FALSE;
+    return eTransparencyTransparent;
+  return eTransparencyOpaque;
 }
 
 static PRBool
 IsNonzeroCoord(const nsStyleCoord& aCoord)
 {
   if (eStyleUnit_Coord == aCoord.GetUnit())
     return aCoord.GetCoordValue() != 0;
   return PR_FALSE;
--- a/layout/base/nsLayoutUtils.h
+++ b/layout/base/nsLayoutUtils.h
@@ -739,17 +739,17 @@ public:
    */
   static PRBool HasNonZeroSide(const nsStyleSides& aSides);
 
   /**
    * Determine if a widget is likely to require transparency or translucency.
    *   @param aFrame the frame of a <window>, <popup> or <menupopup> element.
    *   @return a value suitable for passing to SetWindowTranslucency
    */
-  static PRBool FrameHasTransparency(nsIFrame* aFrame);
+  static nsTransparencyMode GetFrameTransparency(nsIFrame* aFrame);
 
   /**
    * Get textrun construction flags determined by a given style; in particular
    * some combination of:
    * -- TEXT_DISABLE_OPTIONAL_LIGATURES if letter-spacing is in use
    * -- TEXT_OPTIMIZE_SPEED if the text-rendering CSS property and font size
    * and prefs indicate we should be optimizing for speed over quality
    */
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -5401,19 +5401,18 @@ PresShell::Paint(nsIView*             aV
 
   NS_ASSERTION(!(nsnull == aView), "null view");
 
   frame = static_cast<nsIFrame*>(aView->GetClientData());
   nscolor backgroundColor;
   mViewManager->GetDefaultBackgroundColor(&backgroundColor);
   for (nsIView *view = aView; view; view = view->GetParent()) {
     if (view->HasWidget()) {
-      PRBool widgetIsTransparent;
-      view->GetWidget()->GetHasTransparentBackground(widgetIsTransparent);
-      if (widgetIsTransparent) {
+      // Both glass and transparent windows need the transparent bg color
+      if (eTransparencyOpaque != view->GetWidget()->GetTransparencyMode()) {
         backgroundColor = NS_RGBA(0,0,0,0);
         break;
       }
     }
   }
   
   if (!frame) {
     if (NS_GET_A(backgroundColor) > 0) {
--- a/layout/generic/nsContainerFrame.cpp
+++ b/layout/generic/nsContainerFrame.cpp
@@ -65,16 +65,19 @@
 #include "nsTransform2D.h"
 #include "nsRegion.h"
 #include "nsLayoutErrors.h"
 #include "nsDisplayList.h"
 #include "nsContentErrors.h"
 #include "nsIEventStateManager.h"
 #include "nsListControlFrame.h"
 #include "nsIBaseWindow.h"
+#include "nsThemeConstants.h"
+#include "nsCSSFrameConstructor.h"
+#include "nsThemeConstants.h"
 
 #ifdef NS_DEBUG
 #undef NOISY
 #else
 #undef NOISY
 #endif
 
 nsContainerFrame::~nsContainerFrame()
@@ -490,17 +493,25 @@ SyncFrameViewGeometryDependentProperties
     nsCSSRendering::FindBackground(aPresContext, aFrame, &bg, &isCanvas);
 
   if (isCanvas) {
     nsIView* rootView;
     vm->GetRootView(rootView);
 
     if (aView->HasWidget() && aView == rootView &&
         IsTopLevelWidget(aPresContext)) {
-      aView->GetWidget()->SetHasTransparentBackground(nsLayoutUtils::FrameHasTransparency(aFrame));
+      // The issue here is that the CSS 'background' propagates from the root
+      // element's frame (rootFrame) to the real root frame (nsViewportFrame),
+      // so we need to call GetFrameTransparency on that. But -moz-appearance
+      // does not propagate so we need to check that directly on rootFrame.
+      nsTransparencyMode mode = nsLayoutUtils::GetFrameTransparency(aFrame);
+      nsIFrame *rootFrame = aPresContext->PresShell()->FrameConstructor()->GetRootElementStyleFrame();
+      if(rootFrame && NS_THEME_WIN_GLASS == rootFrame->GetStyleDisplay()->mAppearance)
+        mode = eTransparencyGlass;
+      aView->GetWidget()->SetTransparencyMode(mode);
     }
   }
 }
 
 void
 nsContainerFrame::SyncFrameViewAfterReflow(nsPresContext* aPresContext,
                                            nsIFrame*       aFrame,
                                            nsIView*        aView,
--- a/layout/style/nsCSSKeywordList.h
+++ b/layout/style/nsCSSKeywordList.h
@@ -565,16 +565,17 @@ CSS_KEY(radio-container, radiocontainer)
 CSS_KEY(checkbox-label, checkboxlabel)
 CSS_KEY(radio-label, radiolabel)
 CSS_KEY(button-focus, buttonfocus)
 CSS_KEY(-moz-win-media-toolbox, _moz_win_media_toolbox)
 CSS_KEY(-moz-win-communications-toolbox, _moz_win_communications_toolbox)
 CSS_KEY(-moz-win-browsertabbar-toolbox, _moz_win_browsertabbar_toolbox)
 CSS_KEY(-moz-win-mediatext, _moz_win_mediatext)
 CSS_KEY(-moz-win-communicationstext, _moz_win_communicationstext)
+CSS_KEY(-moz-win-glass, _moz_win_glass)
 
 #ifdef MOZ_SVG
 //CSS_KEY(all, all)
 CSS_KEY(alphabetic, alphabetic)
 //CSS_KEY(auto, auto)
 CSS_KEY(bevel, bevel)
 CSS_KEY(butt, butt)
 CSS_KEY(central, central)
--- a/layout/style/nsCSSProps.cpp
+++ b/layout/style/nsCSSProps.cpp
@@ -324,16 +324,17 @@ const PRInt32 nsCSSProps::kAppearanceKTa
   eCSSKeyword_menuradio,              NS_THEME_MENURADIO,
   eCSSKeyword_menuseparator,          NS_THEME_MENUSEPARATOR,
   eCSSKeyword_menuarrow,              NS_THEME_MENUARROW,
   eCSSKeyword_menuimage,              NS_THEME_MENUIMAGE,
   eCSSKeyword_menuitemtext,           NS_THEME_MENUITEMTEXT,
   eCSSKeyword__moz_win_media_toolbox, NS_THEME_WIN_MEDIA_TOOLBOX,
   eCSSKeyword__moz_win_communications_toolbox, NS_THEME_WIN_COMMUNICATIONS_TOOLBOX,
   eCSSKeyword__moz_win_browsertabbar_toolbox,  NS_THEME_WIN_BROWSER_TAB_BAR_TOOLBOX,
+  eCSSKeyword__moz_win_glass,         NS_THEME_WIN_GLASS,
   eCSSKeyword_UNKNOWN,-1
 };
 
 // Keyword id tables for variant/enum parsing
 const PRInt32 nsCSSProps::kAzimuthKTable[] = {
   eCSSKeyword_left_side,    NS_STYLE_AZIMUTH_LEFT_SIDE,
   eCSSKeyword_far_left,     NS_STYLE_AZIMUTH_FAR_LEFT,
   eCSSKeyword_left,         NS_STYLE_AZIMUTH_LEFT,
--- a/layout/style/nsCSSRuleProcessor.cpp
+++ b/layout/style/nsCSSRuleProcessor.cpp
@@ -19,16 +19,17 @@
  * Netscape Communications Corporation.
  * Portions created by the Initial Developer are Copyright (C) 1998
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   L. David Baron <dbaron@dbaron.org>
  *   Daniel Glazman <glazman@netscape.com>
  *   Ehsan Akhgari <ehsan.akhgari@gmail.com>
+ *   Rob Arnold <robarnold@mozilla.com>
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either of the GNU General Public License Version 2 or later (the "GPL"),
  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  * in which case the provisions of the GPL or the LGPL are applicable instead
  * of those above. If you wish to allow use of your version of this file only
  * under the terms of either the GPL or the LGPL, and not to allow others to
  * use your version of this file under the terms of the MPL, indicate your
@@ -786,16 +787,21 @@ InitSystemMetrics()
     sSystemMetrics->AppendElement(do_GetAtom("images-in-menus"));
   }
 
   rv = lookAndFeel->GetMetric(nsILookAndFeel::eMetric_WindowsDefaultTheme, metricResult);
   if (NS_SUCCEEDED(rv) && metricResult) {
     sSystemMetrics->AppendElement(do_GetAtom("windows-default-theme"));
   }
 
+  rv = lookAndFeel->GetMetric(nsILookAndFeel::eMetric_DWMCompositor, metricResult);
+  if (NS_SUCCEEDED(rv) && metricResult) {
+    sSystemMetrics->AppendElement(do_GetAtom("windows-compositor"));
+  }
+
   return PR_TRUE;
 }
 
 /* static */ void
 nsCSSRuleProcessor::FreeSystemMetrics()
 {
   delete sSystemMetrics;
   sSystemMetrics = nsnull;
--- a/layout/xul/base/src/nsMenuPopupFrame.cpp
+++ b/layout/xul/base/src/nsMenuPopupFrame.cpp
@@ -206,17 +206,18 @@ nsMenuPopupFrame::CreateWidgetForView(ns
   // Create a widget for ourselves.
   nsWidgetInitData widgetData;
   widgetData.mWindowType = eWindowType_popup;
   widgetData.mBorderStyle = eBorderStyle_default;
   widgetData.clipSiblings = PR_TRUE;
   widgetData.mPopupHint = mPopupType;
 
   PRBool viewHasTransparentContent = !mInContentShell &&
-                                     nsLayoutUtils::FrameHasTransparency(this);
+                                     (eTransparencyTransparent ==
+                                      nsLayoutUtils::GetFrameTransparency(this));
   nsIContent* parentContent = GetContent()->GetParent();
   nsIAtom *tag = nsnull;
   if (parentContent)
     tag = parentContent->Tag();
   widgetData.mDropShadow = !(viewHasTransparentContent || tag == nsGkAtoms::menulist);
 
   // panels which don't auto-hide need a parent widget. This allows them
   // to always appear in front of the parent window but behind other windows
@@ -241,17 +242,18 @@ nsMenuPopupFrame::CreateWidgetForView(ns
   static NS_DEFINE_IID(kCPopupCID,  NS_POPUP_CID);
   aView->CreateWidget(kCPopupCID, &widgetData, nsnull, PR_TRUE, PR_TRUE, 
                       eContentTypeUI, parentWidget);
 #else
   static NS_DEFINE_IID(kCChildCID,  NS_CHILD_CID);
   aView->CreateWidget(kCChildCID, &widgetData, nsnull, PR_TRUE, PR_TRUE,
                       eContentTypeInherit, parentWidget);
 #endif
-  aView->GetWidget()->SetHasTransparentBackground(viewHasTransparentContent);
+  aView->GetWidget()->SetTransparencyMode(viewHasTransparentContent ?
+      eTransparencyTransparent : eTransparencyOpaque);
   return NS_OK;
 }
 
 // this class is used for dispatching popupshowing events asynchronously.
 class nsXULPopupShownEvent : public nsRunnable
 {
 public:
   nsXULPopupShownEvent(nsIContent *aPopup, nsPresContext* aPresContext)
--- a/view/src/nsViewManager.cpp
+++ b/view/src/nsViewManager.cpp
@@ -1095,17 +1095,17 @@ NS_IMETHODIMP nsViewManager::DispatchEve
             // XXXbz do we need to notify other view observers for viewmanagers
             // in our tree?
             // Make sure to not send WillPaint notifications while scrolling
             nsRefPtr<nsViewManager> rootVM = RootViewManager();
 
             nsIWidget *widget = mRootView->GetWidget();
             PRBool transparentWindow = PR_FALSE;
             if (widget)
-                widget->GetHasTransparentBackground(transparentWindow);
+                transparentWindow = widget->GetTransparencyMode() == eTransparencyTransparent;
 
             if (rootVM->mScrollCnt == 0 && !transparentWindow) {
               nsIViewObserver* observer = GetViewObserver();
               if (observer) {
                 // Do an update view batch.  Make sure not to do it DEFERRED,
                 // since that would effectively delay any invalidates that are
                 // triggered by the WillPaint notification (they'd happen when
                 // the invalid event fires, which is later than the reflow
--- a/widget/public/nsILookAndFeel.h
+++ b/widget/public/nsILookAndFeel.h
@@ -231,16 +231,24 @@ public:
      * being used.
      *
      * The value of this metric is not used on other platforms. These platforms
      * should return NS_ERROR_NOT_IMPLEMENTED when queried for this metric.
      */
     eMetric_WindowsDefaultTheme,
 
     /*
+     * A Boolean value to determine whether the DWM compositor is being used
+     *
+     * This metric is not used on non-Windows platforms. These platforms
+     * should return NS_ERROR_NOT_IMPLEMENTED when queried for this metric.
+     */
+    eMetric_DWMCompositor,
+
+    /*
      * eMetric_AlertNotificationOrigin indicates from which corner of the
      * screen alerts slide in, and from which direction (horizontal/vertical).
      * 0, the default, represents bottom right, sliding vertically.
      * Use any bitwise combination of the following constants:
      * NS_ALERT_HORIZONTAL (1), NS_ALERT_LEFT (2), NS_ALERT_TOP (4).
      *
      *       6       4
      *     +-----------+
--- a/widget/public/nsIWidget.h
+++ b/widget/public/nsIWidget.h
@@ -89,20 +89,20 @@ typedef nsEventStatus (*PR_CALLBACK EVEN
 #define NS_NATIVE_PLUGIN_PORT 8
 #define NS_NATIVE_SCREEN      9
 #define NS_NATIVE_SHELLWIDGET 10      // Get the shell GtkWidget
 #ifdef XP_MACOSX
 #define NS_NATIVE_PLUGIN_PORT_QD    100
 #define NS_NATIVE_PLUGIN_PORT_CG    101
 #endif
 
-// 3d304df2-8e6b-4f09-8782-98bd649c7e96
+// AE42543F-BF61-4164-96BA-AF8F4EDCEEAD
 #define NS_IWIDGET_IID \
-{ 0x3d304df2, 0x8e6b, 0x4f09, \
-  { 0x87, 0x82, 0x98, 0xbd, 0x64, 0x9c, 0x7e, 0x96 } }
+{ 0xae42543f, 0xbf61, 0x4164, \
+  { 0x96, 0xba, 0xaf, 0x8f, 0x4e, 0xdc, 0xee, 0xad } }
 
 // Hide the native window systems real window type so as to avoid
 // including native window system types and APIs. This is necessary
 // to ensure cross-platform code.
 typedef void* nsNativeWidget;
 
 /**
  * Border styles
@@ -225,16 +225,22 @@ enum nsContentType {
 };
 
 enum nsTopLevelWidgetZPlacement { // for PlaceBehind()
   eZPlacementBottom = 0,  // bottom of the window stack
   eZPlacementBelow,       // just below another widget
   eZPlacementTop          // top of the window stack
 };
 
+enum nsTransparencyMode {
+  eTransparencyOpaque = 0,  // Fully opaque
+  eTransparencyTransparent, // Parts of the window may be transparent
+  eTransparencyGlass        // Transparent parts of the window have Vista AeroGlass effect applied
+};
+
 /**
  * Basic struct for widget initialization data.
  * @see Create member function of nsIWidget
  */
 
 struct nsWidgetInitData {
   nsWidgetInitData()
     : clipChildren(PR_FALSE), 
@@ -668,43 +674,39 @@ class nsIWidget : public nsISupports {
     /** 
      * Get the window type of this widget
      *
      * @param aWindowType the window type of the widget
      */
     NS_IMETHOD GetWindowType(nsWindowType& aWindowType) = 0;
 
     /**
-     * Set the translucency of the top-level window containing this widget.
+     * Set the transparency mode of the top-level window containing this widget.
      * So, e.g., if you call this on the widget for an IFRAME, the top level
      * browser window containing the IFRAME actually gets set. Be careful.
      *
      * This can fail if the platform doesn't support
-     * transparency/translucency. By default widgets are not
+     * transparency/glass. By default widgets are not
      * transparent.  This will also fail if the toplevel window is not
      * a Mozilla window, e.g., if the widget is in an embedded
      * context.
      *
-     * After translucency has been enabled, the initial alpha channel
+     * After transparency/glass has been enabled, the initial alpha channel
      * value for all pixels is 1, i.e., opaque.
      * 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 aTransparent true if the window may have translucent
-     *   or transparent pixels
      */
-    NS_IMETHOD SetHasTransparentBackground(PRBool aTransparent) = 0;
+    virtual void SetTransparencyMode(nsTransparencyMode aMode) = 0;
 
     /**
-     * Get the translucency of the top-level window that contains this
+     * Get the transparency mode of the top-level window that contains this
      * widget.
-     * @param aTransparent true if the window may have translucent or
-     *   transparent pixels
      */
-    NS_IMETHOD GetHasTransparentBackground(PRBool& aTransparent) = 0;
+    virtual nsTransparencyMode GetTransparencyMode() = 0;
 
     /** 
      * Hide window chrome (borders, buttons) for this widget.
      *
      */
     NS_IMETHOD HideWindowChrome(PRBool aShouldHide) = 0;
 
     /**
--- a/widget/src/beos/nsLookAndFeel.cpp
+++ b/widget/src/beos/nsLookAndFeel.cpp
@@ -416,16 +416,17 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(c
       aMetric = 150;
       break;
     case eMetric_TreeScrollDelay:
       aMetric = 100;
       break;
     case eMetric_TreeScrollLinesMax:
       aMetric = 3;
       break;
+    case eMetric_DWMCompositor:
     case eMetric_WindowsDefaultTheme:
       aMetric = 0;
       res = NS_ERROR_NOT_IMPLEMENTED;
       break;
     case eMetric_IMERawInputUnderlineStyle:
     case eMetric_IMEConvertedTextUnderlineStyle:
       aMetric = NS_UNDERLINE_STYLE_SOLID;
       break;
--- a/widget/src/cocoa/nsChildView.h
+++ b/widget/src/cocoa/nsChildView.h
@@ -346,18 +346,18 @@ public:
                                        PRBool* aLEDState);
 
   // nsIPluginWidget
   NS_IMETHOD        GetPluginClipRect(nsRect& outClipRect, nsPoint& outOrigin, PRBool& outWidgetVisible);
   NS_IMETHOD        StartDrawPlugin();
   NS_IMETHOD        EndDrawPlugin();
   NS_IMETHOD        SetPluginInstanceOwner(nsIPluginInstanceOwner* aInstanceOwner);
   
-  NS_IMETHOD        GetHasTransparentBackground(PRBool& aTransparent);
-  NS_IMETHOD        SetHasTransparentBackground(PRBool aTransparent);
+  virtual nsTransparencyMode GetTransparencyMode();
+  virtual void                SetTransparencyMode(nsTransparencyMode aMode);
   
   // Mac specific methods
   virtual PRBool    PointInWidget(Point aThePoint);
   
   virtual PRBool    DispatchWindowEvent(nsGUIEvent& event);
   
   void              LiveResizeStarted();
   void              LiveResizeEnded();
--- a/widget/src/cocoa/nsChildView.mm
+++ b/widget/src/cocoa/nsChildView.mm
@@ -747,49 +747,49 @@ void* nsChildView::GetNativeData(PRUint3
 
   return retVal;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSNULL;
 }
 
 #pragma mark -
 
-NS_IMETHODIMP nsChildView::GetHasTransparentBackground(PRBool& aTransparent)
-{
-  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
-
-  aTransparent = ![mView isOpaque];
-  return NS_OK;
-
-  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
+nsTransparencyMode nsChildView::GetTransparencyMode()
+{
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
+
+  return [mView isOpaque] ? eTransparencyOpaque : eTransparencyTransparent;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK;
+  return eTransparencyOpaque;
 }
 
 
 // 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)
-{
-  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
-
+// except popup windows (when nsCocoaWindow::SetTransparencyMode is used instead).
+void nsChildView::SetTransparencyMode(nsTransparencyMode aMode)
+{
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
+
+  BOOL isTransparent = aMode == eTransparencyTransparent;
   BOOL currentTransparency = ![[mView nativeWindow] isOpaque];
-  if (aTransparent != currentTransparency) {
+  if (isTransparent != 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);
-        [(ChildView*)mView setTransparent:aTransparent];
+        widget->MakeBackgroundTransparent(aMode);
+        [(ChildView*)mView setTransparent:isTransparent];
       }
     }
   }
-  return NS_OK;
-
-  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
 
 NS_IMETHODIMP nsChildView::IsVisible(PRBool& outState)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
   if (!mVisible) {
--- a/widget/src/cocoa/nsCocoaWindow.h
+++ b/widget/src/cocoa/nsCocoaWindow.h
@@ -242,18 +242,18 @@ public:
     NS_IMETHOD SetColorMap(nsColorMap *aColorMap) { return NS_OK; }
     NS_IMETHOD BeginResizingChildren(void) { return NS_OK; }
     NS_IMETHOD EndResizingChildren(void) { return NS_OK; }
     NS_IMETHOD GetPreferredSize(PRInt32& aWidth, PRInt32& aHeight) { return NS_OK; }
     NS_IMETHOD SetPreferredSize(PRInt32 aWidth, PRInt32 aHeight) { return NS_OK; }
     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);
+    virtual nsTransparencyMode GetTransparencyMode();
+    virtual void SetTransparencyMode(nsTransparencyMode aMode);
     NS_IMETHOD SetWindowTitlebarColor(nscolor aColor, PRBool aActive);
 
     virtual gfxASurface* GetThebesSurface();
 
     // be notified that a some form of drag event needs to go into Gecko
     virtual PRBool DragEvent(unsigned int aMessage, Point aMouseGlobal, UInt16 aKeyModifiers);
 
     // Helpers to prevent recursive resizing during live-resize
--- a/widget/src/cocoa/nsCocoaWindow.mm
+++ b/widget/src/cocoa/nsCocoaWindow.mm
@@ -802,48 +802,48 @@ void nsCocoaWindow::MakeBackgroundTransp
     [mWindow setBackgroundColor:(aTransparent ? [NSColor clearColor] : [NSColor whiteColor])];
     [mWindow setHasShadow:!aTransparent];
   }
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
 
-NS_IMETHODIMP nsCocoaWindow::GetHasTransparentBackground(PRBool& aTransparent)
+nsTransparencyMode nsCocoaWindow::GetTransparencyMode()
 {
-  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
-
-  aTransparent = ![mWindow isOpaque];   
-  return NS_OK;
-
-  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
+
+  return [mWindow isOpaque] ? eTransparencyOpaque : eTransparencyTransparent;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
 
 // This is called from nsMenuPopupFrame when making a popup transparent.
-// For other window types, nsChildView::SetHasTransparentBackground is used.
-NS_IMETHODIMP nsCocoaWindow::SetHasTransparentBackground(PRBool aTransparent)
+// For other window types, nsChildView::SetTransparencyMode is used.
+void nsCocoaWindow::SetTransparencyMode(nsTransparencyMode aMode)
 {
-  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
+
+  BOOL isTransparent = aMode == eTransparencyTransparent;
 
   BOOL currentTransparency = ![mWindow isOpaque];
-  if (aTransparent != currentTransparency) {
+  if (isTransparent != currentTransparency) {
     // Take care of window transparency
-    MakeBackgroundTransparent(aTransparent);
+    MakeBackgroundTransparent(isTransparent);
     // Make sure our content view is also transparent
     if (mPopupContentView) {
       ChildView *childView = (ChildView*)mPopupContentView->GetNativeData(NS_NATIVE_WIDGET);
       if (childView) {
-        [childView setTransparent:aTransparent];
+        [childView setTransparent:isTransparent];
       }
     }
   }
-  return NS_OK;
-
-  NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
+
+  NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
 
 NS_METHOD nsCocoaWindow::AddMouseListener(nsIMouseListener * aListener)
 {
   nsBaseWidget::AddMouseListener(aListener);
 
   if (mPopupContentView)
--- a/widget/src/cocoa/nsLookAndFeel.mm
+++ b/widget/src/cocoa/nsLookAndFeel.mm
@@ -595,16 +595,17 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(c
       aMetric = 150;
       break;
     case eMetric_TreeScrollDelay:
       aMetric = 100;
       break;
     case eMetric_TreeScrollLinesMax:
       aMetric = 3;
       break;
+    case eMetric_DWMCompositor:
     case eMetric_WindowsDefaultTheme:
       aMetric = 0;
       res = NS_ERROR_NOT_IMPLEMENTED;
       break;
     case eMetric_TabFocusModel:
     {
       // we should probably cache this
       CFPropertyListRef fullKeyboardAccessProperty;
--- a/widget/src/gtk2/nsLookAndFeel.cpp
+++ b/widget/src/gtk2/nsLookAndFeel.cpp
@@ -549,16 +549,17 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(c
         aMetric = 150;
         break;
     case eMetric_TreeScrollDelay:
         aMetric = 100;
         break;
     case eMetric_TreeScrollLinesMax:
         aMetric = 3;
         break;
+    case eMetric_DWMCompositor:
     case eMetric_WindowsDefaultTheme:
         aMetric = 0;
         res = NS_ERROR_NOT_IMPLEMENTED;
         break;
     case eMetric_IMERawInputUnderlineStyle:
     case eMetric_IMEConvertedTextUnderlineStyle:
         aMetric = NS_UNDERLINE_STYLE_SOLID;
         break;
--- a/widget/src/gtk2/nsWindow.cpp
+++ b/widget/src/gtk2/nsWindow.cpp
@@ -1744,17 +1744,17 @@ nsWindow::OnExposeEvent(GtkWidget *aWidg
 #ifdef MOZ_X11
     nsCOMPtr<nsIRenderingContext> rc = getter_AddRefs(GetRenderingContext());
     if (NS_UNLIKELY(!rc)) {
         g_free(rects);
         return FALSE;
     }
 
     PRBool translucent;
-    GetHasTransparentBackground(translucent);
+    translucent = eTransparencyTransparent == GetTransparencyMode();
     nsIntRect boundsRect;
     GdkPixmap* bufferPixmap = nsnull;
     nsRefPtr<gfxASurface> bufferPixmapSurface;
 
     updateRegion->GetBoundingBox(&boundsRect.x, &boundsRect.y,
                                  &boundsRect.width, &boundsRect.height);
 
     // do double-buffering and clipping here
@@ -3823,74 +3823,72 @@ void
 nsWindow::EnsureGrabs(void)
 {
     if (mRetryPointerGrab)
         GrabPointer();
     if (mRetryKeyboardGrab)
         GrabKeyboard();
 }
 
-NS_IMETHODIMP
-nsWindow::SetHasTransparentBackground(PRBool aTransparent)
+void
+nsWindow::SetTransparencyMode(nsTransparencyMode aMode)
 {
     if (!mShell) {
         // Pass the request to the toplevel window
         GtkWidget *topWidget = nsnull;
         GetToplevelWidget(&topWidget);
         if (!topWidget)
-            return NS_ERROR_FAILURE;
+            return;
 
         nsWindow *topWindow = get_window_for_gtk_widget(topWidget);
         if (!topWindow)
-            return NS_ERROR_FAILURE;
-
-        return topWindow->SetHasTransparentBackground(aTransparent);
-    }
-
-    if (mIsTransparent == aTransparent)
-        return NS_OK;
-
-    if (!aTransparent) {
+            return;
+
+        topWindow->SetTransparencyMode(aMode);
+        return;
+    }
+    PRBool isTransparent = aMode == eTransparencyTransparent;
+
+    if (mIsTransparent == isTransparent)
+        return;
+
+    if (!isTransparent) {
         if (mTransparencyBitmap) {
             delete[] mTransparencyBitmap;
             mTransparencyBitmap = nsnull;
             mTransparencyBitmapWidth = 0;
             mTransparencyBitmapHeight = 0;
             gtk_widget_reset_shapes(mShell);
         }
     } // else the new default alpha values are "all 1", so we don't
     // need to change anything yet
 
-    mIsTransparent = aTransparent;
-    return NS_OK;
-}
-
-NS_IMETHODIMP
-nsWindow::GetHasTransparentBackground(PRBool& aTransparent)
+    mIsTransparent = isTransparent;
+}
+
+nsTransparencyMode
+nsWindow::GetTransparencyMode()
 {
     if (!mShell) {
         // Pass the request to the toplevel window
         GtkWidget *topWidget = nsnull;
         GetToplevelWidget(&topWidget);
         if (!topWidget) {
-            aTransparent = PR_FALSE;
-            return NS_ERROR_FAILURE;
+            return eTransparencyOpaque;
         }
 
         nsWindow *topWindow = get_window_for_gtk_widget(topWidget);
         if (!topWindow) {
-            aTransparent = PR_FALSE;
-            return NS_ERROR_FAILURE;
+            return eTransparencyOpaque;
         }
 
-        return topWindow->GetHasTransparentBackground(aTransparent);
-    }
-
-    aTransparent = mIsTransparent;
-    return NS_OK;
+        return topWindow->GetTransparencyMode();
+    }
+
+    return mIsTransparent ? eTransparencyTransparent : eTransparencyOpaque;
 }
 
 void
 nsWindow::ResizeTransparencyBitmap(PRInt32 aNewWidth, PRInt32 aNewHeight)
 {
     if (!mTransparencyBitmap)
         return;
 
--- a/widget/src/gtk2/nsWindow.h
+++ b/widget/src/gtk2/nsWindow.h
@@ -361,18 +361,18 @@ public:
     NS_IMETHOD GetIMEEnabled(PRUint32* aState);
     NS_IMETHOD CancelIMEComposition();
     NS_IMETHOD GetToggledKeyState(PRUint32 aKeyCode, PRBool* aLEDState);
 
 #endif
 
    void                ResizeTransparencyBitmap(PRInt32 aNewWidth, PRInt32 aNewHeight);
    void                ApplyTransparencyBitmap();
-   NS_IMETHOD          SetHasTransparentBackground(PRBool aTransparent);
-   NS_IMETHOD          GetHasTransparentBackground(PRBool& aTransparent);
+   virtual void        SetTransparencyMode(nsTransparencyMode aMode);
+   virtual nsTransparencyMode GetTransparencyMode();
    nsresult            UpdateTranslucentWindowAlphaInternal(const nsRect& aRect,
                                                             PRUint8* aAlphas, PRInt32 aStride);
 
     gfxASurface       *GetThebesSurface();
 
     static already_AddRefed<gfxASurface> GetSurfaceForGdkDrawable(GdkDrawable* aDrawable,
                                                                   const nsSize& aSize);
 
--- a/widget/src/os2/nsLookAndFeel.cpp
+++ b/widget/src/os2/nsLookAndFeel.cpp
@@ -361,16 +361,17 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(c
         aMetric = 150;
         break;
     case eMetric_TreeScrollDelay:
         aMetric = 100;
         break;
     case eMetric_TreeScrollLinesMax:
         aMetric = 3;
         break;
+    case eMetric_DWMCompositor:
     case eMetric_WindowsDefaultTheme:
         aMetric = 0;
         res = NS_ERROR_NOT_IMPLEMENTED;
         break;
     case eMetric_IMERawInputUnderlineStyle:
     case eMetric_IMEConvertedTextUnderlineStyle:
         aMetric = NS_UNDERLINE_STYLE_SOLID;
         break;
--- a/widget/src/photon/nsLookAndFeel.cpp
+++ b/widget/src/photon/nsLookAndFeel.cpp
@@ -358,16 +358,17 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(c
     aMetric = 150;
     break;
   case eMetric_TreeScrollDelay:
     aMetric = 100;
     break;
   case eMetric_TreeScrollLinesMax:
     aMetric = 3;
     break;
+  case eMetric_DWMCompositor:
   case eMetric_WindowsDefaultTheme:
     aMetric = 0;
     res = NS_ERROR_NOT_IMPLEMENTED;
     break;
   case eMetric_IMERawInputUnderlineStyle:
   case eMetric_IMEConvertedTextUnderlineStyle:
     aMetric = NS_UNDERLINE_STYLE_SOLID;
     break;
--- a/widget/src/windows/nsLookAndFeel.cpp
+++ b/widget/src/windows/nsLookAndFeel.cpp
@@ -515,16 +515,19 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(c
           }
         } else
 #endif
         {
           res = NS_ERROR_NOT_IMPLEMENTED;
         }
         break;
 #ifndef WINCE
+    case eMetric_DWMCompositor:
+        aMetric = nsUXThemeData::sHaveCompositor;
+        break;
     case eMetric_AlertNotificationOrigin:
         aMetric = 0;
         if (gSHAppBarMessage)
         {
           // Get task bar window handle
           HWND shellWindow = FindWindow("Shell_TrayWnd", NULL);
 
           if (shellWindow != NULL)
--- a/widget/src/windows/nsUXThemeData.cpp
+++ b/widget/src/windows/nsUXThemeData.cpp
@@ -41,47 +41,59 @@
 #include "nsDebug.h"
 // For GetWindowsVersion
 #include "nsWindow.h"
 #include "nsUXThemeConstants.h"
 #include "nsUXThemeData.h"
 
 const char
 nsUXThemeData::kThemeLibraryName[] = "uxtheme.dll";
+const char
+nsUXThemeData::kDwmLibraryName[] = "dwmapi.dll";
 
 HANDLE
 nsUXThemeData::sThemes[eUXNumClasses];
 
 HMODULE
 nsUXThemeData::sThemeDLL = NULL;
+HMODULE
+nsUXThemeData::sDwmDLL = NULL;
 
 BOOL
 nsUXThemeData::sFlatMenus = FALSE;
 PRPackedBool
 nsUXThemeData::sIsXPOrLater = PR_FALSE;
 PRPackedBool
 nsUXThemeData::sIsVistaOrLater = PR_FALSE;
+PRPackedBool
+nsUXThemeData::sHaveCompositor = PR_FALSE;
 
 nsUXThemeData::OpenThemeDataPtr nsUXThemeData::openTheme = NULL;
 nsUXThemeData::CloseThemeDataPtr nsUXThemeData::closeTheme = NULL;
 nsUXThemeData::DrawThemeBackgroundPtr nsUXThemeData::drawThemeBG = NULL;
 nsUXThemeData::DrawThemeEdgePtr nsUXThemeData::drawThemeEdge = NULL;
 nsUXThemeData::GetThemeContentRectPtr nsUXThemeData::getThemeContentRect = NULL;
 nsUXThemeData::GetThemePartSizePtr nsUXThemeData::getThemePartSize = NULL;
 nsUXThemeData::GetThemeSysFontPtr nsUXThemeData::getThemeSysFont = NULL;
 nsUXThemeData::GetThemeColorPtr nsUXThemeData::getThemeColor = NULL;
 nsUXThemeData::GetThemeMarginsPtr nsUXThemeData::getThemeMargins = NULL;
 nsUXThemeData::IsAppThemedPtr nsUXThemeData::isAppThemed = NULL;
 nsUXThemeData::GetCurrentThemeNamePtr nsUXThemeData::getCurrentThemeName = NULL;
+nsUXThemeData::GetThemeSysColorPtr nsUXThemeData::getThemeSysColor = NULL;
+
+nsUXThemeData::DwmExtendFrameIntoClientAreaProc nsUXThemeData::dwmExtendFrameIntoClientAreaPtr = NULL;
+nsUXThemeData::DwmIsCompositionEnabledProc nsUXThemeData::dwmIsCompositionEnabledPtr = NULL;
 
 void
 nsUXThemeData::Teardown() {
   Invalidate();
   if(sThemeDLL)
     FreeLibrary(sThemeDLL);
+  if(sDwmDLL)
+    FreeLibrary(sDwmDLL);
 }
 
 void
 nsUXThemeData::Initialize()
 {
   ::ZeroMemory(sThemes, sizeof(sThemes));
   NS_ASSERTION(!sThemeDLL, "nsUXThemeData being initialized twice!");
   sThemeDLL = ::LoadLibrary(kThemeLibraryName);
@@ -92,16 +104,23 @@ nsUXThemeData::Initialize()
     drawThemeEdge = (DrawThemeEdgePtr)GetProcAddress(sThemeDLL, "DrawThemeEdge");
     getThemeContentRect = (GetThemeContentRectPtr)GetProcAddress(sThemeDLL, "GetThemeBackgroundContentRect");
     getThemePartSize = (GetThemePartSizePtr)GetProcAddress(sThemeDLL, "GetThemePartSize");
     getThemeSysFont = (GetThemeSysFontPtr)GetProcAddress(sThemeDLL, "GetThemeSysFont");
     getThemeColor = (GetThemeColorPtr)GetProcAddress(sThemeDLL, "GetThemeColor");
     getThemeMargins = (GetThemeMarginsPtr)GetProcAddress(sThemeDLL, "GetThemeMargins");
     isAppThemed = (IsAppThemedPtr)GetProcAddress(sThemeDLL, "IsAppThemed");
     getCurrentThemeName = (GetCurrentThemeNamePtr)GetProcAddress(sThemeDLL, "GetCurrentThemeName");
+    getThemeSysColor = (GetThemeSysColorPtr)GetProcAddress(sThemeDLL, "GetThemeSysColor");
+  }
+  sDwmDLL = ::LoadLibrary(kDwmLibraryName);
+  if(sDwmDLL) {
+    dwmExtendFrameIntoClientAreaPtr = (DwmExtendFrameIntoClientAreaProc)::GetProcAddress(sDwmDLL, "DwmExtendFrameIntoClientArea");
+    dwmIsCompositionEnabledPtr = (DwmIsCompositionEnabledProc)::GetProcAddress(sDwmDLL, "DwmIsCompositionEnabled");
+    CheckForCompositor();
   }
 
   PRInt32 version = ::GetWindowsVersion();
   sIsXPOrLater = version >= WINXP_VERSION;
   sIsVistaOrLater = version >= VISTA_VERSION;
   Invalidate();
 }
 
--- a/widget/src/windows/nsUXThemeData.h
+++ b/widget/src/windows/nsUXThemeData.h
@@ -35,16 +35,20 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 #include <Windows.h>
 #include "nscore.h"
 
+#ifndef WM_DWMCOMPOSITIONCHANGED
+#define WM_DWMCOMPOSITIONCHANGED        0x031E
+#endif
+
 enum nsUXThemeClass {
   eUXButton = 0,
   eUXEdit,
   eUXTooltip,
   eUXRebar,
   eUXMediaRebar,
   eUXCommunicationsRebar,
   eUXBrowserTabBarRebar,
@@ -69,42 +73,45 @@ struct MARGINS
   int cxLeftWidth;
   int cxRightWidth;
   int cyTopHeight;
   int cyBottomHeight;
 };
 
 class nsUXThemeData {
   static HMODULE sThemeDLL;
+  static HMODULE sDwmDLL;
   static HANDLE sThemes[eUXNumClasses];
   
   static const wchar_t *GetClassName(nsUXThemeClass);
 
 public:
   static const char kThemeLibraryName[];
+  static const char kDwmLibraryName[];
   static BOOL sFlatMenus;
   static PRPackedBool sIsXPOrLater;
   static PRPackedBool sIsVistaOrLater;
+  static PRPackedBool sHaveCompositor;
   static void Initialize();
   static void Teardown();
   static void Invalidate();
   static HANDLE GetTheme(nsUXThemeClass cls);
 
   static inline BOOL IsAppThemed() {
     return isAppThemed && isAppThemed();
   }
 
   static inline HRESULT GetThemeColor(nsUXThemeClass cls, int iPartId, int iStateId,
                                                    int iPropId, OUT COLORREF* pFont) {
     if(!getThemeColor)
       return E_FAIL;
     return getThemeColor(GetTheme(cls), iPartId, iStateId, iPropId, pFont);
   }
 
-  // Function typedefs and declarations
+  // UXTheme.dll Function typedefs and declarations
   typedef HANDLE (WINAPI*OpenThemeDataPtr)(HWND hwnd, LPCWSTR pszClassList);
   typedef HRESULT (WINAPI*CloseThemeDataPtr)(HANDLE hTheme);
   typedef HRESULT (WINAPI*DrawThemeBackgroundPtr)(HANDLE hTheme, HDC hdc, int iPartId, 
                                             int iStateId, const RECT *pRect,
                                             const RECT* pClipRect);
   typedef HRESULT (WINAPI*DrawThemeEdgePtr)(HANDLE hTheme, HDC hdc, int iPartId, 
                                             int iStateId, const RECT *pDestRect,
                                             uint uEdge, uint uFlags,
@@ -120,21 +127,37 @@ public:
                                      int iStateId, int iPropId, OUT COLORREF* pFont);
   typedef HRESULT (WINAPI*GetThemeMarginsPtr)(HANDLE hTheme, HDC hdc, int iPartId,
                                            int iStateid, int iPropId,
                                            LPRECT prc, MARGINS *pMargins);
   typedef BOOL (WINAPI*IsAppThemedPtr)(VOID);
   typedef HRESULT (WINAPI*GetCurrentThemeNamePtr)(LPWSTR pszThemeFileName, int dwMaxNameChars,
                                                   LPWSTR pszColorBuff, int cchMaxColorChars,
                                                   LPWSTR pszSizeBuff, int cchMaxSizeChars);
+  typedef COLORREF (WINAPI*GetThemeSysColorPtr)(HTHEME hTheme, int iColorID);
 
   static OpenThemeDataPtr openTheme;
   static CloseThemeDataPtr closeTheme;
   static DrawThemeBackgroundPtr drawThemeBG;
   static DrawThemeEdgePtr drawThemeEdge;
   static GetThemeContentRectPtr getThemeContentRect;
   static GetThemePartSizePtr getThemePartSize;
   static GetThemeSysFontPtr getThemeSysFont;
   static GetThemeColorPtr getThemeColor;
   static GetThemeMarginsPtr getThemeMargins;
   static IsAppThemedPtr isAppThemed;
   static GetCurrentThemeNamePtr getCurrentThemeName;
+  static GetThemeSysColorPtr getThemeSysColor;
+
+  // dwmapi.dll function typedefs and declarations
+  typedef HRESULT (WINAPI*DwmExtendFrameIntoClientAreaProc)(HWND hWnd, const MARGINS *pMarInset);
+  typedef HRESULT (WINAPI*DwmIsCompositionEnabledProc)(BOOL *pfEnabled);
+
+  static DwmExtendFrameIntoClientAreaProc dwmExtendFrameIntoClientAreaPtr;
+  static DwmIsCompositionEnabledProc dwmIsCompositionEnabledPtr;
+
+  static PRBool CheckForCompositor() {
+    BOOL compositionIsEnabled = FALSE;
+    if(dwmIsCompositionEnabledPtr)
+      dwmIsCompositionEnabledPtr(&compositionIsEnabled);
+    return sHaveCompositor = (compositionIsEnabled != 0);
+  }
 };
--- a/widget/src/windows/nsWindow.cpp
+++ b/widget/src/windows/nsWindow.cpp
@@ -147,16 +147,18 @@
 #include "nsCRT.h"
 #include "nsAppDirectoryServiceDefs.h"
 #include "nsXPIDLString.h"
 #include "nsIFile.h"
 
 #include "prprf.h"
 #include "prmem.h"
 
+#include "nsUXThemeData.h"
+
 #ifdef PR_LOGGING
 PRLogModuleInfo* sWindowsLog = nsnull;
 #endif
 
 static const char kMozHeapDumpMessageString[] = "MOZ_HeapDump";
 
 #define kWindowPositionSlop 20
 
@@ -641,17 +643,17 @@ nsWindow::nsWindow() : nsBaseWidget()
   mDeferredPositioner = NULL;
   mLastPoint.x        = 0;
   mLastPoint.y        = 0;
   mPreferredWidth     = 0;
   mPreferredHeight    = 0;
   mIsVisible          = PR_FALSE;
   mHas3DBorder        = PR_FALSE;
 #ifdef MOZ_XUL
-  mIsTransparent      = PR_FALSE;
+  mTransparencyMode   = eTransparencyOpaque;
   mTransparentSurface = nsnull;
   mMemoryDC           = NULL;
 #endif
   mWindowType         = eWindowType_child;
   mBorderStyle        = eBorderStyle_default;
   mUnicodeWidget      = PR_TRUE;
   mIsInMouseCapture   = PR_FALSE;
   mIsInMouseWheelProcessing = PR_FALSE;
@@ -1445,19 +1447,19 @@ NS_METHOD nsWindow::Destroy()
     if (icon)
       ::DestroyIcon(icon);
 
     icon = (HICON) ::SendMessageW(mWnd, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM) 0);
     if (icon)
       ::DestroyIcon(icon);
 
 #ifdef MOZ_XUL
-    if (mIsTransparent)
+    if (eTransparencyTransparent == mTransparencyMode)
     {
-      SetupTranslucentWindowMemoryBitmap(PR_FALSE);
+      SetupTranslucentWindowMemoryBitmap(eTransparencyOpaque);
 
     }
 #endif
 
     // bug 333907: During WM_*ENDSESSION, closing all windows
     // will cause immediate termination of the process. This
     // avoids closing windows during WM_ENDSESSION for a cleaner exit.
     if (!sIsInEndSession)
@@ -1980,17 +1982,17 @@ NS_METHOD nsWindow::Move(PRInt32 aX, PRI
 //
 //-------------------------------------------------------------------------
 NS_METHOD nsWindow::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint)
 {
   NS_ASSERTION((aWidth >=0 ) , "Negative width passed to nsWindow::Resize");
   NS_ASSERTION((aHeight >=0 ), "Negative height passed to nsWindow::Resize");
 
 #ifdef MOZ_XUL
-  if (mIsTransparent)
+  if (eTransparencyTransparent == mTransparencyMode)
     ResizeTranslucentWindow(aWidth, aHeight);
 #endif
 
   // Set cached value for lightweight and printing
   mBounds.width  = aWidth;
   mBounds.height = aHeight;
 
   if (mWnd) {
@@ -2030,17 +2032,17 @@ NS_METHOD nsWindow::Resize(PRInt32 aWidt
 //
 //-------------------------------------------------------------------------
 NS_METHOD nsWindow::Resize(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint)
 {
   NS_ASSERTION((aWidth >=0 ),  "Negative width passed to nsWindow::Resize");
   NS_ASSERTION((aHeight >=0 ), "Negative height passed to nsWindow::Resize");
 
 #ifdef MOZ_XUL
-  if (mIsTransparent)
+  if (eTransparencyTransparent == mTransparencyMode)
     ResizeTranslucentWindow(aWidth, aHeight);
 #endif
 
   // Set cached value for lightweight and printing
   mBounds.x      = aX;
   mBounds.y      = aY;
   mBounds.width  = aWidth;
   mBounds.height = aHeight;
@@ -2760,17 +2762,17 @@ void* nsWindow::GetNativeData(PRUint32 a
   switch (aDataType) {
     case NS_NATIVE_WIDGET:
     case NS_NATIVE_WINDOW:
     case NS_NATIVE_PLUGIN_PORT:
       return (void*)mWnd;
     case NS_NATIVE_GRAPHIC:
       // XXX:  This is sleezy!!  Remember to Release the DC after using it!
 #ifdef MOZ_XUL
-      return (void*)(mIsTransparent) ?
+      return (void*)(eTransparencyTransparent == mTransparencyMode) ?
         mMemoryDC : ::GetDC(mWnd);
 #else
       return (void*)::GetDC(mWnd);
 #endif
     case NS_NATIVE_COLORMAP:
     default:
       break;
   }
@@ -2780,17 +2782,17 @@ void* nsWindow::GetNativeData(PRUint32 a
 
 //~~~
 void nsWindow::FreeNativeData(void * data, PRUint32 aDataType)
 {
   switch (aDataType)
   {
     case NS_NATIVE_GRAPHIC:
 #ifdef MOZ_XUL
-      if (!mIsTransparent)
+      if (eTransparencyTransparent != mTransparencyMode)
         ::ReleaseDC(mWnd, (HDC)data);
 #else
       ::ReleaseDC(mWnd, (HDC)data);
 #endif
       break;
     case NS_NATIVE_WIDGET:
     case NS_NATIVE_WINDOW:
     case NS_NATIVE_PLUGIN_PORT:
@@ -4804,17 +4806,17 @@ PRBool nsWindow::ProcessMessage(UINT msg
         ::GetWindowRect(mWnd, &r);
         PRInt32 newWidth, newHeight;
         newWidth = PRInt32(r.right - r.left);
         newHeight = PRInt32(r.bottom - r.top);
         nsRect rect(wp->x, wp->y, newWidth, newHeight);
 
 
 #ifdef MOZ_XUL
-        if (mIsTransparent)
+        if (eTransparencyTransparent == mTransparencyMode)
           ResizeTranslucentWindow(newWidth, newHeight);
 #endif
 
         if (newWidth > mLastSize.width)
         {
           RECT drect;
 
           //getting wider
@@ -5263,16 +5265,24 @@ PRBool nsWindow::ProcessMessage(UINT msg
         // XXX pass in message parameters.
         HeapDump("c:\\heapdump.txt", "whatever");
         result = PR_TRUE;
       }
 #endif // WINCE
 
     }
     break;
+  case WM_DWMCOMPOSITIONCHANGED:
+    if (nsUXThemeData::CheckForCompositor() && mTransparencyMode == eTransparencyGlass) {
+      MARGINS margins = { -1, -1, -1, -1 };
+      nsUXThemeData::dwmExtendFrameIntoClientAreaPtr(mWnd, &margins);
+    }
+    BroadcastMsg(mWnd, WM_DWMCOMPOSITIONCHANGED);
+    DispatchStandardEvent(NS_THEMECHANGED);
+    break;
   }
 
   //*aRetValue = result;
   if (mWnd) {
     return result;
   }
   else {
     //Events which caused mWnd destruction and aren't consumed
@@ -5694,17 +5704,17 @@ ConvertHRGNToRegion(HRGN aRgn)
 PRBool nsWindow::OnPaint(HDC aDC)
 {
   nsRect bounds;
   PRBool result = PR_TRUE;
   PAINTSTRUCT ps;
   nsEventStatus eventStatus = nsEventStatus_eIgnore;
 
 #ifdef MOZ_XUL
-  if (!aDC && mIsTransparent)
+  if (!aDC && (eTransparencyTransparent == mTransparencyMode))
   {
     // For layered translucent windows all drawing should go to memory DC and no
     // WM_PAINT messages are normally generated. To support asynchronous painting
     // we force generation of WM_PAINT messages by invalidating window areas with
     // RedrawWindow, InvalidateRect or InvalidateRgn function calls.
     // BeginPaint/EndPaint must be called to make Windows think that invalid area
     // is painted. Otherwise it will continue sending the same message endlessly.
     ::BeginPaint(mWnd, &ps);
@@ -5728,17 +5738,17 @@ PRBool nsWindow::OnPaint(HDC aDC)
   }
 #endif // NS_DEBUG
 
   HDC hDC = aDC ? aDC : (::BeginPaint(mWnd, &ps));
   mPaintDC = hDC;
   HRGN paintRgn = NULL;
 
 #ifdef MOZ_XUL
-  if (aDC || mIsTransparent) {
+  if (aDC || (eTransparencyTransparent == mTransparencyMode)) {
 #else
   if (aDC) {
 #endif
     RECT paintRect;
     ::GetClientRect(mWnd, &paintRect);
     paintRgn = ::CreateRectRgn(paintRect.left, paintRect.top, paintRect.right, paintRect.bottom);
   }
   else {
@@ -5778,29 +5788,31 @@ PRBool nsWindow::OnPaint(HDC aDC)
                            this,
                            &event,
                            nsCAutoString("noname"),
                            (PRInt32) mWnd);
 #endif // NS_DEBUG
 
 #ifdef MOZ_XUL
       nsRefPtr<gfxASurface> targetSurface;
-      if (mIsTransparent) {
+      if (eTransparencyTransparent == mTransparencyMode) {
         targetSurface = mTransparentSurface;
       } else {
         targetSurface = new gfxWindowsSurface(hDC);
       }
 #else
       nsRefPtr<gfxASurface> targetSurface = new gfxWindowsSurface(hDC);
 #endif
 
       nsRefPtr<gfxContext> thebesContext = new gfxContext(targetSurface);
 
 #ifdef MOZ_XUL
-      if (mIsTransparent) {
+      if (eTransparencyGlass == mTransparencyMode && nsUXThemeData::sHaveCompositor) {
+        thebesContext->PushGroup(gfxASurface::CONTENT_COLOR_ALPHA);
+      } else if (eTransparencyTransparent == mTransparencyMode) {
         // 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);
         thebesContext->Paint();
         thebesContext->SetOperator(gfxContext::OPERATOR_OVER);
       } else {
         // If we're not doing translucency, then double buffer
         thebesContext->PushGroup(gfxASurface::CONTENT_COLOR);
@@ -5820,17 +5832,17 @@ PRBool nsWindow::OnPaint(HDC aDC)
         return PR_FALSE;
       }
 
       event.renderingContext = rc;
       result = DispatchWindowEvent(&event, eventStatus);
       event.renderingContext = nsnull;
 
 #ifdef MOZ_XUL
-      if (mIsTransparent) {
+      if (eTransparencyTransparent == mTransparencyMode) {
         // 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.
         UpdateTranslucentWindow();
       } else if (result) {
         // Only update if DispatchWindowEvent returned TRUE; otherwise, nothing handled
         // this, and we'll just end up painting with black.
         thebesContext->PopGroupToSource();
@@ -7974,77 +7986,74 @@ void nsWindow::ResizeTranslucentWindow(P
 {
   if (!force && aNewWidth == mBounds.width && aNewHeight == mBounds.height)
     return;
 
   mTransparentSurface = new gfxWindowsSurface(gfxIntSize(aNewWidth, aNewHeight), gfxASurface::ImageFormatARGB32);
   mMemoryDC = mTransparentSurface->GetDC();
 }
 
-NS_IMETHODIMP nsWindow::GetHasTransparentBackground(PRBool& aTransparent)
-{
-  aTransparent = GetTopLevelWindow()->GetWindowTranslucencyInner();
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP nsWindow::SetHasTransparentBackground(PRBool aTransparent)
-{
-  nsresult rv = GetTopLevelWindow()->SetWindowTranslucencyInner(aTransparent);
-
-  return rv;
-}
-
-nsresult nsWindow::SetWindowTranslucencyInner(PRBool aTransparent)
-{
-  if (aTransparent == mIsTransparent)
-    return NS_OK;
-  
+nsTransparencyMode nsWindow::GetTransparencyMode()
+{
+  return GetTopLevelWindow()->GetWindowTranslucencyInner();
+}
+
+void nsWindow::SetTransparencyMode(nsTransparencyMode aMode)
+{
+  GetTopLevelWindow()->SetWindowTranslucencyInner(aMode);
+}
+
+void nsWindow::SetWindowTranslucencyInner(nsTransparencyMode aMode)
+{
+  if (aMode == mTransparencyMode)
+    return;
+
   HWND hWnd = GetTopLevelHWND(mWnd, PR_TRUE);
   nsWindow* topWindow = GetNSWindowPtr(hWnd);
 
   if (!topWindow)
   {
     NS_WARNING("Trying to use transparent chrome in an embedded context");
-    return NS_ERROR_FAILURE;
+    return;
   }
 
   LONG style, exStyle;
 
-  if (aTransparent)
-  {
-    style = ::GetWindowLongW(hWnd, GWL_STYLE) &
-            ~(WS_CAPTION | WS_THICKFRAME | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX);
-    exStyle = ::GetWindowLongW(hWnd, GWL_EXSTYLE) &
-              ~(WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE);
-
-    exStyle |= WS_EX_LAYERED;
-  } else
-  {
-    style = topWindow->WindowStyle();
-    exStyle = topWindow->WindowExStyle();
+  style = topWindow->WindowStyle();
+  exStyle = topWindow->WindowExStyle();
+
+  switch(aMode) {
+    case eTransparencyTransparent:
+      exStyle |= WS_EX_LAYERED;
+    case eTransparencyOpaque:
+    case eTransparencyGlass:
+      topWindow->mTransparencyMode = aMode;
+      break;
   }
   ::SetWindowLongW(hWnd, GWL_STYLE, style);
   ::SetWindowLongW(hWnd, GWL_EXSTYLE, exStyle);
 
-  mIsTransparent = aTransparent;
-
-  return SetupTranslucentWindowMemoryBitmap(aTransparent);
-}
-
-nsresult nsWindow::SetupTranslucentWindowMemoryBitmap(PRBool aTransparent)
-{
-  if (aTransparent) {
+  mTransparencyMode = aMode;
+
+  SetupTranslucentWindowMemoryBitmap(aMode);
+  MARGINS margins = { 0, 0, 0, 0 };
+  if(eTransparencyGlass == aMode)
+    margins.cxLeftWidth = -1;
+  if(nsUXThemeData::sHaveCompositor)
+    nsUXThemeData::dwmExtendFrameIntoClientAreaPtr(hWnd, &margins);
+}
+
+void nsWindow::SetupTranslucentWindowMemoryBitmap(nsTransparencyMode aMode)
+{
+  if (eTransparencyTransparent == aMode) {
     ResizeTranslucentWindow(mBounds.width, mBounds.height, PR_TRUE);
   } else {
     mTransparentSurface = nsnull;
     mMemoryDC = NULL;
   }
-
-  return NS_OK;
 }
 
 nsresult nsWindow::UpdateTranslucentWindow()
 {
   if (mBounds.IsEmpty())
     return NS_OK;
 
   ::GdiFlush();
--- a/widget/src/windows/nsWindow.h
+++ b/widget/src/windows/nsWindow.h
@@ -205,24 +205,24 @@ public:
 
   NS_IMETHOD              GetAttention(PRInt32 aCycleCount);
   NS_IMETHOD              GetLastInputEventTime(PRUint32& aTime);
   nsWindow*               GetTopLevelWindow();
 
   gfxASurface             *GetThebesSurface();
 
 #ifdef MOZ_XUL
-  NS_IMETHOD              SetHasTransparentBackground(PRBool aTransparent);
-  NS_IMETHOD              GetHasTransparentBackground(PRBool& aTransparent);
+  virtual void            SetTransparencyMode(nsTransparencyMode aMode);
+  virtual nsTransparencyMode GetTransparencyMode();
 private:
-  nsresult                SetWindowTranslucencyInner(PRBool aTransparent);
-  PRBool                  GetWindowTranslucencyInner() { return mIsTransparent; }
+  void                    SetWindowTranslucencyInner(nsTransparencyMode aMode);
+  nsTransparencyMode      GetWindowTranslucencyInner() const { return mTransparencyMode; }
   void                    ResizeTranslucentWindow(PRInt32 aNewWidth, PRInt32 aNewHeight, PRBool force = PR_FALSE);
   nsresult                UpdateTranslucentWindow();
-  nsresult                SetupTranslucentWindowMemoryBitmap(PRBool aTransparent);
+  void                    SetupTranslucentWindowMemoryBitmap(nsTransparencyMode aMode);
 public:
 #endif
 
   NS_IMETHOD ResetInputState();
   NS_IMETHOD SetIMEOpenState(PRBool aState);
   NS_IMETHOD GetIMEOpenState(PRBool* aState);
   NS_IMETHOD SetIMEEnabled(PRUint32 aState);
   NS_IMETHOD GetIMEEnabled(PRUint32* aState);
@@ -412,19 +412,18 @@ protected:
   WNDPROC       mPrevWndProc;
   HBRUSH        mBrush;
 
 #ifdef MOZ_XUL
   // use layered windows to support full 256 level alpha translucency
   nsRefPtr<gfxWindowsSurface> mTransparentSurface;
 
   HDC           mMemoryDC;
-  PRPackedBool  mIsTransparent;
+  nsTransparencyMode mTransparencyMode;
 #endif
-  PRPackedBool  mHasAeroGlass;
   PRPackedBool  mIsTopWidgetWindow;
   PRPackedBool  mHas3DBorder;
   PRPackedBool  mIsShiftDown;
   PRPackedBool  mIsControlDown;
   PRPackedBool  mIsAltDown;
   PRPackedBool  mIsDestroying;
   PRPackedBool  mOnDestroyCalled;
   PRPackedBool  mIsVisible;
--- a/widget/src/xpwidgets/nsBaseWidget.cpp
+++ b/widget/src/xpwidgets/nsBaseWidget.cpp
@@ -539,23 +539,21 @@ NS_IMETHODIMP nsBaseWidget::SetWindowTyp
 }
 
 //-------------------------------------------------------------------------
 //
 // Window transparency methods
 //
 //-------------------------------------------------------------------------
 
-NS_IMETHODIMP nsBaseWidget::SetHasTransparentBackground(PRBool aTransparent) {
-  return NS_ERROR_NOT_IMPLEMENTED;
+void nsBaseWidget::SetTransparencyMode(nsTransparencyMode aMode) {
 }
 
-NS_IMETHODIMP nsBaseWidget::GetHasTransparentBackground(PRBool& aTransparent) {
-  aTransparent = PR_FALSE;
-  return NS_OK;
+nsTransparencyMode nsBaseWidget::GetTransparencyMode() {
+  return eTransparencyOpaque;
 }
 
 //-------------------------------------------------------------------------
 //
 // Hide window borders/decorations for this widget
 //
 //-------------------------------------------------------------------------
 NS_IMETHODIMP nsBaseWidget::HideWindowChrome(PRBool aShouldHide)
--- a/widget/src/xpwidgets/nsBaseWidget.h
+++ b/widget/src/xpwidgets/nsBaseWidget.h
@@ -99,18 +99,18 @@ public:
   virtual nscolor         GetBackgroundColor(void);
   NS_IMETHOD              SetBackgroundColor(const nscolor &aColor);
   virtual nsCursor        GetCursor();
   NS_IMETHOD              SetCursor(nsCursor aCursor);
   NS_IMETHOD              SetCursor(imgIContainer* aCursor,
                                     PRUint32 aHotspotX, PRUint32 aHotspotY);
   NS_IMETHOD              GetWindowType(nsWindowType& aWindowType);
   NS_IMETHOD              SetWindowType(nsWindowType aWindowType);
-  NS_IMETHOD              SetHasTransparentBackground(PRBool aTransparent);
-  NS_IMETHOD              GetHasTransparentBackground(PRBool& aTransparent);
+  virtual void            SetTransparencyMode(nsTransparencyMode aMode);
+  virtual nsTransparencyMode GetTransparencyMode();
   NS_IMETHOD              HideWindowChrome(PRBool aShouldHide);
   NS_IMETHOD              MakeFullScreen(PRBool aFullScreen);
   virtual nsIRenderingContext* GetRenderingContext();
   virtual nsIDeviceContext* GetDeviceContext();
   virtual nsIToolkit*     GetToolkit();  
   virtual gfxASurface*    GetThebesSurface();
   NS_IMETHOD              SetModal(PRBool aModal); 
   NS_IMETHOD              ModalEventFilter(PRBool aRealEvent, void *aEvent,