aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dw/oofawarewidget.cc61
-rw-r--r--dw/oofawarewidget.hh4
-rw-r--r--dw/textblock.cc10
-rw-r--r--dw/textblock.hh2
4 files changed, 52 insertions, 25 deletions
diff --git a/dw/oofawarewidget.cc b/dw/oofawarewidget.cc
index e5e6aa2f..5747b78e 100644
--- a/dw/oofawarewidget.cc
+++ b/dw/oofawarewidget.cc
@@ -21,10 +21,6 @@
#include "ooffloatsmgr.hh"
#include "oofposabsmgr.hh"
#include "oofposfixedmgr.hh"
-#include "textblock.hh"
-
-// TODO: Avoid reference to Textblock by replacing
-// "instanceOf (Textblock::CLASS_ID)" by some new methods.
using namespace dw;
using namespace dw::core;
@@ -58,28 +54,35 @@ void OOFAwareWidget::notifySetAsTopLevel()
= oofContainer[OOFM_FIXED] = this;
}
-bool OOFAwareWidget::isContainingBlock (Widget *widget, int oofmIndex)
+bool OOFAwareWidget::isOOFContainer (Widget *widget, int oofmIndex)
{
+ // TODO The methods isPossibleContainer() and isPossibleContainerParent()
+ // are only used in few cases. Does not matter currently, however.
+
switch (oofmIndex) {
case OOFM_FLOATS:
- return
- // For floats, only textblocks are considered as containing
- // blocks.
- widget->instanceOf (Textblock::CLASS_ID) &&
- // The second condition: that this block is "out of flow", in a
- // wider sense.
- (// The toplevel widget is "out of flow", since there is no
- // parent, and so no context.
- widget->getParent() == NULL ||
- // A similar reasoning applies to a widget with another parent
- // than a textblock (typical example: a table cell (this is
- // also a text block) within a table widget).
- !widget->getParent()->instanceOf (Textblock::CLASS_ID) ||
- // Inline blocks are containing blocks, too.
- widget->getStyle()->display == core::style::DISPLAY_INLINE_BLOCK ||
- // Finally, "out of flow" in a narrower sense: floats; absolutely
- // and fixedly positioned elements.
- testWidgetOutOfFlow (widget));
+ return widget->instanceOf (OOFAwareWidget::CLASS_ID) &&
+ (// For floats, only some OOF aware widgets are considered as
+ // containers.
+ ((OOFAwareWidget*)widget)->isPossibleContainer (OOFM_FLOATS) &&
+ // The second condition: that this block is "out of flow", in a
+ // wider sense.
+ (// The toplevel widget is "out of flow", since there is no
+ // parent, and so no context.
+ widget->getParent() == NULL ||
+ // A similar reasoning applies to a widget with an
+ // unsuitable parent (typical example: a table cell (this
+ // is also a text block, so possible float container)
+ // within a table widget, which is not a suitable float
+ // container parent).
+ !(widget->getParent()->instanceOf (OOFAwareWidget::CLASS_ID) &&
+ ((OOFAwareWidget*)widget->getParent())
+ ->isPossibleContainerParent (OOFM_FLOATS)) ||
+ // Inline blocks are containing blocks, too.
+ widget->getStyle()->display == core::style::DISPLAY_INLINE_BLOCK ||
+ // Finally, "out of flow" in a narrower sense: floats; absolutely
+ // and fixedly positioned elements.
+ testWidgetOutOfFlow (widget)));
case OOFM_ABSOLUTE:
// Only the toplevel widget (as for all) as well as absolutely,
@@ -124,7 +127,7 @@ void OOFAwareWidget::notifySetParent ()
for (Widget *widget = this;
widget != NULL && oofContainer[oofmIndex] == NULL;
widget = widget->getParent ())
- if (isContainingBlock (widget, oofmIndex)) {
+ if (isOOFContainer (widget, oofmIndex)) {
assert (widget->instanceOf (OOFAwareWidget::CLASS_ID));
oofContainer[oofmIndex] = (OOFAwareWidget*)widget;
}
@@ -199,6 +202,16 @@ int OOFAwareWidget::getLineBreakWidth ()
return 0;
}
+bool OOFAwareWidget::isPossibleContainer (int oofmIndex)
+{
+ return oofmIndex != OOFM_FLOATS;
+}
+
+bool OOFAwareWidget::isPossibleContainerParent (int oofmIndex)
+{
+ return oofmIndex != OOFM_FLOATS;
+}
+
} // namespace oof
} // namespace dw
diff --git a/dw/oofawarewidget.hh b/dw/oofawarewidget.hh
index 13f16162..7121f9ea 100644
--- a/dw/oofawarewidget.hh
+++ b/dw/oofawarewidget.hh
@@ -49,7 +49,7 @@ protected:
void notifySetAsTopLevel();
void notifySetParent();
- static bool isContainingBlock (Widget *widget, int oofmIndex);
+ static bool isOOFContainer (Widget *widget, int oofmIndex);
public:
static int CLASS_ID;
@@ -60,6 +60,8 @@ public:
virtual void borderChanged (int y, core::Widget *vloat);
virtual void oofSizeChanged (bool extremesChanged);
virtual int getLineBreakWidth (); // Should perhaps be renamed.
+ virtual bool isPossibleContainer (int oofmIndex);
+ virtual bool isPossibleContainerParent (int oofmIndex);
};
} // namespace oof
diff --git a/dw/textblock.cc b/dw/textblock.cc
index 566bd9f6..64f5fc23 100644
--- a/dw/textblock.cc
+++ b/dw/textblock.cc
@@ -3025,6 +3025,16 @@ int Textblock::getLineBreakWidth ()
return lineBreakWidth;
}
+bool Textblock::isPossibleContainer (int oofmIndex)
+{
+ return true;
+}
+
+bool Textblock::isPossibleContainerParent (int oofmIndex)
+{
+ return true;
+}
+
Textblock *Textblock::getTextblockForLine (Line *line)
{
return getTextblockForLine (line->firstWord, line->lastWord);
diff --git a/dw/textblock.hh b/dw/textblock.hh
index 4c1810e6..dc496550 100644
--- a/dw/textblock.hh
+++ b/dw/textblock.hh
@@ -880,6 +880,8 @@ public:
void borderChanged (int y, core::Widget *vloat);
void oofSizeChanged (bool extremesChanged);
int getLineBreakWidth ();
+ bool isPossibleContainer (int oofmIndex);
+ bool isPossibleContainerParent (int oofmIndex);
};
#define DBG_SET_WORD_PENALTY(n, i, is) \