1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
23 * Dean Tessman <dean_tessman@hotmail.com>
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 #include "nsBaseWidget.h"
40 #include "nsIDeviceContext.h"
42 #include "nsGfxCIID.h"
43 #include "nsWidgetsCID.h"
44 #include "nsServiceManagerUtils.h"
45 #include "nsIScreenManager.h"
46 #include "nsAppDirectoryServiceDefs.h"
47 #include "nsISimpleEnumerator.h"
48 #include "nsIContent.h"
49 #include "nsIServiceManager.h"
50 #include "nsIPrefService.h"
51 #include "nsIPrefBranch2.h"
52 #include "BasicLayers.h"
53 #include "LayerManagerOGL.h"
54 #include "nsIXULRuntime.h"
55 #include "nsIGfxInfo.h"
59 #include "nsIObserver.h"
61 static void debug_RegisterPrefCallbacks();
63 static PRBool debug_InSecureKeyboardInputMode
= PR_FALSE
;
66 #ifdef NOISY_WIDGET_LEAKS
67 static PRInt32 gNumWidgets
;
70 using namespace mozilla::layers
;
72 nsIContent
* nsBaseWidget::mLastRollup
= nsnull
;
75 NS_IMPL_ISUPPORTS1(nsBaseWidget
, nsIWidget
)
78 nsAutoRollup::nsAutoRollup()
80 // remember if mLastRollup was null, and only clear it upon destruction
81 // if so. This prevents recursive usage of nsAutoRollup from clearing
82 // mLastRollup when it shouldn't.
83 wasClear
= !nsBaseWidget::mLastRollup
;
86 nsAutoRollup::~nsAutoRollup()
88 if (nsBaseWidget::mLastRollup
&& wasClear
) {
89 NS_RELEASE(nsBaseWidget::mLastRollup
);
93 //-------------------------------------------------------------------------
95 // nsBaseWidget constructor
97 //-------------------------------------------------------------------------
99 nsBaseWidget::nsBaseWidget()
100 : mClientData(nsnull
)
101 , mViewWrapperPtr(nsnull
)
102 , mEventCallback(nsnull
)
103 , mViewCallback(nsnull
)
106 , mCursor(eCursor_standard
)
107 , mWindowType(eWindowType_child
)
108 , mBorderStyle(eBorderStyle_none
)
109 , mOnDestroyCalled(PR_FALSE
)
110 , mUseAcceleratedRendering(PR_FALSE
)
111 , mTemporarilyUseBasicLayerManager(PR_FALSE
)
113 , mOriginalBounds(nsnull
)
116 , mSizeMode(nsSizeMode_Normal
)
117 , mPopupLevel(ePopupLevelTop
)
119 #ifdef NOISY_WIDGET_LEAKS
121 printf("WIDGETS+ = %d\n", gNumWidgets
);
125 debug_RegisterPrefCallbacks();
130 //-------------------------------------------------------------------------
132 // nsBaseWidget destructor
134 //-------------------------------------------------------------------------
135 nsBaseWidget::~nsBaseWidget()
138 mLayerManager
->GetBackendType() == LayerManager::LAYERS_BASIC
) {
139 static_cast<BasicLayerManager
*>(mLayerManager
.get())->ClearRetainerWidget();
143 mLayerManager
->Destroy();
146 #ifdef NOISY_WIDGET_LEAKS
148 printf("WIDGETS- = %d\n", gNumWidgets
);
151 NS_IF_RELEASE(mToolkit
);
152 NS_IF_RELEASE(mContext
);
154 delete mOriginalBounds
;
158 //-------------------------------------------------------------------------
162 //-------------------------------------------------------------------------
163 void nsBaseWidget::BaseCreate(nsIWidget
*aParent
,
164 const nsIntRect
&aRect
,
165 EVENT_CALLBACK aHandleEventFunction
,
166 nsIDeviceContext
*aContext
,
167 nsIAppShell
*aAppShell
,
168 nsIToolkit
*aToolkit
,
169 nsWidgetInitData
*aInitData
)
171 if (nsnull
== mToolkit
) {
172 if (nsnull
!= aToolkit
) {
173 mToolkit
= (nsIToolkit
*)aToolkit
;
177 if (nsnull
!= aParent
) {
178 mToolkit
= aParent
->GetToolkit();
179 NS_IF_ADDREF(mToolkit
);
181 // it's some top level window with no toolkit passed in.
182 // Create a default toolkit with the current thread
183 #if !defined(USE_TLS_FOR_TOOLKIT)
185 static NS_DEFINE_CID(kToolkitCID
, NS_TOOLKIT_CID
);
188 res
= CallCreateInstance(kToolkitCID
, &mToolkit
);
189 NS_ASSERTION(NS_SUCCEEDED(res
), "Can not create a toolkit in nsBaseWidget::Create");
191 mToolkit
->Init(PR_GetCurrentThread());
193 #else /* USE_TLS_FOR_TOOLKIT */
197 rv
= NS_GetCurrentToolkit(&mToolkit
);
199 #endif /* USE_TLS_FOR_TOOLKIT */
204 // save the event callback function
205 mEventCallback
= aHandleEventFunction
;
207 // keep a reference to the device context
215 static NS_DEFINE_CID(kDeviceContextCID
, NS_DEVICE_CONTEXT_CID
);
217 res
= CallCreateInstance(kDeviceContextCID
, &mContext
);
219 if (NS_SUCCEEDED(res
))
220 mContext
->Init(nsnull
);
223 if (nsnull
!= aInitData
) {
224 mWindowType
= aInitData
->mWindowType
;
225 mBorderStyle
= aInitData
->mBorderStyle
;
226 mPopupLevel
= aInitData
->mPopupLevel
;
230 aParent
->AddChild(this);
234 NS_IMETHODIMP
nsBaseWidget::CaptureMouse(PRBool aCapture
)
239 //-------------------------------------------------------------------------
241 // Accessor functions to get/set the client data
243 //-------------------------------------------------------------------------
245 NS_IMETHODIMP
nsBaseWidget::GetClientData(void*& aClientData
)
247 aClientData
= mClientData
;
251 NS_IMETHODIMP
nsBaseWidget::SetClientData(void* aClientData
)
253 mClientData
= aClientData
;
257 already_AddRefed
<nsIWidget
>
258 nsBaseWidget::CreateChild(const nsIntRect
&aRect
,
259 EVENT_CALLBACK aHandleEventFunction
,
260 nsIDeviceContext
*aContext
,
261 nsIAppShell
*aAppShell
,
262 nsIToolkit
*aToolkit
,
263 nsWidgetInitData
*aInitData
,
264 PRBool aForceUseIWidgetParent
)
266 nsIWidget
* parent
= this;
267 nsNativeWidget nativeParent
= nsnull
;
269 if (!aForceUseIWidgetParent
) {
270 // Use only either parent or nativeParent, not both, to match
271 // existing code. Eventually Create() should be divested of its
272 // nativeWidget parameter.
273 nativeParent
= parent
? parent
->GetNativeData(NS_NATIVE_WIDGET
) : nsnull
;
274 parent
= nativeParent
? nsnull
: parent
;
275 NS_ABORT_IF_FALSE(!parent
|| !nativeParent
, "messed up logic");
278 nsCOMPtr
<nsIWidget
> widget
;
279 if (aInitData
&& aInitData
->mWindowType
== eWindowType_popup
) {
280 widget
= AllocateChildPopupWidget();
282 static NS_DEFINE_IID(kCChildCID
, NS_CHILD_CID
);
283 widget
= do_CreateInstance(kCChildCID
);
287 NS_SUCCEEDED(widget
->Create(parent
, nativeParent
, aRect
,
288 aHandleEventFunction
,
289 aContext
, aAppShell
, aToolkit
,
291 return widget
.forget();
297 // Attach a view to our widget which we'll send events to.
299 nsBaseWidget::AttachViewToTopLevel(EVENT_CALLBACK aViewEventFunction
,
300 nsIDeviceContext
*aContext
)
302 NS_ASSERTION((mWindowType
== eWindowType_toplevel
||
303 mWindowType
== eWindowType_dialog
||
304 mWindowType
== eWindowType_invisible
||
305 mWindowType
== eWindowType_child
),
306 "Can't attach to window of that type");
308 mViewCallback
= aViewEventFunction
;
312 NS_IF_RELEASE(mContext
);
321 ViewWrapper
* nsBaseWidget::GetAttachedViewPtr()
323 return mViewWrapperPtr
;
326 NS_IMETHODIMP
nsBaseWidget::SetAttachedViewPtr(ViewWrapper
* aViewWrapper
)
328 mViewWrapperPtr
= aViewWrapper
;
332 NS_METHOD
nsBaseWidget::ResizeClient(PRInt32 aX
,
338 return Resize(aX
, aY
, aWidth
, aHeight
, aRepaint
);
341 //-------------------------------------------------------------------------
343 // Close this nsBaseWidget
345 //-------------------------------------------------------------------------
346 NS_METHOD
nsBaseWidget::Destroy()
348 // Just in case our parent is the only ref to us
349 nsCOMPtr
<nsIWidget
> kungFuDeathGrip(this);
350 // disconnect from the parent
351 nsIWidget
*parent
= GetParent();
353 parent
->RemoveChild(this);
360 //-------------------------------------------------------------------------
362 // Set this nsBaseWidget's parent
364 //-------------------------------------------------------------------------
365 NS_IMETHODIMP
nsBaseWidget::SetParent(nsIWidget
* aNewParent
)
367 return NS_ERROR_NOT_IMPLEMENTED
;
371 //-------------------------------------------------------------------------
373 // Get this nsBaseWidget parent
375 //-------------------------------------------------------------------------
376 nsIWidget
* nsBaseWidget::GetParent(void)
381 //-------------------------------------------------------------------------
383 // Get this nsBaseWidget top level widget
385 //-------------------------------------------------------------------------
386 nsIWidget
* nsBaseWidget::GetTopLevelWidget()
388 nsIWidget
*topLevelWidget
= nsnull
, *widget
= this;
390 topLevelWidget
= widget
;
391 widget
= widget
->GetParent();
393 return topLevelWidget
;
396 //-------------------------------------------------------------------------
398 // Get this nsBaseWidget's top (non-sheet) parent (if it's a sheet)
400 //-------------------------------------------------------------------------
401 nsIWidget
* nsBaseWidget::GetSheetWindowParent(void)
406 float nsBaseWidget::GetDPI()
411 double nsBaseWidget::GetDefaultScale()
416 //-------------------------------------------------------------------------
418 // Add a child to the list of children
420 //-------------------------------------------------------------------------
421 void nsBaseWidget::AddChild(nsIWidget
* aChild
)
423 NS_PRECONDITION(!aChild
->GetNextSibling() && !aChild
->GetPrevSibling(),
424 "aChild not properly removed from its old child list");
427 mFirstChild
= mLastChild
= aChild
;
429 // append to the list
430 NS_ASSERTION(mLastChild
, "Bogus state");
431 NS_ASSERTION(!mLastChild
->GetNextSibling(), "Bogus state");
432 mLastChild
->SetNextSibling(aChild
);
433 aChild
->SetPrevSibling(mLastChild
);
439 //-------------------------------------------------------------------------
441 // Remove a child from the list of children
443 //-------------------------------------------------------------------------
444 void nsBaseWidget::RemoveChild(nsIWidget
* aChild
)
446 NS_ASSERTION(aChild
->GetParent() == this, "Not one of our kids!");
448 if (mLastChild
== aChild
) {
449 mLastChild
= mLastChild
->GetPrevSibling();
451 if (mFirstChild
== aChild
) {
452 mFirstChild
= mFirstChild
->GetNextSibling();
455 // Now remove from the list. Make sure that we pass ownership of the tail
456 // of the list correctly before we have aChild let go of it.
457 nsIWidget
* prev
= aChild
->GetPrevSibling();
458 nsIWidget
* next
= aChild
->GetNextSibling();
460 prev
->SetNextSibling(next
);
463 next
->SetPrevSibling(prev
);
466 aChild
->SetNextSibling(nsnull
);
467 aChild
->SetPrevSibling(nsnull
);
471 //-------------------------------------------------------------------------
473 // Sets widget's position within its parent's child list.
475 //-------------------------------------------------------------------------
476 NS_IMETHODIMP
nsBaseWidget::SetZIndex(PRInt32 aZIndex
)
478 // Hold a ref to ourselves just in case, since we're going to remove
480 nsCOMPtr
<nsIWidget
> kungFuDeathGrip(this);
484 // reorder this child in its parent's list.
485 nsBaseWidget
* parent
= static_cast<nsBaseWidget
*>(GetParent());
487 parent
->RemoveChild(this);
488 // Scope sib outside the for loop so we can check it afterward
489 nsIWidget
* sib
= parent
->GetFirstChild();
490 for ( ; sib
; sib
= sib
->GetNextSibling()) {
492 if (NS_SUCCEEDED(sib
->GetZIndex(&childZIndex
))) {
493 if (aZIndex
< childZIndex
) {
494 // Insert ourselves before sib
495 nsIWidget
* prev
= sib
->GetPrevSibling();
498 sib
->SetPrevSibling(this);
500 prev
->SetNextSibling(this);
502 NS_ASSERTION(sib
== parent
->mFirstChild
, "Broken child list");
503 // We've taken ownership of sib, so it's safe to have parent let
505 parent
->mFirstChild
= this;
507 PlaceBehind(eZPlacementBelow
, sib
, PR_FALSE
);
512 // were we added to the list?
514 parent
->AddChild(this);
520 //-------------------------------------------------------------------------
522 // Gets widget's position within its parent's child list.
524 //-------------------------------------------------------------------------
525 NS_IMETHODIMP
nsBaseWidget::GetZIndex(PRInt32
* aZIndex
)
531 //-------------------------------------------------------------------------
533 // Places widget behind the given widget (platforms must override)
535 //-------------------------------------------------------------------------
536 NS_IMETHODIMP
nsBaseWidget::PlaceBehind(nsTopLevelWidgetZPlacement aPlacement
,
537 nsIWidget
*aWidget
, PRBool aActivate
)
542 //-------------------------------------------------------------------------
544 // Maximize, minimize or restore the window. The BaseWidget implementation
545 // merely stores the state.
547 //-------------------------------------------------------------------------
548 NS_IMETHODIMP
nsBaseWidget::SetSizeMode(PRInt32 aMode
)
550 if (aMode
== nsSizeMode_Normal
||
551 aMode
== nsSizeMode_Minimized
||
552 aMode
== nsSizeMode_Maximized
||
553 aMode
== nsSizeMode_Fullscreen
) {
555 mSizeMode
= (nsSizeMode
) aMode
;
558 return NS_ERROR_ILLEGAL_VALUE
;
561 //-------------------------------------------------------------------------
563 // Get the size mode (minimized, maximized, that sort of thing...)
565 //-------------------------------------------------------------------------
566 NS_IMETHODIMP
nsBaseWidget::GetSizeMode(PRInt32
* aMode
)
572 //-------------------------------------------------------------------------
574 // Get the foreground color
576 //-------------------------------------------------------------------------
577 nscolor
nsBaseWidget::GetForegroundColor(void)
583 //-------------------------------------------------------------------------
585 // Set the foreground color
587 //-------------------------------------------------------------------------
588 NS_METHOD
nsBaseWidget::SetForegroundColor(const nscolor
&aColor
)
590 mForeground
= aColor
;
595 //-------------------------------------------------------------------------
597 // Get the background color
599 //-------------------------------------------------------------------------
600 nscolor
nsBaseWidget::GetBackgroundColor(void)
605 //-------------------------------------------------------------------------
607 // Set the background color
609 //-------------------------------------------------------------------------
610 NS_METHOD
nsBaseWidget::SetBackgroundColor(const nscolor
&aColor
)
612 mBackground
= aColor
;
616 //-------------------------------------------------------------------------
618 // Get this component cursor
620 //-------------------------------------------------------------------------
621 nsCursor
nsBaseWidget::GetCursor()
626 NS_METHOD
nsBaseWidget::SetCursor(nsCursor aCursor
)
632 NS_IMETHODIMP
nsBaseWidget::SetCursor(imgIContainer
* aCursor
,
633 PRUint32 aHotspotX
, PRUint32 aHotspotY
)
635 return NS_ERROR_NOT_IMPLEMENTED
;
638 //-------------------------------------------------------------------------
640 // Get the window type for this widget
642 //-------------------------------------------------------------------------
643 NS_IMETHODIMP
nsBaseWidget::GetWindowType(nsWindowType
& aWindowType
)
645 aWindowType
= mWindowType
;
649 //-------------------------------------------------------------------------
651 // Window transparency methods
653 //-------------------------------------------------------------------------
655 void nsBaseWidget::SetTransparencyMode(nsTransparencyMode aMode
) {
658 nsTransparencyMode
nsBaseWidget::GetTransparencyMode() {
659 return eTransparencyOpaque
;
663 nsBaseWidget::StoreWindowClipRegion(const nsTArray
<nsIntRect
>& aRects
)
665 if (mClipRects
&& mClipRectCount
== aRects
.Length() &&
666 memcmp(mClipRects
, aRects
.Elements(), sizeof(nsIntRect
)*mClipRectCount
) == 0)
669 mClipRectCount
= aRects
.Length();
670 mClipRects
= new nsIntRect
[mClipRectCount
];
672 memcpy(mClipRects
, aRects
.Elements(), sizeof(nsIntRect
)*mClipRectCount
);
678 nsBaseWidget::GetWindowClipRegion(nsTArray
<nsIntRect
>* aRects
)
681 aRects
->AppendElements(mClipRects
.get(), mClipRectCount
);
683 aRects
->AppendElement(nsIntRect(0, 0, mBounds
.width
, mBounds
.height
));
687 //-------------------------------------------------------------------------
689 // Set window shadow style
691 //-------------------------------------------------------------------------
693 NS_IMETHODIMP
nsBaseWidget::SetWindowShadowStyle(PRInt32 aMode
)
695 return NS_ERROR_NOT_IMPLEMENTED
;
698 //-------------------------------------------------------------------------
700 // Hide window borders/decorations for this widget
702 //-------------------------------------------------------------------------
703 NS_IMETHODIMP
nsBaseWidget::HideWindowChrome(PRBool aShouldHide
)
705 return NS_ERROR_NOT_IMPLEMENTED
;
708 //-------------------------------------------------------------------------
710 // Put the window into full-screen mode
712 //-------------------------------------------------------------------------
713 NS_IMETHODIMP
nsBaseWidget::MakeFullScreen(PRBool aFullScreen
)
715 HideWindowChrome(aFullScreen
);
718 if (!mOriginalBounds
)
719 mOriginalBounds
= new nsIntRect();
720 GetScreenBounds(*mOriginalBounds
);
722 // Move to top-left corner of screen and size to the screen dimensions
723 nsCOMPtr
<nsIScreenManager
> screenManager
;
724 screenManager
= do_GetService("@mozilla.org/gfx/screenmanager;1");
725 NS_ASSERTION(screenManager
, "Unable to grab screenManager.");
727 nsCOMPtr
<nsIScreen
> screen
;
728 screenManager
->ScreenForRect(mOriginalBounds
->x
, mOriginalBounds
->y
,
729 mOriginalBounds
->width
, mOriginalBounds
->height
,
730 getter_AddRefs(screen
));
732 PRInt32 left
, top
, width
, height
;
733 if (NS_SUCCEEDED(screen
->GetRect(&left
, &top
, &width
, &height
))) {
734 Resize(left
, top
, width
, height
, PR_TRUE
);
739 } else if (mOriginalBounds
) {
740 Resize(mOriginalBounds
->x
, mOriginalBounds
->y
, mOriginalBounds
->width
,
741 mOriginalBounds
->height
, PR_TRUE
);
747 nsBaseWidget::AutoLayerManagerSetup::AutoLayerManagerSetup(
748 nsBaseWidget
* aWidget
, gfxContext
* aTarget
,
749 BasicLayerManager::BufferMode aDoubleBuffering
)
752 BasicLayerManager
* manager
=
753 static_cast<BasicLayerManager
*>(mWidget
->GetLayerManager(nsnull
));
755 NS_ASSERTION(manager
->GetBackendType() == LayerManager::LAYERS_BASIC
,
756 "AutoLayerManagerSetup instantiated for non-basic layer backend!");
757 manager
->SetDefaultTarget(aTarget
, aDoubleBuffering
);
761 nsBaseWidget::AutoLayerManagerSetup::~AutoLayerManagerSetup()
763 BasicLayerManager
* manager
=
764 static_cast<BasicLayerManager
*>(mWidget
->GetLayerManager(nsnull
));
766 NS_ASSERTION(manager
->GetBackendType() == LayerManager::LAYERS_BASIC
,
767 "AutoLayerManagerSetup instantiated for non-basic layer backend!");
768 manager
->SetDefaultTarget(nsnull
, BasicLayerManager::BUFFER_NONE
);
772 nsBaseWidget::AutoUseBasicLayerManager::AutoUseBasicLayerManager(nsBaseWidget
* aWidget
)
775 mWidget
->mTemporarilyUseBasicLayerManager
= PR_TRUE
;
778 nsBaseWidget::AutoUseBasicLayerManager::~AutoUseBasicLayerManager()
780 mWidget
->mTemporarilyUseBasicLayerManager
= PR_FALSE
;
784 nsBaseWidget::GetShouldAccelerate()
786 nsCOMPtr
<nsIPrefBranch2
> prefs
= do_GetService(NS_PREFSERVICE_CONTRACTID
);
788 PRBool disableAcceleration
= PR_FALSE
;
789 PRBool forceAcceleration
= PR_FALSE
;
790 #if defined(XP_WIN) || defined(ANDROID) || (MOZ_PLATFORM_MAEMO > 5)
791 PRBool accelerateByDefault
= PR_TRUE
;
792 #elif defined(XP_MACOSX)
793 /* quickdraw plugins don't work with OpenGL so we need to avoid OpenGL when we want to support
795 # if defined(NP_NO_QUICKDRAW)
796 PRBool accelerateByDefault
= PR_TRUE
;
798 // 10.6.2 and lower have a bug involving textures and pixel buffer objects
799 // that caused bug 629016, so we don't allow OpenGL-accelerated layers on
800 // those versions of the OS.
801 // This will still let full-screen video be accelerated on OpenGL, because
802 // that XUL widget opts in to acceleration, but that's probably OK.
803 SInt32 major
, minor
, bugfix
;
804 OSErr err1
= ::Gestalt(gestaltSystemVersionMajor
, &major
);
805 OSErr err2
= ::Gestalt(gestaltSystemVersionMinor
, &minor
);
806 OSErr err3
= ::Gestalt(gestaltSystemVersionBugFix
, &bugfix
);
807 if (err1
== noErr
&& err2
== noErr
&& err3
== noErr
) {
808 if (major
== 10 && minor
== 6) {
810 accelerateByDefault
= PR_FALSE
;
816 PRBool accelerateByDefault
= PR_FALSE
;
820 PRBool accelerateByDefault
= PR_FALSE
;
824 // we should use AddBoolPrefVarCache
825 prefs
->GetBoolPref("layers.acceleration.disabled",
826 &disableAcceleration
);
828 prefs
->GetBoolPref("layers.acceleration.force-enabled",
833 const char *acceleratedEnv
= PR_GetEnv("MOZ_ACCELERATED");
834 accelerateByDefault
= accelerateByDefault
||
835 (acceleratedEnv
&& (*acceleratedEnv
!= '0'));
837 nsCOMPtr
<nsIXULRuntime
> xr
= do_GetService("@mozilla.org/xre/runtime;1");
838 PRBool safeMode
= PR_FALSE
;
840 xr
->GetInSafeMode(&safeMode
);
842 if (disableAcceleration
|| safeMode
)
845 if (forceAcceleration
)
848 nsCOMPtr
<nsIGfxInfo
> gfxInfo
= do_GetService("@mozilla.org/gfx/info;1");
851 if (NS_SUCCEEDED(gfxInfo
->GetFeatureStatus(nsIGfxInfo::FEATURE_OPENGL_LAYERS
, &status
))) {
852 if (status
!= nsIGfxInfo::FEATURE_NO_INFO
) {
853 NS_WARNING("OpenGL-accelerated layers are not supported on this system.");
859 if (accelerateByDefault
)
862 /* use the window acceleration flag */
863 return mUseAcceleratedRendering
;
866 LayerManager
* nsBaseWidget::GetLayerManager(bool* aAllowRetaining
)
868 return GetLayerManager(LAYER_MANAGER_CURRENT
, aAllowRetaining
);
871 LayerManager
* nsBaseWidget::GetLayerManager(LayerManagerPersistence
,
872 bool* aAllowRetaining
)
874 if (!mLayerManager
) {
876 mUseAcceleratedRendering
= GetShouldAccelerate();
878 if (mUseAcceleratedRendering
) {
879 nsRefPtr
<LayerManagerOGL
> layerManager
=
880 new mozilla::layers::LayerManagerOGL(this);
882 * XXX - On several OSes initialization is expected to fail for now.
883 * If we'd get a none-basic layer manager they'd crash. This is ok though
884 * since on those platforms it will fail. Anyone implementing new
885 * platforms on LayerManagerOGL should ensure their widget is able to
886 * deal with it though!
888 if (layerManager
->Initialize()) {
889 mLayerManager
= layerManager
;
892 if (!mLayerManager
) {
893 mBasicLayerManager
= mLayerManager
= CreateBasicLayerManager();
896 if (mTemporarilyUseBasicLayerManager
&& !mBasicLayerManager
) {
897 mBasicLayerManager
= CreateBasicLayerManager();
899 LayerManager
* usedLayerManager
= mTemporarilyUseBasicLayerManager
?
900 mBasicLayerManager
: mLayerManager
;
901 if (aAllowRetaining
) {
902 *aAllowRetaining
= (usedLayerManager
== mLayerManager
);
904 return usedLayerManager
;
907 BasicLayerManager
* nsBaseWidget::CreateBasicLayerManager()
909 #if !defined(MOZ_IPC)
910 return new BasicLayerManager(this);
912 return new BasicShadowLayerManager(this);
916 //-------------------------------------------------------------------------
918 // Return the toolkit this widget was created on
920 //-------------------------------------------------------------------------
921 nsIToolkit
* nsBaseWidget::GetToolkit()
927 //-------------------------------------------------------------------------
929 // Return the used device context
931 //-------------------------------------------------------------------------
932 nsIDeviceContext
* nsBaseWidget::GetDeviceContext()
937 //-------------------------------------------------------------------------
939 // Get the thebes surface
941 //-------------------------------------------------------------------------
942 gfxASurface
*nsBaseWidget::GetThebesSurface()
944 // in theory we should get our parent's surface,
945 // clone it, and set a device offset before returning
950 //-------------------------------------------------------------------------
952 // Destroy the window
954 //-------------------------------------------------------------------------
955 void nsBaseWidget::OnDestroy()
957 // release references to device context, toolkit, and app shell
958 NS_IF_RELEASE(mContext
);
959 NS_IF_RELEASE(mToolkit
);
962 NS_METHOD
nsBaseWidget::SetWindowClass(const nsAString
& xulWinType
)
964 return NS_ERROR_NOT_IMPLEMENTED
;
967 //-------------------------------------------------------------------------
971 //-------------------------------------------------------------------------
974 * If the implementation of nsWindow supports borders this method MUST be overridden
977 NS_METHOD
nsBaseWidget::GetClientBounds(nsIntRect
&aRect
)
979 return GetBounds(aRect
);
983 * If the implementation of nsWindow supports borders this method MUST be overridden
986 NS_METHOD
nsBaseWidget::GetBounds(nsIntRect
&aRect
)
993 * If the implementation of nsWindow uses a local coordinate system within the window,
994 * this method must be overridden
997 NS_METHOD
nsBaseWidget::GetScreenBounds(nsIntRect
&aRect
)
999 return GetBounds(aRect
);
1002 nsIntPoint
nsBaseWidget::GetClientOffset()
1004 return nsIntPoint(0, 0);
1007 NS_METHOD
nsBaseWidget::SetBounds(const nsIntRect
&aRect
)
1015 nsBaseWidget::GetNonClientMargins(nsIntMargin
&margins
)
1017 return NS_ERROR_NOT_IMPLEMENTED
;
1021 nsBaseWidget::SetNonClientMargins(nsIntMargin
&margins
)
1023 return NS_ERROR_NOT_IMPLEMENTED
;
1026 NS_METHOD
nsBaseWidget::EnableDragDrop(PRBool aEnable
)
1031 NS_METHOD
nsBaseWidget::SetModal(PRBool aModal
)
1033 return NS_ERROR_FAILURE
;
1037 nsBaseWidget::GetAttention(PRInt32 aCycleCount
) {
1042 nsBaseWidget::HasPendingInputEvent()
1048 nsBaseWidget::SetIcon(const nsAString
&)
1054 nsBaseWidget::BeginSecureKeyboardInput()
1057 NS_ASSERTION(!debug_InSecureKeyboardInputMode
, "Attempting to nest call to BeginSecureKeyboardInput!");
1058 debug_InSecureKeyboardInputMode
= PR_TRUE
;
1064 nsBaseWidget::EndSecureKeyboardInput()
1067 NS_ASSERTION(debug_InSecureKeyboardInputMode
, "Calling EndSecureKeyboardInput when it hasn't been enabled!");
1068 debug_InSecureKeyboardInputMode
= PR_FALSE
;
1074 nsBaseWidget::SetWindowTitlebarColor(nscolor aColor
, PRBool aActive
)
1076 return NS_ERROR_NOT_IMPLEMENTED
;
1080 nsBaseWidget::ShowsResizeIndicator(nsIntRect
* aResizerRect
)
1086 nsBaseWidget::SetAcceleratedRendering(PRBool aEnabled
)
1088 if (mUseAcceleratedRendering
== aEnabled
) {
1091 mUseAcceleratedRendering
= aEnabled
;
1092 if (mLayerManager
) {
1093 mLayerManager
->Destroy();
1095 mLayerManager
= NULL
;
1100 nsBaseWidget::GetAcceleratedRendering()
1102 return mUseAcceleratedRendering
;
1105 NS_METHOD
nsBaseWidget::RegisterTouchWindow()
1107 return NS_ERROR_NOT_IMPLEMENTED
;
1110 NS_METHOD
nsBaseWidget::UnregisterTouchWindow()
1112 return NS_ERROR_NOT_IMPLEMENTED
;
1116 nsBaseWidget::OverrideSystemMouseScrollSpeed(PRInt32 aOriginalDelta
,
1117 PRBool aIsHorizontal
,
1118 PRInt32
&aOverriddenDelta
)
1120 aOverriddenDelta
= aOriginalDelta
;
1122 nsCOMPtr
<nsIPrefService
> prefs
= do_GetService(NS_PREFSERVICE_CONTRACTID
);
1123 NS_ENSURE_TRUE(prefs
, NS_ERROR_FAILURE
);
1124 nsCOMPtr
<nsIPrefBranch
> prefBranch
;
1125 nsresult rv
= prefs
->GetBranch(nsnull
, getter_AddRefs(prefBranch
));
1126 NS_ENSURE_SUCCESS(rv
, rv
);
1127 NS_ENSURE_TRUE(prefBranch
, NS_ERROR_FAILURE
);
1129 PRBool isOverrideEnabled
;
1130 const char* kPrefNameOverrideEnabled
=
1131 "mousewheel.system_scroll_override_on_root_content.enabled";
1132 rv
= prefBranch
->GetBoolPref(kPrefNameOverrideEnabled
, &isOverrideEnabled
);
1133 if (NS_FAILED(rv
) || !isOverrideEnabled
) {
1138 nsCAutoString
factorPrefName(
1139 "mousewheel.system_scroll_override_on_root_content.");
1140 if (aIsHorizontal
) {
1141 factorPrefName
.AppendLiteral("horizontal.");
1143 factorPrefName
.AppendLiteral("vertical.");
1145 factorPrefName
.AppendLiteral("factor");
1146 rv
= prefBranch
->GetIntPref(factorPrefName
.get(), &iFactor
);
1147 // The pref value must be larger than 100, otherwise, we don't override the
1149 if (NS_FAILED(rv
) || iFactor
<= 100) {
1152 double factor
= (double)iFactor
/ 100;
1153 aOverriddenDelta
= PRInt32(NS_round((double)aOriginalDelta
* factor
));
1160 * Modifies aFile to point at an icon file with the given name and suffix. The
1161 * suffix may correspond to a file extension with leading '.' if appropriate.
1162 * Returns true if the icon file exists and can be read.
1165 ResolveIconNameHelper(nsILocalFile
*aFile
,
1166 const nsAString
&aIconName
,
1167 const nsAString
&aIconSuffix
)
1169 aFile
->Append(NS_LITERAL_STRING("icons"));
1170 aFile
->Append(NS_LITERAL_STRING("default"));
1171 aFile
->Append(aIconName
+ aIconSuffix
);
1174 return NS_SUCCEEDED(aFile
->IsReadable(&readable
)) && readable
;
1178 * Resolve the given icon name into a local file object. This method is
1179 * intended to be called by subclasses of nsBaseWidget. aIconSuffix is a
1180 * platform specific icon file suffix (e.g., ".ico" under Win32).
1182 * If no file is found matching the given parameters, then null is returned.
1185 nsBaseWidget::ResolveIconName(const nsAString
&aIconName
,
1186 const nsAString
&aIconSuffix
,
1187 nsILocalFile
**aResult
)
1191 nsCOMPtr
<nsIProperties
> dirSvc
= do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID
);
1195 // first check auxilary chrome directories
1197 nsCOMPtr
<nsISimpleEnumerator
> dirs
;
1198 dirSvc
->Get(NS_APP_CHROME_DIR_LIST
, NS_GET_IID(nsISimpleEnumerator
),
1199 getter_AddRefs(dirs
));
1202 while (NS_SUCCEEDED(dirs
->HasMoreElements(&hasMore
)) && hasMore
) {
1203 nsCOMPtr
<nsISupports
> element
;
1204 dirs
->GetNext(getter_AddRefs(element
));
1207 nsCOMPtr
<nsILocalFile
> file
= do_QueryInterface(element
);
1210 if (ResolveIconNameHelper(file
, aIconName
, aIconSuffix
)) {
1211 NS_ADDREF(*aResult
= file
);
1217 // then check the main app chrome directory
1219 nsCOMPtr
<nsILocalFile
> file
;
1220 dirSvc
->Get(NS_APP_CHROME_DIR
, NS_GET_IID(nsILocalFile
),
1221 getter_AddRefs(file
));
1222 if (file
&& ResolveIconNameHelper(file
, aIconName
, aIconSuffix
))
1223 NS_ADDREF(*aResult
= file
);
1227 nsBaseWidget::BeginResizeDrag(nsGUIEvent
* aEvent
, PRInt32 aHorizontal
, PRInt32 aVertical
)
1229 return NS_ERROR_NOT_IMPLEMENTED
;
1233 nsBaseWidget::BeginMoveDrag(nsMouseEvent
* aEvent
)
1235 return NS_ERROR_NOT_IMPLEMENTED
;
1238 // For backwards compatibility only
1240 nsBaseWidget::SetIMEEnabled(PRUint32 aState
)
1243 context
.mStatus
= aState
;
1244 return SetInputMode(context
);
1248 nsBaseWidget::GetIMEEnabled(PRUint32
* aState
)
1251 nsresult rv
= GetInputMode(context
);
1252 NS_ENSURE_SUCCESS(rv
, rv
);
1254 *aState
= context
.mStatus
;
1259 //////////////////////////////////////////////////////////////
1261 // Convert a GUI event message code to a string.
1262 // Makes it a lot easier to debug events.
1264 // See gtk/nsWidget.cpp and windows/nsWindow.cpp
1265 // for a DebugPrintEvent() function that uses
1268 //////////////////////////////////////////////////////////////
1269 /* static */ nsAutoString
1270 nsBaseWidget::debug_GuiEventToString(nsGUIEvent
* aGuiEvent
)
1272 NS_ASSERTION(nsnull
!= aGuiEvent
,"cmon, null gui event.");
1274 nsAutoString
eventName(NS_LITERAL_STRING("UNKNOWN"));
1276 #define _ASSIGN_eventName(_value,_name)\
1277 case _value: eventName.AssignWithConversion(_name) ; break
1279 switch(aGuiEvent
->message
)
1281 _ASSIGN_eventName(NS_BLUR_CONTENT
,"NS_BLUR_CONTENT");
1282 _ASSIGN_eventName(NS_CREATE
,"NS_CREATE");
1283 _ASSIGN_eventName(NS_DESTROY
,"NS_DESTROY");
1284 _ASSIGN_eventName(NS_DRAGDROP_GESTURE
,"NS_DND_GESTURE");
1285 _ASSIGN_eventName(NS_DRAGDROP_DROP
,"NS_DND_DROP");
1286 _ASSIGN_eventName(NS_DRAGDROP_ENTER
,"NS_DND_ENTER");
1287 _ASSIGN_eventName(NS_DRAGDROP_EXIT
,"NS_DND_EXIT");
1288 _ASSIGN_eventName(NS_DRAGDROP_OVER
,"NS_DND_OVER");
1289 _ASSIGN_eventName(NS_FOCUS_CONTENT
,"NS_FOCUS_CONTENT");
1290 _ASSIGN_eventName(NS_FORM_SELECTED
,"NS_FORM_SELECTED");
1291 _ASSIGN_eventName(NS_FORM_CHANGE
,"NS_FORM_CHANGE");
1292 _ASSIGN_eventName(NS_FORM_INPUT
,"NS_FORM_INPUT");
1293 _ASSIGN_eventName(NS_FORM_RESET
,"NS_FORM_RESET");
1294 _ASSIGN_eventName(NS_FORM_SUBMIT
,"NS_FORM_SUBMIT");
1295 _ASSIGN_eventName(NS_IMAGE_ABORT
,"NS_IMAGE_ABORT");
1296 _ASSIGN_eventName(NS_LOAD_ERROR
,"NS_LOAD_ERROR");
1297 _ASSIGN_eventName(NS_KEY_DOWN
,"NS_KEY_DOWN");
1298 _ASSIGN_eventName(NS_KEY_PRESS
,"NS_KEY_PRESS");
1299 _ASSIGN_eventName(NS_KEY_UP
,"NS_KEY_UP");
1300 _ASSIGN_eventName(NS_MOUSE_ENTER
,"NS_MOUSE_ENTER");
1301 _ASSIGN_eventName(NS_MOUSE_EXIT
,"NS_MOUSE_EXIT");
1302 _ASSIGN_eventName(NS_MOUSE_BUTTON_DOWN
,"NS_MOUSE_BUTTON_DOWN");
1303 _ASSIGN_eventName(NS_MOUSE_BUTTON_UP
,"NS_MOUSE_BUTTON_UP");
1304 _ASSIGN_eventName(NS_MOUSE_CLICK
,"NS_MOUSE_CLICK");
1305 _ASSIGN_eventName(NS_MOUSE_DOUBLECLICK
,"NS_MOUSE_DBLCLICK");
1306 _ASSIGN_eventName(NS_MOUSE_MOVE
,"NS_MOUSE_MOVE");
1307 _ASSIGN_eventName(NS_MOVE
,"NS_MOVE");
1308 _ASSIGN_eventName(NS_LOAD
,"NS_LOAD");
1309 _ASSIGN_eventName(NS_POPSTATE
,"NS_POPSTATE");
1310 _ASSIGN_eventName(NS_BEFORE_SCRIPT_EXECUTE
,"NS_BEFORE_SCRIPT_EXECUTE");
1311 _ASSIGN_eventName(NS_AFTER_SCRIPT_EXECUTE
,"NS_AFTER_SCRIPT_EXECUTE");
1312 _ASSIGN_eventName(NS_PAGE_UNLOAD
,"NS_PAGE_UNLOAD");
1313 _ASSIGN_eventName(NS_HASHCHANGE
,"NS_HASHCHANGE");
1314 _ASSIGN_eventName(NS_READYSTATECHANGE
,"NS_READYSTATECHANGE");
1315 _ASSIGN_eventName(NS_PAINT
,"NS_PAINT");
1316 _ASSIGN_eventName(NS_XUL_BROADCAST
, "NS_XUL_BROADCAST");
1317 _ASSIGN_eventName(NS_XUL_COMMAND_UPDATE
, "NS_XUL_COMMAND_UPDATE");
1318 _ASSIGN_eventName(NS_SCROLLBAR_LINE_NEXT
,"NS_SB_LINE_NEXT");
1319 _ASSIGN_eventName(NS_SCROLLBAR_LINE_PREV
,"NS_SB_LINE_PREV");
1320 _ASSIGN_eventName(NS_SCROLLBAR_PAGE_NEXT
,"NS_SB_PAGE_NEXT");
1321 _ASSIGN_eventName(NS_SCROLLBAR_PAGE_PREV
,"NS_SB_PAGE_PREV");
1322 _ASSIGN_eventName(NS_SCROLLBAR_POS
,"NS_SB_POS");
1323 _ASSIGN_eventName(NS_SIZE
,"NS_SIZE");
1325 #undef _ASSIGN_eventName
1331 sprintf(buf
,"UNKNOWN: %d",aGuiEvent
->message
);
1333 eventName
.AssignWithConversion(buf
);
1338 return nsAutoString(eventName
);
1340 //////////////////////////////////////////////////////////////
1342 // Code to deal with paint and event debug prefs.
1344 //////////////////////////////////////////////////////////////
1351 static PrefPair debug_PrefValues
[] =
1353 { "nglayout.debug.crossing_event_dumping", PR_FALSE
},
1354 { "nglayout.debug.event_dumping", PR_FALSE
},
1355 { "nglayout.debug.invalidate_dumping", PR_FALSE
},
1356 { "nglayout.debug.motion_event_dumping", PR_FALSE
},
1357 { "nglayout.debug.paint_dumping", PR_FALSE
},
1358 { "nglayout.debug.paint_flashing", PR_FALSE
}
1361 static PRUint32 debug_NumPrefValues
=
1362 (sizeof(debug_PrefValues
) / sizeof(debug_PrefValues
[0]));
1365 //////////////////////////////////////////////////////////////
1366 static PRBool
debug_GetBoolPref(nsIPrefBranch
* aPrefs
,const char * aPrefName
)
1368 NS_ASSERTION(nsnull
!= aPrefName
,"cmon, pref name is null.");
1369 NS_ASSERTION(nsnull
!= aPrefs
,"cmon, prefs are null.");
1371 PRBool value
= PR_FALSE
;
1375 aPrefs
->GetBoolPref(aPrefName
,&value
);
1380 //////////////////////////////////////////////////////////////
1382 nsBaseWidget::debug_GetCachedBoolPref(const char * aPrefName
)
1384 NS_ASSERTION(nsnull
!= aPrefName
,"cmon, pref name is null.");
1386 for (PRUint32 i
= 0; i
< debug_NumPrefValues
; i
++)
1388 if (strcmp(debug_PrefValues
[i
].name
, aPrefName
) == 0)
1390 return debug_PrefValues
[i
].value
;
1396 //////////////////////////////////////////////////////////////
1397 static void debug_SetCachedBoolPref(const char * aPrefName
,PRBool aValue
)
1399 NS_ASSERTION(nsnull
!= aPrefName
,"cmon, pref name is null.");
1401 for (PRUint32 i
= 0; i
< debug_NumPrefValues
; i
++)
1403 if (strcmp(debug_PrefValues
[i
].name
, aPrefName
) == 0)
1405 debug_PrefValues
[i
].value
= aValue
;
1411 NS_ASSERTION(PR_FALSE
, "cmon, this code is not reached dude.");
1414 //////////////////////////////////////////////////////////////
1415 class Debug_PrefObserver
: public nsIObserver
{
1421 NS_IMPL_ISUPPORTS1(Debug_PrefObserver
, nsIObserver
)
1424 Debug_PrefObserver::Observe(nsISupports
* subject
, const char* topic
,
1425 const PRUnichar
* data
)
1427 nsCOMPtr
<nsIPrefBranch
> branch(do_QueryInterface(subject
));
1428 NS_ASSERTION(branch
, "must implement nsIPrefBranch");
1430 NS_ConvertUTF16toUTF8
prefName(data
);
1432 PRBool value
= PR_FALSE
;
1433 branch
->GetBoolPref(prefName
.get(), &value
);
1434 debug_SetCachedBoolPref(prefName
.get(), value
);
1438 //////////////////////////////////////////////////////////////
1440 debug_RegisterPrefCallbacks()
1442 static PRBool once
= PR_TRUE
;
1448 nsCOMPtr
<nsIPrefBranch2
> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID
));
1450 NS_ASSERTION(prefs
, "Prefs services is null.");
1454 nsCOMPtr
<nsIObserver
> obs(new Debug_PrefObserver());
1455 for (PRUint32 i
= 0; i
< debug_NumPrefValues
; i
++)
1457 // Initialize the pref values
1458 debug_PrefValues
[i
].value
=
1459 debug_GetBoolPref(prefs
,debug_PrefValues
[i
].name
);
1462 // Register callbacks for when these change
1463 prefs
->AddObserver(debug_PrefValues
[i
].name
, obs
, PR_FALSE
);
1469 //////////////////////////////////////////////////////////////
1473 static PRInt32 sCount
= 0;
1477 //////////////////////////////////////////////////////////////
1479 nsBaseWidget::debug_WantPaintFlashing()
1481 return debug_GetCachedBoolPref("nglayout.debug.paint_flashing");
1483 //////////////////////////////////////////////////////////////
1485 nsBaseWidget::debug_DumpEvent(FILE * aFileOut
,
1486 nsIWidget
* aWidget
,
1487 nsGUIEvent
* aGuiEvent
,
1488 const nsCAutoString
& aWidgetName
,
1491 // NS_PAINT is handled by debug_DumpPaintEvent()
1492 if (aGuiEvent
->message
== NS_PAINT
)
1495 if (aGuiEvent
->message
== NS_MOUSE_MOVE
)
1497 if (!debug_GetCachedBoolPref("nglayout.debug.motion_event_dumping"))
1501 if (aGuiEvent
->message
== NS_MOUSE_ENTER
||
1502 aGuiEvent
->message
== NS_MOUSE_EXIT
)
1504 if (!debug_GetCachedBoolPref("nglayout.debug.crossing_event_dumping"))
1508 if (!debug_GetCachedBoolPref("nglayout.debug.event_dumping"))
1511 nsCAutoString tempString
; tempString
.AssignWithConversion(debug_GuiEventToString(aGuiEvent
).get());
1514 "%4d %-26s widget=%-8p name=%-12s id=%-8p refpt=%d,%d\n",
1519 (void *) (aWindowID
? aWindowID
: 0x0),
1520 aGuiEvent
->refPoint
.x
,
1521 aGuiEvent
->refPoint
.y
);
1523 //////////////////////////////////////////////////////////////
1525 nsBaseWidget::debug_DumpPaintEvent(FILE * aFileOut
,
1526 nsIWidget
* aWidget
,
1527 nsPaintEvent
* aPaintEvent
,
1528 const nsCAutoString
& aWidgetName
,
1531 NS_ASSERTION(nsnull
!= aFileOut
,"cmon, null output FILE");
1532 NS_ASSERTION(nsnull
!= aWidget
,"cmon, the widget is null");
1533 NS_ASSERTION(nsnull
!= aPaintEvent
,"cmon, the paint event is null");
1535 if (!debug_GetCachedBoolPref("nglayout.debug.paint_dumping"))
1538 nsIntRect rect
= aPaintEvent
->region
.GetBounds();
1540 "%4d PAINT widget=%p name=%-12s id=%-8p bounds-rect=%3d,%-3d %3d,%-3d",
1545 rect
.x
, rect
.y
, rect
.width
, rect
.height
1548 fprintf(aFileOut
,"\n");
1550 //////////////////////////////////////////////////////////////
1552 nsBaseWidget::debug_DumpInvalidate(FILE * aFileOut
,
1553 nsIWidget
* aWidget
,
1554 const nsIntRect
* aRect
,
1555 PRBool aIsSynchronous
,
1556 const nsCAutoString
& aWidgetName
,
1559 if (!debug_GetCachedBoolPref("nglayout.debug.invalidate_dumping"))
1562 NS_ASSERTION(nsnull
!= aFileOut
,"cmon, null output FILE");
1563 NS_ASSERTION(nsnull
!= aWidget
,"cmon, the widget is null");
1566 "%4d Invalidate widget=%p name=%-12s id=%-8p",
1570 (void *) aWindowID
);
1575 " rect=%3d,%-3d %3d,%-3d",
1590 (const char *) (aIsSynchronous
? "yes" : "no "));
1592 fprintf(aFileOut
,"\n");
1594 //////////////////////////////////////////////////////////////