Closed
Bug 413277
Opened 17 years ago
Closed 14 years ago
window.resizeBy(0, 1000000) throws and asserts
Categories
(Core :: Widget: Cocoa, defect)
Tracking
()
RESOLVED
FIXED
People
(Reporter: jruderman, Assigned: sgreenlay)
References
(Blocks 1 open bug)
Details
(Keywords: assertion, testcase)
Attachments
(2 files, 7 obsolete files)
109 bytes,
text/html
|
Details | |
8.44 KB,
patch
|
jaas
:
review+
|
Details | Diff | Splinter Review |
Steps to reproduce: 1. Allow scripts to resize windows. (Preferences > Content > Advanced) 2. Load the testcase. Expected: The window should be resized to the maximum height allowed. Result: NS_ERROR_FAILURE is thrown, and the window is not resized at all. The following assertion appears in the console: ###!!! ASSERTION: Requested Cocoa window height of 1000593 is too much, max allowed is 100000 : 'Error', file /Users/jruderman/trunk/mozilla/widget/src/cocoa/nsCocoaWindow.mm, line 189
Reporter | ||
Comment 1•17 years ago
|
||
Assignee | ||
Comment 2•14 years ago
|
||
This patch solves the problem by removing the 'WindowSizeAllowed' check on resize (which limits the maximum window size to 100000x100000) and instead bounds the window to the current screen (using 'FitToScreen').
Attachment #478822 -
Flags: review?(joshmoz)
Assignee | ||
Comment 3•14 years ago
|
||
Using [mainScreen visibleFrame] instead of [mainScreen frame] (to prevent small glitches when resizing past visible frame)
Attachment #478822 -
Attachment is obsolete: true
Attachment #478873 -
Flags: review?(joshmoz)
Attachment #478822 -
Flags: review?(joshmoz)
Comment on attachment 478873 [details] [diff] [review] Resize Patch (v1.1) >+static void FitToScreen(nsIntRect &aRect) This function name is too vague. Call it "FitRectToVisibleAreaForScreen" or something like that. >+ NSScreen *mainScreen = [NSScreen mainScreen]; Shouldn't we use the window's screen? The resize constraints will seem arbitrary on a screen that is not the main screen. Maybe make the fit function also take a screen argument and pass "[mWindow screen]". >+ nsIntRect mNewBounds = nsIntRect(aX, aY, aWidth, aHeight); The "m" prefix on variables means "member" - it's used to denote member variables for a class. Don't use it for stack-based variables. Use the name "newBounds" here instead. I think you've got the right idea in general, thanks.
Attachment #478873 -
Flags: review?(joshmoz) → review-
Assignee | ||
Comment 5•14 years ago
|
||
Added above fixes
Attachment #478873 -
Attachment is obsolete: true
Attachment #479120 -
Flags: review?(joshmoz)
Comment on attachment 479120 [details] [diff] [review] Resize Patch (v1.2) Looks good, lets get a second opinion from mstange though.
Attachment #479120 -
Flags: review?(mstange)
Attachment #479120 -
Flags: review?(joshmoz)
Attachment #479120 -
Flags: review+
Comment 7•14 years ago
|
||
What's the reason for clamping to the screen size instead of the old 100000x100000 size? I sometimes make the window wider than the screen to test drawing performance, and I don't know why we should disallow it. In any case, you should use the same numbers in all places where we used WindowSizeAllowed before, i.e. also when creating the window. Then WindowSizeAllowed can be removed. FitRectToVisibleAreaForScreen doesn't need exception guards. It's only called from Objective C++ code which can deal with the exceptions and already protects them from pure C++ code at the relevant entry points. They're slow (see bug 516046 or bug 513493 comment 23) so we shouldn't add them when not necessary.
Assignee | ||
Comment 8•14 years ago
|
||
The reason for clamping the screen size on resizeBy is because some developers (especially those who make unwanted pop-ups) use window.resizeBy(1000000,1000000) in order to make a window fill the users' screen. This does not affect the user simply dragging the window to make it larger then their current screen. Bounding to the current screen is also done by Safari. If we want to keep the current functionality, then we could just cap any resize at the 100000x100000 size.
Comment 9•14 years ago
|
||
(In reply to comment #8) > This does not affect the user simply dragging the window to make it > larger then their current screen. Ah, I see. At least not with the native window resizer. (It would affect it if we were using XUL resizers, which call into nsIWidget::Resize, but we don't use them on Mac, so yeah.) > If we want to keep the current functionality, then we could just cap any resize > at the 100000x100000 size. I'd prefer that.
Assignee | ||
Comment 10•14 years ago
|
||
Attachment #479120 -
Attachment is obsolete: true
Attachment #479538 -
Flags: review?(joshmoz)
Attachment #479120 -
Flags: review?(mstange)
Assignee | ||
Comment 11•14 years ago
|
||
This is the same as the previous patch, but uses the maximum size to bound the window, not the size of the current screen.
Assignee | ||
Comment 12•14 years ago
|
||
From a users' standpoint I would prefer to bound to the current screen (because I can't think of any instance where I would want a window to resize itself outside of my current screen), but from a testing perspective I see the benefit of being able to create large windows through JS. Let me know what solution you want.
Comment 13•14 years ago
|
||
(In reply to comment #8) > The reason for clamping the screen size on resizeBy is because some developers > (especially those who make unwanted pop-ups) use > window.resizeBy(1000000,1000000) in order to make a window fill the users' > screen. I've changed my mind - this is a very persuasive argument for clamping to the screen size. We should do that.
Comment 14•14 years ago
|
||
Comment on attachment 479538 [details] [diff] [review] Resize Patch (v1.3) NS_IMETHODIMP nsCocoaWindow::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint) { NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT; - - if (!WindowSizeAllowed(aWidth, aHeight)) - return NS_ERROR_FAILURE; - + Don't add these two spaces.
Attachment #479538 -
Flags: review+
Comment 15•14 years ago
|
||
Comment on attachment 479538 [details] [diff] [review] Resize Patch (v1.3) Looks good, thanks.
Attachment #479538 -
Flags: review?(joshmoz) → review+
Attachment #479541 -
Attachment is obsolete: true
Assignee | ||
Updated•14 years ago
|
Status: NEW → ASSIGNED
Keywords: checkin-needed
Comment 16•14 years ago
|
||
I have no idea what the other widget implementations do, but has any thought been given to trying to get consistent window size clamping behavior across the three main ones, if possible? Worth a followup bug, perhaps?
Comment 17•14 years ago
|
||
Comment on attachment 479538 [details] [diff] [review] Resize Patch (v1.3) This shouldn't block but it is a nice improvement for 2.0. We should take it.
Attachment #479538 -
Flags: approval2.0+
Comment 18•14 years ago
|
||
We should be able to write a test for this behavior as well.
Assignee | ||
Comment 19•14 years ago
|
||
Turned on for all platforms right now, will disable those that don't pass after tryserver run.
Attachment #483583 -
Flags: review?(joshmoz)
Assignee | ||
Comment 20•14 years ago
|
||
Test fails on linux, filed as bug 604789.
Comment 21•14 years ago
|
||
Comment on attachment 483583 [details] [diff] [review] Resize Test Patch (v1.0) r+, please combine this test with your fix and have the test disabled on Windows and Linux since it doesn't pass there.
Attachment #483583 -
Flags: review?(joshmoz) → review+
Assignee | ||
Comment 22•14 years ago
|
||
Test fails on windows, filed as bug 605178.
Assignee | ||
Comment 23•14 years ago
|
||
Attachment #479538 -
Attachment is obsolete: true
Attachment #483583 -
Attachment is obsolete: true
Attachment #484086 -
Flags: review?(joshmoz)
Attachment #484086 -
Flags: review?(joshmoz) → review+
Attachment #484086 -
Flags: approval2.0+
Comment 24•14 years ago
|
||
pushed to mozilla-central http://hg.mozilla.org/mozilla-central/rev/a2aaf00c4acc
Comment 25•14 years ago
|
||
backed out due to test failures http://hg.mozilla.org/mozilla-central/rev/4ebc35e7695a http://hg.mozilla.org/mozilla-central/rev/9b7e1b761cb7
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Assignee | ||
Comment 26•14 years ago
|
||
Attachment #484086 -
Attachment is obsolete: true
Attachment #485433 -
Flags: review?(joshmoz)
Attachment #485433 -
Flags: review?(joshmoz) → review+
Comment 27•14 years ago
|
||
pushed to mozilla-central again http://hg.mozilla.org/mozilla-central/rev/0fed77757e88
Status: REOPENED → RESOLVED
Closed: 14 years ago → 14 years ago
Resolution: --- → FIXED
Comment 28•14 years ago
|
||
Do reftests on mac still need to create windows bigger than the screen size?
No, we fixed the screen size instead.
Although it would still be nice to be able to create windows bigger than the screen size, for users running reftests on their own machines with small screen sizes.
Comment 31•13 years ago
|
||
This fix causes Mozilla windows to "disappear" offscreen (when the windows are created/instantiated) on multi-screened displays). Please see bug 644733.
You need to log in
before you can comment on or make changes to this bug.
Description
•