Bug 1239743: Do not allow windows to be resized to sizes above the maximum texture size. We don't know how to draw to these anyway. r=jmathies
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -184,16 +184,17 @@
#endif
#if !defined(WM_DPICHANGED)
#define WM_DPICHANGED 0x02E0
#endif
#include "mozilla/layers/APZCTreeManager.h"
#include "mozilla/layers/InputAPZContext.h"
+#include "ClientLayerManager.h"
#include "InputData.h"
#include "mozilla/Telemetry.h"
using namespace mozilla;
using namespace mozilla::dom;
using namespace mozilla::gfx;
using namespace mozilla::layers;
@@ -1405,16 +1406,30 @@ BOOL CALLBACK nsWindow::RegisterTouchFor
void
nsWindow::SetSizeConstraints(const SizeConstraints& aConstraints)
{
SizeConstraints c = aConstraints;
if (mWindowType != eWindowType_popup) {
c.mMinSize.width = std::max(int32_t(::GetSystemMetrics(SM_CXMINTRACK)), c.mMinSize.width);
c.mMinSize.height = std::max(int32_t(::GetSystemMetrics(SM_CYMINTRACK)), c.mMinSize.height);
}
+ ClientLayerManager *clientLayerManager =
+ (GetLayerManager()->GetBackendType() == LayersBackend::LAYERS_CLIENT)
+ ? static_cast<ClientLayerManager*>(GetLayerManager())
+ : nullptr;
+
+ if (clientLayerManager) {
+ int32_t maxSize = clientLayerManager->GetMaxTextureSize();
+ // We can't make ThebesLayers bigger than this anyway.. no point it letting
+ // a window grow bigger as we won't be able to draw content there in
+ // general.
+ c.mMaxSize.width = std::min(c.mMaxSize.width, maxSize);
+ c.mMaxSize.height = std::min(c.mMaxSize.height, maxSize);
+ }
+
mSizeConstraintsScale = GetDefaultScale().scale;
nsBaseWidget::SetSizeConstraints(c);
}
const SizeConstraints
nsWindow::GetSizeConstraints()
{