mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-01 17:23:59 +00:00
Bug 1448208: Use CheckedInt for overflow check in nsWindowWatcher::SizeOpenedWindow. r=froydnj
--HG-- extra : rebase_source : 5781b2086ee7af0b211fb28d2fda02f433ecbbca
This commit is contained in:
parent
750b04b27f
commit
198ddd8ab8
@ -9,6 +9,5 @@ skip-if = (toolkit == "cocoa" && e10s) # bug 1252223
|
||||
[test_private_window_from_content.html]
|
||||
[test_window_open_position_constraint.html]
|
||||
skip-if = toolkit == 'android'
|
||||
fail-if = (os == "win" && ccov) # bug 1421715
|
||||
[test_window_open_units.html]
|
||||
skip-if = toolkit == 'android'
|
||||
|
@ -59,6 +59,7 @@
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsSandboxFlags.h"
|
||||
#include "mozilla/CheckedInt.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/Storage.h"
|
||||
@ -2368,19 +2369,26 @@ nsWindowWatcher::SizeOpenedWindow(nsIDocShellTreeOwner* aTreeOwner,
|
||||
}
|
||||
}
|
||||
|
||||
if (left + winWidth > screenLeft + screenWidth ||
|
||||
left + winWidth < left) {
|
||||
CheckedInt<decltype(left)> leftPlusWinWidth = left;
|
||||
leftPlusWinWidth += winWidth;
|
||||
if (!leftPlusWinWidth.isValid() ||
|
||||
leftPlusWinWidth.value() > screenLeft + screenWidth) {
|
||||
left = screenLeft + screenWidth - winWidth;
|
||||
}
|
||||
if (left < screenLeft) {
|
||||
left = screenLeft;
|
||||
}
|
||||
if (top + winHeight > screenTop + screenHeight || top + winHeight < top) {
|
||||
|
||||
CheckedInt<decltype(top)> topPlusWinHeight = top;
|
||||
topPlusWinHeight += winHeight;
|
||||
if (!topPlusWinHeight.isValid() ||
|
||||
topPlusWinHeight.value() > screenTop + screenHeight) {
|
||||
top = screenTop + screenHeight - winHeight;
|
||||
}
|
||||
if (top < screenTop) {
|
||||
top = screenTop;
|
||||
}
|
||||
|
||||
if (top != oldTop || left != oldLeft) {
|
||||
positionSpecified = true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user