Closed
Bug 347452
Opened 18 years ago
Closed 17 years ago
add native resize animation support to nsIDOMChromeWindow
Categories
(Core :: DOM: Core & HTML, enhancement)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
WONTFIX
People
(Reporter: jaas, Assigned: jaas)
References
Details
Attachments
(1 file, 8 obsolete files)
13.98 KB,
patch
|
jst
:
review+
pavlov
:
superreview+
|
Details | Diff | Splinter Review |
I'd like to propose adding native resize animation support to nsIDOMChromeWindow. This would allow chrome windows to resize themselves using different animation techniques. Any platform that does not implement a given animation technique should just do a normal resize when the unimplemented technique is requested. That way we can implement animation techniques for different platforms as it becomes necessary and as we have the resources to do so. The basic animation, which we should implement first, is the type used by Mac OS X preference windows (see the System Preferences window when switching between pref panes). We can use that immediately in the Firefox preferences on Mac OS X to provide smooth animation without a lot of nasty js code (see the js for animation in toolkit/content/widgets/preferences.xml). Right now the animation isn't very smooth under Carbon widgets, and it is horrible under Cocoa widgets. Due to the way Cocoa window origins work, there isn't a good way to animate the resize without using the native Mac OS X window animation API, which the new API I'm proposing allows us to do.
This fix works well, but it does not include API stubs for platforms other than Mac OS X Cocoa widgets. This is the API support only, it does not include any consumer code.
This causes preferences to become a consumer of the new API. This is clearly not the best way to write the consumer code for preferences widgets, but it is simple and enough to work as a good example of native resize animation API usage.
This is the same as v1.0, it just includes an additional animation type, fade, as an example of other things we could do. This is also Cocoa widgets only.
Comment 4•18 years ago
|
||
Comment on attachment 232222 [details] [diff] [review] fix v1.0 (Mac OS X only) >Index: dom/public/idl/base/nsIDOMChromeWindow.idl>+ >+ const unsigned short ANIMATION_OFF = 1; >+ const unsigned short ANIMATION_SLIDE = 2; I think these should be named RESIZE_ANIMATION_*, and RESIZE_ANIMATION_OFF should be 0. >Index: dom/src/base/nsGlobalWindow.cpp > NS_IMETHODIMP >+nsGlobalChromeWindow::SetAnimatedResize(PRUint16 aAnimation) [...] >+ widget->SetAnimatedResize(aAnimation); >+ return NS_OK; return widget->SetAnimatedResize(aAnimation); Same comment applies to: >+NS_IMETHODIMP >+nsGlobalChromeWindow::GetAnimatedResize(PRUint16* aAnimation) [...] >+ widget->GetAnimatedResize(aAnimation); >+ return NS_OK; >Index: widget/src/cocoa/nsChildView.mm >+NS_IMETHODIMP nsChildView::SetAnimatedResize(PRUint16 aAnimation) >+{ >+ return NS_OK; NS_ERROR_NOT_IMPLEMENTED? Same comment applies to: >+NS_IMETHODIMP nsChildView::GetAnimatedResize(PRUint16* aAnimation) >+{ >+ return NS_OK; >Index: widget/src/cocoa/nsCocoaWindow.h > PRPackedBool mIsResizing; // we originated the resize, prevent infinite recursion > PRPackedBool mWindowMadeHere; // true if we created the window, false for embedding >- PRPackedBool mVisible; // Whether or not we're visible. >+ PRPackedBool mVisible; // whether or not we're visible. > PRPackedBool mSheetNeedsShow; // if this is a sheet, are we waiting to be shown? >+ PRPackedBool mAnimation; // whether or not we should animate resizes PRUint16, not PRPackedBool. Because it's a wider type, move the declaration above the PRPackedBool declarations. >Index: widget/src/cocoa/nsCocoaWindow.mm > , mWindow(nil) > , mDelegate(nil) > , mSheetWindowParent(nil) > , mPopupContentView(nil) > , mIsResizing(PR_FALSE) > , mWindowMadeHere(PR_FALSE) > , mVisible(PR_FALSE) > , mSheetNeedsShow(PR_FALSE) >+, mAnimation(nsIDOMChromeWindow::ANIMATION_OFF) This will need to move up too. >+ if (mAnimation == nsIDOMChromeWindow::ANIMATION_SLIDE) { >+ [[mWindow contentView] setHidden:YES]; >+ [mWindow setFrame:newFrame display:YES animate:YES]; >+ [[mWindow contentView] setHidden:NO]; What's with the setHidden business? >+ } >+ else { >+ [mWindow setFrame:newFrame display:NO]; >+ } Could we just do this? [mWindow setFrame:newFrame display:YES animate:(mAnimation == nsIDOMChromeWindow::ANIMATION_SLIDE)]; Does this call block until the animated resize is complete? One way to check would be to override [(NSWindow) animationResizeTime:]. I'd prefer non-blocking. Your ANIMATION_FADE code from the later patch was blocking for sure. In Carbon, you can do non-blocking window transitions by sticking management into the event loop. You make a single call that takes care of this for you. Would it be possible to do that here? Also, 0.2s is standard for a fade-in or fade-out transition. I'm not sure if 0.3s to do both would seem too long or too short. It sounds about right, but you might want to check against other fades. Consumers of this API might want a way to determine if animated resizes are supported or not. It may be enough for the prefs code to fetch or set the animatedResize property in a try block, and fall back to the JS that steps through the sizes if animatedResize isn't implemented. This strategy relies on throwing NS_ERROR_NOT_IMPLEMENTED from nsIWidget::Resize on platforms (or for widgets) that don't implment native resize. You should add @throws (and @return) to the comments in nsIDOMChromeWindow and nsIWidget to make this clear, if this is the way you'd like to go.
Attachment #232222 -
Flags: review?(mark) → review-
This addresses Mark's comments and fixes up some of the math in the fading. I'm not sure why we'd want this to be non-blocking. I wouldn't want somebody dealing with the window size while the window is in an odd transitional state.
Attachment #232222 -
Attachment is obsolete: true
Attachment #232365 -
Attachment is obsolete: true
Attachment #233739 -
Flags: review?(mark)
Attachment #232223 -
Attachment is obsolete: true
Comment 7•18 years ago
|
||
We'd want non-blocking because it's evil for the main thread to go to sleep. Ideally, the window would be internally resized to the new size immediately when the resize call returns, so it's harmless to draw into the window, but the effect would take place asynchronously over time. If consumers need to know when the effect is complete, they should be notified.
I order to deal with the blocking situation for now I suggest just removing the FADE option from the patch. We don't actually need that I was just throwing it in there to show another option.
Comment 9•18 years ago
|
||
Comment on attachment 233739 [details] [diff] [review] fix v1.1 (Mac OS X only) OK, I guess we could go with this. Let's leave the fade stuff out for now.
Attachment #233739 -
Flags: review?(mark) → review+
Comment 10•18 years ago
|
||
Comment on attachment 233739 [details] [diff] [review] fix v1.1 (Mac OS X only) OK, I guess we could go with this. Let's leave the fade stuff out for now.
Assignee | ||
Comment 11•18 years ago
|
||
doesn't have Fade option in it
Attachment #233739 -
Attachment is obsolete: true
Attachment #235250 -
Flags: review?(mark)
Updated•18 years ago
|
Attachment #235250 -
Flags: review?(mark) → review+
Assignee | ||
Comment 12•18 years ago
|
||
This patch doesn't work. It is for reference only.
Assignee | ||
Comment 13•18 years ago
|
||
updated so it applies/builds on trunk
Attachment #235250 -
Attachment is obsolete: true
Assignee | ||
Comment 14•17 years ago
|
||
Updated to current trunk.
Attachment #247588 -
Attachment is obsolete: true
Attachment #260416 -
Flags: review?(stanshebs)
Assignee | ||
Comment 15•17 years ago
|
||
Comment on attachment 260416 [details] [diff] [review] fix v1.1.3 Requesting sr, but I won't land this until a consumer patch is ready.
Attachment #260416 -
Flags: review?(stanshebs) → superreview?(pavlov)
Assignee | ||
Comment 16•17 years ago
|
||
There is a patch in bug 355177 that works well using this API.
Updated•17 years ago
|
Attachment #239670 -
Attachment is obsolete: true
Updated•17 years ago
|
Attachment #233740 -
Attachment is obsolete: true
Comment 17•17 years ago
|
||
Comment on attachment 260416 [details] [diff] [review] fix v1.1.3 this looks ok to me but should have jst or jonas or someone familiar with dom/chrome/etc review it
Attachment #260416 -
Flags: review?(jst)
Comment 18•17 years ago
|
||
Comment on attachment 260416 [details] [diff] [review] fix v1.1.3 Looks good to me.
Attachment #260416 -
Flags: review?(jst) → review+
Updated•17 years ago
|
Attachment #260416 -
Flags: superreview?(pavlov) → superreview+
Assignee | ||
Comment 19•17 years ago
|
||
landed on trunk with stub NS_ERROR_NOT_IMPLEMENTED in nsBaseWidget for platforms that don't implement native resize animation
Status: ASSIGNED → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Comment 20•17 years ago
|
||
This was backed-out in bug 393117.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Updated•17 years ago
|
Status: REOPENED → RESOLVED
Closed: 17 years ago → 17 years ago
Resolution: --- → WONTFIX
Updated•5 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•