Skip to content

Commit 936ba7d

Browse files
committed
Bug 674370 - Make browser windows (and other document-like windows) zoom on creation on OS X 10.7. r=mstange,dao sr=bzbarsky
1 parent 6a945ff commit 936ba7d

File tree

12 files changed

+112
-27
lines changed

12 files changed

+112
-27
lines changed

browser/base/content/browser.xul

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
lightweightthemes="true"
9191
lightweightthemesfooter="browser-bottombox"
9292
windowtype="navigator:browser"
93+
macanimationtype="document"
9394
screenX="4" screenY="4"
9495
browsingmode="normal"
9596
persist="screenX screenY width height sizemode">

browser/components/sessionstore/src/nsSessionStore.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3816,7 +3816,7 @@ SessionStoreService.prototype = {
38163816
argString.data = "";
38173817

38183818
// Build feature string
3819-
let features = "chrome,dialog=no,all";
3819+
let features = "chrome,dialog=no,macsuppressanimation,all";
38203820
let winState = aState.windows[0];
38213821
WINDOW_ATTRIBUTES.forEach(function(aFeature) {
38223822
// Use !isNaN as an easy way to ignore sizemode and check for numbers

browser/devtools/scratchpad/scratchpad.xul

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
5252
title="&window.title;"
5353
windowtype="devtools:scratchpad"
54+
macanimationtype="document"
5455
screenX="4" screenY="4"
5556
width="640" height="480"
5657
persist="screenX screenY width height sizemode">

embedding/browser/webBrowser/nsIWebBrowserChrome.idl

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ interface nsIDocShellTreeItem;
4747
* containing an embedded Gecko web browser.
4848
*/
4949

50-
[scriptable, uuid(BA434C60-9D52-11d3-AFB0-00A024FFC08C)]
50+
[scriptable, uuid(E8C414C4-DC38-4BA3-AB4E-EC4CBBE22907)]
5151
interface nsIWebBrowserChrome : nsISupports
5252
{
5353
const unsigned long STATUS_SCRIPT = 0x00000001;
@@ -75,43 +75,47 @@ interface nsIWebBrowserChrome : nsISupports
7575
/**
7676
* Definitions for the chrome flags
7777
*/
78-
const unsigned long CHROME_DEFAULT = 0x00000001;
79-
const unsigned long CHROME_WINDOW_BORDERS = 0x00000002;
80-
const unsigned long CHROME_WINDOW_CLOSE = 0x00000004;
81-
const unsigned long CHROME_WINDOW_RESIZE = 0x00000008;
82-
const unsigned long CHROME_MENUBAR = 0x00000010;
83-
const unsigned long CHROME_TOOLBAR = 0x00000020;
84-
const unsigned long CHROME_LOCATIONBAR = 0x00000040;
85-
const unsigned long CHROME_STATUSBAR = 0x00000080;
86-
const unsigned long CHROME_PERSONAL_TOOLBAR = 0x00000100;
87-
const unsigned long CHROME_SCROLLBARS = 0x00000200;
88-
const unsigned long CHROME_TITLEBAR = 0x00000400;
89-
const unsigned long CHROME_EXTRA = 0x00000800;
78+
const unsigned long CHROME_DEFAULT = 0x00000001;
79+
const unsigned long CHROME_WINDOW_BORDERS = 0x00000002;
80+
const unsigned long CHROME_WINDOW_CLOSE = 0x00000004;
81+
const unsigned long CHROME_WINDOW_RESIZE = 0x00000008;
82+
const unsigned long CHROME_MENUBAR = 0x00000010;
83+
const unsigned long CHROME_TOOLBAR = 0x00000020;
84+
const unsigned long CHROME_LOCATIONBAR = 0x00000040;
85+
const unsigned long CHROME_STATUSBAR = 0x00000080;
86+
const unsigned long CHROME_PERSONAL_TOOLBAR = 0x00000100;
87+
const unsigned long CHROME_SCROLLBARS = 0x00000200;
88+
const unsigned long CHROME_TITLEBAR = 0x00000400;
89+
const unsigned long CHROME_EXTRA = 0x00000800;
9090

9191
// createBrowserWindow specific flags
92-
const unsigned long CHROME_WITH_SIZE = 0x00001000;
93-
const unsigned long CHROME_WITH_POSITION = 0x00002000;
92+
const unsigned long CHROME_WITH_SIZE = 0x00001000;
93+
const unsigned long CHROME_WITH_POSITION = 0x00002000;
9494

9595
// special cases
96-
const unsigned long CHROME_WINDOW_MIN = 0x00004000;
97-
const unsigned long CHROME_WINDOW_POPUP = 0x00008000;
96+
const unsigned long CHROME_WINDOW_MIN = 0x00004000;
97+
const unsigned long CHROME_WINDOW_POPUP = 0x00008000;
9898

99-
const unsigned long CHROME_WINDOW_RAISED = 0x02000000;
100-
const unsigned long CHROME_WINDOW_LOWERED = 0x04000000;
101-
const unsigned long CHROME_CENTER_SCREEN = 0x08000000;
99+
// Prevents new window animations on Mac OS X Lion. Ignored on other
100+
// platforms.
101+
const unsigned long CHROME_MAC_SUPPRESS_ANIMATION = 0x01000000;
102+
103+
const unsigned long CHROME_WINDOW_RAISED = 0x02000000;
104+
const unsigned long CHROME_WINDOW_LOWERED = 0x04000000;
105+
const unsigned long CHROME_CENTER_SCREEN = 0x08000000;
102106

103107
// Make the new window dependent on the parent. This flag is only
104108
// meaningful if CHROME_OPENAS_CHROME is set; content windows should not be
105109
// dependent.
106-
const unsigned long CHROME_DEPENDENT = 0x10000000;
110+
const unsigned long CHROME_DEPENDENT = 0x10000000;
107111

108112
// Note: The modal style bit just affects the way the window looks and does
109113
// mean it's actually modal.
110-
const unsigned long CHROME_MODAL = 0x20000000;
111-
const unsigned long CHROME_OPENAS_DIALOG = 0x40000000;
112-
const unsigned long CHROME_OPENAS_CHROME = 0x80000000;
114+
const unsigned long CHROME_MODAL = 0x20000000;
115+
const unsigned long CHROME_OPENAS_DIALOG = 0x40000000;
116+
const unsigned long CHROME_OPENAS_CHROME = 0x80000000;
113117

114-
const unsigned long CHROME_ALL = 0x00000ffe;
118+
const unsigned long CHROME_ALL = 0x00000ffe;
115119

116120
/**
117121
* The chrome flags for this browser chrome. The implementation should

embedding/components/windowwatcher/src/nsWindowWatcher.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,6 +1527,9 @@ PRUint32 nsWindowWatcher::CalculateChromeFlags(const char *aFeatures,
15271527
else if (WinHasOption(aFeatures, "alwaysRaised", 0, nsnull))
15281528
chromeFlags |= nsIWebBrowserChrome::CHROME_WINDOW_RAISED;
15291529

1530+
chromeFlags |= WinHasOption(aFeatures, "macsuppressanimation", 0, nsnull) ?
1531+
nsIWebBrowserChrome::CHROME_MAC_SUPPRESS_ANIMATION : 0;
1532+
15301533
chromeFlags |= WinHasOption(aFeatures, "chrome", 0, nsnull) ?
15311534
nsIWebBrowserChrome::CHROME_OPENAS_CHROME : 0;
15321535
chromeFlags |= WinHasOption(aFeatures, "extrachrome", 0, nsnull) ?

widget/cocoa/nsCocoaWindow.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,21 @@ typedef struct _nsCocoaWindowList {
197197
- (void)setDrawsContentsIntoWindowFrame:(BOOL)aState;
198198
@end
199199

200+
#if !defined(MAC_OS_X_VERSION_10_7) || (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7)
201+
enum {
202+
NSWindowAnimationBehaviorDefault = 0,
203+
NSWindowAnimationBehaviorNone = 2,
204+
NSWindowAnimationBehaviorDocumentWindow = 3,
205+
NSWindowAnimationBehaviorUtilityWindow = 4,
206+
NSWindowAnimationBehaviorAlertPanel = 5
207+
};
208+
typedef NSInteger NSWindowAnimationBehavior;
209+
210+
@interface NSWindow (LionWindowFeatures)
211+
- (void)setAnimationBehavior:(NSWindowAnimationBehavior)newAnimationBehavior;
212+
@end
213+
#endif
214+
200215
class nsCocoaWindow : public nsBaseWidget, public nsPIWidgetCocoa
201216
{
202217
private:
@@ -266,6 +281,7 @@ class nsCocoaWindow : public nsBaseWidget, public nsPIWidgetCocoa
266281
virtual void SetTransparencyMode(nsTransparencyMode aMode);
267282
NS_IMETHOD SetWindowShadowStyle(PRInt32 aStyle);
268283
virtual void SetShowsToolbarButton(bool aShow);
284+
virtual void SetWindowAnimationType(WindowAnimationType aType);
269285
NS_IMETHOD SetWindowTitlebarColor(nscolor aColor, bool aActive);
270286
virtual void SetDrawsInTitlebar(bool aState);
271287
virtual nsresult SynthesizeNativeMouseEvent(nsIntPoint aPoint,
@@ -335,12 +351,16 @@ class nsCocoaWindow : public nsBaseWidget, public nsPIWidgetCocoa
335351
PRInt32 mShadowStyle;
336352
NSUInteger mWindowFilter;
337353

354+
WindowAnimationType mAnimationType;
355+
338356
bool mWindowMadeHere; // true if we created the window, false for embedding
339357
bool mSheetNeedsShow; // if this is a sheet, are we waiting to be shown?
340358
// this is used for sibling sheet contention only
341359
bool mFullScreen;
342360
bool mModal;
343361

362+
bool mIsAnimationSuppressed;
363+
344364
bool mInReportMoveEvent; // true if in a call to ReportMoveEvent().
345365

346366
PRInt32 mNumModalDescendents;

widget/cocoa/nsCocoaWindow.mm

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,12 @@ static void RollUpPopups()
135135
, mPopupContentView(nil)
136136
, mShadowStyle(NS_STYLE_WINDOW_SHADOW_DEFAULT)
137137
, mWindowFilter(0)
138+
, mAnimationType(nsIWidget::eGenericWindowAnimation)
138139
, mWindowMadeHere(false)
139140
, mSheetNeedsShow(false)
140141
, mFullScreen(false)
141142
, mModal(false)
143+
, mIsAnimationSuppressed(false)
142144
, mInReportMoveEvent(false)
143145
, mNumModalDescendents(0)
144146
{
@@ -304,6 +306,8 @@ static bool UseNativePopupWindows()
304306
return CreatePopupContentView(newBounds, aHandleEventFunction, aContext);
305307
}
306308

309+
mIsAnimationSuppressed = aInitData->mIsAnimationSuppressed;
310+
307311
return NS_OK;
308312

309313
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
@@ -745,6 +749,26 @@ static unsigned int WindowMaskForBorderStyle(nsBorderStyle aBorderStyle)
745749
}
746750
else {
747751
NS_OBJC_BEGIN_TRY_LOGONLY_BLOCK;
752+
if (mWindowType == eWindowType_toplevel &&
753+
[mWindow respondsToSelector:@selector(setAnimationBehavior:)]) {
754+
NSWindowAnimationBehavior behavior;
755+
if (mIsAnimationSuppressed) {
756+
behavior = NSWindowAnimationBehaviorNone;
757+
} else {
758+
switch (mAnimationType) {
759+
case nsIWidget::eDocumentWindowAnimation:
760+
behavior = NSWindowAnimationBehaviorDocumentWindow;
761+
break;
762+
default:
763+
NS_NOTREACHED("unexpected mAnimationType value");
764+
// fall through
765+
case nsIWidget::eGenericWindowAnimation:
766+
behavior = NSWindowAnimationBehaviorDefault;
767+
break;
768+
}
769+
}
770+
[mWindow setAnimationBehavior:behavior];
771+
}
748772
[mWindow makeKeyAndOrderFront:nil];
749773
NS_OBJC_END_TRY_LOGONLY_BLOCK;
750774
SendSetZLevelEvent();
@@ -1618,6 +1642,11 @@ nsIntRect screenBounds(
16181642
NS_OBJC_END_TRY_ABORT_BLOCK;
16191643
}
16201644

1645+
void nsCocoaWindow::SetWindowAnimationType(nsIWidget::WindowAnimationType aType)
1646+
{
1647+
mAnimationType = aType;
1648+
}
1649+
16211650
NS_IMETHODIMP nsCocoaWindow::SetWindowTitlebarColor(nscolor aColor, bool aActive)
16221651
{
16231652
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;

widget/nsIWidget.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,20 @@ class nsIWidget : public nsISupports {
10171017
*/
10181018
virtual void SetShowsToolbarButton(bool aShow) = 0;
10191019

1020+
enum WindowAnimationType {
1021+
eGenericWindowAnimation,
1022+
eDocumentWindowAnimation
1023+
};
1024+
1025+
/**
1026+
* Sets the kind of top-level window animation this widget should have. On
1027+
* Mac OS X, this causes a particular kind of animation to be shown when the
1028+
* window is first made visible.
1029+
*
1030+
* Ignored on child widgets and on non-Mac platforms.
1031+
*/
1032+
virtual void SetWindowAnimationType(WindowAnimationType aType) = 0;
1033+
10201034
/**
10211035
* Hide window chrome (borders, buttons) for this widget.
10221036
*

widget/nsWidgetInitData.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ struct nsWidgetInitData {
133133
mUnicode(true),
134134
mRTL(false),
135135
mNoAutoHide(false),
136-
mIsDragPopup(false)
136+
mIsDragPopup(false),
137+
mIsAnimationSuppressed(false)
137138
{
138139
}
139140

@@ -148,6 +149,8 @@ struct nsWidgetInitData {
148149
bool mRTL;
149150
bool mNoAutoHide; // true for noautohide panels
150151
bool mIsDragPopup; // true for drag feedback panels
152+
bool mIsAnimationSuppressed; // true if window creation animation is
153+
// suppressed, e.g. for session restore
151154
};
152155

153156
#endif // nsWidgetInitData_h__

widget/xpwidgets/nsBaseWidget.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ class nsBaseWidget : public nsIWidget
123123
virtual void GetWindowClipRegion(nsTArray<nsIntRect>* aRects);
124124
NS_IMETHOD SetWindowShadowStyle(PRInt32 aStyle);
125125
virtual void SetShowsToolbarButton(bool aShow) {}
126+
virtual void SetWindowAnimationType(WindowAnimationType aType) {}
126127
NS_IMETHOD HideWindowChrome(bool aShouldHide);
127128
NS_IMETHOD MakeFullScreen(bool aFullScreen);
128129
virtual nsDeviceContext* GetDeviceContext();

0 commit comments

Comments
 (0)