summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Geerken <devnull@localhost>2014-10-23 13:56:47 +0200
committerSebastian Geerken <devnull@localhost>2014-10-23 13:56:47 +0200
commit9eaaa3b90cba69593ab664b552ac5f5e4a299140 (patch)
tree2fbd8ad2bad2dca3dfb45b64db3bb123f3954c4d
parent8b633a44f51ecdda001addb99f2474f688920065 (diff)
Fixed drawing of widgets previously (possibly) drawn after interruption.
-rw-r--r--dw/oofawarewidget.cc72
-rw-r--r--dw/oofawarewidget.hh37
-rw-r--r--dw/ooffloatsmgr.cc18
-rw-r--r--dw/oofpositionedmgr.cc16
4 files changed, 85 insertions, 58 deletions
diff --git a/dw/oofawarewidget.cc b/dw/oofawarewidget.cc
index 7cbbc318..8381fcd3 100644
--- a/dw/oofawarewidget.cc
+++ b/dw/oofawarewidget.cc
@@ -27,11 +27,48 @@ using namespace dw::core;
using namespace dw::core::style;
using namespace lout::object;
using namespace lout::misc;
+using namespace lout::container::typed;
namespace dw {
namespace oof {
+OOFAwareWidget::OOFStackingIterator::OOFStackingIterator (bool atEnd)
+{
+ // TODO Consider atEnd.
+ majorLevel = OOFStackingIterator::BACKGROUND;
+ minorLevel = index = 0;
+
+ widgetsDrawnAfterInterruption = NULL;
+}
+
+OOFAwareWidget::OOFStackingIterator::~OOFStackingIterator ()
+{
+ if (widgetsDrawnAfterInterruption)
+ delete widgetsDrawnAfterInterruption;
+}
+
+void OOFAwareWidget::OOFStackingIterator::registerWidgetDrawnAfterInterruption
+ (Widget *widget)
+{
+ if (widgetsDrawnAfterInterruption == NULL)
+ widgetsDrawnAfterInterruption = new HashSet<TypedPointer<Widget> > (true);
+
+ TypedPointer<Widget> *p = new TypedPointer<Widget> (widget);
+ assert (!widgetsDrawnAfterInterruption->contains (p));
+ widgetsDrawnAfterInterruption->put (p);
+}
+
+bool OOFAwareWidget::OOFStackingIterator::hasWidgetBeenDrawnAfterInterruption
+ (Widget *widget)
+{
+ if (widgetsDrawnAfterInterruption) {
+ TypedPointer<Widget> p (widget);
+ return widgetsDrawnAfterInterruption->contains (&p);
+ } else
+ return false;
+}
+
const char *OOFAwareWidget::OOFStackingIterator::majorLevelText (int majorLevel)
{
switch (majorLevel) {
@@ -294,23 +331,6 @@ void OOFAwareWidget::containerSizeChangedForChildrenOOF ()
outOfFlowMgr[i]->containerSizeChangedForChildren ();
}
-bool OOFAwareWidget::doesWidgetOOFInterruptDrawing (Widget *widget,
- OOFAwareWidget *generator,
- OOFAwareWidget *container)
-{
- DBG_OBJ_ENTER_O ("draw", 0, (void*)NULL, "doesWidgetOOFInterruptDrawing",
- "%p, %p, %p", widget, generator, container);
-
- int cl = container->stackingContextWidget->getLevel (),
- gl = generator->stackingContextWidget->getLevel ();
-
- DBG_OBJ_MSGF_O ("draw", 1, (void*)NULL, "%d < %d => %s",
- cl, gl, cl < gl ? "true" : "false");
-
- DBG_OBJ_LEAVE_O ((void*)NULL);
- return cl < gl;
-}
-
bool OOFAwareWidget::doesWidgetOOFInterruptDrawing (Widget *widget)
{
DBG_OBJ_ENTER ("draw", 0, "doesWidgetOOFInterruptDrawing", "%p", widget);
@@ -319,12 +339,14 @@ bool OOFAwareWidget::doesWidgetOOFInterruptDrawing (Widget *widget)
int oofmIndex = getOOFMIndex (widget);
DBG_OBJ_MSGF ("draw", 1, "oofmIndex = %d", oofmIndex);
- bool b =
- doesWidgetOOFInterruptDrawing (widget, this, oofContainer[oofmIndex]);
- DBG_OBJ_MSGF ("draw", 1, "=> %s", b ? "true" : "false");
+ int cl = oofContainer[oofmIndex]->stackingContextWidget->getLevel (),
+ gl = stackingContextWidget->getLevel ();
+
+ DBG_OBJ_MSGF_O ("draw", 1, (void*)NULL, "%d < %d => %s",
+ cl, gl, cl < gl ? "true" : "false");
DBG_OBJ_LEAVE ();
- return b;
+ return cl < gl;
}
Widget *OOFAwareWidget::draw (View *view, Rectangle *area,
@@ -359,6 +381,8 @@ Widget *OOFAwareWidget::draw (View *view, Rectangle *area,
assert (retWidget2 == NULL);
}
+ osi->registerWidgetDrawnAfterInterruption (retWidget);
+
retWidget = NULL; // Continue with the current state of "iterator".
DBG_OBJ_MSG ("draw", 1, "done with interruption");
}
@@ -551,11 +575,7 @@ Widget *OOFAwareWidget::getWidgetAtPoint (int x, int y)
Object *OOFAwareWidget::stackingIterator (bool atEnd)
{
- OOFStackingIterator *osi = new OOFStackingIterator ();
- // TODO Consider atEnd.
- osi->majorLevel = OOFStackingIterator::BACKGROUND;
- osi->minorLevel = osi->index = 0;
- return osi;
+ return new OOFStackingIterator (atEnd);
}
void OOFAwareWidget::borderChanged (int y, Widget *vloat)
diff --git a/dw/oofawarewidget.hh b/dw/oofawarewidget.hh
index 231be48d..20a482f3 100644
--- a/dw/oofawarewidget.hh
+++ b/dw/oofawarewidget.hh
@@ -104,18 +104,6 @@ protected:
bool prev ();
};
- class OOFStackingIterator: public lout::object::Object
- {
- public:
- enum { START, BACKGROUND, SC_BOTTOM, IN_FLOW, OOF_REF, OOF_CONT, SC_TOP,
- END } ;
- int majorLevel, minorLevel, index;
-
- void intoStringBuffer(lout::misc::StringBuffer *sb);
-
- static const char *majorLevelText (int majorLevel4);
- };
-
inline bool isParentRefOOF (int parentRef)
{ return parentRef != -1 && (parentRef & PARENT_REF_OOFM_MASK); }
@@ -205,12 +193,31 @@ protected:
public:
static int CLASS_ID;
+ class OOFStackingIterator: public lout::object::Object
+ {
+ private:
+ lout::container::typed::HashSet<lout::object::TypedPointer<Widget> >
+ *widgetsDrawnAfterInterruption;
+
+ public:
+ enum { START, BACKGROUND, SC_BOTTOM, IN_FLOW, OOF_REF, OOF_CONT, SC_TOP,
+ END } ;
+ int majorLevel, minorLevel, index;
+
+ static const char *majorLevelText (int majorLevel);
+
+ OOFStackingIterator (bool atEnd);
+ ~OOFStackingIterator ();
+
+ void intoStringBuffer(lout::misc::StringBuffer *sb);
+
+ void registerWidgetDrawnAfterInterruption (Widget *widget);
+ bool hasWidgetBeenDrawnAfterInterruption (Widget *widget);
+ };
+
OOFAwareWidget ();
~OOFAwareWidget ();
- static bool doesWidgetOOFInterruptDrawing (Widget *widget,
- OOFAwareWidget *generator,
- OOFAwareWidget *container);
bool doesWidgetOOFInterruptDrawing (Widget *widget);
Widget *draw (core::View *view, core::Rectangle *area,
diff --git a/dw/ooffloatsmgr.cc b/dw/ooffloatsmgr.cc
index 5373d84c..3bddbb34 100644
--- a/dw/ooffloatsmgr.cc
+++ b/dw/ooffloatsmgr.cc
@@ -1307,21 +1307,21 @@ Widget *OOFFloatsMgr::drawFloats (SortedFloatsVector *list, View *view,
// first float fitting into the area, and iterate until one is
// found below the area.
+ OOFAwareWidget::OOFStackingIterator *osi =
+ (OOFAwareWidget::OOFStackingIterator*)iteratorStack->getTop ();
Widget *retWidget = NULL;
while (retWidget == NULL && *index - startIndex < list->size()) {
Float *vloat = list->get(*index - startIndex);
Widget *childWidget = vloat->getWidget ();
- if (!OOFAwareWidget:: doesWidgetOOFInterruptDrawing
- (childWidget, vloat->generatingBlock, container)) {
- Rectangle childArea;
- if (!StackingContextMgr::handledByStackingContextMgr (childWidget) &&
- childWidget->intersects (area, &childArea))
- retWidget =
- childWidget->drawTotal (view, &childArea, iteratorStack);
- }
-
+ Rectangle childArea;
+ if (!osi->hasWidgetBeenDrawnAfterInterruption (childWidget) &&
+ !StackingContextMgr::handledByStackingContextMgr (childWidget) &&
+ childWidget->intersects (area, &childArea))
+ retWidget =
+ childWidget->drawTotal (view, &childArea, iteratorStack);
+
if (retWidget == NULL)
(*index)++;
}
diff --git a/dw/oofpositionedmgr.cc b/dw/oofpositionedmgr.cc
index c0c31417..8c322333 100644
--- a/dw/oofpositionedmgr.cc
+++ b/dw/oofpositionedmgr.cc
@@ -175,19 +175,19 @@ Widget *OOFPositionedMgr::draw (View *view, Rectangle *area,
DBG_OBJ_ENTER ("draw", 0, "draw", "(%d, %d, %d * %d), [%d]",
area->x, area->y, area->width, area->height, *index);
+ OOFAwareWidget::OOFStackingIterator *osi =
+ (OOFAwareWidget::OOFStackingIterator*)iteratorStack->getTop ();
Widget *retWidget = NULL;
while (retWidget == NULL && *index < children->size()) {
Child *child = children->get(*index);
- if (!OOFAwareWidget:: doesWidgetOOFInterruptDrawing
- (child->widget, child->generator, container)) {
- Rectangle childArea;
- if (!StackingContextMgr::handledByStackingContextMgr (child->widget) &&
- child->widget->intersects (area, &childArea))
- retWidget =
- child->widget->drawTotal (view, &childArea, iteratorStack);
- }
+ Rectangle childArea;
+ if (!osi->hasWidgetBeenDrawnAfterInterruption (child->widget) &&
+ !StackingContextMgr::handledByStackingContextMgr (child->widget) &&
+ child->widget->intersects (area, &childArea))
+ retWidget =
+ child->widget->drawTotal (view, &childArea, iteratorStack);
if (retWidget == NULL)
(*index)++;