From c2629b5f08a874109ac0b22cb21ed0fc79bc6531 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Thu, 14 Nov 2024 19:54:37 +0100 Subject: [PATCH 1/2] Only limit resizes on the top-level layout Buttons also have their own Layout, which will try to resize every time the window has changed. We are only interested in the top-level layout, as is the one that has a problem on some pages. --- dw/layout.cc | 5 +++-- dw/layout.hh | 3 ++- dw/ui.cc | 4 +++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/dw/layout.cc b/dw/layout.cc index 4a5be74e..ed6f55db 100644 --- a/dw/layout.cc +++ b/dw/layout.cc @@ -255,7 +255,7 @@ Layout::Anchor::~Anchor () // --------------------------------------------------------------------- -Layout::Layout (Platform *platform) +Layout::Layout (Platform *platform, bool limit) { this->platform = platform; view = NULL; @@ -308,6 +308,7 @@ Layout::Layout (Platform *platform) resizeIdleCounter = queueResizeCounter = sizeAllocateCounter = sizeRequestCounter = getExtremesCounter = resizeCounter = 0; + resizeLimit = limit; } Layout::~Layout () @@ -882,7 +883,7 @@ void Layout::resizeIdle () /* Prevent infinite resize loop, if we reach this point it is very likely * there is a bug in the layouting process */ - if (resizeCounter >= 1000) { + if (resizeLimit && resizeCounter >= 1000) { MSG_ERR("Emergency layout stop after %d iterations\n", resizeCounter); MSG_ERR("Please file a bug report with the complete console output\n"); resizeIdleId = -1; diff --git a/dw/layout.hh b/dw/layout.hh index e2b64901..08360e19 100644 --- a/dw/layout.hh +++ b/dw/layout.hh @@ -247,12 +247,13 @@ private: int resizeIdleCounter, queueResizeCounter, sizeAllocateCounter, sizeRequestCounter, getExtremesCounter, resizeCounter; + bool resizeLimit; void enterResizeIdle () { resizeIdleCounter++; } void leaveResizeIdle () { resizeIdleCounter--; } public: - Layout (Platform *platform); + Layout (Platform *platform, bool limit=true); ~Layout (); inline void connectLink (LinkReceiver *receiver) diff --git a/dw/ui.cc b/dw/ui.cc index 540ead8f..f14d27aa 100644 --- a/dw/ui.cc +++ b/dw/ui.cc @@ -2,6 +2,7 @@ * Dillo Widget * * Copyright 2005-2007 Sebastian Geerken + * Copyright 2024 Rodrigo Arias Mallo * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -343,7 +344,8 @@ void ComplexButtonResource::init (Widget *widget) { childWidget = widget; - layout = new Layout (createPlatform ()); + /* FIXME: Buttons should not need a full Layout */ + layout = new Layout (createPlatform (), false); setLayout (layout); DBG_OBJ_ASSOC_CHILD (layout); layout->setWidget (widget); From 318d1f14e699e8dd38b73fbe2f8da1c0586ccab7 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Thu, 14 Nov 2024 19:56:41 +0100 Subject: [PATCH 2/2] Reset resize counter when viewport size changes To prevent the page from triggering the emergency stop at resizeIdle(), we reset the resize counter when the viewport is resized. Fixes: https://github.com/dillo-browser/dillo/issues/300 --- dw/layout.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/dw/layout.cc b/dw/layout.cc index ed6f55db..33c3e75d 100644 --- a/dw/layout.cc +++ b/dw/layout.cc @@ -1329,6 +1329,7 @@ void Layout::viewportSizeChanged (View *view, int width, int height) canvasHeightGreater = false; // reset value here viewportWidth = width; viewportHeight = height; + resizeCounter = 0; containerSizeChanged (); DBG_OBJ_SET_SYM ("canvasHeightGreater",