aboutsummaryrefslogtreecommitdiff
path: root/dw
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2010-04-29 15:36:43 +0200
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2010-04-29 15:36:43 +0200
commita12f41162beec5d3aead82a53b38e1e6955c9fbf (patch)
tree51059e48ce28ebac80b0a0011ce23f065264a804 /dw
parentcb1fa27648c91dcbcfe0cfb86e2bf379e98f1463 (diff)
fix redraw optimization
When a widget changes it's height, this may affect the position of other words in the same line. Take care by only applying the redraw optimization if there are no other words in the line. This special case is quite common e.g with nested <div>'s or table based layouts and the redraw optimization avoids unnecessary redraws. Reported by: Dennis Nezic
Diffstat (limited to 'dw')
-rw-r--r--dw/textblock.cc27
1 files changed, 20 insertions, 7 deletions
diff --git a/dw/textblock.cc b/dw/textblock.cc
index d22b9726..3e188cab 100644
--- a/dw/textblock.cc
+++ b/dw/textblock.cc
@@ -397,14 +397,27 @@ void Textblock::sizeAllocateImpl (core::Allocation *allocation)
* child might be a table covering the whole page so we would
* end up redrawing the whole screen over and over.
* The drawing of the child content is left to the child itself.
+ * However this optimization is only possible if the widget is
+ * the only word in the line apart from an optional BREAK.
+ * Otherwise the height change of the widget could change the
+ * position of other words in the line, requiring a
+ * redraw of the complete line.
*/
- int childChangedY =
- misc::min(childAllocation.y - allocation->y +
- childAllocation.ascent + childAllocation.descent,
- oldChildAllocation->y - this->allocation.y +
- oldChildAllocation->ascent + oldChildAllocation->descent);
-
- redrawY = misc::min (redrawY, childChangedY);
+ if (line->lastWord == line->firstWord ||
+ (line->lastWord == line->firstWord + 1 &&
+ words->getRef (line->lastWord)->content.type ==
+ core::Content::BREAK)) {
+
+ int childChangedY =
+ misc::min(childAllocation.y - allocation->y +
+ childAllocation.ascent + childAllocation.descent,
+ oldChildAllocation->y - this->allocation.y +
+ oldChildAllocation->ascent + oldChildAllocation->descent);
+
+ redrawY = misc::min (redrawY, childChangedY);
+ } else {
+ redrawY = misc::min (redrawY, lineYOffsetWidget (line));
+ }
}
word->content.widget->sizeAllocate (&childAllocation);